@sphereon/ssi-sdk-ext.did-resolver-key 0.28.1-feature.esm.cjs.8 → 0.28.1-feature.oyd.cmsm.improv.16

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.
Files changed (54) hide show
  1. package/dist/drivers/bls12381g2.d.ts +8 -0
  2. package/dist/drivers/bls12381g2.d.ts.map +1 -0
  3. package/dist/drivers/bls12381g2.js +49 -0
  4. package/dist/drivers/bls12381g2.js.map +1 -0
  5. package/dist/drivers/ed25519.d.ts +8 -0
  6. package/dist/drivers/ed25519.d.ts.map +1 -0
  7. package/dist/drivers/ed25519.js +118 -0
  8. package/dist/drivers/ed25519.js.map +1 -0
  9. package/dist/drivers/jwk.jcs.d.ts +8 -0
  10. package/dist/drivers/jwk.jcs.d.ts.map +1 -0
  11. package/dist/drivers/jwk.jcs.js +23 -0
  12. package/dist/drivers/jwk.jcs.js.map +1 -0
  13. package/dist/drivers/secp256k1.d.ts +8 -0
  14. package/dist/drivers/secp256k1.d.ts.map +1 -0
  15. package/dist/drivers/secp256k1.js +49 -0
  16. package/dist/drivers/secp256k1.js.map +1 -0
  17. package/dist/drivers/secp256r1.d.ts +24 -0
  18. package/dist/drivers/secp256r1.d.ts.map +1 -0
  19. package/dist/drivers/secp256r1.js +99 -0
  20. package/dist/drivers/secp256r1.js.map +1 -0
  21. package/dist/drivers/secp384r1.d.ts +24 -0
  22. package/dist/drivers/secp384r1.d.ts.map +1 -0
  23. package/dist/drivers/secp384r1.js +99 -0
  24. package/dist/drivers/secp384r1.js.map +1 -0
  25. package/dist/drivers/secp521r1.d.ts +23 -0
  26. package/dist/drivers/secp521r1.d.ts.map +1 -0
  27. package/dist/drivers/secp521r1.js +87 -0
  28. package/dist/drivers/secp521r1.js.map +1 -0
  29. package/dist/index.d.ts +5 -18
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +87 -484
  32. package/dist/index.js.map +1 -1
  33. package/dist/types.d.ts +14 -0
  34. package/dist/types.d.ts.map +1 -0
  35. package/dist/types.js +6 -0
  36. package/dist/types.js.map +1 -0
  37. package/package.json +10 -22
  38. package/src/__tests__/__snapshots__/secp256r1.test.ts.snap +1 -249
  39. package/src/__tests__/__snapshots__/secp384r1.test.ts.snap +1 -249
  40. package/src/__tests__/__snapshots__/secp521r1.test.ts.snap +1 -280
  41. package/src/__tests__/key_resolver.test.ts +1 -2
  42. package/src/__tests__/secp256r1.test.ts +4 -4
  43. package/src/__tests__/secp384r1.test.ts +3 -3
  44. package/src/__tests__/secp521r1.test.ts +2 -3
  45. package/src/drivers/bls12381g2.ts +2 -3
  46. package/src/drivers/ed25519.ts +5 -7
  47. package/src/drivers/secp256k1.ts +2 -3
  48. package/src/drivers/secp256r1.ts +5 -5
  49. package/src/drivers/secp384r1.ts +2 -3
  50. package/src/drivers/secp521r1.ts +2 -3
  51. package/src/index.ts +0 -1
  52. package/dist/index.cjs +0 -520
  53. package/dist/index.cjs.map +0 -1
  54. package/dist/index.d.cts +0 -21
