@sphereon/ssi-sdk-ext.key-manager 0.13.0 → 0.13.1-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/SphereonKeyManager.d.ts +4 -2
- package/dist/agent/SphereonKeyManager.d.ts.map +1 -1
- package/dist/agent/SphereonKeyManager.js +15 -1
- package/dist/agent/SphereonKeyManager.js.map +1 -1
- package/dist/ssi-sdk-ext.key-manager.d.ts +23 -23
- package/dist/types/ISphereonKeyManager.d.ts +12 -14
- package/dist/types/ISphereonKeyManager.d.ts.map +1 -1
- package/package.json +3 -3
- package/plugin.schema.json +78 -136
- package/src/agent/SphereonKeyManager.ts +19 -4
- package/src/types/ISphereonKeyManager.ts +19 -15
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { KeyManager, AbstractKeyManagementSystem, AbstractKeyStore } from '@veramo/key-manager';
|
|
2
|
-
import {
|
|
2
|
+
import { ISphereonKeyManager, ISphereonKeyManagerSignArgs, ISphereonKeyManagerVerifyArgs } from '../types/ISphereonKeyManager';
|
|
3
3
|
export declare class SphereonKeyManager extends KeyManager {
|
|
4
4
|
private localStore;
|
|
5
5
|
private readonly localKms;
|
|
6
|
+
readonly localMethods: ISphereonKeyManager;
|
|
6
7
|
constructor(options: {
|
|
7
8
|
store: AbstractKeyStore;
|
|
8
9
|
kms: Record<string, AbstractKeyManagementSystem>;
|
|
9
10
|
});
|
|
10
11
|
private getLocalKms;
|
|
11
|
-
keyManagerSign(args:
|
|
12
|
+
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>;
|
|
13
|
+
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>;
|
|
12
14
|
}
|
|
13
15
|
//# sourceMappingURL=SphereonKeyManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SphereonKeyManager.d.ts","sourceRoot":"","sources":["../../src/agent/SphereonKeyManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"SphereonKeyManager.d.ts","sourceRoot":"","sources":["../../src/agent/SphereonKeyManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAI/F,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAA;AAE9H,qBAAa,kBAAmB,SAAQ,UAAU;IAChD,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6C;IACtE,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAA;gBAE9B,OAAO,EAAE;QAAE,KAAK,EAAE,gBAAgB,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,2BAA2B,CAAC,CAAA;KAAE;IASlG,OAAO,CAAC,WAAW;IASb,cAAc,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAUlE,gBAAgB,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,OAAO,CAAC;CAQ9E"}
|
|
@@ -17,6 +17,9 @@ class SphereonKeyManager extends key_manager_1.KeyManager {
|
|
|
17
17
|
super({ store: options.store, kms: options.kms });
|
|
18
18
|
this.localStore = options.store;
|
|
19
19
|
this.localKms = options.kms;
|
|
20
|
+
const methods = this.methods;
|
|
21
|
+
methods.keyManagerVerify = this.keyManagerVerify.bind(this);
|
|
22
|
+
this.localMethods = methods;
|
|
20
23
|
}
|
|
21
24
|
getLocalKms(name) {
|
|
22
25
|
const kms = this.localKms[name];
|
|
@@ -36,7 +39,18 @@ class SphereonKeyManager extends key_manager_1.KeyManager {
|
|
|
36
39
|
if (keyInfo.type === ssi_sdk_ext_kms_local_1.KeyType.Bls12381G2) {
|
|
37
40
|
return yield kms.sign({ keyRef: keyInfo, data: Uint8Array.from(Buffer.from(args.data)) });
|
|
38
41
|
}
|
|
39
|
-
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
return yield _super.keyManagerSign.call(this, args);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
keyManagerVerify(args) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const kms = this.getLocalKms(args.kms);
|
|
49
|
+
if (('verify' in kms && typeof kms.verify === 'function') || kms instanceof ssi_sdk_ext_kms_local_1.SphereonKeyManagementSystem) {
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
return yield kms.verify(args);
|
|
52
|
+
}
|
|
53
|
+
throw Error(`KMS ${kms} does not support verification`);
|
|
40
54
|
});
|
|
41
55
|
}
|
|
42
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SphereonKeyManager.js","sourceRoot":"","sources":["../../src/agent/SphereonKeyManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA+F;AAG/F,
|
|
1
|
+
{"version":3,"file":"SphereonKeyManager.js","sourceRoot":"","sources":["../../src/agent/SphereonKeyManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA+F;AAG/F,2EAAoF;AAGpF,MAAa,kBAAmB,SAAQ,wBAAU;IAKhD,YAAY,OAAsF;QAChG,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;QACjD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,KAAK,CAAA;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAA;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC5B,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3D,IAAI,CAAC,YAAY,GAAkC,OAAQ,CAAA;IAC7D,CAAC;IAEO,WAAW,CAAC,IAAY;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC/B,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,KAAK,CAAC,iFAAiF,IAAI,GAAG,CAAC,CAAA;SACtG;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,8EAA8E;IACxE,cAAc,CAAC,IAAiC;;;;;YACpD,MAAM,OAAO,GAAS,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAS,CAAA;YAC/E,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YACzC,IAAI,OAAO,CAAC,IAAI,KAAe,+BAAO,CAAC,UAAU,EAAE;gBACjD,OAAO,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAA;aAC1F;YACD,aAAa;YACb,OAAO,MAAM,OAAM,cAAc,YAAC,IAAI,CAAC,CAAA;QACzC,CAAC;KAAA;IAEK,gBAAgB,CAAC,IAAmC;;YACxD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACtC,IAAI,CAAC,QAAQ,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,CAAC,IAAI,GAAG,YAAY,mDAA2B,EAAE;gBACvG,aAAa;gBACb,OAAO,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;aAC9B;YACD,MAAM,KAAK,CAAC,OAAO,GAAG,gCAAgC,CAAC,CAAA;QACzD,CAAC;KAAA;CACF;AAzCD,gDAyCC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AbstractKeyManagementSystem } from '@veramo/key-manager';
|
|
2
2
|
import { AbstractKeyStore } from '@veramo/key-manager';
|
|
3
3
|
import { IKey } from '@veramo/core';
|
|
4
|
-
import { IKeyManagerSignArgs
|
|
4
|
+
import { IKeyManagerSignArgs } from '@veramo/core';
|
|
5
5
|
import { IPluginMethodMap } from '@veramo/core';
|
|
6
6
|
import { KeyManager } from '@veramo/key-manager';
|
|
7
7
|
import { KeyMetadata } from '@veramo/core';
|
|
@@ -49,36 +49,34 @@ export declare interface IKeyManagerGetArgs {
|
|
|
49
49
|
kid: string;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
export declare interface ISphereonKeyManager extends IPluginMethodMap {
|
|
53
|
+
keyManagerCreate(args: IKeyManagerCreateArgs): Promise<PartialKey>;
|
|
54
|
+
keyManagerGetKeyManagementSystems(): Promise<Array<string>>;
|
|
55
|
+
keyManagerGet({ kid }: IKeyManagerGetArgs): Promise<IKey>;
|
|
56
|
+
keyManagerDelete({ kid }: IKeyManagerDeleteArgs): Promise<boolean>;
|
|
57
|
+
keyManagerImport(key: MinimalImportableKey): Promise<PartialKey>;
|
|
58
|
+
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>;
|
|
59
|
+
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>;
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
/**
|
|
53
|
-
* Input arguments for {@link
|
|
63
|
+
* Input arguments for {@link ISphereonKeyManagerSignArgs.keyManagerSign | keyManagerSign}
|
|
54
64
|
* @public
|
|
55
65
|
*/
|
|
56
|
-
export declare interface IKeyManagerSignArgs {
|
|
57
|
-
/**
|
|
58
|
-
* The key handle, as returned during `keyManagerCreateKey`
|
|
59
|
-
*/
|
|
60
|
-
keyRef: string;
|
|
66
|
+
export declare interface ISphereonKeyManagerSignArgs extends IKeyManagerSignArgs {
|
|
61
67
|
/**
|
|
62
68
|
* Data to sign
|
|
63
69
|
*/
|
|
64
|
-
data: Uint8Array
|
|
70
|
+
data: string | Uint8Array;
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
export declare interface
|
|
73
|
+
export declare interface ISphereonKeyManagerVerifyArgs {
|
|
68
74
|
kms: string;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
export declare interface ISphereonKeyManager extends IPluginMethodMap {
|
|
75
|
-
keyManagerCreate(args: IKeyManagerCreateArgs): Promise<PartialKey>;
|
|
76
|
-
keyManagerGetKeyManagementSystems(): Promise<Array<string>>;
|
|
77
|
-
keyManagerGet({ kid }: IKeyManagerGetArgs): Promise<IKey>;
|
|
78
|
-
keyManagerDelete({ kid }: IKeyManagerDeleteArgs): Promise<boolean>;
|
|
79
|
-
keyManagerImport(key: MinimalImportableKey): Promise<PartialKey>;
|
|
80
|
-
keyManagerSign(args: IKeyManagerSignArgs): Promise<string>;
|
|
81
|
-
keyManagerVerify(args: IKeyManagerVerifyArgs): Promise<boolean>;
|
|
75
|
+
publicKeyHex: string;
|
|
76
|
+
type: TKeyType;
|
|
77
|
+
algorithm?: string;
|
|
78
|
+
data: Uint8Array;
|
|
79
|
+
signature: string;
|
|
82
80
|
}
|
|
83
81
|
|
|
84
82
|
export declare type PartialKey = Partial<IKey>;
|
|
@@ -88,12 +86,14 @@ export declare const schema: any;
|
|
|
88
86
|
export declare class SphereonKeyManager extends KeyManager {
|
|
89
87
|
private localStore;
|
|
90
88
|
private readonly localKms;
|
|
89
|
+
readonly localMethods: ISphereonKeyManager;
|
|
91
90
|
constructor(options: {
|
|
92
91
|
store: AbstractKeyStore;
|
|
93
92
|
kms: Record<string, AbstractKeyManagementSystem>;
|
|
94
93
|
});
|
|
95
94
|
private getLocalKms;
|
|
96
|
-
keyManagerSign(args:
|
|
95
|
+
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>;
|
|
96
|
+
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export { }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPluginMethodMap, IKey, KeyMetadata, MinimalImportableKey, TKeyType } from '@veramo/core';
|
|
1
|
+
import { IPluginMethodMap, IKey, KeyMetadata, MinimalImportableKey, TKeyType, IKeyManagerSignArgs } from '@veramo/core';
|
|
2
2
|
export type PartialKey = Partial<IKey>;
|
|
3
3
|
export interface ISphereonKeyManager extends IPluginMethodMap {
|
|
4
4
|
keyManagerCreate(args: IKeyManagerCreateArgs): Promise<PartialKey>;
|
|
@@ -6,8 +6,8 @@ export interface ISphereonKeyManager extends IPluginMethodMap {
|
|
|
6
6
|
keyManagerGet({ kid }: IKeyManagerGetArgs): Promise<IKey>;
|
|
7
7
|
keyManagerDelete({ kid }: IKeyManagerDeleteArgs): Promise<boolean>;
|
|
8
8
|
keyManagerImport(key: MinimalImportableKey): Promise<PartialKey>;
|
|
9
|
-
keyManagerSign(args:
|
|
10
|
-
keyManagerVerify(args:
|
|
9
|
+
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>;
|
|
10
|
+
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Input arguments for {@link ISphereonKeyManager.keyManagerCreate | keyManagerCreate}
|
|
@@ -48,23 +48,21 @@ export interface IKeyManagerDeleteArgs {
|
|
|
48
48
|
kid: string;
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
|
-
* Input arguments for {@link
|
|
51
|
+
* Input arguments for {@link ISphereonKeyManagerSignArgs.keyManagerSign | keyManagerSign}
|
|
52
52
|
* @public
|
|
53
53
|
*/
|
|
54
|
-
export interface IKeyManagerSignArgs {
|
|
55
|
-
/**
|
|
56
|
-
* The key handle, as returned during `keyManagerCreateKey`
|
|
57
|
-
*/
|
|
58
|
-
keyRef: string;
|
|
54
|
+
export interface ISphereonKeyManagerSignArgs extends IKeyManagerSignArgs {
|
|
59
55
|
/**
|
|
60
56
|
* Data to sign
|
|
61
57
|
*/
|
|
62
|
-
data: Uint8Array
|
|
58
|
+
data: string | Uint8Array;
|
|
63
59
|
}
|
|
64
|
-
export interface
|
|
60
|
+
export interface ISphereonKeyManagerVerifyArgs {
|
|
65
61
|
kms: string;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
publicKeyHex: string;
|
|
63
|
+
type: TKeyType;
|
|
64
|
+
algorithm?: string;
|
|
65
|
+
data: Uint8Array;
|
|
66
|
+
signature: string;
|
|
69
67
|
}
|
|
70
68
|
//# sourceMappingURL=ISphereonKeyManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ISphereonKeyManager.d.ts","sourceRoot":"","sources":["../../src/types/ISphereonKeyManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"ISphereonKeyManager.d.ts","sourceRoot":"","sources":["../../src/types/ISphereonKeyManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAEvH,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAEtC,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,gBAAgB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAElE,iCAAiC,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;IAE3D,aAAa,CAAC,EAAE,GAAG,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEzD,gBAAgB,CAAC,EAAE,GAAG,EAAE,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAElE,gBAAgB,CAAC,GAAG,EAAE,oBAAoB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAEhE,cAAc,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAElE,gBAAgB,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CACxE;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAA;IAEd;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IAEX;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAA;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;;GAGG;AAEH,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;CAC1B;AAED,MAAM,WAAW,6BAA6B;IAC5C,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,QAAQ,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,UAAU,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk-ext.key-manager",
|
|
3
3
|
"description": "Sphereon Key Manager plugin with BLS support",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.1-next.10+a555f11",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@mattrglobal/bbs-signatures": "^1.1.0",
|
|
19
|
-
"@sphereon/ssi-sdk-ext.kms-local": "0.13.
|
|
19
|
+
"@sphereon/ssi-sdk-ext.kms-local": "0.13.1-next.10+a555f11",
|
|
20
20
|
"@veramo/core": "4.2.0",
|
|
21
21
|
"@veramo/key-manager": "4.2.0"
|
|
22
22
|
},
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"kms",
|
|
46
46
|
"Veramo"
|
|
47
47
|
],
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "a555f115901f325fbee26be5aeda23f808b48a1d"
|
|
49
49
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -195,163 +195,101 @@
|
|
|
195
195
|
},
|
|
196
196
|
"description": "Represents an object type where a subset of keys are required and everything else is optional."
|
|
197
197
|
},
|
|
198
|
-
"
|
|
198
|
+
"ISphereonKeyManagerSignArgs": {
|
|
199
199
|
"type": "object",
|
|
200
200
|
"properties": {
|
|
201
201
|
"keyRef": {
|
|
202
202
|
"type": "string",
|
|
203
203
|
"description": "The key handle, as returned during `keyManagerCreateKey`"
|
|
204
204
|
},
|
|
205
|
+
"algorithm": {
|
|
206
|
+
"type": "string",
|
|
207
|
+
"description": "The algorithm to use for signing. This must be one of the algorithms supported by the KMS for this key type.\n\nThe algorithm used here should match one of the names listed in `IKey.meta.algorithms`"
|
|
208
|
+
},
|
|
205
209
|
"data": {
|
|
206
|
-
"
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
210
|
+
"anyOf": [
|
|
211
|
+
{
|
|
212
|
+
"type": "string"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"type": "object",
|
|
216
|
+
"properties": {
|
|
217
|
+
"BYTES_PER_ELEMENT": {
|
|
218
|
+
"type": "number"
|
|
219
|
+
},
|
|
220
|
+
"buffer": {
|
|
221
|
+
"anyOf": [
|
|
222
|
+
{
|
|
223
|
+
"type": "object",
|
|
224
|
+
"properties": {
|
|
225
|
+
"byteLength": {
|
|
226
|
+
"type": "number"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
"required": [
|
|
230
|
+
"byteLength"
|
|
231
|
+
]
|
|
221
232
|
},
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
233
|
+
{}
|
|
234
|
+
]
|
|
235
|
+
},
|
|
236
|
+
"byteLength": {
|
|
237
|
+
"type": "number"
|
|
238
|
+
},
|
|
239
|
+
"byteOffset": {
|
|
240
|
+
"type": "number"
|
|
241
|
+
},
|
|
242
|
+
"length": {
|
|
243
|
+
"type": "number"
|
|
244
|
+
}
|
|
234
245
|
},
|
|
235
|
-
"
|
|
246
|
+
"required": [
|
|
247
|
+
"BYTES_PER_ELEMENT",
|
|
248
|
+
"buffer",
|
|
249
|
+
"byteLength",
|
|
250
|
+
"byteOffset",
|
|
251
|
+
"length"
|
|
252
|
+
],
|
|
253
|
+
"additionalProperties": {
|
|
236
254
|
"type": "number"
|
|
237
255
|
}
|
|
238
|
-
},
|
|
239
|
-
"required": [
|
|
240
|
-
"BYTES_PER_ELEMENT",
|
|
241
|
-
"buffer",
|
|
242
|
-
"byteLength",
|
|
243
|
-
"byteOffset",
|
|
244
|
-
"length"
|
|
245
|
-
],
|
|
246
|
-
"additionalProperties": {
|
|
247
|
-
"type": "number"
|
|
248
256
|
}
|
|
249
|
-
|
|
257
|
+
],
|
|
250
258
|
"description": "Data to sign"
|
|
259
|
+
},
|
|
260
|
+
"encoding": {
|
|
261
|
+
"type": "string",
|
|
262
|
+
"enum": [
|
|
263
|
+
"utf-8",
|
|
264
|
+
"base16",
|
|
265
|
+
"base64",
|
|
266
|
+
"hex"
|
|
267
|
+
],
|
|
268
|
+
"description": "If the data is a \"string\" then you can specify which encoding is used. Default is \"utf-8\""
|
|
251
269
|
}
|
|
252
270
|
},
|
|
253
271
|
"required": [
|
|
254
|
-
"
|
|
255
|
-
"
|
|
272
|
+
"data",
|
|
273
|
+
"keyRef"
|
|
256
274
|
],
|
|
257
|
-
"description": "Input arguments for {@link
|
|
275
|
+
"description": "Input arguments for {@link ISphereonKeyManagerSignArgs.keyManagerSign | keyManagerSign }"
|
|
258
276
|
},
|
|
259
|
-
"
|
|
277
|
+
"ISphereonKeyManagerVerifyArgs": {
|
|
260
278
|
"type": "object",
|
|
261
279
|
"properties": {
|
|
262
280
|
"kms": {
|
|
263
281
|
"type": "string"
|
|
264
282
|
},
|
|
265
|
-
"
|
|
266
|
-
"type": "
|
|
267
|
-
"properties": {
|
|
268
|
-
"BYTES_PER_ELEMENT": {
|
|
269
|
-
"type": "number"
|
|
270
|
-
},
|
|
271
|
-
"buffer": {
|
|
272
|
-
"anyOf": [
|
|
273
|
-
{
|
|
274
|
-
"type": "object",
|
|
275
|
-
"properties": {
|
|
276
|
-
"byteLength": {
|
|
277
|
-
"type": "number"
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
"required": [
|
|
281
|
-
"byteLength"
|
|
282
|
-
]
|
|
283
|
-
},
|
|
284
|
-
{}
|
|
285
|
-
]
|
|
286
|
-
},
|
|
287
|
-
"byteLength": {
|
|
288
|
-
"type": "number"
|
|
289
|
-
},
|
|
290
|
-
"byteOffset": {
|
|
291
|
-
"type": "number"
|
|
292
|
-
},
|
|
293
|
-
"length": {
|
|
294
|
-
"type": "number"
|
|
295
|
-
}
|
|
296
|
-
},
|
|
297
|
-
"required": [
|
|
298
|
-
"BYTES_PER_ELEMENT",
|
|
299
|
-
"buffer",
|
|
300
|
-
"byteLength",
|
|
301
|
-
"byteOffset",
|
|
302
|
-
"length"
|
|
303
|
-
],
|
|
304
|
-
"additionalProperties": {
|
|
305
|
-
"type": "number"
|
|
306
|
-
}
|
|
283
|
+
"publicKeyHex": {
|
|
284
|
+
"type": "string"
|
|
307
285
|
},
|
|
308
|
-
"
|
|
309
|
-
"
|
|
310
|
-
"items": {
|
|
311
|
-
"type": "object",
|
|
312
|
-
"properties": {
|
|
313
|
-
"BYTES_PER_ELEMENT": {
|
|
314
|
-
"type": "number"
|
|
315
|
-
},
|
|
316
|
-
"buffer": {
|
|
317
|
-
"anyOf": [
|
|
318
|
-
{
|
|
319
|
-
"type": "object",
|
|
320
|
-
"properties": {
|
|
321
|
-
"byteLength": {
|
|
322
|
-
"type": "number"
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
"required": [
|
|
326
|
-
"byteLength"
|
|
327
|
-
]
|
|
328
|
-
},
|
|
329
|
-
{}
|
|
330
|
-
]
|
|
331
|
-
},
|
|
332
|
-
"byteLength": {
|
|
333
|
-
"type": "number"
|
|
334
|
-
},
|
|
335
|
-
"byteOffset": {
|
|
336
|
-
"type": "number"
|
|
337
|
-
},
|
|
338
|
-
"length": {
|
|
339
|
-
"type": "number"
|
|
340
|
-
}
|
|
341
|
-
},
|
|
342
|
-
"required": [
|
|
343
|
-
"BYTES_PER_ELEMENT",
|
|
344
|
-
"buffer",
|
|
345
|
-
"byteLength",
|
|
346
|
-
"byteOffset",
|
|
347
|
-
"length"
|
|
348
|
-
],
|
|
349
|
-
"additionalProperties": {
|
|
350
|
-
"type": "number"
|
|
351
|
-
}
|
|
352
|
-
}
|
|
286
|
+
"type": {
|
|
287
|
+
"$ref": "#/components/schemas/TKeyType"
|
|
353
288
|
},
|
|
354
|
-
"
|
|
289
|
+
"algorithm": {
|
|
290
|
+
"type": "string"
|
|
291
|
+
},
|
|
292
|
+
"data": {
|
|
355
293
|
"type": "object",
|
|
356
294
|
"properties": {
|
|
357
295
|
"BYTES_PER_ELEMENT": {
|
|
@@ -393,12 +331,16 @@
|
|
|
393
331
|
"additionalProperties": {
|
|
394
332
|
"type": "number"
|
|
395
333
|
}
|
|
334
|
+
},
|
|
335
|
+
"signature": {
|
|
336
|
+
"type": "string"
|
|
396
337
|
}
|
|
397
338
|
},
|
|
398
339
|
"required": [
|
|
399
340
|
"kms",
|
|
400
|
-
"
|
|
401
|
-
"
|
|
341
|
+
"publicKeyHex",
|
|
342
|
+
"type",
|
|
343
|
+
"data",
|
|
402
344
|
"signature"
|
|
403
345
|
]
|
|
404
346
|
}
|
|
@@ -455,7 +397,7 @@
|
|
|
455
397
|
"keyManagerSign": {
|
|
456
398
|
"description": "",
|
|
457
399
|
"arguments": {
|
|
458
|
-
"$ref": "#/components/schemas/
|
|
400
|
+
"$ref": "#/components/schemas/ISphereonKeyManagerSignArgs"
|
|
459
401
|
},
|
|
460
402
|
"returnType": {
|
|
461
403
|
"type": "string"
|
|
@@ -464,7 +406,7 @@
|
|
|
464
406
|
"keyManagerVerify": {
|
|
465
407
|
"description": "",
|
|
466
408
|
"arguments": {
|
|
467
|
-
"$ref": "#/components/schemas/
|
|
409
|
+
"$ref": "#/components/schemas/ISphereonKeyManagerVerifyArgs"
|
|
468
410
|
},
|
|
469
411
|
"returnType": {
|
|
470
412
|
"type": "boolean"
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { KeyManager, AbstractKeyManagementSystem, AbstractKeyStore } from '@veramo/key-manager'
|
|
2
2
|
|
|
3
|
-
import { IKey,
|
|
4
|
-
import {
|
|
3
|
+
import { IKey, TKeyType } from '@veramo/core'
|
|
4
|
+
import {KeyType, SphereonKeyManagementSystem} from '@sphereon/ssi-sdk-ext.kms-local'
|
|
5
|
+
import { ISphereonKeyManager, ISphereonKeyManagerSignArgs, ISphereonKeyManagerVerifyArgs } from '../types/ISphereonKeyManager'
|
|
5
6
|
|
|
6
7
|
export class SphereonKeyManager extends KeyManager {
|
|
7
8
|
private localStore: AbstractKeyStore
|
|
8
9
|
private readonly localKms: Record<string, AbstractKeyManagementSystem>
|
|
10
|
+
readonly localMethods: ISphereonKeyManager
|
|
9
11
|
|
|
10
12
|
constructor(options: { store: AbstractKeyStore; kms: Record<string, AbstractKeyManagementSystem> }) {
|
|
11
13
|
super({ store: options.store, kms: options.kms })
|
|
12
14
|
this.localStore = options.store
|
|
13
15
|
this.localKms = options.kms
|
|
16
|
+
const methods = this.methods
|
|
17
|
+
methods.keyManagerVerify = this.keyManagerVerify.bind(this)
|
|
18
|
+
this.localMethods = <ISphereonKeyManager>(<unknown>methods)
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
private getLocalKms(name: string): AbstractKeyManagementSystem {
|
|
@@ -22,12 +27,22 @@ export class SphereonKeyManager extends KeyManager {
|
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
//FIXME extend the IKeyManagerSignArgs.data to be a string or array of strings
|
|
25
|
-
async keyManagerSign(args:
|
|
30
|
+
async keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string> {
|
|
26
31
|
const keyInfo: IKey = (await this.localStore.get({ kid: args.keyRef })) as IKey
|
|
27
32
|
const kms = this.getLocalKms(keyInfo.kms)
|
|
28
33
|
if (keyInfo.type === <TKeyType>KeyType.Bls12381G2) {
|
|
29
34
|
return await kms.sign({ keyRef: keyInfo, data: Uint8Array.from(Buffer.from(args.data)) })
|
|
30
35
|
}
|
|
31
|
-
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
return await super.keyManagerSign(args)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean> {
|
|
41
|
+
const kms = this.getLocalKms(args.kms)
|
|
42
|
+
if (('verify' in kms && typeof kms.verify === 'function') || kms instanceof SphereonKeyManagementSystem) {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
return await kms.verify(args)
|
|
45
|
+
}
|
|
46
|
+
throw Error(`KMS ${kms} does not support verification`)
|
|
32
47
|
}
|
|
33
48
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { IPluginMethodMap, IKey, KeyMetadata, MinimalImportableKey, TKeyType } from '@veramo/core'
|
|
1
|
+
import { IPluginMethodMap, IKey, KeyMetadata, MinimalImportableKey, TKeyType, IKeyManagerSignArgs } from '@veramo/core'
|
|
2
2
|
|
|
3
3
|
export type PartialKey = Partial<IKey>
|
|
4
4
|
|
|
5
5
|
export interface ISphereonKeyManager extends IPluginMethodMap {
|
|
6
6
|
keyManagerCreate(args: IKeyManagerCreateArgs): Promise<PartialKey>
|
|
7
|
+
|
|
7
8
|
keyManagerGetKeyManagementSystems(): Promise<Array<string>>
|
|
9
|
+
|
|
8
10
|
keyManagerGet({ kid }: IKeyManagerGetArgs): Promise<IKey>
|
|
11
|
+
|
|
9
12
|
keyManagerDelete({ kid }: IKeyManagerDeleteArgs): Promise<boolean>
|
|
13
|
+
|
|
10
14
|
keyManagerImport(key: MinimalImportableKey): Promise<PartialKey>
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
|
|
16
|
+
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>
|
|
17
|
+
|
|
18
|
+
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
/**
|
|
@@ -56,24 +62,22 @@ export interface IKeyManagerDeleteArgs {
|
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
/**
|
|
59
|
-
* Input arguments for {@link
|
|
65
|
+
* Input arguments for {@link ISphereonKeyManagerSignArgs.keyManagerSign | keyManagerSign}
|
|
60
66
|
* @public
|
|
61
67
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
* The key handle, as returned during `keyManagerCreateKey`
|
|
65
|
-
*/
|
|
66
|
-
keyRef: string
|
|
67
|
-
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
export interface ISphereonKeyManagerSignArgs extends IKeyManagerSignArgs {
|
|
68
70
|
/**
|
|
69
71
|
* Data to sign
|
|
70
72
|
*/
|
|
71
|
-
data: Uint8Array
|
|
73
|
+
data: string | Uint8Array
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
export interface
|
|
76
|
+
export interface ISphereonKeyManagerVerifyArgs {
|
|
75
77
|
kms: string
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
publicKeyHex: string
|
|
79
|
+
type: TKeyType
|
|
80
|
+
algorithm?: string
|
|
81
|
+
data: Uint8Array
|
|
82
|
+
signature: string
|
|
79
83
|
}
|