@jmcanterafonseca-iota/anchoring-channels
Version:
Powered by IOTA Streams, Anchor Channels is an easy to be used library that allows to anchor messages to the Tangle.
1 lines • 59.2 kB
JavaScript
"use strict";var t=require("@jmcanterafonseca-iota/iota_streams_wasm"),e=require("crypto"),r=require("node-fetch"),n=require("jsonld"),o=require("path"),i=require("fs"),_=require("bs58"),s=require("elliptic");function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var c=a(t),u=a(e),d=a(r),l=a(n),f=a(o),p=a(i),h=a(_),g=a(s),w="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function b(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var y={},O={},v={};Object.defineProperty(v,"__esModule",{value:!0});class m extends Error{constructor(t,e){super(),this.type=m.ERR_TYPE,this.name=t,this.message=e}}v.default=m,m.ERR_TYPE="AnchoringChannelError";var S={};Object.defineProperty(S,"__esModule",{value:!0});class N{}S.default=N,N.CHANNEL_NOT_BOUND="Not_Bound",N.ANCHORAGE_NOT_FOUND="Anchorage_Not_Found",N.MSG_NOT_FOUND="Message_Not_Found",N.CHANNEL_BINDING_ERROR="Channel_Binding_Error",N.CHANNEL_ALREADY_BOUND="Channel_Already_Bound",N.OTHER_ERROR="Runtime_Error",N.INVALID_NODE="Invalid_Node",N.INVALID_DID="Invalid_DID",N.DID_NOT_FOUND="DID_Not_Found",N.INVALID_DID_METHOD="Invalid_DID_Method",N.DID_NOT_VERIFIED="DID_Not_Verified",N.INVALID_SIGNING_KEY="Invalid_Signing_Key",N.NOT_SUPPORTED_SIGNATURE="Not_Supported_Signature",N.INVALID_DATA_TYPE="Invalid_Data_Type",N.JSON_DOC_NOT_SIGNED="JSON_Doc_Not_Signed";var J={},D=w&&w.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),x=w&&w.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),I=w&&w.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&D(e,t,r);return x(e,t),e},j=w&&w.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function _(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(_,s)}a((n=n.apply(t,e||[])).next())}))};Object.defineProperty(J,"__esModule",{value:!0}),J.ChannelHelper=void 0;const k=c.default,T=I(u.default);J.ChannelHelper=class{static generateSeed(t=20){const e="abcdefghijklmnopqrstuvwxyz";let r="";for(;r.length<t;){r+=e[T.randomBytes(1)[0]%e.length]}return r}static findAnchorage(t,e){return j(this,void 0,void 0,(function*(){let r,n=!1;const o=k.Address.from_string(`${t.clone().channel_address()}:${e}`);let i;try{i=yield t.clone().receive_signed_packet(o)}catch(t){}for(i&&(r=i.get_link().copy(),n=!0);!n;){const o=yield t.clone().fetch_next_msgs();if(!o||0===o.length)break;r=o[0].get_link().copy(),r.msg_id===e&&(n=!0)}return{found:n,anchorageLink:r}}))}};var E={},A=w&&w.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),M=w&&w.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),R=w&&w.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)"default"!==r&&Object.prototype.hasOwnProperty.call(t,r)&&A(e,t,r);return M(e,t),e};Object.defineProperty(E,"__esModule",{value:!0});const P=c.default,C=R(d.default);E.default=function(){w.fetch=C,w.Headers=C.Headers,w.Request=C.Request,w.Response=C.Response,P.set_panic_hook()};var L={};Object.defineProperty(L,"__esModule",{value:!0});L.default=class{static url(t){try{new URL(t)}catch(t){return!1}return!0}static did(t){return/^did:[\da-z]+:[\w.-]+/.test(t)}};var V={},U=w&&w.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function _(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(_,s)}a((n=n.apply(t,e||[])).next())}))},q=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(V,"__esModule",{value:!0});const $=c.default,H=q(v),B=q(S),K=J;V.default=class{static anchor(t){return U(this,void 0,void 0,(function*(){try{const e=t.anchorageID,r=t.subscriber,n=t.channelID.split(":")[1];let o,i=!0;if(n===e)o=$.Address.from_string(t.channelID).copy();else if(({found:i,anchorageLink:o}=yield K.ChannelHelper.findAnchorage(r,e)),!i)throw new H.default(B.default.ANCHORAGE_NOT_FOUND,`The anchorage ${e} has not been found on the channel`);const _=Buffer.from(t.message),s=Buffer.from(""),a=yield r.clone().send_signed_packet(o,_,s);return{anchorageID:e,msgID:a.get_link().msg_id}}catch(e){if(e.type===H.default.ERR_TYPE)throw e;throw new H.default(B.default.OTHER_ERROR,`Error while anchoring to ${t.anchorageID} on ${t.channelID} -> ${e}`)}}))}};var F={},G=w&&w.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function _(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(_,s)}a((n=n.apply(t,e||[])).next())}))},Y=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(F,"__esModule",{value:!0});const z=c.default,W=Y(v),Q=Y(S);F.default=class{static createChannel(t,e){return G(this,void 0,void 0,(function*(){const r=new z.SendOptions(t,!0),n=new z.Author(e,r.clone(),z.ChannelType.SingleBranch);return{announceMsgID:(yield n.clone().send_announce()).get_link().copy().msg_id,channelAddress:n.channel_address()}}))}static bindToChannel(t){return G(this,void 0,void 0,(function*(){try{const e=new z.SendOptions(t.node,!0),r=new z.Subscriber(t.seed,e.clone()),n=t.channelID,o=z.Address.from_string(n).copy();return yield r.clone().receive_announcement(o),r}catch(e){throw new W.default(Q.default.CHANNEL_BINDING_ERROR,`Cannot bind to channel ${t.channelID}`)}}))}};var X={},Z=w&&w.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function _(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(_,s)}a((n=n.apply(t,e||[])).next())}))},tt=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(X,"__esModule",{value:!0});const et=c.default,rt=tt(v),nt=tt(S),ot=J;X.default=class{static fetch(t){return Z(this,void 0,void 0,(function*(){const e=t.subscriber,r=t.channelID.split(":")[1],n=t.anchorageID;let o=!0;if(n!==r&&({found:o}=yield ot.ChannelHelper.findAnchorage(e,n)),!o)throw new rt.default(nt.default.ANCHORAGE_NOT_FOUND,`The anchorage point ${n} has not been found on the channel`);const i=t.msgID,_=et.Address.from_string(`${e.clone().channel_address()}:${i}`);let s;try{s=yield e.clone().receive_signed_packet(_)}catch(t){throw new rt.default(nt.default.MSG_NOT_FOUND,`The message ${i} has not been found on the Channel`)}const a=Buffer.from(s.get_message().get_public_payload()).toString();if(s.get_link().copy().msg_id!==i)throw new Error("Requested message ID and fetched message ID are not equal");return{message:a,msgID:i,pk:s.get_message().get_pk()}}))}};var it=w&&w.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function _(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(_,s)}a((n=n.apply(t,e||[])).next())}))},_t=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(O,"__esModule",{value:!0}),O.IotaAnchoringChannel=void 0;const st=_t(v),at=_t(S),ct=J,ut=_t(E),dt=_t(L),lt=_t(V),ft=_t(F),pt=_t(X);ut.default();class ht{constructor(t,e){this._node=t,this._seed=e,e||(this._seed=ct.ChannelHelper.generateSeed())}static create(t,e){if(!dt.default.url(t))throw new st.default(at.default.INVALID_NODE,"The node has to be a URL");return new ht(t,e)}bind(t){return it(this,void 0,void 0,(function*(){if(this._subscriber)throw new st.default(at.default.CHANNEL_ALREADY_BOUND,`Channel already bound to ${this._channelID}`);if(t){const e=t.split(":");if(!Array.isArray(e)||2!==e.length)throw new st.default(at.default.CHANNEL_BINDING_ERROR,`Invalid channel identifier: ${t}`);this._channelID=t,this._channelAddress=e[0],this._announceMsgID=e[1]}else{const{channelAddress:t,announceMsgID:e}=yield ft.default.createChannel(this._node,this._seed);this._channelAddress=t,this._announceMsgID=e,this._channelID=`${t}:${e}`}const e={node:this._node,seed:this._seed,channelID:this._channelID};return this._subscriber=yield ft.default.bindToChannel(e),this}))}get channelID(){return this._channelID}get channelAddr(){return this._channelAddress}get firstAnchorageID(){return this._announceMsgID}get node(){return this._node}get seed(){return this._seed}anchor(t,e){return it(this,void 0,void 0,(function*(){if(!this._channelAddress)throw new st.default(at.default.CHANNEL_NOT_BOUND,"Unbound anchoring channel. Please call bind first");const r={channelID:this._channelID,subscriber:this._subscriber,message:e,anchorageID:t};return yield lt.default.anchor(r)}))}fetch(t,e){return it(this,void 0,void 0,(function*(){if(!this._channelAddress)throw new st.default(at.default.CHANNEL_NOT_BOUND,"Unbound anchoring channel. Please call bind first");const r={channelID:this._channelID,subscriber:this._subscriber,msgID:e,anchorageID:t};return pt.default.fetch(r)}))}}O.IotaAnchoringChannel=ht;var gt={},wt={};Object.defineProperty(wt,"__esModule",{value:!0}),wt.JsonCanonicalization=void 0;wt.JsonCanonicalization=class{static calculate(t){let e="";return function t(r){if(null===r||"object"!=typeof r)e+=JSON.stringify(r);else if(Array.isArray(r)){e+="[";let n=!1;r.forEach((r=>{n&&(e+=","),n=!0,t(r)})),e+="]"}else{e+="{";let n=!1;Object.keys(r).sort().forEach((o=>{n&&(e+=","),n=!0,e+=JSON.stringify(o),e+=":",t(r[o])})),e+="}"}}(t),e}};var bt={},yt=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bt,"__esModule",{value:!0});const Ot=yt(v),vt=yt(S);bt.default=class{static getDocument(t){if("string"!=typeof t&&"object"!=typeof t||Array.isArray(t))throw new Ot.default(vt.default.INVALID_DATA_TYPE,"Please provide a Javascript object or string in JSON format");let e;if("string"==typeof t)try{e=JSON.parse(t)}catch(t){throw new Ot.default(vt.default.INVALID_DATA_TYPE,"Invalid JSON Format")}else e=JSON.parse(JSON.stringify(t));return e}static getSignedDocument(t){const e=this.getDocument(t);if(!e.proof)throw new Ot.default(vt.default.JSON_DOC_NOT_SIGNED,"The provided JSON document does not include a proof");return e}static getJsonLdDocument(t){const e=this.getDocument(t);if(!e["@context"])throw new Ot.default(vt.default.INVALID_DATA_TYPE,"Not a JSON-LD document. Use 'signJson' instead");return e}static getSignedJsonLdDocument(t){const e=this.getJsonLdDocument(t);if(!e.proof)throw new Ot.default(vt.default.JSON_DOC_NOT_SIGNED,"The provided JSON document does not include a proof");return e}};var mt={},St=w&&w.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function _(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(_,s)}a((n=n.apply(t,e||[])).next())}))};Object.defineProperty(mt,"__esModule",{value:!0}),mt.customLdContextLoader=void 0;const Nt="application/ld+json";mt.customLdContextLoader=function t(e,r){var n,o;return St(this,void 0,void 0,(function*(){(new Headers).append("accept",`application/json,${Nt}`);const r=yield fetch(e);let i,_=e;if(r.ok){const s=r.headers.get("content-type").toLowerCase();if("application/json"!==s&&s!==Nt){const i=r.headers.get("link").split(";");if((null===(n=i[1])||void 0===n?void 0:n.includes("alternate"))&&(null===(o=i[2])||void 0===o?void 0:o.includes(Nt))){const r=i[0],n=i[0].slice(1,r.length-1),o=`${e}${n}`;if(o!==e)return t(o)}}else i=yield r.json(),r.redirected&&(_=r.url)}else console.error(`The JSON-LD @context ${e} cannot be retrieved`);return{document:i,documentUrl:_}}))};var Jt={};Object.defineProperty(Jt,"__esModule",{value:!0}),Jt.LdContextURL=void 0;class Dt{}Jt.LdContextURL=Dt,Dt.W3C_SECURITY="https://w3id.org/security/v1";var xt={};Object.defineProperty(xt,"__esModule",{value:!0}),xt.SignatureTypes=void 0;class It{}xt.SignatureTypes=It,It.ED25519_2018="Ed25519Signature2018",It.JCS_ED25519_2020="JcsEd25519Signature2020";var jt={},kt={exports:{}};!function(t){const e=d.default;w.Headers=e.Headers,w.Request=e.Request,w.Response=e.Response,w.fetch=e;let r,n={};n.__wbindgen_placeholder__=t.exports;const{TextDecoder:o,TextEncoder:i,inspect:_}=require(String.raw`util`);let s=new o("utf-8",{ignoreBOM:!0,fatal:!0});s.decode();let a=null;function c(){return null!==a&&a.buffer===r.memory.buffer||(a=new Uint8Array(r.memory.buffer)),a}function u(t,e){return s.decode(c().subarray(t,t+e))}const l=new Array(32).fill(void 0);l.push(void 0,null,!0,!1);let h=l.length;function g(t){h===l.length&&l.push(l.length+1);const e=h;return h=l[e],l[e]=t,e}function b(t){return l[t]}let y=0,O=new i("utf-8");const v="function"==typeof O.encodeInto?function(t,e){return O.encodeInto(t,e)}:function(t,e){const r=O.encode(t);return e.set(r),{read:t.length,written:r.length}};function m(t,e,r){if(void 0===r){const r=O.encode(t),n=e(r.length);return c().subarray(n,n+r.length).set(r),y=r.length,n}let n=t.length,o=e(n);const i=c();let _=0;for(;_<n;_++){const e=t.charCodeAt(_);if(e>127)break;i[o+_]=e}if(_!==n){0!==_&&(t=t.slice(_)),o=r(o,n,n=_+3*t.length);const e=c().subarray(o+_,o+n);_+=v(t,e).written}return y=_,o}let S=null;function N(){return null!==S&&S.buffer===r.memory.buffer||(S=new Int32Array(r.memory.buffer)),S}function J(t){const e=b(t);return function(t){t<36||(l[t]=h,h=t)}(t),e}function D(t){return null==t}function x(t){const e=typeof t;if("number"==e||"boolean"==e||null==t)return`${t}`;if("string"==e)return`"${t}"`;if("symbol"==e){const e=t.description;return null==e?"Symbol":`Symbol(${e})`}if("function"==e){const e=t.name;return"string"==typeof e&&e.length>0?`Function(${e})`:"Function"}if(Array.isArray(t)){const e=t.length;let r="[";e>0&&(r+=x(t[0]));for(let n=1;n<e;n++)r+=", "+x(t[n]);return r+="]",r}const r=/\[object ([^\]]+)\]/.exec(toString.call(t));let n;if(!(r.length>1))return toString.call(t);if(n=r[1],"Object"==n)try{return"Object("+JSON.stringify(t)+")"}catch(t){return"Object"}return t instanceof Error?`${t.name}: ${t.message}\n${t.stack}`:n}function I(t,e,n){r._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hbee689cb88024203(t,e,g(n))}function j(t,e){if(!(t instanceof e))throw new Error(`expected instance of ${e.name}`);return t.ptr}let k=32;function T(t){if(1==k)throw new Error("out of js stack");return l[--k]=t,k}t.exports.start=function(){r.start()},t.exports.publish=function(t,e){return J(r.publish(g(t),g(e)))},t.exports.resolve=function(t,e){var n=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),o=y;return J(r.resolve(n,o,g(e)))},t.exports.checkCredential=function(t,e){var n=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),o=y;return J(r.checkCredential(n,o,g(e)))},t.exports.checkPresentation=function(t,e){var n=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),o=y;return J(r.checkPresentation(n,o,g(e)))};const E=new Uint32Array(2),A=new BigUint64Array(E.buffer);function M(t,e){try{return t.apply(this,e)}catch(t){r.__wbindgen_exn_store(g(t))}}function R(t,e){return c().subarray(t/1,t/1+e)}t.exports.Digest=Object.freeze({Sha256:1,1:"Sha256"}),t.exports.KeyType=Object.freeze({Ed25519:1,1:"Ed25519"});class P{static __wrap(t){const e=Object.create(P.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_authenticationrequest_free(t)}toJSON(){return J(r.authenticationrequest_toJSON(this.ptr))}static fromJSON(t){try{var e=r.authenticationrequest_fromJSON(T(t));return P.__wrap(e)}finally{l[k++]=void 0}}}t.exports.AuthenticationRequest=P;class C{static __wrap(t){const e=Object.create(C.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_authenticationresponse_free(t)}toJSON(){return J(r.authenticationresponse_toJSON(this.ptr))}static fromJSON(t){try{var e=r.authenticationresponse_fromJSON(T(t));return C.__wrap(e)}finally{l[k++]=void 0}}}t.exports.AuthenticationResponse=C;class L{static __wrap(t){const e=Object.create(L.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_credentialissuance_free(t)}toJSON(){return J(r.credentialissuance_toJSON(this.ptr))}static fromJSON(t){try{var e=r.credentialissuance_fromJSON(T(t));return L.__wrap(e)}finally{l[k++]=void 0}}}t.exports.CredentialIssuance=L;class V{static __wrap(t){const e=Object.create(V.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_credentialoptionrequest_free(t)}toJSON(){return J(r.credentialoptionrequest_toJSON(this.ptr))}static fromJSON(t){try{var e=r.credentialoptionrequest_fromJSON(T(t));return V.__wrap(e)}finally{l[k++]=void 0}}}t.exports.CredentialOptionRequest=V;class U{static __wrap(t){const e=Object.create(U.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_credentialoptionresponse_free(t)}toJSON(){return J(r.credentialoptionresponse_toJSON(this.ptr))}static fromJSON(t){try{var e=r.credentialoptionresponse_fromJSON(T(t));return U.__wrap(e)}finally{l[k++]=void 0}}}t.exports.CredentialOptionResponse=U;class q{static __wrap(t){const e=Object.create(q.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_credentialrevocation_free(t)}toJSON(){return J(r.credentialrevocation_toJSON(this.ptr))}static fromJSON(t){try{var e=r.credentialrevocation_fromJSON(T(t));return q.__wrap(e)}finally{l[k++]=void 0}}}t.exports.CredentialRevocation=q;class ${static __wrap(t){const e=Object.create($.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_credentialselection_free(t)}toJSON(){return J(r.credentialselection_toJSON(this.ptr))}static fromJSON(t){try{var e=r.credentialselection_fromJSON(T(t));return $.__wrap(e)}finally{l[k++]=void 0}}}t.exports.CredentialSelection=$;class H{static __wrap(t){const e=Object.create(H.prototype);return e.ptr=t,e}toJSON(){return{network:this.network,shard:this.shard,tag:this.tag,tangleNode:this.tangleNode,tangleExplorer:this.tangleExplorer}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_did_free(t)}constructor(t,e,n){j(t,Z);var o=D(e)?0:m(e,r.__wbindgen_malloc,r.__wbindgen_realloc),i=y,_=D(n)?0:m(n,r.__wbindgen_malloc,r.__wbindgen_realloc),s=y,a=r.did_new(t.ptr,o,i,_,s);return H.__wrap(a)}static fromBase58(t,e,n){var o=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),i=y,_=D(e)?0:m(e,r.__wbindgen_malloc,r.__wbindgen_realloc),s=y,a=D(n)?0:m(n,r.__wbindgen_malloc,r.__wbindgen_realloc),c=y,u=r.did_fromBase58(o,i,_,s,a,c);return H.__wrap(u)}static parse(t){var e=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=y,o=r.did_parse(e,n);return H.__wrap(o)}get network(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.did_network(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];return u(t,e)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,e)}}get shard(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.did_shard(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];let o;return 0!==t&&(o=u(t,e).slice(),r.__wbindgen_free(t,1*e)),o}finally{r.__wbindgen_add_to_stack_pointer(16)}}get tag(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.did_tag(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];return u(t,e)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,e)}}get tangleNode(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.did_tangle_node(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];return u(t,e)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,e)}}get tangleExplorer(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.did_tangle_explorer(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];return u(t,e)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,e)}}toString(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.did_toString(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];return u(t,e)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,e)}}}t.exports.DID=H;class B{static __wrap(t){const e=Object.create(B.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_didrequest_free(t)}toJSON(){return J(r.didrequest_toJSON(this.ptr))}static fromJSON(t){try{var e=r.didrequest_fromJSON(T(t));return B.__wrap(e)}finally{l[k++]=void 0}}}t.exports.DidRequest=B;class K{static __wrap(t){const e=Object.create(K.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_didresponse_free(t)}toJSON(){return J(r.didresponse_toJSON(this.ptr))}static fromJSON(t){try{var e=r.didresponse_fromJSON(T(t));return K.__wrap(e)}finally{l[k++]=void 0}}}t.exports.DidResponse=K;class F{static __wrap(t){const e=Object.create(F.prototype);return e.ptr=t,e}toJSON(){return{id:this.id,proof:this.proof,previousMessageId:this.previousMessageId}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_document_free(t)}constructor(t,e,n){var o=D(e)?0:m(e,r.__wbindgen_malloc,r.__wbindgen_realloc),i=y,_=D(n)?0:m(n,r.__wbindgen_malloc,r.__wbindgen_realloc),s=y,a=r.document_new(t,o,i,_,s);return tt.__wrap(a)}static fromKeyPair(t){j(t,Z);var e=r.document_fromKeyPair(t.ptr);return F.__wrap(e)}static fromAuthentication(t){j(t,dt);var e=r.document_fromAuthentication(t.ptr);return F.__wrap(e)}get id(){var t=r.document_id(this.ptr);return H.__wrap(t)}get proof(){return J(r.document_proof(this.ptr))}get previousMessageId(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.document_previous_message_id(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];return u(t,e)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,e)}}set previousMessageId(t){var e=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=y;r.document_set_previous_message_id(this.ptr,e,n)}insertMethod(t,e){j(t,dt);var n=D(e)?0:m(e,r.__wbindgen_malloc,r.__wbindgen_realloc),o=y;return 0!==r.document_insertMethod(this.ptr,t.ptr,n,o)}removeMethod(t){j(t,H),r.document_removeMethod(this.ptr,t.ptr)}insertService(t){return j(t,it),0!==r.document_insertService(this.ptr,t.ptr)}removeService(t){j(t,H),r.document_removeService(this.ptr,t.ptr)}sign(t){j(t,Z),r.document_sign(this.ptr,t.ptr)}verify(){return 0!==r.document_verify(this.ptr)}signCredential(t,e){try{var n=r.document_signCredential(this.ptr,T(t),T(e));return ct.__wrap(n)}finally{l[k++]=void 0,l[k++]=void 0}}signPresentation(t,e){try{var n=r.document_signPresentation(this.ptr,T(t),T(e));return ut.__wrap(n)}finally{l[k++]=void 0,l[k++]=void 0}}signData(t,e){try{return J(r.document_signData(this.ptr,T(t),T(e)))}finally{l[k++]=void 0,l[k++]=void 0}}verifyData(t){try{return 0!==r.document_verifyData(this.ptr,T(t))}finally{l[k++]=void 0}}resolveKey(t){var e=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=y,o=r.document_resolveKey(this.ptr,e,n);return dt.__wrap(o)}revokeMerkleKey(t,e){var n=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),o=y;return 0!==r.document_revokeMerkleKey(this.ptr,n,o,e)}diff(t,e,n){j(t,F);var o=m(e,r.__wbindgen_malloc,r.__wbindgen_realloc),i=y;return j(n,Z),J(r.document_diff(this.ptr,t.ptr,o,i,n.ptr))}merge(t){var e=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=y;r.document_merge(this.ptr,e,n)}toJSON(){return J(r.document_toJSON(this.ptr))}static fromJSON(t){try{var e=r.document_fromJSON(T(t));return F.__wrap(e)}finally{l[k++]=void 0}}}t.exports.Document=F;class G{static __wrap(t){const e=Object.create(G.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_featuresrequest_free(t)}toJSON(){return J(r.featuresrequest_toJSON(this.ptr))}static fromJSON(t){try{var e=r.featuresrequest_fromJSON(T(t));return G.__wrap(e)}finally{l[k++]=void 0}}}t.exports.FeaturesRequest=G;class Y{static __wrap(t){const e=Object.create(Y.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_featuresresponse_free(t)}toJSON(){return J(r.featuresresponse_toJSON(this.ptr))}static fromJSON(t){try{var e=r.featuresresponse_fromJSON(T(t));return Y.__wrap(e)}finally{l[k++]=void 0}}}t.exports.FeaturesResponse=Y;class z{static __wrap(t){const e=Object.create(z.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_introduction_free(t)}toJSON(){return J(r.introduction_toJSON(this.ptr))}static fromJSON(t){try{var e=r.introduction_fromJSON(T(t));return z.__wrap(e)}finally{l[k++]=void 0}}}t.exports.Introduction=z;class W{static __wrap(t){const e=Object.create(W.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_introductionproposal_free(t)}toJSON(){return J(r.introductionproposal_toJSON(this.ptr))}static fromJSON(t){try{var e=r.introductionproposal_fromJSON(T(t));return W.__wrap(e)}finally{l[k++]=void 0}}}t.exports.IntroductionProposal=W;class Q{static __wrap(t){const e=Object.create(Q.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_introductionresponse_free(t)}toJSON(){return J(r.introductionresponse_toJSON(this.ptr))}static fromJSON(t){try{var e=r.introductionresponse_fromJSON(T(t));return Q.__wrap(e)}finally{l[k++]=void 0}}}t.exports.IntroductionResponse=Q;class X{static __wrap(t){const e=Object.create(X.prototype);return e.ptr=t,e}toJSON(){return{length:this.length}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_keycollection_free(t)}constructor(t,e){var n=r.keycollection_new(t,e);return X.__wrap(n)}get length(){return r.keycollection_length(this.ptr)>>>0}isEmpty(){return 0!==r.keycollection_isEmpty(this.ptr)}keypair(t){var e=r.keycollection_keypair(this.ptr,t);return 0===e?void 0:Z.__wrap(e)}public(t){try{const o=r.__wbindgen_add_to_stack_pointer(-16);r.keycollection_public(o,this.ptr,t);var e=N()[o/4+0],n=N()[o/4+1];let i;return 0!==e&&(i=u(e,n).slice(),r.__wbindgen_free(e,1*n)),i}finally{r.__wbindgen_add_to_stack_pointer(16)}}secret(t){try{const o=r.__wbindgen_add_to_stack_pointer(-16);r.keycollection_secret(o,this.ptr,t);var e=N()[o/4+0],n=N()[o/4+1];let i;return 0!==e&&(i=u(e,n).slice(),r.__wbindgen_free(e,1*n)),i}finally{r.__wbindgen_add_to_stack_pointer(16)}}merkleRoot(t){try{const o=r.__wbindgen_add_to_stack_pointer(-16);r.keycollection_merkleRoot(o,this.ptr,t);var e=N()[o/4+0],n=N()[o/4+1];return u(e,n)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(e,n)}}merkleProof(t,e){try{const i=r.__wbindgen_add_to_stack_pointer(-16);r.keycollection_merkleProof(i,this.ptr,t,e);var n=N()[i/4+0],o=N()[i/4+1];let _;return 0!==n&&(_=u(n,o).slice(),r.__wbindgen_free(n,1*o)),_}finally{r.__wbindgen_add_to_stack_pointer(16)}}toJSON(){return J(r.keycollection_toJSON(this.ptr))}static fromJSON(t){try{var e=r.keycollection_fromJSON(T(t));return X.__wrap(e)}finally{l[k++]=void 0}}}t.exports.KeyCollection=X;class Z{static __wrap(t){const e=Object.create(Z.prototype);return e.ptr=t,e}toJSON(){return{public:this.public,secret:this.secret}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_keypair_free(t)}constructor(t){var e=r.keypair_new(t);return Z.__wrap(e)}static fromBase58(t,e,n){var o=m(e,r.__wbindgen_malloc,r.__wbindgen_realloc),i=y,_=m(n,r.__wbindgen_malloc,r.__wbindgen_realloc),s=y,a=r.keypair_fromBase58(t,o,i,_,s);return Z.__wrap(a)}get public(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.keypair_public(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];return u(t,e)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,e)}}get secret(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.keypair_secret(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];return u(t,e)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,e)}}toJSON(){return J(r.keypair_toJSON(this.ptr))}static fromJSON(t){try{var e=r.keypair_fromJSON(T(t));return Z.__wrap(e)}finally{l[k++]=void 0}}}t.exports.KeyPair=Z;class tt{static __wrap(t){const e=Object.create(tt.prototype);return e.ptr=t,e}toJSON(){return{key:this.key,doc:this.doc}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_newdocument_free(t)}get key(){var t=r.newdocument_key(this.ptr);return Z.__wrap(t)}get doc(){var t=r.newdocument_doc(this.ptr);return F.__wrap(t)}}t.exports.NewDocument=tt;class et{static __wrap(t){const e=Object.create(et.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_presentationrequest_free(t)}toJSON(){return J(r.presentationrequest_toJSON(this.ptr))}static fromJSON(t){try{var e=r.presentationrequest_fromJSON(T(t));return et.__wrap(e)}finally{l[k++]=void 0}}}t.exports.PresentationRequest=et;class rt{static __wrap(t){const e=Object.create(rt.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_presentationresponse_free(t)}toJSON(){return J(r.presentationresponse_toJSON(this.ptr))}static fromJSON(t){try{var e=r.presentationresponse_fromJSON(T(t));return rt.__wrap(e)}finally{l[k++]=void 0}}}t.exports.PresentationResponse=rt;class nt{static __wrap(t){const e=Object.create(nt.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_resolutionrequest_free(t)}toJSON(){return J(r.resolutionrequest_toJSON(this.ptr))}static fromJSON(t){try{var e=r.resolutionrequest_fromJSON(T(t));return nt.__wrap(e)}finally{l[k++]=void 0}}}t.exports.ResolutionRequest=nt;class ot{static __wrap(t){const e=Object.create(ot.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_resolutionresponse_free(t)}toJSON(){return J(r.resolutionresponse_toJSON(this.ptr))}static fromJSON(t){try{var e=r.resolutionresponse_fromJSON(T(t));return ot.__wrap(e)}finally{l[k++]=void 0}}}t.exports.ResolutionResponse=ot;class it{static __wrap(t){const e=Object.create(it.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_service_free(t)}toJSON(){return J(r.service_toJSON(this.ptr))}static fromJSON(t){try{var e=r.service_fromJSON(T(t));return it.__wrap(e)}finally{l[k++]=void 0}}}t.exports.Service=it;class _t{static __wrap(t){const e=Object.create(_t.prototype);return e.ptr=t,e}toJSON(){return{outTime:this.outTime,inTime:this.inTime,staleTime:this.staleTime,expiresTime:this.expiresTime,waitUntilTime:this.waitUntilTime,delayMilli:this.delayMilli}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_timing_free(t)}get outTime(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.timing_out_time(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];let o;return 0!==t&&(o=u(t,e).slice(),r.__wbindgen_free(t,1*e)),o}finally{r.__wbindgen_add_to_stack_pointer(16)}}set outTime(t){var e=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=y;r.timing_set_out_time(this.ptr,e,n)}get inTime(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.timing_in_time(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];let o;return 0!==t&&(o=u(t,e).slice(),r.__wbindgen_free(t,1*e)),o}finally{r.__wbindgen_add_to_stack_pointer(16)}}set inTime(t){var e=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=y;r.timing_set_in_time(this.ptr,e,n)}get staleTime(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.timing_stale_time(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];let o;return 0!==t&&(o=u(t,e).slice(),r.__wbindgen_free(t,1*e)),o}finally{r.__wbindgen_add_to_stack_pointer(16)}}set staleTime(t){var e=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=y;r.timing_set_stale_time(this.ptr,e,n)}get expiresTime(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.timing_expires_time(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];let o;return 0!==t&&(o=u(t,e).slice(),r.__wbindgen_free(t,1*e)),o}finally{r.__wbindgen_add_to_stack_pointer(16)}}set expiresTime(t){var e=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=y;r.timing_set_expires_time(this.ptr,e,n)}get waitUntilTime(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.timing_wait_until_time(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];let o;return 0!==t&&(o=u(t,e).slice(),r.__wbindgen_free(t,1*e)),o}finally{r.__wbindgen_add_to_stack_pointer(16)}}set waitUntilTime(t){var e=m(t,r.__wbindgen_malloc,r.__wbindgen_realloc),n=y;r.timing_set_wait_until_time(this.ptr,e,n)}get delayMilli(){try{const o=r.__wbindgen_add_to_stack_pointer(-16);r.timing_delay_milli(o,this.ptr);var t=N()[o/4+0],e=N()[o/4+1],n=N()[o/4+2];E[0]=e,E[1]=n;return 0===t?void 0:A[0]}finally{r.__wbindgen_add_to_stack_pointer(16)}}set delayMilli(t){A[0]=t;const e=E[0],n=E[1];r.timing_set_delay_milli(this.ptr,e,n)}toJSON(){return J(r.timing_toJSON(this.ptr))}static fromJSON(t){try{var e=r.timing_fromJSON(T(t));return _t.__wrap(e)}finally{l[k++]=void 0}}}t.exports.Timing=_t;class st{static __wrap(t){const e=Object.create(st.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_trustping_free(t)}toJSON(){return J(r.trustping_toJSON(this.ptr))}static fromJSON(t){try{var e=r.trustping_fromJSON(T(t));return st.__wrap(e)}finally{l[k++]=void 0}}}t.exports.TrustPing=st;class at{static __wrap(t){const e=Object.create(at.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_trustedissuer_free(t)}toJSON(){return J(r.trustedissuer_toJSON(this.ptr))}static fromJSON(t){try{var e=r.trustedissuer_fromJSON(T(t));return at.__wrap(e)}finally{l[k++]=void 0}}}t.exports.TrustedIssuer=at;class ct{static __wrap(t){const e=Object.create(ct.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_verifiablecredential_free(t)}static extend(t){try{var e=r.verifiablecredential_extend(T(t));return ct.__wrap(e)}finally{l[k++]=void 0}}static issue(t,e,n,o){try{j(t,F);var i=D(n)?0:m(n,r.__wbindgen_malloc,r.__wbindgen_realloc),_=y,s=D(o)?0:m(o,r.__wbindgen_malloc,r.__wbindgen_realloc),a=y,c=r.verifiablecredential_issue(t.ptr,T(e),i,_,s,a);return ct.__wrap(c)}finally{l[k++]=void 0}}toJSON(){return J(r.verifiablecredential_toJSON(this.ptr))}static fromJSON(t){try{var e=r.verifiablecredential_fromJSON(T(t));return ct.__wrap(e)}finally{l[k++]=void 0}}}t.exports.VerifiableCredential=ct;class ut{static __wrap(t){const e=Object.create(ut.prototype);return e.ptr=t,e}toJSON(){return{}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_verifiablepresentation_free(t)}constructor(t,e,n,o){j(t,F);var i=D(n)?0:m(n,r.__wbindgen_malloc,r.__wbindgen_realloc),_=y,s=D(o)?0:m(o,r.__wbindgen_malloc,r.__wbindgen_realloc),a=y,c=r.verifiablepresentation_new(t.ptr,g(e),i,_,s,a);return ut.__wrap(c)}toJSON(){return J(r.verifiablepresentation_toJSON(this.ptr))}static fromJSON(t){try{var e=r.verifiablepresentation_fromJSON(T(t));return ut.__wrap(e)}finally{l[k++]=void 0}}}t.exports.VerifiablePresentation=ut;class dt{static __wrap(t){const e=Object.create(dt.prototype);return e.ptr=t,e}toJSON(){return{id:this.id,controller:this.controller,type:this.type,data:this.data}}toString(){return JSON.stringify(this)}[_.custom](){return Object.assign(Object.create({constructor:this.constructor}),this.toJSON())}__destroy_into_raw(){const t=this.ptr;return this.ptr=0,t}free(){const t=this.__destroy_into_raw();r.__wbg_verificationmethod_free(t)}constructor(t,e){j(t,Z);var n=D(e)?0:m(e,r.__wbindgen_malloc,r.__wbindgen_realloc),o=y,i=r.verificationmethod_new(t.ptr,n,o);return dt.__wrap(i)}static fromDID(t,e,n){j(t,H),j(e,Z);var o=D(n)?0:m(n,r.__wbindgen_malloc,r.__wbindgen_realloc),i=y,_=r.verificationmethod_fromDID(t.ptr,e.ptr,o,i);return dt.__wrap(_)}static createMerkleKey(t,e,n,o){j(e,H),j(n,X);var i=D(o)?0:m(o,r.__wbindgen_malloc,r.__wbindgen_realloc),_=y,s=r.verificationmethod_createMerkleKey(t,e.ptr,n.ptr,i,_);return dt.__wrap(s)}get id(){var t=r.verificationmethod_id(this.ptr);return H.__wrap(t)}get controller(){var t=r.verificationmethod_controller(this.ptr);return H.__wrap(t)}get type(){try{const n=r.__wbindgen_add_to_stack_pointer(-16);r.verificationmethod_type(n,this.ptr);var t=N()[n/4+0],e=N()[n/4+1];return u(t,e)}finally{r.__wbindgen_add_to_stack_pointer(16),r.__wbindgen_free(t,e)}}get data(){return J(r.verificationmethod_data(this.ptr))}toJSON(){return J(r.verificationmethod_toJSON(this.ptr))}static fromJSON(t){try{var e=r.verificationmethod_fromJSON(T(t));return dt.__wrap(e)}finally{l[k++]=void 0}}}t.exports.VerificationMethod=dt,t.exports.__wbindgen_json_parse=function(t,e){return g(JSON.parse(u(t,e)))},t.exports.__wbindgen_json_serialize=function(t,e){const n=b(e);var o=m(JSON.stringify(void 0===n?null:n),r.__wbindgen_malloc,r.__wbindgen_realloc),i=y;N()[t/4+1]=i,N()[t/4+0]=o},t.exports.__wbindgen_object_drop_ref=function(t){J(t)},t.exports.__wbindgen_cb_drop=function(t){const e=J(t).original;if(1==e.cnt--)return e.a=0,!0;return!1},t.exports.__wbindgen_is_object=function(t){const e=b(t);return"object"==typeof e&&null!==e},t.exports.__wbindgen_is_undefined=function(t){return void 0===b(t)},t.exports.__wbindgen_string_new=function(t,e){return g(u(t,e))},t.exports.__wbg_new_59cb74e423758ede=function(){return g(new Error)},t.exports.__wbg_stack_558ba5917b466edd=function(t,e){var n=m(b(e).stack,r.__wbindgen_malloc,r.__wbindgen_realloc),o=y;N()[t/4+1]=o,N()[t/4+0]=n},t.exports.__wbg_error_4bb6c2a97407129a=function(t,e){try{console.error(u(t,e))}finally{r.__wbindgen_free(t,e)}},t.exports.__wbindgen_object_clone_ref=function(t){return g(b(t))},t.exports.__wbg_fetch_01d048dd000bcda1=function(t){return g(e(b(t)))},t.exports.__wbg_new_80e79fe6852cbe9c=function(){return M((function(){return g(new Headers)}),arguments)},t.exports.__wbg_append_441dc2c4b2281095=function(){return M((function(t,e,r,n,o){b(t).append(u(e,r),u(n,o))}),arguments)},t.exports.__wbg_fetch_9dbf87b840590e85=function(t,e){return g(b(t).fetch(b(e)))},t.exports.__wbg_instanceof_Response_d61ff4c524b8dbc4=function(t){return b(t)instanceof Response},t.exports.__wbg_url_0ffe73d78f393423=function(t,e){var n=m(b(e).url,r.__wbindgen_malloc,r.__wbindgen_realloc),o=y;N()[t/4+1]=o,N()[t/4+0]=n},t.exports.__wbg_status_1a7d875f6e1318cd=function(t){return b(t).status},t.exports.__wbg_headers_f49eca784c8ebeba=function(t){return g(b(t).headers)},t.exports.__wbg_arrayBuffer_b7c95af83e1e2705=function(){return M((function(t){return g(b(t).arrayBuffer())}),arguments)},t.exports.__wbg_text_7c3304aebfcffa1a=function(){return M((function(t){return g(b(t).text())}),arguments)},t.exports.__wbg_newwithstrandinit_155cb1478824b198=function(){return M((function(t,e,r){return g(new Request(u(t,e),b(r)))}),arguments)},t.exports.__wbg_getRandomValues_57e4008f45f0e105=function(){return M((function(t,e){b(t).getRandomValues(b(e))}),arguments)},t.exports.__wbg_randomFillSync_d90848a552cbd666=function(){return M((function(t,e,r){b(t).randomFillSync(R(e,r))}),arguments)},t.exports.__wbg_self_f865985e662246aa=function(){return M((function(){return g(self.self)}),arguments)},t.exports.__wbg_static_accessor_MODULE_39947eb3fe77895f=function(){return g(t)},t.exports.__wbg_require_c59851dfa0dc7e78=function(){return M((function(t,e,r){return g(b(t).require(u(e,r)))}),arguments)},t.exports.__wbg_crypto_bfb05100db79193b=function(t){return g(b(t).crypto)},t.exports.__wbg_msCrypto_f6dddc6ae048b7e2=function(t){return g(b(t).msCrypto)},t.exports.__wbindgen_is_function=function(t){return"function"==typeof b(t)},t.exports.__wbg_next_e38a92137a5693de=function(t){return g(b(t).next)},t.exports.__wbg_next_8b73f854755d8e5e=function(){return M((function(t){return g(b(t).next())}),arguments)},t.exports.__wbg_done_86efa5ac73f5b194=function(t){return b(t).done},t.exports.__wbg_value_708ce1aa93862729=function(t){return g(b(t).value)},t.exports.__wbg_iterator_30586bd3e46ee10e=function(){return g(Symbol.iterator)},t.exports.__wbg_get_800098c980b31ea2=function(){return M((function(t,e){return g(Reflect.get(b(t),b(e)))}),arguments)},t.exports.__wbg_call_ba36642bd901572b=function(){return M((function(t,e){return g(b(t).call(b(e)))}),arguments)},t.exports.__wbg_newnoargs_9fdd8f3961dd1bee=function(t,e){return g(new Function(u(t,e)))},t.exports.__wbg_call_3fc07b7d5fc9022d=function(){return M((function(t,e,r){return g(b(t).call(b(e),b(r)))}),arguments)},t.exports.__wbg_getTime_55dfad3366aec58a=function(t){return b(t).getTime()},t.exports.__wbg_new0_85024d5e91a046e9=function(){return g(new Date)},t.exports.__wbg_new_edbe38a4e21329dd=function(){return g(new Object)},t.exports.__wbg_new_c143a4f563f78c4e=function(t,e){try{var n={a:t,b:e},o=new Promise(((t,e)=>{const o=n.a;n.a=0;try{return function(t,e,n,o){r.wasm_bindgen__convert__closures__invoke2_mut__h5596c51b6c4da58d(t,e,g(n),g(o))}(o,n.b,t,e)}finally{n.a=o}}));return g(o)}finally{n.a=n.b=0}},t.exports.__wbg_resolve_cae3d8f752f5db88=function(t){return g(Promise.resolve(b(t)))},t.exports.__wbg_then_c2361a9d5c9a4fcb=function(t,e){return g(b(t).then(b(e)))},t.exports.__wbg_then_6c9a4bf55755f9b8=function(t,e,r){return g(b(t).then(b(e),b(r)))},t.exports.__wbg_self_bb69a836a72ec6e9=function(){return M((function(){return g(self.self)}),arguments)},t.exports.__wbg_window_3304fc4b414c9693=function(){return M((function(){return g(window.window)}),arguments)},t.exports.__wbg_globalThis_e0d21cabc6630763=function(){return M((function(){return g(globalThis.globalThis)}),arguments)},t.exports.__wbg_global_8463719227271676=function(){return M((function(){return g(w.global)}),arguments)},t.exports.__wbg_buffer_9e184d6f785de5ed=function(t){return g(b(t).buffer)},t.exports.__wbg_newwithbyteoffsetandlength_e57ad1f2ce812c03=function(t,e,r){return g(new Uint8Array(b(t),e>>>0,r>>>0))},t.exports.__wbg_length_2d56cb37075fcfb1=function(t){return b(t).length},t.exports.__wbg_new_e8101319e4cf95fc=function(t){return g(new Uint8Array(b(t)))},t.exports.__wbg_set_e8ae7b27314e8b98=function(t,e,r){b(t).set(b(e),r>>>0)},t.exports.__wbg_newwithlength_a8d1dbcbe703a5c6=function(t){return g(new Uint8Array(t>>>0))},t.exports.__wbg_subarray_901ede8318da52a6=function(t,e,r){return g(b(t).subarray(e>>>0,r>>>0))},t.exports.__wbg_has_9fa0c068863afd36=function(){return M((function(t,e){return Reflect.has(b(t),b(e))}),arguments)},t.exports.__wbg_set_73349fc4814e0fc6=function(){return M((function(t,e,r){return Reflect.set(b(t),b(e),b(r))}),arguments)},t.exports.__wbindgen_string_get=function(t,e){const n=b(e);var o="string"==typeof n?n:void 0,i=D(o)?0:m(o,r.__wbindgen_malloc,r.__wbindgen_realloc),_=y;N()[t/4+1]=_,N()[t/4+0]=i},t.exports.__wbindgen_debug_string=function(t,e){var n=m(x(b(e)),r.__wbindgen_malloc,r.__wbindgen_realloc),o=y;N()[t/4+1]=o,N()[t/4+0]=n},t.exports.__wbindgen_throw=function(t,e){throw new Error(u(t,e))},t.exports.__wbindgen_rethrow=function(t){throw J(t)},t.exports.__wbindgen_memory=function(){return g(r.memory)},t.exports.__wbindgen_closure_wrapper2813=function(t,e,n){return g(function(t,e,n,o){const i={a:t,b:e,cnt:1,dtor:n},_=(...t)=>{i.cnt++;const e=i.a;i.a=0;try{return o(e,i.b,...t)}finally{0==--i.cnt?r.__wbindgen_export_2.get(i.dtor)(e,i.b):i.a=e}};return _.original=i,_}(t,e,482,I))};const lt=f.default.join(__dirname,"identity_wasm_bg.wasm"),ft=p.default.readFileSync(lt),pt=new WebAssembly.Module(ft),ht=new WebAssembly.Instance(pt,n);r=ht.exports,t.exports.__wasm=r,r.__wbindgen_start()}(kt);var Tt=w&&w.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function _(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(_,s)}a((n=n.apply(t,e||[])).next())}))},Et=w&&w.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(jt,"__esModule",{value:!0});const At=kt.exports,Mt=Et(v),Rt=Et(S),Pt=J;jt.default=class{static resolve(t,e){return Tt(this,void 0,void 0,(function*(){try{const t=yield At.resolve(e,{network:"mainnet"}),r=At.Document.fromJSON(t);if(!r.verify())throw new Mt.default(Rt.default.DID_NOT_VERIFIED,"DID cannot be verified");return r}catch(t){throw new Mt.default(Rt.default.DID_NOT_FOUND,"DID cannot be resolved")}}))}static resolveMethod(t,e){return Tt(this,void 0,void 0,(fun