Skip to content

Commit

Permalink
feat(key-manager): allow user defined kid on keyManagerCreate (#1426)
Browse files Browse the repository at this point in the history
fixes #1353
  • Loading branch information
0x62 authored Oct 30, 2024
1 parent 06882b9 commit 0784df0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/core-types/src/plugin.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,10 @@ export const schema = {
"meta": {
"$ref": "#/components/schemas/KeyMetadata",
"description": "Optional. Key meta data"
},
"kid": {
"type": "string",
"description": "Key ID"
}
},
"required": [
Expand Down
5 changes: 5 additions & 0 deletions packages/core-types/src/types/IKeyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export interface IKeyManagerCreateArgs {
* Optional. Key meta data
*/
meta?: KeyMetadata

/**
* Optional. Key ID
*/
kid?: string;
}

/**
Expand Down
6 changes: 5 additions & 1 deletion packages/key-manager/src/key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ 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 }
}
Expand Down

0 comments on commit 0784df0

Please sign in to comment.