@sphereon/ssi-sdk-ext.identifier-resolution 0.28.1-feature.oyd.cmsm.improv.21 → 0.28.1-next.54
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/index.cjs +12080 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +439 -0
- package/dist/index.d.ts +434 -7
- package/dist/index.js +12047 -27
- package/dist/index.js.map +1 -1
- package/package.json +34 -21
- package/plugin.schema.json +7927 -1289
- package/src/agent/IdentifierResolution.ts +40 -39
- package/src/functions/LegacySupport.ts +2 -2
- package/src/functions/externalIdentifierFunctions.ts +27 -18
- package/src/functions/externalOIDFIdentifier.ts +9 -7
- package/src/functions/managedIdentifierFunctions.ts +25 -19
- package/src/index.ts +1 -1
- package/src/types/IIdentifierResolution.ts +4 -4
- package/src/types/IJwtService.d.ts +6 -5
- package/src/types/common.ts +4 -4
- package/src/types/externalIdentifierTypes.ts +7 -7
- package/src/types/managedIdentifierTypes.ts +4 -4
- package/dist/agent/IdentifierResolution.d.ts +0 -38
- package/dist/agent/IdentifierResolution.d.ts.map +0 -1
- package/dist/agent/IdentifierResolution.js +0 -123
- package/dist/agent/IdentifierResolution.js.map +0 -1
- package/dist/functions/LegacySupport.d.ts +0 -12
- package/dist/functions/LegacySupport.d.ts.map +0 -1
- package/dist/functions/LegacySupport.js +0 -39
- package/dist/functions/LegacySupport.js.map +0 -1
- package/dist/functions/externalIdentifierFunctions.d.ts +0 -26
- package/dist/functions/externalIdentifierFunctions.d.ts.map +0 -1
- package/dist/functions/externalIdentifierFunctions.js +0 -250
- package/dist/functions/externalIdentifierFunctions.js.map +0 -1
- package/dist/functions/externalOIDFIdentifier.d.ts +0 -19
- package/dist/functions/externalOIDFIdentifier.d.ts.map +0 -1
- package/dist/functions/externalOIDFIdentifier.js +0 -106
- package/dist/functions/externalOIDFIdentifier.js.map +0 -1
- package/dist/functions/index.d.ts +0 -5
- package/dist/functions/index.d.ts.map +0 -1
- package/dist/functions/index.js +0 -21
- package/dist/functions/index.js.map +0 -1
- package/dist/functions/managedIdentifierFunctions.d.ts +0 -38
- package/dist/functions/managedIdentifierFunctions.d.ts.map +0 -1
- package/dist/functions/managedIdentifierFunctions.js +0 -359
- package/dist/functions/managedIdentifierFunctions.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types/IIdentifierResolution.d.ts +0 -42
- package/dist/types/IIdentifierResolution.d.ts.map +0 -1
- package/dist/types/IIdentifierResolution.js +0 -21
- package/dist/types/IIdentifierResolution.js.map +0 -1
- package/dist/types/common.d.ts +0 -20
- package/dist/types/common.d.ts.map +0 -1
- package/dist/types/common.js +0 -51
- package/dist/types/common.js.map +0 -1
- package/dist/types/externalIdentifierTypes.d.ts +0 -114
- package/dist/types/externalIdentifierTypes.d.ts.map +0 -1
- package/dist/types/externalIdentifierTypes.js +0 -44
- package/dist/types/externalIdentifierTypes.js.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -21
- package/dist/types/index.js.map +0 -1
- package/dist/types/managedIdentifierTypes.d.ts +0 -122
- package/dist/types/managedIdentifierTypes.d.ts.map +0 -1
- package/dist/types/managedIdentifierTypes.js +0 -63
- package/dist/types/managedIdentifierTypes.js.map +0 -1
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.IdentifierResolution = void 0;
|
|
13
|
-
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
14
|
-
const __1 = require("..");
|
|
15
|
-
const functions_1 = require("../functions");
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
class IdentifierResolution {
|
|
20
|
-
/**
|
|
21
|
-
* TODO: Add a cache, as we are retrieving the same keys/info quite often
|
|
22
|
-
*/
|
|
23
|
-
constructor(opts) {
|
|
24
|
-
this.schema = __1.schema.IMnemonicInfoGenerator;
|
|
25
|
-
this.methods = {
|
|
26
|
-
identifierManagedGet: this.identifierGetManaged.bind(this),
|
|
27
|
-
identifierManagedGetByDid: this.identifierGetManagedByDid.bind(this),
|
|
28
|
-
identifierManagedGetByKid: this.identifierGetManagedByKid.bind(this),
|
|
29
|
-
identifierManagedGetByJwk: this.identifierGetManagedByJwk.bind(this),
|
|
30
|
-
identifierManagedGetByX5c: this.identifierGetManagedByX5c.bind(this),
|
|
31
|
-
identifierManagedGetByKey: this.identifierGetManagedByKey.bind(this),
|
|
32
|
-
identifierManagedGetByCoseKey: this.identifierGetManagedByCoseKey.bind(this),
|
|
33
|
-
identifierManagedGetByOID4VCIssuer: this.identifierGetManagedByOID4VCIssuer.bind(this),
|
|
34
|
-
identifierExternalResolve: this.identifierResolveExternal.bind(this),
|
|
35
|
-
identifierExternalResolveByDid: this.identifierExternalResolveByDid.bind(this),
|
|
36
|
-
identifierExternalResolveByX5c: this.identifierExternalResolveByX5c.bind(this),
|
|
37
|
-
identifierExternalResolveByJwk: this.identifierExternalResolveByJwk.bind(this),
|
|
38
|
-
identifierExternalResolveByCoseKey: this.identifierExternalResolveByCoseKey.bind(this),
|
|
39
|
-
identifierExternalResolveByOIDFEntityId: this.identifierExternalResolveByOIDFEntityId.bind(this),
|
|
40
|
-
// todo: JWKSet, oidc-discovery, oid4vci-issuer etc. Anything we already can resolve and need keys of
|
|
41
|
-
};
|
|
42
|
-
this._crypto = (0, ssi_sdk_ext_key_utils_1.globalCrypto)(false, opts === null || opts === void 0 ? void 0 : opts.crypto);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Main method for managed identifiers. We always go through this method (also the other methods below) as we want to
|
|
46
|
-
* integrate a plugin for anomaly detection. Having a single method helps
|
|
47
|
-
* @param args
|
|
48
|
-
* @param context
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
identifierGetManaged(args, context) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
return yield (0, functions_1.ensureManagedIdentifierResult)(Object.assign(Object.assign({}, args), { crypto: this._crypto }), context);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
identifierGetManagedByDid(args, context) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'did' }), context));
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
identifierGetManagedByKid(args, context) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'kid' }), context));
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
identifierGetManagedByKey(args, context) {
|
|
67
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'key' }), context));
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
identifierGetManagedByCoseKey(args, context) {
|
|
72
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'cose_key' }), context));
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
identifierGetManagedByOID4VCIssuer(args, context) {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'oid4vci-issuer' }), context));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
identifierGetManagedByJwk(args, context) {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'jwk' }), context));
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
identifierGetManagedByX5c(args, context) {
|
|
87
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
return (yield this.identifierGetManaged(Object.assign(Object.assign({}, args), { method: 'x5c' }), context));
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
identifierResolveExternal(args, context) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
return yield (0, functions_1.resolveExternalIdentifier)(Object.assign(Object.assign({}, args), { crypto: this._crypto }), context);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
identifierExternalResolveByDid(args, context) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'did' }), context));
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
identifierExternalResolveByX5c(args, context) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'x5c' }), context));
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
identifierExternalResolveByCoseKey(args, context) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'cose_key' }), context));
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
identifierExternalResolveByJwk(args, context) {
|
|
112
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'jwk' }), context));
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
identifierExternalResolveByOIDFEntityId(args, context) {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
return (yield this.identifierResolveExternal(Object.assign(Object.assign({}, args), { method: 'entity_id' }), context));
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
exports.IdentifierResolution = IdentifierResolution;
|
|
123
|
-
//# sourceMappingURL=IdentifierResolution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IdentifierResolution.js","sourceRoot":"","sources":["../../src/agent/IdentifierResolution.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2EAA8D;AAG9D,0BAA2B;AAC3B,4CAAuF;AAgCvF;;GAEG;AACH,MAAa,oBAAoB;IAwB/B;;OAEG;IACH,YAAY,IAA0B;QAxB7B,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;YACpE,6BAA6B,EAAE,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,IAAI,CAAC;YAC5E,kCAAkC,EAAE,IAAI,CAAC,kCA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yBAAyB,iCAAM,IAAI,KAAE,MAAM,EAAE,KAAK,KAAI,OAAO,CAAC,CAAgC,CAAA;QACnH,CAAC;KAAA;IAEa,kCAAkC,CAC9C,IAAmC,EACnC,OAA2B;;YAE3B,OAAO,CAAC,MAAM,IAAI,CAAC,yBAAyB,iCAAM,IAAI,KAAE,MAAM,EAAE,UAAU,KAAI,OAAO,CAAC,CAAoC,CAAA;QAC5H,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,uCAAuC,CACnD,IAAwC,EACxC,OAA2B;;YAE3B,OAAO,CAAC,MAAM,IAAI,CAAC,yBAAyB,iCAAM,IAAI,KAAE,MAAM,EAAE,WAAW,KAAI,OAAO,CAAC,CAAyC,CAAA;QAClI,CAAC;KAAA;CACF;AA9HD,oDA8HC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ManagedIdentifierOptsOrResult } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Converts legacy id opts key refs to the new ManagedIdentifierOpts
|
|
4
|
-
* @param opts
|
|
5
|
-
*/
|
|
6
|
-
export declare function legacyKeyRefsToIdentifierOpts(opts: {
|
|
7
|
-
idOpts?: ManagedIdentifierOptsOrResult;
|
|
8
|
-
iss?: string;
|
|
9
|
-
keyRef?: string;
|
|
10
|
-
didOpts?: any;
|
|
11
|
-
}): ManagedIdentifierOptsOrResult;
|
|
12
|
-
//# sourceMappingURL=LegacySupport.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegacySupport.d.ts","sourceRoot":"","sources":["../../src/functions/LegacySupport.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAElF;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,MAAM,CAAC,EAAE,6BAA6B,CAAA;IACtC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,GAAG,CAAA;CACd,GAAG,6BAA6B,CAyChC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.legacyKeyRefsToIdentifierOpts = legacyKeyRefsToIdentifierOpts;
|
|
4
|
-
/**
|
|
5
|
-
* Converts legacy id opts key refs to the new ManagedIdentifierOpts
|
|
6
|
-
* @param opts
|
|
7
|
-
*/
|
|
8
|
-
function legacyKeyRefsToIdentifierOpts(opts) {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
10
|
-
if (!opts.idOpts) {
|
|
11
|
-
console.warn(`Legacy idOpts being used. Support will be dropped in the future. Consider switching to the idOpts, to have support for DIDs, JWKS, x5c etc. See https://github.com/Sphereon-Opensource/SSI-SDK-crypto-extensions/tree/feature/multi_identifier_support/packages/identifier-resolution`);
|
|
12
|
-
// legacy way
|
|
13
|
-
let kmsKeyRef = (_j = (_f = (_d = (_a = opts.keyRef) !== null && _a !== void 0 ? _a : (_c = (_b = opts.didOpts) === null || _b === void 0 ? void 0 : _b.idOpts) === null || _c === void 0 ? void 0 : _c.kmsKeyRef) !== null && _d !== void 0 ? _d : (_e = opts.didOpts) === null || _e === void 0 ? void 0 : _e.kid) !== null && _f !== void 0 ? _f : (_h = (_g = opts.didOpts) === null || _g === void 0 ? void 0 : _g.idOpts) === null || _h === void 0 ? void 0 : _h.kid) !== null && _j !== void 0 ? _j : (typeof ((_l = (_k = opts.didOpts) === null || _k === void 0 ? void 0 : _k.idOpts) === null || _l === void 0 ? void 0 : _l.identifier) === 'object' ? opts.didOpts.idOpts.identifier.keys[0].kid : undefined);
|
|
14
|
-
if (!kmsKeyRef) {
|
|
15
|
-
throw Error('Key ref is needed for access token signer');
|
|
16
|
-
}
|
|
17
|
-
let identifier = ((_o = (_m = opts.didOpts) === null || _m === void 0 ? void 0 : _m.identifier) !== null && _o !== void 0 ? _o : (_q = (_p = opts.didOpts) === null || _p === void 0 ? void 0 : _p.idOpts) === null || _q === void 0 ? void 0 : _q.identifier);
|
|
18
|
-
return {
|
|
19
|
-
kmsKeyRef: (_r = opts.keyRef) !== null && _r !== void 0 ? _r : kmsKeyRef,
|
|
20
|
-
identifier: identifier !== null && identifier !== void 0 ? identifier : kmsKeyRef,
|
|
21
|
-
issuer: opts.iss,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
const idOpts = opts.idOpts;
|
|
26
|
-
if (opts.keyRef && !idOpts.kmsKeyRef) {
|
|
27
|
-
// legacy way
|
|
28
|
-
console.warn(`Legacy keyRef being used. Support will be dropped in the future. Consider switching to the idOpts, to have support for DIDs, JWKS, x5c etc. See https://github.com/Sphereon-Opensource/SSI-SDK-crypto-extensions/tree/feature/multi_identifier_support/packages/identifier-resolution`);
|
|
29
|
-
idOpts.kmsKeyRef = opts.keyRef;
|
|
30
|
-
}
|
|
31
|
-
if (opts.iss && !idOpts.issuer) {
|
|
32
|
-
// legacy way
|
|
33
|
-
console.warn(`Legacy iss being used. Support will be dropped in the future. Consider switching to the idOpts, to have support for DIDs, JWKS, x5c etc. See https://github.com/Sphereon-Opensource/SSI-SDK-crypto-extensions/tree/feature/multi_identifier_support/packages/identifier-resolution`);
|
|
34
|
-
idOpts.issuer = opts.iss;
|
|
35
|
-
}
|
|
36
|
-
return idOpts;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=LegacySupport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LegacySupport.js","sourceRoot":"","sources":["../../src/functions/LegacySupport.ts"],"names":[],"mappings":";;AAOA,sEA8C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,CACV,uRAAuR,CACxR,CAAA;YACD,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAA;QAChC,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YAC/B,aAAa;YACb,OAAO,CAAC,IAAI,CACV,oRAAoR,CACrR,CAAA;YACD,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAA;QAC1B,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { IAgentContext, IDIDManager, IResolver } from '@veramo/core';
|
|
2
|
-
import { ExternalIdentifierCoseKeyOpts, ExternalIdentifierCoseKeyResult, ExternalIdentifierDidOpts, ExternalIdentifierDidResult, ExternalIdentifierJwkOpts, ExternalIdentifierJwkResult, ExternalIdentifierOpts, ExternalIdentifierResult, ExternalIdentifierX5cOpts, ExternalIdentifierX5cResult } from '../types';
|
|
3
|
-
export declare function resolveExternalIdentifier(opts: ExternalIdentifierOpts & {
|
|
4
|
-
crypto?: Crypto;
|
|
5
|
-
}, context: IAgentContext<any>): Promise<ExternalIdentifierResult>;
|
|
6
|
-
export declare function resolveExternalX5cIdentifier(opts: ExternalIdentifierX5cOpts & {
|
|
7
|
-
crypto?: Crypto;
|
|
8
|
-
}, context: IAgentContext<IResolver & IDIDManager>): Promise<ExternalIdentifierX5cResult>;
|
|
9
|
-
/**
|
|
10
|
-
* Resolves a JWK. Normally this is just returning the JWK, but in case the JWK contains a x5c the chain is validated
|
|
11
|
-
* @param opts
|
|
12
|
-
* @param context
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolveExternalJwkIdentifier(opts: ExternalIdentifierJwkOpts & {
|
|
15
|
-
x5c?: ExternalIdentifierX5cOpts;
|
|
16
|
-
}, context: IAgentContext<any>): Promise<ExternalIdentifierJwkResult>;
|
|
17
|
-
/**
|
|
18
|
-
* Resolves a JWK. Normally this is just returning the JWK, but in case the JWK contains a x5c the chain is validated
|
|
19
|
-
* @param opts
|
|
20
|
-
* @param context
|
|
21
|
-
*/
|
|
22
|
-
export declare function resolveExternalCoseKeyIdentifier(opts: ExternalIdentifierCoseKeyOpts & {
|
|
23
|
-
x5c?: ExternalIdentifierX5cOpts;
|
|
24
|
-
}, context: IAgentContext<any>): Promise<ExternalIdentifierCoseKeyResult>;
|
|
25
|
-
export declare function resolveExternalDidIdentifier(opts: ExternalIdentifierDidOpts, context: IAgentContext<IResolver & IDIDManager>): Promise<ExternalIdentifierDidResult>;
|
|
26
|
-
//# sourceMappingURL=externalIdentifierFunctions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"externalIdentifierFunctions.d.ts","sourceRoot":"","sources":["../../src/functions/externalIdentifierFunctions.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGpE,OAAO,EACL,6BAA6B,EAC7B,+BAA+B,EAC/B,yBAAyB,EACzB,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,EAE3B,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,2BAA2B,EAU5B,MAAM,UAAU,CAAA;AAGjB,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,sBAAsB,GAAG;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,EACD,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAC1B,OAAO,CAAC,wBAAwB,CAAC,CAoBnC;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,yBAAyB,GAAG;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,EACD,OAAO,EAAE,aAAa,CAAC,SAAS,GAAG,WAAW,CAAC,GAC9C,OAAO,CAAC,2BAA2B,CAAC,CA4EtC;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,yBAAyB,GAAG;IAChC,GAAG,CAAC,EAAE,yBAAyB,CAAA;CAChC,EACD,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAC1B,OAAO,CAAC,2BAA2B,CAAC,CAuBtC;AAED;;;;GAIG;AACH,wBAAsB,gCAAgC,CACpD,IAAI,EAAE,6BAA6B,GAAG;IACpC,GAAG,CAAC,EAAE,yBAAyB,CAAA;CAChC,EACD,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,GAC1B,OAAO,CAAC,+BAA+B,CAAC,CAyB1C;AAED,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,yBAAyB,EAC/B,OAAO,EAAE,aAAa,CAAC,SAAS,GAAG,WAAW,CAAC,GAC9C,OAAO,CAAC,2BAA2B,CAAC,CAmDtC"}
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.resolveExternalIdentifier = resolveExternalIdentifier;
|
|
13
|
-
exports.resolveExternalX5cIdentifier = resolveExternalX5cIdentifier;
|
|
14
|
-
exports.resolveExternalJwkIdentifier = resolveExternalJwkIdentifier;
|
|
15
|
-
exports.resolveExternalCoseKeyIdentifier = resolveExternalCoseKeyIdentifier;
|
|
16
|
-
exports.resolveExternalDidIdentifier = resolveExternalDidIdentifier;
|
|
17
|
-
const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
18
|
-
const ssi_sdk_ext_key_utils_1 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
19
|
-
const ssi_sdk_ext_x509_utils_1 = require("@sphereon/ssi-sdk-ext.x509-utils");
|
|
20
|
-
const ssi_sdk_agent_config_1 = require("@sphereon/ssi-sdk.agent-config");
|
|
21
|
-
const ssi_types_1 = require("@sphereon/ssi-types");
|
|
22
|
-
const utils_1 = require("@veramo/utils");
|
|
23
|
-
const pkijs_1 = require("pkijs");
|
|
24
|
-
const types_1 = require("../types");
|
|
25
|
-
const _1 = require(".");
|
|
26
|
-
function resolveExternalIdentifier(opts, context) {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
let method;
|
|
29
|
-
if ((0, types_1.isExternalIdentifierDidOpts)(opts)) {
|
|
30
|
-
return resolveExternalDidIdentifier(opts, context);
|
|
31
|
-
}
|
|
32
|
-
else if ((0, types_1.isExternalIdentifierX5cOpts)(opts)) {
|
|
33
|
-
return resolveExternalX5cIdentifier(opts, context);
|
|
34
|
-
}
|
|
35
|
-
else if ((0, types_1.isExternalIdentifierJwkOpts)(opts)) {
|
|
36
|
-
return resolveExternalJwkIdentifier(opts, context);
|
|
37
|
-
}
|
|
38
|
-
else if ((0, types_1.isExternalIdentifierCoseKeyOpts)(opts)) {
|
|
39
|
-
return resolveExternalCoseKeyIdentifier(opts, context);
|
|
40
|
-
}
|
|
41
|
-
else if ((0, types_1.isExternalIdentifierOIDFEntityIdOpts)(opts)) {
|
|
42
|
-
return (0, _1.resolveExternalOIDFEntityIdIdentifier)(opts, context);
|
|
43
|
-
}
|
|
44
|
-
else if ((0, types_1.isExternalIdentifierKidOpts)(opts)) {
|
|
45
|
-
method = 'kid';
|
|
46
|
-
}
|
|
47
|
-
else if ((0, types_1.isExternalIdentifierJwksUrlOpts)(opts)) {
|
|
48
|
-
method = 'jwks-url';
|
|
49
|
-
}
|
|
50
|
-
else if ((0, types_1.isExternalIdentifierOidcDiscoveryOpts)(opts)) {
|
|
51
|
-
method = 'oidc-discovery';
|
|
52
|
-
}
|
|
53
|
-
throw Error(`External resolution method ${method} is not yet implemented`);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function resolveExternalX5cIdentifier(opts, context) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
-
var _a, _b, _c;
|
|
59
|
-
if (!(0, types_1.isExternalIdentifierX5cOpts)(opts)) {
|
|
60
|
-
return Promise.reject('External x5c Identifier args need to be provided');
|
|
61
|
-
}
|
|
62
|
-
const verify = (_a = opts.verify) !== null && _a !== void 0 ? _a : true;
|
|
63
|
-
const x5c = opts.identifier.map((derOrPem) => (derOrPem.includes('CERTIFICATE') ? (0, ssi_sdk_ext_x509_utils_1.PEMToDer)(derOrPem) : derOrPem));
|
|
64
|
-
if (x5c.length === 0) {
|
|
65
|
-
return Promise.reject('Empty certification chain is not allowed');
|
|
66
|
-
}
|
|
67
|
-
const certificates = x5c.map(ssi_sdk_ext_x509_utils_1.pemOrDerToX509Certificate);
|
|
68
|
-
let verificationResult;
|
|
69
|
-
let issuerJWK;
|
|
70
|
-
let jwks = [];
|
|
71
|
-
if (verify) {
|
|
72
|
-
// We use the agent plugin if it is available as that is more powerful, but revert to the function otherwise
|
|
73
|
-
if ((0, ssi_sdk_agent_config_1.contextHasPlugin)(context, 'verifyCertificateChain')) {
|
|
74
|
-
verificationResult = (yield context.agent.verifyCertificateChain({
|
|
75
|
-
chain: opts.identifier,
|
|
76
|
-
trustAnchors: (_b = opts.trustAnchors) !== null && _b !== void 0 ? _b : [],
|
|
77
|
-
verificationTime: opts.verificationTime,
|
|
78
|
-
})); // We need to cast, as we know this is the value and we do not want to rely on the x509 plugin perse
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
verificationResult = yield (0, ssi_sdk_ext_x509_utils_1.validateX509CertificateChain)({
|
|
82
|
-
chain: opts.identifier,
|
|
83
|
-
trustAnchors: (_c = opts.trustAnchors) !== null && _c !== void 0 ? _c : [],
|
|
84
|
-
verificationTime: opts.verificationTime,
|
|
85
|
-
opts,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (verificationResult.certificateChain) {
|
|
89
|
-
jwks = verificationResult.certificateChain.map((cert) => {
|
|
90
|
-
return {
|
|
91
|
-
jwk: cert.publicKeyJWK,
|
|
92
|
-
kid: cert.subject.dn.DN,
|
|
93
|
-
jwkThumbprint: (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprint)({ jwk: cert.publicKeyJWK }),
|
|
94
|
-
publicKeyHex: (0, ssi_sdk_ext_did_utils_1.jwkTtoPublicKeyHex)(cert.publicKeyJWK),
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (!jwks || jwks.length === 0) {
|
|
100
|
-
const cryptoEngine = new pkijs_1.CryptoEngine({
|
|
101
|
-
name: 'identifier_resolver_external',
|
|
102
|
-
crypto: (0, ssi_sdk_ext_key_utils_1.globalCrypto)(false, opts.crypto),
|
|
103
|
-
});
|
|
104
|
-
(0, pkijs_1.setEngine)(cryptoEngine.name, cryptoEngine);
|
|
105
|
-
jwks = yield Promise.all(certificates.map((cert) => __awaiter(this, void 0, void 0, function* () {
|
|
106
|
-
const pk = yield cert.getPublicKey(undefined, cryptoEngine);
|
|
107
|
-
const jwk = (yield cryptoEngine.exportKey('jwk', pk));
|
|
108
|
-
return {
|
|
109
|
-
jwk,
|
|
110
|
-
kid: (0, ssi_sdk_ext_x509_utils_1.getSubjectDN)(cert).DN,
|
|
111
|
-
jwkThumbprint: (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprint)({ jwk }),
|
|
112
|
-
publicKeyHex: (0, ssi_sdk_ext_did_utils_1.jwkTtoPublicKeyHex)(jwk),
|
|
113
|
-
};
|
|
114
|
-
})));
|
|
115
|
-
}
|
|
116
|
-
if (jwks.length === 0) {
|
|
117
|
-
return Promise.reject('Empty certification chain is now allowed');
|
|
118
|
-
}
|
|
119
|
-
if (!issuerJWK) {
|
|
120
|
-
issuerJWK = jwks[0].jwk;
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
method: 'x5c',
|
|
124
|
-
verificationResult,
|
|
125
|
-
issuerJWK,
|
|
126
|
-
jwks,
|
|
127
|
-
certificates,
|
|
128
|
-
x5c,
|
|
129
|
-
};
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Resolves a JWK. Normally this is just returning the JWK, but in case the JWK contains a x5c the chain is validated
|
|
134
|
-
* @param opts
|
|
135
|
-
* @param context
|
|
136
|
-
*/
|
|
137
|
-
function resolveExternalJwkIdentifier(opts, context) {
|
|
138
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
-
if (!(0, types_1.isExternalIdentifierJwkOpts)(opts)) {
|
|
140
|
-
return Promise.reject('External JWK Identifier args need to be provided');
|
|
141
|
-
}
|
|
142
|
-
const jwk = opts.identifier;
|
|
143
|
-
let x5c = undefined;
|
|
144
|
-
if (jwk.x5c) {
|
|
145
|
-
x5c = yield resolveExternalX5cIdentifier(Object.assign(Object.assign({}, opts.x5c), { identifier: jwk.x5c }), context);
|
|
146
|
-
}
|
|
147
|
-
const jwkThumbprint = (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprint)({ jwk });
|
|
148
|
-
return {
|
|
149
|
-
method: 'jwk',
|
|
150
|
-
jwk,
|
|
151
|
-
jwks: [
|
|
152
|
-
{
|
|
153
|
-
jwk,
|
|
154
|
-
jwkThumbprint,
|
|
155
|
-
kid: jwk.kid,
|
|
156
|
-
publicKeyHex: (0, ssi_sdk_ext_did_utils_1.jwkTtoPublicKeyHex)(jwk),
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
x5c,
|
|
160
|
-
};
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Resolves a JWK. Normally this is just returning the JWK, but in case the JWK contains a x5c the chain is validated
|
|
165
|
-
* @param opts
|
|
166
|
-
* @param context
|
|
167
|
-
*/
|
|
168
|
-
function resolveExternalCoseKeyIdentifier(opts, context) {
|
|
169
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
if (!(0, types_1.isExternalIdentifierCoseKeyOpts)(opts)) {
|
|
171
|
-
return Promise.reject('External Cose Key args need to be provided');
|
|
172
|
-
}
|
|
173
|
-
// TODO: We need to do cbor conversion here as well.
|
|
174
|
-
const coseKey = opts.identifier;
|
|
175
|
-
let x5c = undefined;
|
|
176
|
-
if (coseKey.x5chain) {
|
|
177
|
-
x5c = yield resolveExternalX5cIdentifier(Object.assign(Object.assign({}, opts.x5c), { identifier: coseKey.x5chain }), context);
|
|
178
|
-
}
|
|
179
|
-
const jwk = (0, ssi_sdk_ext_key_utils_1.coseKeyToJwk)(coseKey);
|
|
180
|
-
const jwkThumbprint = (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprint)({ jwk });
|
|
181
|
-
return {
|
|
182
|
-
method: 'cose_key',
|
|
183
|
-
coseKey,
|
|
184
|
-
jwks: [
|
|
185
|
-
{
|
|
186
|
-
jwk,
|
|
187
|
-
jwkThumbprint,
|
|
188
|
-
kid: coseKey.kid,
|
|
189
|
-
publicKeyHex: (0, ssi_sdk_ext_did_utils_1.jwkTtoPublicKeyHex)(jwk),
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
x5c,
|
|
193
|
-
};
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
function resolveExternalDidIdentifier(opts, context) {
|
|
197
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
-
var _a;
|
|
199
|
-
if (!(0, types_1.isExternalIdentifierDidOpts)(opts)) {
|
|
200
|
-
return Promise.reject('External DID Identifier args need to be provided');
|
|
201
|
-
}
|
|
202
|
-
else if (!(0, ssi_sdk_agent_config_1.contextHasPlugin)(context, 'resolveDid')) {
|
|
203
|
-
return Promise.reject(Error(`Cannot get external DID identifier if DID resolver plugin is not enabled!`));
|
|
204
|
-
}
|
|
205
|
-
const { uniresolverResolution = false, localResolution = true, resolverResolution = true } = opts;
|
|
206
|
-
const did = opts.identifier;
|
|
207
|
-
let parsed;
|
|
208
|
-
try {
|
|
209
|
-
parsed = (0, ssi_types_1.parseDid)(did);
|
|
210
|
-
}
|
|
211
|
-
catch (error) {
|
|
212
|
-
// Error from did resolution spec
|
|
213
|
-
return Promise.reject(error);
|
|
214
|
-
}
|
|
215
|
-
const didParsed = parsed;
|
|
216
|
-
const didResolutionResult = yield (0, ssi_sdk_ext_did_utils_1.getAgentResolver)(context, {
|
|
217
|
-
uniresolverResolution,
|
|
218
|
-
localResolution,
|
|
219
|
-
resolverResolution,
|
|
220
|
-
}).resolve(did);
|
|
221
|
-
const didDocument = (_a = didResolutionResult.didDocument) !== null && _a !== void 0 ? _a : undefined;
|
|
222
|
-
const didJwks = didDocument ? (0, ssi_sdk_ext_did_utils_1.didDocumentToJwks)(didDocument) : undefined;
|
|
223
|
-
const jwks = didJwks
|
|
224
|
-
? Array.from(new Set(Array.from(Object.values(didJwks)
|
|
225
|
-
.filter((jwks) => (0, utils_1.isDefined)(jwks) && jwks.length > 0)
|
|
226
|
-
.flatMap((jwks) => jwks)).flatMap((jwk) => {
|
|
227
|
-
return {
|
|
228
|
-
jwk,
|
|
229
|
-
jwkThumbprint: (0, ssi_sdk_ext_key_utils_1.calculateJwkThumbprint)({ jwk }),
|
|
230
|
-
kid: jwk.kid,
|
|
231
|
-
publicKeyHex: (0, ssi_sdk_ext_did_utils_1.jwkTtoPublicKeyHex)(jwk),
|
|
232
|
-
};
|
|
233
|
-
}).map(jwk => JSON.stringify(jwk)))).map((jwks) => JSON.parse(jwks))
|
|
234
|
-
: [];
|
|
235
|
-
if (didResolutionResult === null || didResolutionResult === void 0 ? void 0 : didResolutionResult.didDocument) {
|
|
236
|
-
// @ts-ignore // Mandatory on the original object, but we already provide it directly
|
|
237
|
-
delete didResolutionResult['didDocument'];
|
|
238
|
-
}
|
|
239
|
-
return {
|
|
240
|
-
method: 'did',
|
|
241
|
-
did,
|
|
242
|
-
jwks,
|
|
243
|
-
didJwks,
|
|
244
|
-
didDocument,
|
|
245
|
-
didResolutionResult,
|
|
246
|
-
didParsed,
|
|
247
|
-
};
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
//# sourceMappingURL=externalIdentifierFunctions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"externalIdentifierFunctions.js","sourceRoot":"","sources":["../../src/functions/externalIdentifierFunctions.ts"],"names":[],"mappings":";;;;;;;;;;;AAsCA,8DAyBC;AAED,oEAiFC;AAOD,oEA4BC;AAOD,4EA8BC;AAED,oEAsDC;AAlRD,2EAAyG;AACzG,2EAAoG;AACpG,6EAMyC;AACzC,yEAAiE;AACjE,mDAA+D;AAE/D,yCAAyC;AACzC,iCAA+C;AAC/C,oCAqBiB;AACjB,wBAAyD;AAEzD,SAAsB,yBAAyB,CAC7C,IAEC,EACD,OAA2B;;QAE3B,IAAI,MAA4C,CAAA;QAChD,IAAI,IAAA,mCAA2B,EAAC,IAAI,CAAC,EAAE,CAAC;YACtC,OAAO,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;aAAM,IAAI,IAAA,mCAA2B,EAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,OAAO,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;aAAM,IAAI,IAAA,mCAA2B,EAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,OAAO,4BAA4B,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACpD,CAAC;aAAM,IAAI,IAAA,uCAA+B,EAAC,IAAI,CAAC,EAAE,CAAC;YACjD,OAAO,gCAAgC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACxD,CAAC;aAAM,IAAI,IAAA,4CAAoC,EAAC,IA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ult } from '../types';
|
|
2
|
-
import { IAgentContext } from '@veramo/core';
|
|
3
|
-
import { IOIDFClient } from '@sphereon/ssi-sdk.oidf-client';
|
|
4
|
-
/**
|
|
5
|
-
* Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
|
|
6
|
-
*
|
|
7
|
-
* @param opts Configuration options containing the identifier to resolve and trust anchors to validate against
|
|
8
|
-
* @param context Agent context that must include the OIDF client plugin and JWT verification capabilities
|
|
9
|
-
*
|
|
10
|
-
* @returns Promise resolving to an ExternalIdentifierOIDFEntityIdResult containing:
|
|
11
|
-
* - trustedAnchors: Record mapping trust anchors to their public key hexes
|
|
12
|
-
* - errorList: Optional record of errors encountered per trust anchor
|
|
13
|
-
* - jwks: Array of JWK information from the trust chain
|
|
14
|
-
* - trustEstablished: Boolean indicating if any trust relationships were established
|
|
15
|
-
*
|
|
16
|
-
* @throws Error if trust anchors are missing or JWT verification plugin is not enabled
|
|
17
|
-
*/
|
|
18
|
-
export declare function resolveExternalOIDFEntityIdIdentifier(opts: ExternalIdentifierOIDFEntityIdOpts, context: IAgentContext<IOIDFClient>): Promise<ExternalIdentifierOIDFEntityIdResult>;
|
|
19
|
-
//# sourceMappingURL=externalOIDFIdentifier.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"externalOIDFIdentifier.d.ts","sourceRoot":"","sources":["../../src/functions/externalOIDFIdentifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,kCAAkC,EAAE,oCAAoC,EAAkC,MAAM,UAAU,CAAA;AACjJ,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAI3D;;;;;;;;;;;;;GAaG;AACH,wBAAsB,qCAAqC,CACzD,IAAI,EAAE,kCAAkC,EACxC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAClC,OAAO,CAAC,oCAAoC,CAAC,CAmE/C"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.resolveExternalOIDFEntityIdIdentifier = resolveExternalOIDFEntityIdIdentifier;
|
|
36
|
-
const ssi_sdk_agent_config_1 = require("@sphereon/ssi-sdk.agent-config");
|
|
37
|
-
const u8a = __importStar(require("uint8arrays"));
|
|
38
|
-
/**
|
|
39
|
-
* Resolves an OIDF Entity ID against multiple trust anchors to establish trusted relationships
|
|
40
|
-
*
|
|
41
|
-
* @param opts Configuration options containing the identifier to resolve and trust anchors to validate against
|
|
42
|
-
* @param context Agent context that must include the OIDF client plugin and JWT verification capabilities
|
|
43
|
-
*
|
|
44
|
-
* @returns Promise resolving to an ExternalIdentifierOIDFEntityIdResult containing:
|
|
45
|
-
* - trustedAnchors: Record mapping trust anchors to their public key hexes
|
|
46
|
-
* - errorList: Optional record of errors encountered per trust anchor
|
|
47
|
-
* - jwks: Array of JWK information from the trust chain
|
|
48
|
-
* - trustEstablished: Boolean indicating if any trust relationships were established
|
|
49
|
-
*
|
|
50
|
-
* @throws Error if trust anchors are missing or JWT verification plugin is not enabled
|
|
51
|
-
*/
|
|
52
|
-
function resolveExternalOIDFEntityIdIdentifier(opts, context) {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
var _a;
|
|
55
|
-
let { trustAnchors, identifier } = opts;
|
|
56
|
-
if (!trustAnchors || trustAnchors.length === 0) {
|
|
57
|
-
return Promise.reject(Error('ExternalIdentifierOIDFEntityIdOpts is missing the trustAnchors'));
|
|
58
|
-
}
|
|
59
|
-
if (!(0, ssi_sdk_agent_config_1.contextHasPlugin)(context, 'jwtVerifyJwsSignature')) {
|
|
60
|
-
return Promise.reject(Error('For OIDFEntityId resolving the agent needs to have the JwtService plugin enabled'));
|
|
61
|
-
}
|
|
62
|
-
const trustedAnchors = new Set();
|
|
63
|
-
const errorList = {};
|
|
64
|
-
const jwkInfos = [];
|
|
65
|
-
let payload;
|
|
66
|
-
for (const trustAnchor of trustAnchors) {
|
|
67
|
-
const resolveResult = yield context.agent.resolveTrustChain({
|
|
68
|
-
entityIdentifier: identifier,
|
|
69
|
-
trustAnchors: [trustAnchor],
|
|
70
|
-
});
|
|
71
|
-
if (resolveResult.error || !resolveResult.trustChain) {
|
|
72
|
-
errorList[trustAnchor] = (_a = resolveResult.errorMessage) !== null && _a !== void 0 ? _a : 'unspecified';
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
const trustChain = resolveResult.trustChain.asJsReadonlyArrayView();
|
|
76
|
-
if (trustChain.length === 0) {
|
|
77
|
-
errorList[trustAnchor] = 'Trust chain is empty';
|
|
78
|
-
continue;
|
|
79
|
-
}
|
|
80
|
-
const jwt = trustChain[0];
|
|
81
|
-
const jwtVerifyResult = yield context.agent.jwtVerifyJwsSignature({ jws: jwt });
|
|
82
|
-
if (jwtVerifyResult.error || jwtVerifyResult.critical) {
|
|
83
|
-
errorList[trustAnchor] = jwtVerifyResult.message;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (jwtVerifyResult.jws.signatures.length === 0) {
|
|
87
|
-
errorList[trustAnchor] = 'No signature was present in the trust anchor JWS';
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
payload = JSON.parse(u8a.toString(u8a.fromString(jwtVerifyResult.jws.payload, 'base64url')));
|
|
91
|
-
const signature = jwtVerifyResult.jws.signatures[0];
|
|
92
|
-
if (signature.identifier.jwks.length === 0) {
|
|
93
|
-
errorList[trustAnchor] = 'No JWK was present in the trust anchor signature';
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
if (jwkInfos.length === 0) {
|
|
97
|
-
// We need the entity JWK only once
|
|
98
|
-
jwkInfos.push(...signature.identifier.jwks);
|
|
99
|
-
}
|
|
100
|
-
trustedAnchors.add(trustAnchor);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return Object.assign(Object.assign({ method: 'entity_id', trustedAnchors: Array.from(trustedAnchors) }, (Object.keys(errorList).length > 0 && { errorList })), { jwks: jwkInfos, jwtPayload: payload, trustEstablished: trustedAnchors.size > 0 });
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=externalOIDFIdentifier.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"externalOIDFIdentifier.js","sourceRoot":"","sources":["../../src/functions/externalOIDFIdentifier.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,sFAsEC;AAvFD,yEAAiE;AAEjE,iDAAkC;AAClC;;;;;;;;;;;;;GAaG;AACH,SAAsB,qCAAqC,CACzD,IAAwC,EACxC,OAAmC;;;QAEnC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;QAEvC,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/C,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC,CAAA;QAChG,CAAC;QAED,IAAI,CAAC,IAAA,uCAAgB,EAAC,OAAO,EAAE,uBAAuB,CAAC,EAAE,CAAC;YACxD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kFAAkF,CAAC,CAAC,CAAA;QAClH,CAAC;QAED,MAAM,cAAc,GAAuB,IAAI,GAAG,EAAiB,CAAA;QACnE,MAAM,SAAS,GAAwC,EAAE,CAAA;QACzD,MAAM,QAAQ,GAA2B,EAAE,CAAA;QAE3C,IAAI,OAA+B,CAAA;QACnC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;YACvC,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC;gBAC1D,gBAAgB,EAAE,UAAU;gBAC5B,YAAY,EAAE,CAAC,WAAW,CAAC;aAC5B,CAAC,CAAA;YAEF,IAAI,aAAa,CAAC,KAAK,IAAI,CAAC,aAAa,CAAC,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