@sphereon/ssi-sdk-ext.did-utils 0.28.1-feature.esm.cjs.9 → 0.28.1-feature.jose.vcdm.20

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 CHANGED
@@ -1,18 +1,84 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __defProp = Object.defineProperty;
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
2
8
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.ts
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ AgentDIDResolver: () => AgentDIDResolver,
35
+ DID_PREFIX: () => DID_PREFIX,
36
+ IdentifierAliasEnum: () => IdentifierAliasEnum,
37
+ SupportedDidMethodEnum: () => SupportedDidMethodEnum,
38
+ asDidWeb: () => asDidWeb,
39
+ createIdentifier: () => createIdentifier,
40
+ dereferenceDidKeysWithJwkSupport: () => dereferenceDidKeysWithJwkSupport,
41
+ determineKid: () => determineKid,
42
+ didDocumentToJwks: () => didDocumentToJwks,
43
+ extractPublicKeyHex: () => extractPublicKeyHex,
44
+ extractPublicKeyHexWithJwkSupport: () => extractPublicKeyHexWithJwkSupport,
45
+ getAgentDIDMethods: () => getAgentDIDMethods,
46
+ getAgentResolver: () => getAgentResolver,
47
+ getAuthenticationKey: () => getAuthenticationKey,
48
+ getControllerKey: () => getControllerKey,
49
+ getDID: () => getDID,
50
+ getDidSigner: () => getDidSigner,
51
+ getEthereumAddressFromKey: () => getEthereumAddressFromKey,
52
+ getFirstKeyWithRelation: () => getFirstKeyWithRelation,
53
+ getFirstKeyWithRelationFromDIDDoc: () => getFirstKeyWithRelationFromDIDDoc,
54
+ getKey: () => getKey,
55
+ getKeys: () => getKeys,
56
+ getOrCreatePrimaryIdentifier: () => getOrCreatePrimaryIdentifier,
57
+ getPrimaryIdentifier: () => getPrimaryIdentifier,
58
+ getSupportedDIDMethods: () => getSupportedDIDMethods,
59
+ isEvenHexString: () => isEvenHexString,
60
+ jwkTtoPublicKeyHex: () => jwkTtoPublicKeyHex,
61
+ mapIdentifierKeysToDocWithJwkSupport: () => mapIdentifierKeysToDocWithJwkSupport,
62
+ signDidJWT: () => signDidJWT,
63
+ toDID: () => toDID,
64
+ toDIDs: () => toDIDs,
65
+ toDidDocument: () => toDidDocument,
66
+ toDidResolutionResult: () => toDidResolutionResult,
67
+ verificationMethodToJwk: () => verificationMethodToJwk
68
+ });
69
+ module.exports = __toCommonJS(index_exports);
3
70
 
4
71
  // src/did-functions.ts
5
- var _transactions = require('@ethersproject/transactions');
6
- var _diduniclient = require('@sphereon/did-uni-client');
7
- var _ssisdkextkeyutils = require('@sphereon/ssi-sdk-ext.key-utils');
8
- var _ssisdkextx509utils = require('@sphereon/ssi-sdk-ext.x509-utils');
9
- var _ssisdkcore = require('@sphereon/ssi-sdk.core');
10
- var _ed25519 = require('@stablelib/ed25519');
11
- var _utils = require('@veramo/utils');
12
- var _didjwt = require('did-jwt');
13
- var _elliptic = require('elliptic'); var _elliptic2 = _interopRequireDefault(_elliptic);
14
- var _fromstring = require('uint8arrays/from-string');
15
- var _tostring = require('uint8arrays/to-string');
72
+ var import_transactions = require("@ethersproject/transactions");
73
+ var import_did_uni_client = require("@sphereon/did-uni-client");
74
+ var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.key-utils");
75
+ var import_ssi_sdk_ext2 = require("@sphereon/ssi-sdk-ext.x509-utils");
76
+ var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
77
+ var import_ed25519 = require("@stablelib/ed25519");
78
+ var import_utils = require("@veramo/utils");
79
+ var import_did_jwt = require("did-jwt");
80
+ var import_elliptic = __toESM(require("elliptic"), 1);
81
+ var u8a = __toESM(require("uint8arrays"), 1);
16
82
 
17
83
  // src/types.ts
