-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for User Defined kid
on KeyManagerCreate
#1353
Comments
@radleylewis Where's the diff for the diff --git a/packages/core-types/src/plugin.schema.ts b/packages/core-types/src/plugin.schema.ts
index 738bf62a..0ebabe75 100644
--- a/packages/core-types/src/plugin.schema.ts
+++ b/packages/core-types/src/plugin.schema.ts
@@ -537,6 +537,10 @@ export const schema = {
"type": "string",
"description": "Key Management System"
},
+ "kid": {
+ "type": "string",
+ "description": "Key ID"
+ },
"meta": {
"$ref": "#/components/schemas/KeyMetadata",
"description": "Optional. Key meta data"
diff --git a/packages/core-types/src/types/IKeyManager.ts b/packages/core-types/src/types/IKeyManager.ts
index 939c43c6..f0e820c8 100644
--- a/packages/core-types/src/types/IKeyManager.ts
+++ b/packages/core-types/src/types/IKeyManager.ts
@@ -38,6 +38,11 @@ export interface IKeyManagerCreateArgs {
*/
kms: string
+ /**
+ * Key ID
+ */
+ kid?: string
+
/**
* Optional. Key meta data
*/
diff --git a/packages/key-manager/src/key-manager.ts b/packages/key-manager/src/key-manager.ts
index 21088ff3..1ba68ba6 100644
--- a/packages/key-manager/src/key-manager.ts
+++ b/packages/key-manager/src/key-manager.ts
@@ -22,7 +22,7 @@ import * as u8a from 'uint8arrays'
import { createAnonDecrypter, createAnonEncrypter, createJWE, decryptJWE, type ECDH, type JWE } from 'did-jwt'
import { convertEd25519PublicKeyToX25519 } from '@veramo/utils'
import Debug from 'debug'
-import {getBytes, hexlify, toUtf8Bytes, toUtf8String, computeAddress, Transaction} from "ethers";
+import { getBytes, hexlify, toUtf8Bytes, toUtf8String, computeAddress, Transaction } from 'ethers'
const debug = Debug('veramo:key-manager')
@@ -87,7 +87,8 @@ export class KeyManager implements IAgentPlugin {
async keyManagerCreate(args: IKeyManagerCreateArgs): Promise<ManagedKeyInfo> {
const kms = this.getKms(args.kms)
const partialKey = await kms.createKey({ type: args.type, meta: args.meta })
- const key: IKey = { ...partialKey, kms: args.kms }
+
+ const key: IKey = { ...partialKey, kms: args.kms, kid: args.kid ?? partialKey.kid }
if (args.meta || key.meta) {
key.meta = { ...args.meta, ...key.meta }
} |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Problem
Presently, the
keyManagerCreate
method automatically generates akid
. However, there are plausible use-cases whereby the user may wish to define this manually.Solution
The solution to this current limitation requires only basic changes to the code, which would not be breaking (noting that the provision of a manual
kid
would be optional and would be provided in thekeyManagerCreateArgs
(see below diff):The text was updated successfully, but these errors were encountered: