@learncard/react 2.3.3 → 2.3.7

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.
@@ -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);
@@ -132565,7 +131917,30 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async$1(void 0, [_0, _1]
132565
131917
  }
132566
131918
  };
132567
131919
  }), "getIDXPlugin");
131920
+ var ED25519_METHODS = ["key", "tz", "pkh:tz", "pkh:tezos", "pkh:sol", "pkh:solana"];
131921
+ var SECP256K1_METHODS = [
131922
+ "key",
131923
+ "tz",
131924
+ "ethr",
131925
+ "pkh:tz",
131926
+ "pkh:tezos",
131927
+ "pkh:eth",
131928
+ "pkh:celo",
131929
+ "pkh:poly",
131930
+ "pkh:btc",
131931
+ "pkh:doge",
131932
+ "pkh:eip155",
131933
+ "pkh:bip122"
131934
+ ];
132568
131935
  var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
131936
+ var getAlgorithmForDidMethod = /* @__PURE__ */ __name((didMethod) => {
131937
+ if (ED25519_METHODS.includes(didMethod))
131938
+ return "ed25519";
131939
+ if (SECP256K1_METHODS.includes(didMethod) || didMethod.startsWith("pkh:eip155:") || didMethod.startsWith("pkh:bip122:")) {
131940
+ return "secp256k1";
131941
+ }
131942
+ throw new Error("Unspported Did Method");
131943
+ }, "getAlgorithmForDidMethod");
132569
131944
  var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async$1(void 0, null, function* () {
132570
131945
  if (key2.length === 0)
132571
131946
  throw new Error("Please don't use an empty string for a key!");
@@ -132573,13 +131948,28 @@ var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async$1(void 0,
132573
131948
  throw new Error("Key must be a hexadecimal string!");
132574
131949
  if (key2.length > 64)
132575
131950
  throw new Error("Key must be less than 64 characters");
132576
- const keypair = wallet.pluginMethods.generateEd25519KeyFromBytes(toUint8Array(key2.padStart(64, "0")));
132577
- const did = wallet.pluginMethods.keyToDid("key", keypair);
131951
+ const seed = key2.padStart(64, "0");
131952
+ const seedBytes = toUint8Array(seed);
131953
+ const memoizedDids = {};
131954
+ const keyPairs = {
131955
+ ed25519: wallet.pluginMethods.generateEd25519KeyFromBytes(seedBytes),
131956
+ secp256k1: wallet.pluginMethods.generateSecp256k1KeyFromBytes(seedBytes)
131957
+ };
132578
131958
  return {
132579
131959
  pluginMethods: {
132580
- getSubjectDid: () => did,
132581
- getSubjectKeypair: () => keypair,
132582
- getKey: () => key2.padStart(64, "0")
131960
+ getSubjectDid: (_wallet, type) => {
131961
+ if (!memoizedDids[type]) {
131962
+ const algorithm = getAlgorithmForDidMethod(type);
131963
+ memoizedDids[type] = wallet.pluginMethods.keyToDid(type, keyPairs[algorithm]);
131964
+ }
131965
+ return memoizedDids[type];
131966
+ },
131967
+ getSubjectKeypair: (_wallet, type = "ed25519") => {
131968
+ if (!keyPairs[type])
131969
+ throw new Error("Unsupported algorithm");
131970
+ return keyPairs[type];
131971
+ },
131972
+ getKey: () => seed
132583
131973
  }
132584
131974
  };
132585
131975
  }), "getDidKeyPlugin");
@@ -132596,7 +131986,8 @@ var ExpirationPlugin = /* @__PURE__ */ __name((wallet) => ({
132596
131986
  })
132597
131987
  }
132598
131988
  }), "ExpirationPlugin");
132599
- var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
131989
+ var recycleDependents = /* @__PURE__ */ __name((_methods) => ({}), "recycleDependents");
131990
+ var issueCredential = /* @__PURE__ */ __name((initWallet) => {
132600
131991
  return (wallet, credential) => __async$1(void 0, null, function* () {
132601
131992
  const kp = wallet.pluginMethods.getSubjectKeypair();
132602
131993
  if (!kp)
@@ -132608,14 +131999,14 @@ var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
132608
131999
  return initWallet.pluginMethods.issueCredential(credential, options, kp);
132609
132000
  });
132610
132001
  }, "issueCredential");
