@sphereon/ssi-sdk-ext.key-manager 0.24.1-unstable.54 → 0.24.1-unstable.63
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 +1 -2
- package/dist/agent/SphereonKeyManager.d.ts.map +1 -1
- package/dist/agent/SphereonKeyManager.js +0 -24
- package/dist/agent/SphereonKeyManager.js.map +1 -1
- package/dist/ssi-sdk-ext.key-manager.d.ts +0 -3
- package/package.json +4 -4
- package/src/agent/SphereonKeyManager.ts +1 -22
- package/src/__tests__/SphereonKeyManager.test.ts +0 -74
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeyManager as VeramoKeyManager, AbstractKeyManagementSystem, AbstractKeyStore } from '@veramo/key-manager';
|
|
2
|
-
import {
|
|
2
|
+
import { ManagedKeyInfo } from '@veramo/core';
|
|
3
3
|
import { ISphereonKeyManager, ISphereonKeyManagerSignArgs, ISphereonKeyManagerVerifyArgs } from '../types/ISphereonKeyManager';
|
|
4
4
|
export declare const sphereonKeyManagerMethods: Array<string>;
|
|
5
5
|
export declare class SphereonKeyManager extends VeramoKeyManager {
|
|
@@ -14,6 +14,5 @@ export declare class SphereonKeyManager extends VeramoKeyManager {
|
|
|
14
14
|
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>;
|
|
15
15
|
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>;
|
|
16
16
|
keyManagerListKeys(): Promise<ManagedKeyInfo[]>;
|
|
17
|
-
keyManagerGet({ kid }: IKeyManagerGetArgs): Promise<IKey>;
|
|
18
17
|
}
|
|
19
18
|
//# 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,IAAI,gBAAgB,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEnH,OAAO,
|
|
1
|
+
{"version":3,"file":"SphereonKeyManager.d.ts","sourceRoot":"","sources":["../../src/agent/SphereonKeyManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEnH,OAAO,EAAQ,cAAc,EAAY,MAAM,cAAc,CAAA;AAE7D,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAA;AAE9H,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,MAAM,CAMnD,CAAA;AAED,qBAAa,kBAAmB,SAAQ,gBAAgB;IACtD,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAC5E,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;IAUlG,OAAO,CAAC,eAAe;IASjB,cAAc,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC;IAUlE,gBAAgB,CAAC,IAAI,EAAE,6BAA6B,GAAG,OAAO,CAAC,OAAO,CAAC;IASvE,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;CAGtD"}
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.SphereonKeyManager = exports.sphereonKeyManagerMethods = void 0;
|
|
13
13
|
const key_manager_1 = require("@veramo/key-manager");
|
|
14
14
|
const ssi_sdk_ext_kms_local_1 = require("@sphereon/ssi-sdk-ext.kms-local");
|
|
15
|
-
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
16
15
|
exports.sphereonKeyManagerMethods = [
|
|
17
16
|
'keyManagerCreate',
|
|
18
17
|
'keyManagerImport',
|
|
@@ -67,29 +66,6 @@ class SphereonKeyManager extends key_manager_1.KeyManager {
|
|
|
67
66
|
return this.localStore.list({}); // FIXME there are no args it seems
|
|
68
67
|
});
|
|
69
68
|
}
|
|
70
|
-
keyManagerGet(_a) {
|
|
71
|
-
return __awaiter(this, arguments, void 0, function* ({ kid }) {
|
|
72
|
-
try {
|
|
73
|
-
const key = yield this.localStore.get({ kid });
|
|
74
|
-
return key;
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
const keys = yield this.keyManagerListKeys();
|
|
78
|
-
const foundKey = keys.find((key) => {
|
|
79
|
-
var _a, _b;
|
|
80
|
-
return key.publicKeyHex === kid ||
|
|
81
|
-
((_a = key.meta) === null || _a === void 0 ? void 0 : _a.jwkThumbprint) === kid ||
|
|
82
|
-
(((_b = key.meta) === null || _b === void 0 ? void 0 : _b.jwkThumbprint) == null && (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprintForKey)({ key }) === kid);
|
|
83
|
-
});
|
|
84
|
-
if (foundKey) {
|
|
85
|
-
return foundKey;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
throw new Error(`Key with kid ${kid} not found`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
69
|
}
|
|
94
70
|
exports.SphereonKeyManager = SphereonKeyManager;
|
|
95
71
|
//# sourceMappingURL=SphereonKeyManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SphereonKeyManager.js","sourceRoot":"","sources":["../../src/agent/SphereonKeyManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAmH;AAGnH,2EAAsF;
|
|
1
|
+
{"version":3,"file":"SphereonKeyManager.js","sourceRoot":"","sources":["../../src/agent/SphereonKeyManager.ts"],"names":[],"mappings":";;;;;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,+BAAO,CAAC,UAAU,EAAE,CAAC;gBAClD,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;YAC3F,CAAC;YACD,aAAa;YACb,OAAO,MAAM,OAAM,cAAc,YAAC,IAAI,CAAC,CAAA;QACzC,CAAC;KAAA;IAEK,gBAAgB,CAAC,IAAmC;;YACxD,MAAM,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAC1C,IAAI,CAAC,QAAQ,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,CAAC,IAAI,GAAG,YAAY,mDAA2B,EAAE,CAAC;gBACxG,aAAa;gBACb,OAAO,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC/B,CAAC;YACD,MAAM,KAAK,CAAC,OAAO,GAAG,gCAAgC,CAAC,CAAA;QACzD,CAAC;KAAA;IAEK,kBAAkB;;YACtB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA,CAAC,mCAAmC;QACrE,CAAC;KAAA;CACF;AA9CD,gDA8CC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { AbstractKeyManagementSystem } from '@veramo/key-manager';
|
|
2
2
|
import { AbstractKeyStore } from '@veramo/key-manager';
|
|
3
|
-
import { IKey } from '@veramo/core';
|
|
4
3
|
import { IKeyManager } from '@veramo/core';
|
|
5
|
-
import { IKeyManagerGetArgs as IKeyManagerGetArgs_2 } from '@veramo/core';
|
|
6
4
|
import { IKeyManagerSignArgs } from '@veramo/core';
|
|
7
5
|
import { IPluginMethodMap } from '@veramo/core';
|
|
8
6
|
import { KeyManager } from '@veramo/key-manager';
|
|
@@ -104,7 +102,6 @@ export declare class SphereonKeyManager extends KeyManager {
|
|
|
104
102
|
keyManagerSign(args: ISphereonKeyManagerSignArgs): Promise<string>;
|
|
105
103
|
keyManagerVerify(args: ISphereonKeyManagerVerifyArgs): Promise<boolean>;
|
|
106
104
|
keyManagerListKeys(): Promise<ManagedKeyInfo[]>;
|
|
107
|
-
keyManagerGet({ kid }: IKeyManagerGetArgs_2): Promise<IKey>;
|
|
108
105
|
}
|
|
109
106
|
|
|
110
107
|
export declare const sphereonKeyManagerMethods: Array<string>;
|
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.24.1-unstable.
|
|
4
|
+
"version": "0.24.1-unstable.63+adfc57a",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"generate-plugin-schema": "sphereon dev generate-plugin-schema"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@sphereon/ssi-sdk-ext.kms-local": "0.24.1-unstable.
|
|
18
|
+
"@sphereon/ssi-sdk-ext.kms-local": "0.24.1-unstable.63+adfc57a",
|
|
19
19
|
"@veramo/core": "4.2.0",
|
|
20
20
|
"@veramo/key-manager": "4.2.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@mattrglobal/bbs-signatures": "^1.3.1",
|
|
24
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.24.1-unstable.
|
|
24
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.24.1-unstable.63+adfc57a",
|
|
25
25
|
"@sphereon/ssi-sdk.dev": "0.28.0"
|
|
26
26
|
},
|
|
27
27
|
"resolutions": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"kms",
|
|
47
47
|
"Veramo"
|
|
48
48
|
],
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "adfc57aea4001853b32c0a0b0c910ea79ed83edf"
|
|
50
50
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { KeyManager as VeramoKeyManager, AbstractKeyManagementSystem, AbstractKeyStore } from '@veramo/key-manager'
|
|
2
2
|
|
|
3
|
-
import { IKey,
|
|
3
|
+
import { IKey, ManagedKeyInfo, TKeyType } from '@veramo/core'
|
|
4
4
|
import { KeyType, SphereonKeyManagementSystem } from '@sphereon/ssi-sdk-ext.kms-local'
|
|
5
5
|
import { ISphereonKeyManager, ISphereonKeyManagerSignArgs, ISphereonKeyManagerVerifyArgs } from '../types/ISphereonKeyManager'
|
|
6
|
-
import { calculateJwkThumbprintForKey } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
7
6
|
|
|
8
7
|
export const sphereonKeyManagerMethods: Array<string> = [
|
|
9
8
|
'keyManagerCreate',
|
|
@@ -59,24 +58,4 @@ export class SphereonKeyManager extends VeramoKeyManager {
|
|
|
59
58
|
async keyManagerListKeys(): Promise<ManagedKeyInfo[]> {
|
|
60
59
|
return this.localStore.list({}) // FIXME there are no args it seems
|
|
61
60
|
}
|
|
62
|
-
|
|
63
|
-
async keyManagerGet({ kid }: IKeyManagerGetArgs): Promise<IKey> {
|
|
64
|
-
try {
|
|
65
|
-
const key = await this.localStore.get({ kid })
|
|
66
|
-
return key
|
|
67
|
-
} catch (e) {
|
|
68
|
-
const keys: ManagedKeyInfo[] = await this.keyManagerListKeys()
|
|
69
|
-
const foundKey = keys.find(
|
|
70
|
-
(key) =>
|
|
71
|
-
key.publicKeyHex === kid ||
|
|
72
|
-
key.meta?.jwkThumbprint === kid ||
|
|
73
|
-
(key.meta?.jwkThumbprint == null && calculateJwkThumbprintForKey({ key }) === kid)
|
|
74
|
-
)
|
|
75
|
-
if (foundKey) {
|
|
76
|
-
return foundKey as IKey
|
|
77
|
-
} else {
|
|
78
|
-
throw new Error(`Key with kid ${kid} not found`)
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
61
|
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { SphereonKeyManager } from '../agent/SphereonKeyManager'
|
|
2
|
-
import { MemoryKeyStore, MemoryPrivateKeyStore } from '@veramo/key-manager'
|
|
3
|
-
import { SphereonKeyManagementSystem } from '@sphereon/ssi-sdk-ext.kms-local'
|
|
4
|
-
|
|
5
|
-
describe('@sphereon/ssi-sdk-ext.key-manager key functionalities', () => {
|
|
6
|
-
const kms = new SphereonKeyManager({
|
|
7
|
-
store: new MemoryKeyStore(),
|
|
8
|
-
kms: {
|
|
9
|
-
local: new SphereonKeyManagementSystem(new MemoryPrivateKeyStore()),
|
|
10
|
-
},
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('should create and fetch a RSA key', async () => {
|
|
14
|
-
const key = await kms.keyManagerCreate({ type: 'RSA', kms: 'local' })
|
|
15
|
-
const fetchByKid = await kms.keyManagerGet({ kid: key.kid })
|
|
16
|
-
expect(fetchByKid.kid).toEqual(key.kid)
|
|
17
|
-
expect(fetchByKid.publicKeyHex).toEqual(key.publicKeyHex)
|
|
18
|
-
expect(fetchByKid?.meta?.publicKeyJwk).toBeDefined()
|
|
19
|
-
expect(fetchByKid?.meta?.publicKeyPEM).toBeDefined()
|
|
20
|
-
expect(fetchByKid.type).toEqual('RSA')
|
|
21
|
-
const fetchByPublicKeyHex = await kms.keyManagerGet({ kid: key.publicKeyHex })
|
|
22
|
-
expect(fetchByPublicKeyHex.kid).toEqual(key.kid)
|
|
23
|
-
expect(fetchByPublicKeyHex?.meta?.publicKeyJwk).toBeDefined()
|
|
24
|
-
expect(fetchByPublicKeyHex?.meta?.publicKeyPEM).toBeDefined()
|
|
25
|
-
const deleteByPublicKeyHex = await kms.keyManagerDelete({ kid: key.publicKeyHex })
|
|
26
|
-
expect(deleteByPublicKeyHex).toBeTruthy()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
it('should create and fetch a X25519 key', async () => {
|
|
30
|
-
const key = await kms.keyManagerCreate({ type: 'X25519', kms: 'local' })
|
|
31
|
-
const fetchByKid = await kms.keyManagerGet({ kid: key.kid })
|
|
32
|
-
expect(fetchByKid.type).toEqual('X25519')
|
|
33
|
-
expect(fetchByKid.kid).toEqual(key.kid)
|
|
34
|
-
expect(fetchByKid.publicKeyHex).toEqual(key.publicKeyHex)
|
|
35
|
-
expect(fetchByKid?.meta).toEqual({ algorithms: ['ECDH', 'ECDH-ES', 'ECDH-1PU'] })
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it('should create and fetch a Ed25519 key', async () => {
|
|
39
|
-
const key = await kms.keyManagerCreate({ type: 'Ed25519', kms: 'local' })
|
|
40
|
-
const fetchByKid = await kms.keyManagerGet({ kid: key.kid })
|
|
41
|
-
expect(fetchByKid.type).toEqual('Ed25519')
|
|
42
|
-
expect(fetchByKid.kid).toEqual(key.kid)
|
|
43
|
-
expect(fetchByKid.publicKeyHex).toEqual(key.publicKeyHex)
|
|
44
|
-
expect(fetchByKid?.meta).toEqual({ algorithms: ['Ed25519', 'EdDSA'] })
|
|
45
|
-
const fetchByPublicKeyHex = await kms.keyManagerGet({ kid: key.publicKeyHex })
|
|
46
|
-
expect(fetchByPublicKeyHex.kid).toEqual(key.kid)
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
it('should create and fetch a Secp256k1 key', async () => {
|
|
50
|
-
const key = await kms.keyManagerCreate({ type: 'Secp256k1', kms: 'local' })
|
|
51
|
-
const fetchByKid = await kms.keyManagerGet({ kid: key.kid })
|
|
52
|
-
expect(fetchByKid.type).toEqual('Secp256k1')
|
|
53
|
-
expect(fetchByKid.kid).toEqual(key.kid)
|
|
54
|
-
expect(fetchByKid.publicKeyHex).toEqual(key.publicKeyHex)
|
|
55
|
-
expect(fetchByKid?.meta?.algorithms).toEqual(['ES256K', 'ES256K-R', 'eth_signTransaction', 'eth_signTypedData', 'eth_signMessage', 'eth_rawSign'])
|
|
56
|
-
const fetchByPublicKeyHex = await kms.keyManagerGet({ kid: key.publicKeyHex })
|
|
57
|
-
expect(fetchByPublicKeyHex.kid).toEqual(key.kid)
|
|
58
|
-
const fetchByThumbprint = await kms.keyManagerGet({ kid: key?.meta?.jwkThumbprint })
|
|
59
|
-
expect(fetchByThumbprint.kid).toEqual(fetchByThumbprint.kid)
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
it('should create and fetch a Secp256r1 key', async () => {
|
|
63
|
-
const key = await kms.keyManagerCreate({ type: 'Secp256r1', kms: 'local' })
|
|
64
|
-
const fetchByKid = await kms.keyManagerGet({ kid: key.kid })
|
|
65
|
-
expect(fetchByKid.kid).toEqual(key.kid)
|
|
66
|
-
expect(fetchByKid.type).toEqual('Secp256r1')
|
|
67
|
-
expect(fetchByKid.publicKeyHex).toEqual(key.publicKeyHex)
|
|
68
|
-
expect(fetchByKid?.meta?.algorithms).toEqual(['ES256'])
|
|
69
|
-
const fetchByPublicKeyHex = await kms.keyManagerGet({ kid: key.publicKeyHex })
|
|
70
|
-
expect(fetchByPublicKeyHex.kid).toEqual(key.kid)
|
|
71
|
-
const fetchByThumbprint = await kms.keyManagerGet({ kid: key?.meta?.jwkThumbprint })
|
|
72
|
-
expect(fetchByThumbprint.kid).toEqual(fetchByThumbprint.kid)
|
|
73
|
-
})
|
|
74
|
-
})
|