@sphereon/ssi-sdk-ext.identifier-resolution 0.24.1-unstable.81 → 0.24.1-unstable.83

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.
@@ -10,7 +10,7 @@ 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({ crypto: cryptoArg }: {
13
+ constructor(opts?: {
14
14
  crypto?: Crypto;
15
15
  });
16
16
  /**
@@ -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,CAYtC;IAED;;OAEG;gBACS,EAAE,MAAM,EAAE,SAAyB,EAAE,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAItE;;;;;OAKG;YACW,oBAAoB;YAIpB,yBAAyB;YAOzB,yBAAyB;YAIzB,yBAAyB;YAIzB,yBAAyB;YAIzB,yBAAyB;YAIzB,8BAA8B;YAI9B,8BAA8B;CAG7C"}
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,CAYtC;IAED;;OAEG;gBACS,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAItC;;;;;OAKG;YACW,oBAAoB;YAIpB,yBAAyB;YAOzB,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({ crypto: cryptoArg = global.crypto }) {
22
+ constructor(opts) {
23
+ var _a;
23
24
  this.schema = __1.schema.IMnemonicInfoGenerator;
24
25
  this.methods = {
25
26
  identifierManagedGet: this.identifierGetManaged.bind(this),
@@ -32,7 +33,7 @@ class IdentifierResolution {
32
33
  identifierExternalResolveByX5c: this.identifierExternalResolveByX5c.bind(this),
33
34
  // todo: JWKSet, oidc-discovery, oid4vci-issuer etc. Anything we already can resolve and need keys of
34
35
  };
35
- this._crypto = cryptoArg;
36
+ this._crypto = (_a = opts === null || opts === void 0 ? void 0 : opts.crypto) !== null && _a !== void 0 ? _a : global.crypto;
36
37
  }
37
38
  /**
38
39
  * 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
@@ -1 +1 @@
1
- {"version":3,"file":"IdentifierResolution.js","sourceRoot":"","sources":["../../src/agent/IdentifierResolution.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,0BAA2B;AAC3B,4CAA8E;AAqB9E;;GAEG;AACH,MAAa,oBAAoB;IAkB/B;;OAEG;IACH,YAAY,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAuB;QAlB7D,WAAM,GAAG,UAAM,CAAC,sBAAsB,CAAA;QACtC,YAAO,GAA0B;YACxC,oBAAoB,EAAE,IAAI,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AO,CAAC,CAA+B,CAAA;QAC7G,CAAC;KAAA;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;AAjED,oDAiEC"}
@@ -1,3 +1,14 @@
1
+ import { ManagedIdentifierOpts } from '../types';
1
2
  export * from './managedIdentifierFunctions';
2
3
  export * from './externalIdentifierFunctions';
4
+ /**
5
+ * Converts legacy id opts key refs to the new ManagedIdentifierOpts
6
+ * @param opts
7
+ */
8
+ export declare function legacyKeyRefsToIdentifierOpts(opts: {
9
+ idOpts?: ManagedIdentifierOpts;
10
+ iss?: string;
11
+ keyRef?: string;
12
+ didOpts?: any;
13
+ }): ManagedIdentifierOpts;
3
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAE1E,cAAc,8BAA8B,CAAA;AAC5C,cAAc,+BAA+B,CAAA;AAE7C;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE;IAClD,MAAM,CAAC,EAAE,qBAAqB,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,GAAG,CAAA;CACd,GAAG,qBAAqB,CAqCxB"}
@@ -14,6 +14,42 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.legacyKeyRefsToIdentifierOpts = void 0;
17
18
  __exportStar(require("./managedIdentifierFunctions"), exports);
18
19
  __exportStar(require("./externalIdentifierFunctions"), exports);
20
+ /**
21
+ * Converts legacy id opts key refs to the new ManagedIdentifierOpts
22
+ * @param opts
23
+ */
24
+ function legacyKeyRefsToIdentifierOpts(opts) {
25
+ var _a, _b, _c, _d, _e, _f, _g;
26
+ if (!opts.idOpts) {
27
+ 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`);
28
+ // legacy way
29
+ let kmsKeyRef = (_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 : (typeof ((_e = opts.didOpts) === null || _e === void 0 ? void 0 : _e.idOpts.identifier) === 'object' ? ((_f = opts.didOpts) === null || _f === void 0 ? void 0 : _f.idOpts.identifier).keys[0].kid : undefined);
30
+ if (!kmsKeyRef) {
31
+ throw Error('Key ref is needed for access token signer');
32
+ }
33
+ return {
34
+ kmsKeyRef: (_g = opts.keyRef) !== null && _g !== void 0 ? _g : kmsKeyRef,
35
+ identifier: kmsKeyRef,
36
+ issuer: opts.iss,
37
+ };
38
+ }
39
+ else {
40
+ const idOpts = opts.idOpts;
41
+ if (opts.keyRef && !idOpts.kmsKeyRef) {
42
+ // legacy way
43
+ 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`);
44
+ idOpts.kmsKeyRef = opts.keyRef;
45
+ }
46
+ if (opts.iss && !idOpts.issuer) {
47
+ // legacy way
48
+ 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`);
49
+ idOpts.issuer = opts.iss;
50
+ }
51
+ return idOpts;
52
+ }
53
+ }
54
+ exports.legacyKeyRefsToIdentifierOpts = legacyKeyRefsToIdentifierOpts;
19
55
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA4C;AAC5C,gEAA6C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,+DAA4C;AAC5C,gEAA6C;AAE7C;;;GAGG;AACH,SAAgB,6BAA6B,CAAC,IAK7C;;IACC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,IAAI,CACV,uRAAuR,CACxR,C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version": "0.24.1-unstable.81+22f2aa6",
3
+ "version": "0.24.1-unstable.83+dab8be1",
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.81+22f2aa6",
19
- "@sphereon/ssi-sdk-ext.key-utils": "0.24.1-unstable.81+22f2aa6",
20
- "@sphereon/ssi-sdk-ext.x509-utils": "0.24.1-unstable.81+22f2aa6",
18
+ "@sphereon/ssi-sdk-ext.did-utils": "0.24.1-unstable.83+dab8be1",
19
+ "@sphereon/ssi-sdk-ext.key-utils": "0.24.1-unstable.83+dab8be1",
20
+ "@sphereon/ssi-sdk-ext.x509-utils": "0.24.1-unstable.83+dab8be1",
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.81+22f2aa6",
31
- "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.24.1-unstable.81+22f2aa6",
32
- "@sphereon/ssi-sdk-ext.key-manager": "0.24.1-unstable.81+22f2aa6",
33
- "@sphereon/ssi-sdk-ext.kms-local": "0.24.1-unstable.81+22f2aa6",
30
+ "@sphereon/ssi-sdk-ext.did-provider-jwk": "0.24.1-unstable.83+dab8be1",
31
+ "@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.24.1-unstable.83+dab8be1",
32
+ "@sphereon/ssi-sdk-ext.key-manager": "0.24.1-unstable.83+dab8be1",
33
+ "@sphereon/ssi-sdk-ext.kms-local": "0.24.1-unstable.83+dab8be1",
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": "22f2aa671bf4bfb071e5513200f42b28c4064b44"
67
+ "gitHead": "dab8be188694c6301bee250b02fb52178b93002b"
68
68
  }
@@ -45,8 +45,8 @@ export class IdentifierResolution implements IAgentPlugin {
45
45
  /**
46
46
  * TODO: Add a cache, as we are retrieving the same keys/info quite often
47
47
  */
48
- constructor({ crypto: cryptoArg = global.crypto }: { crypto?: Crypto }) {
49
- this._crypto = cryptoArg
48
+ constructor(opts?: { crypto?: Crypto }) {
49
+ this._crypto = opts?.crypto ?? global.crypto
50
50
  }
51
51
 
52
52
  /**
@@ -1,2 +1,53 @@
1
+ import { IIdentifier } from '@veramo/core'
2
+ import { ManagedIdentifierDidOpts, ManagedIdentifierOpts } from '../types'
3
+
1
4
  export * from './managedIdentifierFunctions'
2
5
  export * from './externalIdentifierFunctions'
6
+
7
+ /**
8
+ * Converts legacy id opts key refs to the new ManagedIdentifierOpts
9
+ * @param opts
10
+ */
11
+ export function legacyKeyRefsToIdentifierOpts(opts: {
12
+ idOpts?: ManagedIdentifierOpts
13
+ iss?: string
14
+ keyRef?: string
15
+ didOpts?: any
16
+ }): ManagedIdentifierOpts {
17
+ if (!opts.idOpts) {
18
+ console.warn(
19
+ `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`
20
+ )
21
+ // legacy way
22
+ let kmsKeyRef =
23
+ opts.keyRef ??
24
+ opts.didOpts?.idOpts?.kmsKeyRef ??
25
+ (typeof opts.didOpts?.idOpts.identifier === 'object' ? (opts.didOpts?.idOpts.identifier as IIdentifier).keys[0].kid : undefined)
26
+ if (!kmsKeyRef) {
27
+ throw Error('Key ref is needed for access token signer')
28
+ }
29
+ return {
30
+ kmsKeyRef: opts.keyRef ?? kmsKeyRef,
31
+ identifier: kmsKeyRef,
32
+ issuer: opts.iss,
33
+ } satisfies ManagedIdentifierDidOpts
34
+ } else {
35
+ const idOpts = opts.idOpts
36
+ if (opts.keyRef && !idOpts.kmsKeyRef) {
37
+ // legacy way
38
+ console.warn(
39
+ `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`
40
+ )
41
+ idOpts.kmsKeyRef = opts.keyRef
42
+ }
43
+ if (opts.iss && !idOpts.issuer) {
44
+ // legacy way
45
+ console.warn(
46
+ `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`
47
+ )
48
+ idOpts.issuer = opts.iss
49
+ }
50
+
51
+ return idOpts
52
+ }
53
+ }