132611
- var verifyCredential2 = /* @__PURE__ */ __name((initWallet) => {
132002
+ var verifyCredential = /* @__PURE__ */ __name((initWallet) => {
132612
132003
  return (_wallet, credential) => __async$1(void 0, null, function* () {
132613
132004
  return initWallet.pluginMethods.verifyCredential(credential);
132614
132005
  });
132615
132006
  }, "verifyCredential");
132616
- var issuePresentation2 = /* @__PURE__ */ __name((initWallet) => {
132007
+ var issuePresentation = /* @__PURE__ */ __name((initWallet) => {
132617
132008
  return (wallet, credential) => __async$1(void 0, null, function* () {
132618
- const did = wallet.pluginMethods.getSubjectDid();
132009
+ const did = wallet.pluginMethods.getSubjectDid("key");
132619
132010
  if (!did)
132620
132011
  throw new Error("Cannot create presentation: No holder key found");
132621
132012
  const holder = did;
@@ -132635,20 +132026,20 @@ var issuePresentation2 = /* @__PURE__ */ __name((initWallet) => {
132635
132026
  return initWallet.pluginMethods.issuePresentation(presentation, options, kp);
132636
132027
  });
132637
132028
  }, "issuePresentation");
132638
- var verifyPresentation2 = /* @__PURE__ */ __name((initWallet) => {
132029
+ var verifyPresentation = /* @__PURE__ */ __name((initWallet) => {
132639
132030
  return (_wallet, presentation) => __async$1(void 0, null, function* () {
132640
132031
  return initWallet.pluginMethods.verifyPresentation(presentation);
132641
132032
  });
132642
132033
  }, "verifyPresentation");
132643
132034
  var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async$1(void 0, null, function* () {
132644
132035
  return {
132645
- pluginMethods: __spreadProps(__spreadValues({}, wallet.pluginMethods), {
132646
- issueCredential: issueCredential2(wallet),
132647
- verifyCredential: verifyCredential2(wallet),
132648
- issuePresentation: issuePresentation2(wallet),
132649
- verifyPresentation: verifyPresentation2(wallet),
132036
+ pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
132037
+ issueCredential: issueCredential(wallet),
132038
+ verifyCredential: verifyCredential(wallet),
132039
+ issuePresentation: issuePresentation(wallet),
132040
+ verifyPresentation: verifyPresentation(wallet),
132650
132041
  getTestVc: (_wallet, subject = "did:example:d23dd687a7dc6787646f2eb98d0") => {
132651
- const did = _wallet.pluginMethods.getSubjectDid();
132042
+ const did = _wallet.pluginMethods.getSubjectDid("key");
132652
132043
  return {
132653
132044
  "@context": ["https://www.w3.org/2018/credentials/v1"],
132654
132045
  id: "http://example.org/credentials/3731",
@@ -136863,425 +136254,1107 @@ var formatters2 = {
136863
136254
  });
136864
136255
  }
136865
136256
  },
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
- });
136257
+ h: function(date, token, localize2) {
136258
+ if (token === "ho") {
136259
+ var hours = date.getUTCHours() % 12;
136260
+ if (hours === 0)
136261
+ hours = 12;
136262
+ return localize2.ordinalNumber(hours, {
136263
+ unit: "hour"
136264
+ });
136265
+ }
136266
+ return lightFormatters_default.h(date, token);
136267
+ },
136268
+ H: function(date, token, localize2) {
136269
+ if (token === "Ho") {
136270
+ return localize2.ordinalNumber(date.getUTCHours(), {
136271
+ unit: "hour"
136272
+ });
136273
+ }
136274
+ return lightFormatters_default.H(date, token);
136275
+ },
136276
+ K: function(date, token, localize2) {
136277
+ var hours = date.getUTCHours() % 12;
136278
+ if (token === "Ko") {
136279
+ return localize2.ordinalNumber(hours, {
136280
+ unit: "hour"
136281
+ });
136282
+ }
136283
+ return addLeadingZeros(hours, token.length);
136284
+ },
136285
+ k: function(date, token, localize2) {
136286
+ var hours = date.getUTCHours();
136287
+ if (hours === 0)
136288
+ hours = 24;
136289
+ if (token === "ko") {
136290
+ return localize2.ordinalNumber(hours, {
136291
+ unit: "hour"
136292
+ });
136293
+ }
136294
+ return addLeadingZeros(hours, token.length);
136295
+ },
136296
+ m: function(date, token, localize2) {
136297
+ if (token === "mo") {
136298
+ return localize2.ordinalNumber(date.getUTCMinutes(), {
136299
+ unit: "minute"
136300
+ });
136301
+ }
136302
+ return lightFormatters_default.m(date, token);
136303
+ },
136304
+ s: function(date, token, localize2) {
136305
+ if (token === "so") {
136306
+ return localize2.ordinalNumber(date.getUTCSeconds(), {
136307
+ unit: "second"
136308
+ });
136309
+ }
136310
+ return lightFormatters_default.s(date, token);
136311
+ },
136312
+ S: function(date, token) {
136313
+ return lightFormatters_default.S(date, token);
136314
+ },
136315
+ X: function(date, token, _localize, options) {
136316
+ var originalDate = options._originalDate || date;
136317
+ var timezoneOffset = originalDate.getTimezoneOffset();
136318
+ if (timezoneOffset === 0) {
136319
+ return "Z";
136320
+ }
136321
+ switch (token) {
136322
+ case "X":
136323
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
136324
+ case "XXXX":
136325
+ case "XX":
136326
+ return formatTimezone(timezoneOffset);
136327
+ case "XXXXX":
136328
+ case "XXX":
136329
+ default:
136330
+ return formatTimezone(timezoneOffset, ":");
136331
+ }
136332
+ },
136333
+ x: function(date, token, _localize, options) {
136334
+ var originalDate = options._originalDate || date;
136335
+ var timezoneOffset = originalDate.getTimezoneOffset();
136336
+ switch (token) {
136337
+ case "x":
136338
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
136339
+ case "xxxx":
136340
+ case "xx":
136341
+ return formatTimezone(timezoneOffset);
136342
+ case "xxxxx":
136343
+ case "xxx":
136344
+ default:
136345
+ return formatTimezone(timezoneOffset, ":");
136346
+ }
136347
+ },
136348
+ O: function(date, token, _localize, options) {
136349
+ var originalDate = options._originalDate || date;
136350
+ var timezoneOffset = originalDate.getTimezoneOffset();
136351
+ switch (token) {
136352
+ case "O":
136353
+ case "OO":
136354
+ case "OOO":
136355
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
136356
+ case "OOOO":
136357
+ default:
136358
+ return "GMT" + formatTimezone(timezoneOffset, ":");
136359
+ }
136360
+ },
136361
+ z: function(date, token, _localize, options) {
136362
+ var originalDate = options._originalDate || date;
136363
+ var timezoneOffset = originalDate.getTimezoneOffset();
136364
+ switch (token) {
136365
+ case "z":
136366
+ case "zz":
136367
+ case "zzz":
136368
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
136369
+ case "zzzz":
136370
+ default:
136371
+ return "GMT" + formatTimezone(timezoneOffset, ":");
136874
136372
  }
136875
- return lightFormatters_default.h(date, token);
136876
136373
  },
136877
- H: function(date, token, localize2) {
136878
- if (token === "Ho") {
136879
- return localize2.ordinalNumber(date.getUTCHours(), {
136880
- unit: "hour"
136881
- });
136882
- }
136883
- return lightFormatters_default.H(date, token);
136374
+ t: function(date, token, _localize, options) {
136375
+ var originalDate = options._originalDate || date;
136376
+ var timestamp = Math.floor(originalDate.getTime() / 1e3);
136377
+ return addLeadingZeros(timestamp, token.length);
136884
136378
  },
136885
- K: function(date, token, localize2) {
136886
- var hours = date.getUTCHours() % 12;
136887
- if (token === "Ko") {
136888
- return localize2.ordinalNumber(hours, {
136889
- unit: "hour"
136379
+ T: function(date, token, _localize, options) {
136380
+ var originalDate = options._originalDate || date;
136381
+ var timestamp = originalDate.getTime();
136382
+ return addLeadingZeros(timestamp, token.length);
136383
+ }
136384
+ };
136385
+ function formatTimezoneShort(offset, dirtyDelimiter) {
136386
+ var sign5 = offset > 0 ? "-" : "+";
136387
+ var absOffset = Math.abs(offset);
136388
+ var hours = Math.floor(absOffset / 60);
136389
+ var minutes = absOffset % 60;
136390
+ if (minutes === 0) {
136391
+ return sign5 + String(hours);
136392
+ }
136393
+ var delimiter = dirtyDelimiter || "";
136394
+ return sign5 + String(hours) + delimiter + addLeadingZeros(minutes, 2);
136395
+ }
136396
+ __name(formatTimezoneShort, "formatTimezoneShort");
136397
+ function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
136398
+ if (offset % 60 === 0) {
136399
+ var sign5 = offset > 0 ? "-" : "+";
136400
+ return sign5 + addLeadingZeros(Math.abs(offset) / 60, 2);
136401
+ }
136402
+ return formatTimezone(offset, dirtyDelimiter);
136403
+ }
136404
+ __name(formatTimezoneWithOptionalMinutes, "formatTimezoneWithOptionalMinutes");
136405
+ function formatTimezone(offset, dirtyDelimiter) {
136406
+ var delimiter = dirtyDelimiter || "";
136407
+ var sign5 = offset > 0 ? "-" : "+";
136408
+ var absOffset = Math.abs(offset);
136409
+ var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
136410
+ var minutes = addLeadingZeros(absOffset % 60, 2);
136411
+ return sign5 + hours + delimiter + minutes;
136412
+ }
136413
+ __name(formatTimezone, "formatTimezone");
136414
+ var formatters_default = formatters2;
136415
+ function dateLongFormatter(pattern, formatLong2) {
136416
+ switch (pattern) {
136417
+ case "P":
136418
+ return formatLong2.date({
136419
+ width: "short"
136420
+ });
136421
+ case "PP":
136422
+ return formatLong2.date({
136423
+ width: "medium"
136424
+ });
136425
+ case "PPP":
136426
+ return formatLong2.date({
136427
+ width: "long"
136428
+ });
136429
+ case "PPPP":
136430
+ default:
136431
+ return formatLong2.date({
136432
+ width: "full"
136433
+ });
136434
+ }
136435
+ }
136436
+ __name(dateLongFormatter, "dateLongFormatter");
136437
+ function timeLongFormatter(pattern, formatLong2) {
136438
+ switch (pattern) {
136439
+ case "p":
136440
+ return formatLong2.time({
136441
+ width: "short"
136442
+ });
136443
+ case "pp":
136444
+ return formatLong2.time({
136445
+ width: "medium"
136446
+ });
136447
+ case "ppp":
136448
+ return formatLong2.time({
136449
+ width: "long"
136450
+ });
136451
+ case "pppp":
136452
+ default:
136453
+ return formatLong2.time({
136454
+ width: "full"
136455
+ });
136456
+ }
136457
+ }
136458
+ __name(timeLongFormatter, "timeLongFormatter");
136459
+ function dateTimeLongFormatter(pattern, formatLong2) {
136460
+ var matchResult = pattern.match(/(P+)(p+)?/) || [];
136461
+ var datePattern = matchResult[1];
136462
+ var timePattern = matchResult[2];
136463
+ if (!timePattern) {
136464
+ return dateLongFormatter(pattern, formatLong2);
136465
+ }
136466
+ var dateTimeFormat;
136467
+ switch (datePattern) {
136468
+ case "P":
136469
+ dateTimeFormat = formatLong2.dateTime({
136470
+ width: "short"
136471
+ });
136472
+ break;
136473
+ case "PP":
136474
+ dateTimeFormat = formatLong2.dateTime({
136475
+ width: "medium"
136476
+ });
136477
+ break;
136478
+ case "PPP":
136479
+ dateTimeFormat = formatLong2.dateTime({
136480
+ width: "long"
136481
+ });
136482
+ break;
136483
+ case "PPPP":
136484
+ default:
136485
+ dateTimeFormat = formatLong2.dateTime({
136486
+ width: "full"
136890
136487
  });
136488
+ break;
136489
+ }
136490
+ return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
136491
+ }
136492
+ __name(dateTimeLongFormatter, "dateTimeLongFormatter");
136493
+ var longFormatters = {
136494
+ p: timeLongFormatter,
136495
+ P: dateTimeLongFormatter
136496
+ };
136497
+ var longFormatters_default = longFormatters;
136498
+ var protectedDayOfYearTokens = ["D", "DD"];
136499
+ var protectedWeekYearTokens = ["YY", "YYYY"];
136500
+ function isProtectedDayOfYearToken(token) {
136501
+ return protectedDayOfYearTokens.indexOf(token) !== -1;
136502
+ }
136503
+ __name(isProtectedDayOfYearToken, "isProtectedDayOfYearToken");
136504
+ function isProtectedWeekYearToken(token) {
136505
+ return protectedWeekYearTokens.indexOf(token) !== -1;
136506
+ }
136507
+ __name(isProtectedWeekYearToken, "isProtectedWeekYearToken");
136508
+ function throwProtectedError(token, format2, input) {
136509
+ if (token === "YYYY") {
136510
+ throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
136511
+ } else if (token === "YY") {
136512
+ throw new RangeError("Use `yy` instead of `YY` (in `".concat(format2, "`) for formatting years to the input `").concat(input, "`; see: https://git.io/fxCyr"));
136513
+ } else if (token === "D") {
136514
+ 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"));
136515
+ } else if (token === "DD") {
136516
+ 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"));
136517
+ }
136518
+ }
136519
+ __name(throwProtectedError, "throwProtectedError");
136520
+ var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
136521
+ var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
136522
+ var escapedStringRegExp = /^'([^]*?)'?$/;
136523
+ var doubleQuoteRegExp = /''/g;
136524
+ var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
136525
+ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
136526
+ requiredArgs(2, arguments);
136527
+ var formatStr = String(dirtyFormatStr);
136528
+ var options = dirtyOptions || {};
136529
+ var locale2 = options.locale || en_US_default;
136530
+ var localeFirstWeekContainsDate = locale2.options && locale2.options.firstWeekContainsDate;
136531
+ var defaultFirstWeekContainsDate = localeFirstWeekContainsDate == null ? 1 : toInteger(localeFirstWeekContainsDate);
136532
+ var firstWeekContainsDate = options.firstWeekContainsDate == null ? defaultFirstWeekContainsDate : toInteger(options.firstWeekContainsDate);
136533
+ if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
136534
+ throw new RangeError("firstWeekContainsDate must be between 1 and 7 inclusively");
136535
+ }
136536
+ var localeWeekStartsOn = locale2.options && locale2.options.weekStartsOn;
136537
+ var defaultWeekStartsOn = localeWeekStartsOn == null ? 0 : toInteger(localeWeekStartsOn);
136538
+ var weekStartsOn = options.weekStartsOn == null ? defaultWeekStartsOn : toInteger(options.weekStartsOn);
136539
+ if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
136540
+ throw new RangeError("weekStartsOn must be between 0 and 6 inclusively");
136541
+ }
136542
+ if (!locale2.localize) {
136543
+ throw new RangeError("locale must contain localize property");
136544
+ }
136545
+ if (!locale2.formatLong) {
136546
+ throw new RangeError("locale must contain formatLong property");
136547
+ }
136548
+ var originalDate = toDate(dirtyDate);
136549
+ if (!isValid2(originalDate)) {
136550
+ throw new RangeError("Invalid time value");
136551
+ }
136552
+ var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
136553
+ var utcDate = subMilliseconds(originalDate, timezoneOffset);
136554
+ var formatterOptions = {
136555
+ firstWeekContainsDate,
136556
+ weekStartsOn,
136557
+ locale: locale2,
136558
+ _originalDate: originalDate
136559
+ };
136560
+ var result = formatStr.match(longFormattingTokensRegExp).map(function(substring) {
136561
+ var firstCharacter = substring[0];
136562
+ if (firstCharacter === "p" || firstCharacter === "P") {
136563
+ var longFormatter = longFormatters_default[firstCharacter];
136564
+ return longFormatter(substring, locale2.formatLong, formatterOptions);
136891
136565
  }
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"
136566
+ return substring;
136567
+ }).join("").match(formattingTokensRegExp).map(function(substring) {
136568
+ if (substring === "''") {
136569
+ return "'";
136570
+ }
136571
+ var firstCharacter = substring[0];
136572
+ if (firstCharacter === "'") {
136573
+ return cleanEscapedString(substring);
136574
+ }
136575
+ var formatter = formatters_default[firstCharacter];
136576
+ if (formatter) {
136577
+ if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
136578
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
136579
+ }
136580
+ if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
136581
+ throwProtectedError(substring, dirtyFormatStr, dirtyDate);
136582
+ }
136583
+ return formatter(utcDate, substring, locale2.localize, formatterOptions);
136584
+ }
136585
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
136586
+ throw new RangeError("Format string contains an unescaped latin alphabet character `" + firstCharacter + "`");
136587
+ }
136588
+ return substring;
136589
+ }).join("");
136590
+ return result;
136591
+ }
136592
+ __name(format, "format");
136593
+ function cleanEscapedString(input) {
136594
+ return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, "'");
136595
+ }
136596
+ __name(cleanEscapedString, "cleanEscapedString");
136597
+ var transformErrorCheck = /* @__PURE__ */ __name((error, _credential) => {
136598
+ const prefix = error.split(" error")[0];
136599
+ return prefix || error;
136600
+ }, "transformErrorCheck");
136601
+ var transformErrorMessage = /* @__PURE__ */ __name((error, credential) => {
136602
+ if (error.startsWith("expiration")) {
136603
+ return credential.expirationDate ? `Invalid \u2022 Expired ${format(new Date(credential.expirationDate), "dd MMM yyyy").toUpperCase()}` : "Invalid \u2022 Expired";
136604
+ }
136605
+ return error;
136606
+ }, "transformErrorMessage");
136607
+ var transformCheckMessage = /* @__PURE__ */ __name((check, credential) => {
136608
+ return {
136609
+ proof: "Valid",
136610
+ expiration: credential.expirationDate ? `Valid \u2022 Expires ${format(new Date(credential.expirationDate), "dd MMM yyyy").toUpperCase()}` : "Valid \u2022 Does Not Expire"
136611
+ }[check] || check;
136612
+ }, "transformCheckMessage");
136613
+ var verifyCredential2 = /* @__PURE__ */ __name((wallet) => {
136614
+ return (credential) => __async$1(void 0, null, function* () {
136615
+ const rawVerificationCheck = yield wallet.pluginMethods.verifyCredential(credential);
136616
+ const verificationItems = [];
136617
+ rawVerificationCheck.errors.forEach((error) => {
136618
+ verificationItems.push({
136619
+ status: VerificationStatusEnum.Failed,
136620
+ check: transformErrorCheck(error, credential),
136621
+ details: transformErrorMessage(error, credential)
136901
136622
  });
136902
- }
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"
136623
+ });
136624
+ rawVerificationCheck.warnings.forEach((warning) => {
136625
+ verificationItems.push({
136626
+ status: VerificationStatusEnum.Error,
136627
+ check: "hmm",
136628
+ message: warning
136909
136629
  });
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"
136630
+ });
136631
+ rawVerificationCheck.checks.forEach((check) => {
136632
+ verificationItems.push({
136633
+ status: VerificationStatusEnum.Success,
136634
+ check,
136635
+ message: transformCheckMessage(check, credential)
136917
136636
  });
136918
- }
136919
- return lightFormatters_default.s(date, token);
136920
- },
136921
- S: function(date, token) {
136922
- return lightFormatters_default.S(date, token);
136637
+ });
136638
+ return verificationItems;
136639
+ });
136640
+ }, "verifyCredential");
136641
+ var defaultCeramicIDXArgs = {
136642
+ modelData: {
136643
+ definitions: {
136644
+ MyVerifiableCredentials: "kjzl6cwe1jw14am5tu5hh412s19o4zm8aq3g2lpd6s4paxj2nly2lj4drp3pun2"
136645
+ },
136646
+ schemas: {
136647
+ AchievementVerifiableCredential: "ceramic://k3y52l7qbv1frylibw2725v8gem3hxs1onoh6pvux0szdduugczh0hddxo6qsd6o0",
136648
+ VerifiableCredentialsList: "ceramic://k3y52l7qbv1frxkcwfpyauky3fyl4n44izridy3blvjjzgftis40sk9w8g3remghs"
136649
+ },
136650
+ tiles: {}
136923
136651
  },
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";
136929
- }
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, ":");
136652
+ credentialAlias: "MyVerifiableCredentials",
136653
+ ceramicEndpoint: "https://ceramic-node.welibrary.io:7007",
136654
+ defaultContentFamily: "SuperSkills"
136655
+ };
136656
+ var wasm;
136657
+ var cachedTextDecoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
136658
+ cachedTextDecoder.decode();
136659
+ var cachegetUint8Memory0 = null;
136660
+ function getUint8Memory0() {
136661
+ if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) {
136662
+ cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer);
136663
+ }
136664
+ return cachegetUint8Memory0;
136665
+ }
136666
+ __name(getUint8Memory0, "getUint8Memory0");
136667
+ function getStringFromWasm0(ptr, len) {
136668
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
136669
+ }
136670
+ __name(getStringFromWasm0, "getStringFromWasm0");
136671
+ var heap = new Array(32).fill(void 0);
136672
+ heap.push(void 0, null, true, false);
136673
+ var heap_next = heap.length;
136674
+ function addHeapObject(obj) {
136675
+ if (heap_next === heap.length)
136676
+ heap.push(heap.length + 1);
136677
+ const idx = heap_next;
136678
+ heap_next = heap[idx];
136679
+ heap[idx] = obj;
136680
+ return idx;
136681
+ }
136682
+ __name(addHeapObject, "addHeapObject");
136683
+ function getObject(idx) {
136684
+ return heap[idx];
136685
+ }
136686
+ __name(getObject, "getObject");
136687
+ function dropObject(idx) {
136688
+ if (idx < 36)
136689
+ return;
136690
+ heap[idx] = heap_next;
136691
+ heap_next = idx;
136692
+ }
136693
+ __name(dropObject, "dropObject");
136694
+ function takeObject(idx) {
136695
+ const ret = getObject(idx);
136696
+ dropObject(idx);
136697
+ return ret;
136698
+ }
136699
+ __name(takeObject, "takeObject");
136700
+ var WASM_VECTOR_LEN = 0;
136701
+ var cachedTextEncoder = new TextEncoder("utf-8");
136702
+ var encodeString2 = typeof cachedTextEncoder.encodeInto === "function" ? function(arg, view) {
136703
+ return cachedTextEncoder.encodeInto(arg, view);
136704
+ } : function(arg, view) {
136705
+ const buf2 = cachedTextEncoder.encode(arg);
136706
+ view.set(buf2);
136707
+ return {
136708
+ read: arg.length,
136709
+ written: buf2.length
136710
+ };
136711
+ };
136712
+ function passStringToWasm0(arg, malloc, realloc) {
136713
+ if (realloc === void 0) {
136714
+ const buf2 = cachedTextEncoder.encode(arg);
136715
+ const ptr2 = malloc(buf2.length);
136716
+ getUint8Memory0().subarray(ptr2, ptr2 + buf2.length).set(buf2);
136717
+ WASM_VECTOR_LEN = buf2.length;
136718
+ return ptr2;
136719
+ }
136720
+ let len = arg.length;
136721
+ let ptr = malloc(len);
136722
+ const mem = getUint8Memory0();
136723
+ let offset = 0;
136724
+ for (; offset < len; offset++) {
136725
+ const code5 = arg.charCodeAt(offset);
136726
+ if (code5 > 127)
136727
+ break;
136728
+ mem[ptr + offset] = code5;
136729
+ }
136730
+ if (offset !== len) {
136731
+ if (offset !== 0) {
136732
+ arg = arg.slice(offset);
136940
136733
  }
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, ":");
136734
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
136735
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
136736
+ const ret = encodeString2(arg, view);
136737
+ offset += ret.written;
136738
+ }
136739
+ WASM_VECTOR_LEN = offset;
136740
+ return ptr;
136741
+ }
136742
+ __name(passStringToWasm0, "passStringToWasm0");
136743
+ function isLikeNone(x) {
136744
+ return x === void 0 || x === null;
136745
+ }
136746
+ __name(isLikeNone, "isLikeNone");
136747
+ var cachegetInt32Memory0 = null;
136748
+ function getInt32Memory0() {
136749
+ if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) {
136750
+ cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer);
136751
+ }
136752
+ return cachegetInt32Memory0;
136753
+ }
136754
+ __name(getInt32Memory0, "getInt32Memory0");
136755
+ function debugString(val) {
136756
+ const type = typeof val;
136757
+ if (type == "number" || type == "boolean" || val == null) {
136758
+ return `${val}`;
136759
+ }
136760
+ if (type == "string") {
136761
+ return `"${val}"`;
136762
+ }
136763
+ if (type == "symbol") {
136764
+ const description = val.description;
136765
+ if (description == null) {
136766
+ return "Symbol";
136767
+ } else {
136768
+ return `Symbol(${description})`;
136955
136769
  }
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, ":");
136770
+ }
136771
+ if (type == "function") {
136772
+ const name5 = val.name;
136773
+ if (typeof name5 == "string" && name5.length > 0) {
136774
+ return `Function(${name5})`;
136775
+ } else {
136776
+ return "Function";
136968
136777
  }
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, ":");
136778
+ }
136779
+ if (Array.isArray(val)) {
136780
+ const length2 = val.length;
136781
+ let debug = "[";
136782
+ if (length2 > 0) {
136783
+ debug += debugString(val[0]);
136981
136784
  }
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);
136785
+ for (let i = 1; i < length2; i++) {
136786
+ debug += ", " + debugString(val[i]);
136787
+ }
136788
+ debug += "]";
136789
+ return debug;
136992
136790
  }
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);
136791
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
136792
+ let className;
136793
+ if (builtInMatches.length > 1) {
136794
+ className = builtInMatches[1];
136795
+ } else {
136796
+ return toString.call(val);
137001
136797
  }
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);
136798
+ if (className == "Object") {
136799
+ try {
136800
+ return "Object(" + JSON.stringify(val) + ")";
136801
+ } catch (_) {
136802
+ return "Object";
136803
+ }
137010
136804
  }
