@sphereon/ssi-sdk-ext.identifier-resolution 0.24.1-unstable.82 → 0.24.1-unstable.85
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/IdentifierResolution.d.ts +4 -2
- package/dist/agent/IdentifierResolution.d.ts.map +1 -1
- package/dist/agent/IdentifierResolution.js +11 -3
- package/dist/agent/IdentifierResolution.js.map +1 -1
- package/dist/functions/managedIdentifierFunctions.d.ts +7 -1
- package/dist/functions/managedIdentifierFunctions.d.ts.map +1 -1
- package/dist/functions/managedIdentifierFunctions.js +33 -1
- package/dist/functions/managedIdentifierFunctions.js.map +1 -1
- package/dist/types/IIdentifierResolution.d.ts +4 -1
- package/dist/types/IIdentifierResolution.d.ts.map +1 -1
- package/dist/types/common.d.ts +2 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +9 -1
- package/dist/types/common.js.map +1 -1
- package/dist/types/managedIdentifierTypes.d.ts +17 -6
- package/dist/types/managedIdentifierTypes.d.ts.map +1 -1
- package/dist/types/managedIdentifierTypes.js +10 -1
- package/dist/types/managedIdentifierTypes.js.map +1 -1
- package/package.json +9 -9
- package/plugin.schema.json +147 -18
- package/src/agent/IdentifierResolution.ts +10 -4
- package/src/functions/managedIdentifierFunctions.ts +32 -1
- package/src/types/IIdentifierResolution.ts +8 -0
- package/src/types/common.ts +11 -1
- package/src/types/managedIdentifierTypes.ts +35 -9
|
@@ -10,11 +10,12 @@ export declare class IdentifierResolution implements IAgentPlugin {
|
|
|
10
10
|
/**
|
|
11
11
|
* TODO: Add a cache, as we are retrieving the same keys/info quite often
|
|
12
12
|
*/
|
|
13
|
-
constructor(
|
|
13
|
+
constructor(opts?: {
|
|
14
14
|
crypto?: Crypto;
|
|
15
15
|
});
|
|
16
16
|
/**
|
|
17
|
-
* Main method for managed identifiers. We always go through this method (also the
|
|
17
|
+
* Main method for managed identifiers. We always go through this method (also the other methods below) as we want to
|
|
18
|
+
* integrate a plugin for anomaly detection. Having a single method helps
|
|
18
19
|
* @param args
|
|
19
20
|
* @param context
|
|
20
21
|
* @private
|
|
@@ -22,6 +23,7 @@ export declare class IdentifierResolution implements IAgentPlugin {
|
|
|
22
23
|
private identifierGetManaged;
|
|
23
24
|
private identifierGetManagedByDid;
|
|
24
25
|
private identifierGetManagedByKid;
|
|
26
|
+
private identifierGetManagedByKey;
|
|
25
27
|
private identifierGetManagedByJwk;
|
|
26
28
|
private identifierGetManagedByX5c;
|
|
27
29
|
private identifierResolveExternal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifierResolution.d.ts","sourceRoot":"","sources":["../../src/agent/IdentifierResolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAA4B,MAAM,cAAc,CAAA;AAGpF,OAAO,EAOL,qBAAqB,EAWtB,MAAM,UAAU,CAAA;AAEjB;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAEhC,QAAQ,CAAC,MAAM,MAAgC;IAC/C,QAAQ,CAAC,OAAO,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"IdentifierResolution.d.ts","sourceRoot":"","sources":["../../src/agent/IdentifierResolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAA4B,MAAM,cAAc,CAAA;AAGpF,OAAO,EAOL,qBAAqB,EAWtB,MAAM,UAAU,CAAA;AAEjB;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;IAEhC,QAAQ,CAAC,MAAM,MAAgC;IAC/C,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAatC;IAED;;OAEG;gBACS,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAItC;;;;;;OAMG;YACW,oBAAoB;YAIpB,yBAAyB;YAOzB,yBAAyB;YAIzB,yBAAyB;YAIzB,yBAAyB;YAIzB,yBAAyB;YAIzB,yBAAyB;YAIzB,8BAA8B;YAI9B,8BAA8B;CAG7C"}
|
|
@@ -19,7 +19,8 @@ class IdentifierResolution {
|
|
|
19
19
|
/**
|
|
20
20
|
* TODO: Add a cache, as we are retrieving the same keys/info quite often
|
|
21
21
|
*/
|
|
22
|
-
constructor(
|
|
22
|
+
constructor(opts) {
|
|
23
|
+
var _a;
|
|
23
24
|
this.schema = __1.schema.IMnemonicInfoGenerator;
|
|
24
25
|
this.methods = {
|
|
25
26
|
identifierManagedGet: this.identifierGetManaged.bind(this),
|
|
@@ -27,15 +28,17 @@ class IdentifierResolution {
|
|
|
27
28
|
identifierManagedGetByKid: this.identifierGetManagedByKid.bind(this),
|
|
28
29
|
identifierManagedGetByJwk: this.identifierGetManagedByJwk.bind(this),
|
|
29
30
|
identifierManagedGetByX5c: this.identifierGetManagedByX5c.bind(this),
|
|
31
|
+
identifierManagedGetByKey: this.identifierGetManagedByKey.bind(this),
|
|
30
32
|
identifierExternalResolve: this.identifierResolveExternal.bind(this),
|
|
31
33
|
identifierExternalResolveByDid: this.identifierExternalResolveByDid.bind(this),
|
|
32
34
|
identifierExternalResolveByX5c: this.identifierExternalResolveByX5c.bind(this),
|
|
33
35
|
// todo: JWKSet, oidc-discovery, oid4vci-issuer etc. Anything we already can resolve and need keys of
|
|
34
36
|
};
|
|
35
|
-
this._crypto =
|
|
37
|
+
this._crypto = (_a = opts === null || opts === void 0 ? void 0 : opts.crypto) !== null && _a !== void 0 ? _a : global.crypto;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
|
-
* Main method for managed identifiers. We always go through this method (also the
|
|
40
|
+
* Main method for managed identifiers. We always go through this method (also the other methods below) as we want to
|
|
41
|
+
* integrate a plugin for anomaly detection. Having a single method helps
|
|
39
42
|
* @param args
|
|
40
43
|
* @param context
|
|
41
44
|
* @private
|
|
@@ -55,6 +58,11 @@ class IdentifierResolution {
|
|
|
55
58
|
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'kid' }), context));
|
|
56
59
|
});
|
|
57
60
|
}
|
|
61
|
+
identifierGetManagedByKey(args, context) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'key' }), context));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
58
66
|
identifierGetManagedByJwk(args, context) {
|
|
59
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
68
|
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'jwk' }), context));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifierResolution.js","sourceRoot":"","sources":["../../src/agent/IdentifierResolution.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"IdentifierResolution.js","sourceRoot":"","sources":["../../src/agent/IdentifierResolution.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0BAAiF;AACjF,4CAA8E;AAqB9E;;GAEG;AACH,MAAa,oBAAoB;IAmB/B;;OAEG;IACH,YAAY,IAA0B;;QAnB7B,WAAM,GAAG,UAAM,CAAC,sBAAsB,CAAA;QACtC,YAAO,GAA0B;YACxC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1D,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YACpE,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;YAEpE,yBAAyB,E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AA;IAEa,yBAAyB,CAAC,IAA8B,EAAE,OAAmC;;YACzG,OAAO,CAAC,MAAM,IAAI,CAAC,oBAAoB,iCAAM,IAAI,KAAE,MAAM,EAAE,KAAK,KAAI,OAAO,CAAC,CAA+B,CAAA;QAC7G,CAAC;KAAA;IAEa,yBAAyB,CAAC,IAA4B,EAAE,OAAmC;;YACvG,OAAO,MAAM,IAAA,qCAAyB,kCAAM,IAAI,KAAE,MAAM,EAAE,IAAI,CAAC,OAAO,KAAI,OAAO,CAAC,CAAA;QACpF,CAAC;KAAA;IAEa,8BAA8B,CAAC,IAA+B,EAAE,OAA2B;;YACvG,OAAO,CAAC,MAAM,IAAI,CAAC,yBAAyB,iCAAM,IAAI,KAAE,MAAM,EAAE,KAAK,KAAI,OAAO,CAAC,CAAgC,CAAA;QACnH,CAAC;KAAA;IAEa,8BAA8B,CAAC,IAA+B,EAAE,OAA2B;;YACvG,OAAO,CAAC,MAAM,IAAI,CAAC,yBAAyB,iCAAM,IAAI,KAAE,MAAM,EAAE,KAAK,KAAI,OAAO,CAAC,CAAgC,CAAA;QACnH,CAAC;KAAA;CACF;AAvED,oDAuEC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { IAgentContext, IKeyManager } from '@veramo/core';
|
|
2
|
-
import { ManagedIdentifierDidOpts, ManagedIdentifierDidResult, ManagedIdentifierJwkOpts, ManagedIdentifierJwkResult, ManagedIdentifierKidOpts, ManagedIdentifierKidResult, ManagedIdentifierOpts, ManagedIdentifierResult, ManagedIdentifierX5cOpts, ManagedIdentifierX5cResult } from '../types';
|
|
2
|
+
import { ManagedIdentifierDidOpts, ManagedIdentifierDidResult, ManagedIdentifierJwkOpts, ManagedIdentifierJwkResult, ManagedIdentifierKeyOpts, ManagedIdentifierKeyResult, ManagedIdentifierKidOpts, ManagedIdentifierKidResult, ManagedIdentifierOpts, ManagedIdentifierResult, ManagedIdentifierX5cOpts, ManagedIdentifierX5cResult } from '../types';
|
|
3
3
|
export declare function getManagedKidIdentifier(opts: ManagedIdentifierKidOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierKidResult>;
|
|
4
|
+
/**
|
|
5
|
+
* This function is just a convenience function to get a common result. The user already apparently had a key, so could have called the kid version as well
|
|
6
|
+
* @param opts
|
|
7
|
+
* @param _context
|
|
8
|
+
*/
|
|
9
|
+
export declare function getManagedKeyIdentifier(opts: ManagedIdentifierKeyOpts, _context?: IAgentContext<any>): Promise<ManagedIdentifierKeyResult>;
|
|
4
10
|
export declare function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, context: IAgentContext<any>): Promise<ManagedIdentifierDidResult>;
|
|
5
11
|
export declare function getManagedJwkIdentifier(opts: ManagedIdentifierJwkOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierJwkResult>;
|
|
6
12
|
export declare function getManagedX5cIdentifier(opts: ManagedIdentifierX5cOpts & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedIdentifierFunctions.d.ts","sourceRoot":"","sources":["../../src/functions/managedIdentifierFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"managedIdentifierFunctions.d.ts","sourceRoot":"","sources":["../../src/functions/managedIdentifierFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAqB,WAAW,EAAE,MAAM,cAAc,CAAA;AAE5E,OAAO,EAOL,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,UAAU,CAAA;AAEjB,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,wBAAwB,EAC9B,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAClC,OAAO,CAAC,0BAA0B,CAAC,CAmBrC;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,EAAE,QAAQ,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAmBhJ;AAED,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA0C9I;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,wBAAwB,EAC9B,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAClC,OAAO,CAAC,0BAA0B,CAAC,CAmBrC;AAED,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,wBAAwB,GAAG;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,EACD,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAClC,OAAO,CAAC,0BAA0B,CAAC,CA8BrC;AAED,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,qBAAqB,GAAG;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,EACD,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAClC,OAAO,CAAC,uBAAuB,CAAC,CAqBlC"}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getManagedIdentifier = exports.getManagedX5cIdentifier = exports.getManagedJwkIdentifier = exports.getManagedDidIdentifier = exports.getManagedKidIdentifier = void 0;
|
|
12
|
+
exports.getManagedIdentifier = exports.getManagedX5cIdentifier = exports.getManagedJwkIdentifier = exports.getManagedDidIdentifier = exports.getManagedKeyIdentifier = exports.getManagedKidIdentifier = void 0;
|
|
13
13
|
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
14
14
|
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
15
15
|
const ssi_sdk_ext_x509_utils_1 = require("@sphereon/ssi-sdk-ext.x509-utils");
|
|
@@ -40,6 +40,35 @@ function getManagedKidIdentifier(opts, context) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
exports.getManagedKidIdentifier = getManagedKidIdentifier;
|
|
43
|
+
/**
|
|
44
|
+
* This function is just a convenience function to get a common result. The user already apparently had a key, so could have called the kid version as well
|
|
45
|
+
* @param opts
|
|
46
|
+
* @param _context
|
|
47
|
+
*/
|
|
48
|
+
function getManagedKeyIdentifier(opts, _context) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
51
|
+
const method = 'key';
|
|
52
|
+
const key = opts.identifier;
|
|
53
|
+
if (opts.kmsKeyRef && opts.kmsKeyRef !== key.kid) {
|
|
54
|
+
return Promise.reject(Error(`Cannot get a managed key object by providing a key and a kmsKeyRef that are different.}`));
|
|
55
|
+
}
|
|
56
|
+
const jwk = (0, ssi_sdk_ext_key_utils_1.toJwk)(key.publicKeyHex, key.type, { key });
|
|
57
|
+
const jwkThumbprint = (_b = (_a = key.meta) === null || _a === void 0 ? void 0 : _a.jwkThumbprint) !== null && _b !== void 0 ? _b : (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprint)({ jwk });
|
|
58
|
+
const kid = (_f = (_c = opts.kid) !== null && _c !== void 0 ? _c : (_e = (_d = key.meta) === null || _d === void 0 ? void 0 : _d.verificationMethod) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : jwkThumbprint;
|
|
59
|
+
const issuer = (_g = opts.issuer) !== null && _g !== void 0 ? _g : kid; // The different identifiers should set the value. Defaults to the kid
|
|
60
|
+
return {
|
|
61
|
+
method,
|
|
62
|
+
key,
|
|
63
|
+
jwk,
|
|
64
|
+
jwkThumbprint,
|
|
65
|
+
kid,
|
|
66
|
+
issuer,
|
|
67
|
+
kmsKeyRef: key.kid,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
exports.getManagedKeyIdentifier = getManagedKeyIdentifier;
|
|
43
72
|
function getManagedDidIdentifier(opts, context) {
|
|
44
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
74
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -153,6 +182,9 @@ function getManagedIdentifier(opts, context) {
|
|
|
153
182
|
else if ((0, types_1.isManagedIdentifierX5cOpts)(opts)) {
|
|
154
183
|
resolutionResult = yield getManagedX5cIdentifier(opts, context);
|
|
155
184
|
}
|
|
185
|
+
else if ((0, types_1.isManagedIdentifierKeyOpts)(opts)) {
|
|
186
|
+
resolutionResult = yield getManagedKeyIdentifier(opts, context);
|
|
187
|
+
}
|
|
156
188
|
else {
|
|
157
189
|
return Promise.reject(Error(`Could not determine identifier method. Please provide explicitly`));
|
|
158
190
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedIdentifierFunctions.js","sourceRoot":"","sources":["../../src/functions/managedIdentifierFunctions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2EAAyE;AACzE,2EAAoF;AACpF,6EAA4E;AAC5E,yEAA2F;AAE3F,iCAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"managedIdentifierFunctions.js","sourceRoot":"","sources":["../../src/functions/managedIdentifierFunctions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2EAAyE;AACzE,2EAAoF;AACpF,6EAA4E;AAC5E,yEAA2F;AAE3F,iCAA+C;AAC/C,oCAmBiB;AAEjB,SAAsB,uBAAuB,CAC3C,IAA8B,EAC9B,OAAmC;;;QAEnC,MAAM,MAAM,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,IAAA,2CAAoB,EAAC,OAAO,CAAC,EAAE,CAAC;YACnC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oEAAoE,CAAC,CAA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ACjE,CAAC;aAAM,IAAI,IAAA,kCAA0B,EAAC,IAAI,CAAC,EAAE,CAAC;YAC5C,gBAAgB,GAAG,MAAM,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACjE,CAAC;aAAM,IAAI,IAAA,kCAA0B,EAAC,IAAI,CAAC,EAAE,CAAC;YAC5C,gBAAgB,GAAG,MAAM,uBAAuB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACjE,CAAC;aAAM,CAAC;YACN,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC,CAAA;QAClG,CAAC;QACD,MAAM,EAAE,GAAG,EAAE,GAAG,gBAAgB,CAAA;QAChC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAA,kCAA0B,EAAC,IAAI,CAAC,IAAI,IAAA,oCAA4B,EAAC,gBAAgB,CAAC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE,CAAC;YACjI,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;YACtD,OAAO,OAAO,CAAC,MAAM,CAAC,0BAA0B,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;QACpE,CAAC;QACD,OAAO,gBAAgB,CAAA;IACzB,CAAC;CAAA;AA1BD,oDA0BC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { IAgentContext, IDIDManager, IKeyManager, IPluginMethodMap } from '@veramo/core';
|
|
2
2
|
import { ExternalIdentifierDidOpts, ExternalIdentifierDidResult, ExternalIdentifierOpts, ExternalIdentifierResult, ExternalIdentifierX5cOpts, ExternalIdentifierX5cResult } from './externalIdentifierTypes';
|
|
3
|
-
import { ManagedIdentifierDidOpts, ManagedIdentifierDidResult, ManagedIdentifierJwkOpts, ManagedIdentifierJwkResult, ManagedIdentifierKidOpts, ManagedIdentifierKidResult, ManagedIdentifierOpts, ManagedIdentifierResult, ManagedIdentifierX5cOpts, ManagedIdentifierX5cResult } from './managedIdentifierTypes';
|
|
3
|
+
import { ManagedIdentifierDidOpts, ManagedIdentifierDidResult, ManagedIdentifierJwkOpts, ManagedIdentifierJwkResult, ManagedIdentifierKeyOpts, ManagedIdentifierKeyResult, ManagedIdentifierKidOpts, ManagedIdentifierKidResult, ManagedIdentifierOpts, ManagedIdentifierResult, ManagedIdentifierX5cOpts, ManagedIdentifierX5cResult } from './managedIdentifierTypes';
|
|
4
4
|
/**
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
7
|
export interface IIdentifierResolution extends IPluginMethodMap {
|
|
8
8
|
/**
|
|
9
9
|
* Main method for managed identifiers. We always go through this method (also the others) as we want to integrate a plugin for anomaly detection. Having a single method helps
|
|
10
|
+
*
|
|
11
|
+
* The end result of all these methods is a common baseline response that allows to use a key from the registered KMS systems. It also provides kid and iss(uer) values that can be used in a JWT/JWS for instance
|
|
10
12
|
* @param args
|
|
11
13
|
* @param context
|
|
12
14
|
* @public
|
|
@@ -16,6 +18,7 @@ export interface IIdentifierResolution extends IPluginMethodMap {
|
|
|
16
18
|
identifierManagedGetByKid(args: ManagedIdentifierKidOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierKidResult>;
|
|
17
19
|
identifierManagedGetByJwk(args: ManagedIdentifierJwkOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierJwkResult>;
|
|
18
20
|
identifierManagedGetByX5c(args: ManagedIdentifierX5cOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierX5cResult>;
|
|
21
|
+
identifierManagedGetByKey(args: ManagedIdentifierKeyOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierKeyResult>;
|
|
19
22
|
/**
|
|
20
23
|
* Main method for external identifiers. We always go through this method (also the others) as we want to integrate a plugin for anomaly detection. Having a single method helps
|
|
21
24
|
* @param args
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IIdentifierResolution.d.ts","sourceRoot":"","sources":["../../src/types/IIdentifierResolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACxF,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,0BAA0B,CAAA;AAEjC;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D
|
|
1
|
+
{"version":3,"file":"IIdentifierResolution.d.ts","sourceRoot":"","sources":["../../src/types/IIdentifierResolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACxF,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC3B,MAAM,0BAA0B,CAAA;AAEjC;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D;;;;;;;OAOG;IACH,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;IAExH,yBAAyB,CAAC,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,CAAC,WAAW,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;IAEjJ,yBAAyB,CAAC,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;IAEnI,yBAAyB,CAAC,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;IAEnI,yBAAyB,CAAC,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;IAEnI,yBAAyB,CAAC,IAAI,EAAE,wBAAwB,EAAE,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;IAInI;;;;;OAKG;IACH,yBAAyB,CAAC,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAA;IAEvH,8BAA8B,CAAC,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;IAElI,8BAA8B,CAAC,IAAI,EAAE,yBAAyB,EAAE,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;CACnI"}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JWK } from '@sphereon/ssi-sdk-ext.key-utils';
|
|
2
|
-
import { IIdentifier } from '@veramo/core';
|
|
2
|
+
import { IIdentifier, IKey } from '@veramo/core';
|
|
3
3
|
import { ExternalIdentifierType } from './externalIdentifierTypes';
|
|
4
4
|
import { ManagedIdentifierType } from './managedIdentifierTypes';
|
|
5
5
|
export interface JwkInfo {
|
|
@@ -12,5 +12,6 @@ export declare function isJwkIdentifier(identifier: ManagedIdentifierType | Exte
|
|
|
12
12
|
export declare function isOidcDiscoveryIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string;
|
|
13
13
|
export declare function isJwksUrlIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string;
|
|
14
14
|
export declare function isKidIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string;
|
|
15
|
+
export declare function isKeyIdentifier(identifier: ManagedIdentifierType): identifier is IKey;
|
|
15
16
|
export declare function isX5cIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string[];
|
|
16
17
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAEhE,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,GAAG,CAAA;IACR,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,UAAU,IAAI,WAAW,GAAG,MAAM,CAE9H;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,UAAU,IAAI,WAAW,CAEnH;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,UAAU,IAAI,GAAG,CAE7G;AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,UAAU,IAAI,MAAM,CAE1H;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,UAAU,IAAI,MAAM,CAEpH;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,UAAU,IAAI,MAAM,CAEhH;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,qBAAqB,GAAG,UAAU,IAAI,IAAI,CAQrF;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,qBAAqB,GAAG,sBAAsB,GAAG,UAAU,IAAI,MAAM,EAAE,CAElH"}
|
package/dist/types/common.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isX5cIdentifier = exports.isKidIdentifier = exports.isJwksUrlIdentifier = exports.isOidcDiscoveryIdentifier = exports.isJwkIdentifier = exports.isIIdentifier = exports.isDidIdentifier = void 0;
|
|
3
|
+
exports.isX5cIdentifier = exports.isKeyIdentifier = exports.isKidIdentifier = exports.isJwksUrlIdentifier = exports.isOidcDiscoveryIdentifier = exports.isJwkIdentifier = exports.isIIdentifier = exports.isDidIdentifier = void 0;
|
|
4
4
|
function isDidIdentifier(identifier) {
|
|
5
5
|
return isIIdentifier(identifier) || (typeof identifier === 'string' && identifier.startsWith('did:'));
|
|
6
6
|
}
|
|
@@ -25,6 +25,14 @@ function isKidIdentifier(identifier) {
|
|
|
25
25
|
return typeof identifier === 'string' && !identifier.startsWith('did:');
|
|
26
26
|
}
|
|
27
27
|
exports.isKidIdentifier = isKidIdentifier;
|
|
28
|
+
function isKeyIdentifier(identifier) {
|
|
29
|
+
return (typeof identifier === 'string' &&
|
|
30
|
+
!Array.isArray(identifier) &&
|
|
31
|
+
typeof identifier === 'object' &&
|
|
32
|
+
`kid` in identifier &&
|
|
33
|
+
'publicKeyHex' in identifier);
|
|
34
|
+
}
|
|
35
|
+
exports.isKeyIdentifier = isKeyIdentifier;
|
|
28
36
|
function isX5cIdentifier(identifier) {
|
|
29
37
|
return Array.isArray(identifier) && identifier.length > 0; // todo: Do we want to do additional validation? We know it must be DER and thus hex for instance
|
|
30
38
|
}
|
package/dist/types/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";;;AAUA,SAAgB,eAAe,CAAC,UAA0D;IACxF,OAAO,aAAa,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAA;AACvG,CAAC;AAFD,0CAEC;AAED,SAAgB,aAAa,CAAC,UAA0D;IACtF,OAAO,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,KAAK,IAAI,UAAU,IAAI,MAAM,IAAI,UAAU,CAAA;AACpH,CAAC;AAFD,sCAEC;AAED,SAAgB,eAAe,CAAC,UAA0D;IACxF,OAAO,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,KAAK,IAAI,UAAU,CAAA;AAC5F,CAAC;AAFD,0CAEC;AAED,SAAgB,yBAAyB,CAAC,UAA0D;IAClG,OAAO,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,mCAAmC,CAAC,CAAA;AACpI,CAAC;AAFD,8DAEC;AAED,SAAgB,mBAAmB,CA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U,CAAC,QAAQ,CAAC,mCAAmC,CAAC,CAAA;AACpI,CAAC;AAFD,8DAEC;AAED,SAAgB,mBAAmB,CAAC,UAA0D;IAC5F,OAAO,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AAC5G,CAAC;AAFD,kDAEC;AAED,SAAgB,eAAe,CAAC,UAA0D;IACxF,OAAO,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;AACzE,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe,CAAC,UAAiC;IAC/D,OAAO,CACL,OAAO,UAAU,KAAK,QAAQ;QAC9B,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QAC1B,OAAO,UAAU,KAAK,QAAQ;QAC9B,KAAK,IAAI,UAAU;QACnB,cAAc,IAAI,UAAU,CAC7B,CAAA;AACH,CAAC;AARD,0CAQC;AAED,SAAgB,eAAe,CAAC,UAA0D;IACxF,OAAO,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,CAAA,CAAC,iGAAiG;AAC7J,CAAC;AAFD,0CAEC"}
|
|
@@ -4,10 +4,10 @@ import { JwkInfo } from './common';
|
|
|
4
4
|
/**
|
|
5
5
|
* Use whenever we need to pass in an identifier. We can pass in kids, DIDs, IIdentifier objects and x5chains
|
|
6
6
|
*
|
|
7
|
-
* The functions below can be used to check the type, and they also provide the proper runtime types
|
|
7
|
+
* The functions below can be used to check the type, and they also provide the proper 'runtime' types
|
|
8
8
|
*/
|
|
9
|
-
export type ManagedIdentifierType = IIdentifier | string | string[] | JWK;
|
|
10
|
-
export type ManagedIdentifierOpts = (ManagedIdentifierJwkOpts | ManagedIdentifierX5cOpts | ManagedIdentifierDidOpts | ManagedIdentifierKidOpts) & ManagedIdentifierOptsBase;
|
|
9
|
+
export type ManagedIdentifierType = IIdentifier | string | string[] | JWK | IKey;
|
|
10
|
+
export type ManagedIdentifierOpts = (ManagedIdentifierJwkOpts | ManagedIdentifierX5cOpts | ManagedIdentifierDidOpts | ManagedIdentifierKidOpts | ManagedIdentifierKeyOpts) & ManagedIdentifierOptsBase;
|
|
11
11
|
export type ManagedIdentifierOptsBase = {
|
|
12
12
|
method?: ManagedIdentifierMethod;
|
|
13
13
|
identifier: ManagedIdentifierType;
|
|
@@ -30,6 +30,11 @@ export type ManagedIdentifierKidOpts = Omit<ManagedIdentifierOptsBase, 'method'>
|
|
|
30
30
|
identifier: string;
|
|
31
31
|
};
|
|
32
32
|
export declare function isManagedIdentifierKidOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierKidOpts;
|
|
33
|
+
export type ManagedIdentifierKeyOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
|
|
34
|
+
method?: 'key';
|
|
35
|
+
identifier: IKey;
|
|
36
|
+
};
|
|
37
|
+
export declare function isManagedIdentifierKeyOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierKidOpts;
|
|
33
38
|
export type ManagedIdentifierJwkOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
|
|
34
39
|
method?: 'jwk';
|
|
35
40
|
identifier: JWK;
|
|
@@ -50,9 +55,10 @@ export interface IManagedIdentifierResultBase extends ManagedJwkInfo {
|
|
|
50
55
|
issuer?: string;
|
|
51
56
|
}
|
|
52
57
|
export declare function isManagedIdentifierDidResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierDidResult;
|
|
53
|
-
export declare function isManagedIdentifierX5cResult(object: IManagedIdentifierResultBase): object is
|
|
58
|
+
export declare function isManagedIdentifierX5cResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierX5cResult;
|
|
54
59
|
export declare function isManagedIdentifierJwkResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierJwkResult;
|
|
55
60
|
export declare function isManagedIdentifierKidResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierKidResult;
|
|
61
|
+
export declare function isManagedIdentifierKeyResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierKeyResult;
|
|
56
62
|
export interface ManagedIdentifierDidResult extends IManagedIdentifierResultBase {
|
|
57
63
|
method: 'did';
|
|
58
64
|
identifier: IIdentifier;
|
|
@@ -71,11 +77,16 @@ export interface ManagedIdentifierKidResult extends IManagedIdentifierResultBase
|
|
|
71
77
|
issuer: string;
|
|
72
78
|
kid: string;
|
|
73
79
|
}
|
|
80
|
+
export interface ManagedIdentifierKeyResult extends IManagedIdentifierResultBase {
|
|
81
|
+
method: 'key';
|
|
82
|
+
issuer: string;
|
|
83
|
+
kid: string;
|
|
84
|
+
}
|
|
74
85
|
export interface ManagedIdentifierX5cResult extends IManagedIdentifierResultBase {
|
|
75
86
|
method: 'x5c';
|
|
76
87
|
x5c: string[];
|
|
77
88
|
certificate: any;
|
|
78
89
|
}
|
|
79
|
-
export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid';
|
|
80
|
-
export type ManagedIdentifierResult = IManagedIdentifierResultBase & (ManagedIdentifierX5cResult | ManagedIdentifierDidResult | ManagedIdentifierJwkResult | ManagedIdentifierKidResult);
|
|
90
|
+
export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key';
|
|
91
|
+
export type ManagedIdentifierResult = IManagedIdentifierResultBase & (ManagedIdentifierX5cResult | ManagedIdentifierDidResult | ManagedIdentifierJwkResult | ManagedIdentifierKidResult | ManagedIdentifierKeyResult);
|
|
81
92
|
//# sourceMappingURL=managedIdentifierTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedIdentifierTypes.d.ts","sourceRoot":"","sources":["../../src/types/managedIdentifierTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,IAAI,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AAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;AAE3E,MAAM,MAAM,uBAAuB,GAAG,4BAA4B,GAChE,CAAC,0BAA0B,GAAG,0BAA0B,GAAG,0BAA0B,GAAG,0BAA0B,GAAG,0BAA0B,CAAC,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isManagedIdentifierKidResult = exports.isManagedIdentifierJwkResult = exports.isManagedIdentifierX5cResult = exports.isManagedIdentifierDidResult = exports.isManagedIdentifierX5cOpts = exports.isManagedIdentifierJwkOpts = exports.isManagedIdentifierKidOpts = exports.isManagedIdentifierDidOpts = void 0;
|
|
3
|
+
exports.isManagedIdentifierKeyResult = exports.isManagedIdentifierKidResult = exports.isManagedIdentifierJwkResult = exports.isManagedIdentifierX5cResult = exports.isManagedIdentifierDidResult = exports.isManagedIdentifierX5cOpts = exports.isManagedIdentifierJwkOpts = exports.isManagedIdentifierKeyOpts = exports.isManagedIdentifierKidOpts = exports.isManagedIdentifierDidOpts = void 0;
|
|
4
4
|
const common_1 = require("./common");
|
|
5
5
|
function isManagedIdentifierDidOpts(opts) {
|
|
6
6
|
const { identifier } = opts;
|
|
@@ -12,6 +12,11 @@ function isManagedIdentifierKidOpts(opts) {
|
|
|
12
12
|
return ('method' in opts && opts.method === 'kid') || (0, common_1.isKidIdentifier)(identifier);
|
|
13
13
|
}
|
|
14
14
|
exports.isManagedIdentifierKidOpts = isManagedIdentifierKidOpts;
|
|
15
|
+
function isManagedIdentifierKeyOpts(opts) {
|
|
16
|
+
const { identifier } = opts;
|
|
17
|
+
return ('method' in opts && opts.method === 'key') || (0, common_1.isKeyIdentifier)(identifier);
|
|
18
|
+
}
|
|
19
|
+
exports.isManagedIdentifierKeyOpts = isManagedIdentifierKeyOpts;
|
|
15
20
|
function isManagedIdentifierJwkOpts(opts) {
|
|
16
21
|
const { identifier } = opts;
|
|
17
22
|
return ('method' in opts && opts.method === 'jwk') || (0, common_1.isJwkIdentifier)(identifier);
|
|
@@ -38,4 +43,8 @@ function isManagedIdentifierKidResult(object) {
|
|
|
38
43
|
return object && typeof object === 'object' && 'method' in object && object.method === 'kid';
|
|
39
44
|
}
|
|
40
45
|
exports.isManagedIdentifierKidResult = isManagedIdentifierKidResult;
|
|
46
|
+
function isManagedIdentifierKeyResult(object) {
|
|
47
|
+
return object && typeof object === 'object' && 'method' in object && object.method === 'key';
|
|
48
|
+
}
|
|
49
|
+
exports.isManagedIdentifierKeyResult = isManagedIdentifierKeyResult;
|
|
41
50
|
//# sourceMappingURL=managedIdentifierTypes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedIdentifierTypes.js","sourceRoot":"","sources":["../../src/types/managedIdentifierTypes.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"managedIdentifierTypes.js","sourceRoot":"","sources":["../../src/types/managedIdentifierTypes.ts"],"names":[],"mappings":";;;AAEA,qCAAuH;AAoCvH,SAAgB,0BAA0B,CAAC,IAA+B;IACxE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAC3B,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,IAAA,wBAAe,EAAC,UAAU,CAAC,CAAA;AACnF,CAAC;AAHD,gEAGC;AAOD,SAAgB,0BAA0B,CAAC,IAA+B;IACxE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAC3B,OAAO,CAAC,QAAQ,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,IAAI,IAAA,wBAAe,EAAC,UAAU,CAAC,CAAA;AACnF,CAAC;AAHD,gEAGC;AAOD,SAAgB,0BAA0B,CAAC,IAA+B;IACxE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAC3B,OAAO,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,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,CAAA;AAChG,CAAC;AAFD,oEAEC;AAED,SAAgB,4BAA4B,CAAC,MAAoC;IAC/E,OAAO,MAAQ,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,QAAQ,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK,CAAA;AAChG,CAAC;AAFD,oEAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk-ext.identifier-resolution",
|
|
3
|
-
"version": "0.24.1-unstable.
|
|
3
|
+
"version": "0.24.1-unstable.85+f6a9007",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"generate-plugin-schema": "sphereon dev generate-plugin-schema"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.24.1-unstable.
|
|
19
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.24.1-unstable.
|
|
20
|
-
"@sphereon/ssi-sdk-ext.x509-utils": "0.24.1-unstable.
|
|
18
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.24.1-unstable.85+f6a9007",
|
|
19
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.24.1-unstable.85+f6a9007",
|
|
20
|
+
"@sphereon/ssi-sdk-ext.x509-utils": "0.24.1-unstable.85+f6a9007",
|
|
21
21
|
"@sphereon/ssi-sdk.agent-config": "0.29.1-unstable.75",
|
|
22
22
|
"@sphereon/ssi-types": "0.29.1-unstable.75",
|
|
23
23
|
"@veramo/core": "4.2.0",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"uint8arrays": "^3.1.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.24.1-unstable.
|
|
31
|
-
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.24.1-unstable.
|
|
32
|
-
"@sphereon/ssi-sdk-ext.key-manager": "0.24.1-unstable.
|
|
33
|
-
"@sphereon/ssi-sdk-ext.kms-local": "0.24.1-unstable.
|
|
30
|
+
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.24.1-unstable.85+f6a9007",
|
|
31
|
+
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.24.1-unstable.85+f6a9007",
|
|
32
|
+
"@sphereon/ssi-sdk-ext.key-manager": "0.24.1-unstable.85+f6a9007",
|
|
33
|
+
"@sphereon/ssi-sdk-ext.kms-local": "0.24.1-unstable.85+f6a9007",
|
|
34
34
|
"@sphereon/ssi-sdk.dev": "0.29.1-unstable.75",
|
|
35
35
|
"@veramo/data-store": "4.2.0",
|
|
36
36
|
"@veramo/did-manager": "4.2.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"X.509 Certificates",
|
|
65
65
|
"ARF"
|
|
66
66
|
],
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "f6a9007ee413ee23d77214c6f8e8a75b8a7e356d"
|
|
68
68
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -117,10 +117,19 @@
|
|
|
117
117
|
"kty": {
|
|
118
118
|
"type": "string"
|
|
119
119
|
},
|
|
120
|
-
"
|
|
120
|
+
"crv": {
|
|
121
121
|
"type": "string"
|
|
122
122
|
},
|
|
123
|
-
"
|
|
123
|
+
"x": {
|
|
124
|
+
"type": "string"
|
|
125
|
+
},
|
|
126
|
+
"y": {
|
|
127
|
+
"type": "string"
|
|
128
|
+
},
|
|
129
|
+
"e": {
|
|
130
|
+
"type": "string"
|
|
131
|
+
},
|
|
132
|
+
"n": {
|
|
124
133
|
"type": "string"
|
|
125
134
|
},
|
|
126
135
|
"d": {
|
|
@@ -132,9 +141,6 @@
|
|
|
132
141
|
"dq": {
|
|
133
142
|
"type": "string"
|
|
134
143
|
},
|
|
135
|
-
"e": {
|
|
136
|
-
"type": "string"
|
|
137
|
-
},
|
|
138
144
|
"ext": {
|
|
139
145
|
"type": "boolean"
|
|
140
146
|
},
|
|
@@ -150,9 +156,6 @@
|
|
|
150
156
|
"kid": {
|
|
151
157
|
"type": "string"
|
|
152
158
|
},
|
|
153
|
-
"n": {
|
|
154
|
-
"type": "string"
|
|
155
|
-
},
|
|
156
159
|
"oth": {
|
|
157
160
|
"type": "array",
|
|
158
161
|
"items": {
|
|
@@ -182,12 +185,6 @@
|
|
|
182
185
|
"use": {
|
|
183
186
|
"type": "string"
|
|
184
187
|
},
|
|
185
|
-
"x": {
|
|
186
|
-
"type": "string"
|
|
187
|
-
},
|
|
188
|
-
"y": {
|
|
189
|
-
"type": "string"
|
|
190
|
-
},
|
|
191
188
|
"x5c": {
|
|
192
189
|
"type": "array",
|
|
193
190
|
"items": {
|
|
@@ -208,10 +205,10 @@
|
|
|
208
205
|
"description": "JWK \"x5u\" (X.509 URL) Parameter."
|
|
209
206
|
}
|
|
210
207
|
},
|
|
208
|
+
"additionalProperties": {},
|
|
211
209
|
"required": [
|
|
212
210
|
"kty"
|
|
213
|
-
]
|
|
214
|
-
"additionalProperties": {}
|
|
211
|
+
]
|
|
215
212
|
},
|
|
216
213
|
"DIDDocumentSection": {
|
|
217
214
|
"type": "string",
|
|
@@ -1071,6 +1068,30 @@
|
|
|
1071
1068
|
"required": [
|
|
1072
1069
|
"identifier"
|
|
1073
1070
|
]
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
"type": "object",
|
|
1074
|
+
"properties": {
|
|
1075
|
+
"method": {
|
|
1076
|
+
"type": "string",
|
|
1077
|
+
"const": "key"
|
|
1078
|
+
},
|
|
1079
|
+
"identifier": {
|
|
1080
|
+
"$ref": "#/components/schemas/ManagedIdentifierType"
|
|
1081
|
+
},
|
|
1082
|
+
"kmsKeyRef": {
|
|
1083
|
+
"type": "string"
|
|
1084
|
+
},
|
|
1085
|
+
"issuer": {
|
|
1086
|
+
"type": "string"
|
|
1087
|
+
},
|
|
1088
|
+
"kid": {
|
|
1089
|
+
"type": "string"
|
|
1090
|
+
}
|
|
1091
|
+
},
|
|
1092
|
+
"required": [
|
|
1093
|
+
"identifier"
|
|
1094
|
+
]
|
|
1074
1095
|
}
|
|
1075
1096
|
]
|
|
1076
1097
|
},
|
|
@@ -1090,9 +1111,12 @@
|
|
|
1090
1111
|
},
|
|
1091
1112
|
{
|
|
1092
1113
|
"$ref": "#/components/schemas/JWK"
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
"$ref": "#/components/schemas/IKey"
|
|
1093
1117
|
}
|
|
1094
1118
|
],
|
|
1095
|
-
"description": "Use whenever we need to pass in an identifier. We can pass in kids, DIDs, IIdentifier objects and x5chains\n\nThe functions below can be used to check the type, and they also provide the proper runtime types"
|
|
1119
|
+
"description": "Use whenever we need to pass in an identifier. We can pass in kids, DIDs, IIdentifier objects and x5chains\n\nThe functions below can be used to check the type, and they also provide the proper 'runtime' types"
|
|
1096
1120
|
},
|
|
1097
1121
|
"IIdentifier": {
|
|
1098
1122
|
"type": "object",
|
|
@@ -1385,6 +1409,41 @@
|
|
|
1385
1409
|
"method"
|
|
1386
1410
|
]
|
|
1387
1411
|
},
|
|
1412
|
+
{
|
|
1413
|
+
"type": "object",
|
|
1414
|
+
"properties": {
|
|
1415
|
+
"jwk": {
|
|
1416
|
+
"$ref": "#/components/schemas/JWK"
|
|
1417
|
+
},
|
|
1418
|
+
"jwkThumbprint": {
|
|
1419
|
+
"type": "string"
|
|
1420
|
+
},
|
|
1421
|
+
"kmsKeyRef": {
|
|
1422
|
+
"type": "string"
|
|
1423
|
+
},
|
|
1424
|
+
"method": {
|
|
1425
|
+
"$ref": "#/components/schemas/ManagedIdentifierMethod"
|
|
1426
|
+
},
|
|
1427
|
+
"key": {
|
|
1428
|
+
"$ref": "#/components/schemas/IKey"
|
|
1429
|
+
},
|
|
1430
|
+
"kid": {
|
|
1431
|
+
"type": "string"
|
|
1432
|
+
},
|
|
1433
|
+
"issuer": {
|
|
1434
|
+
"type": "string"
|
|
1435
|
+
}
|
|
1436
|
+
},
|
|
1437
|
+
"required": [
|
|
1438
|
+
"issuer",
|
|
1439
|
+
"jwk",
|
|
1440
|
+
"jwkThumbprint",
|
|
1441
|
+
"key",
|
|
1442
|
+
"kid",
|
|
1443
|
+
"kmsKeyRef",
|
|
1444
|
+
"method"
|
|
1445
|
+
]
|
|
1446
|
+
},
|
|
1388
1447
|
{
|
|
1389
1448
|
"type": "object",
|
|
1390
1449
|
"properties": {
|
|
@@ -1428,7 +1487,8 @@
|
|
|
1428
1487
|
"did",
|
|
1429
1488
|
"jwk",
|
|
1430
1489
|
"x5c",
|
|
1431
|
-
"kid"
|
|
1490
|
+
"kid",
|
|
1491
|
+
"key"
|
|
1432
1492
|
]
|
|
1433
1493
|
},
|
|
1434
1494
|
"ManagedIdentifierDidOpts": {
|
|
@@ -1585,6 +1645,66 @@
|
|
|
1585
1645
|
"method"
|
|
1586
1646
|
]
|
|
1587
1647
|
},
|
|
1648
|
+
"ManagedIdentifierKeyOpts": {
|
|
1649
|
+
"type": "object",
|
|
1650
|
+
"properties": {
|
|
1651
|
+
"method": {
|
|
1652
|
+
"type": "string",
|
|
1653
|
+
"const": "key"
|
|
1654
|
+
},
|
|
1655
|
+
"identifier": {
|
|
1656
|
+
"$ref": "#/components/schemas/ManagedIdentifierType"
|
|
1657
|
+
},
|
|
1658
|
+
"kmsKeyRef": {
|
|
1659
|
+
"type": "string"
|
|
1660
|
+
},
|
|
1661
|
+
"issuer": {
|
|
1662
|
+
"type": "string"
|
|
1663
|
+
},
|
|
1664
|
+
"kid": {
|
|
1665
|
+
"type": "string"
|
|
1666
|
+
}
|
|
1667
|
+
},
|
|
1668
|
+
"required": [
|
|
1669
|
+
"identifier"
|
|
1670
|
+
]
|
|
1671
|
+
},
|
|
1672
|
+
"ManagedIdentifierKeyResult": {
|
|
1673
|
+
"type": "object",
|
|
1674
|
+
"properties": {
|
|
1675
|
+
"jwk": {
|
|
1676
|
+
"$ref": "#/components/schemas/JWK"
|
|
1677
|
+
},
|
|
1678
|
+
"jwkThumbprint": {
|
|
1679
|
+
"type": "string"
|
|
1680
|
+
},
|
|
1681
|
+
"kmsKeyRef": {
|
|
1682
|
+
"type": "string"
|
|
1683
|
+
},
|
|
1684
|
+
"method": {
|
|
1685
|
+
"type": "string",
|
|
1686
|
+
"const": "key"
|
|
1687
|
+
},
|
|
1688
|
+
"key": {
|
|
1689
|
+
"$ref": "#/components/schemas/IKey"
|
|
1690
|
+
},
|
|
1691
|
+
"kid": {
|
|
1692
|
+
"type": "string"
|
|
1693
|
+
},
|
|
1694
|
+
"issuer": {
|
|
1695
|
+
"type": "string"
|
|
1696
|
+
}
|
|
1697
|
+
},
|
|
1698
|
+
"required": [
|
|
1699
|
+
"issuer",
|
|
1700
|
+
"jwk",
|
|
1701
|
+
"jwkThumbprint",
|
|
1702
|
+
"key",
|
|
1703
|
+
"kid",
|
|
1704
|
+
"kmsKeyRef",
|
|
1705
|
+
"method"
|
|
1706
|
+
]
|
|
1707
|
+
},
|
|
1588
1708
|
"ManagedIdentifierKidOpts": {
|
|
1589
1709
|
"type": "object",
|
|
1590
1710
|
"properties": {
|
|
@@ -1768,6 +1888,15 @@
|
|
|
1768
1888
|
"$ref": "#/components/schemas/ManagedIdentifierJwkResult"
|
|
1769
1889
|
}
|
|
1770
1890
|
},
|
|
1891
|
+
"identifierManagedGetByKey": {
|
|
1892
|
+
"description": "",
|
|
1893
|
+
"arguments": {
|
|
1894
|
+
"$ref": "#/components/schemas/ManagedIdentifierKeyOpts"
|
|
1895
|
+
},
|
|
1896
|
+
"returnType": {
|
|
1897
|
+
"$ref": "#/components/schemas/ManagedIdentifierKeyResult"
|
|
1898
|
+
}
|
|
1899
|
+
},
|
|
1771
1900
|
"identifierManagedGetByKid": {
|
|
1772
1901
|
"description": "",
|
|
1773
1902
|
"arguments": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IAgentContext, IAgentPlugin, IDIDManager, IKeyManager } from '@veramo/core'
|
|
2
|
-
import { schema } from '..'
|
|
2
|
+
import { ManagedIdentifierKeyOpts, ManagedIdentifierKeyResult, schema } from '..'
|
|
3
3
|
import { getManagedIdentifier, resolveExternalIdentifier } from '../functions'
|
|
4
4
|
import {
|
|
5
5
|
ExternalIdentifierDidOpts,
|
|
@@ -34,6 +34,7 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
34
34
|
identifierManagedGetByKid: this.identifierGetManagedByKid.bind(this),
|
|
35
35
|
identifierManagedGetByJwk: this.identifierGetManagedByJwk.bind(this),
|
|
36
36
|
identifierManagedGetByX5c: this.identifierGetManagedByX5c.bind(this),
|
|
37
|
+
identifierManagedGetByKey: this.identifierGetManagedByKey.bind(this),
|
|
37
38
|
|
|
38
39
|
identifierExternalResolve: this.identifierResolveExternal.bind(this),
|
|
39
40
|
identifierExternalResolveByDid: this.identifierExternalResolveByDid.bind(this),
|
|
@@ -45,12 +46,13 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
45
46
|
/**
|
|
46
47
|
* TODO: Add a cache, as we are retrieving the same keys/info quite often
|
|
47
48
|
*/
|
|
48
|
-
constructor(
|
|
49
|
-
this._crypto =
|
|
49
|
+
constructor(opts?: { crypto?: Crypto }) {
|
|
50
|
+
this._crypto = opts?.crypto ?? global.crypto
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
/**
|
|
53
|
-
* Main method for managed identifiers. We always go through this method (also the
|
|
54
|
+
* Main method for managed identifiers. We always go through this method (also the other methods below) as we want to
|
|
55
|
+
* integrate a plugin for anomaly detection. Having a single method helps
|
|
54
56
|
* @param args
|
|
55
57
|
* @param context
|
|
56
58
|
* @private
|
|
@@ -70,6 +72,10 @@ export class IdentifierResolution implements IAgentPlugin {
|
|
|
70
72
|
return (await this.identifierGetManaged({ ...args, method: 'kid' }, context)) as ManagedIdentifierKidResult
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
private async identifierGetManagedByKey(args: ManagedIdentifierKeyOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierKeyResult> {
|
|
76
|
+
return (await this.identifierGetManaged({ ...args, method: 'key' }, context)) as ManagedIdentifierKeyResult
|
|
77
|
+
}
|
|
78
|
+
|
|
73
79
|
private async identifierGetManagedByJwk(args: ManagedIdentifierJwkOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierJwkResult> {
|
|
74
80
|
return (await this.identifierGetManaged({ ...args, method: 'jwk' }, context)) as ManagedIdentifierJwkResult
|
|
75
81
|
}
|
|
@@ -2,18 +2,21 @@ import { getFirstKeyWithRelation } from '@sphereon/ssi-sdk-ext.did-utils'
|
|
|
2
2
|
import { calculateJwkThumbprint, JWK, toJwk } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
3
3
|
import { pemOrDerToX509Certificate } from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
4
4
|
import { contextHasDidManager, contextHasKeyManager } from '@sphereon/ssi-sdk.agent-config'
|
|
5
|
-
import { IAgentContext, IIdentifier, IKeyManager } from '@veramo/core'
|
|
5
|
+
import { IAgentContext, IIdentifier, IKey, IKeyManager } from '@veramo/core'
|
|
6
6
|
import { CryptoEngine, setEngine } from 'pkijs'
|
|
7
7
|
import {
|
|
8
8
|
isManagedIdentifierDidOpts,
|
|
9
9
|
isManagedIdentifierDidResult,
|
|
10
10
|
isManagedIdentifierJwkOpts,
|
|
11
|
+
isManagedIdentifierKeyOpts,
|
|
11
12
|
isManagedIdentifierKidOpts,
|
|
12
13
|
isManagedIdentifierX5cOpts,
|
|
13
14
|
ManagedIdentifierDidOpts,
|
|
14
15
|
ManagedIdentifierDidResult,
|
|
15
16
|
ManagedIdentifierJwkOpts,
|
|
16
17
|
ManagedIdentifierJwkResult,
|
|
18
|
+
ManagedIdentifierKeyOpts,
|
|
19
|
+
ManagedIdentifierKeyResult,
|
|
17
20
|
ManagedIdentifierKidOpts,
|
|
18
21
|
ManagedIdentifierKidResult,
|
|
19
22
|
ManagedIdentifierOpts,
|
|
@@ -46,6 +49,32 @@ export async function getManagedKidIdentifier(
|
|
|
46
49
|
} satisfies ManagedIdentifierKidResult
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
/**
|
|
53
|
+
* This function is just a convenience function to get a common result. The user already apparently had a key, so could have called the kid version as well
|
|
54
|
+
* @param opts
|
|
55
|
+
* @param _context
|
|
56
|
+
*/
|
|
57
|
+
export async function getManagedKeyIdentifier(opts: ManagedIdentifierKeyOpts, _context?: IAgentContext<any>): Promise<ManagedIdentifierKeyResult> {
|
|
58
|
+
const method = 'key'
|
|
59
|
+
const key: IKey = opts.identifier
|
|
60
|
+
if (opts.kmsKeyRef && opts.kmsKeyRef !== key.kid) {
|
|
61
|
+
return Promise.reject(Error(`Cannot get a managed key object by providing a key and a kmsKeyRef that are different.}`))
|
|
62
|
+
}
|
|
63
|
+
const jwk = toJwk(key.publicKeyHex, key.type, { key })
|
|
64
|
+
const jwkThumbprint = (key.meta?.jwkThumbprint as string) ?? calculateJwkThumbprint({ jwk })
|
|
65
|
+
const kid = opts.kid ?? (key.meta?.verificationMethod?.id as string) ?? jwkThumbprint
|
|
66
|
+
const issuer = opts.issuer ?? kid // The different identifiers should set the value. Defaults to the kid
|
|
67
|
+
return {
|
|
68
|
+
method,
|
|
69
|
+
key,
|
|
70
|
+
jwk,
|
|
71
|
+
jwkThumbprint,
|
|
72
|
+
kid,
|
|
73
|
+
issuer,
|
|
74
|
+
kmsKeyRef: key.kid,
|
|
75
|
+
} satisfies ManagedIdentifierKeyResult
|
|
76
|
+
}
|
|
77
|
+
|
|
49
78
|
export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, context: IAgentContext<any>): Promise<ManagedIdentifierDidResult> {
|
|
50
79
|
const method = 'did'
|
|
51
80
|
if (!contextHasDidManager(context)) {
|
|
@@ -166,6 +195,8 @@ export async function getManagedIdentifier(
|
|
|
166
195
|
resolutionResult = await getManagedJwkIdentifier(opts, context)
|
|
167
196
|
} else if (isManagedIdentifierX5cOpts(opts)) {
|
|
168
197
|
resolutionResult = await getManagedX5cIdentifier(opts, context)
|
|
198
|
+
} else if (isManagedIdentifierKeyOpts(opts)) {
|
|
199
|
+
resolutionResult = await getManagedKeyIdentifier(opts, context)
|
|
169
200
|
} else {
|
|
170
201
|
return Promise.reject(Error(`Could not determine identifier method. Please provide explicitly`))
|
|
171
202
|
}
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
ManagedIdentifierDidResult,
|
|
13
13
|
ManagedIdentifierJwkOpts,
|
|
14
14
|
ManagedIdentifierJwkResult,
|
|
15
|
+
ManagedIdentifierKeyOpts,
|
|
16
|
+
ManagedIdentifierKeyResult,
|
|
15
17
|
ManagedIdentifierKidOpts,
|
|
16
18
|
ManagedIdentifierKidResult,
|
|
17
19
|
ManagedIdentifierOpts,
|
|
@@ -26,6 +28,8 @@ import {
|
|
|
26
28
|
export interface IIdentifierResolution extends IPluginMethodMap {
|
|
27
29
|
/**
|
|
28
30
|
* Main method for managed identifiers. We always go through this method (also the others) as we want to integrate a plugin for anomaly detection. Having a single method helps
|
|
31
|
+
*
|
|
32
|
+
* The end result of all these methods is a common baseline response that allows to use a key from the registered KMS systems. It also provides kid and iss(uer) values that can be used in a JWT/JWS for instance
|
|
29
33
|
* @param args
|
|
30
34
|
* @param context
|
|
31
35
|
* @public
|
|
@@ -40,6 +44,10 @@ export interface IIdentifierResolution extends IPluginMethodMap {
|
|
|
40
44
|
|
|
41
45
|
identifierManagedGetByX5c(args: ManagedIdentifierX5cOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierX5cResult>
|
|
42
46
|
|
|
47
|
+
identifierManagedGetByKey(args: ManagedIdentifierKeyOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierKeyResult>
|
|
48
|
+
|
|
49
|
+
// TODO: We can create a custom managed identifier method allowing developers to register a callback function to get their implementation hooked up. Needs more investigation as it would also impact the KMS
|
|
50
|
+
|
|
43
51
|
/**
|
|
44
52
|
* Main method for external identifiers. We always go through this method (also the others) as we want to integrate a plugin for anomaly detection. Having a single method helps
|
|
45
53
|
* @param args
|
package/src/types/common.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JWK } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
2
|
-
import { IIdentifier } from '@veramo/core'
|
|
2
|
+
import { IIdentifier, IKey } from '@veramo/core'
|
|
3
3
|
import { ExternalIdentifierType } from './externalIdentifierTypes'
|
|
4
4
|
import { ManagedIdentifierType } from './managedIdentifierTypes'
|
|
5
5
|
|
|
@@ -32,6 +32,16 @@ export function isKidIdentifier(identifier: ManagedIdentifierType | ExternalIden
|
|
|
32
32
|
return typeof identifier === 'string' && !identifier.startsWith('did:')
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
export function isKeyIdentifier(identifier: ManagedIdentifierType): identifier is IKey {
|
|
36
|
+
return (
|
|
37
|
+
typeof identifier === 'string' &&
|
|
38
|
+
!Array.isArray(identifier) &&
|
|
39
|
+
typeof identifier === 'object' &&
|
|
40
|
+
`kid` in identifier &&
|
|
41
|
+
'publicKeyHex' in identifier
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
export function isX5cIdentifier(identifier: ManagedIdentifierType | ExternalIdentifierType): identifier is string[] {
|
|
36
46
|
return Array.isArray(identifier) && identifier.length > 0 // todo: Do we want to do additional validation? We know it must be DER and thus hex for instance
|
|
37
47
|
}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { JWK } from '@sphereon/ssi-sdk-ext.key-utils'
|
|
2
2
|
import { DIDDocumentSection, IIdentifier, IKey, TKeyType } from '@veramo/core'
|
|
3
|
-
import { isDidIdentifier, isJwkIdentifier, isKidIdentifier, isX5cIdentifier, JwkInfo } from './common'
|
|
3
|
+
import { isDidIdentifier, isJwkIdentifier, isKeyIdentifier, isKidIdentifier, isX5cIdentifier, JwkInfo } from './common'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Use whenever we need to pass in an identifier. We can pass in kids, DIDs, IIdentifier objects and x5chains
|
|
7
7
|
*
|
|
8
|
-
* The functions below can be used to check the type, and they also provide the proper runtime types
|
|
8
|
+
* The functions below can be used to check the type, and they also provide the proper 'runtime' types
|
|
9
9
|
*/
|
|
10
|
-
export type ManagedIdentifierType = IIdentifier /*did*/ | string /*did or kid*/ | string[] /*x5c*/ | JWK
|
|
11
|
-
|
|
12
|
-
export type ManagedIdentifierOpts = (
|
|
10
|
+
export type ManagedIdentifierType = IIdentifier /*did*/ | string /*did or kid*/ | string[] /*x5c*/ | JWK | IKey
|
|
11
|
+
|
|
12
|
+
export type ManagedIdentifierOpts = (
|
|
13
|
+
| ManagedIdentifierJwkOpts
|
|
14
|
+
| ManagedIdentifierX5cOpts
|
|
15
|
+
| ManagedIdentifierDidOpts
|
|
16
|
+
| ManagedIdentifierKidOpts
|
|
17
|
+
| ManagedIdentifierKeyOpts
|
|
18
|
+
) &
|
|
13
19
|
ManagedIdentifierOptsBase
|
|
14
20
|
|
|
15
21
|
export type ManagedIdentifierOptsBase = {
|
|
16
22
|
method?: ManagedIdentifierMethod // If provided always takes precedences otherwise it will be inferred from the identifier
|
|
17
23
|
identifier: ManagedIdentifierType
|
|
18
|
-
kmsKeyRef?: string
|
|
24
|
+
kmsKeyRef?: string // The key reference for the KMS system. If provided this value will be used to determine the appropriate key. Otherwise it will be inferred
|
|
19
25
|
issuer?: string // can be used when a specific issuer needs to end up, for instance when signing JWTs. Will be returned or inferred if not provided
|
|
20
26
|
kid?: string // can be used when a specific kid value needs to be used. For instance when signing JWTs. Will be returned or inferred if not provided
|
|
21
27
|
}
|
|
@@ -45,6 +51,16 @@ export function isManagedIdentifierKidOpts(opts: ManagedIdentifierOptsBase): opt
|
|
|
45
51
|
return ('method' in opts && opts.method === 'kid') || isKidIdentifier(identifier)
|
|
46
52
|
}
|
|
47
53
|
|
|
54
|
+
export type ManagedIdentifierKeyOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
|
|
55
|
+
method?: 'key'
|
|
56
|
+
identifier: IKey
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function isManagedIdentifierKeyOpts(opts: ManagedIdentifierOptsBase): opts is ManagedIdentifierKidOpts {
|
|
60
|
+
const { identifier } = opts
|
|
61
|
+
return ('method' in opts && opts.method === 'key') || isKeyIdentifier(identifier)
|
|
62
|
+
}
|
|
63
|
+
|
|
48
64
|
export type ManagedIdentifierJwkOpts = Omit<ManagedIdentifierOptsBase, 'method'> & {
|
|
49
65
|
method?: 'jwk'
|
|
50
66
|
identifier: JWK
|
|
@@ -80,7 +96,7 @@ export function isManagedIdentifierDidResult(object: IManagedIdentifierResultBas
|
|
|
80
96
|
return object!! && typeof object === 'object' && 'method' in object && object.method === 'did'
|
|
81
97
|
}
|
|
82
98
|
|
|
83
|
-
export function isManagedIdentifierX5cResult(object: IManagedIdentifierResultBase): object is
|
|
99
|
+
export function isManagedIdentifierX5cResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierX5cResult {
|
|
84
100
|
return object!! && typeof object === 'object' && 'method' in object && object.method === 'x5c'
|
|
85
101
|
}
|
|
86
102
|
|
|
@@ -92,6 +108,10 @@ export function isManagedIdentifierKidResult(object: IManagedIdentifierResultBas
|
|
|
92
108
|
return object!! && typeof object === 'object' && 'method' in object && object.method === 'kid'
|
|
93
109
|
}
|
|
94
110
|
|
|
111
|
+
export function isManagedIdentifierKeyResult(object: IManagedIdentifierResultBase): object is ManagedIdentifierKeyResult {
|
|
112
|
+
return object!! && typeof object === 'object' && 'method' in object && object.method === 'key'
|
|
113
|
+
}
|
|
114
|
+
|
|
95
115
|
export interface ManagedIdentifierDidResult extends IManagedIdentifierResultBase {
|
|
96
116
|
method: 'did'
|
|
97
117
|
identifier: IIdentifier
|
|
@@ -114,13 +134,19 @@ export interface ManagedIdentifierKidResult extends IManagedIdentifierResultBase
|
|
|
114
134
|
kid: string
|
|
115
135
|
}
|
|
116
136
|
|
|
137
|
+
export interface ManagedIdentifierKeyResult extends IManagedIdentifierResultBase {
|
|
138
|
+
method: 'key'
|
|
139
|
+
issuer: string
|
|
140
|
+
kid: string
|
|
141
|
+
}
|
|
142
|
+
|
|
117
143
|
export interface ManagedIdentifierX5cResult extends IManagedIdentifierResultBase {
|
|
118
144
|
method: 'x5c'
|
|
119
145
|
x5c: string[]
|
|
120
146
|
certificate: any // Certificate(JSON_, but trips schema generator. Probably want to create our own DTO
|
|
121
147
|
}
|
|
122
148
|
|
|
123
|
-
export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid'
|
|
149
|
+
export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key'
|
|
124
150
|
|
|
125
151
|
export type ManagedIdentifierResult = IManagedIdentifierResultBase &
|
|
126
|
-
(ManagedIdentifierX5cResult | ManagedIdentifierDidResult | ManagedIdentifierJwkResult | ManagedIdentifierKidResult)
|
|
152
|
+
(ManagedIdentifierX5cResult | ManagedIdentifierDidResult | ManagedIdentifierJwkResult | ManagedIdentifierKidResult | ManagedIdentifierKeyResult)
|