package/dist/index.cjs DELETED
@@ -1,520 +0,0 @@
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;
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
- DID_JSON: () => DID_JSON,
35
- DID_LD_JSON: () => DID_LD_JSON,
36
- default: () => index_default,
37
- getResolver: () => getResolver
38
- });
39
- module.exports = __toCommonJS(index_exports);
40
- var import_varint = require("varint");
41
- var import_base58 = require("multiformats/bases/base58");
42
-
43
- // src/drivers/ed25519.ts
44
- var import_to_string = require("uint8arrays/to-string");
45
- var import_ed25519 = require("@stablelib/ed25519");
46
-
47
- // src/types.ts
48
- var DID_LD_JSON = "application/did+ld+json";
49
- var DID_JSON = "application/did+json";
50
-
51
- // src/drivers/ed25519.ts
52
- function encodeKey(key, encodeKey2) {
53
- const bytes = new Uint8Array(key.length + 2);
54
- bytes[0] = encodeKey2 ?? 236;
55
- bytes[1] = 1;
56
- bytes.set(key, 2);
57
- return `z${(0, import_to_string.toString)(bytes, "base58btc")}`;
58
- }
59
- __name(encodeKey, "encodeKey");
60
- var keyToDidDoc = /* @__PURE__ */ __name((args) => {
61
- const { options } = args;
62
- if (!options?.publicKeyFormat) {
63
- return keyToDidDoc2020(args);
64
- }
65
- switch (options.publicKeyFormat) {
66
- case "Ed25519VerificationKey2018":
67
- case "X25519KeyAgreementKey2019":
68
- return keyToDidDoc2018_2019(args);
69
- case "Ed25519VerificationKey2020":
70
- case "X25519KeyAgreementKey2020":
71
- case "Multikey":
72
- return keyToDidDoc2020(args);
73
- default:
74
- throw Error(`${options.publicKeyFormat} not supported yet for the ed25519 driver`);
75
- }
76
- }, "keyToDidDoc");
77
- var keyToDidDoc2018_2019 = /* @__PURE__ */ __name(({ pubKeyBytes, fingerprint, contentType }) => {
78
- const did = `did:key:${fingerprint}`;
79
- const keyId = `${did}#${fingerprint}`;
80
- const x25519PubBytes = (0, import_ed25519.convertPublicKeyToX25519)(pubKeyBytes);
81
- const x25519KeyId = `${did}#${encodeKey(x25519PubBytes)}`;
82
- return {
83
- ...contentType === DID_LD_JSON && {
84
- "@context": [
85
- "https://www.w3.org/ns/did/v1",
86
- "https://w3id.org/security/suites/ed25519-2018/v1",
87
- "https://w3id.org/security/suites/x25519-2019/v1"
88
- ]
89
- },
90
- id: did,
91
- verificationMethod: [
92
- {
93
- id: keyId,
94
- type: "Ed25519VerificationKey2018",
95
- controller: did,
96
- publicKeyBase58: (0, import_to_string.toString)(pubKeyBytes, "base58btc")
97
- },
98
- {
99
- id: x25519KeyId,
100
- type: "X25519KeyAgreementKey2019",
101
- controller: did,
102
- publicKeyBase58: (0, import_to_string.toString)(x25519PubBytes, "base58btc")
103
- }
104
- ],
105
- authentication: [
106
- keyId
107
- ],
108
- assertionMethod: [
109
- keyId
110
- ],
111
- capabilityDelegation: [
112
- keyId
113
- ],
114
- capabilityInvocation: [
115
- keyId
116
- ],
117
- keyAgreement: [
118
- x25519KeyId
119
- ]
120
- };
121
- }, "keyToDidDoc2018_2019");
122
- var keyToDidDoc2020 = /* @__PURE__ */ __name(({ pubKeyBytes, fingerprint, contentType }) => {
123
- const did = `did:key:${fingerprint}`;
124
- const keyId = `${did}#${fingerprint}`;
125
- const x25519PubBytes = (0, import_ed25519.convertPublicKeyToX25519)(pubKeyBytes);
126
- const x25519KeyId = `${did}#${encodeKey(x25519PubBytes)}`;
127
- return {
128
- ...contentType === DID_LD_JSON && {
129
- "@context": [
130
- "https://www.w3.org/ns/did/v1",
131
- "https://w3id.org/security/suites/ed25519-2020/v1",
132
- "https://w3id.org/security/suites/x25519-2020/v1"
133
- ]
134
- },
135
- id: did,
136
- verificationMethod: [
137
- {
138
- id: keyId,
139
- type: "Ed25519VerificationKey2020",
140
- controller: did,
141
- publicKeyMultibase: encodeKey(pubKeyBytes, 237)
142
- }
143
- ],
144
- authentication: [
145
- keyId
146
- ],
147
- assertionMethod: [
148
- keyId
149
- ],
150
- capabilityDelegation: [
151
- keyId
152
- ],
153
- capabilityInvocation: [
154
- keyId
155
- ],
156
- keyAgreement: [
157
- {
158
- id: x25519KeyId,
159
- type: "X25519KeyAgreementKey2020",
160
- controller: did,
161
- publicKeyMultibase: encodeKey(x25519PubBytes, 236)
162
- }
163
- ]
164
- };
165
- }, "keyToDidDoc2020");
166
- var ed25519_default = {
167
- keyToDidDoc
168
- };
169
-
170
- // src/drivers/bls12381g2.ts
171
- var import_to_string2 = require("uint8arrays/to-string");
172
- var keyToDidDoc2 = /* @__PURE__ */ __name(({ pubKeyBytes, fingerprint }) => {
173
- const did = `did:key:${fingerprint}`;
174
- const keyId = `${did}#${fingerprint}`;
175
- return {
176
- id: did,
177
- verificationMethod: [
178
- {
179
- id: keyId,
180
- type: "Bls12381G2Key2020",
181
- controller: did,
182
- publicKeyBase58: (0, import_to_string2.toString)(pubKeyBytes, "base58btc")
183
- }
184
- ],
185
- authentication: [
186
- keyId
187
- ],
188
- assertionMethod: [
189
- keyId
190
- ],
191
- capabilityDelegation: [
192
- keyId
193
- ],
194
- capabilityInvocation: [
195
- keyId
196
- ]
197
- };
198
- }, "keyToDidDoc");
199
- var bls12381g2_default = {
200
- keyToDidDoc: keyToDidDoc2
201
- };
202
-
203
- // src/drivers/secp256k1.ts
204
- var import_to_string3 = require("uint8arrays/to-string");
205
- var keyToDidDoc3 = /* @__PURE__ */ __name(({ pubKeyBytes, fingerprint }) => {
206
- const did = `did:key:${fingerprint}`;
207
- const keyId = `${did}#${fingerprint}`;
208
- return {
209
- id: did,
210
- verificationMethod: [
211
- {
212
- id: keyId,
213
- type: "Secp256k1VerificationKey2018",
214
- controller: did,
215
- publicKeyBase58: (0, import_to_string3.toString)(pubKeyBytes, "base58btc")
216
- }
217
- ],
218
- authentication: [
219
- keyId
220
- ],
221
- assertionMethod: [
222
- keyId
223
- ],
224
- capabilityDelegation: [
225
- keyId
226
- ],
227
- capabilityInvocation: [
228
- keyId
229
- ]
230
- };
231
- }, "keyToDidDoc");
232
- var secp256k1_default = {
233
- keyToDidDoc: keyToDidDoc3
234
- };
235
-
236
- // src/drivers/secp256r1.ts
237
- var nist_weierstrauss = __toESM(require("nist-weierstrauss"), 1);
238
- var import_from_string = require("uint8arrays/from-string");
239
- function keyToDidDoc4({ pubKeyBytes, fingerprint }) {
240
- const did = `did:key:${fingerprint}`;
241
- const keyId = `${did}#${fingerprint}`;
242
- const key = pubKeyBytesToXY(pubKeyBytes);
243
- return {
244
- id: did,
245
- verificationMethod: [
246
- {
247
- id: keyId,
248
- type: "JsonWebKey2020",
249
- controller: did,
250
- publicKeyJwk: {
251
- kty: "EC",
252
- crv: "P-256",
253
- x: key.xm,
254
- y: key.ym
255
- }
256
- }
257
- ],
258
- authentication: [
259
- keyId
260
- ],
261
- assertionMethod: [
262
- keyId
263
- ],
264
- capabilityDelegation: [
265
- keyId
266
- ],
267
- capabilityInvocation: [
268
- keyId
269
- ]
270
- };
271
- }
272
- __name(keyToDidDoc4, "keyToDidDoc");
273
- function pubKeyBytesToXY(pubKeyBytes) {
274
- if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {
275
- throw new TypeError("input must be a Uint8Array");
276
- }
277
- const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes);
278
- const bytesCount = publicKeyHex.length / 2;
279
- if (bytesCount == 64) {
280
- return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKeyHex);
281
- }
282
- if (bytesCount == 65) {
283
- if (publicKeyHex.slice(0, 2) == "04") {
284
- const publicKey = publicKeyHex.slice(2);
285
- return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKey);
286
- }
287
- }
288
- if (bytesCount == 33) {
289
- if (publicKeyHex.slice(0, 2) == "03" || publicKeyHex.slice(0, 2) == "02") {
290
- const publicKey = (0, import_from_string.fromString)(publicKeyHex, "base16");
291
- const point = nist_weierstrauss.secp256r1.ECPointDecompress(publicKey);
292
- return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point);
293
- }
294
- }
295
- throw new Error("Unexpected pubKeyBytes");
296
- }
297
- __name(pubKeyBytesToXY, "pubKeyBytesToXY");
298
- var secp256r1_default = {
299
- keyToDidDoc: keyToDidDoc4
300
- };
301
-
302
- // src/drivers/secp384r1.ts
303
- var import_from_string2 = require("uint8arrays/from-string");
304
- var nist_weierstrauss2 = __toESM(require("nist-weierstrauss"), 1);
305
- function keyToDidDoc5({ pubKeyBytes, fingerprint }) {
306
- const did = `did:key:${fingerprint}`;
307
- const keyId = `${did}#${fingerprint}`;
308
- const key = pubKeyBytesToXY2(pubKeyBytes);
309
- return {
310
- id: did,
311
- verificationMethod: [
312
- {
313
- id: keyId,
314
- type: "JsonWebKey2020",
315
- controller: did,
316
- publicKeyJwk: {
317
- kty: "EC",
318
- crv: "P-384",
319
- x: key.xm,
320
- y: key.ym
321
- }
322
- }
323
- ],
324
- authentication: [
325
- keyId
326
- ],
327
- assertionMethod: [
328
- keyId
329
- ],
330
- capabilityDelegation: [
331
- keyId
332
- ],
333
- capabilityInvocation: [
334
- keyId
335
- ]
336
- };
337
- }
338
- __name(keyToDidDoc5, "keyToDidDoc");
339
- function pubKeyBytesToXY2(pubKeyBytes) {
340
- if (!nist_weierstrauss2.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {
341
- throw new TypeError("input must be a Uint8Array");
342
- }
343
- const publicKeyHex = nist_weierstrauss2.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes);
344
- const bytesCount = publicKeyHex.length / 2;
345
- if (bytesCount == 96) {
346
- return nist_weierstrauss2.nist_weierstrauss_common.publicKeyToXY(publicKeyHex);
347
- }
348
- if (bytesCount == 97) {
349
- if (publicKeyHex.slice(0, 2) == "04") {
350
- const publicKey = publicKeyHex.slice(2);
351
- return nist_weierstrauss2.nist_weierstrauss_common.publicKeyToXY(publicKey);
352
- }
353
- }
354
- if (bytesCount == 49) {
355
- if (publicKeyHex.slice(0, 2) == "03" || publicKeyHex.slice(0, 2) == "02") {
356
- const publicKey = (0, import_from_string2.fromString)(publicKeyHex, "base16");
357
- const point = nist_weierstrauss2.secp384r1.ECPointDecompress(publicKey);
358
- return nist_weierstrauss2.nist_weierstrauss_common.publicKeyIntToXY(point);
359
- }
360
- }
361
- throw new Error("Unexpected pubKeyBytes");
362
- }
363
- __name(pubKeyBytesToXY2, "pubKeyBytesToXY");
364
- var secp384r1_default = {
365
- keyToDidDoc: keyToDidDoc5
366
- };
367
-
368
- // src/drivers/secp521r1.ts
369
- var import_from_string3 = require("uint8arrays/from-string");
370
- var nist_weierstrauss3 = __toESM(require("nist-weierstrauss"), 1);
371
- function keyToDidDoc6({ pubKeyBytes, fingerprint }) {
372
- const did = `did:key:${fingerprint}`;
373
- const keyId = `${did}#${fingerprint}`;
374
- const key = pubKeyBytesToXY3(pubKeyBytes);
375
- return {
376
- id: did,
377
- verificationMethod: [
378
- {
379
- id: keyId,
380
- type: "JsonWebKey2020",
381
- controller: did,
382
- publicKeyJwk: {
383
- kty: "EC",
384
- crv: "P-521",
385
- x: key.xm,
386
- y: key.ym
387
- }
388
- }
389
- ],
390
- authentication: [
391
- keyId
392
- ],
393
- assertionMethod: [
394
- keyId
395
- ],
396
- capabilityDelegation: [
397
- keyId
398
- ],
399
- capabilityInvocation: [
400
- keyId
401
- ]
402
- };
403
- }
404
- __name(keyToDidDoc6, "keyToDidDoc");
405
- function pubKeyBytesToXY3(pubKeyBytes) {
406
- if (!nist_weierstrauss3.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {
407
- throw new TypeError("input must be a Uint8Array");
408
- }
409
- const publicKeyHex = nist_weierstrauss3.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes);
410
- if (132 <= publicKeyHex.length && publicKeyHex.length <= 134) {
411
- if (publicKeyHex.slice(0, 2) == "03" || publicKeyHex.slice(0, 2) == "02") {
412
- const publicKey = (0, import_from_string3.fromString)(publicKeyHex, "base16");
413
- const point = nist_weierstrauss3.secp521r1.ECPointDecompress(publicKey);
414
- return nist_weierstrauss3.nist_weierstrauss_common.publicKeyIntToXY(point);
415
- }
416
- }
417
- throw new Error("Unexpected pubKeyBytes");
418
- }
419
- __name(pubKeyBytesToXY3, "pubKeyBytesToXY");
420
- var secp521r1_default = {
421
- keyToDidDoc: keyToDidDoc6
422
- };
423
-
424
- // src/drivers/jwk.jcs.ts
425
- var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.key-utils");
426
- var keyToDidDoc7 = /* @__PURE__ */ __name(({ pubKeyBytes, fingerprint, contentType }) => {
427
- const did = `did:key:${fingerprint}`;
428
- const keyId = `${did}#${fingerprint}`;
429
- const publicKeyJwk = (0, import_ssi_sdk_ext.jwkJcsDecode)(pubKeyBytes);
430
- return {
431
- ...contentType === DID_LD_JSON && {
432
- "@context": [
433
- "https://www.w3.org/ns/did/v1",
434
- "https://w3id.org/security/suites/jws-2020/v1"
435
- ]
436
- },
437
- id: did,
438
- verificationMethod: [
439
- {
440
- id: keyId,
441
- type: "JsonWebKey2020",
442
- controller: did,
443
- publicKeyJwk
444
- }
445
- ],
446
- authentication: [
447
- keyId
448
- ],
449
- assertionMethod: [
450
- keyId
451
- ],
452
- capabilityDelegation: [
453
- keyId
454
- ],
455
- capabilityInvocation: [
456
- keyId
457
- ]
458
- };
459
- }, "keyToDidDoc");
460
- var jwk_jcs_default = {
461
- keyToDidDoc: keyToDidDoc7
462
- };
463
-
464
- // src/index.ts
465
- var prefixToDriverMap = {
466
- 231: secp256k1_default,
467
- 237: ed25519_default,
468
- 4608: secp256r1_default,
469
- 4609: secp384r1_default,
470
- 4610: secp521r1_default,
471
- 235: bls12381g2_default,
472
- 60241: jwk_jcs_default
473
- };
474
- var getResolver = /* @__PURE__ */ __name(() => {
475
- return {
476
- key: /* @__PURE__ */ __name(async (did, parsed, r, options) => {
477
- const contentType = options.accept || DID_LD_JSON;
478
- const response = {
479
- didResolutionMetadata: {
480
- contentType
481
- },
482
- didDocument: null,
483
- didDocumentMetadata: {}
484
- };
485
- try {
486
- const multicodecPubKey = import_base58.base58btc.decode(parsed.id);
487
- const keyType = (0, import_varint.decode)(multicodecPubKey);
488
- const pubKeyBytes = multicodecPubKey.slice(import_varint.decode.bytes);
489
- const args = {
490
- pubKeyBytes,
491
- fingerprint: parsed.id,
492
- contentType,
493
- options
494
- };
495
- const doc = await prefixToDriverMap[keyType].keyToDidDoc(args);
496
- if (contentType === DID_LD_JSON) {
497
- if (!doc["@context"]) {
498
- doc["@context"] = "https://w3id.org/did/v1";
499
- } else if (Array.isArray(doc["@context"]) && !doc["@context"].includes("https://w3id.org/did/v1") && !doc["@context"].includes("https://www.w3.org/ns/did/v1")) {
500
- doc["@context"].push("https://w3id.org/did/v1");
501
- }
502
- response.didDocument = doc;
503
- } else if (contentType === DID_JSON) {
504
- response.didDocument = doc;
505
- } else {
506
- delete response.didResolutionMetadata.contentType;
507
- response.didResolutionMetadata.error = "representationNotSupported";
508
- }
509
- } catch (e) {
510
- response.didResolutionMetadata.error = "invalidDid";
511
- response.didResolutionMetadata.message = e.toString();
512
- }
513
- return response;
514
- }, "key")
515
- };
516
- }, "getResolver");
517
- var index_default = {
518
- getResolver
519
- };
520
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/drivers/ed25519.ts","../src/types.ts","../src/drivers/bls12381g2.ts","../src/drivers/secp256k1.ts","../src/drivers/secp256r1.ts","../src/drivers/secp384r1.ts","../src/drivers/secp521r1.ts","../src/drivers/jwk.jcs.ts"],"sourcesContent":["import { decode } from 'varint'\n// @ts-ignore\nimport { base58btc } from 'multiformats/bases/base58'\nimport ed25519 from './drivers/ed25519'\nimport bls12381g2 from './drivers/bls12381g2'\nimport secp256k1 from './drivers/secp256k1'\nimport secp256r1 from './drivers/secp256r1'\nimport secp384r1 from './drivers/secp384r1'\nimport secp521r1 from './drivers/secp521r1'\nimport { DIDResolutionResult, ParsedDID, Resolvable, ResolverRegistry } from 'did-resolver'\nimport jwkJcs from './drivers/jwk.jcs'\nimport { DID_JSON, DID_LD_JSON, DIDKeyResolutionOptions, KeyToDidDocArgs } from './types'\n\nexport * from './types'\n\nconst prefixToDriverMap: any = {\n 0xe7: secp256k1,\n 0xed: ed25519,\n 0x1200: secp256r1,\n 0x1201: secp384r1,\n 0x1202: secp521r1,\n 0xeb: bls12381g2,\n 0xeb51: jwkJcs,\n}\n\nexport const getResolver = (): ResolverRegistry => {\n return {\n key: async (did: string, parsed: ParsedDID, r: Resolvable, options: DIDKeyResolutionOptions) => {\n const contentType = options.accept || DID_LD_JSON\n const response: DIDResolutionResult = {\n didResolutionMetadata: { contentType },\n didDocument: null,\n didDocumentMetadata: {},\n }\n try {\n const multicodecPubKey = base58btc.decode(parsed.id)\n const keyType = decode(multicodecPubKey)\n const pubKeyBytes = multicodecPubKey.slice(decode.bytes)\n const args: KeyToDidDocArgs = { pubKeyBytes, fingerprint: parsed.id, contentType, options }\n const doc = await prefixToDriverMap[keyType].keyToDidDoc(args)\n if (contentType === DID_LD_JSON) {\n if (!doc['@context']) {\n doc['@context'] = 'https://w3id.org/did/v1'\n } else if (\n Array.isArray(doc['@context']) &&\n !doc['@context'].includes('https://w3id.org/did/v1') &&\n !doc['@context'].includes('https://www.w3.org/ns/did/v1')\n ) {\n doc['@context'].push('https://w3id.org/did/v1')\n }\n response.didDocument = doc\n } else if (contentType === DID_JSON) {\n response.didDocument = doc\n } else {\n delete response.didResolutionMetadata.contentType\n response.didResolutionMetadata.error = 'representationNotSupported'\n }\n } catch (e: any) {\n response.didResolutionMetadata.error = 'invalidDid'\n response.didResolutionMetadata.message = e.toString()\n }\n return response\n },\n }\n}\nexport default { getResolver }\n","\n// @ts-ignore\nimport { toString } from 'uint8arrays/to-string'\nimport { DIDDocument } from 'did-resolver'\n// import { edwardsToMontgomery } from '@noble/curves/ed25519'\nimport { convertPublicKeyToX25519 } from '@stablelib/ed25519'\nimport { DID_LD_JSON, KeyToDidDocArgs } from '../types'\n\nfunction encodeKey(key: Uint8Array, encodeKey?: number) {\n const bytes = new Uint8Array(key.length + 2)\n bytes[0] = encodeKey ?? 0xec\n // The multicodec is encoded as a varint so we need to add this.\n // See js-multicodec for a general implementation\n bytes[1] = 0x01\n bytes.set(key, 2)\n return `z${toString(bytes, 'base58btc')}`\n}\n\nexport const keyToDidDoc = (args: KeyToDidDocArgs) => {\n const { options } = args\n if (!options?.publicKeyFormat) {\n return keyToDidDoc2020(args)\n }\n switch (options.publicKeyFormat) {\n case 'Ed25519VerificationKey2018':\n case 'X25519KeyAgreementKey2019':\n return keyToDidDoc2018_2019(args)\n case 'Ed25519VerificationKey2020':\n case 'X25519KeyAgreementKey2020':\n case 'Multikey':\n return keyToDidDoc2020(args)\n default:\n throw Error(`${options.publicKeyFormat} not supported yet for the ed25519 driver`)\n }\n}\nconst keyToDidDoc2018_2019 = ({ pubKeyBytes, fingerprint, contentType }: KeyToDidDocArgs): DIDDocument => {\n const did = `did:key:${fingerprint}`\n const keyId = `${did}#${fingerprint}`\n\n //todo: Move to noble lib. x25519 values differ between below methods. Current implementation is correct according to DID:key spec\n // const pubKeyHex = toString(pubKeyBytes, 'base16')\n // const x25519PubBytes = edwardsToMontgomery(pubKeyHex)\n const x25519PubBytes = convertPublicKeyToX25519(pubKeyBytes)\n\n const x25519KeyId = `${did}#${encodeKey(x25519PubBytes)}`\n return {\n ...(contentType === DID_LD_JSON && {\n '@context': [\n 'https://www.w3.org/ns/did/v1',\n 'https://w3id.org/security/suites/ed25519-2018/v1',\n 'https://w3id.org/security/suites/x25519-2019/v1',\n ],\n }),\n id: did,\n verificationMethod: [\n {\n id: keyId,\n type: 'Ed25519VerificationKey2018',\n controller: did,\n publicKeyBase58: toString(pubKeyBytes, 'base58btc'),\n },\n {\n id: x25519KeyId,\n type: 'X25519KeyAgreementKey2019',\n controller: did,\n publicKeyBase58: toString(x25519PubBytes, 'base58btc'),\n },\n ],\n authentication: [keyId],\n assertionMethod: [keyId],\n capabilityDelegation: [keyId],\n capabilityInvocation: [keyId],\n keyAgreement: [x25519KeyId],\n }\n}\n\nconst keyToDidDoc2020 = ({ pubKeyBytes, fingerprint, contentType }: KeyToDidDocArgs): DIDDocument => {\n const did = `did:key:${fingerprint}`\n const keyId = `${did}#${fingerprint}`\n //todo: Move to noble lib. x25519 values differ between below methods. Current implementation is correct according to DID:key spec\n // const pubKeyHex = u8a.toString(pubKeyBytes, 'base16')\n // const x25519PubBytes = edwardsToMontgomery(pubKeyBytes)\n const x25519PubBytes = convertPublicKeyToX25519(pubKeyBytes)\n\n const x25519KeyId = `${did}#${encodeKey(x25519PubBytes)}`\n return {\n ...(contentType === DID_LD_JSON && {\n '@context': [\n 'https://www.w3.org/ns/did/v1',\n 'https://w3id.org/security/suites/ed25519-2020/v1',\n 'https://w3id.org/security/suites/x25519-2020/v1',\n ],\n }),\n id: did,\n verificationMethod: [\n {\n id: keyId,\n type: 'Ed25519VerificationKey2020',\n controller: did,\n publicKeyMultibase: encodeKey(pubKeyBytes, 0xed),\n },\n ],\n authentication: [keyId],\n assertionMethod: [keyId],\n capabilityDelegation: [keyId],\n capabilityInvocation: [keyId],\n keyAgreement: [\n {\n id: x25519KeyId,\n type: 'X25519KeyAgreementKey2020',\n controller: did,\n publicKeyMultibase: encodeKey(x25519PubBytes, 0xec),\n },\n ],\n }\n}\nexport default { keyToDidDoc }\n","import { DIDResolutionOptions } from 'did-resolver'\n\nexport const DID_LD_JSON = 'application/did+ld+json'\nexport const DID_JSON = 'application/did+json'\n\nexport type PublicKeyFormat =\n | 'JsonWebKey2020'\n | 'Ed25519VerificationKey2018'\n | 'X25519KeyAgreementKey2019'\n | 'Ed25519VerificationKey2020'\n | 'X25519KeyAgreementKey2020'\n | 'Multikey'\nexport interface KeyToDidDocArgs {\n pubKeyBytes: Uint8Array\n fingerprint: string\n contentType?: string\n options?: DIDKeyResolutionOptions\n}\n\nexport interface DIDKeyResolutionOptions extends DIDResolutionOptions {\n publicKeyFormat?: PublicKeyFormat\n}\n","import { DIDDocument } from 'did-resolver'\n// @ts-ignore\nimport { toString } from 'uint8arrays/to-string'\nimport { KeyToDidDocArgs } from '../index'\n\nexport const keyToDidDoc = ({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): DIDDocument => {\n const did = `did:key:${fingerprint}`\n const keyId = `${did}#${fingerprint}`\n return {\n id: did,\n verificationMethod: [\n {\n id: keyId,\n type: 'Bls12381G2Key2020',\n controller: did,\n publicKeyBase58: toString(pubKeyBytes, 'base58btc'),\n },\n ],\n authentication: [keyId],\n assertionMethod: [keyId],\n capabilityDelegation: [keyId],\n capabilityInvocation: [keyId],\n }\n}\nexport default { keyToDidDoc }\n","// @ts-ignore\nimport { toString } from 'uint8arrays/to-string'\nimport { DIDDocument } from 'did-resolver'\nimport { KeyToDidDocArgs } from '../types'\n\nexport const keyToDidDoc = ({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): DIDDocument => {\n const did = `did:key:${fingerprint}`\n const keyId = `${did}#${fingerprint}`\n return {\n id: did,\n verificationMethod: [\n {\n id: keyId,\n type: 'Secp256k1VerificationKey2018',\n controller: did,\n publicKeyBase58: toString(pubKeyBytes, 'base58btc'),\n },\n ],\n authentication: [keyId],\n assertionMethod: [keyId],\n capabilityDelegation: [keyId],\n capabilityInvocation: [keyId],\n }\n}\n\nexport default { keyToDidDoc }\n","// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.\n\nimport * as nist_weierstrauss from 'nist-weierstrauss'\nimport {base64urlPoint} from 'nist-weierstrauss'\n// @ts-ignore\nimport {fromString} from 'uint8arrays/from-string'\nimport {KeyToDidDocArgs} from '../types'\n\n/**\n * Constructs the document based on the method key\n */\nexport function keyToDidDoc({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): any {\n const did = `did:key:${fingerprint}`\n const keyId = `${did}#${fingerprint}`\n const key = pubKeyBytesToXY(pubKeyBytes)\n return {\n id: did,\n verificationMethod: [\n {\n id: keyId,\n type: 'JsonWebKey2020',\n controller: did,\n publicKeyJwk: {\n kty: 'EC',\n crv: 'P-256',\n x: key.xm,\n y: key.ym,\n },\n },\n ],\n authentication: [keyId],\n assertionMethod: [keyId],\n capabilityDelegation: [keyId],\n capabilityInvocation: [keyId],\n }\n}\n\n/**\n *\n * @param pubKeyBytes - public key as uncompressed byte array with no prefix (raw key),\n * uncompressed with 0x04 prefix, or compressed with 0x02 prefix if even and 0x03 prefix if odd.\n * @returns point x,y with coordinates as multibase encoded base64urls\n *\n * See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-256.\n * At present only raw p-256 keys are covered in the specification.\n * @throws TypeError: input cannot be null or undefined.\n * @throws Error: Unexpected pubKeyBytes\n * @internal\n */\nexport function pubKeyBytesToXY(pubKeyBytes: Uint8Array): base64urlPoint {\n if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {\n throw new TypeError('input must be a Uint8Array')\n }\n const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes)\n const bytesCount = publicKeyHex.length / 2\n\n // raw p-256 key\n if (bytesCount == 64) {\n return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKeyHex)\n }\n\n // uncompressed p-256 key, SEC format\n if (bytesCount == 65) {\n if (publicKeyHex.slice(0, 2) == '04') {\n const publicKey = publicKeyHex.slice(2)\n return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKey)\n }\n }\n\n // compressed p-256 key, SEC format\n if (bytesCount == 33) {\n if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {\n const publicKey = fromString(publicKeyHex, 'base16')\n const point = nist_weierstrauss.secp256r1.ECPointDecompress(publicKey)\n return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point)\n }\n }\n\n throw new Error('Unexpected pubKeyBytes')\n}\n\nexport default { keyToDidDoc }\n","// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.\n\n// @ts-ignore\nimport { fromString } from 'uint8arrays/from-string'\n\nimport * as nist_weierstrauss from 'nist-weierstrauss'\nimport { base64urlPoint } from 'nist-weierstrauss'\nimport { KeyToDidDocArgs } from '../types'\n\n/**\n * Constructs the document based on the method key\n */\nexport function keyToDidDoc({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): any {\n const did = `did:key:${fingerprint}`\n const keyId = `${did}#${fingerprint}`\n const key = pubKeyBytesToXY(pubKeyBytes)\n return {\n id: did,\n verificationMethod: [\n {\n id: keyId,\n type: 'JsonWebKey2020',\n controller: did,\n publicKeyJwk: {\n kty: 'EC',\n crv: 'P-384',\n x: key.xm,\n y: key.ym,\n },\n },\n ],\n authentication: [keyId],\n assertionMethod: [keyId],\n capabilityDelegation: [keyId],\n capabilityInvocation: [keyId],\n }\n}\n\n/**\n *\n * @param pubKeyBytes - public key as uncompressed byte array with no prefix (raw key),\n * uncompressed with 0x04 prefix, or compressed with 0x02 prefix if even and 0x03 prefix if odd.\n * @returns point x,y with coordinates as multibase encoded base64urls\n *\n * See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-384.\n * At present only raw p-384 keys are covered in the specification.\n * @throws TypeError: input cannot be null or undefined.\n * @throws Error: Unexpected pubKeyBytes\n * @internal\n */\nexport function pubKeyBytesToXY(pubKeyBytes: Uint8Array): base64urlPoint {\n if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {\n throw new TypeError('input must be a Uint8Array')\n }\n const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes)\n const bytesCount = publicKeyHex.length / 2\n\n // raw p-384 key\n if (bytesCount == 96) {\n return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKeyHex)\n }\n\n // uncompressed p-384 key, SEC format\n if (bytesCount == 97) {\n if (publicKeyHex.slice(0, 2) == '04') {\n const publicKey = publicKeyHex.slice(2)\n return nist_weierstrauss.nist_weierstrauss_common.publicKeyToXY(publicKey)\n }\n }\n\n // compressed p-384 key, SEC format\n if (bytesCount == 49) {\n if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {\n const publicKey = fromString(publicKeyHex, 'base16')\n const point = nist_weierstrauss.secp384r1.ECPointDecompress(publicKey)\n return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point)\n }\n }\n\n throw new Error('Unexpected pubKeyBytes')\n}\n\nexport default { keyToDidDoc }\n","// Brent Shambaugh <brent.shambaugh@gmail.com>. 2021.\n\n// @ts-ignore\nimport { fromString } from 'uint8arrays/from-string'\n\nimport * as nist_weierstrauss from 'nist-weierstrauss'\nimport { base64urlPoint } from 'nist-weierstrauss'\nimport { KeyToDidDocArgs } from '../types'\n\n/**\n * Constructs the document based on the method key\n */\nexport function keyToDidDoc({ pubKeyBytes, fingerprint }: KeyToDidDocArgs): any {\n const did = `did:key:${fingerprint}`\n const keyId = `${did}#${fingerprint}`\n const key = pubKeyBytesToXY(pubKeyBytes)\n return {\n id: did,\n verificationMethod: [\n {\n id: keyId,\n type: 'JsonWebKey2020',\n controller: did,\n publicKeyJwk: {\n kty: 'EC',\n crv: 'P-521',\n x: key.xm,\n y: key.ym,\n },\n },\n ],\n authentication: [keyId],\n assertionMethod: [keyId],\n capabilityDelegation: [keyId],\n capabilityInvocation: [keyId],\n }\n}\n\n/**\n *\n * @param pubKeyBytes - public key as compressed with 0x02 prefix if even and 0x03 prefix if odd.\n * @returns point x,y with coordinates as multibase encoded base64urls\n *\n * See the the did:key specification: https://w3c-ccg.github.io/did-method-key/#p-521.\n * For compression see: https://tools.ietf.org/id/draft-jivsov-ecc-compact-05.html#rfc.section.3\n * @throws TypeError: input cannot be null or undefined.\n * @throws Error: Unexpected pubKeyBytes\n * @internal\n */\nexport function pubKeyBytesToXY(pubKeyBytes: Uint8Array): base64urlPoint {\n if (!nist_weierstrauss.nist_weierstrauss_common.testUint8Array(pubKeyBytes)) {\n throw new TypeError('input must be a Uint8Array')\n }\n const publicKeyHex = nist_weierstrauss.nist_weierstrauss_common.pubKeyBytesToHex(pubKeyBytes)\n\n // compressed p-521 key, SEC format\n // publicKeyHex.length / 2.0 = 67.0 bytes\n if (132 <= publicKeyHex.length && publicKeyHex.length <= 134) {\n if (publicKeyHex.slice(0, 2) == '03' || publicKeyHex.slice(0, 2) == '02') {\n const publicKey = fromString(publicKeyHex, 'base16')\n const point = nist_weierstrauss.secp521r1.ECPointDecompress(publicKey)\n return nist_weierstrauss.nist_weierstrauss_common.publicKeyIntToXY(point)\n }\n }\n\n throw new Error('Unexpected pubKeyBytes')\n}\n\nexport default { keyToDidDoc }\n","import { DIDDocument, JsonWebKey as DIFJWK } from 'did-resolver'\nimport { DID_LD_JSON, KeyToDidDocArgs } from '../index'\nimport { jwkJcsDecode } from '@sphereon/ssi-sdk-ext.key-utils'\n\nexport const keyToDidDoc = ({ pubKeyBytes, fingerprint, contentType }: KeyToDidDocArgs): DIDDocument => {\n const did = `did:key:${fingerprint}`\n const keyId = `${did}#${fingerprint}`\n const publicKeyJwk = jwkJcsDecode(pubKeyBytes) as DIFJWK\n return {\n ...(contentType === DID_LD_JSON && {\n '@context': ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/suites/jws-2020/v1'],\n }),\n id: did,\n verificationMethod: [\n {\n id: keyId,\n type: 'JsonWebKey2020',\n controller: did,\n publicKeyJwk,\n },\n ],\n authentication: [keyId],\n assertionMethod: [keyId],\n capabilityDelegation: [keyId],\n capabilityInvocation: [keyId],\n }\n}\nexport default { keyToDidDoc }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AAAA,oBAAuB;AAEvB,oBAA0B;;;ACA1B,uBAAyB;AAGzB,qBAAyC;;;ACHlC,IAAMA,cAAc;AACpB,IAAMC,WAAW;;;ADKxB,SAASC,UAA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;MACxB;AACA,UAAI;AACF,cAAMC,mBAAmBC,wBAAUC,OAAOZ,OAAOa,EAAE;AACnD,cAAMC,cAAUF,sBAAOF,gBAAAA;AACvB,cAAMK,cAAcL,iBAAiBM,MAAMJ,qBAAOK,KAAK;AACvD,cAAMC,OAAwB;UAAEH;UAAaI,aAAanB,OAAOa;UAAIV;UAAaD;QAAQ;AAC1F,cAAMkB,MAAM,MAAM/B,kBAAkByB,OAAAA,EAASO,YAAYH,IAAAA;AACzD,YAAIf,gBAAgBE,aAAa;AAC/B,cAAI,CAACe,IAAI,UAAA,GAAa;AACpBA,gBAAI,UAAA,IAAc;UACpB,WACEE,MAAMC,QAAQH,IAAI,UAAA,CAAW,KAC7B,CAACA,IAAI,UAAA,EAAYI,SAAS,yBAAA,KAC1B,CAACJ,IAAI,UAAA,EAAYI,SAAS,8BAAA,GAC1B;AACAJ,gBAAI,UAAA,EAAYK,KAAK,yBAAA;UACvB;AACAnB,mBAASE,cAAcY;QACzB,WAAWjB,gBAAgBuB,UAAU;AACnCpB,mBAASE,cAAcY;QACzB,OAAO;AACL,iBAAOd,SAASC,sBAAsBJ;AACtCG,mBAASC,sBAAsBoB,QAAQ;QACzC;MACF,SAASC,GAAQ;AACftB,iBAASC,sBAAsBoB,QAAQ;AACvCrB,iBAASC,sBAAsBsB,UAAUD,EAAEE,SAAQ;MACrD;AACA,aAAOxB;IACT,GAnCK;EAoCP;AACF,GAvC2B;AAwC3B,IAAA,gBAAe;EAAET;AAAY;","names":["DID_LD_JSON","DID_JSON","encodeKey","key","bytes","Uint8Array","length","set","toString","keyToDidDoc","args","options","publicKeyFormat","keyToDidDoc2020","keyToDidDoc2018_2019","Error","pubKeyBytes","fingerprint","contentType","did","keyId","x25519PubBytes","convertPublicKeyToX25519","x25519KeyId","DID_LD_JSON","id","verificationMethod","type","controller","publicKeyBase58","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","keyAgreement","publicKeyMultibase","import_to_string","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","id","verificationMethod","type","controller","publicKeyBase58","toString","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","import_to_string","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","id","verificationMethod","type","controller","publicKeyBase58","toString","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","key","pubKeyBytesToXY","id","verificationMethod","type","controller","publicKeyJwk","kty","crv","x","xm","y","ym","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","nist_weierstrauss_common","testUint8Array","TypeError","publicKeyHex","pubKeyBytesToHex","bytesCount","length","publicKeyToXY","slice","publicKey","fromString","point","secp256r1","ECPointDecompress","publicKeyIntToXY","Error","import_from_string","nist_weierstrauss","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","key","pubKeyBytesToXY","id","verificationMethod","type","controller","publicKeyJwk","kty","crv","x","xm","y","ym","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","nist_weierstrauss_common","testUint8Array","TypeError","publicKeyHex","pubKeyBytesToHex","bytesCount","length","publicKeyToXY","slice","publicKey","fromString","point","secp384r1","ECPointDecompress","publicKeyIntToXY","Error","import_from_string","nist_weierstrauss","keyToDidDoc","pubKeyBytes","fingerprint","did","keyId","key","pubKeyBytesToXY","id","verificationMethod","type","controller","publicKeyJwk","kty","crv","x","xm","y","ym","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","nist_weierstrauss_common","testUint8Array","TypeError","publicKeyHex","pubKeyBytesToHex","length","slice","publicKey","fromString","point","secp521r1","ECPointDecompress","publicKeyIntToXY","Error","keyToDidDoc","pubKeyBytes","fingerprint","contentType","did","keyId","publicKeyJwk","jwkJcsDecode","DID_LD_JSON","id","verificationMethod","type","controller","authentication","assertionMethod","capabilityDelegation","capabilityInvocation","prefixToDriverMap","secp256k1","ed25519","secp256r1","secp384r1","secp521r1","bls12381g2","jwkJcs","getResolver","key","did","parsed","r","options","contentType","accept","DID_LD_JSON","response","didResolutionMetadata","didDocument","didDocumentMetadata","multicodecPubKey","base58btc","decode","id","keyType","pubKeyBytes","slice","bytes","args","fingerprint","doc","keyToDidDoc","Array","isArray","includes","push","DID_JSON","error","e","message","toString"]}
package/dist/index.d.cts DELETED
@@ -1,21 +0,0 @@
1
- import { DIDResolutionOptions, ResolverRegistry } from 'did-resolver';
2
-
3
- declare const DID_LD_JSON = "application/did+ld+json";
4
- declare const DID_JSON = "application/did+json";
5
- type PublicKeyFormat = 'JsonWebKey2020' | 'Ed25519VerificationKey2018' | 'X25519KeyAgreementKey2019' | 'Ed25519VerificationKey2020' | 'X25519KeyAgreementKey2020' | 'Multikey';
6
- interface KeyToDidDocArgs {
7
- pubKeyBytes: Uint8Array;
8
- fingerprint: string;
9
- contentType?: string;
10
- options?: DIDKeyResolutionOptions;
11
- }
12
- interface DIDKeyResolutionOptions extends DIDResolutionOptions {
13
- publicKeyFormat?: PublicKeyFormat;
14
- }
15
-
16
- declare const getResolver: () => ResolverRegistry;
17
- declare const _default: {
18
- getResolver: () => ResolverRegistry;
19
- };
20
-
21
- export { type DIDKeyResolutionOptions, DID_JSON, DID_LD_JSON, type KeyToDidDocArgs, type PublicKeyFormat, _default as default, getResolver };