137011
- return formatTimezone(offset, dirtyDelimiter);
136805
+ if (val instanceof Error) {
136806
+ return `${val.name}: ${val.message}
136807
+ ${val.stack}`;
136808
+ }
136809
+ return className;
137012
136810
  }
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;
136811
+ __name(debugString, "debugString");
136812
+ function makeMutClosure(arg0, arg1, dtor, f) {
136813
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
136814
+ const real = /* @__PURE__ */ __name((...args) => {
136815
+ state.cnt++;
136816
+ const a = state.a;
136817
+ state.a = 0;
136818
+ try {
136819
+ return f(a, state.b, ...args);
136820
+ } finally {
136821
+ if (--state.cnt === 0) {
136822
+ wasm.__wbindgen_export_2.get(state.dtor)(a, state.b);
136823
+ } else {
136824
+ state.a = a;
136825
+ }
136826
+ }
136827
+ }, "real");
136828
+ real.original = state;
136829
+ return real;
137021
136830
  }
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
- }
136831
+ __name(makeMutClosure, "makeMutClosure");
136832
+ function __wbg_adapter_24(arg0, arg1, arg2) {
136833
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h91a8814f66f14b17(arg0, arg1, addHeapObject(arg2));
137044
136834
  }
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
- });
136835
+ __name(__wbg_adapter_24, "__wbg_adapter_24");
136836
+ function passArray8ToWasm0(arg, malloc) {
136837
+ const ptr = malloc(arg.length * 1);
136838
+ getUint8Memory0().set(arg, ptr / 1);
136839
+ WASM_VECTOR_LEN = arg.length;
136840
+ return ptr;
136841
+ }
136842
+ __name(passArray8ToWasm0, "passArray8ToWasm0");
136843
+ function generateEd25519KeyFromBytes(bytes) {
136844
+ try {
136845
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
136846
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
136847
+ const len0 = WASM_VECTOR_LEN;
136848
+ wasm.generateEd25519KeyFromBytes(retptr, ptr0, len0);
136849
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
136850
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
136851
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
136852
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
136853
+ var ptr1 = r0;
136854
+ var len1 = r1;
136855
+ if (r3) {
136856
+ ptr1 = 0;
136857
+ len1 = 0;
136858
+ throw takeObject(r2);
136859
+ }
136860
+ return getStringFromWasm0(ptr1, len1);
136861
+ } finally {
136862
+ wasm.__wbindgen_add_to_stack_pointer(16);
136863
+ wasm.__wbindgen_free(ptr1, len1);
137065
136864
  }
137066
136865
  }
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);
136866
+ __name(generateEd25519KeyFromBytes, "generateEd25519KeyFromBytes");
136867
+ function generateSecp256k1KeyFromBytes(bytes) {
136868
+ try {
136869
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
136870
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
136871
+ const len0 = WASM_VECTOR_LEN;
136872
+ wasm.generateSecp256k1KeyFromBytes(retptr, ptr0, len0);
136873
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
136874
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
136875
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
136876
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
136877
+ var ptr1 = r0;
136878
+ var len1 = r1;
136879
+ if (r3) {
136880
+ ptr1 = 0;
136881
+ len1 = 0;
136882
+ throw takeObject(r2);
136883
+ }
136884
+ return getStringFromWasm0(ptr1, len1);
136885
+ } finally {
136886
+ wasm.__wbindgen_add_to_stack_pointer(16);
136887
+ wasm.__wbindgen_free(ptr1, len1);
137074
136888
  }
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;
136889
+ }
136890
+ __name(generateSecp256k1KeyFromBytes, "generateSecp256k1KeyFromBytes");
136891
+ function keyToDID(method_pattern, jwk) {
136892
+ try {
136893
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
136894
+ const ptr0 = passStringToWasm0(method_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136895
+ const len0 = WASM_VECTOR_LEN;
136896
+ const ptr1 = passStringToWasm0(jwk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136897
+ const len1 = WASM_VECTOR_LEN;
136898
+ wasm.keyToDID(retptr, ptr0, len0, ptr1, len1);
136899
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
136900
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
136901
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
136902
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
136903
+ var ptr2 = r0;
136904
+ var len2 = r1;
136905
+ if (r3) {
136906
+ ptr2 = 0;
136907
+ len2 = 0;
136908
+ throw takeObject(r2);
136909
+ }
136910
+ return getStringFromWasm0(ptr2, len2);
136911
+ } finally {
136912
+ wasm.__wbindgen_add_to_stack_pointer(16);
136913
+ wasm.__wbindgen_free(ptr2, len2);
137098
136914
  }
137099
- return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
137100
136915
  }
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;
136916
+ __name(keyToDID, "keyToDID");
136917
+ function keyToVerificationMethod(method_pattern, jwk) {
136918
+ const ptr0 = passStringToWasm0(method_pattern, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136919
+ const len0 = WASM_VECTOR_LEN;
136920
+ const ptr1 = passStringToWasm0(jwk, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136921
+ const len1 = WASM_VECTOR_LEN;
136922
+ const ret = wasm.keyToVerificationMethod(ptr0, len0, ptr1, len1);
136923
+ return takeObject(ret);
136924
+ }
136925
+ __name(keyToVerificationMethod, "keyToVerificationMethod");
136926
+ function issueCredential2(credential, proof_options, key2) {
136927
+ const ptr0 = passStringToWasm0(credential, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136928
+ const len0 = WASM_VECTOR_LEN;
136929
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136930
+ const len1 = WASM_VECTOR_LEN;
136931
+ const ptr2 = passStringToWasm0(key2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136932
+ const len2 = WASM_VECTOR_LEN;
136933
+ const ret = wasm.issueCredential(ptr0, len0, ptr1, len1, ptr2, len2);
136934
+ return takeObject(ret);
136935
+ }
136936
+ __name(issueCredential2, "issueCredential");
136937
+ function verifyCredential3(vc, proof_options) {
136938
+ const ptr0 = passStringToWasm0(vc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136939
+ const len0 = WASM_VECTOR_LEN;
136940
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136941
+ const len1 = WASM_VECTOR_LEN;
136942
+ const ret = wasm.verifyCredential(ptr0, len0, ptr1, len1);
136943
+ return takeObject(ret);
137111
136944
  }
137112
- __name(isProtectedDayOfYearToken, "isProtectedDayOfYearToken");
137113
- function isProtectedWeekYearToken(token) {
137114
- return protectedWeekYearTokens.indexOf(token) !== -1;
136945
+ __name(verifyCredential3, "verifyCredential");
136946
+ function issuePresentation2(presentation, proof_options, key2) {
136947
+ const ptr0 = passStringToWasm0(presentation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136948
+ const len0 = WASM_VECTOR_LEN;
136949
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136950
+ const len1 = WASM_VECTOR_LEN;
136951
+ const ptr2 = passStringToWasm0(key2, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136952
+ const len2 = WASM_VECTOR_LEN;
136953
+ const ret = wasm.issuePresentation(ptr0, len0, ptr1, len1, ptr2, len2);
136954
+ return takeObject(ret);
137115
136955
  }
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
- }
136956
+ __name(issuePresentation2, "issuePresentation");
136957
+ function verifyPresentation2(vp, proof_options) {
136958
+ const ptr0 = passStringToWasm0(vp, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136959
+ const len0 = WASM_VECTOR_LEN;
136960
+ const ptr1 = passStringToWasm0(proof_options, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
136961
+ const len1 = WASM_VECTOR_LEN;
136962
+ const ret = wasm.verifyPresentation(ptr0, len0, ptr1, len1);
136963
+ return takeObject(ret);
137127
136964
  }
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");
136965
+ __name(verifyPresentation2, "verifyPresentation");
136966
+ function handleError(f, args) {
136967
+ try {
136968
+ return f.apply(this, args);
136969
+ } catch (e) {
136970
+ wasm.__wbindgen_exn_store(addHeapObject(e));
137160
136971
  }
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);
136972
+ }
136973
+ __name(handleError, "handleError");
136974
+ function getArrayU8FromWasm0(ptr, len) {
136975
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
136976
+ }
136977
+ __name(getArrayU8FromWasm0, "getArrayU8FromWasm0");
136978
+ function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
136979
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h3ecfeb7a01c1be81(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
136980
+ }
136981
+ __name(__wbg_adapter_110, "__wbg_adapter_110");
136982
+ function load(module, imports) {
136983
+ return __async$1(this, null, function* () {
136984
+ if (typeof Response === "function" && module instanceof Response) {
136985
+ if (typeof WebAssembly.instantiateStreaming === "function") {
136986
+ try {
136987
+ return yield WebAssembly.instantiateStreaming(module, imports);
136988
+ } catch (e) {
136989
+ if (module.headers.get("Content-Type") != "application/wasm") {
136990
+ 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);
136991
+ } else {
136992
+ throw e;
136993
+ }
136994
+ }
136995
+ }
136996
+ const bytes = yield module.arrayBuffer();
136997
+ return yield WebAssembly.instantiate(bytes, imports);
136998
+ } else {
136999
+ const instance = yield WebAssembly.instantiate(module, imports);
137000
+ if (instance instanceof WebAssembly.Instance) {
137001
+ return { instance, module };
137002
+ } else {
137003
+ return instance;
137004
+ }
137183
137005
  }
137184
- var formatter = formatters_default[firstCharacter];
137185
- if (formatter) {
137186
- if (!options.useAdditionalWeekYearTokens && isProtectedWeekYearToken(substring)) {
137187
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
137006
+ });
137007
+ }
137008
+ __name(load, "load");
137009
+ function init2(input) {
137010
+ return __async$1(this, null, function* () {
137011
+ const imports = {};
137012
+ imports.wbg = {};
137013
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
137014
+ const ret = getStringFromWasm0(arg0, arg1);
137015
+ return addHeapObject(ret);
137016
+ };
137017
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
137018
+ takeObject(arg0);
137019
+ };
137020
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
137021
+ const obj = takeObject(arg0).original;
137022
+ if (obj.cnt-- == 1) {
137023
+ obj.a = 0;
137024
+ return true;
137188
137025
  }
137189
- if (!options.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(substring)) {
137190
- throwProtectedError(substring, dirtyFormatStr, dirtyDate);
137026
+ const ret = false;
137027
+ return ret;
137028
+ };
137029
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
137030
+ const ret = getObject(arg0);
137031
+ return addHeapObject(ret);
137032
+ };
137033
+ imports.wbg.__wbg_fetch_811d43d6bdcad5b1 = function(arg0) {
137034
+ const ret = fetch(getObject(arg0));
137035
+ return addHeapObject(ret);
137036
+ };
137037
+ imports.wbg.__wbg_fetch_bf56e2a9f0644e3f = function(arg0, arg1) {
137038
+ const ret = getObject(arg0).fetch(getObject(arg1));
137039
+ return addHeapObject(ret);
137040
+ };
137041
+ imports.wbg.__wbg_new_89d7f088c1c45353 = function() {
137042
+ return handleError(function() {
137043
+ const ret = new Headers();
137044
+ return addHeapObject(ret);
137045
+ }, arguments);
137046
+ };
137047
+ imports.wbg.__wbg_append_f4f93bc73c45ee3e = function() {
137048
+ return handleError(function(arg0, arg1, arg2, arg3, arg4) {
137049
+ getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
137050
+ }, arguments);
137051
+ };
137052
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
137053
+ const obj = getObject(arg1);
137054
+ const ret = typeof obj === "string" ? obj : void 0;
137055
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
137056
+ var len0 = WASM_VECTOR_LEN;
137057
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
137058
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
137059
+ };
137060
+ imports.wbg.__wbg_instanceof_Response_ccfeb62399355bcd = function(arg0) {
137061
+ const ret = getObject(arg0) instanceof Response;
137062
+ return ret;
137063
+ };
137064
+ imports.wbg.__wbg_url_06c0f822d68d195c = function(arg0, arg1) {
137065
+ const ret = getObject(arg1).url;
137066
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
137067
+ const len0 = WASM_VECTOR_LEN;
137068
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
137069
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
137070
+ };
137071
+ imports.wbg.__wbg_status_600fd8b881393898 = function(arg0) {
137072
+ const ret = getObject(arg0).status;
137073
+ return ret;
137074
+ };
137075
+ imports.wbg.__wbg_headers_9e7f2c05a9b962ea = function(arg0) {
137076
+ const ret = getObject(arg0).headers;
137077
+ return addHeapObject(ret);
137078
+ };
137079
+ imports.wbg.__wbg_arrayBuffer_5a99283a3954c850 = function() {
137080
+ return handleError(function(arg0) {
137081
+ const ret = getObject(arg0).arrayBuffer();
137082
+ return addHeapObject(ret);
137083
+ }, arguments);
137084
+ };
137085
+ imports.wbg.__wbg_newwithstrandinit_fd99688f189f053e = function() {
137086
+ return handleError(function(arg0, arg1, arg2) {
137087
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
137088
+ return addHeapObject(ret);
137089
+ }, arguments);
137090
+ };
137091
+ imports.wbg.__wbindgen_is_object = function(arg0) {
137092
+ const val = getObject(arg0);
137093
+ const ret = typeof val === "object" && val !== null;
137094
+ return ret;
137095
+ };
137096
+ imports.wbg.__wbg_self_86b4b13392c7af56 = function() {
137097
+ return handleError(function() {
137098
+ const ret = self.self;
137099
+ return addHeapObject(ret);
137100
+ }, arguments);
137101
+ };
137102
+ imports.wbg.__wbg_crypto_b8c92eaac23d0d80 = function(arg0) {
137103
+ const ret = getObject(arg0).crypto;
137104
+ return addHeapObject(ret);
137105
+ };
137106
+ imports.wbg.__wbg_msCrypto_9ad6677321a08dd8 = function(arg0) {
137107
+ const ret = getObject(arg0).msCrypto;
137108
+ return addHeapObject(ret);
137109
+ };
137110
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
137111
+ const ret = getObject(arg0) === void 0;
137112
+ return ret;
137113
+ };
137114
+ imports.wbg.__wbg_static_accessor_MODULE_452b4680e8614c81 = function() {
137115
+ const ret = module;
137116
+ return addHeapObject(ret);
137117
+ };
137118
+ imports.wbg.__wbg_require_f5521a5b85ad2542 = function(arg0, arg1, arg2) {
137119
+ const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
137120
+ return addHeapObject(ret);
137121
+ };
137122
+ imports.wbg.__wbg_getRandomValues_dd27e6b0652b3236 = function(arg0) {
137123
+ const ret = getObject(arg0).getRandomValues;
137124
+ return addHeapObject(ret);
137125
+ };
137126
+ imports.wbg.__wbg_getRandomValues_e57c9b75ddead065 = function(arg0, arg1) {
137127
+ getObject(arg0).getRandomValues(getObject(arg1));
137128
+ };
137129
+ imports.wbg.__wbg_randomFillSync_d2ba53160aec6aba = function(arg0, arg1, arg2) {
137130
+ getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
137131
+ };
137132
+ imports.wbg.__wbindgen_is_function = function(arg0) {
137133
+ const ret = typeof getObject(arg0) === "function";
137134
+ return ret;
137135
+ };
137136
+ imports.wbg.__wbg_newnoargs_e23b458e372830de = function(arg0, arg1) {
137137
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
137138
+ return addHeapObject(ret);
137139
+ };
137140
+ imports.wbg.__wbg_next_cabb70b365520721 = function(arg0) {
137141
+ const ret = getObject(arg0).next;
137142
+ return addHeapObject(ret);
137143
+ };
137144
+ imports.wbg.__wbg_next_bf3d83fc18df496e = function() {
137145
+ return handleError(function(arg0) {
137146
+ const ret = getObject(arg0).next();
137147
+ return addHeapObject(ret);
137148
+ }, arguments);
137149
+ };
137150
+ imports.wbg.__wbg_done_040f966faa9a72b3 = function(arg0) {
137151
+ const ret = getObject(arg0).done;
137152
+ return ret;
137153
+ };
137154
+ imports.wbg.__wbg_value_419afbd9b9574c4c = function(arg0) {
137155
+ const ret = getObject(arg0).value;
137156
+ return addHeapObject(ret);
137157
+ };
137158
+ imports.wbg.__wbg_iterator_4832ef1f15b0382b = function() {
137159
+ const ret = Symbol.iterator;
137160
+ return addHeapObject(ret);
137161
+ };
137162
+ imports.wbg.__wbg_get_a9cab131e3152c49 = function() {
137163
+ return handleError(function(arg0, arg1) {
137164
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
137165
+ return addHeapObject(ret);
137166
+ }, arguments);
137167
+ };
137168
+ imports.wbg.__wbg_call_ae78342adc33730a = function() {
137169
+ return handleError(function(arg0, arg1) {
137170
+ const ret = getObject(arg0).call(getObject(arg1));
137171
+ return addHeapObject(ret);
137172
+ }, arguments);
137173
+ };
137174
+ imports.wbg.__wbg_new_36359baae5a47e27 = function() {
137175
+ const ret = new Object();
137176
+ return addHeapObject(ret);
137177
+ };
137178
+ imports.wbg.__wbg_call_3ed288a247f13ea5 = function() {
137179
+ return handleError(function(arg0, arg1, arg2) {
137180
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
137181
+ return addHeapObject(ret);
137182
+ }, arguments);
137183
+ };
137184
+ imports.wbg.__wbg_getTime_bffb1c09df09618b = function(arg0) {
137185
+ const ret = getObject(arg0).getTime();
137186
+ return ret;
137187
+ };
137188
+ imports.wbg.__wbg_new0_0ff7eb5c1486f3ec = function() {
137189
+ const ret = new Date();
137190
+ return addHeapObject(ret);
137191
+ };
137192
+ imports.wbg.__wbg_new_37705eed627d5ed9 = function(arg0, arg1) {
137193
+ try {
137194
+ var state0 = { a: arg0, b: arg1 };
137195
+ var cb0 = /* @__PURE__ */ __name((arg02, arg12) => {
137196
+ const a = state0.a;
137197
+ state0.a = 0;
137198
+ try {
137199
+ return __wbg_adapter_110(a, state0.b, arg02, arg12);
137200
+ } finally {
137201
+ state0.a = a;
137202
+ }
137203
+ }, "cb0");
137204
+ const ret = new Promise(cb0);
137205
+ return addHeapObject(ret);
137206
+ } finally {
137207
+ state0.a = state0.b = 0;
137191
137208
  }
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 + "`");
137209
+ };
137210
+ imports.wbg.__wbg_resolve_a9a87bdd64e9e62c = function(arg0) {
137211
+ const ret = Promise.resolve(getObject(arg0));
137212
+ return addHeapObject(ret);
137213
+ };
137214
+ imports.wbg.__wbg_then_ce526c837d07b68f = function(arg0, arg1) {
137215
+ const ret = getObject(arg0).then(getObject(arg1));
137216
+ return addHeapObject(ret);
137217
+ };
137218
+ imports.wbg.__wbg_then_842e65b843962f56 = function(arg0, arg1, arg2) {
137219
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
137220
+ return addHeapObject(ret);
137221
+ };
137222
+ imports.wbg.__wbg_self_99737b4dcdf6f0d8 = function() {
137223
+ return handleError(function() {
137224
+ const ret = self.self;
137225
+ return addHeapObject(ret);
137226
+ }, arguments);
137227
+ };
137228
+ imports.wbg.__wbg_window_9b61fbbf3564c4fb = function() {
137229
+ return handleError(function() {
137230
+ const ret = window.window;
137231
+ return addHeapObject(ret);
137232
+ }, arguments);
137233
+ };
137234
+ imports.wbg.__wbg_globalThis_8e275ef40caea3a3 = function() {
137235
+ return handleError(function() {
137236
+ const ret = globalThis.globalThis;
137237
+ return addHeapObject(ret);
137238
+ }, arguments);
137239
+ };
137240
+ imports.wbg.__wbg_global_5de1e0f82bddcd27 = function() {
137241
+ return handleError(function() {
137242
+ const ret = global.global;
137243
+ return addHeapObject(ret);
137244
+ }, arguments);
137245
+ };
137246
+ imports.wbg.__wbg_buffer_7af23f65f6c64548 = function(arg0) {
137247
+ const ret = getObject(arg0).buffer;
137248
+ return addHeapObject(ret);
137249
+ };
137250
+ imports.wbg.__wbg_newwithbyteoffsetandlength_ce1e75f0ce5f7974 = function(arg0, arg1, arg2) {
137251
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
137252
+ return addHeapObject(ret);
137253
+ };
137254
+ imports.wbg.__wbg_new_cc9018bd6f283b6f = function(arg0) {
137255
+ const ret = new Uint8Array(getObject(arg0));
137256
+ return addHeapObject(ret);
137257
+ };
137258
+ imports.wbg.__wbg_set_f25e869e4565d2a2 = function(arg0, arg1, arg2) {
137259
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
137260
+ };
137261
+ imports.wbg.__wbg_length_0acb1cf9bbaf8519 = function(arg0) {
137262
+ const ret = getObject(arg0).length;
137263
+ return ret;
137264
+ };
137265
+ imports.wbg.__wbg_newwithlength_8f0657faca9f1422 = function(arg0) {
137266
+ const ret = new Uint8Array(arg0 >>> 0);
137267
+ return addHeapObject(ret);
137268
+ };
137269
+ imports.wbg.__wbg_subarray_da527dbd24eafb6b = function(arg0, arg1, arg2) {
137270
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
137271
+ return addHeapObject(ret);
137272
+ };
137273
+ imports.wbg.__wbg_has_ce995ec88636803d = function() {
137274
+ return handleError(function(arg0, arg1) {
137275
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
137276
+ return ret;
137277
+ }, arguments);
137278
+ };
137279
+ imports.wbg.__wbg_set_93b1c87ee2af852e = function() {
137280
+ return handleError(function(arg0, arg1, arg2) {
137281
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
137282
+ return ret;
137283
+ }, arguments);
137284
+ };
137285
+ imports.wbg.__wbg_stringify_c760003feffcc1f2 = function() {
137286
+ return handleError(function(arg0) {
137287
+ const ret = JSON.stringify(getObject(arg0));
137288
+ return addHeapObject(ret);
137289
+ }, arguments);
137290
+ };
137291
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
137292
+ const ret = debugString(getObject(arg1));
137293
+ const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
137294
+ const len0 = WASM_VECTOR_LEN;
137295
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
137296
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
137297
+ };
137298
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
137299
+ throw new Error(getStringFromWasm0(arg0, arg1));
137300
+ };
137301
+ imports.wbg.__wbindgen_memory = function() {
137302
+ const ret = wasm.memory;
137303
+ return addHeapObject(ret);
137304
+ };
137305
+ imports.wbg.__wbindgen_closure_wrapper10913 = function(arg0, arg1, arg2) {
137306
+ const ret = makeMutClosure(arg0, arg1, 3725, __wbg_adapter_24);
137307
+ return addHeapObject(ret);
137308
+ };
137309
+ if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
137310
+ input = fetch(input);
137196
137311
  }
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;
137312
+ const { instance, module } = yield load(yield input, imports);
137313
+ wasm = instance.exports;
137314
+ init2.__wbindgen_wasm_module = module;
137315
+ return wasm;
137248
137316
  });
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
- };
137317
+ }
137318
+ __name(init2, "init");
137319
+ var didkit_wasm_default = init2;
137320
+ var initialized = false;
137321
+ var init3 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/dlXanMvQCGDR76JXcBkA") => __async$1(void 0, null, function* () {
137322
+ if (initialized)
137323
+ return;
137324
+ initialized = true;
137325
+ return didkit_wasm_default(arg);
137326
+ }), "init");
137327
+ var didkit_default = init3;
137265
137328
  var getDidKitPlugin = /* @__PURE__ */ __name((input) => __async$1(void 0, null, function* () {
137266
137329
  yield didkit_default(input);
137330
+ const memoizedDids = {};
137267
137331
  return {
137268
137332
  pluginMethods: {
137269
137333
  generateEd25519KeyFromBytes: (_wallet, bytes) => JSON.parse(generateEd25519KeyFromBytes(bytes)),
137270
- keyToDid: (_wallet, type, keypair) => keyToDID(type, JSON.stringify(keypair)),
137334
+ generateSecp256k1KeyFromBytes: (_wallet, bytes) => JSON.parse(generateSecp256k1KeyFromBytes(bytes)),
137335
+ keyToDid: (_wallet, type, keypair) => {
137336
+ const memoizedDid = memoizedDids[type];
137337
+ if (!memoizedDid) {
137338
+ const did = keyToDID(type, JSON.stringify(keypair));
137339
+ memoizedDids[type] = did;
137340
+ return did;
137341
+ }
137342
+ return memoizedDid;
137343
+ },
137271
137344
  keyToVerificationMethod: (_wallet, type, keypair) => __async$1(void 0, null, function* () {
137272
137345
  return keyToVerificationMethod(type, JSON.stringify(keypair));
137273
137346
  }),
137274
137347
  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)));
137348
+ return JSON.parse(yield issueCredential2(JSON.stringify(credential), JSON.stringify(options), JSON.stringify(keypair)));
137276
137349
  }),
