@learncard/react 2.3.2 → 2.3.6

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 (27) hide show
  1. package/dist/cjs/{LearnCardCreditCardBackFace-f1b96ce5.js → LearnCardCreditCardBackFace-ecb49e43.js} +5 -3
  2. package/dist/cjs/LearnCardCreditCardBackFace-ecb49e43.js.map +1 -0
  3. package/dist/cjs/{LearnCardCreditCardFrontFace-a7b89edc.js → LearnCardCreditCardFrontFace-7d383319.js} +9 -8
  4. package/dist/cjs/{LearnCardCreditCardFrontFace-a7b89edc.js.map → LearnCardCreditCardFrontFace-7d383319.js.map} +1 -1
  5. package/dist/cjs/{VCCard-5495759e.js → VCCard-37198c86.js} +1495 -1489
  6. package/dist/{esm/VCCard-e39551a6.js.map → cjs/VCCard-37198c86.js.map} +1 -1
  7. package/dist/cjs/index.js +3 -3
  8. package/dist/cjs/index14.js +1 -1
  9. package/dist/cjs/index5.js +3 -3
  10. package/dist/cjs/index6.js +1 -1
  11. package/dist/cjs/index7.js +1 -1
  12. package/dist/esm/{LearnCardCreditCardBackFace-5ecba121.js → LearnCardCreditCardBackFace-4f7eaaa9.js} +5 -3
  13. package/dist/esm/LearnCardCreditCardBackFace-4f7eaaa9.js.map +1 -0
  14. package/dist/esm/{LearnCardCreditCardFrontFace-0a843e76.js → LearnCardCreditCardFrontFace-269b2847.js} +9 -8
  15. package/dist/esm/{LearnCardCreditCardFrontFace-0a843e76.js.map → LearnCardCreditCardFrontFace-269b2847.js.map} +1 -1
  16. package/dist/esm/{VCCard-e39551a6.js → VCCard-27020ddd.js} +1495 -1489
  17. package/dist/{cjs/VCCard-5495759e.js.map → esm/VCCard-27020ddd.js.map} +1 -1
  18. package/dist/esm/index.js +3 -3
  19. package/dist/esm/index14.js +1 -1
  20. package/dist/esm/index5.js +3 -3
  21. package/dist/esm/index6.js +1 -1
  22. package/dist/esm/index7.js +1 -1
  23. package/dist/main.css +1 -1
  24. package/dist/main.js +1 -1
  25. package/package.json +2 -2
  26. package/dist/cjs/LearnCardCreditCardBackFace-f1b96ce5.js.map +0 -1
  27. package/dist/esm/LearnCardCreditCardBackFace-5ecba121.js.map +0 -1
@@ -119620,1129 +119620,481 @@ var require_src3 = __commonJS({
119620
119620
  };
119621
119621
  }
119622
119622
  });
