@sphereon/ssi-sdk-ext.identifier-resolution 0.24.1-unstable.85 → 0.24.1-unstable.88
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/functions/managedIdentifierFunctions.d.ts +8 -1
- package/dist/functions/managedIdentifierFunctions.d.ts.map +1 -1
- package/dist/functions/managedIdentifierFunctions.js +12 -1
- package/dist/functions/managedIdentifierFunctions.js.map +1 -1
- package/dist/types/managedIdentifierTypes.d.ts +1 -0
- package/dist/types/managedIdentifierTypes.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/functions/managedIdentifierFunctions.ts +188 -177
- package/src/types/managedIdentifierTypes.ts +3 -0
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { IRequiredContext } from "@sphereon/ssi-sdk-ext.did-provider-jwk";
|
|
1
2
|
import { IAgentContext, IKeyManager } from '@veramo/core';
|
|
2
|
-
import { ManagedIdentifierDidOpts, ManagedIdentifierDidResult, ManagedIdentifierJwkOpts, ManagedIdentifierJwkResult, ManagedIdentifierKeyOpts, ManagedIdentifierKeyResult, ManagedIdentifierKidOpts, ManagedIdentifierKidResult, ManagedIdentifierOpts, ManagedIdentifierResult, ManagedIdentifierX5cOpts, ManagedIdentifierX5cResult } from '../types';
|
|
3
|
+
import { ManagedIdentifierDidOpts, ManagedIdentifierDidResult, ManagedIdentifierJwkOpts, ManagedIdentifierJwkResult, ManagedIdentifierKeyOpts, ManagedIdentifierKeyResult, ManagedIdentifierKidOpts, ManagedIdentifierKidResult, ManagedIdentifierOpts, ManagedIdentifierOptsOrResult, ManagedIdentifierResult, ManagedIdentifierX5cOpts, ManagedIdentifierX5cResult } from '../types';
|
|
3
4
|
export declare function getManagedKidIdentifier(opts: ManagedIdentifierKidOpts, context: IAgentContext<IKeyManager>): Promise<ManagedIdentifierKidResult>;
|
|
5
|
+
/**
|
|
6
|
+
* Allows to get a managed identifier result in case identifier options are passed in, but returns the identifier directly in case results are passed in. This means resolution can have happened before, or happens in this method
|
|
7
|
+
* @param identifier
|
|
8
|
+
* @param context
|
|
9
|
+
*/
|
|
10
|
+
export declare function ensureManagedIdentifierResult(identifier: ManagedIdentifierOptsOrResult, context: IRequiredContext): Promise<ManagedIdentifierResult>;
|
|
4
11
|
/**
|
|
5
12
|
* 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
13
|
* @param opts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedIdentifierFunctions.d.ts","sourceRoot":"","sources":["../../src/functions/managedIdentifierFunctions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"managedIdentifierFunctions.d.ts","sourceRoot":"","sources":["../../src/functions/managedIdentifierFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,wCAAwC,CAAC;AAKxE,OAAO,EAAC,aAAa,EAAqB,WAAW,EAAC,MAAM,cAAc,CAAA;AAE1E,OAAO,EAOH,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,EAC1B,qBAAqB,EAAE,6BAA6B,EACpD,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAC7B,MAAM,UAAU,CAAA;AAEjB,wBAAsB,uBAAuB,CACzC,IAAI,EAAE,wBAAwB,EAC9B,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GACpC,OAAO,CAAC,0BAA0B,CAAC,CAmBrC;AAGD;;;;GAIG;AACH,wBAAsB,6BAA6B,CAAC,UAAU,EAAE,6BAA6B,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAE1J;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,CACzC,IAAI,EAAE,wBAAwB,EAC9B,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GACpC,OAAO,CAAC,0BAA0B,CAAC,CAmBrC;AAED,wBAAsB,uBAAuB,CACzC,IAAI,EAAE,wBAAwB,GAAG;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,EACD,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GACpC,OAAO,CAAC,0BAA0B,CAAC,CA8BrC;AAED,wBAAsB,oBAAoB,CACtC,IAAI,EAAE,qBAAqB,GAAG;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB,EACD,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GACpC,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.getManagedKeyIdentifier = exports.getManagedKidIdentifier = void 0;
|
|
12
|
+
exports.getManagedIdentifier = exports.getManagedX5cIdentifier = exports.getManagedJwkIdentifier = exports.getManagedDidIdentifier = exports.getManagedKeyIdentifier = exports.ensureManagedIdentifierResult = 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,17 @@ function getManagedKidIdentifier(opts, context) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
exports.getManagedKidIdentifier = getManagedKidIdentifier;
|
|
43
|
+
/**
|
|
44
|
+
* Allows to get a managed identifier result in case identifier options are passed in, but returns the identifier directly in case results are passed in. This means resolution can have happened before, or happens in this method
|
|
45
|
+
* @param identifier
|
|
46
|
+
* @param context
|
|
47
|
+
*/
|
|
48
|
+
function ensureManagedIdentifierResult(identifier, context) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
return 'key' in identifier && 'kmsKeyRef' in identifier && 'method' in identifier && !('identifier' in identifier) ? identifier : yield context.agent.identifierManagedGet(identifier);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
exports.ensureManagedIdentifierResult = ensureManagedIdentifierResult;
|
|
43
54
|
/**
|
|
44
55
|
* 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
56
|
* @param opts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedIdentifierFunctions.js","sourceRoot":"","sources":["../../src/functions/managedIdentifierFunctions.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"managedIdentifierFunctions.js","sourceRoot":"","sources":["../../src/functions/managedIdentifierFunctions.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,2EAAuE;AACvE,2EAAkF;AAClF,6EAA0E;AAC1E,yEAAyF;AAEzF,iCAA6C;AAC7C,oCAmBiB;AAEjB,SAAsB,uBAAuB,CACzC,IAA8B,EAC9B,OAAmC;;;QAEnC,MAAM,MAAM,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,IAAA,2CAAoB,EAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oEAAoE,CAAC,CAAC,CAAA;QACtG,CAAC;QACD,M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IdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key';
|
|
91
91
|
export type ManagedIdentifierResult = IManagedIdentifierResultBase & (ManagedIdentifierX5cResult | ManagedIdentifierDidResult | ManagedIdentifierJwkResult | ManagedIdentifierKidResult | ManagedIdentifierKeyResult);
|
|
92
|
+
export type ManagedIdentifierOptsOrResult = ManagedIdentifierResult | ManagedIdentifierOpts;
|
|
92
93
|
//# 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,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC9E,OAAO,EAAuF,OAAO,EAAE,MAAM,UAAU,CAAA;AAEvH;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG,WAAW,GAAW,MAAM,GAAkB,MAAM,EAAE,GAAW,GAAG,GAAG,IAAI,CAAA;AAE/G,MAAM,MAAM,qBAAqB,GAAG,CAChC,wBAAwB,GACxB,wBAAwB,GACxB,wBAAwB,GACxB,wBAAwB,GACxB,wBAAwB,CAC3B,GACC,yBAAyB,CAAA;AAE3B,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,CAAC,EAAE,uBAAuB,CAAA;IAChC,UAAU,EAAE,qBAAqB,CAAA;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,yBAAyB,EAAE,QAAQ,CAAC,GAAG;IACjF,MAAM,CAAC,EAAE,KAAK,CAAA;IACd,UAAU,EAAE,WAAW,GAAG,MAAM,CAAA;IACh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AAQ,4BAA4B;IAC9E,MAAM,EAAE,KAAK,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,0BAA2B,SAAQ,4BAA4B;IAC9E,MAAM,EAAE,KAAK,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,0BAA2B,SAAQ,4BAA4B;IAC9E,MAAM,EAAE,KAAK,CAAA;IACb,GAAG,EAAE,MAAM,EAAE,CAAA;IACb,WAAW,EAAE,GAAG,CAAA;CACjB;AAED,MAAM,MAAM,uBAAuB,GAAG,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;AAGlJ,MAAM,MAAM,6BAA6B,GAAG,uBAAuB,GAAG,qBAAqB,CAAA"}
|
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.88+7f70f66",
|
|
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.88+7f70f66",
|
|
19
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.24.1-unstable.88+7f70f66",
|
|
20
|
+
"@sphereon/ssi-sdk-ext.x509-utils": "0.24.1-unstable.88+7f70f66",
|
|
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.88+7f70f66",
|
|
31
|
+
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.24.1-unstable.88+7f70f66",
|
|
32
|
+
"@sphereon/ssi-sdk-ext.key-manager": "0.24.1-unstable.88+7f70f66",
|
|
33
|
+
"@sphereon/ssi-sdk-ext.kms-local": "0.24.1-unstable.88+7f70f66",
|
|
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": "7f70f6609cb82dacba2db07710b62ffb3cc9a26e"
|
|
68
68
|
}
|
|
@@ -1,52 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import {IRequiredContext} from "@sphereon/ssi-sdk-ext.did-provider-jwk";
|
|
2
|
+
import {getFirstKeyWithRelation} from '@sphereon/ssi-sdk-ext.did-utils'
|
|
3
|
+
import {calculateJwkThumbprint, JWK, toJwk} from '@sphereon/ssi-sdk-ext.key-utils'
|
|
4
|
+
import {pemOrDerToX509Certificate} from '@sphereon/ssi-sdk-ext.x509-utils'
|
|
5
|
+
import {contextHasDidManager, contextHasKeyManager} from '@sphereon/ssi-sdk.agent-config'
|
|
6
|
+
import {IAgentContext, IIdentifier, IKey, IKeyManager} from '@veramo/core'
|
|
7
|
+
import {CryptoEngine, setEngine} from 'pkijs'
|
|
7
8
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
isManagedIdentifierDidOpts,
|
|
10
|
+
isManagedIdentifierDidResult,
|
|
11
|
+
isManagedIdentifierJwkOpts,
|
|
12
|
+
isManagedIdentifierKeyOpts,
|
|
13
|
+
isManagedIdentifierKidOpts,
|
|
14
|
+
isManagedIdentifierX5cOpts,
|
|
15
|
+
ManagedIdentifierDidOpts,
|
|
16
|
+
ManagedIdentifierDidResult,
|
|
17
|
+
ManagedIdentifierJwkOpts,
|
|
18
|
+
ManagedIdentifierJwkResult,
|
|
19
|
+
ManagedIdentifierKeyOpts,
|
|
20
|
+
ManagedIdentifierKeyResult,
|
|
21
|
+
ManagedIdentifierKidOpts,
|
|
22
|
+
ManagedIdentifierKidResult,
|
|
23
|
+
ManagedIdentifierOpts, ManagedIdentifierOptsOrResult,
|
|
24
|
+
ManagedIdentifierResult,
|
|
25
|
+
ManagedIdentifierX5cOpts,
|
|
26
|
+
ManagedIdentifierX5cResult,
|
|
26
27
|
} from '../types'
|
|
27
28
|
|
|
28
29
|
export async function getManagedKidIdentifier(
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
opts: ManagedIdentifierKidOpts,
|
|
31
|
+
context: IAgentContext<IKeyManager>
|
|
31
32
|
): Promise<ManagedIdentifierKidResult> {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
const method = 'kid'
|
|
34
|
+
if (!contextHasKeyManager(context)) {
|
|
35
|
+
return Promise.reject(Error(`Cannot get Key/JWK identifier if KeyManager plugin is not enabled!`))
|
|
36
|
+
}
|
|
37
|
+
const key = await context.agent.keyManagerGet({kid: opts.kmsKeyRef ?? opts.identifier})
|
|
38
|
+
const jwk = toJwk(key.publicKeyHex, key.type, {key})
|
|
39
|
+
const jwkThumbprint = (key.meta?.jwkThumbprint as string) ?? calculateJwkThumbprint({jwk})
|
|
40
|
+
const kid = opts.kid ?? (key.meta?.verificationMethod?.id as string) ?? jwkThumbprint
|
|
41
|
+
const issuer = opts.issuer ?? kid // The different identifiers should set the value. Defaults to the kid
|
|
42
|
+
return {
|
|
43
|
+
method,
|
|
44
|
+
key,
|
|
45
|
+
jwk,
|
|
46
|
+
jwkThumbprint,
|
|
47
|
+
kid,
|
|
48
|
+
issuer,
|
|
49
|
+
kmsKeyRef: key.kid,
|
|
50
|
+
} satisfies ManagedIdentifierKidResult
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Allows to get a managed identifier result in case identifier options are passed in, but returns the identifier directly in case results are passed in. This means resolution can have happened before, or happens in this method
|
|
56
|
+
* @param identifier
|
|
57
|
+
* @param context
|
|
58
|
+
*/
|
|
59
|
+
export async function ensureManagedIdentifierResult(identifier: ManagedIdentifierOptsOrResult, context: IRequiredContext): Promise<ManagedIdentifierResult> {
|
|
60
|
+
return 'key' in identifier && 'kmsKeyRef' in identifier && 'method' in identifier && !('identifier' in identifier) ? identifier : await context.agent.identifierManagedGet(identifier)
|
|
50
61
|
}
|
|
51
62
|
|
|
52
63
|
/**
|
|
@@ -55,155 +66,155 @@ export async function getManagedKidIdentifier(
|
|
|
55
66
|
* @param _context
|
|
56
67
|
*/
|
|
57
68
|
export async function getManagedKeyIdentifier(opts: ManagedIdentifierKeyOpts, _context?: IAgentContext<any>): Promise<ManagedIdentifierKeyResult> {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
const method = 'key'
|
|
70
|
+
const key: IKey = opts.identifier
|
|
71
|
+
if (opts.kmsKeyRef && opts.kmsKeyRef !== key.kid) {
|
|
72
|
+
return Promise.reject(Error(`Cannot get a managed key object by providing a key and a kmsKeyRef that are different.}`))
|
|
73
|
+
}
|
|
74
|
+
const jwk = toJwk(key.publicKeyHex, key.type, {key})
|
|
75
|
+
const jwkThumbprint = (key.meta?.jwkThumbprint as string) ?? calculateJwkThumbprint({jwk})
|
|
76
|
+
const kid = opts.kid ?? (key.meta?.verificationMethod?.id as string) ?? jwkThumbprint
|
|
77
|
+
const issuer = opts.issuer ?? kid // The different identifiers should set the value. Defaults to the kid
|
|
78
|
+
return {
|
|
79
|
+
method,
|
|
80
|
+
key,
|
|
81
|
+
jwk,
|
|
82
|
+
jwkThumbprint,
|
|
83
|
+
kid,
|
|
84
|
+
issuer,
|
|
85
|
+
kmsKeyRef: key.kid,
|
|
86
|
+
} satisfies ManagedIdentifierKeyResult
|
|
76
87
|
}
|
|
77
88
|
|
|
78
89
|
export async function getManagedDidIdentifier(opts: ManagedIdentifierDidOpts, context: IAgentContext<any>): Promise<ManagedIdentifierDidResult> {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
const method = 'did'
|
|
91
|
+
if (!contextHasDidManager(context)) {
|
|
92
|
+
return Promise.reject(Error(`Cannot get DID identifier if DID Manager plugin is not enabled!`))
|
|
93
|
+
}
|
|
83
94
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
95
|
+
let identifier: IIdentifier
|
|
96
|
+
if (typeof opts.identifier === 'string') {
|
|
97
|
+
identifier = await context.agent.didManagerGet({did: opts.identifier.split('#')[0]})
|
|
98
|
+
} else {
|
|
99
|
+
identifier = opts.identifier
|
|
100
|
+
}
|
|
90
101
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
102
|
+
const did = identifier.did
|
|
103
|
+
const keys = identifier?.keys // fixme: We really want to return the vmRelationship keys here actually
|
|
104
|
+
const extendedKey = await getFirstKeyWithRelation(
|
|
105
|
+
{
|
|
106
|
+
...opts,
|
|
107
|
+
identifier,
|
|
108
|
+
vmRelationship: opts.vmRelationship ?? 'verificationMethod',
|
|
109
|
+
},
|
|
110
|
+
context
|
|
111
|
+
)
|
|
112
|
+
const key = extendedKey
|
|
113
|
+
const controllerKeyId = identifier.controllerKeyId
|
|
114
|
+
const jwk = toJwk(key.publicKeyHex, key.type, {key})
|
|
115
|
+
const jwkThumbprint = key.meta?.jwkThumbprint ?? calculateJwkThumbprint({jwk})
|
|
116
|
+
const kid = opts.kid ?? extendedKey.meta?.verificationMethod?.id
|
|
117
|
+
const issuer = opts.issuer ?? did
|
|
118
|
+
return {
|
|
119
|
+
method,
|
|
120
|
+
key,
|
|
121
|
+
did,
|
|
122
|
+
kmsKeyRef: key.kid,
|
|
123
|
+
jwk,
|
|
124
|
+
jwkThumbprint,
|
|
125
|
+
controllerKeyId,
|
|
126
|
+
kid,
|
|
127
|
+
keys,
|
|
128
|
+
issuer,
|
|
129
|
+
identifier,
|
|
130
|
+
}
|
|
120
131
|
}
|
|
121
132
|
|
|
122
133
|
export async function getManagedJwkIdentifier(
|
|
123
|
-
|
|
124
|
-
|
|
134
|
+
opts: ManagedIdentifierJwkOpts,
|
|
135
|
+
context: IAgentContext<IKeyManager>
|
|
125
136
|
): Promise<ManagedIdentifierJwkResult> {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
const method = 'jwk'
|
|
138
|
+
const {kid, issuer} = opts
|
|
139
|
+
if (!contextHasKeyManager(context)) {
|
|
140
|
+
return Promise.reject(Error(`Cannot get Key/JWK identifier if KeyManager plugin is not enabled!`))
|
|
141
|
+
}
|
|
142
|
+
const key = await context.agent.keyManagerGet({kid: opts.kmsKeyRef ?? calculateJwkThumbprint({jwk: opts.identifier})})
|
|
143
|
+
const jwk = opts.identifier ?? toJwk(key.publicKeyHex, key.type, {key})
|
|
144
|
+
const jwkThumbprint = (key.meta?.jwkThumbprint as string) ?? calculateJwkThumbprint({jwk})
|
|
145
|
+
// we explicitly do not set the kid and issuer, meaning it can remain null. Normally you do not provide a kid and issuer with Jwks.
|
|
146
|
+
return {
|
|
147
|
+
method,
|
|
148
|
+
key,
|
|
149
|
+
kmsKeyRef: key.kid,
|
|
150
|
+
jwk,
|
|
151
|
+
jwkThumbprint,
|
|
152
|
+
kid,
|
|
153
|
+
issuer,
|
|
154
|
+
} satisfies ManagedIdentifierJwkResult
|
|
144
155
|
}
|
|
145
156
|
|
|
146
157
|
export async function getManagedX5cIdentifier(
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
158
|
+
opts: ManagedIdentifierX5cOpts & {
|
|
159
|
+
crypto?: Crypto
|
|
160
|
+
},
|
|
161
|
+
context: IAgentContext<IKeyManager>
|
|
151
162
|
): Promise<ManagedIdentifierX5cResult> {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
163
|
+
const {kid, issuer} = opts
|
|
164
|
+
const method = 'x5c'
|
|
165
|
+
const x5c = opts.identifier
|
|
166
|
+
if (x5c.length === 0) {
|
|
167
|
+
return Promise.reject(`Cannot resolve x5c when an empty x5c is passed in`)
|
|
168
|
+
} else if (!contextHasKeyManager(context)) {
|
|
169
|
+
return Promise.reject(Error(`Cannot get X5c identifier if KeyManager plugin is not enabled!`))
|
|
170
|
+
}
|
|
171
|
+
const cryptoImpl = opts.crypto ?? crypto
|
|
172
|
+
const certificate = pemOrDerToX509Certificate(x5c[0])
|
|
173
|
+
const cryptoEngine = new CryptoEngine({name: 'identifier_resolver_managed', crypto: cryptoImpl})
|
|
174
|
+
setEngine(cryptoEngine.name, cryptoEngine)
|
|
175
|
+
const pk = await certificate.getPublicKey(undefined, cryptoEngine)
|
|
176
|
+
const jwk = (await cryptoEngine.subtle.exportKey('jwk', pk)) as JWK
|
|
177
|
+
const jwkThumbprint = calculateJwkThumbprint({jwk})
|
|
178
|
+
const key = await context.agent.keyManagerGet({kid: opts.kmsKeyRef ?? jwkThumbprint})
|
|
179
|
+
// we explicitly do not set the kid and issuer, meaning it can remain null. Normally you do not provide a kid and issuer with x5c.
|
|
169
180
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
return {
|
|
182
|
+
method,
|
|
183
|
+
x5c,
|
|
184
|
+
certificate,
|
|
185
|
+
jwk,
|
|
186
|
+
jwkThumbprint,
|
|
187
|
+
key,
|
|
188
|
+
kmsKeyRef: key.kid,
|
|
189
|
+
kid,
|
|
190
|
+
issuer,
|
|
191
|
+
} satisfies ManagedIdentifierX5cResult
|
|
181
192
|
}
|
|
182
193
|
|
|
183
194
|
export async function getManagedIdentifier(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
195
|
+
opts: ManagedIdentifierOpts & {
|
|
196
|
+
crypto?: Crypto
|
|
197
|
+
},
|
|
198
|
+
context: IAgentContext<IKeyManager>
|
|
188
199
|
): Promise<ManagedIdentifierResult> {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
200
|
+
let resolutionResult: ManagedIdentifierResult
|
|
201
|
+
if (isManagedIdentifierKidOpts(opts)) {
|
|
202
|
+
resolutionResult = await getManagedKidIdentifier(opts, context)
|
|
203
|
+
} else if (isManagedIdentifierDidOpts(opts)) {
|
|
204
|
+
resolutionResult = await getManagedDidIdentifier(opts, context)
|
|
205
|
+
} else if (isManagedIdentifierJwkOpts(opts)) {
|
|
206
|
+
resolutionResult = await getManagedJwkIdentifier(opts, context)
|
|
207
|
+
} else if (isManagedIdentifierX5cOpts(opts)) {
|
|
208
|
+
resolutionResult = await getManagedX5cIdentifier(opts, context)
|
|
209
|
+
} else if (isManagedIdentifierKeyOpts(opts)) {
|
|
210
|
+
resolutionResult = await getManagedKeyIdentifier(opts, context)
|
|
211
|
+
} else {
|
|
212
|
+
return Promise.reject(Error(`Could not determine identifier method. Please provide explicitly`))
|
|
213
|
+
}
|
|
214
|
+
const {key} = resolutionResult
|
|
215
|
+
if (!key || (isManagedIdentifierDidOpts(opts) && isManagedIdentifierDidResult(resolutionResult) && !resolutionResult.identifier)) {
|
|
216
|
+
console.log(`Cannot find identifier`, opts.identifier)
|
|
217
|
+
return Promise.reject(`Cannot find identifier ${opts.identifier}`)
|
|
218
|
+
}
|
|
219
|
+
return resolutionResult
|
|
209
220
|
}
|
|
@@ -150,3 +150,6 @@ export type ManagedIdentifierMethod = 'did' | 'jwk' | 'x5c' | 'kid' | 'key'
|
|
|
150
150
|
|
|
151
151
|
export type ManagedIdentifierResult = IManagedIdentifierResultBase &
|
|
152
152
|
(ManagedIdentifierX5cResult | ManagedIdentifierDidResult | ManagedIdentifierJwkResult | ManagedIdentifierKidResult | ManagedIdentifierKeyResult)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
export type ManagedIdentifierOptsOrResult = ManagedIdentifierResult | ManagedIdentifierOpts
|