simple-hpke 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -8
- package/dist/constants.cjs +2 -22
- package/dist/constants.cjs.map +3 -3
- package/dist/constants.js +2 -22
- package/dist/constants.js.map +3 -3
- package/dist/constants.min.cjs +1 -1
- package/dist/constants.min.cjs.map +3 -3
- package/dist/constants.min.js +1 -1
- package/dist/constants.min.js.map +3 -3
- package/dist/index.cjs +6 -21
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +33 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -21
- package/dist/index.js.map +3 -3
- package/dist/index.min.cjs +1 -1
- package/dist/index.min.cjs.map +3 -3
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +16 -16
- package/dist/util.cjs +2 -22
- package/dist/util.cjs.map +3 -3
- package/dist/util.d.ts +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +2 -22
- package/dist/util.js.map +3 -3
- package/dist/util.min.cjs +1 -1
- package/dist/util.min.cjs.map +3 -3
- package/dist/util.min.js +1 -1
- package/dist/util.min.js.map +3 -3
- package/package.json +1 -1
package/dist/util.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var Y=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var Kt=Object.prototype.hasOwnProperty;var i=(e,t)=>Y(e,"name",{value:t,configurable:!0});var h=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},Pt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ct(t))!Kt.call(e,o)&&o!==r&&Y(e,o,{get:()=>t[o],enumerable:!(n=St(t,o))||n.enumerable});return e};var Dt=e=>Pt(Y({},"__esModule",{value:!0}),e);var Qr={};h(Qr,{aeadOpen:()=>Me,aeadSeal:()=>Ne,concat:()=>l,decap:()=>_e,encap:()=>Oe,encryptBytes:()=>ie,encryptToString:()=>ze,hmac:()=>Fe,i2osp:()=>K,labeledExpand:()=>Q,labeledExtract:()=>V,resolveRecipientPublicKey:()=>Re});module.exports=Dt(Qr);function ee(e=0){return new Uint8Array(e)}i(ee,"allocUnsafe");var pe={};h(pe,{base10:()=>zt});var ln=new Uint8Array(0);function Ge(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}i(Ge,"equals");function C(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}i(C,"coerce");function He(e){return new TextEncoder().encode(e)}i(He,"fromString");function qe(e){return new TextDecoder().decode(e)}i(qe,"toString");function It(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var a=e.charAt(o),s=a.charCodeAt(0);if(r[s]!==255)throw new TypeError(a+" is ambiguous");r[s]=o}var c=e.length,u=e.charAt(0),y=Math.log(c)/Math.log(256),g=Math.log(256)/Math.log(c);function k(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var d=0,I=0,w=0,A=f.length;w!==A&&f[w]===0;)w++,d++;for(var U=(A-w)*g+1>>>0,m=new Uint8Array(U);w!==A;){for(var E=f[w],P=0,x=U-1;(E!==0||P<I)&&x!==-1;x--,P++)E+=256*m[x]>>>0,m[x]=E%c>>>0,E=E/c>>>0;if(E!==0)throw new Error("Non-zero carry");I=P,w++}for(var S=U-I;S!==U&&m[S]===0;)S++;for(var Z=u.repeat(d);S<U;++S)Z+=e.charAt(m[S]);return Z}i(k,"encode");function B(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var d=0;if(f[d]!==" "){for(var I=0,w=0;f[d]===u;)I++,d++;for(var A=(f.length-d)*y+1>>>0,U=new Uint8Array(A);f[d];){var m=r[f.charCodeAt(d)];if(m===255)return;for(var E=0,P=A-1;(m!==0||E<w)&&P!==-1;P--,E++)m+=c*U[P]>>>0,U[P]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");w=E,d++}if(f[d]!==" "){for(var x=A-w;x!==A&&U[x]===0;)x++;for(var S=new Uint8Array(I+(A-x)),Z=I;x!==A;)S[Z++]=U[x++];return S}}}i(B,"decodeUnsafe");function W(f){var d=B(f);if(d)return d;throw new Error(`Non-${t} character`)}return i(W,"decode"),{encode:k,decodeUnsafe:B,decode:W}}i(It,"base");var Lt=It,Bt=Lt,je=Bt;var ae=class{static{i(this,"Encoder")}name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},se=class{static{i(this,"Decoder")}name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Je(this,t)}},ce=class{static{i(this,"ComposedDecoder")}decoders;constructor(t){this.decoders=t}or(t){return Je(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Je(e,t){return new ce({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}i(Je,"or");var fe=class{static{i(this,"Codec")}name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ae(t,r,n),this.decoder=new se(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function T({name:e,prefix:t,encode:r,decode:n}){return new fe(e,t,r,n)}i(T,"from");function D({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=je(r,e);return T({prefix:t,name:e,encode:n,decode:i(a=>C(o(a)),"decode")})}i(D,"baseX");function Tt(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let a=new Uint8Array(o*r/8|0),s=0,c=0,u=0;for(let y=0;y<o;++y){let g=t[e[y]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|g,s+=r,s>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return a}i(Tt,"decode");function Nt(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,a="",s=0,c=0;for(let u=0;u<e.length;++u)for(c=c<<8|e[u],s+=8;s>r;)s-=r,a+=t[o&c>>s];if(s!==0&&(a+=t[o&c<<r-s]),n)for(;(a.length*r&7)!==0;)a+="=";return a}i(Nt,"encode");function Mt(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}i(Mt,"createAlphabetIdx");function p({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Mt(n);return T({prefix:t,name:e,encode(a){return Nt(a,n,r)},decode(a){return Tt(a,o,r,e)}})}i(p,"rfc4648");var zt=D({prefix:"9",name:"base10",alphabet:"0123456789"});var ue={};h(ue,{base16:()=>Rt,base16upper:()=>Ot});var Rt=p({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ot=p({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ye={};h(ye,{base2:()=>_t});var _t=p({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var de={};h(de,{base256emoji:()=>Ht});var Qe=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),$t=Qe.reduce((e,t,r)=>(e[r]=t,e),[]),Vt=Qe.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function Ft(e){return e.reduce((t,r)=>(t+=$t[r],t),"")}i(Ft,"encode");function Gt(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Vt[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}i(Gt,"decode");var Ht=T({prefix:"\u{1F680}",name:"base256emoji",encode:Ft,decode:Gt});var he={};h(he,{base32:()=>N,base32hex:()=>Jt,base32hexpad:()=>Wt,base32hexpadupper:()=>Zt,base32hexupper:()=>Qt,base32pad:()=>Xt,base32padupper:()=>jt,base32upper:()=>qt,base32z:()=>Yt});var N=p({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qt=p({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xt=p({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),jt=p({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jt=p({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Qt=p({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wt=p({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Zt=p({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yt=p({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var le={};h(le,{base36:()=>F,base36upper:()=>er});var F=D({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),er=D({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var me={};h(me,{base58btc:()=>v,base58flickr:()=>tr});var v=D({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),tr=D({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var be={};h(be,{base64:()=>rr,base64pad:()=>nr,base64url:()=>or,base64urlpad:()=>ir});var rr=p({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nr=p({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),or=p({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ir=p({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var we={};h(we,{base8:()=>ar});var ar=p({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var xe={};h(xe,{identity:()=>sr});var sr=T({prefix:"\0",name:"identity",encode:i(e=>qe(e),"encode"),decode:i(e=>He(e),"decode")});var Mn=new TextEncoder,zn=new TextDecoder;var Ae={};h(Ae,{identity:()=>kr});var pr=Ye,We=128,ur=127,yr=~ur,dr=Math.pow(2,31);function Ye(e,t,r){t=t||[],r=r||0;for(var n=r;e>=dr;)t[r++]=e&255|We,e/=128;for(;e&yr;)t[r++]=e&255|We,e>>>=7;return t[r]=e|0,Ye.bytes=r-n+1,t}i(Ye,"encode");var hr=ge,lr=128,Ze=127;function ge(e,n){var r=0,n=n||0,o=0,a=n,s,c=e.length;do{if(a>=c)throw ge.bytes=0,new RangeError("Could not decode varint");s=e[a++],r+=o<28?(s&Ze)<<o:(s&Ze)*Math.pow(2,o),o+=7}while(s>=lr);return ge.bytes=a-n,r}i(ge,"read");var mr=Math.pow(2,7),br=Math.pow(2,14),wr=Math.pow(2,21),xr=Math.pow(2,28),gr=Math.pow(2,35),Ar=Math.pow(2,42),Ur=Math.pow(2,49),Er=Math.pow(2,56),vr=Math.pow(2,63),Sr=i(function(e){return e<mr?1:e<br?2:e<wr?3:e<xr?4:e<gr?5:e<Ar?6:e<Ur?7:e<Er?8:e<vr?9:10},"length"),Cr={encode:pr,decode:hr,encodingLength:Sr},Kr=Cr,G=Kr;function H(e,t=0){return[G.decode(e,t),G.decode.bytes]}i(H,"decode");function M(e,t,r=0){return G.encode(e,t,r),t}i(M,"encodeTo");function z(e){return G.encodingLength(e)}i(z,"encodingLength");function O(e,t){let r=t.byteLength,n=z(e),o=n+z(r),a=new Uint8Array(o+r);return M(e,a,0),M(r,a,n),a.set(t,o),new R(e,r,t,a)}i(O,"create");function et(e){let t=C(e),[r,n]=H(t),[o,a]=H(t.subarray(n)),s=t.subarray(n+a);if(s.byteLength!==o)throw new Error("Incorrect length");return new R(r,o,s,t)}i(et,"decode");function tt(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ge(e.bytes,r.bytes)}}i(tt,"equals");var R=class{static{i(this,"Digest")}code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var rt=0,Pr="identity",nt=C;function Dr(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return O(rt,nt(e))}i(Dr,"digest");var kr={code:rt,name:Pr,encode:nt,digest:Dr};var ve={};h(ve,{sha256:()=>Lr,sha512:()=>Br});var Ir=20;function Ee({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Ue(e,t,r,n,o)}i(Ee,"from");var Ue=class{static{i(this,"Hasher")}name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,a){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Ir,this.maxDigestLength=a}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?ot(n,this.code,r?.truncate):n.then(o=>ot(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ot(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return O(t,e)}i(ot,"createDigest");function at(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}i(at,"sha");var Lr=Ee({name:"sha2-256",code:18,encode:at("SHA-256")}),Br=Ee({name:"sha2-512",code:19,encode:at("SHA-512")});function st(e,t){let{bytes:r,version:n}=e;return n===0?Nr(r,Se(e),t??v.encoder):Mr(r,Se(e),t??N.encoder)}i(st,"format");var ct=new WeakMap;function Se(e){let t=ct.get(e);if(t==null){let r=new Map;return ct.set(e,r),r}return t}i(Se,"baseCache");var re=class e{static{i(this,"CID")}code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==X)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==zr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=O(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&tt(t.multihash,n.multihash)}toString(t){return st(this,t)}toJSON(){return{"/":st(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:a,bytes:s}=r;return new e(n,o,a,s??ft(n,o,a.bytes))}else if(r[Rr]===!0){let{version:n,multihash:o,code:a}=r,s=et(o);return e.create(n,a,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==X)throw new Error(`Version 0 CID must use dag-pb (code: ${X}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ft(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,X,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=C(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let a=o.subarray(r.multihashSize-r.digestSize),s=new R(r.multihashCode,r.digestSize,a,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=i(()=>{let[k,B]=H(t.subarray(r));return r+=B,k},"next"),o=n(),a=X;if(o===18?(o=0,r=0):a=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),u=n(),y=r+u,g=y-s;return{version:o,codec:a,multihashCode:c,digestSize:u,multihashSize:g,size:y}}static parse(t,r){let[n,o]=Tr(t,r),a=e.decode(o);if(a.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Se(a).set(n,t),a}};function Tr(e,t){switch(e[0]){case"Q":{let r=t??v;return[v.prefix,r.decode(`${v.prefix}${e}`)]}case v.prefix:{let r=t??v;return[v.prefix,r.decode(e)]}case N.prefix:{let r=t??N;return[N.prefix,r.decode(e)]}case F.prefix:{let r=t??F;return[F.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}i(Tr,"parseCIDtoBytes");function Nr(e,t,r){let{prefix:n}=r;if(n!==v.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let a=r.encode(e).slice(1);return t.set(n,a),a}else return o}i(Nr,"toStringV0");function Mr(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let a=r.encode(e);return t.set(n,a),a}else return o}i(Mr,"toStringV1");var X=112,zr=18;function ft(e,t,r){let n=z(e),o=n+z(t),a=new Uint8Array(o+r.byteLength);return M(e,a,0),M(t,a,n),a.set(r,o),a}i(ft,"encodeCID");var Rr=Symbol.for("@ipld/js-cid/CID");var Ce={...xe,...ye,...we,...pe,...ue,...he,...le,...me,...be,...de},lo={...ve,...Ae};function ut(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}i(ut,"createCodec");var pt=ut("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Ke=ut("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=ee(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Or={utf8:pt,"utf-8":pt,hex:Ce.base16,latin1:Ke,ascii:Ke,binary:Ke,...Ce},ne=Or;function j(e,t="utf8"){let r=ne[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}i(j,"fromString");function Pe(e,t="utf8"){let r=ne[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}i(Pe,"toString");var yt=32,_r=1,$r=2,De=32,dt=32,J=12,L=32,ke=16,ht=0,Ie=new TextEncoder().encode("HPKE-v1"),_=2,Le=l(new TextEncoder().encode("KEM"),K(yt,2)),$=l(new TextEncoder().encode("HPKE"),K(yt,2),K(_r,2),K($r,2));var oe=globalThis.crypto.subtle;async function mt(e,t){let{wrapped:r,key:n}=await At(e,null,t);return{enc:r,key:n}}i(mt,"create");async function bt(e,t,r){let{wrapped:n,key:o}=await At(e,t,r);return{enc:n,key:o}}i(bt,"seal");var Fo=Object.assign(Xr,{raw:Te}),Go=Object.assign(ie,{asString:ze}),Ho=Object.assign(Be,{asString:Vr,fromString:Fr});async function Be(e,t,r){if(t.byteLength<_)throw new Error("malformed message: too short");let n=t[0]<<8|t[1],o=_+n,a=o+J;if(t.byteLength<a+ke)throw new Error("malformed message: too short");let s=t.slice(_,o),c=t.slice(o,a),u=t.slice(a),y=await Te(e,s,r?.info!==void 0?{info:r.info}:void 0),g=await qr(y),k=await oe.decrypt({name:"AES-GCM",iv:c},g,u);return new Uint8Array(k)}i(Be,"decryptBytes");async function Vr(e,t,r){let n=await Be(e,t,r);return new TextDecoder().decode(n)}i(Vr,"decryptToString");async function Fr(e,t,r){let n=j(t,"base64url"),o=await Be(e,n,r?.info!==void 0?{info:r.info}:void 0);return r?.buffer?o:new TextDecoder().decode(o)}i(Fr,"decryptFromString");function Gr(e){if(e!==128&&e!==256)throw new Error(`invalid keysize: ${e} (expected 128 or 256)`)}i(Gr,"validateKeysize");function lt(e){if(e.length!==16&&e.length!==32)throw new Error(`invalid aesKey length: ${e.length} bytes (expected 16 or 32)`)}i(lt,"validateRawKeyBytes");function wt(e){return e==null?new Uint8Array(0):typeof e=="string"?new TextEncoder().encode(e):e}i(wt,"normalizeInfo");async function Hr(e){if(!e.extractable)throw new Error("aesKey must be extractable: its raw bytes are what get sealed");return new Uint8Array(await oe.exportKey("raw",e))}i(Hr,"exportAesKeyBytes");async function xt(e){return oe.importKey("raw",e,{name:"AES-GCM"},!0,["encrypt","decrypt"])}i(xt,"importAesKey");async function qr(e){return oe.importKey("raw",e,{name:"AES-GCM"},!1,["decrypt"])}i(qr,"importAesKeyDecryptOnly");async function gt(e,t){let r=new Uint8Array(0),n=await V($,r,"psk_id_hash",r),o=await V($,r,"info_hash",t),a=l(new Uint8Array([ht]),n,o),s=await V($,e,"secret",r),c=await Q($,s,"key",a,dt),u=await Q($,s,"base_nonce",a,J);return{key:c,baseNonce:u}}i(gt,"keySchedule");async function Te(e,t,r){if(t.byteLength<L+ke)throw new Error("malformed envelope: too short");let n=wt(r?.info),o=t.slice(0,L),a=t.slice(L),s=await _e(o,e),{key:c,baseNonce:u}=await gt(s,n);return Me(c,u,a)}i(Te,"openRawBytes");async function Xr(e,t,r){let n=await Te(e,t,r);return xt(n)}i(Xr,"openBytes");async function At(e,t,r){let n=wt(r?.info),o;if(t instanceof Uint8Array)lt(t),o=t;else if(t)o=await Hr(t),lt(o);else{let W=r?.size??256;Gr(W),o=globalThis.crypto.getRandomValues(new Uint8Array(W/8))}let a=await Re(e),{sharedSecret:s,enc:c}=await Oe(a),{key:u,baseNonce:y}=await gt(s,n),g=await Ne(u,y,o),k=l(c,g),B=await xt(o);return{wrapped:k,key:B}}i(At,"encryptKey");var b=globalThis.crypto.subtle;async function Ne(e,t,r){let n=await b.importKey("raw",e,{name:"AES-GCM"},!1,["encrypt"]),o=await b.encrypt({name:"AES-GCM",iv:t},n,r);return new Uint8Array(o)}i(Ne,"aeadSeal");async function Me(e,t,r){let n=await b.importKey("raw",e,{name:"AES-GCM"},!1,["decrypt"]),o=await b.decrypt({name:"AES-GCM",iv:t},n,r);return new Uint8Array(o)}i(Me,"aeadOpen");async function ie(e,t,r,n){let o=typeof t=="string"?new TextEncoder().encode(t):t,a,s;if(r){let y=await bt(e,r,n);a=y.enc,s=y.key}else{let y=await mt(e,n);a=y.enc,s=y.key}let c=globalThis.crypto.getRandomValues(new Uint8Array(J)),u=new Uint8Array(await b.encrypt({name:"AES-GCM",iv:c},s,o));return l(K(a.length,_),a,c,u)}i(ie,"encryptBytes");async function ze(e,t,r,n){let o=await ie(e,t,r,n);return Pe(o,n?.encoding??"base64url")}i(ze,"encryptToString");async function Fe(e,t){let r=await b.importKey("raw",e,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return new Uint8Array(await b.sign("HMAC",r,t))}i(Fe,"hmac");async function jr(e,t){let r=e.length===0?new Uint8Array(De):e;return Fe(r,t)}i(jr,"extract");async function Jr(e,t,r){let n=new Uint8Array(r),o=new Uint8Array(0),a=0,s=1;for(;a<r;){o=await Fe(e,l(o,t,K(s,1)));let c=Math.min(o.length,r-a);n.set(o.subarray(0,c),a),a+=c,s++}return n}i(Jr,"expand");async function V(e,t,r,n){let o=l(Ie,e,new TextEncoder().encode(r),n);return jr(t,o)}i(V,"labeledExtract");async function Q(e,t,r,n,o){let a=l(K(o,2),Ie,e,new TextEncoder().encode(r),n);return Jr(t,a,o)}i(Q,"labeledExpand");async function $e(e){return new Uint8Array(await b.exportKey("raw",e))}i($e,"exportRawPublic");async function Ut(e){if(e.length!==L)throw new Error(`invalid public key length: ${e.length} bytes (expected ${L})`);return b.importKey("raw",e,{name:"X25519"},!0,[])}i(Ut,"importRawPublic");async function Re(e){if(e instanceof Uint8Array)return Ut(e);if(e instanceof CryptoKey){if(e.type!=="public")throw new Error("recipient CryptoKey must be a public key");return Ve(e,"recipient CryptoKey"),e}if(typeof e.publicKey=="string"){let{publicKey:r,encoding:n}=e;return Ut(j(r,n??"base64url"))}let t=e;if(t.publicKey instanceof CryptoKey){if(t.publicKey.type!=="public")throw new Error("recipient keypair publicKey must be a public key");return Ve(t.publicKey,"recipient keypair publicKey"),t.publicKey}throw new Error("unrecognized recipient key form")}i(Re,"resolveRecipientPublicKey");function Ve(e,t){if(e.algorithm.name!=="X25519")throw new Error(`${t} must be an X25519 key (got ${e.algorithm.name})`)}i(Ve,"assertX25519Algorithm");async function Et(e,t){let r=await b.deriveBits({name:"X25519",public:t},e,256),n=new Uint8Array(r);if(n.every(o=>o===0))throw new Error("X25519 shared secret is all-zero (small-order public key?)");return n}i(Et,"dh");async function vt(e,t){let r=await V(Le,new Uint8Array(0),"eae_prk",e);return Q(Le,r,"shared_secret",t,De)}i(vt,"extractAndExpand");async function Oe(e){let t=await b.generateKey({name:"X25519"},!1,["deriveBits"]),r=await Et(t.privateKey,e),n=await $e(t.publicKey),o=await $e(e),a=l(n,o);return{sharedSecret:await vt(r,a),enc:n}}i(Oe,"encap");async function _e(e,t){if(t.privateKey.type!=="private")throw new Error("keypair.privateKey must be a private key");Ve(t.privateKey,"keypair.privateKey");let r=await b.importKey("raw",e,{name:"X25519"},!1,[]),n=await Et(t.privateKey,r),o=await $e(t.publicKey),a=l(e,o);return vt(n,a)}i(_e,"decap");function K(e,t){let r=new Uint8Array(t),n=e;for(let o=t-1;o>=0;o--)r[o]=n&255,n=Math.floor(n/256);return r}i(K,"i2osp");function l(...e){let t=0;for(let o of e)t+=o.length;let r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}i(l,"concat");
|
|
1
|
+
"use strict";var Y=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var vt=Object.getOwnPropertyNames;var St=Object.prototype.hasOwnProperty;var i=(e,t)=>Y(e,"name",{value:t,configurable:!0});var d=(e,t)=>{for(var r in t)Y(e,r,{get:t[r],enumerable:!0})},Ct=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vt(t))!St.call(e,o)&&o!==r&&Y(e,o,{get:()=>t[o],enumerable:!(n=Et(t,o))||n.enumerable});return e};var Kt=e=>Ct(Y({},"__esModule",{value:!0}),e);var jr={};d(jr,{aeadOpen:()=>Me,aeadSeal:()=>Ne,concat:()=>h,decap:()=>_e,encap:()=>Oe,encryptBytes:()=>ie,encryptToString:()=>ze,hmac:()=>Fe,i2osp:()=>K,labeledExpand:()=>Q,labeledExtract:()=>V,resolveRecipientPublicKey:()=>Re});module.exports=Kt(jr);function ee(e=0){return new Uint8Array(e)}i(ee,"allocUnsafe");var pe={};d(pe,{base10:()=>Nt});var dn=new Uint8Array(0);function Ge(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}i(Ge,"equals");function C(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}i(C,"coerce");function He(e){return new TextEncoder().encode(e)}i(He,"fromString");function qe(e){return new TextDecoder().decode(e)}i(qe,"toString");function Dt(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var a=e.charAt(o),s=a.charCodeAt(0);if(r[s]!==255)throw new TypeError(a+" is ambiguous");r[s]=o}var c=e.length,u=e.charAt(0),l=Math.log(c)/Math.log(256),g=Math.log(256)/Math.log(c);function I(f){if(f instanceof Uint8Array||(ArrayBuffer.isView(f)?f=new Uint8Array(f.buffer,f.byteOffset,f.byteLength):Array.isArray(f)&&(f=Uint8Array.from(f))),!(f instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(f.length===0)return"";for(var y=0,L=0,x=0,A=f.length;x!==A&&f[x]===0;)x++,y++;for(var U=(A-x)*g+1>>>0,m=new Uint8Array(U);x!==A;){for(var E=f[x],P=0,w=U-1;(E!==0||P<L)&&w!==-1;w--,P++)E+=256*m[w]>>>0,m[w]=E%c>>>0,E=E/c>>>0;if(E!==0)throw new Error("Non-zero carry");L=P,x++}for(var S=U-L;S!==U&&m[S]===0;)S++;for(var Z=u.repeat(y);S<U;++S)Z+=e.charAt(m[S]);return Z}i(I,"encode");function B(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return new Uint8Array;var y=0;if(f[y]!==" "){for(var L=0,x=0;f[y]===u;)L++,y++;for(var A=(f.length-y)*l+1>>>0,U=new Uint8Array(A);f[y];){var m=r[f.charCodeAt(y)];if(m===255)return;for(var E=0,P=A-1;(m!==0||E<x)&&P!==-1;P--,E++)m+=c*U[P]>>>0,U[P]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");x=E,y++}if(f[y]!==" "){for(var w=A-x;w!==A&&U[w]===0;)w++;for(var S=new Uint8Array(L+(A-w)),Z=L;w!==A;)S[Z++]=U[w++];return S}}}i(B,"decodeUnsafe");function W(f){var y=B(f);if(y)return y;throw new Error(`Non-${t} character`)}return i(W,"decode"),{encode:I,decodeUnsafe:B,decode:W}}i(Dt,"base");var It=Dt,Lt=It,je=Lt;var ae=class{static{i(this,"Encoder")}name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},se=class{static{i(this,"Decoder")}name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Je(this,t)}},ce=class{static{i(this,"ComposedDecoder")}decoders;constructor(t){this.decoders=t}or(t){return Je(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Je(e,t){return new ce({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}i(Je,"or");var fe=class{static{i(this,"Codec")}name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ae(t,r,n),this.decoder=new se(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function k({name:e,prefix:t,encode:r,decode:n}){return new fe(e,t,r,n)}i(k,"from");function D({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=je(r,e);return k({prefix:t,name:e,encode:n,decode:i(a=>C(o(a)),"decode")})}i(D,"baseX");function Tt(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let a=new Uint8Array(o*r/8|0),s=0,c=0,u=0;for(let l=0;l<o;++l){let g=t[e[l]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|g,s+=r,s>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return a}i(Tt,"decode");function Bt(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,a="",s=0,c=0;for(let u=0;u<e.length;++u)for(c=c<<8|e[u],s+=8;s>r;)s-=r,a+=t[o&c>>s];if(s!==0&&(a+=t[o&c<<r-s]),n)for(;(a.length*r&7)!==0;)a+="=";return a}i(Bt,"encode");function kt(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}i(kt,"createAlphabetIdx");function p({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=kt(n);return k({prefix:t,name:e,encode(a){return Bt(a,n,r)},decode(a){return Tt(a,o,r,e)}})}i(p,"rfc4648");var Nt=D({prefix:"9",name:"base10",alphabet:"0123456789"});var ue={};d(ue,{base16:()=>Mt,base16upper:()=>zt});var Mt=p({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zt=p({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ye={};d(ye,{base2:()=>Rt});var Rt=p({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var de={};d(de,{base256emoji:()=>Ft});var Qe=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ot=Qe.reduce((e,t,r)=>(e[r]=t,e),[]),_t=Qe.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function $t(e){return e.reduce((t,r)=>(t+=Ot[r],t),"")}i($t,"encode");function Vt(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=_t[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}i(Vt,"decode");var Ft=k({prefix:"\u{1F680}",name:"base256emoji",encode:$t,decode:Vt});var he={};d(he,{base32:()=>N,base32hex:()=>Xt,base32hexpad:()=>Jt,base32hexpadupper:()=>Qt,base32hexupper:()=>jt,base32pad:()=>Ht,base32padupper:()=>qt,base32upper:()=>Gt,base32z:()=>Wt});var N=p({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Gt=p({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ht=p({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qt=p({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Xt=p({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jt=p({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Jt=p({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qt=p({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wt=p({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var le={};d(le,{base36:()=>F,base36upper:()=>Zt});var F=D({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zt=D({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var me={};d(me,{base58btc:()=>v,base58flickr:()=>Yt});var v=D({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Yt=D({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var be={};d(be,{base64:()=>er,base64pad:()=>tr,base64url:()=>rr,base64urlpad:()=>nr});var er=p({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),tr=p({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),rr=p({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),nr=p({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var xe={};d(xe,{base8:()=>or});var or=p({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var we={};d(we,{identity:()=>ir});var ir=k({prefix:"\0",name:"identity",encode:i(e=>qe(e),"encode"),decode:i(e=>He(e),"decode")});var kn=new TextEncoder,Nn=new TextDecoder;var Ae={};d(Ae,{identity:()=>Pr});var cr=Ye,We=128,fr=127,pr=~fr,ur=Math.pow(2,31);function Ye(e,t,r){t=t||[],r=r||0;for(var n=r;e>=ur;)t[r++]=e&255|We,e/=128;for(;e≺)t[r++]=e&255|We,e>>>=7;return t[r]=e|0,Ye.bytes=r-n+1,t}i(Ye,"encode");var yr=ge,dr=128,Ze=127;function ge(e,n){var r=0,n=n||0,o=0,a=n,s,c=e.length;do{if(a>=c)throw ge.bytes=0,new RangeError("Could not decode varint");s=e[a++],r+=o<28?(s&Ze)<<o:(s&Ze)*Math.pow(2,o),o+=7}while(s>=dr);return ge.bytes=a-n,r}i(ge,"read");var hr=Math.pow(2,7),lr=Math.pow(2,14),mr=Math.pow(2,21),br=Math.pow(2,28),xr=Math.pow(2,35),wr=Math.pow(2,42),gr=Math.pow(2,49),Ar=Math.pow(2,56),Ur=Math.pow(2,63),Er=i(function(e){return e<hr?1:e<lr?2:e<mr?3:e<br?4:e<xr?5:e<wr?6:e<gr?7:e<Ar?8:e<Ur?9:10},"length"),vr={encode:cr,decode:yr,encodingLength:Er},Sr=vr,G=Sr;function H(e,t=0){return[G.decode(e,t),G.decode.bytes]}i(H,"decode");function M(e,t,r=0){return G.encode(e,t,r),t}i(M,"encodeTo");function z(e){return G.encodingLength(e)}i(z,"encodingLength");function O(e,t){let r=t.byteLength,n=z(e),o=n+z(r),a=new Uint8Array(o+r);return M(e,a,0),M(r,a,n),a.set(t,o),new R(e,r,t,a)}i(O,"create");function et(e){let t=C(e),[r,n]=H(t),[o,a]=H(t.subarray(n)),s=t.subarray(n+a);if(s.byteLength!==o)throw new Error("Incorrect length");return new R(r,o,s,t)}i(et,"decode");function tt(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Ge(e.bytes,r.bytes)}}i(tt,"equals");var R=class{static{i(this,"Digest")}code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var rt=0,Cr="identity",nt=C;function Kr(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return O(rt,nt(e))}i(Kr,"digest");var Pr={code:rt,name:Cr,encode:nt,digest:Kr};var ve={};d(ve,{sha256:()=>Ir,sha512:()=>Lr});var Dr=20;function Ee({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Ue(e,t,r,n,o)}i(Ee,"from");var Ue=class{static{i(this,"Hasher")}name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,a){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Dr,this.maxDigestLength=a}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?ot(n,this.code,r?.truncate):n.then(o=>ot(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ot(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return O(t,e)}i(ot,"createDigest");function at(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}i(at,"sha");var Ir=Ee({name:"sha2-256",code:18,encode:at("SHA-256")}),Lr=Ee({name:"sha2-512",code:19,encode:at("SHA-512")});function st(e,t){let{bytes:r,version:n}=e;return n===0?Br(r,Se(e),t??v.encoder):kr(r,Se(e),t??N.encoder)}i(st,"format");var ct=new WeakMap;function Se(e){let t=ct.get(e);if(t==null){let r=new Map;return ct.set(e,r),r}return t}i(Se,"baseCache");var re=class e{static{i(this,"CID")}code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==X)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Nr)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=O(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&tt(t.multihash,n.multihash)}toString(t){return st(this,t)}toJSON(){return{"/":st(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:a,bytes:s}=r;return new e(n,o,a,s??ft(n,o,a.bytes))}else if(r[Mr]===!0){let{version:n,multihash:o,code:a}=r,s=et(o);return e.create(n,a,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==X)throw new Error(`Version 0 CID must use dag-pb (code: ${X}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ft(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,X,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=C(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let a=o.subarray(r.multihashSize-r.digestSize),s=new R(r.multihashCode,r.digestSize,a,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=i(()=>{let[I,B]=H(t.subarray(r));return r+=B,I},"next"),o=n(),a=X;if(o===18?(o=0,r=0):a=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),u=n(),l=r+u,g=l-s;return{version:o,codec:a,multihashCode:c,digestSize:u,multihashSize:g,size:l}}static parse(t,r){let[n,o]=Tr(t,r),a=e.decode(o);if(a.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Se(a).set(n,t),a}};function Tr(e,t){switch(e[0]){case"Q":{let r=t??v;return[v.prefix,r.decode(`${v.prefix}${e}`)]}case v.prefix:{let r=t??v;return[v.prefix,r.decode(e)]}case N.prefix:{let r=t??N;return[N.prefix,r.decode(e)]}case F.prefix:{let r=t??F;return[F.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}i(Tr,"parseCIDtoBytes");function Br(e,t,r){let{prefix:n}=r;if(n!==v.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let a=r.encode(e).slice(1);return t.set(n,a),a}else return o}i(Br,"toStringV0");function kr(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let a=r.encode(e);return t.set(n,a),a}else return o}i(kr,"toStringV1");var X=112,Nr=18;function ft(e,t,r){let n=z(e),o=n+z(t),a=new Uint8Array(o+r.byteLength);return M(e,a,0),M(t,a,n),a.set(r,o),a}i(ft,"encodeCID");var Mr=Symbol.for("@ipld/js-cid/CID");var Ce={...we,...ye,...xe,...pe,...ue,...he,...le,...me,...be,...de},yo={...ve,...Ae};function ut(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}i(ut,"createCodec");var pt=ut("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Ke=ut("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=ee(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),zr={utf8:pt,"utf-8":pt,hex:Ce.base16,latin1:Ke,ascii:Ke,binary:Ke,...Ce},ne=zr;function j(e,t="utf8"){let r=ne[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}i(j,"fromString");function Pe(e,t="utf8"){let r=ne[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}i(Pe,"toString");var yt=32,Rr=1,Or=2,De=32,dt=32,J=12,T=32,Ie=16,ht=0,Le=new TextEncoder().encode("HPKE-v1"),_=2,Te=h(new TextEncoder().encode("KEM"),K(yt,2)),$=h(new TextEncoder().encode("HPKE"),K(yt,2),K(Rr,2),K(Or,2));var oe=globalThis.crypto.subtle;var $o=Object.assign(Hr,{raw:ke}),Vo=Object.assign(ie,{asString:ze}),Fo=Object.assign(Be,{asString:_r,fromString:$r});async function Be(e,t,r){if(t.byteLength<_)throw new Error("malformed message: too short");let n=t[0]<<8|t[1],o=_+n,a=o+J;if(t.byteLength<a+Ie)throw new Error("malformed message: too short");let s=t.slice(_,o),c=t.slice(o,a),u=t.slice(a),l=await ke(e,s,r?.info!==void 0?{info:r.info}:void 0),g=await Gr(l),I=await oe.decrypt({name:"AES-GCM",iv:c},g,u);return new Uint8Array(I)}i(Be,"decryptBytes");async function _r(e,t,r){let n=await Be(e,t,r);return new TextDecoder().decode(n)}i(_r,"decryptToString");async function $r(e,t,r){let n=j(t,"base64url"),o=await Be(e,n,r?.info!==void 0?{info:r.info}:void 0);return r?.buffer?o:new TextDecoder().decode(o)}i($r,"decryptFromString");function Vr(e){if(e!==128&&e!==256)throw new Error(`invalid keysize: ${e} (expected 128 or 256)`)}i(Vr,"validateKeysize");function lt(e){if(e.length!==16&&e.length!==32)throw new Error(`invalid aesKey length: ${e.length} bytes (expected 16 or 32)`)}i(lt,"validateRawKeyBytes");function mt(e){return e==null?new Uint8Array(0):typeof e=="string"?new TextEncoder().encode(e):e}i(mt,"normalizeInfo");async function Fr(e){if(!e.extractable)throw new Error("aesKey must be extractable: its raw bytes are what get sealed");return new Uint8Array(await oe.exportKey("raw",e))}i(Fr,"exportAesKeyBytes");async function bt(e){return oe.importKey("raw",e,{name:"AES-GCM"},!0,["encrypt","decrypt"])}i(bt,"importAesKey");async function Gr(e){return oe.importKey("raw",e,{name:"AES-GCM"},!1,["decrypt"])}i(Gr,"importAesKeyDecryptOnly");async function xt(e,t){let r=new Uint8Array(0),n=await V($,r,"psk_id_hash",r),o=await V($,r,"info_hash",t),a=h(new Uint8Array([ht]),n,o),s=await V($,e,"secret",r),c=await Q($,s,"key",a,dt),u=await Q($,s,"base_nonce",a,J);return{key:c,baseNonce:u}}i(xt,"keySchedule");async function ke(e,t,r){if(t.byteLength<T+Ie)throw new Error("malformed envelope: too short");let n=mt(r?.info),o=t.slice(0,T),a=t.slice(T),s=await _e(o,e),{key:c,baseNonce:u}=await xt(s,n);return Me(c,u,a)}i(ke,"openRawBytes");async function Hr(e,t,r){let n=await ke(e,t,r);return bt(n)}i(Hr,"openBytes");async function wt(e,t,r){let n=mt(r?.info),o;if(t instanceof Uint8Array)lt(t),o=t;else if(t)o=await Fr(t),lt(o);else{let W=r?.size??256;Vr(W),o=globalThis.crypto.getRandomValues(new Uint8Array(W/8))}let a=await Re(e),{sharedSecret:s,enc:c}=await Oe(a),{key:u,baseNonce:l}=await xt(s,n),g=await Ne(u,l,o),I=h(c,g),B=await bt(o);return{enc:I,key:B}}i(wt,"encryptKey");var b=globalThis.crypto.subtle;async function Ne(e,t,r){let n=await b.importKey("raw",e,{name:"AES-GCM"},!1,["encrypt"]),o=await b.encrypt({name:"AES-GCM",iv:t},n,r);return new Uint8Array(o)}i(Ne,"aeadSeal");async function Me(e,t,r){let n=await b.importKey("raw",e,{name:"AES-GCM"},!1,["decrypt"]),o=await b.decrypt({name:"AES-GCM",iv:t},n,r);return new Uint8Array(o)}i(Me,"aeadOpen");async function ie(e,t,r,n){let o=typeof t=="string"?new TextEncoder().encode(t):t,{enc:a,key:s}=await wt(e,r,n),c=globalThis.crypto.getRandomValues(new Uint8Array(J)),u=new Uint8Array(await b.encrypt({name:"AES-GCM",iv:c},s,o));return h(K(a.length,_),a,c,u)}i(ie,"encryptBytes");async function ze(e,t,r,n){let o=await ie(e,t,r,n);return Pe(o,n?.encoding??"base64url")}i(ze,"encryptToString");async function Fe(e,t){let r=await b.importKey("raw",e,{name:"HMAC",hash:"SHA-256"},!1,["sign"]);return new Uint8Array(await b.sign("HMAC",r,t))}i(Fe,"hmac");async function qr(e,t){let r=e.length===0?new Uint8Array(De):e;return Fe(r,t)}i(qr,"extract");async function Xr(e,t,r){let n=new Uint8Array(r),o=new Uint8Array(0),a=0,s=1;for(;a<r;){o=await Fe(e,h(o,t,K(s,1)));let c=Math.min(o.length,r-a);n.set(o.subarray(0,c),a),a+=c,s++}return n}i(Xr,"expand");async function V(e,t,r,n){let o=h(Le,e,new TextEncoder().encode(r),n);return qr(t,o)}i(V,"labeledExtract");async function Q(e,t,r,n,o){let a=h(K(o,2),Le,e,new TextEncoder().encode(r),n);return Xr(t,a,o)}i(Q,"labeledExpand");async function $e(e){return new Uint8Array(await b.exportKey("raw",e))}i($e,"exportRawPublic");async function gt(e){if(e.length!==T)throw new Error(`invalid public key length: ${e.length} bytes (expected ${T})`);return b.importKey("raw",e,{name:"X25519"},!0,[])}i(gt,"importRawPublic");async function Re(e){if(e instanceof Uint8Array)return gt(e);if(e instanceof CryptoKey){if(e.type!=="public")throw new Error("recipient CryptoKey must be a public key");return Ve(e,"recipient CryptoKey"),e}if(typeof e.publicKey=="string"){let{publicKey:r,encoding:n}=e;return gt(j(r,n??"base64url"))}let t=e;if(t.publicKey instanceof CryptoKey){if(t.publicKey.type!=="public")throw new Error("recipient keypair publicKey must be a public key");return Ve(t.publicKey,"recipient keypair publicKey"),t.publicKey}throw new Error("unrecognized recipient key form")}i(Re,"resolveRecipientPublicKey");function Ve(e,t){if(e.algorithm.name!=="X25519")throw new Error(`${t} must be an X25519 key (got ${e.algorithm.name})`)}i(Ve,"assertX25519Algorithm");async function At(e,t){let r=await b.deriveBits({name:"X25519",public:t},e,256),n=new Uint8Array(r);if(n.every(o=>o===0))throw new Error("X25519 shared secret is all-zero (small-order public key?)");return n}i(At,"dh");async function Ut(e,t){let r=await V(Te,new Uint8Array(0),"eae_prk",e);return Q(Te,r,"shared_secret",t,De)}i(Ut,"extractAndExpand");async function Oe(e){let t=await b.generateKey({name:"X25519"},!1,["deriveBits"]),r=await At(t.privateKey,e),n=await $e(t.publicKey),o=await $e(e),a=h(n,o);return{sharedSecret:await Ut(r,a),enc:n}}i(Oe,"encap");async function _e(e,t){if(t.privateKey.type!=="private")throw new Error("keypair.privateKey must be a private key");Ve(t.privateKey,"keypair.privateKey");let r=await b.importKey("raw",e,{name:"X25519"},!1,[]),n=await At(t.privateKey,r),o=await $e(t.publicKey),a=h(e,o);return Ut(n,a)}i(_e,"decap");function K(e,t){let r=new Uint8Array(t),n=e;for(let o=t-1;o>=0;o--)r[o]=n&255,n=Math.floor(n/256);return r}i(K,"i2osp");function h(...e){let t=0;for(let o of e)t+=o.length;let r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}i(h,"concat");
|
|
2
2
|
//# sourceMappingURL=util.min.cjs.map
|