18
84
  var SupportedDidMethodEnum = /* @__PURE__ */ function(SupportedDidMethodEnum2) {
@@ -32,6 +98,7 @@ var IdentifierAliasEnum = /* @__PURE__ */ function(IdentifierAliasEnum2) {
32
98
  var DID_PREFIX = "did:";
33
99
 
34
100
  // src/did-functions.ts
101
+ var { fromString, toString } = u8a;
35
102
  var getAuthenticationKey = /* @__PURE__ */ __name(async ({ identifier, offlineWhenNoDIDRegistered, noVerificationMethodFallback, keyType, controllerKey }, context) => {
36
103
  return await getFirstKeyWithRelation({
37
104
  identifier,
@@ -45,19 +112,19 @@ var getAuthenticationKey = /* @__PURE__ */ __name(async ({ identifier, offlineWh
45
112
  var getFirstKeyWithRelation = /* @__PURE__ */ __name(async ({ identifier, offlineWhenNoDIDRegistered, noVerificationMethodFallback, keyType, controllerKey, vmRelationship }, context) => {
46
113
  let key = void 0;
47
114
  try {
48
- key = await _asyncNullishCoalesce(await getFirstKeyWithRelationFromDIDDoc({
115
+ key = await getFirstKeyWithRelationFromDIDDoc({
49
116
  identifier,
50
117
  vmRelationship,
51
118
  errorOnNotFound: false,
52
119
  keyType,
53
120
  controllerKey
54
- }, context), async () => ( (noVerificationMethodFallback || vmRelationship === "verificationMethod" ? void 0 : await getFirstKeyWithRelationFromDIDDoc({
121
+ }, context) ?? (noVerificationMethodFallback || vmRelationship === "verificationMethod" ? void 0 : await getFirstKeyWithRelationFromDIDDoc({
55
122
  identifier,
56
123
  vmRelationship: "verificationMethod",
57
124
  errorOnNotFound: false,
58
125
  keyType,
59
126
  controllerKey
60
- }, context))));
127
+ }, context));
61
128
  } catch (e) {
62
129
  if (e instanceof Error) {
63
130
  if (!e.message.includes("404") || !offlineWhenNoDIDRegistered) {
@@ -69,23 +136,23 @@ var getFirstKeyWithRelation = /* @__PURE__ */ __name(async ({ identifier, offlin
69
136
  }
70
137
  if (!key && offlineWhenNoDIDRegistered) {
71
138
  const offlineDID = toDidDocument(identifier);
72
- key = await _asyncNullishCoalesce(await getFirstKeyWithRelationFromDIDDoc({
139
+ key = await getFirstKeyWithRelationFromDIDDoc({
73
140
  identifier,
74
141
  vmRelationship,
75
142
  errorOnNotFound: false,
76
143
  didDocument: offlineDID,
77
144
  keyType,
78
145
  controllerKey
79
- }, context), async () => ( (noVerificationMethodFallback || vmRelationship === "verificationMethod" ? void 0 : await getFirstKeyWithRelationFromDIDDoc({
146
+ }, context) ?? (noVerificationMethodFallback || vmRelationship === "verificationMethod" ? void 0 : await getFirstKeyWithRelationFromDIDDoc({
80
147
  identifier,
81
148
  vmRelationship: "verificationMethod",
82
149
  errorOnNotFound: false,
83
150
  didDocument: offlineDID,
84
151
  keyType,
85
152
  controllerKey
86
- }, context))));
153
+ }, context));
87
154
  if (!key) {
88
- key = identifier.keys.map((key2) => key2).filter((key2) => keyType === void 0 || key2.type === keyType || controllerKey && key2.kid === identifier.controllerKeyId).find((key2) => _optionalChain([key2, 'access', _ => _.meta, 'access', _2 => _2.verificationMethod, 'optionalAccess', _3 => _3.type, 'access', _4 => _4.includes, 'call', _5 => _5("authentication")]) || _optionalChain([key2, 'access', _6 => _6.meta, 'access', _7 => _7.purposes, 'optionalAccess', _8 => _8.includes, 'call', _9 => _9("authentication")]));
155
+ key = identifier.keys.map((key2) => key2).filter((key2) => keyType === void 0 || key2.type === keyType || controllerKey && key2.kid === identifier.controllerKeyId).find((key2) => key2.meta.verificationMethod?.type.includes("authentication") || key2.meta.purposes?.includes("authentication"));
89
156
  }
90
157
  }
91
158
  if (!key) {
@@ -95,8 +162,8 @@ var getFirstKeyWithRelation = /* @__PURE__ */ __name(async ({ identifier, offlin
95
162
  }, "getFirstKeyWithRelation");
96
163
  var getOrCreatePrimaryIdentifier = /* @__PURE__ */ __name(async (context, opts) => {
97
164
  const primaryIdentifier = await getPrimaryIdentifier(context, {
98
- ..._optionalChain([opts, 'optionalAccess', _10 => _10.createOpts, 'optionalAccess', _11 => _11.options]),
99
- ..._optionalChain([opts, 'optionalAccess', _12 => _12.method]) && {
165
+ ...opts?.createOpts?.options,
166
+ ...opts?.method && {
100
167
  method: opts.method
101
168
  }
102
169
  });
@@ -106,8 +173,8 @@ var getOrCreatePrimaryIdentifier = /* @__PURE__ */ __name(async (context, opts)
106
173
  result: primaryIdentifier
107
174
  };
108
175
  }
109
- if (_optionalChain([opts, 'optionalAccess', _13 => _13.method]) === SupportedDidMethodEnum.DID_KEY) {
110
- const createOpts = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _14 => _14.createOpts]), () => ( {}));
176
+ if (opts?.method === SupportedDidMethodEnum.DID_KEY) {
177
+ const createOpts = opts?.createOpts ?? {};
111
178
  createOpts.options = {
112
179
  codecName: "EBSI",
113
180
  type: "Secp256r1",
@@ -122,19 +189,19 @@ var getOrCreatePrimaryIdentifier = /* @__PURE__ */ __name(async (context, opts)
122
189
  };
123
190
  }, "getOrCreatePrimaryIdentifier");
124
191
  var getPrimaryIdentifier = /* @__PURE__ */ __name(async (context, opts) => {
125
- const identifiers = (await context.agent.didManagerFind(_optionalChain([opts, 'optionalAccess', _15 => _15.method]) ? {
126
- provider: `${DID_PREFIX}${_optionalChain([opts, 'optionalAccess', _16 => _16.method])}`
127
- } : {})).filter((identifier) => _optionalChain([opts, 'optionalAccess', _17 => _17.type]) === void 0 || identifier.keys.some((key) => key.type === _optionalChain([opts, 'optionalAccess', _18 => _18.type])));
192
+ const identifiers = (await context.agent.didManagerFind(opts?.method ? {
193
+ provider: `${DID_PREFIX}${opts?.method}`
194
+ } : {})).filter((identifier) => opts?.type === void 0 || identifier.keys.some((key) => key.type === opts?.type));
128
195
  return identifiers && identifiers.length > 0 ? identifiers[0] : void 0;
129
196
  }, "getPrimaryIdentifier");
130
197
  var createIdentifier = /* @__PURE__ */ __name(async (context, opts) => {
131
198
  return await context.agent.didManagerCreate({
132
- kms: await _ssisdkextkeyutils.getKms.call(void 0, context, _optionalChain([opts, 'optionalAccess', _19 => _19.createOpts, 'optionalAccess', _20 => _20.kms])),
133
- ..._optionalChain([opts, 'optionalAccess', _21 => _21.method]) && {
134
- provider: `${DID_PREFIX}${_optionalChain([opts, 'optionalAccess', _22 => _22.method])}`
199
+ kms: await (0, import_ssi_sdk_ext.getKms)(context, opts?.createOpts?.kms),
200
+ ...opts?.method && {
201
+ provider: `${DID_PREFIX}${opts?.method}`
135
202
  },
136
- alias: _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _23 => _23.createOpts, 'optionalAccess', _24 => _24.alias]), () => ( `${IdentifierAliasEnum.PRIMARY}-${_optionalChain([opts, 'optionalAccess', _25 => _25.method])}-${_optionalChain([opts, 'optionalAccess', _26 => _26.createOpts, 'optionalAccess', _27 => _27.options, 'optionalAccess', _28 => _28.type])}-${(/* @__PURE__ */ new Date()).getTime()}`)),
137
- options: _optionalChain([opts, 'optionalAccess', _29 => _29.createOpts, 'optionalAccess', _30 => _30.options])
203
+ alias: opts?.createOpts?.alias ?? `${IdentifierAliasEnum.PRIMARY}-${opts?.method}-${opts?.createOpts?.options?.type}-${(/* @__PURE__ */ new Date()).getTime()}`,
204
+ options: opts?.createOpts?.options
138
205
  });
139
206
  }, "createIdentifier");
140
207
  var getFirstKeyWithRelationFromDIDDoc = /* @__PURE__ */ __name(async ({ identifier, vmRelationship = "verificationMethod", keyType, errorOnNotFound = false, didDocument, controllerKey }, context) => {
@@ -158,7 +225,7 @@ var getEthereumAddressFromKey = /* @__PURE__ */ __name(({ key }) => {
158
225
  if (key.type !== "Secp256k1") {
159
226
  throw Error(`Can only get ethereum address from a Secp256k1 key. Type is ${key.type} for keyRef: ${key.kid}`);
160
227
  }
161
- const ethereumAddress = _nullishCoalesce(_nullishCoalesce(_optionalChain([key, 'access', _31 => _31.meta, 'optionalAccess', _32 => _32.ethereumAddress]), () => ( _optionalChain([key, 'access', _33 => _33.meta, 'optionalAccess', _34 => _34.account, 'optionalAccess', _35 => _35.toLowerCase, 'call', _36 => _36()]))), () => ( _transactions.computeAddress.call(void 0, `0x${key.publicKeyHex}`).toLowerCase()));
228
+ const ethereumAddress = key.meta?.ethereumAddress ?? key.meta?.account?.toLowerCase() ?? (0, import_transactions.computeAddress)(`0x${key.publicKeyHex}`).toLowerCase();
162
229
  if (!ethereumAddress) {
163
230
  throw Error(`Could not get or generate ethereum address from key with keyRef ${key.kid}`);
164
231
  }
@@ -172,7 +239,7 @@ var getControllerKey = /* @__PURE__ */ __name(({ identifier }) => {
172
239
  return key;
173
240
  }, "getControllerKey");
174
241
  var getKeys = /* @__PURE__ */ __name(({ jwkThumbprint, kms, identifier, kmsKeyRef, keyType, controllerKey }) => {
175
- return identifier.keys.filter((key) => !keyType || key.type === keyType).filter((key) => !kms || key.kms === kms).filter((key) => !kmsKeyRef || key.kid === kmsKeyRef).filter((key) => !jwkThumbprint || _optionalChain([key, 'access', _37 => _37.meta, 'optionalAccess', _38 => _38.jwkThumbprint]) === jwkThumbprint).filter((key) => !controllerKey || identifier.controllerKeyId === key.kid);
242
+ return identifier.keys.filter((key) => !keyType || key.type === keyType).filter((key) => !kms || key.kms === kms).filter((key) => !kmsKeyRef || key.kid === kmsKeyRef).filter((key) => !jwkThumbprint || key.meta?.jwkThumbprint === jwkThumbprint).filter((key) => !controllerKey || identifier.controllerKeyId === key.kid);
176
243
  }, "getKeys");
177
244
  async function dereferenceDidKeysWithJwkSupport(didDocument, section = "keyAgreement", context) {
178
245
  const convert = section === "keyAgreement";
@@ -193,7 +260,7 @@ async function dereferenceDidKeysWithJwkSupport(didDocument, section = "keyAgree
193
260
  } else {
194
261
  return key;
195
262
  }
196
- }))).filter(_utils.isDefined).map((key) => {
263
+ }))).filter(import_utils.isDefined).map((key) => {
197
264
  const hexKey = extractPublicKeyHexWithJwkSupport(key, convert);
198
265
  const { publicKeyHex, publicKeyBase58, publicKeyBase64, publicKeyJwk, ...keyProps } = key;
199
266
  const newKey = {
@@ -209,31 +276,31 @@ async function dereferenceDidKeysWithJwkSupport(didDocument, section = "keyAgree
209
276
  __name(dereferenceDidKeysWithJwkSupport, "dereferenceDidKeysWithJwkSupport");
210
277
  function jwkTtoPublicKeyHex(jwk) {
211
278
  const vm = {
212
- publicKeyJwk: _ssisdkextkeyutils.sanitizedJwk.call(void 0, jwk)
279
+ publicKeyJwk: (0, import_ssi_sdk_ext.sanitizedJwk)(jwk)
213
280
  };
214
281
  return extractPublicKeyHexWithJwkSupport(vm);
215
282
  }
216
283
  __name(jwkTtoPublicKeyHex, "jwkTtoPublicKeyHex");
217
284
  function extractPublicKeyHexWithJwkSupport(pk, convert = false) {
218
285
  if (pk.publicKeyJwk) {
219
- const jwk = _ssisdkextkeyutils.sanitizedJwk.call(void 0, pk.publicKeyJwk);
286
+ const jwk = (0, import_ssi_sdk_ext.sanitizedJwk)(pk.publicKeyJwk);
220
287
  if (jwk.kty === "EC") {
221
288
  const curve = jwk.crv ? toEcLibCurve(jwk.crv) : "p256";
222
- const xHex = _ssisdkextx509utils.base64ToHex.call(void 0, jwk.x, "base64url");
223
- const yHex = _ssisdkextx509utils.base64ToHex.call(void 0, jwk.y, "base64url");
289
+ const xHex = (0, import_ssi_sdk_ext2.base64ToHex)(jwk.x, "base64url");
290
+ const yHex = (0, import_ssi_sdk_ext2.base64ToHex)(jwk.y, "base64url");
224
291
  const prefix = "04";
225
292
  const hex = `${prefix}${xHex}${yHex}`;
226
293
  try {
227
- const ec = new _elliptic2.default.ec(curve);
294
+ const ec = new import_elliptic.default.ec(curve);
228
295
  const publicKeyHex = ec.keyFromPublic(hex, "hex").getPublic(true, "hex");
229
296
  return publicKeyHex;
230
297
  } catch (error) {
231
298
  console.error(`Error converting EC with elliptic lib curve ${curve} from JWK to hex. x: ${jwk.x}, y: ${jwk.y}, error: ${error}`, error);
232
299
  }
233
300
  } else if (jwk.crv === "Ed25519") {
234
- return _tostring.toString.call(void 0, _fromstring.fromString.call(void 0, jwk.x, "base64url"), "base16");
301
+ return toString(fromString(jwk.x, "base64url"), "base16");
235
302
  } else if (jwk.kty === "RSA") {
236
- return _ssisdkextx509utils.hexKeyFromPEMBasedJwk.call(void 0, jwk, "public");
303
+ return (0, import_ssi_sdk_ext2.hexKeyFromPEMBasedJwk)(jwk, "public");
237
304
  }
238
305
  }
239
306
  return extractPublicKeyHex(pk, convert);
@@ -255,23 +322,23 @@ function isEvenHexString(hex) {
255
322
  __name(isEvenHexString, "isEvenHexString");
256
323
  function extractPublicKeyHex(pk, convert = false) {
257
324
  let keyBytes = extractPublicKeyBytes(pk);
258
- const jwk = pk.publicKeyJwk ? _ssisdkextkeyutils.sanitizedJwk.call(void 0, pk.publicKeyJwk) : void 0;
325
+ const jwk = pk.publicKeyJwk ? (0, import_ssi_sdk_ext.sanitizedJwk)(pk.publicKeyJwk) : void 0;
259
326
  if (convert) {
260
327
  if ([
261
328
  "Ed25519",
262
329
  "Ed25519VerificationKey2018",
263
330
  "Ed25519VerificationKey2020"
264
- ].includes(pk.type) || pk.type === "JsonWebKey2020" && _optionalChain([jwk, 'optionalAccess', _39 => _39.crv]) === "Ed25519") {
265
- keyBytes = _ed25519.convertPublicKeyToX25519.call(void 0, keyBytes);
331
+ ].includes(pk.type) || pk.type === "JsonWebKey2020" && jwk?.crv === "Ed25519") {
332
+ keyBytes = (0, import_ed25519.convertPublicKeyToX25519)(keyBytes);
266
333
  } else if (![
267
334
  "X25519",
268
335
  "X25519KeyAgreementKey2019",
269
336
  "X25519KeyAgreementKey2020"
270
- ].includes(pk.type) && !(pk.type === "JsonWebKey2020" && _optionalChain([jwk, 'optionalAccess', _40 => _40.crv]) === "X25519")) {
337
+ ].includes(pk.type) && !(pk.type === "JsonWebKey2020" && jwk?.crv === "X25519")) {
271
338
  return "";
272
339
  }
273
340
  }
274
- return _ssisdkcore.bytesToHex.call(void 0, keyBytes);
341
+ return (0, import_ssi_sdk.bytesToHex)(keyBytes);
275
342
  }
276
343
  __name(extractPublicKeyHex, "extractPublicKeyHex");
277
344
  function toEcLibCurve(input) {
@@ -280,17 +347,17 @@ function toEcLibCurve(input) {
280
347
  __name(toEcLibCurve, "toEcLibCurve");
281
348
  function extractPublicKeyBytes(pk) {
282
349
  if (pk.publicKeyBase58) {
283
- return _ssisdkcore.base58ToBytes.call(void 0, pk.publicKeyBase58);
350
+ return (0, import_ssi_sdk.base58ToBytes)(pk.publicKeyBase58);
284
351
  } else if (pk.publicKeyMultibase) {
285
- return _ssisdkcore.multibaseKeyToBytes.call(void 0, pk.publicKeyMultibase);
352
+ return (0, import_ssi_sdk.multibaseKeyToBytes)(pk.publicKeyMultibase);
286
353
  } else if (pk.publicKeyBase64) {
287
- return _ssisdkcore.base64ToBytes.call(void 0, pk.publicKeyBase64);
354
+ return (0, import_ssi_sdk.base64ToBytes)(pk.publicKeyBase64);
288
355
  } else if (pk.publicKeyHex) {
289
- return _ssisdkcore.hexToBytes.call(void 0, pk.publicKeyHex);
290
- } else if (_optionalChain([pk, 'access', _41 => _41.publicKeyJwk, 'optionalAccess', _42 => _42.crv]) && pk.publicKeyJwk.x && pk.publicKeyJwk.y) {
291
- return _ssisdkcore.hexToBytes.call(void 0, extractPublicKeyHexWithJwkSupport(pk));
356
+ return (0, import_ssi_sdk.hexToBytes)(pk.publicKeyHex);
357
+ } else if (pk.publicKeyJwk?.crv && pk.publicKeyJwk.x && pk.publicKeyJwk.y) {
358
+ return (0, import_ssi_sdk.hexToBytes)(extractPublicKeyHexWithJwkSupport(pk));
292
359
  } else if (pk.publicKeyJwk && (pk.publicKeyJwk.crv === "Ed25519" || pk.publicKeyJwk.crv === "X25519") && pk.publicKeyJwk.x) {
293
- return _ssisdkcore.base64ToBytes.call(void 0, pk.publicKeyJwk.x);
360
+ return (0, import_ssi_sdk.base64ToBytes)(pk.publicKeyJwk.x);
294
361
  }
295
362
  return new Uint8Array();
296
363
  }
@@ -298,8 +365,8 @@ __name(extractPublicKeyBytes, "extractPublicKeyBytes");
298
365
  function verificationMethodToJwk(vm) {
299
366
  let jwk = vm.publicKeyJwk;
300
367
  if (!jwk) {
301
- let publicKeyHex = _nullishCoalesce(vm.publicKeyHex, () => ( _tostring.toString.call(void 0, extractPublicKeyBytes(vm), "hex")));
302
- jwk = _ssisdkextkeyutils.toJwk.call(void 0, publicKeyHex, _ssisdkextkeyutils.keyTypeFromCryptographicSuite.call(void 0, {
368
+ let publicKeyHex = vm.publicKeyHex ?? toString(extractPublicKeyBytes(vm), "hex");
369
+ jwk = (0, import_ssi_sdk_ext.toJwk)(publicKeyHex, (0, import_ssi_sdk_ext.keyTypeFromCryptographicSuite)({
303
370
  crv: vm.type
304
371
  }));
305
372
  }
@@ -307,11 +374,11 @@ function verificationMethodToJwk(vm) {
307
374
  throw Error(`Could not convert verification method to jwk`);
308
375
  }
309
376
  jwk.kid = vm.id;
310
- return _ssisdkextkeyutils.sanitizedJwk.call(void 0, jwk);
377
+ return (0, import_ssi_sdk_ext.sanitizedJwk)(jwk);
311
378
  }
312
379
  __name(verificationMethodToJwk, "verificationMethodToJwk");
313
380
  function didDocumentSectionToJwks(didDocumentSection, searchForVerificationMethods, verificationMethods) {
314
- const jwks = new Set((_nullishCoalesce(searchForVerificationMethods, () => ( []))).map((vmOrId) => typeof vmOrId === "object" ? vmOrId : _optionalChain([verificationMethods, 'optionalAccess', _43 => _43.find, 'call', _44 => _44((vm) => vm.id === vmOrId)])).filter(_utils.isDefined).map((vm) => verificationMethodToJwk(vm)));
381
+ const jwks = new Set((searchForVerificationMethods ?? []).map((vmOrId) => typeof vmOrId === "object" ? vmOrId : verificationMethods?.find((vm) => vm.id === vmOrId)).filter(import_utils.isDefined).map((vm) => verificationMethodToJwk(vm)));
315
382
  return {
316
383
  didDocumentSection,
317
384
  jwks: Array.from(jwks)
@@ -333,15 +400,15 @@ function didDocumentToJwks(didDocument) {
333
400
  }
334
401
  __name(didDocumentToJwks, "didDocumentToJwks");
335
402
  async function mapIdentifierKeysToDocWithJwkSupport({ identifier, vmRelationship = "verificationMethod", didDocument }, context) {
336
- const didDoc = await _asyncNullishCoalesce(didDocument, async () => ( await getAgentResolver(context).resolve(identifier.did).then((result) => result.didDocument)));
403
+ const didDoc = didDocument ?? await getAgentResolver(context).resolve(identifier.did).then((result) => result.didDocument);
337
404
  if (!didDoc) {
338
405
  throw Error(`Could not resolve DID ${identifier.did}`);
339
406
  }
340
- const keys = didDoc ? [] : await _utils.mapIdentifierKeysToDoc.call(void 0, identifier, vmRelationship, context);
407
+ const keys = didDoc ? [] : await (0, import_utils.mapIdentifierKeysToDoc)(identifier, vmRelationship, context);
341
408
  const documentKeys = await dereferenceDidKeysWithJwkSupport(didDoc, vmRelationship, context);
342
- const localKeys = vmRelationship === "keyAgreement" ? _utils.convertIdentifierEncryptionKeys.call(void 0, identifier) : _utils.compressIdentifierSecp256k1Keys.call(void 0, identifier);
409
+ const localKeys = vmRelationship === "keyAgreement" ? (0, import_utils.convertIdentifierEncryptionKeys)(identifier) : (0, import_utils.compressIdentifierSecp256k1Keys)(identifier);
343
410
  const extendedKeys = documentKeys.map((verificationMethod) => {
344
- const localKey = localKeys.find((localKey2) => localKey2.publicKeyHex === verificationMethod.publicKeyHex || _optionalChain([verificationMethod, 'access', _45 => _45.publicKeyHex, 'optionalAccess', _46 => _46.startsWith, 'call', _47 => _47(localKey2.publicKeyHex)]) || compareBlockchainAccountId(localKey2, verificationMethod));
411
+ const localKey = localKeys.find((localKey2) => localKey2.publicKeyHex === verificationMethod.publicKeyHex || verificationMethod.publicKeyHex?.startsWith(localKey2.publicKeyHex) || compareBlockchainAccountId(localKey2, verificationMethod));
345
412
  if (localKey) {
346
413
  const { meta, ...localProps } = localKey;
347
414
  return {
@@ -354,7 +421,7 @@ async function mapIdentifierKeysToDocWithJwkSupport({ identifier, vmRelationship
354
421
  } else {
355
422
  return null;
356
423
  }
357
- }).filter(_utils.isDefined);
424
+ }).filter(import_utils.isDefined);
358
425
  return keys.concat(extendedKeys);
359
426
  }
360
427
  __name(mapIdentifierKeysToDocWithJwkSupport, "mapIdentifierKeysToDocWithJwkSupport");
@@ -362,11 +429,11 @@ function compareBlockchainAccountId(localKey, verificationMethod) {
362
429
  if (verificationMethod.type !== "EcdsaSecp256k1RecoveryMethod2020" && verificationMethod.type !== "EcdsaSecp256k1VerificationKey2019" || localKey.type !== "Secp256k1") {
363
430
  return false;
364
431
  }
365
- let vmEthAddr = _utils.getEthereumAddress.call(void 0, verificationMethod);
366
- if (_optionalChain([localKey, 'access', _48 => _48.meta, 'optionalAccess', _49 => _49.account])) {
367
- return vmEthAddr === _optionalChain([localKey, 'access', _50 => _50.meta, 'optionalAccess', _51 => _51.account, 'access', _52 => _52.toLowerCase, 'call', _53 => _53()]);
432
+ let vmEthAddr = (0, import_utils.getEthereumAddress)(verificationMethod);
433
+ if (localKey.meta?.account) {
434
+ return vmEthAddr === localKey.meta?.account.toLowerCase();
368
435
  }
369
- const computedAddr = _transactions.computeAddress.call(void 0, "0x" + localKey.publicKeyHex).toLowerCase();
436
+ const computedAddr = (0, import_transactions.computeAddress)("0x" + localKey.publicKeyHex).toLowerCase();
370
437
  return computedAddr === vmEthAddr;
371
438
  }
372
439
  __name(compareBlockchainAccountId, "compareBlockchainAccountId");
@@ -404,9 +471,9 @@ async function getKey({ identifier, vmRelationship = "authentication", kmsKeyRef
404
471
  if (!identifier) {
405
472
  return Promise.reject(new Error(`No identifier provided to getKey method!`));
406
473
  }
407
- const kmsKeyRefParts = _optionalChain([kmsKeyRef, 'optionalAccess', _54 => _54.split, 'call', _55 => _55(`#`)]);
408
- const kid = kmsKeyRefParts ? _optionalChain([kmsKeyRefParts, 'optionalAccess', _56 => _56.length]) === 2 ? kmsKeyRefParts[1] : kmsKeyRefParts[0] : void 0;
409
- let identifierKey = kmsKeyRef ? identifier.keys.find((key) => key.kid === kid || _optionalChain([key, 'optionalAccess', _57 => _57.meta, 'optionalAccess', _58 => _58.jwkThumbprint]) === kid) : void 0;
474
+ const kmsKeyRefParts = kmsKeyRef?.split(`#`);
475
+ const kid = kmsKeyRefParts ? kmsKeyRefParts?.length === 2 ? kmsKeyRefParts[1] : kmsKeyRefParts[0] : void 0;
476
+ let identifierKey = kmsKeyRef ? identifier.keys.find((key) => key.kid === kid || key?.meta?.jwkThumbprint === kid) : void 0;
410
477
  if (!identifierKey) {
411
478
  const keys = await mapIdentifierKeysToDocWithJwkSupport({
412
479
  identifier,
@@ -416,10 +483,10 @@ async function getKey({ identifier, vmRelationship = "authentication", kmsKeyRef
416
483
  throw new Error(`No keys found for verificationMethodSection: ${vmRelationship} and did ${identifier.did}`);
417
484
  }
418
485
  if (kmsKeyRef) {
419
- identifierKey = keys.find((key) => _optionalChain([key, 'access', _59 => _59.meta, 'access', _60 => _60.verificationMethod, 'optionalAccess', _61 => _61.id]) === kmsKeyRef || kid && _optionalChain([key, 'access', _62 => _62.meta, 'access', _63 => _63.verificationMethod, 'optionalAccess', _64 => _64.id, 'optionalAccess', _65 => _65.includes, 'call', _66 => _66(kid)]));
486
+ identifierKey = keys.find((key) => key.meta.verificationMethod?.id === kmsKeyRef || kid && key.meta.verificationMethod?.id?.includes(kid));
420
487
  }
421
488
  if (!identifierKey) {
422
- identifierKey = keys.find((key) => _optionalChain([key, 'access', _67 => _67.meta, 'access', _68 => _68.verificationMethod, 'optionalAccess', _69 => _69.type]) === vmRelationship || _optionalChain([key, 'access', _70 => _70.meta, 'access', _71 => _71.purposes, 'optionalAccess', _72 => _72.includes, 'call', _73 => _73(vmRelationship)]));
489
+ identifierKey = keys.find((key) => key.meta.verificationMethod?.type === vmRelationship || key.meta.purposes?.includes(vmRelationship));
423
490
  }
424
491
  if (!identifierKey) {
425
492
  identifierKey = keys[0];
@@ -441,8 +508,8 @@ async function legacyGetIdentifier({ identifier }, context) {
441
508
  }
442
509
  __name(legacyGetIdentifier, "legacyGetIdentifier");
443
510
  async function determineKid({ key, idOpts }, context) {
444
- if (_optionalChain([key, 'access', _74 => _74.meta, 'optionalAccess', _75 => _75.verificationMethod, 'optionalAccess', _76 => _76.id])) {
445
- return _optionalChain([key, 'access', _77 => _77.meta, 'optionalAccess', _78 => _78.verificationMethod, 'optionalAccess', _79 => _79.id]);
511
+ if (key.meta?.verificationMethod?.id) {
512
+ return key.meta?.verificationMethod?.id;
446
513
  }
447
514
  const identifier = await legacyGetIdentifier(idOpts, context);
448
515
  const mappedKeys = await mapIdentifierKeysToDocWithJwkSupport({
@@ -451,13 +518,13 @@ async function determineKid({ key, idOpts }, context) {
451
518
  }, context);
452
519
  const vmKey = mappedKeys.find((extendedKey) => extendedKey.kid === key.kid);
453
520
  if (vmKey) {
454
- return _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([vmKey, 'access', _80 => _80.meta, 'optionalAccess', _81 => _81.verificationMethod, 'optionalAccess', _82 => _82.id]), () => ( _optionalChain([vmKey, 'access', _83 => _83.meta, 'optionalAccess', _84 => _84.jwkThumbprint]))), () => ( idOpts.kmsKeyRef)), () => ( vmKey.kid));
521
+ return vmKey.meta?.verificationMethod?.id ?? vmKey.meta?.jwkThumbprint ?? idOpts.kmsKeyRef ?? vmKey.kid;
455
522
  }
456
- return _nullishCoalesce(_nullishCoalesce(_optionalChain([key, 'access', _85 => _85.meta, 'optionalAccess', _86 => _86.jwkThumbprint]), () => ( idOpts.kmsKeyRef)), () => ( key.kid));
523
+ return key.meta?.jwkThumbprint ?? idOpts.kmsKeyRef ?? key.kid;
457
524
  }
458
525
  __name(determineKid, "determineKid");
459
526
  async function getSupportedDIDMethods(didOpts, context) {
460
- return await _asyncNullishCoalesce(didOpts.supportedDIDMethods, async () => ( await getAgentDIDMethods(context)));
527
+ return didOpts.supportedDIDMethods ?? await getAgentDIDMethods(context);
461
528
  }
462
529
  __name(getSupportedDIDMethods, "getSupportedDIDMethods");
463
530
  function getAgentResolver(context, opts) {
@@ -468,15 +535,15 @@ var AgentDIDResolver = class {
468
535
  static {
469
536
  __name(this, "AgentDIDResolver");
470
537
  }
471
-
472
-
473
-
474
-
538
+ context;
539
+ resolverResolution;
540
+ uniresolverResolution;
541
+ localResolution;
475
542
  constructor(context, opts) {
476
543
  this.context = context;
477
- this.resolverResolution = _optionalChain([opts, 'optionalAccess', _87 => _87.resolverResolution]) !== false;
478
- this.uniresolverResolution = _optionalChain([opts, 'optionalAccess', _88 => _88.uniresolverResolution]) !== false;
479
- this.localResolution = _optionalChain([opts, 'optionalAccess', _89 => _89.localResolution]) !== false;
544
+ this.resolverResolution = opts?.resolverResolution !== false;
545
+ this.uniresolverResolution = opts?.uniresolverResolution !== false;
546
+ this.localResolution = opts?.localResolution !== false;
480
547
  }
481
548
  async resolve(didUrl, options) {
482
549
  let resolutionResult;
@@ -534,7 +601,7 @@ var AgentDIDResolver = class {
534
601
  }
535
602
  if (!resolutionResult && this.uniresolverResolution) {
536
603
  console.log(`Using universal resolver resolution for did ${didUrl} `);
537
- resolutionResult = await new (0, _diduniclient.UniResolver)().resolve(didUrl, options);
604
+ resolutionResult = await new import_did_uni_client.UniResolver().resolve(didUrl, options);
538
605
  if (!origResolutionResult) {
539
606
  origResolutionResult = resolutionResult;
540
607
  }
@@ -548,13 +615,13 @@ var AgentDIDResolver = class {
548
615
  if (!resolutionResult && !origResolutionResult) {
549
616
  throw `Could not resolve ${didUrl}. Resolutions tried: online: ${this.resolverResolution}, local: ${this.localResolution}, uni resolver: ${this.uniresolverResolution}`;
550
617
  }
551
- return _nullishCoalesce(resolutionResult, () => ( origResolutionResult));
618
+ return resolutionResult ?? origResolutionResult;
552
619
  }
553
620
  };
554
621
  function toDidDocument(identifier, opts) {
555
622
  let didDocument = void 0;
556
623
  if (identifier) {
557
- const did = _nullishCoalesce(identifier.did, () => ( _optionalChain([opts, 'optionalAccess', _90 => _90.did])));
624
+ const did = identifier.did ?? opts?.did;
558
625
  didDocument = {
559
626
  "@context": "https://www.w3.org/ns/did/v1",
560
627
  id: did,
@@ -562,48 +629,48 @@ function toDidDocument(identifier, opts) {
562
629
  const vm = {
563
630
  controller: did,
564
631
  id: key.kid.startsWith(did) && key.kid.includes("#") ? key.kid : `${did}#${key.kid}`,
565
- publicKeyJwk: _ssisdkextkeyutils.toJwk.call(void 0, key.publicKeyHex, key.type, {
566
- use: _ssisdkextkeyutils.ENC_KEY_ALGS.includes(key.type) ? _ssisdkextkeyutils.JwkKeyUse.Encryption : _ssisdkextkeyutils.JwkKeyUse.Signature,
632
+ publicKeyJwk: (0, import_ssi_sdk_ext.toJwk)(key.publicKeyHex, key.type, {
633
+ use: import_ssi_sdk_ext.ENC_KEY_ALGS.includes(key.type) ? import_ssi_sdk_ext.JwkKeyUse.Encryption : import_ssi_sdk_ext.JwkKeyUse.Signature,
567
634
  key
568
635
  }),
569
636
  type: "JsonWebKey2020"
570
637
  };
571
638
  return vm;
572
639
  }),
573
- ...(_optionalChain([opts, 'optionalAccess', _91 => _91.use]) === void 0 || _optionalChain([opts, 'optionalAccess', _92 => _92.use, 'optionalAccess', _93 => _93.includes, 'call', _94 => _94(_ssisdkextkeyutils.JwkKeyUse.Signature)])) && identifier.keys && {
574
- assertionMethod: identifier.keys.filter((key) => _optionalChain([key, 'optionalAccess', _95 => _95.meta, 'optionalAccess', _96 => _96.purpose]) === void 0 || _optionalChain([key, 'optionalAccess', _97 => _97.meta, 'optionalAccess', _98 => _98.purpose]) === "assertionMethod" || _optionalChain([key, 'optionalAccess', _99 => _99.meta, 'optionalAccess', _100 => _100.purposes, 'optionalAccess', _101 => _101.includes, 'call', _102 => _102("assertionMethod")])).map((key) => {
640
+ ...(opts?.use === void 0 || opts?.use?.includes(import_ssi_sdk_ext.JwkKeyUse.Signature)) && identifier.keys && {
641
+ assertionMethod: identifier.keys.filter((key) => key?.meta?.purpose === void 0 || key?.meta?.purpose === "assertionMethod" || key?.meta?.purposes?.includes("assertionMethod")).map((key) => {
575
642
  if (key.kid.startsWith(did) && key.kid.includes("#")) {
576
643
  return key.kid;
577
644
  }
578
645
  return `${did}#${key.kid}`;
579
646
  })
580
647
  },
581
- ...(_optionalChain([opts, 'optionalAccess', _103 => _103.use]) === void 0 || _optionalChain([opts, 'optionalAccess', _104 => _104.use, 'optionalAccess', _105 => _105.includes, 'call', _106 => _106(_ssisdkextkeyutils.JwkKeyUse.Signature)])) && identifier.keys && {
582
- authentication: identifier.keys.filter((key) => _optionalChain([key, 'optionalAccess', _107 => _107.meta, 'optionalAccess', _108 => _108.purpose]) === void 0 || _optionalChain([key, 'optionalAccess', _109 => _109.meta, 'optionalAccess', _110 => _110.purpose]) === "authentication" || _optionalChain([key, 'optionalAccess', _111 => _111.meta, 'optionalAccess', _112 => _112.purposes, 'optionalAccess', _113 => _113.includes, 'call', _114 => _114("authentication")])).map((key) => {
648
+ ...(opts?.use === void 0 || opts?.use?.includes(import_ssi_sdk_ext.JwkKeyUse.Signature)) && identifier.keys && {
649
+ authentication: identifier.keys.filter((key) => key?.meta?.purpose === void 0 || key?.meta?.purpose === "authentication" || key?.meta?.purposes?.includes("authentication")).map((key) => {
583
650
  if (key.kid.startsWith(did) && key.kid.includes("#")) {
584
651
  return key.kid;
585
652
  }
586
653
  return `${did}#${key.kid}`;
587
654
  })
588
655
  },
589
- ...(_optionalChain([opts, 'optionalAccess', _115 => _115.use]) === void 0 || _optionalChain([opts, 'optionalAccess', _116 => _116.use, 'optionalAccess', _117 => _117.includes, 'call', _118 => _118(_ssisdkextkeyutils.JwkKeyUse.Encryption)])) && identifier.keys && {
590
- keyAgreement: identifier.keys.filter((key) => key.type === "X25519" || _optionalChain([key, 'optionalAccess', _119 => _119.meta, 'optionalAccess', _120 => _120.purpose]) === "keyAgreement" || _optionalChain([key, 'optionalAccess', _121 => _121.meta, 'optionalAccess', _122 => _122.purposes, 'optionalAccess', _123 => _123.includes, 'call', _124 => _124("keyAgreement")])).map((key) => {
656
+ ...(opts?.use === void 0 || opts?.use?.includes(import_ssi_sdk_ext.JwkKeyUse.Encryption)) && identifier.keys && {
657
+ keyAgreement: identifier.keys.filter((key) => key.type === "X25519" || key?.meta?.purpose === "keyAgreement" || key?.meta?.purposes?.includes("keyAgreement")).map((key) => {
591
658
  if (key.kid.startsWith(did) && key.kid.includes("#")) {
592
659
  return key.kid;
593
660
  }
594
661
  return `${did}#${key.kid}`;
595
662
  })
596
663
  },
597
- ...(_optionalChain([opts, 'optionalAccess', _125 => _125.use]) === void 0 || _optionalChain([opts, 'optionalAccess', _126 => _126.use, 'optionalAccess', _127 => _127.includes, 'call', _128 => _128(_ssisdkextkeyutils.JwkKeyUse.Encryption)])) && identifier.keys && {
598
- capabilityInvocation: identifier.keys.filter((key) => key.type === "X25519" || _optionalChain([key, 'optionalAccess', _129 => _129.meta, 'optionalAccess', _130 => _130.purpose]) === "capabilityInvocation" || _optionalChain([key, 'optionalAccess', _131 => _131.meta, 'optionalAccess', _132 => _132.purposes, 'optionalAccess', _133 => _133.includes, 'call', _134 => _134("capabilityInvocation")])).map((key) => {
664
+ ...(opts?.use === void 0 || opts?.use?.includes(import_ssi_sdk_ext.JwkKeyUse.Encryption)) && identifier.keys && {
665
+ capabilityInvocation: identifier.keys.filter((key) => key.type === "X25519" || key?.meta?.purpose === "capabilityInvocation" || key?.meta?.purposes?.includes("capabilityInvocation")).map((key) => {
599
666
  if (key.kid.startsWith(did) && key.kid.includes("#")) {
600
667
  return key.kid;
601
668
  }
602
669
  return `${did}#${key.kid}`;
603
670
  })
604
671
  },
605
- ...(_optionalChain([opts, 'optionalAccess', _135 => _135.use]) === void 0 || _optionalChain([opts, 'optionalAccess', _136 => _136.use, 'optionalAccess', _137 => _137.includes, 'call', _138 => _138(_ssisdkextkeyutils.JwkKeyUse.Encryption)])) && identifier.keys && {
606
- capabilityDelegation: identifier.keys.filter((key) => key.type === "X25519" || _optionalChain([key, 'optionalAccess', _139 => _139.meta, 'optionalAccess', _140 => _140.purpose]) === "capabilityDelegation" || _optionalChain([key, 'optionalAccess', _141 => _141.meta, 'optionalAccess', _142 => _142.purposes, 'optionalAccess', _143 => _143.includes, 'call', _144 => _144("capabilityDelegation")])).map((key) => {
672
+ ...(opts?.use === void 0 || opts?.use?.includes(import_ssi_sdk_ext.JwkKeyUse.Encryption)) && identifier.keys && {
673
+ capabilityDelegation: identifier.keys.filter((key) => key.type === "X25519" || key?.meta?.purpose === "capabilityDelegation" || key?.meta?.purposes?.includes("capabilityDelegation")).map((key) => {
607
674
  if (key.kid.startsWith(did) && key.kid.includes("#")) {
608
675
  return key.kid;
609
676
  }
@@ -619,7 +686,7 @@ function toDidDocument(identifier, opts) {
619
686
  }
620
687
  __name(toDidDocument, "toDidDocument");
621
688
  function toDidResolutionResult(identifier, opts) {
622
- const didDocument = _nullishCoalesce(toDidDocument(identifier, opts), () => ( null));
689
+ const didDocument = toDidDocument(identifier, opts) ?? null;
623
690
  const resolutionResult = {
624
691
  "@context": "https://w3id.org/did-resolution/v1",
625
692
  didDocument,
@@ -627,13 +694,13 @@ function toDidResolutionResult(identifier, opts) {
627
694
  ...!didDocument && {
628
695
  error: "notFound"
629
696
  },
630
- ...Array.isArray(_optionalChain([opts, 'optionalAccess', _145 => _145.supportedMethods])) && identifier && !_optionalChain([opts, 'optionalAccess', _146 => _146.supportedMethods, 'access', _147 => _147.includes, 'call', _148 => _148(identifier.provider.replace("did:", ""))]) && {
697
+ ...Array.isArray(opts?.supportedMethods) && identifier && !opts?.supportedMethods.includes(identifier.provider.replace("did:", "")) && {
631
698
  error: "unsupportedDidMethod"
632
699
  }
633
700
  },
634
701
  didDocumentMetadata: {
635
- ..._optionalChain([identifier, 'optionalAccess', _149 => _149.alias]) && {
636
- equivalentId: _optionalChain([identifier, 'optionalAccess', _150 => _150.alias])
702
+ ...identifier?.alias && {
703
+ equivalentId: identifier?.alias
637
704
  }
638
705
  }
639
706
  };
@@ -660,7 +727,7 @@ var signDidJWT = /* @__PURE__ */ __name(async (args) => {
660
727
  context
661
728
  })
662
729
  };
663
- return _didjwt.createJWT.call(void 0, payload, jwtOptions, header);
730
+ return (0, import_did_jwt.createJWT)(payload, jwtOptions, header);
664
731
  }, "signDidJWT");
665
732
  var getDidSigner = /* @__PURE__ */ __name(async (args) => {
666
733
  const { idOpts, context } = args;
@@ -670,7 +737,7 @@ var getDidSigner = /* @__PURE__ */ __name(async (args) => {
670
737
  vmRelationship: idOpts.verificationMethodSection,
671
738
  kmsKeyRef: idOpts.kmsKeyRef
672
739
  }, context);
673
- const algorithm = await _ssisdkextkeyutils.signatureAlgorithmFromKey.call(void 0, {
740
+ const algorithm = await (0, import_ssi_sdk_ext.signatureAlgorithmFromKey)({
674
741
  key
675
742
  });
676
743
  return async (data) => {
@@ -682,40 +749,4 @@ var getDidSigner = /* @__PURE__ */ __name(async (args) => {
682
749
  });
683
750
  };
684
751
  }, "getDidSigner");
685
-
686
-
687
-
688
-
689
-
690
-
691
-
692
-
693
-
694
-
695
-
696
-
697
-
698
-
699
-
700
-
701
-
702
-
703
-
704
-
705
-
706
-
707
-
708
-
709
-
710
-
711
-
712
-
713
-
714
-
715
-
716
-
717
-
718
-
719
-
720
- exports.AgentDIDResolver = AgentDIDResolver; exports.DID_PREFIX = DID_PREFIX; exports.IdentifierAliasEnum = IdentifierAliasEnum; exports.SupportedDidMethodEnum = SupportedDidMethodEnum; exports.asDidWeb = asDidWeb; exports.createIdentifier = createIdentifier; exports.dereferenceDidKeysWithJwkSupport = dereferenceDidKeysWithJwkSupport; exports.determineKid = determineKid; exports.didDocumentToJwks = didDocumentToJwks; exports.extractPublicKeyHex = extractPublicKeyHex; exports.extractPublicKeyHexWithJwkSupport = extractPublicKeyHexWithJwkSupport; exports.getAgentDIDMethods = getAgentDIDMethods; exports.getAgentResolver = getAgentResolver; exports.getAuthenticationKey = getAuthenticationKey; exports.getControllerKey = getControllerKey; exports.getDID = getDID; exports.getDidSigner = getDidSigner; exports.getEthereumAddressFromKey = getEthereumAddressFromKey; exports.getFirstKeyWithRelation = getFirstKeyWithRelation; exports.getFirstKeyWithRelationFromDIDDoc = getFirstKeyWithRelationFromDIDDoc; exports.getKey = getKey; exports.getKeys = getKeys; exports.getOrCreatePrimaryIdentifier = getOrCreatePrimaryIdentifier; exports.getPrimaryIdentifier = getPrimaryIdentifier; exports.getSupportedDIDMethods = getSupportedDIDMethods; exports.isEvenHexString = isEvenHexString; exports.jwkTtoPublicKeyHex = jwkTtoPublicKeyHex; exports.mapIdentifierKeysToDocWithJwkSupport = mapIdentifierKeysToDocWithJwkSupport; exports.signDidJWT = signDidJWT; exports.toDID = toDID; exports.toDIDs = toDIDs; exports.toDidDocument = toDidDocument; exports.toDidResolutionResult = toDidResolutionResult; exports.verificationMethodToJwk = verificationMethodToJwk;
721
752
  //# sourceMappingURL=index.cjs.map