119623
- var wasm;
119624
- var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
119625
- cachedTextDecoder.decode();
119626
- var cachegetUint8Memory0 = null;
119627
- function getUint8Memory0() {
119628
- if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
119629
- cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
119630
- }
119631
- return cachegetUint8Memory0;
119632
- }
119633
- __name(getUint8Memory0, "getUint8Memory0");
119634
- function getStringFromWasm0(ptr, len) {
119635
- return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
119636
- }
119637
- __name(getStringFromWasm0, "getStringFromWasm0");
119638
- var heap = new Array(32).fill(void 0);
119639
- heap.push(void 0, null, true, false);
119640
- var heap_next = heap.length;
119641
- function addHeapObject(obj) {
119642
- if (heap_next === heap.length)
119643
- heap.push(heap.length + 1);
119644
- const idx = heap_next;
119645
- heap_next = heap[idx];
119646
- heap[idx] = obj;
119647
- return idx;
119648
- }
119649
- __name(addHeapObject, "addHeapObject");
119650
- function getObject(idx) {
119651
- return heap[idx];
119652
- }
119653
- __name(getObject, "getObject");
119654
- function dropObject(idx) {
119655
- if (idx < 36)
119656
- return;
119657
- heap[idx] = heap_next;
119658
- heap_next = idx;
119659
- }
119660
- __name(dropObject, "dropObject");
119661
- function takeObject(idx) {
119662
- const ret = getObject(idx);
119663
- dropObject(idx);
119664
- return ret;
119665
- }
119666
- __name(takeObject, "takeObject");
119667
- var WASM_VECTOR_LEN = 0;
119668
- var cachedTextEncoder = new TextEncoder("utf-8");
119669
- var encodeString = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
119670
- return cachedTextEncoder.encodeInto(arg, view);
119671
- } : function(arg, view) {
119672
- const buf2 = cachedTextEncoder.encode(arg);
119673
- view.set(buf2);
119674
- return {
119675
- read: arg.length,
119676
- written: buf2.length
119623
+ if (typeof window === "undefined")
119624
+ globalThis.crypto = crypto2;
119625
+ var addPluginToWallet = /* @__PURE__ */ __name((wallet, plugin) => __async$1(void 0, null, function* () {
119626
+ return generateWallet(wallet.contents, {
119627
+ plugins: [...wallet.plugins, plugin]
119628
+ });
119629
+ }), "addPluginToWallet");
119630
+ var addToWallet = /* @__PURE__ */ __name((wallet, content) => __async$1(void 0, null, function* () {
119631
+ return generateWallet([...wallet.contents, content], wallet);
119632
+ }), "addToWallet");
119633
+ var removeFromWallet = /* @__PURE__ */ __name((wallet, contentId) => __async$1(void 0, null, function* () {
119634
+ const clonedContents = JSON.parse(JSON.stringify(wallet.contents));
119635
+ const content = clonedContents.find((c) => c.id === contentId);
119636
+ return generateWallet(clonedContents.filter((i) => i.id !== content.id), wallet);
119637
+ }), "removeFromWallet");
119638
+ var bindMethods = /* @__PURE__ */ __name((wallet, pluginMethods) => Object.fromEntries(Object.entries(pluginMethods).map(([key2, method]) => [key2, method.bind(wallet, wallet)])), "bindMethods");
119639
+ var generateWallet = /* @__PURE__ */ __name((..._0) => __async$1(void 0, [..._0], function* (contents = [], _wallet = {}) {
119640
+ const { plugins = [] } = _wallet;
119641
+ const pluginMethods = plugins.reduce((cumulativePluginMethods, plugin) => {
119642
+ const newPluginMethods = __spreadValues(__spreadValues({}, cumulativePluginMethods), plugin.pluginMethods);
119643
+ return newPluginMethods;
119644
+ }, {});
119645
+ const wallet = {
119646
+ contents: [...contents],
119647
+ add: function(content) {
119648
+ return addToWallet(this, content);
119649
+ },
119650
+ remove: function(contentId) {
119651
+ return removeFromWallet(this, contentId);
119652
+ },
119653
+ status: "UNLOCKED",
119654
+ plugins,
119655
+ pluginMethods,
119656
+ addPlugin: function(plugin) {
119657
+ return addPluginToWallet(this, plugin);
119658
+ }
119677
119659
  };
119678
- };
119679
- function passStringToWasm0(arg, malloc, realloc) {
119680
- if (realloc === void 0) {
119681
- const buf2 = cachedTextEncoder.encode(arg);
119682
- const ptr2 = malloc(buf2.length);
119683
- getUint8Memory0().subarray(ptr2, ptr2 + buf2.length).set(buf2);
119684
- WASM_VECTOR_LEN = buf2.length;
119685
- return ptr2;
119660
+ if (pluginMethods)
119661
+ wallet.pluginMethods = bindMethods(wallet, pluginMethods);
119662
+ return wallet;
119663
+ }), "generateWallet");
119664
+ function _catch(body, recover) {
119665
+ try {
119666
+ var result = body();
119667
+ } catch (e) {
119668
+ return recover(e);
119686
119669
  }
119687
- let len = arg.length;
119688
- let ptr = malloc(len);
119689
- const mem = getUint8Memory0();
119690
- let offset = 0;
119691
- for (; offset < len; offset++) {
119692
- const code5 = arg.charCodeAt(offset);
119693
- if (code5 > 127)
119694
- break;
119695
- mem[ptr + offset] = code5;
119670
+ if (result && result.then) {
119671
+ return result.then(void 0, recover);
119696
119672
  }
119697
- if (offset !== len) {
119698
- if (offset !== 0) {
119699
- arg = arg.slice(offset);
119673
+ return result;
119674
+ }
119675
+ __name(_catch, "_catch");
119676
+ function inMemoryCache() {
119677
+ const cache = /* @__PURE__ */ new Map();
119678
+ return function(parsed, resolve) {
119679
+ try {
119680
+ let _temp2 = function(_result) {
119681
+ if (_exit)
119682
+ return _result;
119683
+ const cached = cache.get(parsed.didUrl);
119684
+ return cached !== void 0 ? cached : Promise.resolve(resolve()).then(function(result) {
119685
+ var _result$didResolution;
119686
+ if (((_result$didResolution = result.didResolutionMetadata) == null ? void 0 : _result$didResolution.error) !== "notFound") {
119687
+ cache.set(parsed.didUrl, result);
119688
+ }
119689
+ return result;
119690
+ });
119691
+ };
119692
+ __name(_temp2, "_temp2");
119693
+ let _exit;
119694
+ const _temp = function() {
119695
+ if (parsed.params && parsed.params["no-cache"] === "true") {
119696
+ return Promise.resolve(resolve()).then(function(_await$resolve) {
119697
+ _exit = 1;
119698
+ return _await$resolve;
119699
+ });
119700
+ }
119701
+ }();
119702
+ return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
119703
+ } catch (e) {
119704
+ return Promise.reject(e);
119700
119705
  }
119701
- ptr = realloc(ptr, len, len = offset + arg.length * 3);
119702
- const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
119703
- const ret = encodeString(arg, view);
119704
- offset += ret.written;
119705
- }
119706
- WASM_VECTOR_LEN = offset;
119707
- return ptr;
119706
+ };
119708
119707
  }
119709
- __name(passStringToWasm0, "passStringToWasm0");
119710
- function isLikeNone(x) {
119711
- return x === void 0 || x === null;
119708
+ __name(inMemoryCache, "inMemoryCache");
119709
+ function noCache(parsed, resolve) {
119710
+ return resolve();
119712
119711
  }
119713
- __name(isLikeNone, "isLikeNone");
119714
- var cachegetInt32Memory0 = null;
119715
- function getInt32Memory0() {
119716
- if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
119717
- cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
119712
+ __name(noCache, "noCache");
119713
+ var PCT_ENCODED = "(?:%[0-9a-fA-F]{2})";
119714
+ var ID_CHAR = `(?:[a-zA-Z0-9._-]|${PCT_ENCODED})`;
119715
+ var METHOD = "([a-z0-9]+)";
119716
+ var METHOD_ID = `((?:${ID_CHAR}*:)*(${ID_CHAR}+))`;
119717
+ var PARAM_CHAR = "[a-zA-Z0-9_.:%-]";
119718
+ var PARAM = `;${PARAM_CHAR}+=${PARAM_CHAR}*`;
119719
+ var PARAMS = `((${PARAM})*)`;
119720
+ var PATH = `(/[^#?]*)?`;
119721
+ var QUERY = `([?][^#]*)?`;
119722
+ var FRAGMENT = `(#.*)?`;
119723
+ var DID_MATCHER = new RegExp(`^did:${METHOD}:${METHOD_ID}${PARAMS}${PATH}${QUERY}${FRAGMENT}$`);
119724
+ function parse(didUrl) {
119725
+ if (didUrl === "" || !didUrl)
119726
+ return null;
119727
+ const sections = didUrl.match(DID_MATCHER);
119728
+ if (sections) {
119729
+ const parts = {
119730
+ did: `did:${sections[1]}:${sections[2]}`,
119731
+ method: sections[1],
119732
+ id: sections[2],
119733
+ didUrl
119734
+ };
119735
+ if (sections[4]) {
119736
+ const params = sections[4].slice(1).split(";");
119737
+ parts.params = {};
119738
+ for (const p of params) {
119739
+ const kv = p.split("=");
119740
+ parts.params[kv[0]] = kv[1];
119741
+ }
119742
+ }
119743
+ if (sections[6])
119744
+ parts.path = sections[6];
119745
+ if (sections[7])
119746
+ parts.query = sections[7].slice(1);
119747
+ if (sections[8])
119748
+ parts.fragment = sections[8].slice(1);
119749
+ return parts;
119718
119750
  }
119719
- return cachegetInt32Memory0;
119751
+ return null;
119720
119752
  }
119721
- __name(getInt32Memory0, "getInt32Memory0");
119722
- function debugString(val) {
119723
- const type = typeof val;
119724
- if (type == "number" || type == "boolean" || val == null) {
119725
- return `${val}`;
119726
- }
119727
- if (type == "string") {
119728
- return `"${val}"`;
119729
- }
119730
- if (type == "symbol") {
119731
- const description = val.description;
119732
- if (description == null) {
119733
- return "Symbol";
119734
- } else {
119735
- return `Symbol(${description})`;
119753
+ __name(parse, "parse");
119754
+ var EMPTY_RESULT = {
119755
+ didResolutionMetadata: {},
119756
+ didDocument: null,
119757
+ didDocumentMetadata: {}
119758
+ };
119759
+ function wrapLegacyResolver(resolve) {
119760
+ return function(did, parsed, resolver) {
119761
+ try {
119762
+ return Promise.resolve(_catch(function() {
119763
+ return Promise.resolve(resolve(did, parsed, resolver)).then(function(doc) {
119764
+ return __spreadProps(__spreadValues({}, EMPTY_RESULT), {
119765
+ didResolutionMetadata: {
119766
+ contentType: "application/did+ld+json"
119767
+ },
119768
+ didDocument: doc
119769
+ });
119770
+ });
119771
+ }, function(e) {
119772
+ return __spreadProps(__spreadValues({}, EMPTY_RESULT), {
119773
+ didResolutionMetadata: {
119774
+ error: "notFound",
119775
+ message: e.toString()
119776
+ }
119777
+ });
119778
+ }));
119779
+ } catch (e) {
119780
+ return Promise.reject(e);
119736
119781
  }
119737
- }
119738
- if (type == "function") {
119739
- const name5 = val.name;
119740
- if (typeof name5 == "string" && name5.length > 0) {
119741
- return `Function(${name5})`;
119742
- } else {
119743
- return "Function";
119744
- }
119745
- }
119746
- if (Array.isArray(val)) {
119747
- const length2 = val.length;
119748
- let debug = "[";
119749
- if (length2 > 0) {
119750
- debug += debugString(val[0]);
119751
- }
119752
- for (let i = 1; i < length2; i++) {
119753
- debug += ", " + debugString(val[i]);
119754
- }
119755
- debug += "]";
119756
- return debug;
119757
- }
119758
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
119759
- let className;
119760
- if (builtInMatches.length > 1) {
119761
- className = builtInMatches[1];
119762
- } else {
119763
- return toString.call(val);
119764
- }
119765
- if (className == "Object") {
119766
- try {
119767
- return "Object(" + JSON.stringify(val) + ")";
119768
- } catch (_) {
119769
- return "Object";
119782
+ };
119783
+ }
119784
+ __name(wrapLegacyResolver, "wrapLegacyResolver");
119785
+ var Resolver = class {
119786
+ constructor(registry2 = {}, options = {}) {
119787
+ this.registry = void 0;
119788
+ this.cache = void 0;
119789
+ this.registry = registry2;
119790
+ this.cache = options.cache === true ? inMemoryCache() : options.cache || noCache;
119791
+ if (options.legacyResolvers) {
119792
+ Object.keys(options.legacyResolvers).map((methodName) => {
119793
+ if (!this.registry[methodName]) {
119794
+ this.registry[methodName] = wrapLegacyResolver(options.legacyResolvers[methodName]);
119795
+ }
119796
+ });
119770
119797
  }
119771
119798
  }
119772
- if (val instanceof Error) {
119773
- return `${val.name}: ${val.message}
119774
- ${val.stack}`;
119775
- }
119776
- return className;
119777
- }
119778
- __name(debugString, "debugString");
119779
- function makeMutClosure(arg0, arg1, dtor, f) {
119780
- const state = { a: arg0, b: arg1, cnt: 1, dtor };
119781
- const real = /* @__PURE__ */ __name((...args) => {
119782
- state.cnt++;
119783
- const a = state.a;
119784
- state.a = 0;
119799
+ resolve(didUrl, options = {}) {
119785
119800
  try {
119786
- return f(a, state.b, ...args);
119787
- } finally {
119788
- if (--state.cnt === 0) {
119789
- wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
119790
- } else {
119791
- state.a = a;
119801
+ const _this = this;
119802
+ const parsed = parse(didUrl);
119803
+ if (parsed === null) {
119804
+ return Promise.resolve(__spreadProps(__spreadValues({}, EMPTY_RESULT), {
119805
+ didResolutionMetadata: {
119806
+ error: "invalidDid"
119807
+ }
119808
+ }));
119809
+ }
119810
+ const resolver = _this.registry[parsed.method];
119811
+ if (!resolver) {
119812
+ return Promise.resolve(__spreadProps(__spreadValues({}, EMPTY_RESULT), {
119813
+ didResolutionMetadata: {
119814
+ error: "unsupportedDidMethod"
119815
+ }
119816
+ }));
119792
119817
  }
119818
+ return Promise.resolve(_this.cache(parsed, () => resolver(parsed.did, parsed, _this, options)));
119819
+ } catch (e) {
119820
+ return Promise.reject(e);
119793
119821
  }
119794
- }, "real");
119795
- real.original = state;
119796
- return real;
119797
- }
119798
- __name(makeMutClosure, "makeMutClosure");
119799
- function __wbg_adapter_24(arg0, arg1, arg2) {
119800
- wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h91a8814f66f14b17(arg0, arg1, addHeapObject(arg2));
119822
+ }
119823
+ };
119824
+ __name(Resolver, "Resolver");
119825
+ init_concat();
119826
+ init_from_string();
119827
+ init_to_string();
119828
+ init_basics();
119829
+ var import_sha256 = __toESM(require_sha256());
119830
+ var import_js_sha3 = __toESM(require_sha3());
119831
+ var import_elliptic = __toESM(require_elliptic());
119832
+ var import_ed25519 = __toESM(require_ed25519());
119833
+ var import_canonicalize = __toESM(require_canonicalize());
119834
+ var import_x25519 = __toESM(require_x25519());
119835
+ var import_xchacha20poly1305 = __toESM(require_xchacha20poly1305());
119836
+ var import_random = __toESM(require_random());
119837
+ function bytesToBase64url(b) {
119838
+ return toString3(b, "base64url");
119801
119839
  }
119802
- __name(__wbg_adapter_24, "__wbg_adapter_24");
119803
- function passArray8ToWasm0(arg, malloc) {
119804
- const ptr = malloc(arg.length * 1);
119805
- getUint8Memory0().set(arg, ptr / 1);
119806
- WASM_VECTOR_LEN = arg.length;
119807
- return ptr;
119840
+ __name(bytesToBase64url, "bytesToBase64url");
119841
+ function base64ToBytes(s) {
119842
+ const inputBase64Url = s.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
119843
+ return fromString2(inputBase64Url, "base64url");
119808
119844
  }
119809
- __name(passArray8ToWasm0, "passArray8ToWasm0");
119810
- function generateEd25519KeyFromBytes(bytes) {
119811
- try {
119812
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
119813
- const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
119814
- const len0 = WASM_VECTOR_LEN;
119815
- wasm.generateEd25519KeyFromBytes(retptr, ptr0, len0);
119816
- var r0 = getInt32Memory0()[retptr / 4 + 0];
119817
- var r1 = getInt32Memory0()[retptr / 4 + 1];
119818
- var r2 = getInt32Memory0()[retptr / 4 + 2];
119819
- var r3 = getInt32Memory0()[retptr / 4 + 3];
119820
- var ptr1 = r0;
119821
- var len1 = r1;
119822
- if (r3) {
119823
- ptr1 = 0;
119824
- len1 = 0;
119825
- throw takeObject(r2);
119826
- }
119827
- return getStringFromWasm0(ptr1, len1);
119828
- } finally {
119829
- wasm.__wbindgen_add_to_stack_pointer(16);
119830
- wasm.__wbindgen_free(ptr1, len1);
119831
- }
119845
+ __name(base64ToBytes, "base64ToBytes");
119846
+ function base58ToBytes(s) {
119847
+ return fromString2(s, "base58btc");
119832
119848
  }
119833
- __name(generateEd25519KeyFromBytes, "generateEd25519KeyFromBytes");
119834
- function keyToDID(method_pattern, jwk) {
119835
- try {
119836
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
119837
- const ptr0 = passStringToWasm0(method_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119838
- const len0 = WASM_VECTOR_LEN;
119839
- const ptr1 = passStringToWasm0(jwk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119840
- const len1 = WASM_VECTOR_LEN;
119841
- wasm.keyToDID(retptr, ptr0, len0, ptr1, len1);
119842
- var r0 = getInt32Memory0()[retptr / 4 + 0];
119843
- var r1 = getInt32Memory0()[retptr / 4 + 1];
119844
- var r2 = getInt32Memory0()[retptr / 4 + 2];
119845
- var r3 = getInt32Memory0()[retptr / 4 + 3];
119846
- var ptr2 = r0;
119847
- var len2 = r1;
119848
- if (r3) {
119849
- ptr2 = 0;
119850
- len2 = 0;
119851
- throw takeObject(r2);
119852
- }
119853
- return getStringFromWasm0(ptr2, len2);
119854
- } finally {
119855
- wasm.__wbindgen_add_to_stack_pointer(16);
119856
- wasm.__wbindgen_free(ptr2, len2);
119857
- }
119849
+ __name(base58ToBytes, "base58ToBytes");
119850
+ function hexToBytes(s) {
119851
+ const input = s.startsWith("0x") ? s.substring(2) : s;
119852
+ return fromString2(input.toLowerCase(), "base16");
119858
119853
  }
119859
- __name(keyToDID, "keyToDID");
119860
- function keyToVerificationMethod(method_pattern, jwk) {
119861
- const ptr0 = passStringToWasm0(method_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119862
- const len0 = WASM_VECTOR_LEN;
119863
- const ptr1 = passStringToWasm0(jwk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119864
- const len1 = WASM_VECTOR_LEN;
119865
- const ret = wasm.keyToVerificationMethod(ptr0, len0, ptr1, len1);
119866
- return takeObject(ret);
119854
+ __name(hexToBytes, "hexToBytes");
119855
+ function encodeBase64url(s) {
119856
+ return bytesToBase64url(fromString2(s));
119867
119857
  }
119868
- __name(keyToVerificationMethod, "keyToVerificationMethod");
119869
- function issueCredential(credential, proof_options, key2) {
119870
- const ptr0 = passStringToWasm0(credential, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119871
- const len0 = WASM_VECTOR_LEN;
119872
- const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119873
- const len1 = WASM_VECTOR_LEN;
119874
- const ptr2 = passStringToWasm0(key2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119875
- const len2 = WASM_VECTOR_LEN;
119876
- const ret = wasm.issueCredential(ptr0, len0, ptr1, len1, ptr2, len2);
119877
- return takeObject(ret);
119858
+ __name(encodeBase64url, "encodeBase64url");
119859
+ function decodeBase64url(s) {
119860
+ return toString3(base64ToBytes(s));
119878
119861
  }
119879
- __name(issueCredential, "issueCredential");
119880
- function verifyCredential(vc, proof_options) {
119881
- const ptr0 = passStringToWasm0(vc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119882
- const len0 = WASM_VECTOR_LEN;
119883
- const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119884
- const len1 = WASM_VECTOR_LEN;
119885
- const ret = wasm.verifyCredential(ptr0, len0, ptr1, len1);
119886
- return takeObject(ret);
119862
+ __name(decodeBase64url, "decodeBase64url");
119863
+ function bytesToHex(b) {
119864
+ return toString3(b, "base16");
119887
119865
  }
119888
- __name(verifyCredential, "verifyCredential");
119889
- function issuePresentation(presentation, proof_options, key2) {
119890
- const ptr0 = passStringToWasm0(presentation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119891
- const len0 = WASM_VECTOR_LEN;
119892
- const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119893
- const len1 = WASM_VECTOR_LEN;
119894
- const ptr2 = passStringToWasm0(key2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119895
- const len2 = WASM_VECTOR_LEN;
119896
- const ret = wasm.issuePresentation(ptr0, len0, ptr1, len1, ptr2, len2);
119897
- return takeObject(ret);
119866
+ __name(bytesToHex, "bytesToHex");
119867
+ function stringToBytes(s) {
119868
+ return fromString2(s);
119898
119869
  }
119899
- __name(issuePresentation, "issuePresentation");
119900
- function verifyPresentation(vp, proof_options) {
119901
- const ptr0 = passStringToWasm0(vp, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119902
- const len0 = WASM_VECTOR_LEN;
119903
- const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119904
- const len1 = WASM_VECTOR_LEN;
119905
- const ret = wasm.verifyPresentation(ptr0, len0, ptr1, len1);
119906
- return takeObject(ret);
119870
+ __name(stringToBytes, "stringToBytes");
119871
+ function toJose({
119872
+ r,
119873
+ s,
119874
+ recoveryParam
119875
+ }, recoverable) {
119876
+ const jose = new Uint8Array(recoverable ? 65 : 64);
119877
+ jose.set(fromString2(r, "base16"), 0);
119878
+ jose.set(fromString2(s, "base16"), 32);
119879
+ if (recoverable) {
119880
+ if (typeof recoveryParam === "undefined") {
119881
+ throw new Error("Signer did not return a recoveryParam");
119882
+ }
119883
+ jose[64] = recoveryParam;
119884
+ }
119885
+ return bytesToBase64url(jose);
119907
119886
  }
119908
- __name(verifyPresentation, "verifyPresentation");
119909
- function handleError(f, args) {
119910
- try {
119911
- return f.apply(this, args);
119912
- } catch (e) {
119913
- wasm.__wbindgen_exn_store(addHeapObject(e));
119887
+ __name(toJose, "toJose");
119888
+ function fromJose(signature2) {
119889
+ const signatureBytes = base64ToBytes(signature2);
119890
+ if (signatureBytes.length < 64 || signatureBytes.length > 65) {
119891
+ throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${signatureBytes.length}`);
119914
119892
  }
119893
+ const r = bytesToHex(signatureBytes.slice(0, 32));
119894
+ const s = bytesToHex(signatureBytes.slice(32, 64));
119895
+ const recoveryParam = signatureBytes.length === 65 ? signatureBytes[64] : void 0;
119896
+ return {
119897
+ r,
119898
+ s,
119899
+ recoveryParam
119900
+ };
119915
119901
  }
119916
- __name(handleError, "handleError");
119917
- function getArrayU8FromWasm0(ptr, len) {
119918
- return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
119902
+ __name(fromJose, "fromJose");
119903
+ function toSealed(ciphertext, tag) {
119904
+ return concat([base64ToBytes(ciphertext), base64ToBytes(tag)]);
119919
119905
  }
119920
- __name(getArrayU8FromWasm0, "getArrayU8FromWasm0");
119921
- function __wbg_adapter_108(arg0, arg1, arg2, arg3) {
119922
- wasm.wasm_bindgen__convert__closures__invoke2_mut__h3ecfeb7a01c1be81(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
119906
+ __name(toSealed, "toSealed");
119907
+ var hexMatcher = /^(0x)?([a-fA-F0-9]{64}|[a-fA-F0-9]{128})$/;
119908
+ var base58Matcher = /^([1-9A-HJ-NP-Za-km-z]{44}|[1-9A-HJ-NP-Za-km-z]{88})$/;
119909
+ var base64Matcher = /^([0-9a-zA-Z=\-_+/]{43}|[0-9a-zA-Z=\-_+/]{86})(={0,2})$/;
119910
+ function parseKey(input) {
119911
+ if (typeof input === "string") {
119912
+ if (hexMatcher.test(input)) {
119913
+ return hexToBytes(input);
119914
+ } else if (base58Matcher.test(input)) {
119915
+ return base58ToBytes(input);
119916
+ } else if (base64Matcher.test(input)) {
119917
+ return base64ToBytes(input);
119918
+ } else {
119919
+ throw TypeError("bad_key: Invalid private key format");
119920
+ }
119921
+ } else if (input instanceof Uint8Array) {
119922
+ return input;
119923
+ } else {
119924
+ throw TypeError("bad_key: Invalid private key format");
119925
+ }
119923
119926
  }
119924
- __name(__wbg_adapter_108, "__wbg_adapter_108");
119925
- function load(module, imports) {
119926
- return __async$1(this, null, function* () {
119927
- if (typeof Response === "function" && module instanceof Response) {
119928
- if (typeof WebAssembly.instantiateStreaming === "function") {
119929
- try {
119930
- return yield WebAssembly.instantiateStreaming(module, imports);
119931
- } catch (e) {
119932
- if (module.headers.get("Content-Type") != "application/wasm") {
119933
- console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
119934
- } else {
119935
- throw e;
119927
+ __name(parseKey, "parseKey");
119928
+ function sha2562(payload) {
119929
+ const data = typeof payload === "string" ? fromString2(payload) : payload;
119930
+ return (0, import_sha256.hash)(data);
119931
+ }
119932
+ __name(sha2562, "sha256");
119933
+ function keccak(data) {
119934
+ return new Uint8Array(import_js_sha3.keccak_256.arrayBuffer(data));
119935
+ }
119936
+ __name(keccak, "keccak");
119937
+ function toEthereumAddress(hexPublicKey) {
119938
+ const hashInput = fromString2(hexPublicKey.slice(2), "base16");
119939
+ return `0x${toString3(keccak(hashInput).slice(-20), "base16")}`;
119940
+ }
119941
+ __name(toEthereumAddress, "toEthereumAddress");
119942
+ function writeUint32BE(value, array = new Uint8Array(4)) {
119943
+ const encoded = fromString2(value.toString(), "base10");
119944
+ array.set(encoded, 4 - encoded.length);
119945
+ return array;
119946
+ }
119947
+ __name(writeUint32BE, "writeUint32BE");
119948
+ var lengthAndInput = /* @__PURE__ */ __name((input) => concat([writeUint32BE(input.length), input]), "lengthAndInput");
119949
+ function concatKDF(secret, keyLen, alg, producerInfo, consumerInfo) {
119950
+ if (keyLen !== 256)
119951
+ throw new Error(`Unsupported key length: ${keyLen}`);
119952
+ const value = concat([lengthAndInput(fromString2(alg)), lengthAndInput(typeof producerInfo === "undefined" ? new Uint8Array(0) : producerInfo), lengthAndInput(typeof consumerInfo === "undefined" ? new Uint8Array(0) : consumerInfo), writeUint32BE(keyLen)]);
119953
+ const roundNumber = 1;
119954
+ return (0, import_sha256.hash)(concat([writeUint32BE(roundNumber), secret, value]));
119955
+ }
119956
+ __name(concatKDF, "concatKDF");
119957
+ new import_elliptic.ec("secp256k1");
119958
+ function EdDSASigner(secretKey) {
119959
+ const privateKeyBytes = parseKey(secretKey);
119960
+ if (privateKeyBytes.length !== 64) {
119961
+ throw new Error(`bad_key: Invalid private key format. Expecting 64 bytes, but got ${privateKeyBytes.length}`);
119962
+ }
119963
+ return function(data) {
119964
+ try {
119965
+ const dataBytes = typeof data === "string" ? stringToBytes(data) : data;
119966
+ const sig = (0, import_ed25519.sign)(privateKeyBytes, dataBytes);
119967
+ return Promise.resolve(bytesToBase64url(sig));
119968
+ } catch (e) {
119969
+ return Promise.reject(e);
119970
+ }
119971
+ };
119972
+ }
119973
+ __name(EdDSASigner, "EdDSASigner");
119974
+ function instanceOfEcdsaSignature(object) {
119975
+ return typeof object === "object" && "r" in object && "s" in object;
119976
+ }
119977
+ __name(instanceOfEcdsaSignature, "instanceOfEcdsaSignature");
119978
+ function ES256KSignerAlg(recoverable) {
119979
+ return /* @__PURE__ */ __name(function sign5(payload, signer) {
119980
+ try {
119981
+ return Promise.resolve(signer(payload)).then(function(signature2) {
119982
+ if (instanceOfEcdsaSignature(signature2)) {
119983
+ return toJose(signature2, recoverable);
119984
+ } else {
119985
+ if (recoverable && typeof fromJose(signature2).recoveryParam === "undefined") {
119986
+ throw new Error(`not_supported: ES256K-R not supported when signer doesn't provide a recovery param`);
119936
119987
  }
119988
+ return signature2;
119937
119989
  }
119938
- }
119939
- const bytes = yield module.arrayBuffer();
119940
- return yield WebAssembly.instantiate(bytes, imports);
119941
- } else {
119942
- const instance = yield WebAssembly.instantiate(module, imports);
119943
- if (instance instanceof WebAssembly.Instance) {
119944
- return { instance, module };
119945
- } else {
119946
- return instance;
119947
- }
119990
+ });
119991
+ } catch (e) {
119992
+ return Promise.reject(e);
119993
+ }
119994
+ }, "sign");
119995
+ }
119996
+ __name(ES256KSignerAlg, "ES256KSignerAlg");
119997
+ function Ed25519SignerAlg() {
119998
+ return /* @__PURE__ */ __name(function sign5(payload, signer) {
119999
+ try {
120000
+ return Promise.resolve(signer(payload)).then(function(signature2) {
120001
+ if (!instanceOfEcdsaSignature(signature2)) {
120002
+ return signature2;
120003
+ } else {
120004
+ throw new Error("invalid_config: expected a signer function that returns a string instead of signature object");
120005
+ }
120006
+ });
120007
+ } catch (e) {
120008
+ return Promise.reject(e);
120009
+ }
120010
+ }, "sign");
120011
+ }
120012
+ __name(Ed25519SignerAlg, "Ed25519SignerAlg");
120013
+ var algorithms$1 = {
120014
+ ES256K: ES256KSignerAlg(),
120015
+ "ES256K-R": ES256KSignerAlg(true),
120016
+ Ed25519: Ed25519SignerAlg(),
120017
+ EdDSA: Ed25519SignerAlg()
120018
+ };
120019
+ function SignerAlg(alg) {
120020
+ const impl = algorithms$1[alg];
120021
+ if (!impl)
120022
+ throw new Error(`not_supported: Unsupported algorithm ${alg}`);
120023
+ return impl;
120024
+ }
120025
+ __name(SignerAlg, "SignerAlg");
120026
+ var secp256k1 = new import_elliptic.ec("secp256k1");
120027
+ function toSignatureObject(signature2, recoverable = false) {
120028
+ const rawSig = base64ToBytes(signature2);
120029
+ if (rawSig.length !== (recoverable ? 65 : 64)) {
120030
+ throw new Error("wrong signature length");
120031
+ }
120032
+ const r = bytesToHex(rawSig.slice(0, 32));
120033
+ const s = bytesToHex(rawSig.slice(32, 64));
120034
+ const sigObj = {
120035
+ r,
120036
+ s
120037
+ };
120038
+ if (recoverable) {
120039
+ sigObj.recoveryParam = rawSig[64];
120040
+ }
120041
+ return sigObj;
120042
+ }
120043
+ __name(toSignatureObject, "toSignatureObject");
120044
+ function extractPublicKeyBytes(pk) {
120045
+ if (pk.publicKeyBase58) {
120046
+ return base58ToBytes(pk.publicKeyBase58);
120047
+ } else if (pk.publicKeyBase64) {
120048
+ return base64ToBytes(pk.publicKeyBase64);
120049
+ } else if (pk.publicKeyHex) {
120050
+ return hexToBytes(pk.publicKeyHex);
120051
+ } else if (pk.publicKeyJwk && pk.publicKeyJwk.crv === "secp256k1" && pk.publicKeyJwk.x && pk.publicKeyJwk.y) {
120052
+ return hexToBytes(secp256k1.keyFromPublic({
120053
+ x: bytesToHex(base64ToBytes(pk.publicKeyJwk.x)),
120054
+ y: bytesToHex(base64ToBytes(pk.publicKeyJwk.y))
120055
+ }).getPublic("hex"));
120056
+ } else if (pk.publicKeyMultibase) {
120057
+ const {
120058
+ base16: base162,
120059
+ base58btc: base58btc2,
120060
+ base64: base642,
120061
+ base64url: base64url2
120062
+ } = bases;
120063
+ const baseDecoder = base162.decoder.or(base58btc2.decoder.or(base642.decoder.or(base64url2.decoder)));
120064
+ return baseDecoder.decode(pk.publicKeyMultibase);
120065
+ }
120066
+ return new Uint8Array();
120067
+ }
120068
+ __name(extractPublicKeyBytes, "extractPublicKeyBytes");
120069
+ function verifyES256K(data, signature2, authenticators) {
120070
+ const hash3 = sha2562(data);
120071
+ const sigObj = toSignatureObject(signature2);
120072
+ const fullPublicKeys = authenticators.filter(({
120073
+ ethereumAddress,
120074
+ blockchainAccountId
120075
+ }) => {
120076
+ return typeof ethereumAddress === "undefined" && typeof blockchainAccountId === "undefined";
120077
+ });
120078
+ const ethAddressKeys = authenticators.filter(({
120079
+ ethereumAddress,
120080
+ blockchainAccountId
120081
+ }) => {
120082
+ return typeof ethereumAddress !== "undefined" || typeof blockchainAccountId !== void 0;
120083
+ });
120084
+ let signer = fullPublicKeys.find((pk) => {
120085
+ try {
120086
+ const pubBytes = extractPublicKeyBytes(pk);
120087
+ return secp256k1.keyFromPublic(pubBytes).verify(hash3, sigObj);
120088
+ } catch (err) {
120089
+ return false;
119948
120090
  }
119949
120091
  });
119950
- }
119951
- __name(load, "load");
119952
- function init(input) {
119953
- return __async$1(this, null, function* () {
119954
- const imports = {};
119955
- imports.wbg = {};
119956
- imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
119957
- const ret = getStringFromWasm0(arg0, arg1);
119958
- return addHeapObject(ret);
119959
- };
119960
- imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
119961
- takeObject(arg0);
119962
- };
119963
- imports.wbg.__wbindgen_cb_drop = function(arg0) {
119964
- const obj = takeObject(arg0).original;
119965
- if (obj.cnt-- == 1) {
119966
- obj.a = 0;
119967
- return true;
119968
- }
119969
- const ret = false;
119970
- return ret;
119971
- };
119972
- imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
119973
- const ret = getObject(arg0);
119974
- return addHeapObject(ret);
119975
- };
119976
- imports.wbg.__wbg_fetch_811d43d6bdcad5b1 = function(arg0) {
119977
- const ret = fetch(getObject(arg0));
119978
- return addHeapObject(ret);
119979
- };
119980
- imports.wbg.__wbg_fetch_bf56e2a9f0644e3f = function(arg0, arg1) {
119981
- const ret = getObject(arg0).fetch(getObject(arg1));
119982
- return addHeapObject(ret);
119983
- };
119984
- imports.wbg.__wbg_new_89d7f088c1c45353 = function() {
119985
- return handleError(function() {
119986
- const ret = new Headers();
119987
- return addHeapObject(ret);
119988
- }, arguments);
119989
- };
119990
- imports.wbg.__wbg_append_f4f93bc73c45ee3e = function() {
119991
- return handleError(function(arg0, arg1, arg2, arg3, arg4) {
119992
- getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
119993
- }, arguments);
119994
- };
119995
- imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
119996
- const obj = getObject(arg1);
119997
- const ret = typeof obj === "string" ? obj : void 0;
119998
- var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
119999
- var len0 = WASM_VECTOR_LEN;
120000
- getInt32Memory0()[arg0 / 4 + 1] = len0;
120001
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
120002
- };
120003
- imports.wbg.__wbg_instanceof_Response_ccfeb62399355bcd = function(arg0) {
120004
- const ret = getObject(arg0) instanceof Response;
120005
- return ret;
120006
- };
120007
- imports.wbg.__wbg_url_06c0f822d68d195c = function(arg0, arg1) {
120008
- const ret = getObject(arg1).url;
120009
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
120010
- const len0 = WASM_VECTOR_LEN;
120011
- getInt32Memory0()[arg0 / 4 + 1] = len0;
120012
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
120013
- };
120014
- imports.wbg.__wbg_status_600fd8b881393898 = function(arg0) {
120015
- const ret = getObject(arg0).status;
120016
- return ret;
120017
- };
120018
- imports.wbg.__wbg_headers_9e7f2c05a9b962ea = function(arg0) {
120019
- const ret = getObject(arg0).headers;
120020
- return addHeapObject(ret);
120021
- };
120022
- imports.wbg.__wbg_arrayBuffer_5a99283a3954c850 = function() {
120023
- return handleError(function(arg0) {
120024
- const ret = getObject(arg0).arrayBuffer();
120025
- return addHeapObject(ret);
120026
- }, arguments);
120027
- };
120028
- imports.wbg.__wbg_newwithstrandinit_fd99688f189f053e = function() {
120029
- return handleError(function(arg0, arg1, arg2) {
120030
- const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
120031
- return addHeapObject(ret);
120032
- }, arguments);
120033
- };
120034
- imports.wbg.__wbindgen_is_object = function(arg0) {
120035
- const val = getObject(arg0);
120036
- const ret = typeof val === "object" && val !== null;
120037
- return ret;
120038
- };
120039
- imports.wbg.__wbg_self_86b4b13392c7af56 = function() {
120040
- return handleError(function() {
120041
- const ret = self.self;
120042
- return addHeapObject(ret);
120043
- }, arguments);
120044
- };
120045
- imports.wbg.__wbg_crypto_b8c92eaac23d0d80 = function(arg0) {
120046
- const ret = getObject(arg0).crypto;
120047
- return addHeapObject(ret);
120048
- };
120049
- imports.wbg.__wbg_msCrypto_9ad6677321a08dd8 = function(arg0) {
120050
- const ret = getObject(arg0).msCrypto;
120051
- return addHeapObject(ret);
120052
- };
120053
- imports.wbg.__wbindgen_is_undefined = function(arg0) {
120054
- const ret = getObject(arg0) === void 0;
120055
- return ret;
120056
- };
120057
- imports.wbg.__wbg_static_accessor_MODULE_452b4680e8614c81 = function() {
120058
- const ret = module;
120059
- return addHeapObject(ret);
120060
- };
120061
- imports.wbg.__wbg_require_f5521a5b85ad2542 = function(arg0, arg1, arg2) {
120062
- const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
120063
- return addHeapObject(ret);
120064
- };
120065
- imports.wbg.__wbg_getRandomValues_dd27e6b0652b3236 = function(arg0) {
120066
- const ret = getObject(arg0).getRandomValues;
120067
- return addHeapObject(ret);
120068
- };
120069
- imports.wbg.__wbg_getRandomValues_e57c9b75ddead065 = function(arg0, arg1) {
120070
- getObject(arg0).getRandomValues(getObject(arg1));
120071
- };
120072
- imports.wbg.__wbg_randomFillSync_d2ba53160aec6aba = function(arg0, arg1, arg2) {
120073
- getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
120074
- };
120075
- imports.wbg.__wbindgen_is_function = function(arg0) {
120076
- const ret = typeof getObject(arg0) === "function";
120077
- return ret;
120078
- };
120079
- imports.wbg.__wbg_newnoargs_e23b458e372830de = function(arg0, arg1) {
120080
- const ret = new Function(getStringFromWasm0(arg0, arg1));
120081
- return addHeapObject(ret);
120082
- };
120083
- imports.wbg.__wbg_next_cabb70b365520721 = function(arg0) {
120084
- const ret = getObject(arg0).next;
120085
- return addHeapObject(ret);
120086
- };
120087
- imports.wbg.__wbg_next_bf3d83fc18df496e = function() {
120088
- return handleError(function(arg0) {
120089
- const ret = getObject(arg0).next();
120090
- return addHeapObject(ret);
120091
- }, arguments);
120092
- };
120093
- imports.wbg.__wbg_done_040f966faa9a72b3 = function(arg0) {
120094
- const ret = getObject(arg0).done;
120095
- return ret;
120096
- };
120097
- imports.wbg.__wbg_value_419afbd9b9574c4c = function(arg0) {
120098
- const ret = getObject(arg0).value;
120099
- return addHeapObject(ret);
120100
- };
120101
- imports.wbg.__wbg_iterator_4832ef1f15b0382b = function() {
120102
- const ret = Symbol.iterator;
120103
- return addHeapObject(ret);
120104
- };
120105
- imports.wbg.__wbg_get_a9cab131e3152c49 = function() {
120106
- return handleError(function(arg0, arg1) {
120107
- const ret = Reflect.get(getObject(arg0), getObject(arg1));
120108
- return addHeapObject(ret);
120109
- }, arguments);
120110
- };
120111
- imports.wbg.__wbg_call_ae78342adc33730a = function() {
120112
- return handleError(function(arg0, arg1) {
120113
- const ret = getObject(arg0).call(getObject(arg1));
120114
- return addHeapObject(ret);
120115
- }, arguments);
120116
- };
120117
- imports.wbg.__wbg_new_36359baae5a47e27 = function() {
120118
- const ret = new Object();
120119
- return addHeapObject(ret);
120120
- };
120121
- imports.wbg.__wbg_call_3ed288a247f13ea5 = function() {
120122
- return handleError(function(arg0, arg1, arg2) {
120123
- const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
120124
- return addHeapObject(ret);
120125
- }, arguments);
120126
- };
120127
- imports.wbg.__wbg_getTime_bffb1c09df09618b = function(arg0) {
120128
- const ret = getObject(arg0).getTime();
120129
- return ret;
120130
- };
120131
- imports.wbg.__wbg_new0_0ff7eb5c1486f3ec = function() {
120132
- const ret = new Date();
120133
- return addHeapObject(ret);
120134
- };
120135
- imports.wbg.__wbg_new_37705eed627d5ed9 = function(arg0, arg1) {
120136
- try {
120137
- var state0 = { a: arg0, b: arg1 };
120138
- var cb0 = /* @__PURE__ */ __name((arg02, arg12) => {
120139
- const a = state0.a;
120140
- state0.a = 0;
120141
- try {
120142
- return __wbg_adapter_108(a, state0.b, arg02, arg12);
120143
- } finally {
120144
- state0.a = a;
120145
- }
120146
- }, "cb0");
120147
- const ret = new Promise(cb0);
120148
- return addHeapObject(ret);
120149
- } finally {
120150
- state0.a = state0.b = 0;
120151
- }
120152
- };
120153
- imports.wbg.__wbg_resolve_a9a87bdd64e9e62c = function(arg0) {
120154
- const ret = Promise.resolve(getObject(arg0));
120155
- return addHeapObject(ret);
120156
- };
120157
- imports.wbg.__wbg_then_ce526c837d07b68f = function(arg0, arg1) {
120158
- const ret = getObject(arg0).then(getObject(arg1));
120159
- return addHeapObject(ret);
120160
- };
120161
- imports.wbg.__wbg_then_842e65b843962f56 = function(arg0, arg1, arg2) {
120162
- const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
120163
- return addHeapObject(ret);
120164
- };
120165
- imports.wbg.__wbg_self_99737b4dcdf6f0d8 = function() {
120166
- return handleError(function() {
120167
- const ret = self.self;
120168
- return addHeapObject(ret);
120169
- }, arguments);
120170
- };
120171
- imports.wbg.__wbg_window_9b61fbbf3564c4fb = function() {
120172
- return handleError(function() {
120173
- const ret = window.window;
120174
- return addHeapObject(ret);
120175
- }, arguments);
120176
- };
120177
- imports.wbg.__wbg_globalThis_8e275ef40caea3a3 = function() {
120178
- return handleError(function() {
120179
- const ret = globalThis.globalThis;
120180
- return addHeapObject(ret);
120181
- }, arguments);
120182
- };
120183
- imports.wbg.__wbg_global_5de1e0f82bddcd27 = function() {
120184
- return handleError(function() {
120185
- const ret = global.global;
120186
- return addHeapObject(ret);
120187
- }, arguments);
120188
- };
120189
- imports.wbg.__wbg_buffer_7af23f65f6c64548 = function(arg0) {
120190
- const ret = getObject(arg0).buffer;
120191
- return addHeapObject(ret);
120192
- };
120193
- imports.wbg.__wbg_newwithbyteoffsetandlength_ce1e75f0ce5f7974 = function(arg0, arg1, arg2) {
120194
- const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
120195
- return addHeapObject(ret);
120196
- };
120197
- imports.wbg.__wbg_new_cc9018bd6f283b6f = function(arg0) {
120198
- const ret = new Uint8Array(getObject(arg0));
120199
- return addHeapObject(ret);
120200
- };
120201
- imports.wbg.__wbg_set_f25e869e4565d2a2 = function(arg0, arg1, arg2) {
120202
- getObject(arg0).set(getObject(arg1), arg2 >>> 0);
120203
- };
120204
- imports.wbg.__wbg_length_0acb1cf9bbaf8519 = function(arg0) {
120205
- const ret = getObject(arg0).length;
120206
- return ret;
120207
- };
120208
- imports.wbg.__wbg_newwithlength_8f0657faca9f1422 = function(arg0) {
120209
- const ret = new Uint8Array(arg0 >>> 0);
120210
- return addHeapObject(ret);
120211
- };
120212
- imports.wbg.__wbg_subarray_da527dbd24eafb6b = function(arg0, arg1, arg2) {
120213
- const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
120214
- return addHeapObject(ret);
120215
- };
120216
- imports.wbg.__wbg_has_ce995ec88636803d = function() {
120217
- return handleError(function(arg0, arg1) {
120218
- const ret = Reflect.has(getObject(arg0), getObject(arg1));
120219
- return ret;
120220
- }, arguments);
120221
- };
120222
- imports.wbg.__wbg_set_93b1c87ee2af852e = function() {
120223
- return handleError(function(arg0, arg1, arg2) {
120224
- const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
120225
- return ret;
120226
- }, arguments);
120227
- };
120228
- imports.wbg.__wbg_stringify_c760003feffcc1f2 = function() {
120229
- return handleError(function(arg0) {
120230
- const ret = JSON.stringify(getObject(arg0));
120231
- return addHeapObject(ret);
120232
- }, arguments);
120233
- };
120234
- imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
120235
- const ret = debugString(getObject(arg1));
120236
- const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
120237
- const len0 = WASM_VECTOR_LEN;
120238
- getInt32Memory0()[arg0 / 4 + 1] = len0;
120239
- getInt32Memory0()[arg0 / 4 + 0] = ptr0;
120240
- };
120241
- imports.wbg.__wbindgen_throw = function(arg0, arg1) {
120242
- throw new Error(getStringFromWasm0(arg0, arg1));
120243
- };
120244
- imports.wbg.__wbindgen_memory = function() {
120245
- const ret = wasm.memory;
120246
- return addHeapObject(ret);
120247
- };
120248
- imports.wbg.__wbindgen_closure_wrapper10902 = function(arg0, arg1, arg2) {
120249
- const ret = makeMutClosure(arg0, arg1, 3717, __wbg_adapter_24);
120250
- return addHeapObject(ret);
120251
- };
120252
- if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
120253
- input = fetch(input);
120254
- }
120255
- const { instance, module } = yield load(yield input, imports);
120256
- wasm = instance.exports;
120257
- init.__wbindgen_wasm_module = module;
120258
- return wasm;
120259
- });
120260
- }
120261
- __name(init, "init");
120262
- var didkit_wasm_default = init;
120263
- var initialized = false;
120264
- var init2 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/jXExSjNXSerFVDMIYOgy") => __async$1(void 0, null, function* () {
120265
- if (initialized)
120266
- return;
120267
- initialized = true;
120268
- return didkit_wasm_default(arg);
120269
- }), "init");
120270
- var didkit_default = init2;
120271
- if (typeof window === "undefined")
120272
- globalThis.crypto = crypto2;
120273
- var addPluginToWallet = /* @__PURE__ */ __name((wallet, plugin) => __async$1(void 0, null, function* () {
120274
- return generateWallet(wallet.contents, {
120275
- plugins: [...wallet.plugins, plugin]
120276
- });
120277
- }), "addPluginToWallet");
120278
- var addToWallet = /* @__PURE__ */ __name((wallet, content) => __async$1(void 0, null, function* () {
120279
- return generateWallet([...wallet.contents, content], wallet);
120280
- }), "addToWallet");
120281
- var removeFromWallet = /* @__PURE__ */ __name((wallet, contentId) => __async$1(void 0, null, function* () {
120282
- const clonedContents = JSON.parse(JSON.stringify(wallet.contents));
120283
- const content = clonedContents.find((c) => c.id === contentId);
120284
- return generateWallet(clonedContents.filter((i) => i.id !== content.id), wallet);
120285
- }), "removeFromWallet");
120286
- var bindMethods = /* @__PURE__ */ __name((wallet, pluginMethods) => Object.fromEntries(Object.entries(pluginMethods).map(([key2, method]) => [key2, method.bind(wallet, wallet)])), "bindMethods");
120287
- var generateWallet = /* @__PURE__ */ __name((..._0) => __async$1(void 0, [..._0], function* (contents = [], _wallet = {}) {
120288
- const { plugins = [] } = _wallet;
120289
- const pluginMethods = plugins.reduce((cumulativePluginMethods, plugin) => {
120290
- const newPluginMethods = __spreadValues(__spreadValues({}, cumulativePluginMethods), plugin.pluginMethods);
120291
- return newPluginMethods;
120292
- }, {});
120293
- const wallet = {
120294
- contents: [...contents],
120295
- add: function(content) {
120296
- return addToWallet(this, content);
120297
- },
120298
- remove: function(contentId) {
120299
- return removeFromWallet(this, contentId);
120300
- },
120301
- status: "UNLOCKED",
120302
- plugins,
120303
- pluginMethods,
120304
- addPlugin: function(plugin) {
120305
- return addPluginToWallet(this, plugin);
120306
- }
120307
- };
120308
- if (pluginMethods)
120309
- wallet.pluginMethods = bindMethods(wallet, pluginMethods);
120310
- return wallet;
120311
- }), "generateWallet");
120312
- function _catch(body, recover) {
120313
- try {
120314
- var result = body();
120315
- } catch (e) {
120316
- return recover(e);
120317
- }
120318
- if (result && result.then) {
120319
- return result.then(void 0, recover);
120320
- }
120321
- return result;
120322
- }
120323
- __name(_catch, "_catch");
120324
- function inMemoryCache() {
120325
- const cache = /* @__PURE__ */ new Map();
120326
- return function(parsed, resolve) {
120327
- try {
120328
- let _temp2 = function(_result) {
120329
- if (_exit)
120330
- return _result;
120331
- const cached = cache.get(parsed.didUrl);
120332
- return cached !== void 0 ? cached : Promise.resolve(resolve()).then(function(result) {
120333
- var _result$didResolution;
120334
- if (((_result$didResolution = result.didResolutionMetadata) == null ? void 0 : _result$didResolution.error) !== "notFound") {
120335
- cache.set(parsed.didUrl, result);
120336
- }
120337
- return result;
120338
- });
120339
- };
120340
- __name(_temp2, "_temp2");
120341
- let _exit;
120342
- const _temp = function() {
120343
- if (parsed.params && parsed.params["no-cache"] === "true") {
120344
- return Promise.resolve(resolve()).then(function(_await$resolve) {
120345
- _exit = 1;
120346
- return _await$resolve;
120347
- });
120348
- }
120349
- }();
120350
- return Promise.resolve(_temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp));
120351
- } catch (e) {
120352
- return Promise.reject(e);
120353
- }
120354
- };
120355
- }
120356
- __name(inMemoryCache, "inMemoryCache");
120357
- function noCache(parsed, resolve) {
120358
- return resolve();
120359
- }
120360
- __name(noCache, "noCache");
120361
- var PCT_ENCODED = "(?:%[0-9a-fA-F]{2})";
120362
- var ID_CHAR = `(?:[a-zA-Z0-9._-]|${PCT_ENCODED})`;
120363
- var METHOD = "([a-z0-9]+)";
120364
- var METHOD_ID = `((?:${ID_CHAR}*:)*(${ID_CHAR}+))`;
120365
- var PARAM_CHAR = "[a-zA-Z0-9_.:%-]";
120366
- var PARAM = `;${PARAM_CHAR}+=${PARAM_CHAR}*`;
120367
- var PARAMS = `((${PARAM})*)`;
120368
- var PATH = `(/[^#?]*)?`;
120369
- var QUERY = `([?][^#]*)?`;
120370
- var FRAGMENT = `(#.*)?`;
120371
- var DID_MATCHER = new RegExp(`^did:${METHOD}:${METHOD_ID}${PARAMS}${PATH}${QUERY}${FRAGMENT}$`);
120372
- function parse(didUrl) {
120373
- if (didUrl === "" || !didUrl)
120374
- return null;
120375
- const sections = didUrl.match(DID_MATCHER);
120376
- if (sections) {
120377
- const parts = {
120378
- did: `did:${sections[1]}:${sections[2]}`,
120379
- method: sections[1],
120380
- id: sections[2],
120381
- didUrl
120382
- };
120383
- if (sections[4]) {
120384
- const params = sections[4].slice(1).split(";");
120385
- parts.params = {};
120386
- for (const p of params) {
120387
- const kv = p.split("=");
120388
- parts.params[kv[0]] = kv[1];
120389
- }
120390
- }
120391
- if (sections[6])
120392
- parts.path = sections[6];
120393
- if (sections[7])
120394
- parts.query = sections[7].slice(1);
120395
- if (sections[8])
120396
- parts.fragment = sections[8].slice(1);
120397
- return parts;
120398
- }
120399
- return null;
120400
- }
120401
- __name(parse, "parse");
120402
- var EMPTY_RESULT = {
120403
- didResolutionMetadata: {},
120404
- didDocument: null,
120405
- didDocumentMetadata: {}
120406
- };
120407
- function wrapLegacyResolver(resolve) {
120408
- return function(did, parsed, resolver) {
120409
- try {
120410
- return Promise.resolve(_catch(function() {
120411
- return Promise.resolve(resolve(did, parsed, resolver)).then(function(doc) {
120412
- return __spreadProps(__spreadValues({}, EMPTY_RESULT), {
120413
- didResolutionMetadata: {
120414
- contentType: "application/did+ld+json"
120415
- },
120416
- didDocument: doc
120417
- });
120418
- });
120419
- }, function(e) {
120420
- return __spreadProps(__spreadValues({}, EMPTY_RESULT), {
120421
- didResolutionMetadata: {
120422
- error: "notFound",
120423
- message: e.toString()
120424
- }
120425
- });
120426
- }));
120427
- } catch (e) {
120428
- return Promise.reject(e);
120429
- }
120430
- };
120431
- }
120432
- __name(wrapLegacyResolver, "wrapLegacyResolver");
120433
- var Resolver = class {
120434
- constructor(registry2 = {}, options = {}) {
120435
- this.registry = void 0;
120436
- this.cache = void 0;
120437
- this.registry = registry2;
120438
- this.cache = options.cache === true ? inMemoryCache() : options.cache || noCache;
120439
- if (options.legacyResolvers) {
120440
- Object.keys(options.legacyResolvers).map((methodName) => {
120441
- if (!this.registry[methodName]) {
120442
- this.registry[methodName] = wrapLegacyResolver(options.legacyResolvers[methodName]);
120443
- }
120444
- });
120445
- }
120446
- }
120447
- resolve(didUrl, options = {}) {
120448
- try {
120449
- const _this = this;
120450
- const parsed = parse(didUrl);
120451
- if (parsed === null) {
120452
- return Promise.resolve(__spreadProps(__spreadValues({}, EMPTY_RESULT), {
120453
- didResolutionMetadata: {
120454
- error: "invalidDid"
120455
- }
120456
- }));
120457
- }
120458
- const resolver = _this.registry[parsed.method];
120459
- if (!resolver) {
120460
- return Promise.resolve(__spreadProps(__spreadValues({}, EMPTY_RESULT), {
120461
- didResolutionMetadata: {
120462
- error: "unsupportedDidMethod"
120463
- }
120464
- }));
120465
- }
120466
- return Promise.resolve(_this.cache(parsed, () => resolver(parsed.did, parsed, _this, options)));
120467
- } catch (e) {
120468
- return Promise.reject(e);
120469
- }
120470
- }
120471
- };
120472
- __name(Resolver, "Resolver");
120473
- init_concat();
120474
- init_from_string();
120475
- init_to_string();
120476
- init_basics();
120477
- var import_sha256 = __toESM(require_sha256());
120478
- var import_js_sha3 = __toESM(require_sha3());
120479
- var import_elliptic = __toESM(require_elliptic());
120480
- var import_ed25519 = __toESM(require_ed25519());
120481
- var import_canonicalize = __toESM(require_canonicalize());
120482
- var import_x25519 = __toESM(require_x25519());
120483
- var import_xchacha20poly1305 = __toESM(require_xchacha20poly1305());
120484
- var import_random = __toESM(require_random());
120485
- function bytesToBase64url(b) {
120486
- return toString3(b, "base64url");
120487
- }
120488
- __name(bytesToBase64url, "bytesToBase64url");
120489
- function base64ToBytes(s) {
120490
- const inputBase64Url = s.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
120491
- return fromString2(inputBase64Url, "base64url");
120492
- }
120493
- __name(base64ToBytes, "base64ToBytes");
120494
- function base58ToBytes(s) {
120495
- return fromString2(s, "base58btc");
120496
- }
120497
- __name(base58ToBytes, "base58ToBytes");
120498
- function hexToBytes(s) {
120499
- const input = s.startsWith("0x") ? s.substring(2) : s;
120500
- return fromString2(input.toLowerCase(), "base16");
120501
- }
120502
- __name(hexToBytes, "hexToBytes");
120503
- function encodeBase64url(s) {
120504
- return bytesToBase64url(fromString2(s));
120505
- }
120506
- __name(encodeBase64url, "encodeBase64url");
120507
- function decodeBase64url(s) {
120508
- return toString3(base64ToBytes(s));
120509
- }
120510
- __name(decodeBase64url, "decodeBase64url");
120511
- function bytesToHex(b) {
120512
- return toString3(b, "base16");
120513
- }
120514
- __name(bytesToHex, "bytesToHex");
120515
- function stringToBytes(s) {
120516
- return fromString2(s);
120517
- }
120518
- __name(stringToBytes, "stringToBytes");
120519
- function toJose({
120520
- r,
120521
- s,
120522
- recoveryParam
120523
- }, recoverable) {
120524
- const jose = new Uint8Array(recoverable ? 65 : 64);
120525
- jose.set(fromString2(r, "base16"), 0);
120526
- jose.set(fromString2(s, "base16"), 32);
120527
- if (recoverable) {
120528
- if (typeof recoveryParam === "undefined") {
120529
- throw new Error("Signer did not return a recoveryParam");
120530
- }
120531
- jose[64] = recoveryParam;
120532
- }
120533
- return bytesToBase64url(jose);
120534
- }
120535
- __name(toJose, "toJose");
120536
- function fromJose(signature2) {
120537
- const signatureBytes = base64ToBytes(signature2);
120538
- if (signatureBytes.length < 64 || signatureBytes.length > 65) {
120539
- throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${signatureBytes.length}`);
120540
- }
120541
- const r = bytesToHex(signatureBytes.slice(0, 32));
120542
- const s = bytesToHex(signatureBytes.slice(32, 64));
120543
- const recoveryParam = signatureBytes.length === 65 ? signatureBytes[64] : void 0;
120544
- return {
120545
- r,
120546
- s,
120547
- recoveryParam
120548
- };
120549
- }
120550
- __name(fromJose, "fromJose");
120551
- function toSealed(ciphertext, tag) {
120552
- return concat([base64ToBytes(ciphertext), base64ToBytes(tag)]);
120553
- }
120554
- __name(toSealed, "toSealed");
120555
- var hexMatcher = /^(0x)?([a-fA-F0-9]{64}|[a-fA-F0-9]{128})$/;
120556
- var base58Matcher = /^([1-9A-HJ-NP-Za-km-z]{44}|[1-9A-HJ-NP-Za-km-z]{88})$/;
120557
- var base64Matcher = /^([0-9a-zA-Z=\-_+/]{43}|[0-9a-zA-Z=\-_+/]{86})(={0,2})$/;
120558
- function parseKey(input) {
120559
- if (typeof input === "string") {
120560
- if (hexMatcher.test(input)) {
120561
- return hexToBytes(input);
120562
- } else if (base58Matcher.test(input)) {
120563
- return base58ToBytes(input);
120564
- } else if (base64Matcher.test(input)) {
120565
- return base64ToBytes(input);
120566
- } else {
120567
- throw TypeError("bad_key: Invalid private key format");
120568
- }
120569
- } else if (input instanceof Uint8Array) {
120570
- return input;
120571
- } else {
120572
- throw TypeError("bad_key: Invalid private key format");
120573
- }
120574
- }
120575
- __name(parseKey, "parseKey");
120576
- function sha2562(payload) {
120577
- const data = typeof payload === "string" ? fromString2(payload) : payload;
120578
- return (0, import_sha256.hash)(data);
120579
- }
120580
- __name(sha2562, "sha256");
120581
- function keccak(data) {
120582
- return new Uint8Array(import_js_sha3.keccak_256.arrayBuffer(data));
120583
- }
120584
- __name(keccak, "keccak");
120585
- function toEthereumAddress(hexPublicKey) {
120586
- const hashInput = fromString2(hexPublicKey.slice(2), "base16");
120587
- return `0x${toString3(keccak(hashInput).slice(-20), "base16")}`;
120588
- }
120589
- __name(toEthereumAddress, "toEthereumAddress");
120590
- function writeUint32BE(value, array = new Uint8Array(4)) {
120591
- const encoded = fromString2(value.toString(), "base10");
120592
- array.set(encoded, 4 - encoded.length);
120593
- return array;
120594
- }
120595
- __name(writeUint32BE, "writeUint32BE");
120596
- var lengthAndInput = /* @__PURE__ */ __name((input) => concat([writeUint32BE(input.length), input]), "lengthAndInput");
120597
- function concatKDF(secret, keyLen, alg, producerInfo, consumerInfo) {
120598
- if (keyLen !== 256)
120599
- throw new Error(`Unsupported key length: ${keyLen}`);
120600
- const value = concat([lengthAndInput(fromString2(alg)), lengthAndInput(typeof producerInfo === "undefined" ? new Uint8Array(0) : producerInfo), lengthAndInput(typeof consumerInfo === "undefined" ? new Uint8Array(0) : consumerInfo), writeUint32BE(keyLen)]);
120601
- const roundNumber = 1;
120602
- return (0, import_sha256.hash)(concat([writeUint32BE(roundNumber), secret, value]));
120603
- }
120604
- __name(concatKDF, "concatKDF");
120605
- new import_elliptic.ec("secp256k1");
120606
- function EdDSASigner(secretKey) {
120607
- const privateKeyBytes = parseKey(secretKey);
120608
- if (privateKeyBytes.length !== 64) {
120609
- throw new Error(`bad_key: Invalid private key format. Expecting 64 bytes, but got ${privateKeyBytes.length}`);
120610
- }
120611
- return function(data) {
120612
- try {
120613
- const dataBytes = typeof data === "string" ? stringToBytes(data) : data;
120614
- const sig = (0, import_ed25519.sign)(privateKeyBytes, dataBytes);
120615
- return Promise.resolve(bytesToBase64url(sig));
120616
- } catch (e) {
120617
- return Promise.reject(e);
120618
- }
120619
- };
120620
- }
120621
- __name(EdDSASigner, "EdDSASigner");
120622
- function instanceOfEcdsaSignature(object) {
120623
- return typeof object === "object" && "r" in object && "s" in object;
120624
- }
120625
- __name(instanceOfEcdsaSignature, "instanceOfEcdsaSignature");
120626
- function ES256KSignerAlg(recoverable) {
120627
- return /* @__PURE__ */ __name(function sign5(payload, signer) {
120628
- try {
120629
- return Promise.resolve(signer(payload)).then(function(signature2) {
120630
- if (instanceOfEcdsaSignature(signature2)) {
120631
- return toJose(signature2, recoverable);
120632
- } else {
120633
- if (recoverable && typeof fromJose(signature2).recoveryParam === "undefined") {
120634
- throw new Error(`not_supported: ES256K-R not supported when signer doesn't provide a recovery param`);
120635
- }
120636
- return signature2;
120637
- }
120638
- });
120639
- } catch (e) {
120640
- return Promise.reject(e);
120641
- }
120642
- }, "sign");
120643
- }
120644
- __name(ES256KSignerAlg, "ES256KSignerAlg");
120645
- function Ed25519SignerAlg() {
120646
- return /* @__PURE__ */ __name(function sign5(payload, signer) {
120647
- try {
120648
- return Promise.resolve(signer(payload)).then(function(signature2) {
120649
- if (!instanceOfEcdsaSignature(signature2)) {
120650
- return signature2;
120651
- } else {
120652
- throw new Error("invalid_config: expected a signer function that returns a string instead of signature object");
120653
- }
120654
- });
120655
- } catch (e) {
120656
- return Promise.reject(e);
120657
- }
120658
- }, "sign");
120659
- }
120660
- __name(Ed25519SignerAlg, "Ed25519SignerAlg");
120661
- var algorithms$1 = {
120662
- ES256K: ES256KSignerAlg(),
120663
- "ES256K-R": ES256KSignerAlg(true),
120664
- Ed25519: Ed25519SignerAlg(),
120665
- EdDSA: Ed25519SignerAlg()
120666
- };
120667
- function SignerAlg(alg) {
120668
- const impl = algorithms$1[alg];
120669
- if (!impl)
120670
- throw new Error(`not_supported: Unsupported algorithm ${alg}`);
120671
- return impl;
120672
- }
120673
- __name(SignerAlg, "SignerAlg");
120674
- var secp256k1 = new import_elliptic.ec("secp256k1");
120675
- function toSignatureObject(signature2, recoverable = false) {
120676
- const rawSig = base64ToBytes(signature2);
120677
- if (rawSig.length !== (recoverable ? 65 : 64)) {
120678
- throw new Error("wrong signature length");
120679
- }
120680
- const r = bytesToHex(rawSig.slice(0, 32));
120681
- const s = bytesToHex(rawSig.slice(32, 64));
120682
- const sigObj = {
120683
- r,
120684
- s
120685
- };
120686
- if (recoverable) {
120687
- sigObj.recoveryParam = rawSig[64];
120688
- }
120689
- return sigObj;
120690
- }
120691
- __name(toSignatureObject, "toSignatureObject");
120692
- function extractPublicKeyBytes(pk) {
120693
- if (pk.publicKeyBase58) {
120694
- return base58ToBytes(pk.publicKeyBase58);
120695
- } else if (pk.publicKeyBase64) {
120696
- return base64ToBytes(pk.publicKeyBase64);
120697
- } else if (pk.publicKeyHex) {
120698
- return hexToBytes(pk.publicKeyHex);
120699
- } else if (pk.publicKeyJwk && pk.publicKeyJwk.crv === "secp256k1" && pk.publicKeyJwk.x && pk.publicKeyJwk.y) {
120700
- return hexToBytes(secp256k1.keyFromPublic({
120701
- x: bytesToHex(base64ToBytes(pk.publicKeyJwk.x)),
120702
- y: bytesToHex(base64ToBytes(pk.publicKeyJwk.y))
120703
- }).getPublic("hex"));
120704
- } else if (pk.publicKeyMultibase) {
120705
- const {
120706
- base16: base162,
120707
- base58btc: base58btc2,
120708
- base64: base642,
120709
- base64url: base64url2
120710
- } = bases;
120711
- const baseDecoder = base162.decoder.or(base58btc2.decoder.or(base642.decoder.or(base64url2.decoder)));
120712
- return baseDecoder.decode(pk.publicKeyMultibase);
120713
- }
120714
- return new Uint8Array();
120715
- }
120716
- __name(extractPublicKeyBytes, "extractPublicKeyBytes");
120717
- function verifyES256K(data, signature2, authenticators) {
120718
- const hash3 = sha2562(data);
120719
- const sigObj = toSignatureObject(signature2);
120720
- const fullPublicKeys = authenticators.filter(({
120721
- ethereumAddress,
120722
- blockchainAccountId
120723
- }) => {
120724
- return typeof ethereumAddress === "undefined" && typeof blockchainAccountId === "undefined";
120725
- });
120726
- const ethAddressKeys = authenticators.filter(({
120727
- ethereumAddress,
120728
- blockchainAccountId
120729
- }) => {
120730
- return typeof ethereumAddress !== "undefined" || typeof blockchainAccountId !== void 0;
120731
- });
120732
- let signer = fullPublicKeys.find((pk) => {
120733
- try {
120734
- const pubBytes = extractPublicKeyBytes(pk);
120735
- return secp256k1.keyFromPublic(pubBytes).verify(hash3, sigObj);
120736
- } catch (err) {
120737
- return false;
120738
- }
120739
- });
120740
- if (!signer && ethAddressKeys.length > 0) {
120741
- signer = verifyRecoverableES256K(data, signature2, ethAddressKeys);
120742
- }
120743
- if (!signer)
120744
- throw new Error("invalid_signature: Signature invalid for JWT");
120745
- return signer;
120092
+ if (!signer && ethAddressKeys.length > 0) {
120093
+ signer = verifyRecoverableES256K(data, signature2, ethAddressKeys);
120094
+ }
120095
+ if (!signer)
120096
+ throw new Error("invalid_signature: Signature invalid for JWT");
120097
+ return signer;
120746
120098
  }
120747
120099
  __name(verifyES256K, "verifyES256K");
120748
120100
  function verifyRecoverableES256K(data, signature2, authenticators) {
@@ -122263,7 +121615,7 @@ function decodeString64(data, pos, _minor, options) {
122263
121615
  return toToken2(data, pos, 9, l, options);
122264
121616
  }
122265
121617
  __name(decodeString64, "decodeString64");
122266
- var encodeString2 = encodeBytes;
121618
+ var encodeString = encodeBytes;
122267
121619
  function toToken3(_data, _pos, prefix, length2) {
122268
121620
  return new Token(Type.array, length2, prefix);
122269
121621
  }
@@ -122731,7 +122083,7 @@ function makeCborEncoders() {
122731
122083
  encoders[Type.uint.major] = encodeUint;
122732
122084
  encoders[Type.negint.major] = encodeNegint;
122733
122085
  encoders[Type.bytes.major] = encodeBytes;
122734
- encoders[Type.string.major] = encodeString2;
122086
+ encoders[Type.string.major] = encodeString;
122735
122087
  encoders[Type.array.major] = encodeArray;
122736
122088
  encoders[Type.map.major] = encodeMap;
122737
122089
  encoders[Type.tag.major] = encodeTag;
@@ -125917,7 +125269,7 @@ function HmacDRBG(options) {
125917
125269
  }
125918
125270
  __name(HmacDRBG, "HmacDRBG");
125919
125271
  var hmacDrbg = HmacDRBG;
125920
- HmacDRBG.prototype._init = /* @__PURE__ */ __name(function init3(entropy, nonce, pers) {
125272
+ HmacDRBG.prototype._init = /* @__PURE__ */ __name(function init(entropy, nonce, pers) {
125921
125273
  var seed = entropy.concat(nonce).concat(pers);
125922
125274
  this.K = new Array(this.outLen / 8);
125923
125275
  this.V = new Array(this.outLen / 8);
@@ -132574,10 +131926,9 @@ var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async$1(void 0,
132574
131926
  if (key2.length > 64)
132575
131927
  throw new Error("Key must be less than 64 characters");
132576
131928
  const keypair = wallet.pluginMethods.generateEd25519KeyFromBytes(toUint8Array(key2.padStart(64, "0")));
132577
- const did = wallet.pluginMethods.keyToDid("key", keypair);
132578
131929
  return {
132579
131930
  pluginMethods: {
132580
- getSubjectDid: () => did,
131931
+ getSubjectDid: (_wallet, type) => wallet.pluginMethods.keyToDid(type, keypair),
132581
131932
  getSubjectKeypair: () => keypair,
132582
131933
  getKey: () => key2.padStart(64, "0")
132583
131934
  }
@@ -132596,7 +131947,8 @@ var ExpirationPlugin = /* @__PURE__ */ __name((wallet) => ({
132596
131947
  })
132597
131948
  }
132598
131949
  }), "ExpirationPlugin");
132599
- var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
131950
+ var recycleDependents = /* @__PURE__ */ __name((_methods) => ({}), "recycleDependents");
131951
+ var issueCredential = /* @__PURE__ */ __name((initWallet) => {
132600
131952
  return (wallet, credential) => __async$1(void 0, null, function* () {
132601
131953
  const kp = wallet.pluginMethods.getSubjectKeypair();
132602
131954
  if (!kp)
@@ -132608,14 +131960,14 @@ var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
132608
131960
  return initWallet.pluginMethods.issueCredential(credential, options, kp);
132609
131961
  });
132610
131962
  }, "issueCredential");
132611
- var verifyCredential2 = /* @__PURE__ */ __name((initWallet) => {
131963
+ var verifyCredential = /* @__PURE__ */ __name((initWallet) => {
132612
131964
  return (_wallet, credential) => __async$1(void 0, null, function* () {
132613
131965
  return initWallet.pluginMethods.verifyCredential(credential);
132614
131966
  });
132615
131967
  }, "verifyCredential");
132616
- var issuePresentation2 = /* @__PURE__ */ __name((initWallet) => {
131968
+ var issuePresentation = /* @__PURE__ */ __name((initWallet) => {
132617
131969
  return (wallet, credential) => __async$1(void 0, null, function* () {
132618
- const did = wallet.pluginMethods.getSubjectDid();
131970
+ const did = wallet.pluginMethods.getSubjectDid("key");
132619
131971
  if (!did)
132620
131972
  throw new Error("Cannot create presentation: No holder key found");
132621
131973
  const holder = did;
@@ -132635,20 +131987,20 @@ var issuePresentation2 = /* @__PURE__ */ __name((initWallet) => {
132635
131987
  return initWallet.pluginMethods.issuePresentation(presentation, options, kp);
132636
131988
  });
132637
131989
  }, "issuePresentation");
132638
- var verifyPresentation2 = /* @__PURE__ */ __name((initWallet) => {
131990
+ var verifyPresentation = /* @__PURE__ */ __name((initWallet) => {
132639
131991
  return (_wallet, presentation) => __async$1(void 0, null, function* () {
132640
131992
  return initWallet.pluginMethods.verifyPresentation(presentation);
132641
131993
  });
132642
131994
  }, "verifyPresentation");
132643
131995
  var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async$1(void 0, null, function* () {
132644
131996
  return {
132645
- pluginMethods: __spreadProps(__spreadValues({}, wallet.pluginMethods), {
132646
- issueCredential: issueCredential2(wallet),
132647
- verifyCredential: verifyCredential2(wallet),
132648
- issuePresentation: issuePresentation2(wallet),
132649
- verifyPresentation: verifyPresentation2(wallet),
131997
+ pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
131998
+ issueCredential: issueCredential(wallet),
131999
+ verifyCredential: verifyCredential(wallet),
132000
+ issuePresentation: issuePresentation(wallet),
132001
+ verifyPresentation: verifyPresentation(wallet),
132650
132002
  getTestVc: (_wallet, subject = "did:example:d23dd687a7dc6787646f2eb98d0") => {
132651
- const did = _wallet.pluginMethods.getSubjectDid();
132003
+ const did = _wallet.pluginMethods.getSubjectDid("key");
132652
132004
  return {
132653
132005
  "@context": ["https://www.w3.org/2018/credentials/v1"],
132654
132006
  id: "http://example.org/credentials/3731",
@@ -136857,431 +136209,1088 @@ var formatters2 = {
136857
136209
  });
136858
136210
  case "BBBB":
136859
136211
  default:
136860
- return localize2.dayPeriod(dayPeriodEnumValue, {
136861
- width: "wide",
136862
- context: "formatting"
136863
- });
136212
+ return localize2.dayPeriod(dayPeriodEnumValue, {
136213
+ width: "wide",
136214
+ context: "formatting"
136215
+ });
136216
+ }
136217
+ },
136218
+ h: function(date, token, localize2) {
136219
+ if (token === "ho") {
136220
+ var hours = date.getUTCHours() % 12;
136221
+ if (hours === 0)
136222
+ hours = 12;
136223
+ return localize2.ordinalNumber(hours, {
136224
+ unit: "hour"
136225
+ });
136226
+ }
136227
+ return lightFormatters_default.h(date, token);
136228
+ },
136229
+ H: function(date, token, localize2) {
136230
+ if (token === "Ho") {
136231
+ return localize2.ordinalNumber(date.getUTCHours(), {
136232
+ unit: "hour"
136233
+ });
136234
+ }
136235
+ return lightFormatters_default.H(date, token);
136236
+ },
136237
+ K: function(date, token, localize2) {
136238
+ var hours = date.getUTCHours() % 12;
136239
+ if (token === "Ko") {
136240
+ return localize2.ordinalNumber(hours, {
136241
+ unit: "hour"
136242
+ });
136243
+ }
136244
+ return addLeadingZeros(hours, token.length);
136245
+ },
136246
+ k: function(date, token, localize2) {
136247
+ var hours = date.getUTCHours();
136248
+ if (hours === 0)
136249
+ hours = 24;
136250
+ if (token === "ko") {
136251
+ return localize2.ordinalNumber(hours, {
136252
+ unit: "hour"
136253
+ });
136254
+ }
136255
+ return addLeadingZeros(hours, token.length);
136256
+ },
136257
+ m: function(date, token, localize2) {
136258
+ if (token === "mo") {
136259
+ return localize2.ordinalNumber(date.getUTCMinutes(), {
136260
+ unit: "minute"
136261
+ });
136262
+ }
136263
+ return lightFormatters_default.m(date, token);
136264
+ },
136265
+ s: function(date, token, localize2) {
136266
+ if (token === "so") {
136267
+ return localize2.ordinalNumber(date.getUTCSeconds(), {
136268
+ unit: "second"
136269
+ });
136270
+ }
136271
+ return lightFormatters_default.s(date, token);
136272
+ },
136273
+ S: function(date, token) {
136274
+ return lightFormatters_default.S(date, token);
136275
+ },
136276
+ X: function(date, token, _localize, options) {
136277
+ var originalDate = options._originalDate || date;
136278
+ var timezoneOffset = originalDate.getTimezoneOffset();
136279
+ if (timezoneOffset === 0) {
136280
+ return "Z";
136281
+ }
136282
+ switch (token) {
136283
+ case "X":
136284
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
136285
+ case "XXXX":
136286
+ case "XX":
136287
+ return formatTimezone(timezoneOffset);
136288
+ case "XXXXX":
136289
+ case "XXX":
136290
+ default:
136291
+ return formatTimezone(timezoneOffset, ":");
136292
+ }
136293
+ },
136294
+ x: function(date, token, _localize, options) {
136295
+ var originalDate = options._originalDate || date;
136296
+ var timezoneOffset = originalDate.getTimezoneOffset();
136297
+ switch (token) {
136298
+ case "x":
136299
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
136300
+ case "xxxx":
136301
+ case "xx":
136302
+ return formatTimezone(timezoneOffset);
136303
+ case "xxxxx":
136304
+ case "xxx":
136305
+ default:
136306
+ return formatTimezone(timezoneOffset, ":");
136864
136307
  }
136865
136308
  },
136866
- h: function(date, token, localize2) {
136867
- if (token === "ho") {
136868
- var hours = date.getUTCHours() % 12;
136869
- if (hours === 0)
136870
- hours = 12;
136871
- return localize2.ordinalNumber(hours, {
136872
- unit: "hour"
136873
- });
136309
+ O: function(date, token, _localize, options) {
136310
+ var originalDate = options._originalDate || date;
136311
+ var timezoneOffset = originalDate.getTimezoneOffset();
136312
+ switch (token) {
136313
+ case "O":
136314
+ case "OO":
136315
+ case "OOO":
136316
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
136317
+ case "OOOO":
136318
+ default:
136319
+ return "GMT" + formatTimezone(timezoneOffset, ":");
136874
136320
  }
136875
- return lightFormatters_default.h(date, token);
136876
136321
  },
136877
- H: function(date, token, localize2) {
136878
- if (token === "Ho") {
136879
- return localize2.ordinalNumber(date.getUTCHours(), {
136880
- unit: "hour"
136881
- });
136322
+ z: function(date, token, _localize, options) {
136323
+ var originalDate = options._originalDate || date;
136324
+ var timezoneOffset = originalDate.getTimezoneOffset();
136325
+ switch (token) {
136326
+ case "z":
136327
+ case "zz":
136328
+ case "zzz":
136329
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
136330
+ case "zzzz":
136331
+ default:
136332
+ return "GMT" + formatTimezone(timezoneOffset, ":");
136882
136333
  }
136883
- return lightFormatters_default.H(date, token);
136884
136334
  },
136885
- K: function(date, token, localize2) {
136886
- var hours = date.getUTCHours() % 12;
136887
- if (token === "Ko") {
136888
- return localize2.ordinalNumber(hours, {
136889
- unit: "hour"
136335
+ t: function(date, token, _localize, options) {
136336
+ var originalDate = options._originalDate || date;
136337
+ var timestamp = Math.floor(originalDate.getTime() / 1e3);
136338
+ return addLeadingZeros(timestamp, token.length);
136339
+ },
136340
+ T: function(date, token, _localize, options) {
136341
+ var originalDate = options._originalDate || date;
136342
+ var timestamp = originalDate.getTime();
136343
+ return addLeadingZeros(timestamp, token.length);
136344
+ }
136345
+ };
136346
+ function formatTimezoneShort(offset, dirtyDelimiter) {
136347
+ var sign5 = offset > 0 ? "-" : "+";
136348
+ var absOffset = Math.abs(offset);
136349
+ var hours = Math.floor(absOffset / 60);
136350
+ var minutes = absOffset % 60;
136351
+ if (minutes === 0) {
136352
+ return sign5 + String(hours);
136353
+ }
136354
+ var delimiter = dirtyDelimiter || "";
136355
+ return sign5 + String(hours) + delimiter + addLeadingZeros(minutes, 2);
136356
+ }
136357
+ __name(formatTimezoneShort, "formatTimezoneShort");
136358
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
136359
+ if (offset % 60 === 0) {
136360
+ var sign5 = offset > 0 ? "-" : "+";
136361
+ return sign5 + addLeadingZeros(Math.abs(offset) / 60, 2);
136362
+ }
136363
+ return formatTimezone(offset, dirtyDelimiter);
136364
+ }
136365
+ __name(formatTimezoneWithOptionalMinutes, "formatTimezoneWithOptionalMinutes");
136366
+ function formatTimezone(offset, dirtyDelimiter) {
136367
+ var delimiter = dirtyDelimiter || "";
136368
+ var sign5 = offset > 0 ? "-" : "+";
136369
+ var absOffset = Math.abs(offset);
136370
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
136371
+ var minutes = addLeadingZeros(absOffset % 60, 2);
136372
+ return sign5 + hours + delimiter + minutes;
136373
+ }
136374
+ __name(formatTimezone, "formatTimezone");
136375
+ var formatters_default = formatters2;
136376
+ function dateLongFormatter(pattern, formatLong2) {
136377
+ switch (pattern) {
136378
+ case "P":
136379
+ return formatLong2.date({
136380
+ width: "short"
136381
+ });
136382
+ case "PP":
136383
+ return formatLong2.date({
136384
+ width: "medium"
136385
+ });
136386
+ case "PPP":
136387
+ return formatLong2.date({
136388
+ width: "long"
136389
+ });
136390
+ case "PPPP":
136391
+ default:
136392
+ return formatLong2.date({
136393
+ width: "full"
136394
+ });
136395
+ }
136396
+ }
136397
+ __name(dateLongFormatter, "dateLongFormatter");
136398
+ function timeLongFormatter(pattern, formatLong2) {
136399
+ switch (pattern) {
136400
+ case "p":
136401
+ return formatLong2.time({
136402
+ width: "short"
136403
+ });
136404
+ case "pp":
136405
+ return formatLong2.time({
136406
+ width: "medium"
136407
+ });
136408
+ case "ppp":
136409
+ return formatLong2.time({
136410
+ width: "long"
136411
+ });
136412
+ case "pppp":
136413
+ default:
136414
+ return formatLong2.time({
136415
+ width: "full"
136416
+ });
136417
+ }
136418
+ }
136419
+ __name(timeLongFormatter, "timeLongFormatter");
136420
+ function dateTimeLongFormatter(pattern, formatLong2) {
136421
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
136422
+ var datePattern = matchResult[1];
136423
+ var timePattern = matchResult[2];
136424
+ if (!timePattern) {
136425
+ return dateLongFormatter(pattern, formatLong2);
136426
+ }
136427
+ var dateTimeFormat;
136428
+ switch (datePattern) {
136429
+ case "P":
136430
+ dateTimeFormat = formatLong2.dateTime({
136431
+ width: "short"
136432
+ });
136433
+ break;
136434
+ case "PP":
136435
+ dateTimeFormat = formatLong2.dateTime({
136436
+ width: "medium"
136437
+ });
136438
+ break;
136439
+ case "PPP":
136440
+ dateTimeFormat = formatLong2.dateTime({
136441
+ width: "long"
136442
+ });
136443
+ break;
136444
+ case "PPPP":
136445
+ default:
136446
+ dateTimeFormat = formatLong2.dateTime({
136447
+ width: "full"
136890
136448
  });
136449
+ break;
136450
+ }
136451
+ return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
136452
+ }
136453
+ __name(dateTimeLongFormatter, "dateTimeLongFormatter");
136454
+ var longFormatters = {
136455
+ p: timeLongFormatter,
136456
+ P: dateTimeLongFormatter
136457
+ };
136458
+ var longFormatters_default = longFormatters;
136459
+ var protectedDayOfYearTokens = ["D", "DD"];
136460
+ var protectedWeekYearTokens = ["YY", "YYYY"];
136461
+ function isProtectedDayOfYearToken(token) {
136462
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
136463
+ }
136464
+ __name(isProtectedDayOfYearToken, "isProtectedDayOfYearToken");
136465
+ function isProtectedWeekYearToken(token) {
136466
+ return protectedWeekYearTokens.indexOf(token) !== -1;
136467
+ }
136468
+ __name(isProtectedWeekYearToken, "isProtectedWeekYearToken");
136469
+ function throwProtectedError(token, format2, input) {
136470
+ if (token === "YYYY") {
136471
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
136472
+ } else if (token === "YY") {
136473
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
136474
+ } else if (token === "D") {
136475
+ throw new RangeError("Use `d` instead of `D` (in `".concat(format2, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
136476
+ } else if (token === "DD") {
136477
+ throw new RangeError("Use `dd` instead of `DD` (in `".concat(format2, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
136478
+ }
136479
+ }
136480
+ __name(throwProtectedError, "throwProtectedError");
136481
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
136482
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
136483
+ var escapedStringRegExp = /^'([^]*?)'?$/;
136484
+ var doubleQuoteRegExp = /''/g;
136485
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
136486
+ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
136487
+ requiredArgs(2, arguments);
136488
+ var formatStr = String(dirtyFormatStr);
136489
+ var options = dirtyOptions || {};
136490
+ var locale2 = options.locale || en_US_default;
136491
+ var localeFirstWeekContainsDate = locale2.options && locale2.options.firstWeekContainsDate;
136492
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
136493
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
136494
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
136495
+ throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");
136496
+ }
136497
+ var localeWeekStartsOn = locale2.options && locale2.options.weekStartsOn;
136498
+ var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
136499
+ var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn);
136500
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
136501
+ throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");
136502
+ }
136503
+ if (!locale2.localize) {
136504
+ throw new RangeError("locale must contain localize property");
136505
+ }
136506
+ if (!locale2.formatLong) {
136507
+ throw new RangeError("locale must contain formatLong property");
136508
+ }
136509
+ var originalDate = toDate(dirtyDate);
136510
+ if (!isValid2(originalDate)) {
136511
+ throw new RangeError("Invalid time value");
136512
+ }
136513
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
136514
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
136515
+ var formatterOptions = {
136516
+ firstWeekContainsDate,
136517
+ weekStartsOn,
136518
+ locale: locale2,
136519
+ _originalDate: originalDate
136520
+ };
136521
+ var result = formatStr.match(longFormattingTokensRegExp).map(function(substring) {
136522
+ var firstCharacter = substring[0];
136523
+ if (firstCharacter === "p" || firstCharacter === "P") {
136524
+ var longFormatter = longFormatters_default[firstCharacter];
136525
+ return longFormatter(substring, locale2.formatLong, formatterOptions);
136526
+ }
136527
+ return substring;
136528
+ }).join("").match(formattingTokensRegExp).map(function(substring) {
136529
+ if (substring === "''") {
136530
+ return "'";
136531
+ }
136532
+ var firstCharacter = substring[0];
136533
+ if (firstCharacter === "'") {
136534
+ return cleanEscapedString(substring);
136535
+ }
136536
+ var formatter = formatters_default[firstCharacter];
136537
+ if (formatter) {
136538
+ if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
136539
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
136540
+ }
136541
+ if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
136542
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
136543
+ }
136544
+ return formatter(utcDate, substring, locale2.localize, formatterOptions);
136891
136545
  }
136892
- return addLeadingZeros(hours, token.length);
136893
- },
136894
- k: function(date, token, localize2) {
136895
- var hours = date.getUTCHours();
136896
- if (hours === 0)
136897
- hours = 24;
136898
- if (token === "ko") {
136899
- return localize2.ordinalNumber(hours, {
136900
- unit: "hour"
136901
- });
136546
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
136547
+ throw new RangeError("Format string contains an unescaped latin alphabet character `" + firstCharacter + "`");
136902
136548
  }
136903
- return addLeadingZeros(hours, token.length);
136904
- },
136905
- m: function(date, token, localize2) {
136906
- if (token === "mo") {
136907
- return localize2.ordinalNumber(date.getUTCMinutes(), {
136908
- unit: "minute"
136549
+ return substring;
136550
+ }).join("");
136551
+ return result;
136552
+ }
136553
+ __name(format, "format");
136554
+ function cleanEscapedString(input) {
136555
+ return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
136556
+ }
136557
+ __name(cleanEscapedString, "cleanEscapedString");
136558
+ var transformErrorCheck = /* @__PURE__ */ __name((error, _credential) => {
136559
+ const prefix = error.split(" error")[0];
136560
+ return prefix || error;
136561
+ }, "transformErrorCheck");
136562
+ var transformErrorMessage = /* @__PURE__ */ __name((error, credential) => {
136563
+ if (error.startsWith("expiration")) {
136564
+ return credential.expirationDate ? `Invalid \u2022 Expired ${format(new Date(credential.expirationDate), "dd MMM yyyy").toUpperCase()}` : "Invalid \u2022 Expired";
136565
+ }
136566
+ return error;
136567
+ }, "transformErrorMessage");
136568
+ var transformCheckMessage = /* @__PURE__ */ __name((check, credential) => {
136569
+ return {
136570
+ proof: "Valid",
136571
+ expiration: credential.expirationDate ? `Valid \u2022 Expires ${format(new Date(credential.expirationDate), "dd MMM yyyy").toUpperCase()}` : "Valid \u2022 Does Not Expire"
136572
+ }[check] || check;
136573
+ }, "transformCheckMessage");
136574
+ var verifyCredential2 = /* @__PURE__ */ __name((wallet) => {
136575
+ return (credential) => __async$1(void 0, null, function* () {
136576
+ const rawVerificationCheck = yield wallet.pluginMethods.verifyCredential(credential);
136577
+ const verificationItems = [];
136578
+ rawVerificationCheck.errors.forEach((error) => {
136579
+ verificationItems.push({
136580
+ status: VerificationStatusEnum.Failed,
136581
+ check: transformErrorCheck(error, credential),
136582
+ details: transformErrorMessage(error, credential)
136909
136583
  });
136910
- }
136911
- return lightFormatters_default.m(date, token);
136912
- },
136913
- s: function(date, token, localize2) {
136914
- if (token === "so") {
136915
- return localize2.ordinalNumber(date.getUTCSeconds(), {
136916
- unit: "second"
136584
+ });
136585
+ rawVerificationCheck.warnings.forEach((warning) => {
136586
+ verificationItems.push({
136587
+ status: VerificationStatusEnum.Error,
136588
+ check: "hmm",
136589
+ message: warning
136917
136590
  });
136918
- }
136919
- return lightFormatters_default.s(date, token);
136920
- },
136921
- S: function(date, token) {
136922
- return lightFormatters_default.S(date, token);
136591
+ });
136592
+ rawVerificationCheck.checks.forEach((check) => {
136593
+ verificationItems.push({
136594
+ status: VerificationStatusEnum.Success,
136595
+ check,
136596
+ message: transformCheckMessage(check, credential)
136597
+ });
136598
+ });
136599
+ return verificationItems;
136600
+ });
136601
+ }, "verifyCredential");
136602
+ var defaultCeramicIDXArgs = {
136603
+ modelData: {
136604
+ definitions: {
136605
+ MyVerifiableCredentials: "kjzl6cwe1jw14am5tu5hh412s19o4zm8aq3g2lpd6s4paxj2nly2lj4drp3pun2"
136606
+ },
136607
+ schemas: {
136608
+ AchievementVerifiableCredential: "ceramic://k3y52l7qbv1frylibw2725v8gem3hxs1onoh6pvux0szdduugczh0hddxo6qsd6o0",
136609
+ VerifiableCredentialsList: "ceramic://k3y52l7qbv1frxkcwfpyauky3fyl4n44izridy3blvjjzgftis40sk9w8g3remghs"
136610
+ },
136611
+ tiles: {}
136923
136612
  },
136924
- X: function(date, token, _localize, options) {
136925
- var originalDate = options._originalDate || date;
136926
- var timezoneOffset = originalDate.getTimezoneOffset();
136927
- if (timezoneOffset === 0) {
136928
- return "Z";
136613
+ credentialAlias: "MyVerifiableCredentials",
136614
+ ceramicEndpoint: "https://ceramic-node.welibrary.io:7007",
136615
+ defaultContentFamily: "SuperSkills"
136616
+ };
136617
+ var wasm;
136618
+ var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
136619
+ cachedTextDecoder.decode();
136620
+ var cachegetUint8Memory0 = null;
136621
+ function getUint8Memory0() {
136622
+ if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
136623
+ cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
136624
+ }
136625
+ return cachegetUint8Memory0;
136626
+ }
136627
+ __name(getUint8Memory0, "getUint8Memory0");
136628
+ function getStringFromWasm0(ptr, len) {
136629
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
136630
+ }
136631
+ __name(getStringFromWasm0, "getStringFromWasm0");
136632
+ var heap = new Array(32).fill(void 0);
136633
+ heap.push(void 0, null, true, false);
136634
+ var heap_next = heap.length;
136635
+ function addHeapObject(obj) {
136636
+ if (heap_next === heap.length)
136637
+ heap.push(heap.length + 1);
136638
+ const idx = heap_next;
136639
+ heap_next = heap[idx];
136640
+ heap[idx] = obj;
136641
+ return idx;
136642
+ }
136643
+ __name(addHeapObject, "addHeapObject");
136644
+ function getObject(idx) {
136645
+ return heap[idx];
136646
+ }
136647
+ __name(getObject, "getObject");
136648
+ function dropObject(idx) {
136649
+ if (idx < 36)
136650
+ return;
136651
+ heap[idx] = heap_next;
136652
+ heap_next = idx;
136653
+ }
136654
+ __name(dropObject, "dropObject");
136655
+ function takeObject(idx) {
136656
+ const ret = getObject(idx);
136657
+ dropObject(idx);
136658
+ return ret;
136659
+ }
136660
+ __name(takeObject, "takeObject");
136661
+ var WASM_VECTOR_LEN = 0;
136662
+ var cachedTextEncoder = new TextEncoder("utf-8");
136663
+ var encodeString2 = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
136664
+ return cachedTextEncoder.encodeInto(arg, view);
136665
+ } : function(arg, view) {
136666
+ const buf2 = cachedTextEncoder.encode(arg);
136667
+ view.set(buf2);
136668
+ return {
136669
+ read: arg.length,
136670
+ written: buf2.length
136671
+ };
136672
+ };
136673
+ function passStringToWasm0(arg, malloc, realloc) {
136674
+ if (realloc === void 0) {
136675
+ const buf2 = cachedTextEncoder.encode(arg);
136676
+ const ptr2 = malloc(buf2.length);
136677
+ getUint8Memory0().subarray(ptr2, ptr2 + buf2.length).set(buf2);
136678
+ WASM_VECTOR_LEN = buf2.length;
136679
+ return ptr2;
136680
+ }
136681
+ let len = arg.length;
136682
+ let ptr = malloc(len);
136683
+ const mem = getUint8Memory0();
136684
+ let offset = 0;
136685
+ for (; offset < len; offset++) {
136686
+ const code5 = arg.charCodeAt(offset);
136687
+ if (code5 > 127)
136688
+ break;
136689
+ mem[ptr + offset] = code5;
136690
+ }
136691
+ if (offset !== len) {
136692
+ if (offset !== 0) {
136693
+ arg = arg.slice(offset);
136929
136694
  }
136930
- switch (token) {
136931
- case "X":
136932
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
136933
- case "XXXX":
136934
- case "XX":
136935
- return formatTimezone(timezoneOffset);
136936
- case "XXXXX":
136937
- case "XXX":
136938
- default:
136939
- return formatTimezone(timezoneOffset, ":");
136695
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
136696
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
136697
+ const ret = encodeString2(arg, view);
136698
+ offset += ret.written;
136699
+ }
136700
+ WASM_VECTOR_LEN = offset;
136701
+ return ptr;
136702
+ }
136703
+ __name(passStringToWasm0, "passStringToWasm0");
136704
+ function isLikeNone(x) {
136705
+ return x === void 0 || x === null;
136706
+ }
136707
+ __name(isLikeNone, "isLikeNone");
136708
+ var cachegetInt32Memory0 = null;
136709
+ function getInt32Memory0() {
136710
+ if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
136711
+ cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
136712
+ }
136713
+ return cachegetInt32Memory0;
136714
+ }
136715
+ __name(getInt32Memory0, "getInt32Memory0");
136716
+ function debugString(val) {
136717
+ const type = typeof val;
136718
+ if (type == "number" || type == "boolean" || val == null) {
136719
+ return `${val}`;
136720
+ }
136721
+ if (type == "string") {
136722
+ return `"${val}"`;
136723
+ }
136724
+ if (type == "symbol") {
136725
+ const description = val.description;
136726
+ if (description == null) {
136727
+ return "Symbol";
136728
+ } else {
136729
+ return `Symbol(${description})`;
136940
136730
  }
136941
- },
136942
- x: function(date, token, _localize, options) {
136943
- var originalDate = options._originalDate || date;
136944
- var timezoneOffset = originalDate.getTimezoneOffset();
136945
- switch (token) {
136946
- case "x":
136947
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
136948
- case "xxxx":
136949
- case "xx":
136950
- return formatTimezone(timezoneOffset);
136951
- case "xxxxx":
136952
- case "xxx":
136953
- default:
136954
- return formatTimezone(timezoneOffset, ":");
136731
+ }
136732
+ if (type == "function") {
136733
+ const name5 = val.name;
136734
+ if (typeof name5 == "string" && name5.length > 0) {
136735
+ return `Function(${name5})`;
136736
+ } else {
136737
+ return "Function";
136955
136738
  }
136956
- },
136957
- O: function(date, token, _localize, options) {
136958
- var originalDate = options._originalDate || date;
136959
- var timezoneOffset = originalDate.getTimezoneOffset();
136960
- switch (token) {
136961
- case "O":
136962
- case "OO":
136963
- case "OOO":
136964
- return "GMT" + formatTimezoneShort(timezoneOffset, ":");
136965
- case "OOOO":
136966
- default:
136967
- return "GMT" + formatTimezone(timezoneOffset, ":");
136739
+ }
136740
+ if (Array.isArray(val)) {
136741
+ const length2 = val.length;
136742
+ let debug = "[";
136743
+ if (length2 > 0) {
136744
+ debug += debugString(val[0]);
136968
136745
  }
136969
- },
136970
- z: function(date, token, _localize, options) {
136971
- var originalDate = options._originalDate || date;
136972
- var timezoneOffset = originalDate.getTimezoneOffset();
136973
- switch (token) {
136974
- case "z":
136975
- case "zz":
136976
- case "zzz":
136977
- return "GMT" + formatTimezoneShort(timezoneOffset, ":");
136978
- case "zzzz":
136979
- default:
136980
- return "GMT" + formatTimezone(timezoneOffset, ":");
136746
+ for (let i = 1; i < length2; i++) {
136747
+ debug += ", " + debugString(val[i]);
136981
136748
  }
136982
- },
136983
- t: function(date, token, _localize, options) {
136984
- var originalDate = options._originalDate || date;
136985
- var timestamp = Math.floor(originalDate.getTime() / 1e3);
136986
- return addLeadingZeros(timestamp, token.length);
136987
- },
136988
- T: function(date, token, _localize, options) {
136989
- var originalDate = options._originalDate || date;
136990
- var timestamp = originalDate.getTime();
136991
- return addLeadingZeros(timestamp, token.length);
136749
+ debug += "]";
136750
+ return debug;
136992
136751
  }
136993
- };
136994
- function formatTimezoneShort(offset, dirtyDelimiter) {
136995
- var sign5 = offset > 0 ? "-" : "+";
136996
- var absOffset = Math.abs(offset);
136997
- var hours = Math.floor(absOffset / 60);
136998
- var minutes = absOffset % 60;
136999
- if (minutes === 0) {
137000
- return sign5 + String(hours);
136752
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
136753
+ let className;
136754
+ if (builtInMatches.length > 1) {
136755
+ className = builtInMatches[1];
136756
+ } else {
136757
+ return toString.call(val);
137001
136758
  }
137002
- var delimiter = dirtyDelimiter || "";
137003
- return sign5 + String(hours) + delimiter + addLeadingZeros(minutes, 2);
137004
- }
137005
- __name(formatTimezoneShort, "formatTimezoneShort");
137006
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
137007
- if (offset % 60 === 0) {
137008
- var sign5 = offset > 0 ? "-" : "+";
137009
- return sign5 + addLeadingZeros(Math.abs(offset) / 60, 2);
136759
+ if (className == "Object") {
136760
+ try {
136761
+ return "Object(" + JSON.stringify(val) + ")";
136762
+ } catch (_) {
136763
+ return "Object";
136764
+ }
137010
136765
  }
137011
- return formatTimezone(offset, dirtyDelimiter);
136766
+ if (val instanceof Error) {
136767
+ return `${val.name}: ${val.message}
136768
+ ${val.stack}`;
136769
+ }
136770
+ return className;
137012
136771
  }
137013
- __name(formatTimezoneWithOptionalMinutes, "formatTimezoneWithOptionalMinutes");
137014
- function formatTimezone(offset, dirtyDelimiter) {
137015
- var delimiter = dirtyDelimiter || "";
137016
- var sign5 = offset > 0 ? "-" : "+";
137017
- var absOffset = Math.abs(offset);
137018
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
137019
- var minutes = addLeadingZeros(absOffset % 60, 2);
137020
- return sign5 + hours + delimiter + minutes;
136772
+ __name(debugString, "debugString");
136773
+ function makeMutClosure(arg0, arg1, dtor, f) {
136774
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
136775
+ const real = /* @__PURE__ */ __name((...args) => {
136776
+ state.cnt++;
136777
+ const a = state.a;
136778
+ state.a = 0;
136779
+ try {
136780
+ return f(a, state.b, ...args);
136781
+ } finally {
136782
+ if (--state.cnt === 0) {
136783
+ wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
136784
+ } else {
136785
+ state.a = a;
136786
+ }
136787
+ }
136788
+ }, "real");
136789
+ real.original = state;
136790
+ return real;
137021
136791
  }
137022
- __name(formatTimezone, "formatTimezone");
137023
- var formatters_default = formatters2;
137024
- function dateLongFormatter(pattern, formatLong2) {
137025
- switch (pattern) {
137026
- case "P":
137027
- return formatLong2.date({
137028
- width: "short"
137029
- });
137030
- case "PP":
137031
- return formatLong2.date({
137032
- width: "medium"
137033
- });
137034
- case "PPP":
137035
- return formatLong2.date({
137036
- width: "long"
137037
- });
137038
- case "PPPP":
137039
- default:
137040
- return formatLong2.date({
137041
- width: "full"
137042
- });
137043
- }
136792
+ __name(makeMutClosure, "makeMutClosure");
136793
+ function __wbg_adapter_24(arg0, arg1, arg2) {
136794
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h91a8814f66f14b17(arg0, arg1, addHeapObject(arg2));
137044
136795
  }
137045
- __name(dateLongFormatter, "dateLongFormatter");
137046
- function timeLongFormatter(pattern, formatLong2) {
137047
- switch (pattern) {
137048
- case "p":
137049
- return formatLong2.time({
137050
- width: "short"
137051
- });
137052
- case "pp":
137053
- return formatLong2.time({
137054
- width: "medium"
137055
- });
137056
- case "ppp":
137057
- return formatLong2.time({
137058
- width: "long"
137059
- });
137060
- case "pppp":
137061
- default:
137062
- return formatLong2.time({
137063
- width: "full"
137064
- });
137065
- }
136796
+ __name(__wbg_adapter_24, "__wbg_adapter_24");
136797
+ function passArray8ToWasm0(arg, malloc) {
136798
+ const ptr = malloc(arg.length * 1);
136799
+ getUint8Memory0().set(arg, ptr / 1);
136800
+ WASM_VECTOR_LEN = arg.length;
136801
+ return ptr;
137066
136802
  }
137067
- __name(timeLongFormatter, "timeLongFormatter");
137068
- function dateTimeLongFormatter(pattern, formatLong2) {
137069
- var matchResult = pattern.match(/(P+)(p+)?/) || [];
137070
- var datePattern = matchResult[1];
137071
- var timePattern = matchResult[2];
137072
- if (!timePattern) {
137073
- return dateLongFormatter(pattern, formatLong2);
136803
+ __name(passArray8ToWasm0, "passArray8ToWasm0");
136804
+ function generateEd25519KeyFromBytes(bytes) {
136805
+ try {
136806
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
136807
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
136808
+ const len0 = WASM_VECTOR_LEN;
136809
+ wasm.generateEd25519KeyFromBytes(retptr, ptr0, len0);
136810
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
136811
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
136812
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
136813
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
136814
+ var ptr1 = r0;
136815
+ var len1 = r1;
136816
+ if (r3) {
136817
+ ptr1 = 0;
136818
+ len1 = 0;
136819
+ throw takeObject(r2);
136820
+ }
136821
+ return getStringFromWasm0(ptr1, len1);
136822
+ } finally {
136823
+ wasm.__wbindgen_add_to_stack_pointer(16);
136824
+ wasm.__wbindgen_free(ptr1, len1);
137074
136825
  }
137075
- var dateTimeFormat;
137076
- switch (datePattern) {
137077
- case "P":
137078
- dateTimeFormat = formatLong2.dateTime({
137079
- width: "short"
137080
- });
137081
- break;
137082
- case "PP":
137083
- dateTimeFormat = formatLong2.dateTime({
137084
- width: "medium"
137085
- });
137086
- break;
137087
- case "PPP":
137088
- dateTimeFormat = formatLong2.dateTime({
137089
- width: "long"
137090
- });
137091
- break;
137092
- case "PPPP":
137093
- default:
137094
- dateTimeFormat = formatLong2.dateTime({
137095
- width: "full"
137096
- });
137097
- break;
136826
+ }
136827
+ __name(generateEd25519KeyFromBytes, "generateEd25519KeyFromBytes");
136828
+ function keyToDID(method_pattern, jwk) {
136829
+ try {
136830
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
136831
+ const ptr0 = passStringToWasm0(method_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136832
+ const len0 = WASM_VECTOR_LEN;
136833
+ const ptr1 = passStringToWasm0(jwk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136834
+ const len1 = WASM_VECTOR_LEN;
136835
+ wasm.keyToDID(retptr, ptr0, len0, ptr1, len1);
136836
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
136837
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
136838
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
136839
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
136840
+ var ptr2 = r0;
136841
+ var len2 = r1;
136842
+ if (r3) {
136843
+ ptr2 = 0;
136844
+ len2 = 0;
136845
+ throw takeObject(r2);
136846
+ }
136847
+ return getStringFromWasm0(ptr2, len2);
136848
+ } finally {
136849
+ wasm.__wbindgen_add_to_stack_pointer(16);
136850
+ wasm.__wbindgen_free(ptr2, len2);
137098
136851
  }
137099
- return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
137100
136852
  }
137101
- __name(dateTimeLongFormatter, "dateTimeLongFormatter");
137102
- var longFormatters = {
137103
- p: timeLongFormatter,
137104
- P: dateTimeLongFormatter
137105
- };
137106
- var longFormatters_default = longFormatters;
137107
- var protectedDayOfYearTokens = ["D", "DD"];
137108
- var protectedWeekYearTokens = ["YY", "YYYY"];
137109
- function isProtectedDayOfYearToken(token) {
137110
- return protectedDayOfYearTokens.indexOf(token) !== -1;
136853
+ __name(keyToDID, "keyToDID");
136854
+ function keyToVerificationMethod(method_pattern, jwk) {
136855
+ const ptr0 = passStringToWasm0(method_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136856
+ const len0 = WASM_VECTOR_LEN;
136857
+ const ptr1 = passStringToWasm0(jwk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136858
+ const len1 = WASM_VECTOR_LEN;
136859
+ const ret = wasm.keyToVerificationMethod(ptr0, len0, ptr1, len1);
136860
+ return takeObject(ret);
136861
+ }
136862
+ __name(keyToVerificationMethod, "keyToVerificationMethod");
136863
+ function issueCredential2(credential, proof_options, key2) {
136864
+ const ptr0 = passStringToWasm0(credential, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136865
+ const len0 = WASM_VECTOR_LEN;
136866
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136867
+ const len1 = WASM_VECTOR_LEN;
136868
+ const ptr2 = passStringToWasm0(key2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136869
+ const len2 = WASM_VECTOR_LEN;
136870
+ const ret = wasm.issueCredential(ptr0, len0, ptr1, len1, ptr2, len2);
136871
+ return takeObject(ret);
136872
+ }
136873
+ __name(issueCredential2, "issueCredential");
136874
+ function verifyCredential3(vc, proof_options) {
136875
+ const ptr0 = passStringToWasm0(vc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136876
+ const len0 = WASM_VECTOR_LEN;
136877
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136878
+ const len1 = WASM_VECTOR_LEN;
136879
+ const ret = wasm.verifyCredential(ptr0, len0, ptr1, len1);
136880
+ return takeObject(ret);
137111
136881
  }
137112
- __name(isProtectedDayOfYearToken, "isProtectedDayOfYearToken");
137113
- function isProtectedWeekYearToken(token) {
137114
- return protectedWeekYearTokens.indexOf(token) !== -1;
136882
+ __name(verifyCredential3, "verifyCredential");
136883
+ function issuePresentation2(presentation, proof_options, key2) {
136884
+ const ptr0 = passStringToWasm0(presentation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136885
+ const len0 = WASM_VECTOR_LEN;
136886
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136887
+ const len1 = WASM_VECTOR_LEN;
136888
+ const ptr2 = passStringToWasm0(key2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136889
+ const len2 = WASM_VECTOR_LEN;
136890
+ const ret = wasm.issuePresentation(ptr0, len0, ptr1, len1, ptr2, len2);
136891
+ return takeObject(ret);
137115
136892
  }
137116
- __name(isProtectedWeekYearToken, "isProtectedWeekYearToken");
137117
- function throwProtectedError(token, format2, input) {
137118
- if (token === "YYYY") {
137119
- throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
137120
- } else if (token === "YY") {
137121
- throw new RangeError("Use `yy` instead of `YY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
137122
- } else if (token === "D") {
137123
- throw new RangeError("Use `d` instead of `D` (in `".concat(format2, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
137124
- } else if (token === "DD") {
137125
- throw new RangeError("Use `dd` instead of `DD` (in `".concat(format2, "`) for formatting days of the month to the input `").concat(input, "`; see: https://git.io/fxCyr"));
137126
- }
136893
+ __name(issuePresentation2, "issuePresentation");
136894
+ function verifyPresentation2(vp, proof_options) {
136895
+ const ptr0 = passStringToWasm0(vp, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136896
+ const len0 = WASM_VECTOR_LEN;
136897
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136898
+ const len1 = WASM_VECTOR_LEN;
136899
+ const ret = wasm.verifyPresentation(ptr0, len0, ptr1, len1);
136900
+ return takeObject(ret);
137127
136901
  }
137128
- __name(throwProtectedError, "throwProtectedError");
137129
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
137130
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
137131
- var escapedStringRegExp = /^'([^]*?)'?$/;
137132
- var doubleQuoteRegExp = /''/g;
137133
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
137134
- function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
137135
- requiredArgs(2, arguments);
137136
- var formatStr = String(dirtyFormatStr);
137137
- var options = dirtyOptions || {};
137138
- var locale2 = options.locale || en_US_default;
137139
- var localeFirstWeekContainsDate = locale2.options && locale2.options.firstWeekContainsDate;
137140
- var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
137141
- var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
137142
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
137143
- throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");
137144
- }
137145
- var localeWeekStartsOn = locale2.options && locale2.options.weekStartsOn;
137146
- var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
137147
- var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn);
137148
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
137149
- throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");
137150
- }
137151
- if (!locale2.localize) {
137152
- throw new RangeError("locale must contain localize property");
137153
- }
137154
- if (!locale2.formatLong) {
137155
- throw new RangeError("locale must contain formatLong property");
137156
- }
137157
- var originalDate = toDate(dirtyDate);
137158
- if (!isValid2(originalDate)) {
137159
- throw new RangeError("Invalid time value");
136902
+ __name(verifyPresentation2, "verifyPresentation");
136903
+ function handleError(f, args) {
136904
+ try {
136905
+ return f.apply(this, args);
136906
+ } catch (e) {
136907
+ wasm.__wbindgen_exn_store(addHeapObject(e));
137160
136908
  }
137161
- var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
137162
- var utcDate = subMilliseconds(originalDate, timezoneOffset);
137163
- var formatterOptions = {
137164
- firstWeekContainsDate,
137165
- weekStartsOn,
137166
- locale: locale2,
137167
- _originalDate: originalDate
137168
- };
137169
- var result = formatStr.match(longFormattingTokensRegExp).map(function(substring) {
137170
- var firstCharacter = substring[0];
137171
- if (firstCharacter === "p" || firstCharacter === "P") {
137172
- var longFormatter = longFormatters_default[firstCharacter];
137173
- return longFormatter(substring, locale2.formatLong, formatterOptions);
137174
- }
137175
- return substring;
137176
- }).join("").match(formattingTokensRegExp).map(function(substring) {
137177
- if (substring === "''") {
137178
- return "'";
137179
- }
137180
- var firstCharacter = substring[0];
137181
- if (firstCharacter === "'") {
137182
- return cleanEscapedString(substring);
136909
+ }
136910
+ __name(handleError, "handleError");
136911
+ function getArrayU8FromWasm0(ptr, len) {
136912
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
136913
+ }
136914
+ __name(getArrayU8FromWasm0, "getArrayU8FromWasm0");
136915
+ function __wbg_adapter_108(arg0, arg1, arg2, arg3) {
136916
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h3ecfeb7a01c1be81(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
136917
+ }
136918
+ __name(__wbg_adapter_108, "__wbg_adapter_108");
136919
+ function load(module, imports) {
136920
+ return __async$1(this, null, function* () {
136921
+ if (typeof Response === "function" && module instanceof Response) {
136922
+ if (typeof WebAssembly.instantiateStreaming === "function") {
136923
+ try {
136924
+ return yield WebAssembly.instantiateStreaming(module, imports);
136925
+ } catch (e) {
136926
+ if (module.headers.get("Content-Type") != "application/wasm") {
136927
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
136928
+ } else {
136929
+ throw e;
136930
+ }
136931
+ }
136932
+ }
136933
+ const bytes = yield module.arrayBuffer();
136934
+ return yield WebAssembly.instantiate(bytes, imports);
136935
+ } else {
136936
+ const instance = yield WebAssembly.instantiate(module, imports);
136937
+ if (instance instanceof WebAssembly.Instance) {
136938
+ return { instance, module };
136939
+ } else {
136940
+ return instance;
136941
+ }
137183
136942
  }
137184
- var formatter = formatters_default[firstCharacter];
137185
- if (formatter) {
137186
- if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
137187
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
136943
+ });
136944
+ }
136945
+ __name(load, "load");
136946
+ function init2(input) {
136947
+ return __async$1(this, null, function* () {
136948
+ const imports = {};
136949
+ imports.wbg = {};
136950
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
136951
+ const ret = getStringFromWasm0(arg0, arg1);
136952
+ return addHeapObject(ret);
136953
+ };
136954
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
136955
+ takeObject(arg0);
136956
+ };
136957
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
136958
+ const obj = takeObject(arg0).original;
136959
+ if (obj.cnt-- == 1) {
136960
+ obj.a = 0;
136961
+ return true;
137188
136962
  }
137189
- if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
137190
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
136963
+ const ret = false;
136964
+ return ret;
136965
+ };
136966
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
136967
+ const ret = getObject(arg0);
136968
+ return addHeapObject(ret);
136969
+ };
136970
+ imports.wbg.__wbg_fetch_811d43d6bdcad5b1 = function(arg0) {
136971
+ const ret = fetch(getObject(arg0));
136972
+ return addHeapObject(ret);
136973
+ };
136974
+ imports.wbg.__wbg_fetch_bf56e2a9f0644e3f = function(arg0, arg1) {
136975
+ const ret = getObject(arg0).fetch(getObject(arg1));
136976
+ return addHeapObject(ret);
136977
+ };
136978
+ imports.wbg.__wbg_new_89d7f088c1c45353 = function() {
136979
+ return handleError(function() {
136980
+ const ret = new Headers();
136981
+ return addHeapObject(ret);
136982
+ }, arguments);
136983
+ };
136984
+ imports.wbg.__wbg_append_f4f93bc73c45ee3e = function() {
136985
+ return handleError(function(arg0, arg1, arg2, arg3, arg4) {
136986
+ getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
136987
+ }, arguments);
136988
+ };
136989
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
136990
+ const obj = getObject(arg1);
136991
+ const ret = typeof obj === "string" ? obj : void 0;
136992
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136993
+ var len0 = WASM_VECTOR_LEN;
136994
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
136995
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
136996
+ };
136997
+ imports.wbg.__wbg_instanceof_Response_ccfeb62399355bcd = function(arg0) {
136998
+ const ret = getObject(arg0) instanceof Response;
136999
+ return ret;
137000
+ };
137001
+ imports.wbg.__wbg_url_06c0f822d68d195c = function(arg0, arg1) {
137002
+ const ret = getObject(arg1).url;
137003
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
137004
+ const len0 = WASM_VECTOR_LEN;
137005
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
137006
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
137007
+ };
137008
+ imports.wbg.__wbg_status_600fd8b881393898 = function(arg0) {
137009
+ const ret = getObject(arg0).status;
137010
+ return ret;
137011
+ };
137012
+ imports.wbg.__wbg_headers_9e7f2c05a9b962ea = function(arg0) {
137013
+ const ret = getObject(arg0).headers;
137014
+ return addHeapObject(ret);
137015
+ };
137016
+ imports.wbg.__wbg_arrayBuffer_5a99283a3954c850 = function() {
137017
+ return handleError(function(arg0) {
137018
+ const ret = getObject(arg0).arrayBuffer();
137019
+ return addHeapObject(ret);
137020
+ }, arguments);
137021
+ };
137022
+ imports.wbg.__wbg_newwithstrandinit_fd99688f189f053e = function() {
137023
+ return handleError(function(arg0, arg1, arg2) {
137024
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
137025
+ return addHeapObject(ret);
137026
+ }, arguments);
137027
+ };
137028
+ imports.wbg.__wbindgen_is_object = function(arg0) {
137029
+ const val = getObject(arg0);
137030
+ const ret = typeof val === "object" && val !== null;
137031
+ return ret;
137032
+ };
137033
+ imports.wbg.__wbg_self_86b4b13392c7af56 = function() {
137034
+ return handleError(function() {
137035
+ const ret = self.self;
137036
+ return addHeapObject(ret);
137037
+ }, arguments);
137038
+ };
137039
+ imports.wbg.__wbg_crypto_b8c92eaac23d0d80 = function(arg0) {
137040
+ const ret = getObject(arg0).crypto;
137041
+ return addHeapObject(ret);
137042
+ };
137043
+ imports.wbg.__wbg_msCrypto_9ad6677321a08dd8 = function(arg0) {
137044
+ const ret = getObject(arg0).msCrypto;
137045
+ return addHeapObject(ret);
137046
+ };
137047
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
137048
+ const ret = getObject(arg0) === void 0;
137049
+ return ret;
137050
+ };
137051
+ imports.wbg.__wbg_static_accessor_MODULE_452b4680e8614c81 = function() {
137052
+ const ret = module;
137053
+ return addHeapObject(ret);
137054
+ };
137055
+ imports.wbg.__wbg_require_f5521a5b85ad2542 = function(arg0, arg1, arg2) {
137056
+ const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
137057
+ return addHeapObject(ret);
137058
+ };
137059
+ imports.wbg.__wbg_getRandomValues_dd27e6b0652b3236 = function(arg0) {
137060
+ const ret = getObject(arg0).getRandomValues;
137061
+ return addHeapObject(ret);
137062
+ };
137063
+ imports.wbg.__wbg_getRandomValues_e57c9b75ddead065 = function(arg0, arg1) {
137064
+ getObject(arg0).getRandomValues(getObject(arg1));
137065
+ };
137066
+ imports.wbg.__wbg_randomFillSync_d2ba53160aec6aba = function(arg0, arg1, arg2) {
137067
+ getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
137068
+ };
137069
+ imports.wbg.__wbindgen_is_function = function(arg0) {
137070
+ const ret = typeof getObject(arg0) === "function";
137071
+ return ret;
137072
+ };
137073
+ imports.wbg.__wbg_newnoargs_e23b458e372830de = function(arg0, arg1) {
137074
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
137075
+ return addHeapObject(ret);
137076
+ };
137077
+ imports.wbg.__wbg_next_cabb70b365520721 = function(arg0) {
137078
+ const ret = getObject(arg0).next;
137079
+ return addHeapObject(ret);
137080
+ };
137081
+ imports.wbg.__wbg_next_bf3d83fc18df496e = function() {
137082
+ return handleError(function(arg0) {
137083
+ const ret = getObject(arg0).next();
137084
+ return addHeapObject(ret);
137085
+ }, arguments);
137086
+ };
137087
+ imports.wbg.__wbg_done_040f966faa9a72b3 = function(arg0) {
137088
+ const ret = getObject(arg0).done;
137089
+ return ret;
137090
+ };
137091
+ imports.wbg.__wbg_value_419afbd9b9574c4c = function(arg0) {
137092
+ const ret = getObject(arg0).value;
137093
+ return addHeapObject(ret);
137094
+ };
137095
+ imports.wbg.__wbg_iterator_4832ef1f15b0382b = function() {
137096
+ const ret = Symbol.iterator;
137097
+ return addHeapObject(ret);
137098
+ };
137099
+ imports.wbg.__wbg_get_a9cab131e3152c49 = function() {
137100
+ return handleError(function(arg0, arg1) {
137101
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
137102
+ return addHeapObject(ret);
137103
+ }, arguments);
137104
+ };
137105
+ imports.wbg.__wbg_call_ae78342adc33730a = function() {
137106
+ return handleError(function(arg0, arg1) {
137107
+ const ret = getObject(arg0).call(getObject(arg1));
137108
+ return addHeapObject(ret);
137109
+ }, arguments);
137110
+ };
137111
+ imports.wbg.__wbg_new_36359baae5a47e27 = function() {
137112
+ const ret = new Object();
137113
+ return addHeapObject(ret);
137114
+ };
137115
+ imports.wbg.__wbg_call_3ed288a247f13ea5 = function() {
137116
+ return handleError(function(arg0, arg1, arg2) {
137117
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
137118
+ return addHeapObject(ret);
137119
+ }, arguments);
137120
+ };
137121
+ imports.wbg.__wbg_getTime_bffb1c09df09618b = function(arg0) {
137122
+ const ret = getObject(arg0).getTime();
137123
+ return ret;
137124
+ };
137125
+ imports.wbg.__wbg_new0_0ff7eb5c1486f3ec = function() {
137126
+ const ret = new Date();
137127
+ return addHeapObject(ret);
137128
+ };
137129
+ imports.wbg.__wbg_new_37705eed627d5ed9 = function(arg0, arg1) {
137130
+ try {
137131
+ var state0 = { a: arg0, b: arg1 };
137132
+ var cb0 = /* @__PURE__ */ __name((arg02, arg12) => {
137133
+ const a = state0.a;
137134
+ state0.a = 0;
137135
+ try {
137136
+ return __wbg_adapter_108(a, state0.b, arg02, arg12);
137137
+ } finally {
137138
+ state0.a = a;
137139
+ }
137140
+ }, "cb0");
137141
+ const ret = new Promise(cb0);
137142
+ return addHeapObject(ret);
137143
+ } finally {
137144
+ state0.a = state0.b = 0;
137191
137145
  }
137192
- return formatter(utcDate, substring, locale2.localize, formatterOptions);
137193
- }
137194
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
137195
- throw new RangeError("Format string contains an unescaped latin alphabet character `" + firstCharacter + "`");
137146
+ };
137147
+ imports.wbg.__wbg_resolve_a9a87bdd64e9e62c = function(arg0) {
137148
+ const ret = Promise.resolve(getObject(arg0));
137149
+ return addHeapObject(ret);
137150
+ };
137151
+ imports.wbg.__wbg_then_ce526c837d07b68f = function(arg0, arg1) {
137152
+ const ret = getObject(arg0).then(getObject(arg1));
137153
+ return addHeapObject(ret);
137154
+ };
137155
+ imports.wbg.__wbg_then_842e65b843962f56 = function(arg0, arg1, arg2) {
137156
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
137157
+ return addHeapObject(ret);
137158
+ };
137159
+ imports.wbg.__wbg_self_99737b4dcdf6f0d8 = function() {
137160
+ return handleError(function() {
137161
+ const ret = self.self;
137162
+ return addHeapObject(ret);
137163
+ }, arguments);
137164
+ };
137165
+ imports.wbg.__wbg_window_9b61fbbf3564c4fb = function() {
137166
+ return handleError(function() {
137167
+ const ret = window.window;
137168
+ return addHeapObject(ret);
137169
+ }, arguments);
137170
+ };
137171
+ imports.wbg.__wbg_globalThis_8e275ef40caea3a3 = function() {
137172
+ return handleError(function() {
137173
+ const ret = globalThis.globalThis;
137174
+ return addHeapObject(ret);
137175
+ }, arguments);
137176
+ };
137177
+ imports.wbg.__wbg_global_5de1e0f82bddcd27 = function() {
137178
+ return handleError(function() {
137179
+ const ret = global.global;
137180
+ return addHeapObject(ret);
137181
+ }, arguments);
137182
+ };
137183
+ imports.wbg.__wbg_buffer_7af23f65f6c64548 = function(arg0) {
137184
+ const ret = getObject(arg0).buffer;
137185
+ return addHeapObject(ret);
137186
+ };
137187
+ imports.wbg.__wbg_newwithbyteoffsetandlength_ce1e75f0ce5f7974 = function(arg0, arg1, arg2) {
137188
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
137189
+ return addHeapObject(ret);
137190
+ };
137191
+ imports.wbg.__wbg_new_cc9018bd6f283b6f = function(arg0) {
137192
+ const ret = new Uint8Array(getObject(arg0));
137193
+ return addHeapObject(ret);
137194
+ };
137195
+ imports.wbg.__wbg_set_f25e869e4565d2a2 = function(arg0, arg1, arg2) {
137196
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
137197
+ };
137198
+ imports.wbg.__wbg_length_0acb1cf9bbaf8519 = function(arg0) {
137199
+ const ret = getObject(arg0).length;
137200
+ return ret;
137201
+ };
137202
+ imports.wbg.__wbg_newwithlength_8f0657faca9f1422 = function(arg0) {
137203
+ const ret = new Uint8Array(arg0 >>> 0);
137204
+ return addHeapObject(ret);
137205
+ };
137206
+ imports.wbg.__wbg_subarray_da527dbd24eafb6b = function(arg0, arg1, arg2) {
137207
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
137208
+ return addHeapObject(ret);
137209
+ };
137210
+ imports.wbg.__wbg_has_ce995ec88636803d = function() {
137211
+ return handleError(function(arg0, arg1) {
137212
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
137213
+ return ret;
137214
+ }, arguments);
137215
+ };
137216
+ imports.wbg.__wbg_set_93b1c87ee2af852e = function() {
137217
+ return handleError(function(arg0, arg1, arg2) {
137218
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
137219
+ return ret;
137220
+ }, arguments);
137221
+ };
137222
+ imports.wbg.__wbg_stringify_c760003feffcc1f2 = function() {
137223
+ return handleError(function(arg0) {
137224
+ const ret = JSON.stringify(getObject(arg0));
137225
+ return addHeapObject(ret);
137226
+ }, arguments);
137227
+ };
137228
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
137229
+ const ret = debugString(getObject(arg1));
137230
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
137231
+ const len0 = WASM_VECTOR_LEN;
137232
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
137233
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
137234
+ };
137235
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
137236
+ throw new Error(getStringFromWasm0(arg0, arg1));
137237
+ };
137238
+ imports.wbg.__wbindgen_memory = function() {
137239
+ const ret = wasm.memory;
137240
+ return addHeapObject(ret);
137241
+ };
137242
+ imports.wbg.__wbindgen_closure_wrapper10902 = function(arg0, arg1, arg2) {
137243
+ const ret = makeMutClosure(arg0, arg1, 3717, __wbg_adapter_24);
137244
+ return addHeapObject(ret);
137245
+ };
137246
+ if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
137247
+ input = fetch(input);
137196
137248
  }
137197
- return substring;
137198
- }).join("");
137199
- return result;
137200
- }
137201
- __name(format, "format");
137202
- function cleanEscapedString(input) {
137203
- return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
137204
- }
137205
- __name(cleanEscapedString, "cleanEscapedString");
137206
- var transformErrorCheck = /* @__PURE__ */ __name((error, _credential) => {
137207
- const prefix = error.split(" error")[0];
137208
- return prefix || error;
137209
- }, "transformErrorCheck");
137210
- var transformErrorMessage = /* @__PURE__ */ __name((error, credential) => {
137211
- if (error.startsWith("expiration")) {
137212
- return credential.expirationDate ? `Invalid \u2022 Expired ${format(new Date(credential.expirationDate), "dd MMM yyyy").toUpperCase()}` : "Invalid \u2022 Expired";
137213
- }
137214
- return error;
137215
- }, "transformErrorMessage");
137216
- var transformCheckMessage = /* @__PURE__ */ __name((check, credential) => {
137217
- return {
137218
- proof: "Valid",
137219
- expiration: credential.expirationDate ? `Valid \u2022 Expires ${format(new Date(credential.expirationDate), "dd MMM yyyy").toUpperCase()}` : "Valid \u2022 Does Not Expire"
137220
- }[check] || check;
137221
- }, "transformCheckMessage");
137222
- var verifyCredential3 = /* @__PURE__ */ __name((wallet) => {
137223
- return (credential) => __async$1(void 0, null, function* () {
137224
- const rawVerificationCheck = yield wallet.pluginMethods.verifyCredential(credential);
137225
- const verificationItems = [];
137226
- rawVerificationCheck.errors.forEach((error) => {
137227
- verificationItems.push({
137228
- status: VerificationStatusEnum.Failed,
137229
- check: transformErrorCheck(error, credential),
137230
- details: transformErrorMessage(error, credential)
137231
- });
137232
- });
137233
- rawVerificationCheck.warnings.forEach((warning) => {
137234
- verificationItems.push({
137235
- status: VerificationStatusEnum.Error,
137236
- check: "hmm",
137237
- message: warning
137238
- });
137239
- });
137240
- rawVerificationCheck.checks.forEach((check) => {
137241
- verificationItems.push({
137242
- status: VerificationStatusEnum.Success,
137243
- check,
137244
- message: transformCheckMessage(check, credential)
137245
- });
137246
- });
137247
- return verificationItems;
137249
+ const { instance, module } = yield load(yield input, imports);
137250
+ wasm = instance.exports;
137251
+ init2.__wbindgen_wasm_module = module;
137252
+ return wasm;
137248
137253
  });
137249
- }, "verifyCredential");
137250
- var defaultCeramicIDXArgs = {
137251
- modelData: {
137252
- definitions: {
137253
- MyVerifiableCredentials: "kjzl6cwe1jw14am5tu5hh412s19o4zm8aq3g2lpd6s4paxj2nly2lj4drp3pun2"
137254
- },
137255
- schemas: {
137256
- AchievementVerifiableCredential: "ceramic://k3y52l7qbv1frylibw2725v8gem3hxs1onoh6pvux0szdduugczh0hddxo6qsd6o0",
137257
- VerifiableCredentialsList: "ceramic://k3y52l7qbv1frxkcwfpyauky3fyl4n44izridy3blvjjzgftis40sk9w8g3remghs"
137258
- },
137259
- tiles: {}
137260
- },
137261
- credentialAlias: "MyVerifiableCredentials",
137262
- ceramicEndpoint: "https://ceramic-node.welibrary.io:7007",
137263
- defaultContentFamily: "SuperSkills"
137264
- };
137254
+ }
137255
+ __name(init2, "init");
137256
+ var didkit_wasm_default = init2;
137257
+ var initialized = false;
137258
+ var init3 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/jXExSjNXSerFVDMIYOgy") => __async$1(void 0, null, function* () {
137259
+ if (initialized)
137260
+ return;
137261
+ initialized = true;
137262
+ return didkit_wasm_default(arg);
137263
+ }), "init");
137264
+ var didkit_default = init3;
137265
137265
  var getDidKitPlugin = /* @__PURE__ */ __name((input) => __async$1(void 0, null, function* () {
137266
137266
  yield didkit_default(input);
137267
+ const memoizedDids = {};
137267
137268
  return {
137268
137269
  pluginMethods: {
137269
137270
  generateEd25519KeyFromBytes: (_wallet, bytes) => JSON.parse(generateEd25519KeyFromBytes(bytes)),
137270
- keyToDid: (_wallet, type, keypair) => keyToDID(type, JSON.stringify(keypair)),
137271
+ keyToDid: (_wallet, type, keypair) => {
137272
+ const memoizedDid = memoizedDids[type];
137273
+ if (!memoizedDid) {
137274
+ const did = keyToDID(type, JSON.stringify(keypair));
137275
+ memoizedDids[type] = did;
137276
+ return did;
137277
+ }
137278
+ return memoizedDid;
137279
+ },
137271
137280
  keyToVerificationMethod: (_wallet, type, keypair) => __async$1(void 0, null, function* () {
137272
137281
  return keyToVerificationMethod(type, JSON.stringify(keypair));
137273
137282
  }),
137274
137283
  issueCredential: (_wallet, credential, options, keypair) => __async$1(void 0, null, function* () {
137275
- return JSON.parse(yield issueCredential(JSON.stringify(credential), JSON.stringify(options), JSON.stringify(keypair)));
137284
+ return JSON.parse(yield issueCredential2(JSON.stringify(credential), JSON.stringify(options), JSON.stringify(keypair)));
137276
137285
  }),
137277
137286
  verifyCredential: (_wallet, credential) => __async$1(void 0, null, function* () {
137278
- return JSON.parse(yield verifyCredential(JSON.stringify(credential), "{}"));
137287
+ return JSON.parse(yield verifyCredential3(JSON.stringify(credential), "{}"));
137279
137288
  }),
137280
- issuePresentation: (presentation, options, keypair) => __async$1(void 0, null, function* () {
137281
- return issuePresentation(JSON.stringify(presentation), JSON.stringify(options), JSON.stringify(keypair));
137289
+ issuePresentation: (_wallet, presentation, options, keypair) => __async$1(void 0, null, function* () {
137290
+ return JSON.parse(yield issuePresentation2(JSON.stringify(presentation), JSON.stringify(options), JSON.stringify(keypair)));
137282
137291
  }),
137283
137292
  verifyPresentation: (_wallet, presentation) => __async$1(void 0, null, function* () {
137284
- return JSON.parse(yield verifyPresentation(JSON.stringify(presentation), "{}"));
137293
+ return JSON.parse(yield verifyPresentation2(JSON.stringify(presentation), "{}"));
137285
137294
  })
137286
137295
  }
137287
137296
  };
@@ -137291,7 +137300,6 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async$1(void 0, [_0,
137291
137300
  didkit,
137292
137301
  defaultContents = []
137293
137302
  } = {}) {
137294
- yield didkit_default(didkit);
137295
137303
  const didkitWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getDidKitPlugin(didkit));
137296
137304
  const didkeyWallet = yield didkitWallet.addPlugin(yield getDidKeyPlugin(didkitWallet, key2));
137297
137305
  const didkeyAndVCWallet = yield didkeyWallet.addPlugin(yield getVCPlugin(didkeyWallet));
@@ -137299,14 +137307,12 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async$1(void 0, [_0,
137299
137307
  const wallet = yield idxWallet.addPlugin(ExpirationPlugin(idxWallet));
137300
137308
  return {
137301
137309
  _wallet: wallet,
137302
- get did() {
137303
- return wallet.pluginMethods.getSubjectDid();
137304
- },
137310
+ did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
137305
137311
  get keypair() {
137306
137312
  return wallet.pluginMethods.getSubjectKeypair();
137307
137313
  },
137308
137314
  issueCredential: wallet.pluginMethods.issueCredential,
137309
- verifyCredential: verifyCredential3(wallet),
137315
+ verifyCredential: verifyCredential2(wallet),
137310
137316
  issuePresentation: wallet.pluginMethods.issuePresentation,
137311
137317
  verifyPresentation: wallet.pluginMethods.verifyPresentation,
137312
137318
  getCredential: wallet.pluginMethods.getVerifiableCredentialFromIndex,
@@ -137380,4 +137386,4 @@ const VCCard = ({ credential, issueeOverride, className = "" }) => {
137380
137386
  };
137381
137387
 
137382
137388
  exports.VCCard = VCCard;
137383
- //# sourceMappingURL=VCCard-5495759e.js.map
137389
+ //# sourceMappingURL=VCCard-37198c86.js.map