137277
137350
  verifyCredential: (_wallet, credential) => __async$1(void 0, null, function* () {
137278
- return JSON.parse(yield verifyCredential(JSON.stringify(credential), "{}"));
137351
+ return JSON.parse(yield verifyCredential3(JSON.stringify(credential), "{}"));
137279
137352
  }),
137280
- issuePresentation: (presentation, options, keypair) => __async$1(void 0, null, function* () {
137281
- return issuePresentation(JSON.stringify(presentation), JSON.stringify(options), JSON.stringify(keypair));
137353
+ issuePresentation: (_wallet, presentation, options, keypair) => __async$1(void 0, null, function* () {
137354
+ return JSON.parse(yield issuePresentation2(JSON.stringify(presentation), JSON.stringify(options), JSON.stringify(keypair)));
137282
137355
  }),
137283
137356
  verifyPresentation: (_wallet, presentation) => __async$1(void 0, null, function* () {
137284
- return JSON.parse(yield verifyPresentation(JSON.stringify(presentation), "{}"));
137357
+ return JSON.parse(yield verifyPresentation2(JSON.stringify(presentation), "{}"));
137285
137358
  })
137286
137359
  }
137287
137360
  };
@@ -137291,7 +137364,6 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async$1(void 0, [_0,
137291
137364
  didkit,
137292
137365
  defaultContents = []
137293
137366
  } = {}) {
137294
- yield didkit_default(didkit);
137295
137367
  const didkitWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getDidKitPlugin(didkit));
137296
137368
  const didkeyWallet = yield didkitWallet.addPlugin(yield getDidKeyPlugin(didkitWallet, key2));
137297
137369
  const didkeyAndVCWallet = yield didkeyWallet.addPlugin(yield getVCPlugin(didkeyWallet));
@@ -137299,14 +137371,10 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async$1(void 0, [_0,
137299
137371
  const wallet = yield idxWallet.addPlugin(ExpirationPlugin(idxWallet));
137300
137372
  return {
137301
137373
  _wallet: wallet,
137302
- get did() {
137303
- return wallet.pluginMethods.getSubjectDid();
137304
- },
137305
- get keypair() {
137306
- return wallet.pluginMethods.getSubjectKeypair();
137307
- },
137374
+ did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
137375
+ keypair: (type = "ed25519") => wallet.pluginMethods.getSubjectKeypair(type),
137308
137376
  issueCredential: wallet.pluginMethods.issueCredential,
137309
- verifyCredential: verifyCredential3(wallet),
137377
+ verifyCredential: verifyCredential2(wallet),
137310
137378
  issuePresentation: wallet.pluginMethods.issuePresentation,
137311
137379
  verifyPresentation: wallet.pluginMethods.verifyPresentation,
137312
137380
  getCredential: wallet.pluginMethods.getVerifiableCredentialFromIndex,
@@ -137380,4 +137448,4 @@ const VCCard = ({ credential, issueeOverride, className = "" }) => {
137380
137448
  };
137381
137449
 
137382
137450
  exports.VCCard = VCCard;
137383
- //# sourceMappingURL=VCCard-5495759e.js.map
137451
+ //# sourceMappingURL=VCCard-5e260b6b.js.map