@blockcerts/blockcerts-verifier 1.72.3 → 1.72.4
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/bundle-stats.html +1 -1
- package/coverage/lcov.info +93 -93
- package/dist/{DataIntegrityProof-BhL7Kkhm-affsdujn.js → DataIntegrityProof-x-pKdBCc-B_YUlE0Z.js} +1 -1
- package/dist/{EcdsaSd2023-CUjrjGzC-Cx7ejHu-.js → EcdsaSd2023-CU35O_1w-CISk0lEt.js} +6 -6
- package/dist/{EcdsaSecp256k1Signature2019-D90cAynb-Bf5kILPF.js → EcdsaSecp256k1Signature2019-DiXIv8yq-B2kEN_Qo.js} +1 -1
- package/dist/{Ed25519Signature2020-fJGvlbIp-B6XhFwr4.js → Ed25519Signature2020-B6yblwC5-BRlzT2Yc.js} +5 -5
- package/dist/EddsaRdfc2022-Csk9U_qt-B798omlR.js +14 -0
- package/dist/{HashlinkVerifier-udsj5z09-BTqOkVoD.js → HashlinkVerifier-Bi7nn19S-DMjUYzMR.js} +1 -1
- package/dist/{MerkleProof2017-C0RhRNNx-zjQMRSQY.js → MerkleProof2017-BIJKwMk5-CLYAJK4G.js} +1 -1
- package/dist/{MerkleProof2019-B7f1hhem-CjLDyx6Q.js → MerkleProof2019-CeAt2OGM-DOuISx_E.js} +1 -1
- package/dist/_polyfill-node.crypto-MVmI5M_M-exGcp6nW.js +1 -0
- package/dist/{checkCredentialSchemaConformity-CgpOS3eC-AjSPoJub.js → checkCredentialSchemaConformity-CECtM4WI-C1vg05zb.js} +1 -1
- package/dist/{checkRevocationStatusList2021-D4VNDRlW-DgNfOAoI.js → checkRevocationStatusList2021-B7NFlV-5-C3Zng1tA.js} +1 -1
- package/dist/controlVerificationMethod-Cuyek_Vk-C_Uq2iA5.js +1 -0
- package/dist/{index-DjD0A6uJ-BdFUkPCF.js → index-D7PA_QcD-CyttRwCk.js} +4 -4
- package/dist/{index-DZ7aUhT_-D0G2DVsh.js → index-DFOHyoZq-BCuOIg2Z.js} +11 -11
- package/dist/{jsonld-signatures-D4X_Irzi-D_wBqxSl.js → jsonld-signatures-BtZPa7MV-DTekMXP5.js} +2 -2
- package/dist/main.js +10 -10
- package/dist/{retrieveVerificationMethodPublicKey-D_autuwE-DGbK-RPm.js → retrieveVerificationMethodPublicKey-DcEGtx_h-D1zuvtQB.js} +1 -1
- package/dist/verifyIssuerProfile-DQji41Fc-l31-7imR.js +1 -0
- package/dist/webcrypto.es-aoUxIxUm-gGk5JRJH.js +40 -0
- package/package.json +2 -2
- package/dist/EddsaRdfc2022-XufziFi3-D5IoKiRE.js +0 -14
- package/dist/_polyfill-node.crypto-DGISCHrB-C5-OOGc0.js +0 -1
- package/dist/controlVerificationMethod-CSwPoUL8-CvUADmjg.js +0 -1
- package/dist/ed25519-key-pair.esm-DxoBwwVJ-D8j8wFfG.js +0 -1
- package/dist/tslib.es6--gQC4x5c-CmLYFWVC.js +0 -1
- package/dist/verifyIssuerProfile-2PhdMtQZ-CfqcAkBL.js +0 -1
- package/dist/webcrypto.es-BOyMRPOj-CAxP3jJR.js +0 -40
- /package/dist/{Suite-Bu3gszvt-Dmvbh142.js → Suite-CBLHluYK-Dmvbh142.js} +0 -0
- /package/dist/{ensureNotRevoked-ByWaYoog-BheL-ZKZ.js → ensureNotRevoked-CNUfpW4F-BheL-ZKZ.js} +0 -0
- /package/dist/{ensureValidIssuingKey-DEV9E0Ph-DY8BTObG.js → ensureValidIssuingKey-DN2kpCwj-DY8BTObG.js} +0 -0
- /package/dist/{index-CyNtT_1q-Dgus2xdV.js → index-6G1g4ypj-Dgus2xdV.js} +0 -0
- /package/dist/{index-tlZQQ_rg-CYTlxhyY.js → index-DNlz8u7B-CYTlxhyY.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{y as t,m as r,B as e}from"./main.js";import{_ as n}from"./tslib.es6--gQC4x5c-CmLYFWVC.js";import{_ as o}from"./_polyfill-node.crypto-DGISCHrB-C5-OOGc0.js";var i,a={},u={},s={},c={};function f(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var h,l={},p={};function y(){if(h)return p;return h=1,Object.defineProperty(p,"__esModule",{value:!0}),p.wipe=function(t){for(var r=0;r<t.length;r++)t[r]=0;return t},p}var d,v,w=t(o);function g(){if(d)return l;d=1,Object.defineProperty(l,"__esModule",{value:!0}),l.NodeRandomSource=void 0;const t=y();return l.NodeRandomSource=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,void 0!==f){const t=w;t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(r){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let e=this._crypto.randomBytes(r);if(e.length!==r)throw new Error("NodeRandomSource: got fewer bytes than requested");const n=new Uint8Array(r);for(let t=0;t<n.length;t++)n[t]=e[t];return(0,t.wipe)(e),n}},l}function b(){if(v)return s;v=1,Object.defineProperty(s,"__esModule",{value:!0}),s.SystemRandomSource=void 0;const t=(i||(i=1,Object.defineProperty(c,"__esModule",{value:!0}),c.BrowserRandomSource=void 0,c.BrowserRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const t="undefined"!=typeof self?self.crypto||self.msCrypto:null;t&&void 0!==t.getRandomValues&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const r=new Uint8Array(t);for(let t=0;t<r.length;t+=65536)this._crypto.getRandomValues(r.subarray(t,t+Math.min(r.length-t,65536)));return r}}),c),r=g();return s.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new t.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new r.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}},s}var m,E,_,L={},K={};function A(){if(E)return L;E=1,Object.defineProperty(L,"__esModule",{value:!0});var t,r=(m||(m=1,t=K,Object.defineProperty(t,"__esModule",{value:!0}),t.mul=Math.imul||function(t,r){var e=65535&t,n=65535&r;return e*n+((t>>>16&65535)*n+e*(r>>>16&65535)<<16>>>0)|0},t.add=function(t,r){return t+r|0},t.sub=function(t,r){return t-r|0},t.rotl=function(t,r){return t<<r|t>>>32-r},t.rotr=function(t,r){return t<<32-r|t>>>r},t.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(r){return t.isInteger(r)&&r>=-t.MAX_SAFE_INTEGER&&r<=t.MAX_SAFE_INTEGER}),K);function e(t,r,e){return void 0===r&&(r=new Uint8Array(2)),void 0===e&&(e=0),r[e+0]=t>>>8,r[e+1]=t>>>0,r}function n(t,r,e){return void 0===r&&(r=new Uint8Array(2)),void 0===e&&(e=0),r[e+0]=t>>>0,r[e+1]=t>>>8,r}function o(t,r){return void 0===r&&(r=0),t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3]}function i(t,r){return void 0===r&&(r=0),(t[r]<<24|t[r+1]<<16|t[r+2]<<8|t[r+3])>>>0}function a(t,r){return void 0===r&&(r=0),t[r+3]<<24|t[r+2]<<16|t[r+1]<<8|t[r]}function u(t,r){return void 0===r&&(r=0),(t[r+3]<<24|t[r+2]<<16|t[r+1]<<8|t[r])>>>0}function s(t,r,e){return void 0===r&&(r=new Uint8Array(4)),void 0===e&&(e=0),r[e+0]=t>>>24,r[e+1]=t>>>16,r[e+2]=t>>>8,r[e+3]=t>>>0,r}function c(t,r,e){return void 0===r&&(r=new Uint8Array(4)),void 0===e&&(e=0),r[e+0]=t>>>0,r[e+1]=t>>>8,r[e+2]=t>>>16,r[e+3]=t>>>24,r}function f(t,r,e){return void 0===r&&(r=new Uint8Array(8)),void 0===e&&(e=0),s(t/4294967296>>>0,r,e),s(t>>>0,r,e+4),r}function h(t,r,e){return void 0===r&&(r=new Uint8Array(8)),void 0===e&&(e=0),c(t>>>0,r,e),c(t/4294967296>>>0,r,e+4),r}return L.readInt16BE=function(t,r){return void 0===r&&(r=0),(t[r+0]<<8|t[r+1])<<16>>16},L.readUint16BE=function(t,r){return void 0===r&&(r=0),(t[r+0]<<8|t[r+1])>>>0},L.readInt16LE=function(t,r){return void 0===r&&(r=0),(t[r+1]<<8|t[r])<<16>>16},L.readUint16LE=function(t,r){return void 0===r&&(r=0),(t[r+1]<<8|t[r])>>>0},L.writeUint16BE=e,L.writeInt16BE=e,L.writeUint16LE=n,L.writeInt16LE=n,L.readInt32BE=o,L.readUint32BE=i,L.readInt32LE=a,L.readUint32LE=u,L.writeUint32BE=s,L.writeInt32BE=s,L.writeUint32LE=c,L.writeInt32LE=c,L.readInt64BE=function(t,r){void 0===r&&(r=0);var e=o(t,r),n=o(t,r+4);return 4294967296*e+n-4294967296*(n>>31)},L.readUint64BE=function(t,r){return void 0===r&&(r=0),4294967296*i(t,r)+i(t,r+4)},L.readInt64LE=function(t,r){void 0===r&&(r=0);var e=a(t,r);return 4294967296*a(t,r+4)+e-4294967296*(e>>31)},L.readUint64LE=function(t,r){void 0===r&&(r=0);var e=u(t,r);return 4294967296*u(t,r+4)+e},L.writeUint64BE=f,L.writeInt64BE=f,L.writeUint64LE=h,L.writeInt64LE=h,L.readUintBE=function(t,r,e){if(void 0===e&&(e=0),t%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>r.length-e)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,o=1,i=t/8+e-1;i>=e;i--)n+=r[i]*o,o*=256;return n},L.readUintLE=function(t,r,e){if(void 0===e&&(e=0),t%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>r.length-e)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,o=1,i=e;i<e+t/8;i++)n+=r[i]*o,o*=256;return n},L.writeUintBE=function(t,e,n,o){if(void 0===n&&(n=new Uint8Array(t/8)),void 0===o&&(o=0),t%8!=0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!r.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,a=t/8+o-1;a>=o;a--)n[a]=e/i&255,i*=256;return n},L.writeUintLE=function(t,e,n,o){if(void 0===n&&(n=new Uint8Array(t/8)),void 0===o&&(o=0),t%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!r.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,a=o;a<o+t/8;a++)n[a]=e/i&255,i*=256;return n},L.readFloat32BE=function(t,r){return void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat32(r)},L.readFloat32LE=function(t,r){return void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat32(r,!0)},L.readFloat64BE=function(t,r){return void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat64(r)},L.readFloat64LE=function(t,r){return void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).getFloat64(r,!0)},L.writeFloat32BE=function(t,r,e){return void 0===r&&(r=new Uint8Array(4)),void 0===e&&(e=0),new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat32(e,t),r},L.writeFloat32LE=function(t,r,e){return void 0===r&&(r=new Uint8Array(4)),void 0===e&&(e=0),new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat32(e,t,!0),r},L.writeFloat64BE=function(t,r,e){return void 0===r&&(r=new Uint8Array(8)),void 0===e&&(e=0),new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat64(e,t),r},L.writeFloat64LE=function(t,r,e){return void 0===r&&(r=new Uint8Array(8)),void 0===e&&(e=0),new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat64(e,t,!0),r},L}function x(){return _||(_=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const r=b(),e=A(),n=y();function o(r,e=t.defaultRandomSource){return e.randomBytes(r)}t.defaultRandomSource=new r.SystemRandomSource,t.randomBytes=o,t.randomUint32=function(r=t.defaultRandomSource){const i=o(4,r),a=(0,e.readUint32LE)(i);return(0,n.wipe)(i),a};const i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function a(r,e=i,a=t.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let u="";const s=e.length,c=256-256%s;for(;r>0;){const t=o(Math.ceil(256*r/c),a);for(let n=0;n<t.length&&r>0;n++){const o=t[n];o<c&&(u+=e.charAt(o%s),r--)}(0,n.wipe)(t)}return u}t.randomString=a,t.randomStringForEntropy=function(r,e=i,n=t.defaultRandomSource){return a(Math.ceil(r/(Math.log(e.length)/Math.LN2)),e,n)}}(u)),u}var M,U,S={};var B,N=(U||(U=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.convertSecretKeyToX25519=t.convertPublicKeyToX25519=t.verify=t.sign=t.extractPublicKeyFromSecretKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.SEED_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=t.SIGNATURE_LENGTH=void 0;const r=x(),e=(M||(M=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});var r=A(),e=y();t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var n=function(){function n(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return n.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},n.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},n.prototype.clean=function(){e.wipe(this._buffer),e.wipe(this._tempHi),e.wipe(this._tempLo),this.reset()},n.prototype.update=function(r,e){if(void 0===e&&(e=r.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var n=0;if(this._bytesHashed+=e,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&e>0;)this._buffer[this._bufferLength++]=r[n++],e--;this._bufferLength===this.blockSize&&(i(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(e>=this.blockSize&&(n=i(this._tempHi,this._tempLo,this._stateHi,this._stateLo,r,n,e),e%=this.blockSize);e>0;)this._buffer[this._bufferLength++]=r[n++],e--;return this},n.prototype.finish=function(t){if(!this._finished){var e=this._bytesHashed,n=this._bufferLength,o=e/536870912|0,a=e<<3,u=e%128<112?128:256;this._buffer[n]=128;for(var s=n+1;s<u-8;s++)this._buffer[s]=0;r.writeUint32BE(o,this._buffer,u-8),r.writeUint32BE(a,this._buffer,u-4),i(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,u),this._finished=!0}for(s=0;s<this.digestLength/8;s++)r.writeUint32BE(this._stateHi[s],t,8*s),r.writeUint32BE(this._stateLo[s],t,8*s+4);return this},n.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},n.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},n.prototype.restoreState=function(t){return this._stateHi.set(t.stateHi),this._stateLo.set(t.stateLo),this._bufferLength=t.bufferLength,t.buffer&&this._buffer.set(t.buffer),this._bytesHashed=t.bytesHashed,this._finished=!1,this},n.prototype.cleanSavedState=function(t){e.wipe(t.stateHi),e.wipe(t.stateLo),t.buffer&&e.wipe(t.buffer),t.bufferLength=0,t.bytesHashed=0},n}();t.SHA512=n;var o=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function i(t,e,n,i,a,u,s){for(var c,f,h,l,p,y,d,v,w=n[0],g=n[1],b=n[2],m=n[3],E=n[4],_=n[5],L=n[6],K=n[7],A=i[0],x=i[1],M=i[2],U=i[3],S=i[4],B=i[5],N=i[6],k=i[7];s>=128;){for(var T=0;T<16;T++){var H=8*T+u;t[T]=r.readUint32BE(a,H),e[T]=r.readUint32BE(a,H+4)}for(T=0;T<80;T++){var P,O,I=w,G=g,F=b,j=m,R=E,J=_,C=L,D=A,X=x,Y=M,V=U,W=S,z=B,q=N;if(p=65535&(f=k),y=f>>>16,d=65535&(c=K),v=c>>>16,p+=65535&(f=(S>>>14|E<<18)^(S>>>18|E<<14)^(E>>>9|S<<23)),y+=f>>>16,d+=65535&(c=(E>>>14|S<<18)^(E>>>18|S<<14)^(S>>>9|E<<23)),v+=c>>>16,p+=65535&(f=S&B^~S&N),y+=f>>>16,d+=65535&(c=E&_^~E&L),v+=c>>>16,c=o[2*T],p+=65535&(f=o[2*T+1]),y+=f>>>16,d+=65535&c,v+=c>>>16,c=t[T%16],y+=(f=e[T%16])>>>16,d+=65535&c,v+=c>>>16,d+=(y+=(p+=65535&f)>>>16)>>>16,p=65535&(f=l=65535&p|y<<16),y=f>>>16,d=65535&(c=h=65535&d|(v+=d>>>16)<<16),v=c>>>16,p+=65535&(f=(A>>>28|w<<4)^(w>>>2|A<<30)^(w>>>7|A<<25)),y+=f>>>16,d+=65535&(c=(w>>>28|A<<4)^(A>>>2|w<<30)^(A>>>7|w<<25)),v+=c>>>16,y+=(f=A&x^A&M^x&M)>>>16,d+=65535&(c=w&g^w&b^g&b),v+=c>>>16,P=65535&(d+=(y+=(p+=65535&f)>>>16)>>>16)|(v+=d>>>16)<<16,O=65535&p|y<<16,p=65535&(f=V),y=f>>>16,d=65535&(c=j),v=c>>>16,y+=(f=l)>>>16,d+=65535&(c=h),v+=c>>>16,g=I,b=G,m=F,E=j=65535&(d+=(y+=(p+=65535&f)>>>16)>>>16)|(v+=d>>>16)<<16,_=R,L=J,K=C,w=P,x=D,M=X,U=Y,S=V=65535&p|y<<16,B=W,N=z,k=q,A=O,T%16==15)for(H=0;H<16;H++)c=t[H],p=65535&(f=e[H]),y=f>>>16,d=65535&c,v=c>>>16,c=t[(H+9)%16],p+=65535&(f=e[(H+9)%16]),y+=f>>>16,d+=65535&c,v+=c>>>16,h=t[(H+1)%16],p+=65535&(f=((l=e[(H+1)%16])>>>1|h<<31)^(l>>>8|h<<24)^(l>>>7|h<<25)),y+=f>>>16,d+=65535&(c=(h>>>1|l<<31)^(h>>>8|l<<24)^h>>>7),v+=c>>>16,h=t[(H+14)%16],y+=(f=((l=e[(H+14)%16])>>>19|h<<13)^(h>>>29|l<<3)^(l>>>6|h<<26))>>>16,d+=65535&(c=(h>>>19|l<<13)^(l>>>29|h<<3)^h>>>6),v+=c>>>16,v+=(d+=(y+=(p+=65535&f)>>>16)>>>16)>>>16,t[H]=65535&d|v<<16,e[H]=65535&p|y<<16}p=65535&(f=A),y=f>>>16,d=65535&(c=w),v=c>>>16,c=n[0],y+=(f=i[0])>>>16,d+=65535&c,v+=c>>>16,v+=(d+=(y+=(p+=65535&f)>>>16)>>>16)>>>16,n[0]=w=65535&d|v<<16,i[0]=A=65535&p|y<<16,p=65535&(f=x),y=f>>>16,d=65535&(c=g),v=c>>>16,c=n[1],y+=(f=i[1])>>>16,d+=65535&c,v+=c>>>16,v+=(d+=(y+=(p+=65535&f)>>>16)>>>16)>>>16,n[1]=g=65535&d|v<<16,i[1]=x=65535&p|y<<16,p=65535&(f=M),y=f>>>16,d=65535&(c=b),v=c>>>16,c=n[2],y+=(f=i[2])>>>16,d+=65535&c,v+=c>>>16,v+=(d+=(y+=(p+=65535&f)>>>16)>>>16)>>>16,n[2]=b=65535&d|v<<16,i[2]=M=65535&p|y<<16,p=65535&(f=U),y=f>>>16,d=65535&(c=m),v=c>>>16,c=n[3],y+=(f=i[3])>>>16,d+=65535&c,v+=c>>>16,v+=(d+=(y+=(p+=65535&f)>>>16)>>>16)>>>16,n[3]=m=65535&d|v<<16,i[3]=U=65535&p|y<<16,p=65535&(f=S),y=f>>>16,d=65535&(c=E),v=c>>>16,c=n[4],y+=(f=i[4])>>>16,d+=65535&c,v+=c>>>16,v+=(d+=(y+=(p+=65535&f)>>>16)>>>16)>>>16,n[4]=E=65535&d|v<<16,i[4]=S=65535&p|y<<16,p=65535&(f=B),y=f>>>16,d=65535&(c=_),v=c>>>16,c=n[5],y+=(f=i[5])>>>16,d+=65535&c,v+=c>>>16,v+=(d+=(y+=(p+=65535&f)>>>16)>>>16)>>>16,n[5]=_=65535&d|v<<16,i[5]=B=65535&p|y<<16,p=65535&(f=N),y=f>>>16,d=65535&(c=L),v=c>>>16,c=n[6],y+=(f=i[6])>>>16,d+=65535&c,v+=c>>>16,v+=(d+=(y+=(p+=65535&f)>>>16)>>>16)>>>16,n[6]=L=65535&d|v<<16,i[6]=N=65535&p|y<<16,p=65535&(f=k),y=f>>>16,d=65535&(c=K),v=c>>>16,c=n[7],y+=(f=i[7])>>>16,d+=65535&c,v+=c>>>16,v+=(d+=(y+=(p+=65535&f)>>>16)>>>16)>>>16,n[7]=K=65535&d|v<<16,i[7]=k=65535&p|y<<16,u+=128,s-=128}return u}t.hash=function(t){var r=new n;r.update(t);var e=r.digest();return r.clean(),e}}(S)),S),n=y();function o(t){const r=new Float64Array(16);if(t)for(let e=0;e<t.length;e++)r[e]=t[e];return r}t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32,new Uint8Array(32)[0]=9;const i=o(),a=o([1]),u=o([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),s=o([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),c=o([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),f=o([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),h=o([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function l(t,r){for(let e=0;e<16;e++)t[e]=0|r[e]}function p(t){let r=1;for(let e=0;e<16;e++){let n=t[e]+r+65535;r=Math.floor(n/65536),t[e]=n-65536*r}t[0]+=r-1+37*(r-1)}function d(t,r,e){const n=~(e-1);for(let e=0;e<16;e++){const o=n&(t[e]^r[e]);t[e]^=o,r[e]^=o}}function v(t,r){const e=o(),n=o();for(let t=0;t<16;t++)n[t]=r[t];p(n),p(n),p(n);for(let t=0;t<2;t++){e[0]=n[0]-65517;for(let t=1;t<15;t++)e[t]=n[t]-65535-(e[t-1]>>16&1),e[t-1]&=65535;e[15]=n[15]-32767-(e[14]>>16&1);const t=e[15]>>16&1;e[14]&=65535,d(n,e,1-t)}for(let r=0;r<16;r++)t[2*r]=255&n[r],t[2*r+1]=n[r]>>8}function w(t,r){let e=0;for(let n=0;n<32;n++)e|=t[n]^r[n];return(1&e-1>>>8)-1}function g(t,r){const e=new Uint8Array(32),n=new Uint8Array(32);return v(e,t),v(n,r),w(e,n)}function b(t){const r=new Uint8Array(32);return v(r,t),1&r[0]}function m(t,r,e){for(let n=0;n<16;n++)t[n]=r[n]+e[n]}function E(t,r,e){for(let n=0;n<16;n++)t[n]=r[n]-e[n]}function _(t,r,e){let n,o,i=0,a=0,u=0,s=0,c=0,f=0,h=0,l=0,p=0,y=0,d=0,v=0,w=0,g=0,b=0,m=0,E=0,_=0,L=0,K=0,A=0,x=0,M=0,U=0,S=0,B=0,N=0,k=0,T=0,H=0,P=0,O=e[0],I=e[1],G=e[2],F=e[3],j=e[4],R=e[5],J=e[6],C=e[7],D=e[8],X=e[9],Y=e[10],V=e[11],W=e[12],z=e[13],q=e[14],Z=e[15];n=r[0],i+=n*O,a+=n*I,u+=n*G,s+=n*F,c+=n*j,f+=n*R,h+=n*J,l+=n*C,p+=n*D,y+=n*X,d+=n*Y,v+=n*V,w+=n*W,g+=n*z,b+=n*q,m+=n*Z,n=r[1],a+=n*O,u+=n*I,s+=n*G,c+=n*F,f+=n*j,h+=n*R,l+=n*J,p+=n*C,y+=n*D,d+=n*X,v+=n*Y,w+=n*V,g+=n*W,b+=n*z,m+=n*q,E+=n*Z,n=r[2],u+=n*O,s+=n*I,c+=n*G,f+=n*F,h+=n*j,l+=n*R,p+=n*J,y+=n*C,d+=n*D,v+=n*X,w+=n*Y,g+=n*V,b+=n*W,m+=n*z,E+=n*q,_+=n*Z,n=r[3],s+=n*O,c+=n*I,f+=n*G,h+=n*F,l+=n*j,p+=n*R,y+=n*J,d+=n*C,v+=n*D,w+=n*X,g+=n*Y,b+=n*V,m+=n*W,E+=n*z,_+=n*q,L+=n*Z,n=r[4],c+=n*O,f+=n*I,h+=n*G,l+=n*F,p+=n*j,y+=n*R,d+=n*J,v+=n*C,w+=n*D,g+=n*X,b+=n*Y,m+=n*V,E+=n*W,_+=n*z,L+=n*q,K+=n*Z,n=r[5],f+=n*O,h+=n*I,l+=n*G,p+=n*F,y+=n*j,d+=n*R,v+=n*J,w+=n*C,g+=n*D,b+=n*X,m+=n*Y,E+=n*V,_+=n*W,L+=n*z,K+=n*q,A+=n*Z,n=r[6],h+=n*O,l+=n*I,p+=n*G,y+=n*F,d+=n*j,v+=n*R,w+=n*J,g+=n*C,b+=n*D,m+=n*X,E+=n*Y,_+=n*V,L+=n*W,K+=n*z,A+=n*q,x+=n*Z,n=r[7],l+=n*O,p+=n*I,y+=n*G,d+=n*F,v+=n*j,w+=n*R,g+=n*J,b+=n*C,m+=n*D,E+=n*X,_+=n*Y,L+=n*V,K+=n*W,A+=n*z,x+=n*q,M+=n*Z,n=r[8],p+=n*O,y+=n*I,d+=n*G,v+=n*F,w+=n*j,g+=n*R,b+=n*J,m+=n*C,E+=n*D,_+=n*X,L+=n*Y,K+=n*V,A+=n*W,x+=n*z,M+=n*q,U+=n*Z,n=r[9],y+=n*O,d+=n*I,v+=n*G,w+=n*F,g+=n*j,b+=n*R,m+=n*J,E+=n*C,_+=n*D,L+=n*X,K+=n*Y,A+=n*V,x+=n*W,M+=n*z,U+=n*q,S+=n*Z,n=r[10],d+=n*O,v+=n*I,w+=n*G,g+=n*F,b+=n*j,m+=n*R,E+=n*J,_+=n*C,L+=n*D,K+=n*X,A+=n*Y,x+=n*V,M+=n*W,U+=n*z,S+=n*q,B+=n*Z,n=r[11],v+=n*O,w+=n*I,g+=n*G,b+=n*F,m+=n*j,E+=n*R,_+=n*J,L+=n*C,K+=n*D,A+=n*X,x+=n*Y,M+=n*V,U+=n*W,S+=n*z,B+=n*q,N+=n*Z,n=r[12],w+=n*O,g+=n*I,b+=n*G,m+=n*F,E+=n*j,_+=n*R,L+=n*J,K+=n*C,A+=n*D,x+=n*X,M+=n*Y,U+=n*V,S+=n*W,B+=n*z,N+=n*q,k+=n*Z,n=r[13],g+=n*O,b+=n*I,m+=n*G,E+=n*F,_+=n*j,L+=n*R,K+=n*J,A+=n*C,x+=n*D,M+=n*X,U+=n*Y,S+=n*V,B+=n*W,N+=n*z,k+=n*q,T+=n*Z,n=r[14],b+=n*O,m+=n*I,E+=n*G,_+=n*F,L+=n*j,K+=n*R,A+=n*J,x+=n*C,M+=n*D,U+=n*X,S+=n*Y,B+=n*V,N+=n*W,k+=n*z,T+=n*q,H+=n*Z,n=r[15],m+=n*O,E+=n*I,_+=n*G,L+=n*F,K+=n*j,A+=n*R,x+=n*J,M+=n*C,U+=n*D,S+=n*X,B+=n*Y,N+=n*V,k+=n*W,T+=n*z,H+=n*q,P+=n*Z,i+=38*E,a+=38*_,u+=38*L,s+=38*K,c+=38*A,f+=38*x,h+=38*M,l+=38*U,p+=38*S,y+=38*B,d+=38*N,v+=38*k,w+=38*T,g+=38*H,b+=38*P,o=1,n=i+o+65535,o=Math.floor(n/65536),i=n-65536*o,n=a+o+65535,o=Math.floor(n/65536),a=n-65536*o,n=u+o+65535,o=Math.floor(n/65536),u=n-65536*o,n=s+o+65535,o=Math.floor(n/65536),s=n-65536*o,n=c+o+65535,o=Math.floor(n/65536),c=n-65536*o,n=f+o+65535,o=Math.floor(n/65536),f=n-65536*o,n=h+o+65535,o=Math.floor(n/65536),h=n-65536*o,n=l+o+65535,o=Math.floor(n/65536),l=n-65536*o,n=p+o+65535,o=Math.floor(n/65536),p=n-65536*o,n=y+o+65535,o=Math.floor(n/65536),y=n-65536*o,n=d+o+65535,o=Math.floor(n/65536),d=n-65536*o,n=v+o+65535,o=Math.floor(n/65536),v=n-65536*o,n=w+o+65535,o=Math.floor(n/65536),w=n-65536*o,n=g+o+65535,o=Math.floor(n/65536),g=n-65536*o,n=b+o+65535,o=Math.floor(n/65536),b=n-65536*o,n=m+o+65535,o=Math.floor(n/65536),m=n-65536*o,i+=o-1+37*(o-1),o=1,n=i+o+65535,o=Math.floor(n/65536),i=n-65536*o,n=a+o+65535,o=Math.floor(n/65536),a=n-65536*o,n=u+o+65535,o=Math.floor(n/65536),u=n-65536*o,n=s+o+65535,o=Math.floor(n/65536),s=n-65536*o,n=c+o+65535,o=Math.floor(n/65536),c=n-65536*o,n=f+o+65535,o=Math.floor(n/65536),f=n-65536*o,n=h+o+65535,o=Math.floor(n/65536),h=n-65536*o,n=l+o+65535,o=Math.floor(n/65536),l=n-65536*o,n=p+o+65535,o=Math.floor(n/65536),p=n-65536*o,n=y+o+65535,o=Math.floor(n/65536),y=n-65536*o,n=d+o+65535,o=Math.floor(n/65536),d=n-65536*o,n=v+o+65535,o=Math.floor(n/65536),v=n-65536*o,n=w+o+65535,o=Math.floor(n/65536),w=n-65536*o,n=g+o+65535,o=Math.floor(n/65536),g=n-65536*o,n=b+o+65535,o=Math.floor(n/65536),b=n-65536*o,n=m+o+65535,o=Math.floor(n/65536),m=n-65536*o,i+=o-1+37*(o-1),t[0]=i,t[1]=a,t[2]=u,t[3]=s,t[4]=c,t[5]=f,t[6]=h,t[7]=l,t[8]=p,t[9]=y,t[10]=d,t[11]=v,t[12]=w,t[13]=g,t[14]=b,t[15]=m}function L(t,r){_(t,r,r)}function K(t,r){const e=o();let n;for(n=0;n<16;n++)e[n]=r[n];for(n=253;n>=0;n--)L(e,e),2!==n&&4!==n&&_(e,e,r);for(n=0;n<16;n++)t[n]=e[n]}function U(t,r){const e=o(),n=o(),i=o(),a=o(),u=o(),c=o(),f=o(),h=o(),l=o();E(e,t[1],t[0]),E(l,r[1],r[0]),_(e,e,l),m(n,t[0],t[1]),m(l,r[0],r[1]),_(n,n,l),_(i,t[3],r[3]),_(i,i,s),_(a,t[2],r[2]),m(a,a,a),E(u,n,e),E(c,a,i),m(f,a,i),m(h,n,e),_(t[0],u,c),_(t[1],h,f),_(t[2],f,c),_(t[3],u,h)}function B(t,r,e){for(let n=0;n<4;n++)d(t[n],r[n],e)}function N(t,r){const e=o(),n=o(),i=o();K(i,r[2]),_(e,r[0],i),_(n,r[1],i),v(t,n),t[31]^=b(e)<<7}function k(t,r,e){l(t[0],i),l(t[1],a),l(t[2],a),l(t[3],i);for(let n=255;n>=0;--n){const o=e[n/8|0]>>(7&n)&1;B(t,r,o),U(r,t),U(t,t),B(t,r,o)}}function T(t,r){const e=[o(),o(),o(),o()];l(e[0],c),l(e[1],f),l(e[2],a),_(e[3],c,f),k(t,e,r)}function H(r){if(r.length!==t.SEED_LENGTH)throw new Error(`ed25519: seed must be ${t.SEED_LENGTH} bytes`);const n=(0,e.hash)(r);n[0]&=248,n[31]&=127,n[31]|=64;const i=new Uint8Array(32),a=[o(),o(),o(),o()];T(a,n),N(i,a);const u=new Uint8Array(64);return u.set(r),u.set(i,32),{publicKey:i,secretKey:u}}t.generateKeyPairFromSeed=H,t.generateKeyPair=function(t){const e=(0,r.randomBytes)(32,t),o=H(e);return(0,n.wipe)(e),o},t.extractPublicKeyFromSecretKey=function(r){if(r.length!==t.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${t.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))};const P=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function O(t,r){let e,n,o,i;for(n=63;n>=32;--n){for(e=0,o=n-32,i=n-12;o<i;++o)r[o]+=e-16*r[n]*P[o-(n-32)],e=Math.floor((r[o]+128)/256),r[o]-=256*e;r[o]+=e,r[n]=0}for(e=0,o=0;o<32;o++)r[o]+=e-(r[31]>>4)*P[o],e=r[o]>>8,r[o]&=255;for(o=0;o<32;o++)r[o]-=e*P[o];for(n=0;n<32;n++)r[n+1]+=r[n]>>8,t[n]=255&r[n]}function I(t){const r=new Float64Array(64);for(let e=0;e<64;e++)r[e]=t[e];for(let r=0;r<64;r++)t[r]=0;O(t,r)}function G(t,r){const e=o(),n=o(),s=o(),c=o(),f=o(),p=o(),y=o();return l(t[2],a),function(t,r){for(let e=0;e<16;e++)t[e]=r[2*e]+(r[2*e+1]<<8);t[15]&=32767}(t[1],r),L(s,t[1]),_(c,s,u),E(s,s,t[2]),m(c,t[2],c),L(f,c),L(p,f),_(y,p,f),_(e,y,s),_(e,e,c),function(t,r){const e=o();let n;for(n=0;n<16;n++)e[n]=r[n];for(n=250;n>=0;n--)L(e,e),1!==n&&_(e,e,r);for(n=0;n<16;n++)t[n]=e[n]}(e,e),_(e,e,s),_(e,e,c),_(e,e,c),_(t[0],e,c),L(n,t[0]),_(n,n,c),g(n,s)&&_(t[0],t[0],h),L(n,t[0]),_(n,n,c),g(n,s)?-1:(b(t[0])===r[31]>>7&&E(t[0],i,t[0]),_(t[3],t[0],t[1]),0)}t.sign=function(t,r){const n=new Float64Array(64),i=[o(),o(),o(),o()],a=(0,e.hash)(t.subarray(0,32));a[0]&=248,a[31]&=127,a[31]|=64;const u=new Uint8Array(64);u.set(a.subarray(32),32);const s=new e.SHA512;s.update(u.subarray(32)),s.update(r);const c=s.digest();s.clean(),I(c),T(i,c),N(u,i),s.reset(),s.update(u.subarray(0,32)),s.update(t.subarray(32)),s.update(r);const f=s.digest();I(f);for(let t=0;t<32;t++)n[t]=c[t];for(let t=0;t<32;t++)for(let r=0;r<32;r++)n[t+r]+=f[t]*a[r];return O(u.subarray(32),n),u},t.verify=function(r,n,i){const a=new Uint8Array(32),u=[o(),o(),o(),o()],s=[o(),o(),o(),o()];if(i.length!==t.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${t.SIGNATURE_LENGTH} bytes`);if(G(s,r))return!1;const c=new e.SHA512;c.update(i.subarray(0,32)),c.update(r),c.update(n);const f=c.digest();return I(f),k(u,s,f),T(s,i.subarray(32)),U(u,s),N(a,u),!w(i,a)},t.convertPublicKeyToX25519=function(t){let r=[o(),o(),o(),o()];if(G(r,t))throw new Error("Ed25519: invalid public key");let e=o(),n=o(),i=r[1];m(e,a,i),E(n,a,i),K(n,n),_(e,e,n);let u=new Uint8Array(32);return v(u,e),u},t.convertSecretKeyToX25519=function(t){const r=(0,e.hash)(t.subarray(0,32));r[0]&=248,r[31]&=127,r[31]|=64;const o=new Uint8Array(r.subarray(0,32));return(0,n.wipe)(r),o}}(a)),a),k={exports:{}},T={};var H,P,O={};var I,G,F=(P||(P=1,"production"===r.env.NODE_ENV?k.exports=(B||(B=1,I=T,Object.defineProperty(I,"__esModule",{value:!0}),I.staticImplements=function(){return function(t){}}),T):k.exports=(H||(H=1,Object.defineProperty(O,"__esModule",{value:!0}),O.staticImplements=function(){return function(t){}}),O)),k.exports),j={};var R,J=(G||(G=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.sharedKey=t.generateKeyPair=t.generateKeyPairFromSeed=t.scalarMultBase=t.scalarMult=t.SHARED_KEY_LENGTH=t.SECRET_KEY_LENGTH=t.PUBLIC_KEY_LENGTH=void 0;const r=x(),e=y();function n(t){const r=new Float64Array(16);if(t)for(let e=0;e<t.length;e++)r[e]=t[e];return r}t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;const o=new Uint8Array(32);o[0]=9;const i=n([56129,1]);function a(t){let r=1;for(let e=0;e<16;e++){let n=t[e]+r+65535;r=Math.floor(n/65536),t[e]=n-65536*r}t[0]+=r-1+37*(r-1)}function u(t,r,e){const n=~(e-1);for(let e=0;e<16;e++){const o=n&(t[e]^r[e]);t[e]^=o,r[e]^=o}}function s(t,r,e){for(let n=0;n<16;n++)t[n]=r[n]+e[n]}function c(t,r,e){for(let n=0;n<16;n++)t[n]=r[n]-e[n]}function f(t,r,e){let n,o,i=0,a=0,u=0,s=0,c=0,f=0,h=0,l=0,p=0,y=0,d=0,v=0,w=0,g=0,b=0,m=0,E=0,_=0,L=0,K=0,A=0,x=0,M=0,U=0,S=0,B=0,N=0,k=0,T=0,H=0,P=0,O=e[0],I=e[1],G=e[2],F=e[3],j=e[4],R=e[5],J=e[6],C=e[7],D=e[8],X=e[9],Y=e[10],V=e[11],W=e[12],z=e[13],q=e[14],Z=e[15];n=r[0],i+=n*O,a+=n*I,u+=n*G,s+=n*F,c+=n*j,f+=n*R,h+=n*J,l+=n*C,p+=n*D,y+=n*X,d+=n*Y,v+=n*V,w+=n*W,g+=n*z,b+=n*q,m+=n*Z,n=r[1],a+=n*O,u+=n*I,s+=n*G,c+=n*F,f+=n*j,h+=n*R,l+=n*J,p+=n*C,y+=n*D,d+=n*X,v+=n*Y,w+=n*V,g+=n*W,b+=n*z,m+=n*q,E+=n*Z,n=r[2],u+=n*O,s+=n*I,c+=n*G,f+=n*F,h+=n*j,l+=n*R,p+=n*J,y+=n*C,d+=n*D,v+=n*X,w+=n*Y,g+=n*V,b+=n*W,m+=n*z,E+=n*q,_+=n*Z,n=r[3],s+=n*O,c+=n*I,f+=n*G,h+=n*F,l+=n*j,p+=n*R,y+=n*J,d+=n*C,v+=n*D,w+=n*X,g+=n*Y,b+=n*V,m+=n*W,E+=n*z,_+=n*q,L+=n*Z,n=r[4],c+=n*O,f+=n*I,h+=n*G,l+=n*F,p+=n*j,y+=n*R,d+=n*J,v+=n*C,w+=n*D,g+=n*X,b+=n*Y,m+=n*V,E+=n*W,_+=n*z,L+=n*q,K+=n*Z,n=r[5],f+=n*O,h+=n*I,l+=n*G,p+=n*F,y+=n*j,d+=n*R,v+=n*J,w+=n*C,g+=n*D,b+=n*X,m+=n*Y,E+=n*V,_+=n*W,L+=n*z,K+=n*q,A+=n*Z,n=r[6],h+=n*O,l+=n*I,p+=n*G,y+=n*F,d+=n*j,v+=n*R,w+=n*J,g+=n*C,b+=n*D,m+=n*X,E+=n*Y,_+=n*V,L+=n*W,K+=n*z,A+=n*q,x+=n*Z,n=r[7],l+=n*O,p+=n*I,y+=n*G,d+=n*F,v+=n*j,w+=n*R,g+=n*J,b+=n*C,m+=n*D,E+=n*X,_+=n*Y,L+=n*V,K+=n*W,A+=n*z,x+=n*q,M+=n*Z,n=r[8],p+=n*O,y+=n*I,d+=n*G,v+=n*F,w+=n*j,g+=n*R,b+=n*J,m+=n*C,E+=n*D,_+=n*X,L+=n*Y,K+=n*V,A+=n*W,x+=n*z,M+=n*q,U+=n*Z,n=r[9],y+=n*O,d+=n*I,v+=n*G,w+=n*F,g+=n*j,b+=n*R,m+=n*J,E+=n*C,_+=n*D,L+=n*X,K+=n*Y,A+=n*V,x+=n*W,M+=n*z,U+=n*q,S+=n*Z,n=r[10],d+=n*O,v+=n*I,w+=n*G,g+=n*F,b+=n*j,m+=n*R,E+=n*J,_+=n*C,L+=n*D,K+=n*X,A+=n*Y,x+=n*V,M+=n*W,U+=n*z,S+=n*q,B+=n*Z,n=r[11],v+=n*O,w+=n*I,g+=n*G,b+=n*F,m+=n*j,E+=n*R,_+=n*J,L+=n*C,K+=n*D,A+=n*X,x+=n*Y,M+=n*V,U+=n*W,S+=n*z,B+=n*q,N+=n*Z,n=r[12],w+=n*O,g+=n*I,b+=n*G,m+=n*F,E+=n*j,_+=n*R,L+=n*J,K+=n*C,A+=n*D,x+=n*X,M+=n*Y,U+=n*V,S+=n*W,B+=n*z,N+=n*q,k+=n*Z,n=r[13],g+=n*O,b+=n*I,m+=n*G,E+=n*F,_+=n*j,L+=n*R,K+=n*J,A+=n*C,x+=n*D,M+=n*X,U+=n*Y,S+=n*V,B+=n*W,N+=n*z,k+=n*q,T+=n*Z,n=r[14],b+=n*O,m+=n*I,E+=n*G,_+=n*F,L+=n*j,K+=n*R,A+=n*J,x+=n*C,M+=n*D,U+=n*X,S+=n*Y,B+=n*V,N+=n*W,k+=n*z,T+=n*q,H+=n*Z,n=r[15],m+=n*O,E+=n*I,_+=n*G,L+=n*F,K+=n*j,A+=n*R,x+=n*J,M+=n*C,U+=n*D,S+=n*X,B+=n*Y,N+=n*V,k+=n*W,T+=n*z,H+=n*q,P+=n*Z,i+=38*E,a+=38*_,u+=38*L,s+=38*K,c+=38*A,f+=38*x,h+=38*M,l+=38*U,p+=38*S,y+=38*B,d+=38*N,v+=38*k,w+=38*T,g+=38*H,b+=38*P,o=1,n=i+o+65535,o=Math.floor(n/65536),i=n-65536*o,n=a+o+65535,o=Math.floor(n/65536),a=n-65536*o,n=u+o+65535,o=Math.floor(n/65536),u=n-65536*o,n=s+o+65535,o=Math.floor(n/65536),s=n-65536*o,n=c+o+65535,o=Math.floor(n/65536),c=n-65536*o,n=f+o+65535,o=Math.floor(n/65536),f=n-65536*o,n=h+o+65535,o=Math.floor(n/65536),h=n-65536*o,n=l+o+65535,o=Math.floor(n/65536),l=n-65536*o,n=p+o+65535,o=Math.floor(n/65536),p=n-65536*o,n=y+o+65535,o=Math.floor(n/65536),y=n-65536*o,n=d+o+65535,o=Math.floor(n/65536),d=n-65536*o,n=v+o+65535,o=Math.floor(n/65536),v=n-65536*o,n=w+o+65535,o=Math.floor(n/65536),w=n-65536*o,n=g+o+65535,o=Math.floor(n/65536),g=n-65536*o,n=b+o+65535,o=Math.floor(n/65536),b=n-65536*o,n=m+o+65535,o=Math.floor(n/65536),m=n-65536*o,i+=o-1+37*(o-1),o=1,n=i+o+65535,o=Math.floor(n/65536),i=n-65536*o,n=a+o+65535,o=Math.floor(n/65536),a=n-65536*o,n=u+o+65535,o=Math.floor(n/65536),u=n-65536*o,n=s+o+65535,o=Math.floor(n/65536),s=n-65536*o,n=c+o+65535,o=Math.floor(n/65536),c=n-65536*o,n=f+o+65535,o=Math.floor(n/65536),f=n-65536*o,n=h+o+65535,o=Math.floor(n/65536),h=n-65536*o,n=l+o+65535,o=Math.floor(n/65536),l=n-65536*o,n=p+o+65535,o=Math.floor(n/65536),p=n-65536*o,n=y+o+65535,o=Math.floor(n/65536),y=n-65536*o,n=d+o+65535,o=Math.floor(n/65536),d=n-65536*o,n=v+o+65535,o=Math.floor(n/65536),v=n-65536*o,n=w+o+65535,o=Math.floor(n/65536),w=n-65536*o,n=g+o+65535,o=Math.floor(n/65536),g=n-65536*o,n=b+o+65535,o=Math.floor(n/65536),b=n-65536*o,n=m+o+65535,o=Math.floor(n/65536),m=n-65536*o,i+=o-1+37*(o-1),t[0]=i,t[1]=a,t[2]=u,t[3]=s,t[4]=c,t[5]=f,t[6]=h,t[7]=l,t[8]=p,t[9]=y,t[10]=d,t[11]=v,t[12]=w,t[13]=g,t[14]=b,t[15]=m}function h(t,r){f(t,r,r)}function l(t,r){const e=new Uint8Array(32),o=new Float64Array(80),l=n(),p=n(),y=n(),d=n(),v=n(),w=n();for(let r=0;r<31;r++)e[r]=t[r];e[31]=127&t[31]|64,e[0]&=248,function(t,r){for(let e=0;e<16;e++)t[e]=r[2*e]+(r[2*e+1]<<8);t[15]&=32767}(o,r);for(let t=0;t<16;t++)p[t]=o[t];l[0]=d[0]=1;for(let t=254;t>=0;--t){const r=e[t>>>3]>>>(7&t)&1;u(l,p,r),u(y,d,r),s(v,l,y),c(l,l,y),s(y,p,d),c(p,p,d),h(d,v),h(w,l),f(l,y,l),f(y,p,v),s(v,l,y),c(l,l,y),h(p,l),c(y,d,w),f(l,y,i),s(l,l,d),f(y,y,l),f(l,d,w),f(d,p,o),h(p,v),u(l,p,r),u(y,d,r)}for(let t=0;t<16;t++)o[t+16]=l[t],o[t+32]=y[t],o[t+48]=p[t],o[t+64]=d[t];const g=o.subarray(32),b=o.subarray(16);!function(t,r){const e=n();for(let t=0;t<16;t++)e[t]=r[t];for(let t=253;t>=0;t--)h(e,e),2!==t&&4!==t&&f(e,e,r);for(let r=0;r<16;r++)t[r]=e[r]}(g,g),f(b,b,g);const m=new Uint8Array(32);return function(t,r){const e=n(),o=n();for(let t=0;t<16;t++)o[t]=r[t];a(o),a(o),a(o);for(let t=0;t<2;t++){e[0]=o[0]-65517;for(let t=1;t<15;t++)e[t]=o[t]-65535-(e[t-1]>>16&1),e[t-1]&=65535;e[15]=o[15]-32767-(e[14]>>16&1);const t=e[15]>>16&1;e[14]&=65535,u(o,e,1-t)}for(let r=0;r<16;r++)t[2*r]=255&o[r],t[2*r+1]=o[r]>>8}(m,b),m}function p(t){return l(t,o)}function d(r){if(r.length!==t.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${t.SECRET_KEY_LENGTH} bytes`);const e=new Uint8Array(r);return{publicKey:p(e),secretKey:e}}t.scalarMult=l,t.scalarMultBase=p,t.generateKeyPairFromSeed=d,t.generateKeyPair=function(t){const n=(0,r.randomBytes)(32,t),o=d(n);return(0,e.wipe)(n),o},t.sharedKey=function(r,e,n=!1){if(r.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const o=l(r,e);if(n){let t=0;for(let r=0;r<o.length;r++)t|=o[r];if(0===t)throw new Error("X25519: invalid shared key")}return o}}(j)),j),C={exports:{}},D={};var X,Y,V={};var W=(Y||(Y=1,"production"===r.env.NODE_ENV?C.exports=(R||(R=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.staticImplements=function(){return function(t){}}}(D)),D):C.exports=(X||(X=1,Object.defineProperty(V,"__esModule",{value:!0}),V.staticImplements=function(){return function(t){}}),V)),C.exports);function z(t,r,e,n,o,i,a){try{var u=t[i](a),s=u.value}catch(t){return void e(t)}u.done?r(s):Promise.resolve(s).then(n,o)}function q(t){return function(){var r=this,e=arguments;return new Promise(function(n,o){var i=t.apply(r,e);function a(t){z(i,n,o,a,u,"next",t)}function u(t){z(i,n,o,a,u,"throw",t)}a(void 0)})}}function Z(){return Z=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},Z.apply(this,arguments)}var $,Q,tt=($=function(t){var r=function(t){var r,e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{s({},"")}catch(t){s=function(t,r,e){return t[r]=e}}function c(t,r,e,n){var o=r&&r.prototype instanceof v?r:v,i=Object.create(o.prototype),a=new U(n||[]);return i._invoke=function(t,r,e){var n=h;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===y){if("throw"===o)throw i;return B()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var u=A(a,e);if(u){if(u===d)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if(n===h)throw n=y,e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n=p;var s=f(t,r,e);if("normal"===s.type){if(n=e.done?y:l,s.arg===d)continue;return{value:s.arg,done:e.done}}"throw"===s.type&&(n=y,e.method="throw",e.arg=s.arg)}}}(t,e,a),i}function f(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h="suspendedStart",l="suspendedYield",p="executing",y="completed",d={};function v(){}function w(){}function g(){}var b={};b[i]=function(){return this};var m=Object.getPrototypeOf,E=m&&m(m(S([])));E&&E!==e&&n.call(E,i)&&(b=E);var _=g.prototype=v.prototype=Object.create(b);function L(t){["next","throw","return"].forEach(function(r){s(t,r,function(t){return this._invoke(r,t)})})}function K(t,r){function e(o,i,a,u){var s=f(t[o],t,i);if("throw"!==s.type){var c=s.arg,h=c.value;return h&&"object"==typeof h&&n.call(h,"__await")?r.resolve(h.__await).then(function(t){e("next",t,a,u)},function(t){e("throw",t,a,u)}):r.resolve(h).then(function(t){c.value=t,a(c)},function(t){return e("throw",t,a,u)})}u(s.arg)}var o;this._invoke=function(t,n){function i(){return new r(function(r,o){e(t,n,r,o)})}return o=o?o.then(i,i):i()}}function A(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,A(t,e),"throw"===e.method))return d;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function x(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function M(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function U(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function S(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function e(){for(;++o<t.length;)if(n.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=r,e.done=!0,e};return a.next=a}}return{next:B}}function B(){return{value:r,done:!0}}return w.prototype=_.constructor=g,g.constructor=w,w.displayName=s(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},L(K.prototype),K.prototype[a]=function(){return this},t.AsyncIterator=K,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new K(c(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next()})},L(_),s(_,u,"Generator"),_[i]=function(){return this},_.toString=function(){return"[object Generator]"},t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=S,U.prototype={constructor:U,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(M),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function o(n,o){return u.type="throw",u.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),d},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),M(e),d}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;M(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),d}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}},$(Q={exports:{}},Q.exports),Q.exports);function rt(t){if(t.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<t.length;o++){var i=t.charAt(o),a=i.charCodeAt(0);if(255!==r[a])throw new TypeError(i+" is ambiguous");r[a]=o}var u=t.length,s=t.charAt(0),c=Math.log(u)/Math.log(256),f=Math.log(256)/Math.log(u);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return e.alloc(0);var n=0;if(" "!==t[n]){for(var o=0,i=0;t[n]===s;)o++,n++;for(var a=(t.length-n)*c+1>>>0,f=new Uint8Array(a);t[n];){var h=r[t.charCodeAt(n)];if(255===h)return;for(var l=0,p=a-1;(0!==h||l<i)&&-1!==p;p--,l++)h+=u*f[p]>>>0,f[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,n++}if(" "!==t[n]){for(var y=a-i;y!==a&&0===f[y];)y++;var d=e.allocUnsafe(o+(a-y));d.fill(0,0,o);for(var v=o;y!==a;)d[v++]=f[y++];return d}}}return{encode:function(r){if((Array.isArray(r)||r instanceof Uint8Array)&&(r=e.from(r)),!e.isBuffer(r))throw new TypeError("Expected Buffer");if(0===r.length)return"";for(var n=0,o=0,i=0,a=r.length;i!==a&&0===r[i];)i++,n++;for(var c=(a-i)*f+1>>>0,h=new Uint8Array(c);i!==a;){for(var l=r[i],p=0,y=c-1;(0!==l||p<o)&&-1!==y;y--,p++)l+=256*h[y]>>>0,h[y]=l%u>>>0,l=l/u>>>0;if(0!==l)throw new Error("Non-zero carry");o=p,i++}for(var d=c-o;d!==c&&0===h[d];)d++;for(var v=s.repeat(n);d<c;++d)v+=t.charAt(h[d]);return v},decodeUnsafe:h,decode:function(t){var r=h(t);if(r)return r;throw new Error("Non-base"+u+" character")}}}var et,nt=rt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),ot=function(t){return e.from(t||"").toString("base64")},it=function(t){return ot(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},at=function(t,r){void 0===r&&(r="base58btc");var e=new Uint8Array(2+t.length);if(e[0]=236,e[1]=1,e.set(t,2),"base58btc"===r)return"z"+nt.encode(e);if("base64url"===r)return"u"+it(e);throw new Error("Unsupported encoding: "+r)},ut=function(t){return Uint8Array.from(e.from(t.x,"base64"))},st={JsonWebKey2020:function(t){var r,n=ut(t.publicKeyJwk),o=void 0;t.privateKeyJwk&&(o=(r=t.privateKeyJwk,{publicKey:ut(r),privateKey:Uint8Array.from(e.from(r.d,"base64"))}).privateKey);return{publicKey:n,privateKey:o}},X25519KeyAgreementKey2019:function(t){var r=nt.decode(t.publicKeyBase58),e=void 0;return t.privateKeyBase58&&(e=Uint8Array.from(nt.decode(t.privateKeyBase58))),{publicKey:r,privateKey:e}}},ct={JsonWebKey2020:function(t,r,e,n){var o={kty:"OKP",crv:"X25519",x:it(e)},i={id:t,type:"JsonWebKey2020",controller:r,publicKeyJwk:o};return n&&(i.privateKeyJwk=Z({},o,{d:it(n)})),i},X25519KeyAgreementKey2019:function(t,r,e,n){var o={id:t,type:"X25519KeyAgreementKey2019",controller:r,publicKeyBase58:nt.encode(e)};return n&&(o.privateKeyBase58=nt.encode(n)),o}},ft=et=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=q(tt.mark(function t(r){var e,n;return tt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,et.from(r);case 2:return e=t.sent,n=e.publicKey,t.abrupt("return",at(n));case 5:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=q(tt.mark(function t(r){var e,n,o,i;return tt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e=r.fingerprint,236!==(n=nt.decode(e.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,et.from({id:"",controller:"",type:"X25519KeyAgreementKey2019",publicKeyBase58:nt.encode(n.slice(2))});case 5:return o=t.sent,t.next=8,o.fingerprint();case 8:return i=t.sent,o.id="did:key:"+i+"#"+i,o.controller="did:key:"+i,t.abrupt("return",o);case 12:throw new Error("Unsupported fingerprint type: "+e);case 13:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}();var r=t.prototype;return r.fingerprint=function(){var t=q(tt.mark(function t(){return tt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",at(this.publicKey));case 1:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),r.export=function(){var t=q(tt.mark(function t(r){return tt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r={privateKey:!1,type:"JsonWebKey2020"}),!ct[r.type]){t.next=3;break}return t.abrupt("return",ct[r.type](this.id,this.controller,this.publicKey,r.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(r));case 4:case"end":return t.stop()}},t,this)}));return function(r){return t.apply(this,arguments)}}(),r.deriveSecret=function(){var t=q(tt.mark(function t(r){var e,n,o;return tt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.publicKey,t.next=3,et.from(e);case 3:if(n=t.sent,this.privateKey){t.next=6;break}throw new Error("No private key available for deriveSecret");case 6:return o=J.sharedKey(this.privateKey,n.publicKey,!0),t.abrupt("return",o);case 8:case"end":return t.stop()}},t,this)}));return function(r){return t.apply(this,arguments)}}(),t}();function ht(t,r,e,n,o,i,a){try{var u=t[i](a),s=u.value}catch(t){return void e(t)}u.done?r(s):Promise.resolve(s).then(n,o)}function lt(t){return function(){var r=this,e=arguments;return new Promise(function(n,o){var i=t.apply(r,e);function a(t){ht(i,n,o,a,u,"next",t)}function u(t){ht(i,n,o,a,u,"throw",t)}a(void 0)})}}function pt(){return pt=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},pt.apply(this,arguments)}ft.generate=function(){var t=q(tt.mark(function t(r){var e,n,o,i,a;return tt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.secureRandom,n=J.generateKeyPair({isAvailable:!0,randomBytes:e}),o=at(n.publicKey),a=(i="did:key:"+o)+"#"+o,t.abrupt("return",new et({id:a,type:"JsonWebKey2020",controller:i,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}(),ft.from=function(){var t=q(tt.mark(function t(r){var e,n,o;return tt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=st[r.type](r),n=e.publicKey,o=e.privateKey,t.abrupt("return",new et({id:r.id,type:r.type,controller:r.controller,publicKey:n,privateKey:o}));case 2:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}(),ft=et=n([W.staticImplements()],ft);var yt=function(t,r){return t(r={exports:{}},r.exports),r.exports}(function(t){var r=function(t){var r,e=Object.prototype,n=e.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function s(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{s({},"")}catch(t){s=function(t,r,e){return t[r]=e}}function c(t,r,e,n){var o=r&&r.prototype instanceof v?r:v,i=Object.create(o.prototype),a=new U(n||[]);return i._invoke=function(t,r,e){var n=h;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===y){if("throw"===o)throw i;return B()}for(e.method=o,e.arg=i;;){var a=e.delegate;if(a){var u=A(a,e);if(u){if(u===d)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if(n===h)throw n=y,e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n=p;var s=f(t,r,e);if("normal"===s.type){if(n=e.done?y:l,s.arg===d)continue;return{value:s.arg,done:e.done}}"throw"===s.type&&(n=y,e.method="throw",e.arg=s.arg)}}}(t,e,a),i}function f(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h="suspendedStart",l="suspendedYield",p="executing",y="completed",d={};function v(){}function w(){}function g(){}var b={};b[i]=function(){return this};var m=Object.getPrototypeOf,E=m&&m(m(S([])));E&&E!==e&&n.call(E,i)&&(b=E);var _=g.prototype=v.prototype=Object.create(b);function L(t){["next","throw","return"].forEach(function(r){s(t,r,function(t){return this._invoke(r,t)})})}function K(t,r){function e(o,i,a,u){var s=f(t[o],t,i);if("throw"!==s.type){var c=s.arg,h=c.value;return h&&"object"==typeof h&&n.call(h,"__await")?r.resolve(h.__await).then(function(t){e("next",t,a,u)},function(t){e("throw",t,a,u)}):r.resolve(h).then(function(t){c.value=t,a(c)},function(t){return e("throw",t,a,u)})}u(s.arg)}var o;this._invoke=function(t,n){function i(){return new r(function(r,o){e(t,n,r,o)})}return o=o?o.then(i,i):i()}}function A(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,A(t,e),"throw"===e.method))return d;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var o=f(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,d;var i=o.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function x(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function M(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function U(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function S(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function e(){for(;++o<t.length;)if(n.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=r,e.done=!0,e};return a.next=a}}return{next:B}}function B(){return{value:r,done:!0}}return w.prototype=_.constructor=g,g.constructor=w,w.displayName=s(g,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===w||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},L(K.prototype),K.prototype[a]=function(){return this},t.AsyncIterator=K,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new K(c(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then(function(t){return t.done?t.value:a.next()})},L(_),s(_,u,"Generator"),_[i]=function(){return this},_.toString=function(){return"[object Generator]"},t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=S,U.prototype={constructor:U,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(M),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function o(n,o){return u.type="throw",u.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],u=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,d):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),d},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),M(e),d}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;M(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),d}},t}(t.exports);try{regeneratorRuntime=r}catch(t){Function("r","regeneratorRuntime = r")(r)}});function dt(t){if(t.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<t.length;o++){var i=t.charAt(o),a=i.charCodeAt(0);if(255!==r[a])throw new TypeError(i+" is ambiguous");r[a]=o}var u=t.length,s=t.charAt(0),c=Math.log(u)/Math.log(256),f=Math.log(256)/Math.log(u);function h(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return e.alloc(0);var n=0;if(" "!==t[n]){for(var o=0,i=0;t[n]===s;)o++,n++;for(var a=(t.length-n)*c+1>>>0,f=new Uint8Array(a);t[n];){var h=r[t.charCodeAt(n)];if(255===h)return;for(var l=0,p=a-1;(0!==h||l<i)&&-1!==p;p--,l++)h+=u*f[p]>>>0,f[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,n++}if(" "!==t[n]){for(var y=a-i;y!==a&&0===f[y];)y++;var d=e.allocUnsafe(o+(a-y));d.fill(0,0,o);for(var v=o;y!==a;)d[v++]=f[y++];return d}}}return{encode:function(r){if((Array.isArray(r)||r instanceof Uint8Array)&&(r=e.from(r)),!e.isBuffer(r))throw new TypeError("Expected Buffer");if(0===r.length)return"";for(var n=0,o=0,i=0,a=r.length;i!==a&&0===r[i];)i++,n++;for(var c=(a-i)*f+1>>>0,h=new Uint8Array(c);i!==a;){for(var l=r[i],p=0,y=c-1;(0!==l||p<o)&&-1!==y;y--,p++)l+=256*h[y]>>>0,h[y]=l%u>>>0,l=l/u>>>0;if(0!==l)throw new Error("Non-zero carry");o=p,i++}for(var d=c-o;d!==c&&0===h[d];)d++;for(var v=s.repeat(n);d<c;++d)v+=t.charAt(h[d]);return v},decodeUnsafe:h,decode:function(t){var r=h(t);if(r)return r;throw new Error("Non-base"+u+" character")}}}var vt,wt=dt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),gt=function(t){return e.from(t||"").toString("base64")},bt=function(t){return gt(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},mt=function(t,r){void 0===r&&(r="base58btc");var e=new Uint8Array(2+t.length);if(e[0]=237,e[1]=1,e.set(t,2),"base58btc"===r)return"z"+wt.encode(e);if("base64url"===r)return"u"+bt(e);throw new Error("Unsupported encoding: "+r)},Et=function(t){return Uint8Array.from(e.from(t.x,"base64"))},_t={JsonWebKey2020:function(t){var r,n=Et(t.publicKeyJwk),o=void 0;t.privateKeyJwk&&(o=(r=t.privateKeyJwk,{publicKey:Et(r),privateKey:Uint8Array.from(e.concat([e.from(r.d,"base64"),e.from(r.x,"base64")]))}).privateKey);return{publicKey:n,privateKey:o}},Ed25519VerificationKey2018:function(t){var r=wt.decode(t.publicKeyBase58),e=void 0;return t.privateKeyBase58&&(e=Uint8Array.from(wt.decode(t.privateKeyBase58))),{publicKey:r,privateKey:e}}},Lt=function(t){if(!_t[t.type])throw new Error("Cannot import from unsupported type: "+JSON.stringify(t,null,2));return _t[t.type](t)},Kt={JsonWebKey2020:function(t,r,e,n){var o={kty:"OKP",crv:"Ed25519",x:bt(e)},i={id:t,type:"JsonWebKey2020",controller:r,publicKeyJwk:o};return n&&(i.privateKeyJwk=pt({},o,{d:bt(n.slice(0,n.length/2))})),i},Ed25519VerificationKey2018:function(t,r,e,n){var o={id:t,type:"Ed25519VerificationKey2018",controller:r,publicKeyBase58:wt.encode(e)};return n&&(o.privateKeyBase58=wt.encode(n)),o}},At={EdDsa:{__proto__:null,signer:function(t){return{sign:function(r){return lt(yt.mark(function e(){var n;return yt.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.data,e.abrupt("return",N.sign(t,n));case 2:case"end":return e.stop()}},e)}))()}}},verifier:function(t){return{verify:function(r){return lt(yt.mark(function e(){var n,o,i;return yt.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:n=r.data,o=r.signature,i=!1;try{i=N.verify(t,n,o)}catch(t){}return e.abrupt("return",i);case 4:case"end":return e.stop()}},e)}))()}}}}},xt=vt=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=lt(yt.mark(function t(r){var e,n;return yt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,vt.from(r);case 2:return e=t.sent,n=e.publicKey,t.abrupt("return",mt(n));case 5:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}(),t.toX25519KeyPair=function(){var t=lt(yt.mark(function t(r){var e,n,o;return yt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=N.convertPublicKeyToX25519(r.publicKey),n=void 0,r.privateKey&&(n=N.convertSecretKeyToX25519(r.privateKey)),o=new ft({id:"",type:"X25519KeyAgreementKey2019",controller:r.controller,publicKey:e,privateKey:n}),t.t0=r.controller+"#",t.next=7,o.fingerprint();case 7:return t.t1=t.sent,o.id=t.t0+t.t1,t.abrupt("return",o);case 10:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=lt(yt.mark(function t(r){var e,n,o,i;return yt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(e=r.fingerprint,237!==(n=wt.decode(e.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,vt.from({id:"",controller:"",type:"Ed25519VerificationKey2018",publicKeyBase58:wt.encode(n.slice(2))});case 5:return o=t.sent,t.next=8,o.fingerprint();case 8:return i=t.sent,o.id="did:key:"+i+"#"+i,o.controller="did:key:"+i,t.abrupt("return",o);case 12:throw new Error("Unsupported fingerprint type: "+e);case 13:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}();var r=t.prototype;return r.fingerprint=function(){var t=lt(yt.mark(function t(){return yt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",mt(this.publicKey));case 1:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),r.export=function(){var t=lt(yt.mark(function t(r){return yt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===r&&(r={privateKey:!1,type:"JsonWebKey2020"}),!Kt[r.type]){t.next=3;break}return t.abrupt("return",Kt[r.type](this.id,this.controller,this.publicKey,r.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(r));case 4:case"end":return t.stop()}},t,this)}));return function(r){return t.apply(this,arguments)}}(),r.signer=function(t){if(void 0===t&&(t="EdDsa"),!this.privateKey)throw new Error("No private key to sign with.");if(At[t])return At[t].signer(this.privateKey);throw new Error("Unsupported suite type "+t)},r.verifier=function(t){if(void 0===t&&(t="EdDsa"),!this.publicKey)throw new Error("No public key to verify with.");if(At[t])return At[t].verifier(this.publicKey);throw new Error("Unsupported suite type "+t)},r.getDerivedKeyPairs=function(){var t=lt(yt.mark(function t(){return yt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,vt.toX25519KeyPair(this);case 3:return t.t1=t.sent,t.abrupt("return",[t.t0,t.t1]);case 5:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),t}();xt.generate=function(){var t=lt(yt.mark(function t(r){var e,n,o,i,a;return yt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=r.secureRandom,n=N.generateKeyPair({isAvailable:!0,randomBytes:e}),o=mt(n.publicKey),a=(i="did:key:"+o)+"#"+o,t.abrupt("return",new vt({id:a,type:"JsonWebKey2020",controller:i,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}(),xt.from=function(){var t=lt(yt.mark(function t(r){var e,n,o;return yt.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=Lt(r),n=e.publicKey,o=e.privateKey,t.abrupt("return",new vt({id:r.id,type:r.type,controller:r.controller,publicKey:n,privateKey:o}));case 2:case"end":return t.stop()}},t)}));return function(r){return t.apply(this,arguments)}}(),xt=vt=n([F.staticImplements()],xt);export{xt as E};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e,r,t,o){var c,f=arguments.length,n=f<3?r:null===o?o=Object.getOwnPropertyDescriptor(r,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,r,t,o);else for(var p=e.length-1;p>=0;p--)(c=e[p])&&(n=(f<3?c(n):f>3?c(r,t,n):c(r,t))||n);return f>3&&n&&Object.defineProperty(r,t,n),n}"function"==typeof SuppressedError&&SuppressedError;export{e as _};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as r,I as t}from"./main.js";async function e(e){if(!e.proof)return void console.warn("No proof found in the issuer profile.");let o=e.proof.type;"DataIntegrityProof"===o&&(o=r(e.proof.cryptosuite));const i=await async function(r){if(r===t.MerkleProof2019){const{default:r}=await import("./MerkleProof2019-B7f1hhem-CjLDyx6Q.js");return r}if(r===t.Ed25519Signature2020){const{default:r}=await import("./Ed25519Signature2020-fJGvlbIp-B6XhFwr4.js");return r}if(r===t.EcdsaSecp256k1Signature2019){const{default:r}=await import("./EcdsaSecp256k1Signature2019-D90cAynb-Bf5kILPF.js");return r}if(r===t.EcdsaSd2023){const{default:r}=await import("./EcdsaSd2023-CUjrjGzC-Cx7ejHu-.js");return r}}(o),a=new i({document:e,proof:e.proof,issuer:e.issuer?e.issuer:e,executeStep:async(r,t,e)=>t()});await a.init();try{await a.verifyProof()}catch(r){throw new Error(`Issuer profile verification failed: ${r.message}`)}}export{e as default};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import{B as e,J as t}from"./main.js";import{_ as r}from"./tslib.es6--gQC4x5c-CmLYFWVC.js";import{c as n}from"./_polyfill-node.crypto-DGISCHrB-C5-OOGc0.js";var s,i={};var o=function(){if(s)return i;s=1;class t{static isArrayBuffer(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,r){const n=t.toUint8Array(e),s=t.toUint8Array(r);if(n.length!==s.byteLength)return!1;for(let e=0;e<n.length;e++)if(n[e]!==s[e])return!1;return!0}static concat(...e){let t;t=!Array.isArray(e[0])||e[1]instanceof Function?Array.isArray(e[0])&&e[1]instanceof Function?e[0]:e[e.length-1]instanceof Function?e.slice(0,e.length-1):e:e[0];let r=0;for(const e of t)r+=e.byteLength;const n=new Uint8Array(r);let s=0;for(const e of t){const t=this.toUint8Array(e);n.set(t,s),s+=t.length}return e[e.length-1]instanceof Function?this.toView(n,e[e.length-1]):n.buffer}}const r="string",n=/^[0-9a-f\s]+$/i,o=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,a=/^[a-zA-Z0-9-_]+$/;class c{static fromString(e){const t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r.buffer}static toString(e){const r=t.toUint8Array(e);let n="";for(let e=0;e<r.length;e++)n+=String.fromCharCode(r[e]);return decodeURIComponent(escape(n))}}class u{static toString(e,r=!1){const n=t.toArrayBuffer(e),s=new DataView(n);let i="";for(let e=0;e<n.byteLength;e+=2){const t=s.getUint16(e,r);i+=String.fromCharCode(t)}return i}static fromString(e,t=!1){const r=new ArrayBuffer(2*e.length),n=new DataView(r);for(let r=0;r<e.length;r++)n.setUint16(2*r,e.charCodeAt(r),t);return r}}class l{static isHex(e){return typeof e===r&&n.test(e)}static isBase64(e){return typeof e===r&&o.test(e)}static isBase64Url(e){return typeof e===r&&a.test(e)}static ToString(e,r="utf8"){const n=t.toUint8Array(e);switch(r.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return u.toString(n,!0);case"utf16":case"utf16be":return u.toString(n);default:throw new Error(`Unknown type of encoding '${r}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return u.fromString(e,!0);case"utf16":case"utf16be":return u.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(r){const n=t.toUint8Array(r);if("undefined"!=typeof btoa){const e=this.ToString(n,"binary");return btoa(e)}return e.from(n).toString("base64")}static FromBase64(t){const r=this.formatString(t);if(!r)return new ArrayBuffer(0);if(!l.isBase64(r))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return"undefined"!=typeof atob?this.FromBinary(atob(r)):new Uint8Array(e.from(r,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!l.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=l.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return c.fromString(e);case"utf16":case"utf16be":return u.fromString(e);case"utf16le":case"usc2":return u.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=l.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return c.toString(e);case"utf16":case"utf16be":return u.toString(e);case"utf16le":case"usc2":return u.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,r=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);return r.buffer}static ToBinary(e){const r=t.toUint8Array(e);let n="";for(let e=0;e<r.length;e++)n+=String.fromCharCode(r[e]);return n}static ToHex(e){const r=t.toUint8Array(e);let n="";const s=r.length;for(let e=0;e<s;e++){const t=r[e];t<16&&(n+="0"),n+=t.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!l.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const r=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2){const n=t.slice(e,e+2);r[e/2]=parseInt(n,16)}return r.buffer}static ToUtf16String(e,t=!1){return u.toString(e,t)}static FromUtf16String(e,t=!1){return u.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let r=0;r<t;r++)e+="=";return e}static formatString(e){return(null==e?void 0:e.replace(/[\n\r\t ]/g,""))||""}}return l.DEFAULT_UTF8_ENCODING="utf8",i.BufferSourceConverter=t,i.Convert=l,i.assign=function(e,...t){const r=arguments[0];for(let e=1;e<arguments.length;e++){const t=arguments[e];for(const e in t)r[e]=t[e]}return r},i.combine=function(...e){const t=e.map(e=>e.byteLength).reduce((e,t)=>e+t),r=new Uint8Array(t);let n=0;return e.map(e=>new Uint8Array(e)).forEach(e=>{for(const t of e)r[n++]=t}),r.buffer},i.isEqual=function(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),n=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==n[t])return!1;return!0},i}();
|
|
2
|
-
/*!
|
|
3
|
-
Copyright (c) Peculiar Ventures, LLC
|
|
4
|
-
*/function a(e,t){let r=0;if(1===e.length)return e[0];for(let n=e.length-1;n>=0;n--)r+=e[e.length-1-n]*Math.pow(2,t*n);return r}function c(e,t,r=-1){const n=r;let s=e,i=0,o=Math.pow(2,t);for(let r=1;r<8;r++){if(e<o){let e;if(n<0)e=new ArrayBuffer(r),i=r;else{if(n<r)return new ArrayBuffer(0);e=new ArrayBuffer(n),i=n}const o=new Uint8Array(e);for(let e=r-1;e>=0;e--){const r=Math.pow(2,e*t);o[i-e-1]=Math.floor(s/r),s-=o[i-e-1]*r}return e}o*=Math.pow(2,t)}return new ArrayBuffer(0)}function u(...e){let t=0,r=0;for(const r of e)t+=r.length;const n=new ArrayBuffer(t),s=new Uint8Array(n);for(const t of e)s.set(t,r),r+=t.length;return s}function l(){const e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const t=255===e[0]&&128&e[1],r=0===e[0]&&!(128&e[1]);(t||r)&&this.warnings.push("Needlessly long format")}const t=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(t);for(let e=0;e<this.valueHex.byteLength;e++)r[e]=0;r[0]=128&e[0];const n=a(r,8),s=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(s);for(let t=0;t<this.valueHex.byteLength;t++)i[t]=e[t];i[0]&=127;return a(i,8)-n}function h(e,t){const r=e.toString(10);if(t<r.length)return"";const n=t-r.length,s=new Array(n);for(let e=0;e<n;e++)s[e]="0";return s.join("").concat(r)}
|
|
5
|
-
/*!
|
|
6
|
-
* Copyright (c) 2014, GMO GlobalSign
|
|
7
|
-
* Copyright (c) 2015-2022, Peculiar Ventures
|
|
8
|
-
* All rights reserved.
|
|
9
|
-
*
|
|
10
|
-
* Author 2014-2019, Yury Strozhevsky
|
|
11
|
-
*
|
|
12
|
-
* Redistribution and use in source and binary forms, with or without modification,
|
|
13
|
-
* are permitted provided that the following conditions are met:
|
|
14
|
-
*
|
|
15
|
-
* * Redistributions of source code must retain the above copyright notice, this
|
|
16
|
-
* list of conditions and the following disclaimer.
|
|
17
|
-
*
|
|
18
|
-
* * Redistributions in binary form must reproduce the above copyright notice, this
|
|
19
|
-
* list of conditions and the following disclaimer in the documentation and/or
|
|
20
|
-
* other materials provided with the distribution.
|
|
21
|
-
*
|
|
22
|
-
* * Neither the name of the copyright holder nor the names of its
|
|
23
|
-
* contributors may be used to endorse or promote products derived from
|
|
24
|
-
* this software without specific prior written permission.
|
|
25
|
-
*
|
|
26
|
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
27
|
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
28
|
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
29
|
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
30
|
-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
31
|
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
32
|
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
33
|
-
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
34
|
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
35
|
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
36
|
-
*
|
|
37
|
-
*/function y(){if("undefined"==typeof BigInt)throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function f(e){let t=0,r=0;for(let r=0;r<e.length;r++){t+=e[r].byteLength}const n=new Uint8Array(t);for(let t=0;t<e.length;t++){const s=e[t];n.set(new Uint8Array(s),r),r+=s.byteLength}return n.buffer}function p(e,t,r,n){return t instanceof Uint8Array?t.byteLength?r<0?(e.error="Wrong parameter: inputOffset less than zero",!1):n<0?(e.error="Wrong parameter: inputLength less than zero",!1):!(t.byteLength-r-n<0)||(e.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):(e.error="Wrong parameter: inputBuffer has zero length",!1):(e.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class g{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return f(this.items)}}const m=[new Uint8Array([1])],d="0123456789",w="name",v="valueHexView",A="",b=new ArrayBuffer(0),k=new Uint8Array(0),S="EndOfContent",B="OCTET STRING",E="BIT STRING";function K(e){var t;return(t=class extends e{get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}constructor(...e){var t;super(...e);const r=e[0]||{};this.isHexOnly=null!==(t=r.isHexOnly)&&void 0!==t&&t,this.valueHexView=r.valueHex?o.BufferSourceConverter.toUint8Array(r.valueHex):k}fromBER(e,t,r){const n=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!p(this,n,t,r))return-1;const s=t+r;return this.valueHexView=n.subarray(t,s),this.valueHexView.length?(this.blockLength=r,s):(this.warnings.push("Zero buffer length"),t)}toBER(e=!1){return this.isHexOnly?e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",b)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:o.Convert.ToHex(this.valueHexView)}}}).NAME="hexBlock",t}class C{static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}constructor({blockLength:e=0,error:t="",warnings:r=[],valueBeforeDecode:n=k}={}){this.blockLength=e,this.error=t,this.warnings=r,this.valueBeforeDecodeView=o.BufferSourceConverter.toUint8Array(n)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:o.Convert.ToHex(this.valueBeforeDecodeView)}}}C.NAME="baseBlock";class x extends C{fromBER(e,t,r){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}x.NAME="valueBlock";class N extends(K(C)){constructor({idBlock:e={}}={}){var t,r,n,s;super(),e?(this.isHexOnly=null!==(t=e.isHexOnly)&&void 0!==t&&t,this.valueHexView=e.valueHex?o.BufferSourceConverter.toUint8Array(e.valueHex):k,this.tagClass=null!==(r=e.tagClass)&&void 0!==r?r:-1,this.tagNumber=null!==(n=e.tagNumber)&&void 0!==n?n:-1,this.isConstructed=null!==(s=e.isConstructed)&&void 0!==s&&s):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",b}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const r=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,r[0]=t}return r.buffer}if(!this.isHexOnly){const r=c(this.tagNumber,7),n=new Uint8Array(r),s=r.byteLength,i=new Uint8Array(s+1);if(i[0]=31|t,!e){for(let e=0;e<s-1;e++)i[e+1]=128|n[e];i[s]=n[s-1]}return i.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=31|t,!e){const e=this.valueHexView;for(let t=0;t<e.length-1;t++)r[t+1]=128|e[t];r[this.valueHexView.byteLength]=e[e.length-1]}return r.buffer}fromBER(e,t,r){const n=o.BufferSourceConverter.toUint8Array(e);if(!p(this,n,t,r))return-1;const s=n.subarray(t,t+r);if(0===s.length)return this.error="Zero buffer length",-1;switch(192&s[0]){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=!(32&~s[0]),this.isHexOnly=!1;const i=31&s[0];if(31!==i)this.tagNumber=i,this.blockLength=1;else{let e=1,t=this.valueHexView=new Uint8Array(255),r=255;for(;128&s[e];){if(t[e-1]=127&s[e],e++,e>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(e===r){r+=255;const e=new Uint8Array(r);for(let r=0;r<t.length;r++)e[r]=t[r];t=this.valueHexView=new Uint8Array(r)}}this.blockLength=e+1,t[e-1]=127&s[e];const n=new Uint8Array(e);for(let r=0;r<e;r++)n[r]=t[r];t=this.valueHexView=new Uint8Array(e),t.set(n),this.blockLength<=9?this.tagNumber=a(t,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(1===this.tagClass&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}}N.NAME="identificationBlock";class U extends C{constructor({lenBlock:e={}}={}){var t,r,n;super(),this.isIndefiniteForm=null!==(t=e.isIndefiniteForm)&&void 0!==t&&t,this.longFormUsed=null!==(r=e.longFormUsed)&&void 0!==r&&r,this.length=null!==(n=e.length)&&void 0!==n?n:0}fromBER(e,t,r){const n=o.BufferSourceConverter.toUint8Array(e);if(!p(this,n,t,r))return-1;const s=n.subarray(t,t+r);if(0===s.length)return this.error="Zero buffer length",-1;if(255===s[0])return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=128===s[0],this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(128&s[0]),!1===this.longFormUsed)return this.length=s[0],this.blockLength=1,t+this.blockLength;const i=127&s[0];if(i>8)return this.error="Too big integer",-1;if(i+1>s.length)return this.error="End of input reached before message was fully decoded",-1;const c=t+1,u=n.subarray(c,c+i);return 0===u[i-1]&&this.warnings.push("Needlessly long encoded length"),this.length=a(u,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,t+this.blockLength}toBER(e=!1){let t,r;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),!1===e&&(r=new Uint8Array(t),r[0]=128),t;if(this.longFormUsed){const n=c(this.length,8);if(n.byteLength>127)return this.error="Too big length",b;if(t=new ArrayBuffer(n.byteLength+1),e)return t;const s=new Uint8Array(n);r=new Uint8Array(t),r[0]=128|n.byteLength;for(let e=0;e<n.byteLength;e++)r[e+1]=s[e];return t}return t=new ArrayBuffer(1),!1===e&&(r=new Uint8Array(t),r[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}U.NAME="lengthBlock";const P={};class I extends C{constructor({name:e="",optional:t=!1,primitiveSchema:r,...n}={},s){super(n),this.name=e,this.optional=t,r&&(this.primitiveSchema=r),this.idBlock=new N(n),this.lenBlock=new U(n),this.valueBlock=s?new s(n):new x(n)}fromBER(e,t,r){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}toBER(e,t){const r=t||new g;t||O(this);const n=this.idBlock.toBER(e);if(r.write(n),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;const n=this.lenBlock.toBER(e);r.write(n),r.write(t)}return t?b:r.final()}toJSON(){const e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return"ascii"===e?this.onAsciiEncoding():o.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${o.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;return function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),n=new Uint8Array(t);for(let e=0;e<r.length;e++)if(r[e]!==n[e])return!1;return!0}(this.toBER(),e.toBER())}}function O(e){var t;if(e instanceof P.Constructed)for(const t of e.valueBlock.value)O(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!(null===(t=e.lenBlock)||void 0===t?void 0:t.isIndefiniteForm)}I.NAME="BaseBlock";class H extends I{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor({value:e="",...t}={},r){super(t,r),e&&this.fromString(e)}fromBER(e,t,r){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}H.NAME="BaseStringBlock";class T extends(K(x)){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}}var L,D,V,R,M,$;T.NAME="PrimitiveValueBlock";class J extends I{constructor(e={}){super(e,T),this.idBlock.isConstructed=!1}}function j(e,t=0,r=e.length){const n=t;let s=new I({},x);const i=new C;if(!p(i,e,t,r))return s.error=i.error,{offset:-1,result:s};if(!e.subarray(t,t+r).length)return s.error="Zero buffer length",{offset:-1,result:s};let o=s.idBlock.fromBER(e,t,r);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),-1===o)return s.error=s.idBlock.error,{offset:-1,result:s};if(t=o,r-=s.idBlock.blockLength,o=s.lenBlock.fromBER(e,t,r),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),-1===o)return s.error=s.lenBlock.error,{offset:-1,result:s};if(t=o,r-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let a=I;if(1===s.idBlock.tagClass){if(s.idBlock.tagNumber>=37&&!1===s.idBlock.isHexOnly)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};a=P.EndOfContent;break;case 1:a=P.Boolean;break;case 2:a=P.Integer;break;case 3:a=P.BitString;break;case 4:a=P.OctetString;break;case 5:a=P.Null;break;case 6:a=P.ObjectIdentifier;break;case 10:a=P.Enumerated;break;case 12:a=P.Utf8String;break;case 13:a=P.RelativeObjectIdentifier;break;case 14:a=P.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:a=P.Sequence;break;case 17:a=P.Set;break;case 18:a=P.NumericString;break;case 19:a=P.PrintableString;break;case 20:a=P.TeletexString;break;case 21:a=P.VideotexString;break;case 22:a=P.IA5String;break;case 23:a=P.UTCTime;break;case 24:a=P.GeneralizedTime;break;case 25:a=P.GraphicString;break;case 26:a=P.VisibleString;break;case 27:a=P.GeneralString;break;case 28:a=P.UniversalString;break;case 29:a=P.CharacterString;break;case 30:a=P.BmpString;break;case 31:a=P.DATE;break;case 32:a=P.TimeOfDay;break;case 33:a=P.DateTime;break;case 34:a=P.Duration;break;default:{const e=s.idBlock.isConstructed?new P.Constructed:new P.Primitive;e.idBlock=s.idBlock,e.lenBlock=s.lenBlock,e.warnings=s.warnings,s=e}}}else a=s.idBlock.isConstructed?P.Constructed:P.Primitive;return s=function(e,t){if(e instanceof t)return e;const r=new t;return r.idBlock=e.idBlock,r.lenBlock=e.lenBlock,r.warnings=e.warnings,r.valueBeforeDecodeView=e.valueBeforeDecodeView,r}(s,a),o=s.fromBER(e,t,s.lenBlock.isIndefiniteForm?r:s.lenBlock.length),s.valueBeforeDecodeView=e.subarray(n,n+s.blockLength),{offset:o,result:s}}function z(e){if(!e.byteLength){const e=new I({},x);return e.error="Input buffer has zero length",{offset:-1,result:e}}return j(o.BufferSourceConverter.toUint8Array(e).slice(),0,e.byteLength)}function F(e,t){return e?1:t}L=J,P.Primitive=L,J.NAME="PRIMITIVE";class G extends x{constructor({value:e=[],isIndefiniteForm:t=!1,...r}={}){super(r),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,r){const n=o.BufferSourceConverter.toUint8Array(e);if(!p(this,n,t,r))return-1;if(this.valueBeforeDecodeView=n.subarray(t,t+r),0===this.valueBeforeDecodeView.length)return this.warnings.push("Zero buffer length"),t;let s=t;for(;F(this.isIndefiniteForm,r)>0;){const e=j(n,s,r);if(-1===e.offset)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(s=e.offset,this.blockLength+=e.result.blockLength,r-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===S)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===S?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){const r=t||new g;for(let t=0;t<this.value.length;t++)this.value[t].toBER(e,r);return t?b:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}G.NAME="ConstructedValueBlock";class _ extends I{constructor(e={}){super(e,G),this.idBlock.isConstructed=!0}fromBER(e,t,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),n)}onAsciiEncoding(){const e=[];for(const t of this.valueBlock.value)e.push(t.toString("ascii").split("\n").map(e=>` ${e}`).join("\n"));const t=3===this.idBlock.tagClass?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join("\n")}`:`${t} :`}}D=_,P.Constructed=D,_.NAME="CONSTRUCTED";class q extends x{fromBER(e,t,r){return t}toBER(e){return b}}q.override="EndOfContentValueBlock";class W extends I{constructor(e={}){super(e,q),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}V=W,P.EndOfContent=V,W.NAME=S;class Y extends I{constructor(e={}){super(e,x),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,t+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+r}toBER(e,t){const r=new ArrayBuffer(2);if(!e){const e=new Uint8Array(r);e[0]=5,e[1]=0}return t&&t.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}R=Y,P.Null=R,Y.NAME="NULL";class X extends(K(x)){get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=o.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}fromBER(e,t,r){const n=o.BufferSourceConverter.toUint8Array(e);return p(this,n,t,r)?(this.valueHexView=n.subarray(t,t+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,l.call(this),this.blockLength=r,t+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}X.NAME="BooleanValueBlock";class Z extends I{getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}constructor(e={}){super(e,X),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}M=Z,P.Boolean=M,Z.NAME="BOOLEAN";class Q extends(K(G)){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,r){let n=0;if(this.isConstructed){if(this.isHexOnly=!1,n=G.prototype.fromBER.call(this,e,t,r),-1===n)return n;for(let e=0;e<this.value.length;e++){const t=this.value[e].constructor.NAME;if(t===S){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(t!==B)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,n=super.fromBER(e,t,r),this.blockLength=r;return n}toBER(e,t){return this.isConstructed?G.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Q.NAME="OctetStringValueBlock";let ee=class extends I{constructor({idBlock:e={},lenBlock:t={},...r}={}){var n,s;null!==(n=r.isConstructed)&&void 0!==n||(r.isConstructed=!!(null===(s=r.value)||void 0===s?void 0:s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},Q),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,0===r)return 0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const n=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+r);try{if(n.byteLength){const e=j(n,0,n.byteLength);-1!==e.offset&&e.offset===r&&(this.valueBlock.value=[e.result])}}catch{}}return super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return _.prototype.onAsciiEncoding.call(this);return`${this.constructor.NAME} : ${o.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof $&&e.push(t.valueBlock.valueHexView);return o.BufferSourceConverter.concat(e)}};$=ee,P.OctetString=$,ee.NAME=B;class te extends(K(G)){constructor({unusedBits:e=0,isConstructed:t=!1,...r}={}){super(r),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,r){if(!r)return t;let n=-1;if(this.isConstructed){if(n=G.prototype.fromBER.call(this,e,t,r),-1===n)return n;for(const e of this.value){const t=e.constructor.NAME;if(t===S){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(t!==E)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const r=e.valueBlock;if(this.unusedBits>0&&r.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=r.unusedBits}return n}const s=o.BufferSourceConverter.toUint8Array(e);if(!p(this,s,t,r))return-1;const i=s.subarray(t,t+r);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const e=i.subarray(1);try{if(e.byteLength){const t=j(e,0,e.byteLength);-1!==t.offset&&t.offset===r-1&&(this.value=[t.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,t+r}toBER(e,t){if(this.isConstructed)return G.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return b;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}var re;te.NAME="BitStringValueBlock";let ne=class extends I{constructor({idBlock:e={},lenBlock:t={},...r}={}){var n,s;null!==(n=r.isConstructed)&&void 0!==n||(r.isConstructed=!!(null===(s=r.value)||void 0===s?void 0:s.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},te),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return _.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const r of t)e.push(r.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}};var se,ie,oe,ae;function ce(e,t){const r=new Uint8Array([0]),n=new Uint8Array(e),s=new Uint8Array(t);let i=n.slice(0);const o=i.length-1,a=s.slice(0),c=a.length-1;let l=0;let h=0;for(let e=c<o?o:c;e>=0;e--,h++){if(!0==h<a.length)l=i[o-h]+a[c-h]+r[0];else l=i[o-h]+r[0];if(r[0]=l/10,!0==h>=i.length)i=u(new Uint8Array([l%10]),i);else i[o-h]=l%10}return r[0]>0&&(i=u(r,i)),i}function ue(e){if(e>=m.length)for(let t=m.length;t<=e;t++){const e=new Uint8Array([0]);let r=m[t-1].slice(0);for(let t=r.length-1;t>=0;t--){const n=new Uint8Array([(r[t]<<1)+e[0]]);e[0]=n[0]/10,r[t]=n[0]%10}e[0]>0&&(r=u(e,r)),m.push(r)}return m[e]}function le(e,t){let r=0;const n=new Uint8Array(e),s=new Uint8Array(t),i=n.slice(0),o=i.length-1,a=s.slice(0),c=a.length-1;let u,l=0;for(let e=c;e>=0;e--,l++)if(u=i[o-l]-a[c-l]-r,!0==u<0)r=1,i[o-l]=u+10;else r=0,i[o-l]=u;if(r>0)for(let e=o-c+1;e>=0;e--,l++){if(u=i[o-l]-r,!(u<0)){r=0,i[o-l]=u;break}r=1,i[o-l]=u+10}return i.slice()}re=ne,P.BitString=re,ne.NAME=E;class he extends(K(x)){setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=l.call(this)))}constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),void 0!==e&&(this.valueDec=e)}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(function(e){const t=e<0?-1*e:e;let r=128;for(let n=1;n<8;n++){if(t<=r){if(e<0){const e=c(r-t,8,n);return new Uint8Array(e)[0]|=128,e}let s=c(t,8,n),i=new Uint8Array(s);if(128&i[0]){const e=s.slice(0),t=new Uint8Array(e);s=new ArrayBuffer(s.byteLength+1),i=new Uint8Array(s);for(let r=0;r<e.byteLength;r++)i[r+1]=t[r];i[0]=0}return s}r*=Math.pow(2,8)}return new ArrayBuffer(0)}(e))}get valueDec(){return this._valueDec}fromDER(e,t,r,n=0){const s=this.fromBER(e,t,r);if(-1===s)return s;const i=this.valueHexView;return 0===i[0]&&128&i[1]?this.valueHexView=i.subarray(1):0!==n&&i.length<n&&(n-i.length>1&&(n=i.length+1),this.valueHexView=i.subarray(n-i.length)),s}toDER(e=!1){const t=this.valueHexView;switch(!0){case!!(128&t[0]):{const e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case 0===t[0]&&!(128&t[1]):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,r){const n=super.fromBER(e,t,r);return-1===n||this.setValueHex(),n}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=8*this.valueHexView.length-1;let t,r=new Uint8Array(8*this.valueHexView.length/3),n=0;const s=this.valueHexView;let i="",o=!1;for(let o=s.byteLength-1;o>=0;o--){t=s[o];for(let s=0;s<8;s++){if(!(1&~t))if(n===e)r=le(ue(n),r),i="-";else r=ce(r,ue(n));n++,t>>=1}}for(let e=0;e<r.length;e++)r[e]&&(o=!0),o&&(i+=d.charAt(r[e]));return!1===o&&(i+=d.charAt(0)),i}}se=he,he.NAME="IntegerValueBlock",Object.defineProperty(se.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});class ye extends I{constructor(e={}){super(e,he),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return y(),BigInt(this.valueBlock.toString())}static fromBigInt(e){y();const t=BigInt(e),r=new g,n=t.toString(16).replace(/^-/,""),s=new Uint8Array(o.Convert.FromHex(n));if(t<0){const e=new Uint8Array(s.length+(128&s[0]?1:0));e[0]|=128;const n=BigInt(`0x${o.Convert.ToHex(e)}`)+t,i=o.BufferSourceConverter.toUint8Array(o.Convert.FromHex(n.toString(16)));i[0]|=128,r.write(i)}else 128&s[0]&&r.write(new Uint8Array([0])),r.write(s);return new ie({valueHex:r.final()})}convertToDER(){const e=new ie({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new ie({valueHex:0===this.valueBlock.valueHexView[0]?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}ie=ye,P.Integer=ie,ye.NAME="INTEGER";class fe extends ye{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}oe=fe,P.Enumerated=oe,fe.NAME="ENUMERATED";class pe extends(K(x)){constructor({valueDec:e=-1,isFirstSid:t=!1,...r}={}){super(r),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,r){if(!r)return t;const n=o.BufferSourceConverter.toUint8Array(e);if(!p(this,n,t,r))return-1;const s=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let e=0;e<r&&(this.valueHexView[e]=127&s[e],this.blockLength++,128&s[e]);e++);const i=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)i[e]=this.valueHexView[e];return this.valueHexView=i,128&s[this.blockLength-1]?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=a(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){y();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const r=new Uint8Array(t.length/7);for(let e=0;e<r.length;e++)r[e]=parseInt(t.slice(7*e,7*e+7),2)+(e+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=c(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",b;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),n=t.byteLength-1;for(let t=0;t<n;t++)r[t]=128|e[t];r[n]=e[n]}return r}toString(){let e="";if(this.isHexOnly)e=o.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}pe.NAME="sidBlock";class ge extends x{constructor({value:e="",...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let n=t;for(;r>0;){const t=new pe;if(n=t.fromBER(e,n,r),-1===n)return this.blockLength=0,this.error=t.error,n;0===this.value.length&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return n}toBER(e){const t=[];for(let r=0;r<this.value.length;r++){const n=this.value[r].toBER(e);if(0===n.byteLength)return this.error=this.value[r].error,b;t.push(n)}return f(t)}fromString(e){this.value=[];let t=0,r=0,n="",s=!1;do{if(r=e.indexOf(".",t),n=-1===r?e.substring(t):e.substring(t,r),t=r+1,s){const e=this.value[0];let t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:return void(this.value=[])}const r=parseInt(n,10);if(isNaN(r))return;e.valueDec=r+t,s=!1}else{const e=new pe;if(n>Number.MAX_SAFE_INTEGER){y();const t=BigInt(n);e.valueBigInt=t}else if(e.valueDec=parseInt(n,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,s=!0),this.value.push(e)}}while(-1!==r)}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let n=this.value[r].toString();0!==r&&(e=`${e}.`),t?(n=`{${n}}`,this.value[r].isFirstSid?e=`2.{${n} - 80}`:e+=n):e+=n}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}ge.NAME="ObjectIdentifierValueBlock";let me=class extends I{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,ge),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};ae=me,P.ObjectIdentifier=ae,me.NAME="OBJECT IDENTIFIER";class de extends(K(C)){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,r){if(0===r)return t;const n=o.BufferSourceConverter.toUint8Array(e);if(!p(this,n,t,r))return-1;const s=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let e=0;e<r&&(this.valueHexView[e]=127&s[e],this.blockLength++,128&s[e]);e++);const i=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength;e++)i[e]=this.valueHexView[e];return this.valueHexView=i,128&s[this.blockLength-1]?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=a(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=c(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",b;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),n=t.byteLength-1;for(let t=0;t<n;t++)r[t]=128|e[t];r[n]=e[n]}return r.buffer}toString(){let e="";return e=this.isHexOnly?o.Convert.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}de.NAME="relativeSidBlock";class we extends x{constructor({value:e="",...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let n=t;for(;r>0;){const t=new de;if(n=t.fromBER(e,n,r),-1===n)return this.blockLength=0,this.error=t.error,n;this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return n}toBER(e,t){const r=[];for(let t=0;t<this.value.length;t++){const n=this.value[t].toBER(e);if(0===n.byteLength)return this.error=this.value[t].error,b;r.push(n)}return f(r)}fromString(e){this.value=[];let t=0,r=0,n="";do{r=e.indexOf(".",t),n=-1===r?e.substring(t):e.substring(t,r),t=r+1;const s=new de;if(s.valueDec=parseInt(n,10),isNaN(s.valueDec))return!0;this.value.push(s)}while(-1!==r);return!0}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let n=this.value[r].toString();0!==r&&(e=`${e}.`),t?(n=`{${n}}`,e+=n):e+=n}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}var ve,Ae,be,ke,Se,Be,Ee,Ke,Ce,xe,Ne,Ue,Pe,Ie,Oe,He,Te,Le,De,Ve,Re,Me;we.NAME="RelativeObjectIdentifierValueBlock";class $e extends I{getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}constructor(e={}){super(e,we),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}ve=$e,P.RelativeObjectIdentifier=ve,$e.NAME="RelativeObjectIdentifier";class Je extends _{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}Ae=Je,P.Sequence=Ae,Je.NAME="SEQUENCE";class je extends _{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}be=je,P.Set=be,je.NAME="SET";class ze extends(K(x)){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=A}toJSON(){return{...super.toJSON(),value:this.value}}}ze.NAME="StringValueBlock";class Fe extends ze{}Fe.NAME="SimpleStringValueBlock";class Ge extends H{constructor({...e}={}){super(e,Fe)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,o.BufferSourceConverter.toUint8Array(e))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);this.valueBlock.value=e}}Ge.NAME="SIMPLE STRING";class _e extends Ge{fromBuffer(e){this.valueBlock.valueHexView=o.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=o.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=o.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(o.Convert.FromUtf8String(e)),this.valueBlock.value=e}}_e.NAME="Utf8StringValueBlock";class qe extends _e{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}ke=qe,P.Utf8String=ke,qe.NAME="UTF8String";class We extends Ge{fromBuffer(e){this.valueBlock.value=o.Convert.ToUtf16String(e),this.valueBlock.valueHexView=o.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(o.Convert.FromUtf16String(e))}}We.NAME="BmpStringValueBlock";class Ye extends We{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}Se=Ye,P.BmpString=Se,Ye.NAME="BMPString";class Xe extends Ge{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(t);for(let e=0;e<r.length;e+=4)r[e]=r[e+3],r[e+1]=r[e+2],r[e+2]=0,r[e+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(4*t);for(let n=0;n<t;n++){const t=c(e.charCodeAt(n),8),s=new Uint8Array(t);if(s.length>4)continue;const i=4-s.length;for(let e=s.length-1;e>=0;e--)r[4*n+e+i]=s[e]}this.valueBlock.value=e}}Xe.NAME="UniversalStringValueBlock";class Ze extends Xe{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}Be=Ze,P.UniversalString=Be,Ze.NAME="UniversalString";class Qe extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}Ee=Qe,P.NumericString=Ee,Qe.NAME="NumericString";class et extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}Ke=et,P.PrintableString=Ke,et.NAME="PrintableString";class tt extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}Ce=tt,P.TeletexString=Ce,tt.NAME="TeletexString";class rt extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}xe=rt,P.VideotexString=xe,rt.NAME="VideotexString";class nt extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Ne=nt,P.IA5String=Ne,nt.NAME="IA5String";class st extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}Ue=st,P.GraphicString=Ue,st.NAME="GraphicString";class it extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Pe=it,P.VisibleString=Pe,it.NAME="VisibleString";class ot extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Ie=ot,P.GeneralString=Ie,ot.NAME="GeneralString";class at extends Ge{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Oe=at,P.CharacterString=Oe,at.NAME="CharacterString";class ct extends it{constructor({value:e,valueDate:t,...r}={}){if(super(r),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,o.BufferSourceConverter.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(null===t)return void(this.error="Wrong input string for conversion");const r=parseInt(t[1],10);this.year=r>=50?1900+r:2e3+r,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(e="iso"){if("iso"===e){const e=new Array(7);return e[0]=h(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=h(this.month,2),e[2]=h(this.day,2),e[3]=h(this.hour,2),e[4]=h(this.minute,2),e[5]=h(this.second,2),e[6]="Z",e.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}He=ct,P.UTCTime=He,ct.NAME="UTCTime";class ut extends ct{constructor(e={}){var t;super(e),null!==(t=this.millisecond)&&void 0!==t||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){const e=Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond);return new Date(e)}fromString(e){let t,r=!1,n="",s="",i=0,o=0,a=0;if("Z"===e[e.length-1])n=e.substring(0,e.length-1),r=!0;else{const t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(-1!==n.indexOf("+"))throw new Error("Wrong input string for conversion");if(-1!==n.indexOf("-"))throw new Error("Wrong input string for conversion")}else{let e=1,t=n.indexOf("+"),r="";if(-1===t&&(t=n.indexOf("-"),e=-1),-1!==t){if(r=n.substring(t+1),n=n.substring(0,t),2!==r.length&&4!==r.length)throw new Error("Wrong input string for conversion");let s=parseInt(r.substring(0,2),10);if(isNaN(s.valueOf()))throw new Error("Wrong input string for conversion");if(o=e*s,4===r.length){if(s=parseInt(r.substring(2,4),10),isNaN(s.valueOf()))throw new Error("Wrong input string for conversion");a=e*s}}}let c=n.indexOf(".");if(-1===c&&(c=n.indexOf(",")),-1!==c){const e=new Number(`0${n.substring(c)}`);if(isNaN(e.valueOf()))throw new Error("Wrong input string for conversion");i=e.valueOf(),s=n.substring(0,c)}else s=n;switch(!0){case 8===s.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==c)throw new Error("Wrong input string for conversion");break;case 10===s.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*i;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 12===s.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*i;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 14===s.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){const e=1e3*i;this.millisecond=Math.floor(e)}break;default:throw new Error("Wrong input string for conversion")}const u=t.exec(s);if(null===u)throw new Error("Wrong input string for conversion");for(let e=1;e<u.length;e++)switch(e){case 1:this.year=parseInt(u[e],10);break;case 2:this.month=parseInt(u[e],10);break;case 3:this.day=parseInt(u[e],10);break;case 4:this.hour=parseInt(u[e],10)+o;break;case 5:this.minute=parseInt(u[e],10)+a;break;case 6:this.second=parseInt(u[e],10);break;default:throw new Error("Wrong input string for conversion")}if(!1===r){const e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(e="iso"){if("iso"===e){const e=[];return e.push(h(this.year,4)),e.push(h(this.month,2)),e.push(h(this.day,2)),e.push(h(this.hour,2)),e.push(h(this.minute,2)),e.push(h(this.second,2)),0!==this.millisecond&&(e.push("."),e.push(h(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Te=ut,P.GeneralizedTime=Te,ut.NAME="GeneralizedTime";class lt extends qe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Le=lt,P.DATE=Le,lt.NAME="DATE";class ht extends qe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}De=ht,P.TimeOfDay=De,ht.NAME="TimeOfDay";class yt extends qe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Ve=yt,P.DateTime=Ve,yt.NAME="DateTime";class ft extends qe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Re=ft,P.Duration=Re,ft.NAME="Duration";class pt extends qe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Me=pt,P.TIME=Me,pt.NAME="TIME";class gt{constructor({name:e="",optional:t=!1}={}){this.name=e,this.optional=t}}class mt extends gt{constructor({value:e=[],...t}={}){super(t),this.value=e}}class dt extends gt{constructor({value:e=new gt,local:t=!1,...r}={}){super(r),this.value=e,this.local=t}}function wt(e,t,r){if(r instanceof mt){for(const n of r.value){if(wt(e,t,n).verified)return{verified:!0,result:e}}{const e={verified:!1,result:{error:"Wrong values for Choice type"}};return r.hasOwnProperty(w)&&(e.name=r.name),e}}if(r instanceof gt)return r.hasOwnProperty(w)&&(e[r.name]=t),{verified:!0,result:e};if(e instanceof Object==!1)return{verified:!1,result:{error:"Wrong root object"}};if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 data"}};if(r instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("idBlock"in r==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("fromBER"in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if("toBER"in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=r.idBlock.toBER(!1);if(0===n.byteLength)return{verified:!1,result:{error:"Error encoding idBlock for ASN.1 schema"}};if(-1===r.idBlock.fromBER(n,0,n.byteLength))return{verified:!1,result:{error:"Error decoding idBlock for ASN.1 schema"}};if(!1===r.idBlock.hasOwnProperty("tagClass"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagClass!==t.idBlock.tagClass)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("tagNumber"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.tagNumber!==t.idBlock.tagNumber)return{verified:!1,result:e};if(!1===r.idBlock.hasOwnProperty("isConstructed"))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isConstructed!==t.idBlock.isConstructed)return{verified:!1,result:e};if(!("isHexOnly"in r.idBlock))return{verified:!1,result:{error:"Wrong ASN.1 schema"}};if(r.idBlock.isHexOnly!==t.idBlock.isHexOnly)return{verified:!1,result:e};if(r.idBlock.isHexOnly){if(v in r.idBlock==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema"}};const n=r.idBlock.valueHexView,s=t.idBlock.valueHexView;if(n.length!==s.length)return{verified:!1,result:e};for(let t=0;t<n.length;t++)if(n[t]!==s[1])return{verified:!1,result:e}}if(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,A),r.name&&(e[r.name]=t)),r instanceof P.Constructed){let n=0,s={verified:!1,result:{error:"Unknown error"}},i=r.valueBlock.value.length;if(i>0&&r.valueBlock.value[0]instanceof dt&&(i=t.valueBlock.value.length),0===i)return{verified:!0,result:e};if(0===t.valueBlock.value.length&&0!==r.valueBlock.value.length){let t=!0;for(let e=0;e<r.valueBlock.value.length;e++)t=t&&(r.valueBlock.value[e].optional||!1);return t?{verified:!0,result:e}:(r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,A),r.name&&delete e[r.name]),e.error="Inconsistent object length",{verified:!1,result:e})}for(let o=0;o<i;o++)if(o-n>=t.valueBlock.value.length){if(!1===r.valueBlock.value[o].optional){const t={verified:!1,result:e};return e.error="Inconsistent length between ASN.1 data and schema",r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,A),r.name&&(delete e[r.name],t.name=r.name)),t}}else if(r.valueBlock.value[0]instanceof dt){if(s=wt(e,t.valueBlock.value[o],r.valueBlock.value[0].value),!1===s.verified){if(!r.valueBlock.value[0].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,A),r.name&&delete e[r.name]),s;n++}if(w in r.valueBlock.value[0]&&r.valueBlock.value[0].name.length>0){let n={};n="local"in r.valueBlock.value[0]&&r.valueBlock.value[0].local?t:e,void 0===n[r.valueBlock.value[0].name]&&(n[r.valueBlock.value[0].name]=[]),n[r.valueBlock.value[0].name].push(t.valueBlock.value[o])}}else if(s=wt(e,t.valueBlock.value[o-n],r.valueBlock.value[o]),!1===s.verified){if(!r.valueBlock.value[o].optional)return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,A),r.name&&delete e[r.name]),s;n++}if(!1===s.verified){const t={verified:!1,result:e};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,A),r.name&&(delete e[r.name],t.name=r.name)),t}return{verified:!0,result:e}}if(r.primitiveSchema&&v in t.valueBlock){const n=j(t.valueBlock.valueHexView);if(-1===n.offset){const t={verified:!1,result:n.result};return r.name&&(r.name=r.name.replace(/^\s+|\s+$/g,A),r.name&&(delete e[r.name],t.name=r.name)),t}return wt(e,n.result,r.primitiveSchema)}return{verified:!0,result:e}}var vt,At,bt=Object.freeze({__proto__:null,Any:gt,BaseBlock:I,BaseStringBlock:H,BitString:ne,BmpString:Ye,Boolean:Z,CharacterString:at,Choice:mt,Constructed:_,DATE:lt,DateTime:yt,Duration:ft,EndOfContent:W,Enumerated:fe,GeneralString:ot,GeneralizedTime:ut,GraphicString:st,HexBlock:K,IA5String:nt,Integer:ye,Null:Y,NumericString:Qe,ObjectIdentifier:me,OctetString:ee,Primitive:J,PrintableString:et,RawData:class{get data(){return this.dataView.slice().buffer}set data(e){this.dataView=o.BufferSourceConverter.toUint8Array(e)}constructor({data:e=k}={}){this.dataView=o.BufferSourceConverter.toUint8Array(e)}fromBER(e,t,r){const n=t+r;return this.dataView=o.BufferSourceConverter.toUint8Array(e).subarray(t,n),n}toBER(e){return this.dataView.slice().buffer}},RelativeObjectIdentifier:$e,Repeated:dt,Sequence:Je,Set:je,TIME:pt,TeletexString:tt,TimeOfDay:ht,UTCTime:ct,UniversalString:Ze,Utf8String:qe,ValueBlock:x,VideotexString:rt,ViewWriter:g,VisibleString:it,compareSchema:wt,fromBER:z,verifySchema:function(e,t){if(t instanceof Object==!1)return{verified:!1,result:{error:"Wrong ASN.1 schema type"}};const r=j(o.BufferSourceConverter.toUint8Array(e));return-1===r.offset?{verified:!1,result:r.result}:wt(r.result,r.result,t)}});!function(e){e[e.Sequence=0]="Sequence",e[e.Set=1]="Set",e[e.Choice=2]="Choice"}(vt||(vt={})),function(e){e[e.Any=1]="Any",e[e.Boolean=2]="Boolean",e[e.OctetString=3]="OctetString",e[e.BitString=4]="BitString",e[e.Integer=5]="Integer",e[e.Enumerated=6]="Enumerated",e[e.ObjectIdentifier=7]="ObjectIdentifier",e[e.Utf8String=8]="Utf8String",e[e.BmpString=9]="BmpString",e[e.UniversalString=10]="UniversalString",e[e.NumericString=11]="NumericString",e[e.PrintableString=12]="PrintableString",e[e.TeletexString=13]="TeletexString",e[e.VideotexString=14]="VideotexString",e[e.IA5String=15]="IA5String",e[e.GraphicString=16]="GraphicString",e[e.VisibleString=17]="VisibleString",e[e.GeneralString=18]="GeneralString",e[e.CharacterString=19]="CharacterString",e[e.UTCTime=20]="UTCTime",e[e.GeneralizedTime=21]="GeneralizedTime",e[e.DATE=22]="DATE",e[e.TimeOfDay=23]="TimeOfDay",e[e.DateTime=24]="DateTime",e[e.Duration=25]="Duration",e[e.TIME=26]="TIME",e[e.Null=27]="Null"}(At||(At={}));const kt={fromASN:e=>e instanceof Y?null:e.valueBeforeDecodeView,toASN:e=>{if(null===e)return new Y;const t=z(e);if(t.result.error)throw new Error(t.result.error);return t.result}},St={fromASN:e=>e.valueBlock.valueHexView.byteLength>=4?e.valueBlock.toString():e.valueBlock.valueDec,toASN:e=>new ye({value:+e})},Bt={fromASN:e=>e.valueBlock.valueDec,toASN:e=>new fe({value:e})},Et={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new ne({valueHex:e})},Kt={fromASN:e=>e.valueBlock.toString(),toASN:e=>new me({value:e})},Ct={fromASN:e=>e.valueBlock.value,toASN:e=>new Z({value:e})},xt={fromASN:e=>e.valueBlock.valueHexView,toASN:e=>new ee({valueHex:e})};function Nt(e){return{fromASN:e=>e.valueBlock.value,toASN:t=>new e({value:t})}}const Ut=Nt(qe),Pt=Nt(Ye),It=Nt(Ze),Ot=Nt(Qe),Ht=Nt(et),Tt=Nt(tt),Lt=Nt(rt),Dt=Nt(nt),Vt=Nt(st),Rt=Nt(it),Mt=Nt(ot),$t=Nt(at),Jt={fromASN:e=>e.toDate(),toASN:e=>new ct({valueDate:e})},jt={fromASN:e=>e.toDate(),toASN:e=>new ut({valueDate:e})},zt={fromASN:()=>null,toASN:()=>new Y};function Ft(e){switch(e){case At.Any:return kt;case At.BitString:return Et;case At.BmpString:return Pt;case At.Boolean:return Ct;case At.CharacterString:return $t;case At.Enumerated:return Bt;case At.GeneralString:return Mt;case At.GeneralizedTime:return jt;case At.GraphicString:return Vt;case At.IA5String:return Dt;case At.Integer:return St;case At.Null:return zt;case At.NumericString:return Ot;case At.ObjectIdentifier:return Kt;case At.OctetString:return xt;case At.PrintableString:return Ht;case At.TeletexString:return Tt;case At.UTCTime:return Jt;case At.UniversalString:return It;case At.Utf8String:return Ut;case At.VideotexString:return Lt;case At.VisibleString:return Rt;default:return null}}function Gt(e){return"function"==typeof e&&e.prototype?!(!e.prototype.toASN||!e.prototype.fromASN)||Gt(e.prototype):!!(e&&"object"==typeof e&&"toASN"in e&&"fromASN"in e)}function _t(e){var t;if(e){const r=Object.getPrototypeOf(e);return(null===(t=null==r?void 0:r.prototype)||void 0===t?void 0:t.constructor)===Array||_t(r)}return!1}function qt(e,t){if(!e||!t)return!1;if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),n=new Uint8Array(t);for(let t=0;t<e.byteLength;t++)if(r[t]!==n[t])return!1;return!0}const Wt=new class{constructor(){this.items=new WeakMap}has(e){return this.items.has(e)}get(e,t=!1){const r=this.items.get(e);if(!r)throw new Error(`Cannot get schema for '${e.prototype.constructor.name}' target`);if(t&&!r.schema)throw new Error(`Schema '${e.prototype.constructor.name}' doesn't contain ASN.1 schema. Call 'AsnSchemaStorage.cache'.`);return r}cache(e){const t=this.get(e);t.schema||(t.schema=this.create(e,!0))}createDefault(e){const t={type:vt.Sequence,items:{}},r=this.findParentSchema(e);return r&&(Object.assign(t,r),t.items=Object.assign({},t.items,r.items)),t}create(e,t){const r=this.items.get(e)||this.createDefault(e),n=[];for(const e in r.items){const s=r.items[e],i=t?e:"";let o;if("number"==typeof s.type){const e=At[s.type],t=bt[e];if(!t)throw new Error(`Cannot get ASN1 class by name '${e}'`);o=new t({name:i})}else if(Gt(s.type)){o=(new s.type).toSchema(i)}else if(s.optional){this.get(s.type).type===vt.Choice?o=new gt({name:i}):(o=this.create(s.type,!1),o.name=i)}else o=new gt({name:i});const a=!!s.optional||void 0!==s.defaultValue;if(s.repeated){o.name="";o=new("set"===s.repeated?je:Je)({name:"",value:[new dt({name:i,value:o})]})}if(null!==s.context&&void 0!==s.context)if(s.implicit)if("number"==typeof s.type||Gt(s.type)){const e=s.repeated?_:J;n.push(new e({name:i,optional:a,idBlock:{tagClass:3,tagNumber:s.context}}))}else{this.cache(s.type);const e=!!s.repeated;let t=e?o:this.get(s.type,!0).schema;t="valueBlock"in t?t.valueBlock.value:t.value,n.push(new _({name:e?"":i,optional:a,idBlock:{tagClass:3,tagNumber:s.context},value:t}))}else n.push(new _({optional:a,idBlock:{tagClass:3,tagNumber:s.context},value:[o]}));else o.optional=a,n.push(o)}switch(r.type){case vt.Sequence:return new Je({value:n,name:""});case vt.Set:return new je({value:n,name:""});case vt.Choice:return new mt({value:n,name:""});default:throw new Error("Unsupported ASN1 type in use")}}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=Object.getPrototypeOf(e);if(t){return this.items.get(t)||this.findParentSchema(t)}return null}},Yt=e=>t=>{let r;Wt.has(t)?r=Wt.get(t):(r=Wt.createDefault(t),Wt.set(t,r)),Object.assign(r,e)},Xt=e=>(t,r)=>{let n;Wt.has(t.constructor)?n=Wt.get(t.constructor):(n=Wt.createDefault(t.constructor),Wt.set(t.constructor,n));const s=Object.assign({},e);if("number"==typeof s.type&&!s.converter){const n=Ft(e.type);if(!n)throw new Error(`Cannot get default converter for property '${r}' of ${t.constructor.name}`);s.converter=n}n.items[r]=s};class Zt extends Error{constructor(){super(...arguments),this.schemas=[]}}class Qt{static parse(e,t){const r=z(e);if(r.result.error)throw new Error(r.result.error);return this.fromASN(r.result,t)}static fromASN(e,t){var r;try{if(Gt(t)){return(new t).fromASN(e)}const n=Wt.get(t);Wt.cache(t);let s=n.schema;if(e.constructor===_&&n.type!==vt.Choice){s=new _({idBlock:{tagClass:3,tagNumber:e.idBlock.tagNumber},value:n.schema.valueBlock.value});for(const t in n.items)delete e[t]}const i=wt({},e,s);if(!i.verified)throw new Zt(`Data does not match to ${t.name} ASN1 schema. ${i.result.error}`);const o=new t;if(_t(t)){if(!("value"in e.valueBlock)||!Array.isArray(e.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const r=n.itemType;if("number"==typeof r){const n=Ft(r);if(!n)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);return t.from(e.valueBlock.value,e=>n.fromASN(e))}return t.from(e.valueBlock.value,e=>this.fromASN(e,r))}for(const e in n.items){const t=i.result[e];if(!t)continue;const s=n.items[e],a=s.type;if("number"==typeof a||Gt(a)){const n=null!==(r=s.converter)&&void 0!==r?r:Gt(a)?new a:null;if(!n)throw new Error("Converter is empty");if(s.repeated)if(s.implicit){const r=new("sequence"===s.repeated?Je:je);r.valueBlock=t.valueBlock;const i=z(r.toBER(!1));if(-1===i.offset)throw new Error(`Cannot parse the child item. ${i.result.error}`);if(!("value"in i.result.valueBlock)||!Array.isArray(i.result.valueBlock.value))throw new Error("Cannot get items from the ASN.1 parsed value. ASN.1 object is not constructed.");const a=i.result.valueBlock.value;o[e]=Array.from(a,e=>n.fromASN(e))}else o[e]=Array.from(t,e=>n.fromASN(e));else{let r=t;if(s.implicit){let e;if(Gt(a))e=(new a).toSchema("");else{const t=At[a],r=bt[t];if(!r)throw new Error(`Cannot get '${t}' class from asn1js module`);e=new r}e.valueBlock=r.valueBlock,r=z(e.toBER(!1)).result}o[e]=n.fromASN(r)}}else if(s.repeated){if(!Array.isArray(t))throw new Error("Cannot get list of items from the ASN.1 parsed value. ASN.1 value should be iterable.");o[e]=Array.from(t,e=>this.fromASN(e,a))}else o[e]=this.fromASN(t,a)}return o}catch(e){throw e instanceof Zt&&e.schemas.push(t.name),e}}}class er{static serialize(e){return e instanceof I?e.toBER(!1):this.toASN(e).toBER(!1)}static toASN(e){if(e&&"object"==typeof e&&Gt(e))return e.toASN();if(!e||"object"!=typeof e)throw new TypeError("Parameter 1 should be type of Object.");const t=e.constructor,r=Wt.get(t);Wt.cache(t);let n,s=[];if(r.itemType){if(!Array.isArray(e))throw new TypeError("Parameter 1 should be type of Array.");if("number"==typeof r.itemType){const n=Ft(r.itemType);if(!n)throw new Error(`Cannot get default converter for array item of ${t.name} ASN1 schema`);s=e.map(e=>n.toASN(e))}else s=e.map(e=>this.toAsnItem({type:r.itemType},"[]",t,e))}else for(const n in r.items){const i=r.items[n],o=e[n];if(void 0===o||i.defaultValue===o||"object"==typeof i.defaultValue&&"object"==typeof o&&qt(this.serialize(i.defaultValue),this.serialize(o)))continue;const a=er.toAsnItem(i,n,t,o);if("number"==typeof i.context)if(i.implicit)if(i.repeated||"number"!=typeof i.type&&!Gt(i.type))s.push(new _({optional:i.optional,idBlock:{tagClass:3,tagNumber:i.context},value:a.valueBlock.value}));else{const e={};e.valueHex=a instanceof Y?a.valueBeforeDecodeView:a.valueBlock.toBER(),s.push(new J({optional:i.optional,idBlock:{tagClass:3,tagNumber:i.context},...e}))}else s.push(new _({optional:i.optional,idBlock:{tagClass:3,tagNumber:i.context},value:[a]}));else i.repeated?s=s.concat(a):s.push(a)}switch(r.type){case vt.Sequence:n=new Je({value:s});break;case vt.Set:n=new je({value:s});break;case vt.Choice:if(!s[0])throw new Error(`Schema '${t.name}' has wrong data. Choice cannot be empty.`);n=s[0]}return n}static toAsnItem(e,t,r,n){let s;if("number"==typeof e.type){const i=e.converter;if(!i)throw new Error(`Property '${t}' doesn't have converter for type ${At[e.type]} in schema '${r.name}'`);if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(n,e=>i.toASN(e));s=new("sequence"===e.repeated?Je:je)({value:t})}else s=i.toASN(n)}else if(e.repeated){if(!Array.isArray(n))throw new TypeError("Parameter 'objProp' should be type of Array.");const t=Array.from(n,e=>this.toASN(e));s=new("sequence"===e.repeated?Je:je)({value:t})}else s=this.toASN(n);return s}}class tr{static serialize(e){return er.serialize(e)}static parse(e,t){return Qt.parse(e,t)}static toString(e){const t=z(o.BufferSourceConverter.isBufferSource(e)?o.BufferSourceConverter.toArrayBuffer(e):tr.serialize(e));if(-1===t.offset)throw new Error(`Cannot decode ASN.1 data. ${t.result.error}`);return t.result.toString()}}class rr extends Error{constructor(e,t){super(t?`${e}. See the inner exception for more details.`:e),this.message=e,this.innerError=t}}class nr extends rr{constructor(e,t,r){super(t,r),this.schema=e}}class sr extends nr{constructor(e,t,r){super(e,`JSON doesn't match to '${e.target.name}' schema. ${t}`,r)}}class ir extends rr{}class or extends rr{constructor(e,t,r){super(`Cannot serialize by '${e}' schema. ${t}`,r),this.schemaName=e}}class ar extends sr{constructor(e,t,r={}){super(e,"Some keys doesn't match to schema"),this.keys=t,this.errors=r}}var cr;function ur(e,t){if(!function(e,t){switch(t){case cr.Boolean:return"boolean"==typeof e;case cr.Number:return"number"==typeof e;case cr.String:return"string"==typeof e}return!0}(e,t))throw new TypeError(`Value must be ${cr[t]}`)}function lr(e){return e&&e.prototype?!(!e.prototype.toJSON||!e.prototype.fromJSON)||lr(e.prototype):!!(e&&e.toJSON&&e.fromJSON)}!function(e){e[e.Any=0]="Any",e[e.Boolean=1]="Boolean",e[e.Number=2]="Number",e[e.String=3]="String"}(cr||(cr={}));const hr="default",yr=new class{constructor(){this.items=new Map}has(e){return this.items.has(e)||!!this.findParentSchema(e)}get(e){const t=this.items.get(e)||this.findParentSchema(e);if(!t)throw new Error("Cannot get schema for current target");return t}create(e){const t={names:{}},r=this.findParentSchema(e);if(r){Object.assign(t,r),t.names={};for(const e in r.names)t.names[e]=Object.assign({},r.names[e])}return t.target=e,t}set(e,t){return this.items.set(e,t),this}findParentSchema(e){const t=e.__proto__;if(t){return this.items.get(t)||this.findParentSchema(t)}return null}};class fr{constructor(e){this.pattern=new RegExp(e)}validate(e){const t=new RegExp(this.pattern.source,this.pattern.flags);if("string"!=typeof e)throw new ir("Incoming value must be string");if(!t.exec(e))throw new ir(`Value doesn't match to pattern '${t.toString()}'`)}}class pr{constructor(e=Number.MIN_VALUE,t=Number.MAX_VALUE){this.min=e,this.max=t}validate(e){if(ur(e,cr.Number),!(this.min<=e&&e<=this.max)){const e=this.min===Number.MIN_VALUE?"MIN":this.min,t=this.max===Number.MAX_VALUE?"MAX":this.max;throw new ir(`Value doesn't match to diapason [${e},${t}]`)}}}class gr{constructor(e=Number.MIN_VALUE,t=Number.MAX_VALUE){this.min=e,this.max=t}validate(e){if(ur(e,cr.Number),!(this.min<e&&e<this.max)){const e=this.min===Number.MIN_VALUE?"MIN":this.min,t=this.max===Number.MAX_VALUE?"MAX":this.max;throw new ir(`Value doesn't match to diapason (${e},${t})`)}}}class mr{constructor(e,t,r){this.length=e,this.minLength=t,this.maxLength=r}validate(e){if(void 0===this.length){if(void 0!==this.minLength&&e.length<this.minLength)throw new ir(`Value length must be more than ${this.minLength}.`);if(void 0!==this.maxLength&&e.length>this.maxLength)throw new ir(`Value length must be less than ${this.maxLength}.`)}else if(e.length!==this.length)throw new ir(`Value length must be exactly ${this.length}.`)}}class dr{constructor(e){this.enumeration=e}validate(e){if(ur(e,cr.String),!this.enumeration.includes(e))throw new ir(`Value must be one of ${this.enumeration.map(e=>`'${e}'`).join(", ")}`)}}class wr{static checkValues(e,t){const r=Array.isArray(e)?e:[e];for(const n of r)for(const r of t.validations)r instanceof mr&&t.repeated?r.validate(e):r.validate(n)}static checkTypes(e,t){if(t.repeated&&!Array.isArray(e))throw new TypeError("Value must be Array");if("number"==typeof t.type){const r=Array.isArray(e)?e:[e];for(const e of r)ur(e,t.type)}}static getSchemaByName(e,t=hr){return{...e.names[hr],...e.names[t]}}}class vr extends wr{static serialize(e,t,r,n){const s=this.toJSON(e,t);return JSON.stringify(s,r,n)}static toJSON(e,t={}){let r,n=t.targetSchema;const s=t.schemaName||hr;if(lr(e))return e.toJSON();if(Array.isArray(e)){r=[];for(const n of e)r.push(this.toJSON(n,t))}else if("object"==typeof e){if(n&&!yr.has(n))throw new rr("Cannot get schema for `targetSchema` param");if(n=n||e.constructor,yr.has(n)){const t=yr.get(n);r={};const i=this.getSchemaByName(t,s);for(const o in i)try{const t=i[o],a=e[o];let c;if(t.optional&&void 0===a||void 0!==t.defaultValue&&a===t.defaultValue)continue;if(!t.optional&&void 0===a)throw new or(n.name,`Property '${o}' is required.`);c="number"==typeof t.type?t.converter?t.repeated?a.map(r=>t.converter.toJSON(r,e)):t.converter.toJSON(a,e):a:t.repeated?a.map(e=>this.toJSON(e,{schemaName:s})):this.toJSON(a,{schemaName:s}),this.checkTypes(c,t),this.checkValues(c,t),r[t.name||o]=c}catch(e){throw e instanceof or?e:new or(t.target.name,`Property '${o}' is wrong. ${e.message}`,e)}}else{r={};for(const t in e)r[t]=this.toJSON(e[t],{schemaName:s})}}else r=e;return r}}class Ar extends wr{static parse(e,t){const r=JSON.parse(e);return this.fromJSON(r,t)}static fromJSON(e,t){const r=t.targetSchema,n=t.schemaName||hr,s=new r;if(lr(s))return s.fromJSON(e);const i=yr.get(r),o=this.getSchemaByName(i,n),a={};t.strictProperty&&!Array.isArray(e)&&Ar.checkStrictProperty(e,o,i);for(const r in o)try{const a=o[r],c=a.name||r,u=e[c];if(void 0===u&&(a.optional||void 0!==a.defaultValue))continue;if(!a.optional&&void 0===u)throw new sr(i,`Property '${c}' is required.`);if(this.checkTypes(u,a),this.checkValues(u,a),"number"==typeof a.type)a.converter?a.repeated?s[r]=u.map(e=>a.converter.fromJSON(e,s)):s[r]=a.converter.fromJSON(u,s):s[r]=u;else{const e={...t,targetSchema:a.type,schemaName:n};a.repeated?s[r]=u.map(t=>this.fromJSON(t,e)):s[r]=this.fromJSON(u,e)}}catch(e){if(e instanceof sr||(e=new sr(i,`Property '${r}' is wrong. ${e.message}`,e)),!t.strictAllKeys)throw e;a[r]=e}const c=Object.keys(a);if(c.length)throw new ar(i,c,a);return s}static checkStrictProperty(e,t,r){const n=Object.keys(e),s=Object.keys(t),i=[];for(const e of n)-1===s.indexOf(e)&&i.push(e);if(i.length)throw new ar(r,i)}}const br=(e={})=>(t,r)=>{const n=`Cannot set type for ${r} property of ${t.constructor.name} schema`;let s;yr.has(t.constructor)?(s=yr.get(t.constructor),s.target!==t.constructor&&(s=yr.create(t.constructor),yr.set(t.constructor,s))):(s=yr.create(t.constructor),yr.set(t.constructor,s));const i={type:cr.Any,validations:[]},o=Object.assign(i,e);if(o.validations=function(e){const t=[];return e.pattern&&t.push(new fr(e.pattern)),e.type!==cr.Number&&e.type!==cr.Any||(void 0===e.minInclusive&&void 0===e.maxInclusive||t.push(new pr(e.minInclusive,e.maxInclusive)),void 0===e.minExclusive&&void 0===e.maxExclusive||t.push(new gr(e.minExclusive,e.maxExclusive)),void 0!==e.enumeration&&t.push(new dr(e.enumeration))),(e.type===cr.String||e.repeated||e.type===cr.Any)&&(void 0===e.length&&void 0===e.minLength&&void 0===e.maxLength||t.push(new mr(e.length,e.minLength,e.maxLength))),t}(o),"number"!=typeof o.type&&!yr.has(o.type)&&!lr(o.type))throw new Error(`${n}. Assigning type doesn't have schema.`);let a;a=Array.isArray(e.schema)?e.schema:[e.schema||hr];for(const e of a){s.names[e]||(s.names[e]={});s.names[e][r]=o}};
|
|
38
|
-
/*!
|
|
39
|
-
Copyright (c) Peculiar Ventures, LLC
|
|
40
|
-
*/class kr extends Error{}class Sr extends kr{}class Br extends kr{constructor(e){super("Unsupported operation: "+(e?`${e}`:""))}}class Er extends kr{}class Kr extends kr{constructor(e){super(`${e}: Missing required property`)}}class Cr{static toArrayBuffer(e){const t=e.replace(/-{5}(BEGIN|END) .*-{5}/g,"").replace("\r","").replace("\n","");return o.Convert.FromBase64(t)}static toUint8Array(e){const t=this.toArrayBuffer(e);return new Uint8Array(t)}static fromBufferSource(e,t){const r=o.Convert.ToBase64(e);let n,s=0;const i=[];for(;s<r.length&&(n=r.slice(s,s+64),n.length);)i.push(n),s+=64;const a=t.toUpperCase();return`-----BEGIN ${a}-----\n${i.join("\n")}\n-----END ${a}-----`}static isPEM(e){return/-----BEGIN .+-----[A-Za-z0-9+/+=\s\n]+-----END .+-----/i.test(e)}static getTagName(e){if(!this.isPEM(e))throw new Error("Bad parameter. Incoming data is not right PEM");const t=/-----BEGIN (.+)-----/.exec(e);if(!t)throw new Error("Cannot get tag from PEM");return t[1]}static hasTagName(e,t){const r=this.getTagName(e);return t.toLowerCase()===r.toLowerCase()}static isCertificate(e){return this.hasTagName(e,"certificate")}static isCertificateRequest(e){return this.hasTagName(e,"certificate request")}static isCRL(e){return this.hasTagName(e,"x509 crl")}static isPublicKey(e){return this.hasTagName(e,"public key")}}class xr{async digest(...e){return this.checkDigest.apply(this,e),this.onDigest.apply(this,e)}checkDigest(e,t){this.checkAlgorithmName(e)}async onDigest(e,t){throw new Br("digest")}async generateKey(...e){return this.checkGenerateKey.apply(this,e),this.onGenerateKey.apply(this,e)}checkGenerateKey(e,t,r,...n){if(this.checkAlgorithmName(e),this.checkGenerateKeyParams(e),!r||!r.length)throw new TypeError("Usages cannot be empty when creating a key.");let s;s=Array.isArray(this.usages)?this.usages:this.usages.privateKey.concat(this.usages.publicKey),this.checkKeyUsages(r,s)}checkGenerateKeyParams(e){}async onGenerateKey(e,t,r,...n){throw new Br("generateKey")}async sign(...e){return this.checkSign.apply(this,e),this.onSign.apply(this,e)}checkSign(e,t,r,...n){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,"sign")}async onSign(e,t,r,...n){throw new Br("sign")}async verify(...e){return this.checkVerify.apply(this,e),this.onVerify.apply(this,e)}checkVerify(e,t,r,n,...s){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,"verify")}async onVerify(e,t,r,n,...s){throw new Br("verify")}async encrypt(...e){return this.checkEncrypt.apply(this,e),this.onEncrypt.apply(this,e)}checkEncrypt(e,t,r,n={},...s){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,n.keyUsage?"encrypt":void 0)}async onEncrypt(e,t,r,...n){throw new Br("encrypt")}async decrypt(...e){return this.checkDecrypt.apply(this,e),this.onDecrypt.apply(this,e)}checkDecrypt(e,t,r,n={},...s){this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,n.keyUsage?"decrypt":void 0)}async onDecrypt(e,t,r,...n){throw new Br("decrypt")}async deriveBits(...e){return this.checkDeriveBits.apply(this,e),this.onDeriveBits.apply(this,e)}checkDeriveBits(e,t,r,n={},...s){if(this.checkAlgorithmName(e),this.checkAlgorithmParams(e),this.checkCryptoKey(t,n.keyUsage?"deriveBits":void 0),r%8!=0)throw new Er("length: Is not multiple of 8")}async onDeriveBits(e,t,r,...n){throw new Br("deriveBits")}async exportKey(...e){return this.checkExportKey.apply(this,e),this.onExportKey.apply(this,e)}checkExportKey(e,t,...r){if(this.checkKeyFormat(e),this.checkCryptoKey(t),!t.extractable)throw new kr("key: Is not extractable")}async onExportKey(e,t,...r){throw new Br("exportKey")}async importKey(...e){return this.checkImportKey.apply(this,e),this.onImportKey.apply(this,e)}checkImportKey(e,t,r,n,s,...i){this.checkKeyFormat(e),this.checkKeyData(e,t),this.checkAlgorithmName(r),this.checkImportParams(r),Array.isArray(this.usages)&&this.checkKeyUsages(s,this.usages)}async onImportKey(e,t,r,n,s,...i){throw new Br("importKey")}checkAlgorithmName(e){if(e.name.toLowerCase()!==this.name.toLowerCase())throw new Sr("Unrecognized name")}checkAlgorithmParams(e){}checkDerivedKeyParams(e){}checkKeyUsages(e,t){for(const r of e)if(-1===t.indexOf(r))throw new TypeError("Cannot create a key using the specified key usages")}checkCryptoKey(e,t){if(this.checkAlgorithmName(e.algorithm),t&&-1===e.usages.indexOf(t))throw new kr("key does not match that of operation")}checkRequiredProperty(e,t){if(!(t in e))throw new Kr(t)}checkHashAlgorithm(e,t){for(const r of t)if(r.toLowerCase()===e.name.toLowerCase())return;throw new Er(`hash: Must be one of ${t.join(", ")}`)}checkImportParams(e){}checkKeyFormat(e){switch(e){case"raw":case"pkcs8":case"spki":case"jwk":break;default:throw new TypeError("format: Is invalid value. Must be 'jwk', 'raw', 'spki', or 'pkcs8'")}}checkKeyData(e,t){if(!t)throw new TypeError("keyData: Cannot be empty on empty on key importing");if("jwk"===e){if("object"!=typeof(r=t)||!("kty"in r))throw new TypeError("keyData: Is not JsonWebToken")}else if(!o.BufferSourceConverter.isBufferSource(t))throw new TypeError("keyData: Is not ArrayBufferView or ArrayBuffer");var r}prepareData(e){return o.BufferSourceConverter.toArrayBuffer(e)}}class Nr extends xr{checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"length"),"number"!=typeof e.length)throw new TypeError("length: Is not of type Number");switch(e.length){case 128:case 192:case 256:break;default:throw new TypeError("length: Must be 128, 192, or 256")}}checkDerivedKeyParams(e){this.checkGenerateKeyParams(e)}}let Ur=class extends Nr{constructor(){super(...arguments),this.name="AES-CBC",this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"iv"),!(e.iv instanceof ArrayBuffer||ArrayBuffer.isView(e.iv)))throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(16!==e.iv.byteLength)throw new TypeError("iv: Must have length 16 bytes")}},Pr=class extends Nr{constructor(){super(...arguments),this.name="AES-CMAC",this.usages=["sign","verify"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"length"),"number"!=typeof e.length)throw new TypeError("length: Is not a Number");if(e.length<1)throw new Er("length: Must be more than 0")}},Ir=class extends Nr{constructor(){super(...arguments),this.name="AES-CTR",this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"counter"),!(e.counter instanceof ArrayBuffer||ArrayBuffer.isView(e.counter)))throw new TypeError("counter: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(16!==e.counter.byteLength)throw new TypeError("iv: Must have length 16 bytes");if(this.checkRequiredProperty(e,"length"),"number"!=typeof e.length)throw new TypeError("length: Is not a Number");if(e.length<1)throw new Er("length: Must be more than 0")}},Or=class extends Nr{constructor(){super(...arguments),this.name="AES-ECB",this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}},Hr=class extends Nr{constructor(){super(...arguments),this.name="AES-GCM",this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}checkAlgorithmParams(e){var t;if(this.checkRequiredProperty(e,"iv"),!(e.iv instanceof ArrayBuffer||ArrayBuffer.isView(e.iv)))throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(e.iv.byteLength<1)throw new Er("iv: Must have length more than 0 and less than 2^64 - 1");switch(null!==(t=e.tagLength)&&void 0!==t||(e.tagLength=128),e.tagLength){case 32:case 64:case 96:case 104:case 112:case 120:case 128:break;default:throw new Er("tagLength: Must be one of 32, 64, 96, 104, 112, 120 or 128")}}},Tr=class extends Nr{constructor(){super(...arguments),this.name="AES-KW",this.usages=["wrapKey","unwrapKey"]}};class Lr extends xr{constructor(){super(...arguments),this.usages=["encrypt","decrypt","wrapKey","unwrapKey"]}checkAlgorithmParams(e){if(this.ivSize){if(this.checkRequiredProperty(e,"iv"),!(e.iv instanceof ArrayBuffer||ArrayBuffer.isView(e.iv)))throw new TypeError("iv: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(e.iv.byteLength!==this.ivSize)throw new TypeError(`iv: Must have length ${this.ivSize} bytes`)}}checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"length"),"number"!=typeof e.length)throw new TypeError("length: Is not of type Number");if(e.length!==this.keySizeBits)throw new Er(`algorithm.length: Must be ${this.keySizeBits}`)}checkDerivedKeyParams(e){this.checkGenerateKeyParams(e)}}class Dr extends xr{constructor(){super(...arguments),this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"]}checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms),this.checkRequiredProperty(e,"publicExponent"),!(e.publicExponent&&e.publicExponent instanceof Uint8Array))throw new TypeError("publicExponent: Missing or not a Uint8Array");const t=o.Convert.ToBase64(e.publicExponent);if("Aw=="!==t&&"AQAB"!==t)throw new TypeError("publicExponent: Must be [3] or [1,0,1]");if(this.checkRequiredProperty(e,"modulusLength"),e.modulusLength%8||e.modulusLength<256||e.modulusLength>16384)throw new TypeError("The modulus length must be a multiple of 8 bits and >= 256 and <= 16384")}checkImportParams(e){this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms)}}let Vr=class extends Dr{constructor(){super(...arguments),this.name="RSASSA-PKCS1-v1_5",this.usages={privateKey:["sign"],publicKey:["verify"]}}},Rr=class extends Dr{constructor(){super(...arguments),this.name="RSA-PSS",this.usages={privateKey:["sign"],publicKey:["verify"]}}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"saltLength"),"number"!=typeof e.saltLength)throw new TypeError("saltLength: Is not a Number");if(e.saltLength<0)throw new RangeError("saltLength: Must be positive number")}},Mr=class extends Dr{constructor(){super(...arguments),this.name="RSA-OAEP",this.usages={privateKey:["decrypt","unwrapKey"],publicKey:["encrypt","wrapKey"]}}checkAlgorithmParams(e){if(e.label&&!(e.label instanceof ArrayBuffer||ArrayBuffer.isView(e.label)))throw new TypeError("label: Is not of type '(ArrayBuffer or ArrayBufferView)'")}};class $r extends xr{checkGenerateKeyParams(e){this.checkRequiredProperty(e,"namedCurve"),this.checkNamedCurve(e.namedCurve)}checkNamedCurve(e){for(const t of this.namedCurves)if(t.toLowerCase()===e.toLowerCase())return;throw new Er(`namedCurve: Must be one of ${this.namedCurves.join(", ")}`)}}let Jr=class extends $r{constructor(){super(...arguments),this.name="ECDSA",this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],this.usages={privateKey:["sign"],publicKey:["verify"]},this.namedCurves=["P-256","P-384","P-521","K-256"]}checkAlgorithmParams(e){this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms)}};const jr=["secret","private","public"];let zr=class{static create(e,t,r,n){const s=new this;return s.algorithm=e,s.type=t,s.extractable=r,s.usages=n,s}static isKeyType(e){return-1!==jr.indexOf(e)}get[Symbol.toStringTag](){return"CryptoKey"}},Fr=class extends $r{constructor(){super(...arguments),this.name="ECDH",this.usages={privateKey:["deriveBits","deriveKey"],publicKey:[]},this.namedCurves=["P-256","P-384","P-521","K-256"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"public"),!(e.public instanceof zr))throw new TypeError("public: Is not a CryptoKey");if("public"!==e.public.type)throw new Er("public: Is not a public key");if(e.public.algorithm.name!==this.name)throw new Er(`public: Is not ${this.name} key`)}},Gr=class extends Fr{constructor(){super(...arguments),this.name="ECDH-ES",this.namedCurves=["X25519","X448"]}},_r=class extends $r{constructor(){super(...arguments),this.name="EdDSA",this.usages={privateKey:["sign"],publicKey:["verify"]},this.namedCurves=["Ed25519","Ed448"]}},qr=class{constructor(e){e&&(this.value=e)}};r([Xt({type:At.ObjectIdentifier})],qr.prototype,"value",void 0),qr=r([Yt({type:vt.Choice})],qr);class Wr{constructor(e){Object.assign(this,e)}}r([Xt({type:At.ObjectIdentifier})],Wr.prototype,"algorithm",void 0),r([Xt({type:At.Any,optional:!0})],Wr.prototype,"parameters",void 0);class Yr{constructor(){this.version=0,this.privateKeyAlgorithm=new Wr,this.privateKey=new ArrayBuffer(0)}}r([Xt({type:At.Integer})],Yr.prototype,"version",void 0),r([Xt({type:Wr})],Yr.prototype,"privateKeyAlgorithm",void 0),r([Xt({type:At.OctetString})],Yr.prototype,"privateKey",void 0),r([Xt({type:At.Any,optional:!0})],Yr.prototype,"attributes",void 0);class Xr{constructor(){this.publicKeyAlgorithm=new Wr,this.publicKey=new ArrayBuffer(0)}}r([Xt({type:Wr})],Xr.prototype,"publicKeyAlgorithm",void 0),r([Xt({type:At.BitString})],Xr.prototype,"publicKey",void 0);const Zr={fromJSON:e=>o.Convert.FromBase64Url(e),toJSON:e=>o.Convert.ToBase64Url(new Uint8Array(e))},Qr={fromASN:e=>{const t=e.valueBlock.valueHex;return new Uint8Array(t)[0]?e.valueBlock.valueHex:e.valueBlock.valueHex.slice(1)},toASN:e=>{const t=new Uint8Array(e)[0]>127?o.combine(new Uint8Array([0]).buffer,e):e;return new ye({valueHex:t})}};let en=class{constructor(){this.version=0,this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0),this.privateExponent=new ArrayBuffer(0),this.prime1=new ArrayBuffer(0),this.prime2=new ArrayBuffer(0),this.exponent1=new ArrayBuffer(0),this.exponent2=new ArrayBuffer(0),this.coefficient=new ArrayBuffer(0)}};r([Xt({type:At.Integer,converter:St})],en.prototype,"version",void 0),r([Xt({type:At.Integer,converter:Qr}),br({name:"n",converter:Zr})],en.prototype,"modulus",void 0),r([Xt({type:At.Integer,converter:Qr}),br({name:"e",converter:Zr})],en.prototype,"publicExponent",void 0),r([Xt({type:At.Integer,converter:Qr}),br({name:"d",converter:Zr})],en.prototype,"privateExponent",void 0),r([Xt({type:At.Integer,converter:Qr}),br({name:"p",converter:Zr})],en.prototype,"prime1",void 0),r([Xt({type:At.Integer,converter:Qr}),br({name:"q",converter:Zr})],en.prototype,"prime2",void 0),r([Xt({type:At.Integer,converter:Qr}),br({name:"dp",converter:Zr})],en.prototype,"exponent1",void 0),r([Xt({type:At.Integer,converter:Qr}),br({name:"dq",converter:Zr})],en.prototype,"exponent2",void 0),r([Xt({type:At.Integer,converter:Qr}),br({name:"qi",converter:Zr})],en.prototype,"coefficient",void 0),r([Xt({type:At.Any,optional:!0})],en.prototype,"otherPrimeInfos",void 0);let tn=class{constructor(){this.modulus=new ArrayBuffer(0),this.publicExponent=new ArrayBuffer(0)}};r([Xt({type:At.Integer,converter:Qr}),br({name:"n",converter:Zr})],tn.prototype,"modulus",void 0),r([Xt({type:At.Integer,converter:Qr}),br({name:"e",converter:Zr})],tn.prototype,"publicExponent",void 0);let rn=class{constructor(e){this.value=new ArrayBuffer(0),e&&(this.value=e)}toJSON(){let e=new Uint8Array(this.value);if(4!==e[0])throw new kr("Wrong ECPoint. Current version supports only Uncompressed (0x04) point");e=new Uint8Array(this.value.slice(1));const t=e.length/2;return{x:o.Convert.ToBase64Url(e.buffer.slice(0,0+t)),y:o.Convert.ToBase64Url(e.buffer.slice(0+t,0+t+t))}}fromJSON(e){if(!("x"in e))throw new Error("x: Missing required property");if(!("y"in e))throw new Error("y: Missing required property");const t=o.Convert.FromBase64Url(e.x),r=o.Convert.FromBase64Url(e.y),n=o.combine(new Uint8Array([4]).buffer,t,r);return this.value=new Uint8Array(n).buffer,this}};r([Xt({type:At.OctetString})],rn.prototype,"value",void 0),rn=r([Yt({type:vt.Choice})],rn);let nn=class{constructor(){this.version=1,this.privateKey=new ArrayBuffer(0)}fromJSON(e){if(!("d"in e))throw new Error("d: Missing required property");if(this.privateKey=o.Convert.FromBase64Url(e.d),"x"in e){const t=new rn;t.fromJSON(e);const r=er.toASN(t);"valueHex"in r.valueBlock&&(this.publicKey=r.valueBlock.valueHex)}return this}toJSON(){const e={};return e.d=o.Convert.ToBase64Url(this.privateKey),this.publicKey&&Object.assign(e,new rn(this.publicKey).toJSON()),e}};r([Xt({type:At.Integer,converter:St})],nn.prototype,"version",void 0),r([Xt({type:At.OctetString})],nn.prototype,"privateKey",void 0),r([Xt({context:0,type:At.Any,optional:!0})],nn.prototype,"parameters",void 0),r([Xt({context:1,type:At.BitString,optional:!0})],nn.prototype,"publicKey",void 0);const sn={fromASN:e=>{const t=new Uint8Array(e.valueBlock.valueHex);return 0===t[0]?t.buffer.slice(1):t.buffer},toASN:e=>{const t=new Uint8Array(e);if(t[0]>127){const e=new Uint8Array(t.length+1);return e.set(t,1),new ye({valueHex:e.buffer})}return new ye({valueHex:e})}};var on=Object.freeze({__proto__:null,AsnIntegerWithoutPaddingConverter:sn});class an{static decodePoint(e,t){const r=o.BufferSourceConverter.toUint8Array(e);if(0===r.length||4!==r[0])throw new Error("Only uncompressed point format supported");const n=(r.length-1)/2;if(n!==Math.ceil(t/8))throw new Error("Point does not match field size");return{x:r.slice(1,n+1),y:r.slice(n+1,n+1+n)}}static encodePoint(e,t){const r=Math.ceil(t/8);if(e.x.byteLength!==r||e.y.byteLength!==r)throw new Error("X,Y coordinates don't match point size criteria");const n=o.BufferSourceConverter.toUint8Array(e.x),s=o.BufferSourceConverter.toUint8Array(e.y),i=new Uint8Array(2*r+1);return i[0]=4,i.set(n,1),i.set(s,r+1),i}static getSize(e){return Math.ceil(e/8)}static encodeSignature(e,t){const r=this.getSize(t),n=o.BufferSourceConverter.toUint8Array(e.r),s=o.BufferSourceConverter.toUint8Array(e.s),i=new Uint8Array(2*r);return i.set(this.padStart(n,r)),i.set(this.padStart(s,r),r),i}static decodeSignature(e,t){const r=this.getSize(t),n=o.BufferSourceConverter.toUint8Array(e);if(n.length!==2*r)throw new Error("Incorrect size of the signature");const s=n.slice(0,r),i=n.slice(r);return{r:this.trimStart(s),s:this.trimStart(i)}}static trimStart(e){let t=0;for(;t<e.length-1&&0===e[t];)t++;return 0===t?e:e.slice(t,e.length)}static padStart(e,t){if(t===e.length)return e;const r=new Uint8Array(t);return r.set(e,t-e.length),r}}class cn{constructor(){this.r=new ArrayBuffer(0),this.s=new ArrayBuffer(0)}static fromWebCryptoSignature(e){const t=e.byteLength/2,r=an.decodeSignature(e,8*t),n=new cn;return n.r=o.BufferSourceConverter.toArrayBuffer(r.r),n.s=o.BufferSourceConverter.toArrayBuffer(r.s),n}toWebCryptoSignature(e){if(!e){const t=Math.max(this.r.byteLength,this.s.byteLength);e=t<=32?256:t<=48?384:521}return an.encodeSignature(this,e).buffer}}r([Xt({type:At.Integer,converter:sn})],cn.prototype,"r",void 0),r([Xt({type:At.Integer,converter:sn})],cn.prototype,"s",void 0);class un extends Yr{}r([Xt({context:1,implicit:!0,type:At.BitString,optional:!0})],un.prototype,"publicKey",void 0);let ln=class{constructor(){this.value=new ArrayBuffer(0)}fromJSON(e){if(!e.d)throw new Error("d: Missing required property");return this.value=o.Convert.FromBase64Url(e.d),this}toJSON(){return{d:o.Convert.ToBase64Url(this.value)}}};r([Xt({type:At.OctetString})],ln.prototype,"value",void 0),ln=r([Yt({type:vt.Choice})],ln);let hn=class{constructor(e){this.value=new ArrayBuffer(0),e&&(this.value=e)}toJSON(){return{x:o.Convert.ToBase64Url(this.value)}}fromJSON(e){if(!("x"in e))throw new Error("x: Missing required property");return this.value=o.Convert.FromBase64Url(e.x),this}};r([Xt({type:At.BitString})],hn.prototype,"value",void 0),hn=r([Yt({type:vt.Choice})],hn);let yn=class{};r([Xt({type:At.OctetString}),br({type:cr.String,converter:Zr})],yn.prototype,"d",void 0),yn=r([Yt({type:vt.Choice})],yn);const fn="1.2.840.10045.3.1.7",pn="1.3.132.0",gn=`${pn}.34`,mn=`${pn}.35`,dn=`${pn}.10`,wn="1.3.36.3.3.2.8.1.1",vn=`${wn}.1`,An=`${wn}.2`,bn=`${wn}.3`,kn=`${wn}.4`,Sn=`${wn}.5`,Bn=`${wn}.6`,En=`${wn}.7`,Kn=`${wn}.8`,Cn=`${wn}.9`,xn=`${wn}.10`,Nn=`${wn}.11`,Un=`${wn}.12`,Pn=`${wn}.13`,In=`${wn}.14`;var On=Object.freeze({__proto__:null,AlgorithmIdentifier:Wr,get CurvePrivateKey(){return yn},EcDsaSignature:cn,EcPrivateKey:nn,get EcPublicKey(){return rn},get EdPrivateKey(){return ln},get EdPublicKey(){return hn},get ObjectIdentifier(){return qr},OneAsymmetricKey:un,PrivateKeyInfo:Yr,PublicKeyInfo:Xr,RsaPrivateKey:en,RsaPublicKey:tn,converters:on,idBrainpoolP160r1:vn,idBrainpoolP160t1:An,idBrainpoolP192r1:bn,idBrainpoolP192t1:kn,idBrainpoolP224r1:Sn,idBrainpoolP224t1:Bn,idBrainpoolP256r1:En,idBrainpoolP256t1:Kn,idBrainpoolP320r1:Cn,idBrainpoolP320t1:xn,idBrainpoolP384r1:Nn,idBrainpoolP384t1:Un,idBrainpoolP512r1:Pn,idBrainpoolP512t1:In,idEd25519:"1.3.101.112",idEd448:"1.3.101.113",idEllipticCurve:pn,idSecp256k1:dn,idSecp256r1:fn,idSecp384r1:gn,idSecp521r1:mn,idVersionOne:wn,idX25519:"1.3.101.110",idX448:"1.3.101.111"});class Hn{constructor(){}static register(e){const t=new qr;t.value=e.id;const r=tr.serialize(t);this.items.push({...e,raw:r}),this.names.push(e.name)}static find(e){e=e.toUpperCase();for(const t of this.items)if(t.name.toUpperCase()===e||t.id.toUpperCase()===e)return t;return null}static get(e){const t=this.find(e);if(!t)throw new Error(`Unsupported EC named curve '${e}'`);return t}}Hn.items=[],Hn.names=[],Hn.register({name:"P-256",id:fn,size:256}),Hn.register({name:"P-384",id:gn,size:384}),Hn.register({name:"P-521",id:mn,size:521}),Hn.register({name:"K-256",id:dn,size:256}),Hn.register({name:"brainpoolP160r1",id:vn,size:160}),Hn.register({name:"brainpoolP160t1",id:An,size:160}),Hn.register({name:"brainpoolP192r1",id:bn,size:192}),Hn.register({name:"brainpoolP192t1",id:kn,size:192}),Hn.register({name:"brainpoolP224r1",id:Sn,size:224}),Hn.register({name:"brainpoolP224t1",id:Bn,size:224}),Hn.register({name:"brainpoolP256r1",id:En,size:256}),Hn.register({name:"brainpoolP256t1",id:Kn,size:256}),Hn.register({name:"brainpoolP320r1",id:Cn,size:320}),Hn.register({name:"brainpoolP320t1",id:xn,size:320}),Hn.register({name:"brainpoolP384r1",id:Nn,size:384}),Hn.register({name:"brainpoolP384t1",id:Un,size:384}),Hn.register({name:"brainpoolP512r1",id:Pn,size:512}),Hn.register({name:"brainpoolP512t1",id:In,size:512});let Tn=class extends xr{constructor(){super(...arguments),this.name="X25519",this.usages={privateKey:["deriveKey","deriveBits"],publicKey:[]}}checkAlgorithmParams(e){this.checkRequiredProperty(e,"public")}},Ln=class extends xr{constructor(){super(...arguments),this.name="Ed25519",this.usages={privateKey:["sign"],publicKey:["verify"]}}},Dn=class extends xr{constructor(){super(...arguments),this.name="HMAC",this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],this.usages=["sign","verify"]}getDefaultLength(e){switch(e.toUpperCase()){case"SHA-1":case"SHA-256":case"SHA-384":case"SHA-512":return 512;default:throw new Error(`Unknown algorithm name '${e}'`)}}checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms),"length"in e){if("number"!=typeof e.length)throw new TypeError("length: Is not a Number");if(e.length<1)throw new RangeError("length: Number is out of range")}}checkImportParams(e){this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms)}},Vn=class extends xr{constructor(){super(...arguments),this.name="PBKDF2",this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],this.usages=["deriveBits","deriveKey"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms),this.checkRequiredProperty(e,"salt"),!(e.salt instanceof ArrayBuffer||ArrayBuffer.isView(e.salt)))throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(this.checkRequiredProperty(e,"iterations"),"number"!=typeof e.iterations)throw new TypeError("iterations: Is not a Number");if(e.iterations<1)throw new TypeError("iterations: Is less than 1")}checkImportKey(e,t,r,n,s,...i){if(super.checkImportKey(e,t,r,n,s,...i),n)throw new SyntaxError("extractable: Must be 'false'")}},Rn=class extends xr{constructor(){super(...arguments),this.name="HKDF",this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512"],this.usages=["deriveKey","deriveBits"]}checkAlgorithmParams(e){if(this.checkRequiredProperty(e,"hash"),this.checkHashAlgorithm(e.hash,this.hashAlgorithms),this.checkRequiredProperty(e,"salt"),!o.BufferSourceConverter.isBufferSource(e.salt))throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'");if(this.checkRequiredProperty(e,"info"),!o.BufferSourceConverter.isBufferSource(e.info))throw new TypeError("salt: Is not of type '(ArrayBuffer or ArrayBufferView)'")}checkImportKey(e,t,r,n,s,...i){if(super.checkImportKey(e,t,r,n,s,...i),n)throw new SyntaxError("extractable: Must be 'false'")}};class Mn extends xr{constructor(){super(...arguments),this.usages=[],this.defaultLength=0}digest(...e){return e[0]={length:this.defaultLength,...e[0]},super.digest.apply(this,e)}checkDigest(e,t){super.checkDigest(e,t);const r=e.length||0;if("number"!=typeof r)throw new TypeError("length: Is not a Number");if(r<0)throw new TypeError("length: Is negative")}}let $n=class extends Mn{constructor(){super(...arguments),this.name="shake128",this.defaultLength=16}},Jn=class extends Mn{constructor(){super(...arguments),this.name="shake256",this.defaultLength=32}},jn=class{get[Symbol.toStringTag](){return"Crypto"}randomUUID(){const e=this.getRandomValues(new Uint8Array(16));e[6]=15&e[6]|64,e[8]=63&e[8]|128;const t=o.Convert.ToHex(e).toLowerCase();return`${t.substring(0,8)}-${t.substring(8,12)}-${t.substring(12,16)}-${t.substring(16,20)}-${t.substring(20)}`}};class zn{constructor(){this.items={}}get(e){return this.items[e.toLowerCase()]||null}set(e){this.items[e.name.toLowerCase()]=e}removeAt(e){const t=this.get(e.toLowerCase());return t&&delete this.items[e],t}has(e){return!!this.get(e)}get length(){return Object.keys(this.items).length}get algorithms(){const e=[];for(const t in this.items){const r=this.items[t];e.push(r.name)}return e.sort()}}const Fn={jwk:["private","public","secret"],pkcs8:["private"],spki:["public"],raw:["secret","public"]},Gn=["pkcs8","spki","raw"];let _n=class e{constructor(){this.providers=new zn}static isHashedAlgorithm(e){return!!(e&&"object"==typeof e&&"name"in e&&"hash"in e)}get[Symbol.toStringTag](){return"SubtleCrypto"}async digest(...e){this.checkRequiredArguments(e,2,"digest");const[t,r,...n]=e,s=this.prepareAlgorithm(t),i=o.BufferSourceConverter.toArrayBuffer(r),a=this.getProvider(s.name);return await a.digest(s,i,...n)}async generateKey(...e){this.checkRequiredArguments(e,3,"generateKey");const[t,r,n,...s]=e,i=this.prepareAlgorithm(t),o=this.getProvider(i.name);return await o.generateKey({...i,name:o.name},r,n,...s)}async sign(...e){this.checkRequiredArguments(e,3,"sign");const[t,r,n,...s]=e;this.checkCryptoKey(r);const i=this.prepareAlgorithm(t),a=o.BufferSourceConverter.toArrayBuffer(n),c=this.getProvider(i.name);return await c.sign({...i,name:c.name},r,a,...s)}async verify(...e){this.checkRequiredArguments(e,4,"verify");const[t,r,n,s,...i]=e;this.checkCryptoKey(r);const a=this.prepareAlgorithm(t),c=o.BufferSourceConverter.toArrayBuffer(s),u=o.BufferSourceConverter.toArrayBuffer(n),l=this.getProvider(a.name);return await l.verify({...a,name:l.name},r,u,c,...i)}async encrypt(...e){this.checkRequiredArguments(e,3,"encrypt");const[t,r,n,...s]=e;this.checkCryptoKey(r);const i=this.prepareAlgorithm(t),a=o.BufferSourceConverter.toArrayBuffer(n),c=this.getProvider(i.name);return await c.encrypt({...i,name:c.name},r,a,{keyUsage:!0},...s)}async decrypt(...e){this.checkRequiredArguments(e,3,"decrypt");const[t,r,n,...s]=e;this.checkCryptoKey(r);const i=this.prepareAlgorithm(t),a=o.BufferSourceConverter.toArrayBuffer(n),c=this.getProvider(i.name);return await c.decrypt({...i,name:c.name},r,a,{keyUsage:!0},...s)}async deriveBits(...e){this.checkRequiredArguments(e,3,"deriveBits");const[t,r,n,...s]=e;this.checkCryptoKey(r);const i=this.prepareAlgorithm(t),o=this.getProvider(i.name);return await o.deriveBits({...i,name:o.name},r,n,{keyUsage:!0},...s)}async deriveKey(...e){this.checkRequiredArguments(e,5,"deriveKey");const[t,r,n,s,i,...o]=e,a=this.prepareAlgorithm(n);this.getProvider(a.name).checkDerivedKeyParams(a);const c=this.prepareAlgorithm(t),u=this.getProvider(c.name);u.checkCryptoKey(r,"deriveKey");const l=await u.deriveBits({...c,name:u.name},r,n.length||512,{keyUsage:!1},...o);return this.importKey("raw",l,n,s,i,...o)}async exportKey(...e){this.checkRequiredArguments(e,2,"exportKey");const[t,r,...n]=e;if(this.checkCryptoKey(r),!Fn[t])throw new TypeError("Invalid keyFormat argument");if(!Fn[t].includes(r.type))throw new DOMException("The key is not of the expected type");const s=this.getProvider(r.algorithm.name);return await s.exportKey(t,r,...n)}async importKey(...e){this.checkRequiredArguments(e,5,"importKey");const[t,r,n,s,i,...a]=e,c=this.prepareAlgorithm(n),u=this.getProvider(c.name);if("jwk"===t){if("object"!=typeof r||!r.kty)throw new TypeError("Key data must be an object for JWK import")}else{if(!Gn.includes(t))throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView or JsonWebKey)'");if(!o.BufferSourceConverter.isBufferSource(r))throw new TypeError("Key data must be a BufferSource for non-JWK formats")}return u.importKey(t,r,{...c,name:u.name},s,i,...a)}async wrapKey(e,t,r,n,...s){let i=await this.exportKey(e,t,...s);if("jwk"===e){const e=JSON.stringify(i);i=o.Convert.FromUtf8String(e)}const a=this.prepareAlgorithm(n),c=o.BufferSourceConverter.toArrayBuffer(i),u=this.getProvider(a.name);return u.encrypt({...a,name:u.name},r,c,{keyUsage:!1},...s)}async unwrapKey(e,t,r,n,s,i,a,...c){const u=this.prepareAlgorithm(n),l=o.BufferSourceConverter.toArrayBuffer(t),h=this.getProvider(u.name);let y=await h.decrypt({...u,name:h.name},r,l,{keyUsage:!1},...c);if("jwk"===e)try{y=JSON.parse(o.Convert.ToUtf8String(y))}catch(e){const t=new TypeError("wrappedKey: Is not a JSON");throw t.internal=e,t}return this.importKey(e,y,s,i,a,...c)}checkRequiredArguments(e,t,r){if(e.length<t)throw new TypeError(`Failed to execute '${r}' on 'SubtleCrypto': ${t} arguments required, but only ${e.length} present`)}prepareAlgorithm(t){if("string"==typeof t)return{name:t};if(e.isHashedAlgorithm(t)){const e={...t};return e.hash=this.prepareAlgorithm(t.hash),e}return{...t}}getProvider(e){const t=this.providers.get(e);if(!t)throw new Sr("Unrecognized name");return t}checkCryptoKey(e){if(!(e instanceof zr))throw new TypeError("Key is not of type 'CryptoKey'")}};const qn={fromJSON:t=>e.from(o.Convert.FromBase64Url(t)),toJSON:e=>o.Convert.ToBase64Url(e)};class Wn extends zr{constructor(){super(...arguments),this.data=e.alloc(0),this.algorithm={name:""},this.extractable=!1,this.type="secret",this.usages=[],this.kty="oct",this.alg=""}}r([br({name:"ext",type:cr.Boolean,optional:!0})],Wn.prototype,"extractable",void 0),r([br({name:"key_ops",type:cr.String,repeated:!0,optional:!0})],Wn.prototype,"usages",void 0),r([br({type:cr.String})],Wn.prototype,"kty",void 0),r([br({type:cr.String,optional:!0})],Wn.prototype,"alg",void 0);class Yn extends Wn{constructor(){super(...arguments),this.kty="oct",this.type="secret"}}class Xn extends Wn{}class Zn extends Yn{get alg(){switch(this.algorithm.name.toUpperCase()){case"AES-CBC":return`A${this.algorithm.length}CBC`;case"AES-CTR":return`A${this.algorithm.length}CTR`;case"AES-GCM":return`A${this.algorithm.length}GCM`;case"AES-KW":return`A${this.algorithm.length}KW`;case"AES-CMAC":return`A${this.algorithm.length}CMAC`;case"AES-ECB":return`A${this.algorithm.length}ECB`;default:throw new Sr("Unsupported algorithm name")}}set alg(e){}}r([br({name:"k",converter:qn})],Zn.prototype,"data",void 0);class Qn{static async generateKey(e,t,r){const s=new Zn;return s.algorithm=e,s.extractable=t,s.usages=r,s.data=n.randomBytes(e.length>>3),s}static async exportKey(e,t){if(!(t instanceof Zn))throw new Error("key: Is not AesCryptoKey");switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"raw":return new Uint8Array(t.data).buffer;default:throw new Er("format: Must be 'jwk' or 'raw'")}}static async importKey(t,r,n,s,i){let o;switch(t.toLowerCase()){case"jwk":o=Ar.fromJSON(r,{targetSchema:Zn});break;case"raw":o=new Zn,o.data=e.from(r);break;default:throw new Er("format: Must be 'jwk' or 'raw'")}switch(o.algorithm=n,o.algorithm.length=o.data.length<<3,o.extractable=s,o.usages=i,o.algorithm.length){case 128:case 192:case 256:break;default:throw new Er("keyData: Is wrong key length")}return o}static async encrypt(t,r,n){switch(t.name.toUpperCase()){case"AES-CBC":return this.encryptAesCBC(t,r,e.from(n));case"AES-CTR":return this.encryptAesCTR(t,r,e.from(n));case"AES-GCM":return this.encryptAesGCM(t,r,e.from(n));case"AES-KW":return this.encryptAesKW(t,r,e.from(n));case"AES-ECB":return this.encryptAesECB(t,r,e.from(n));default:throw new Er("algorithm: Is not recognized")}}static async decrypt(t,r,n){if(!(r instanceof Zn))throw new Error("key: Is not AesCryptoKey");switch(t.name.toUpperCase()){case"AES-CBC":return this.decryptAesCBC(t,r,e.from(n));case"AES-CTR":return this.decryptAesCTR(t,r,e.from(n));case"AES-GCM":return this.decryptAesGCM(t,r,e.from(n));case"AES-KW":return this.decryptAesKW(t,r,e.from(n));case"AES-ECB":return this.decryptAesECB(t,r,e.from(n));default:throw new Er("algorithm: Is not recognized")}}static async encryptAesCBC(t,r,s){const i=n.createCipheriv(`aes-${r.algorithm.length}-cbc`,r.data,new Uint8Array(t.iv));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptAesCBC(t,r,s){const i=n.createDecipheriv(`aes-${r.algorithm.length}-cbc`,r.data,new Uint8Array(t.iv));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async encryptAesCTR(t,r,s){const i=n.createCipheriv(`aes-${r.algorithm.length}-ctr`,r.data,e.from(t.counter));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptAesCTR(t,r,s){const i=n.createDecipheriv(`aes-${r.algorithm.length}-ctr`,r.data,new Uint8Array(t.counter));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async encryptAesGCM(t,r,s){const i=n.createCipheriv(`aes-${r.algorithm.length}-gcm`,r.data,e.from(t.iv),{authTagLength:(t.tagLength||128)>>3});t.additionalData&&i.setAAD(e.from(t.additionalData));let o=i.update(s);o=e.concat([o,i.final(),i.getAuthTag()]);return new Uint8Array(o).buffer}static async decryptAesGCM(t,r,s){const i=(t.tagLength||128)>>3,o=n.createDecipheriv(`aes-${r.algorithm.length}-gcm`,r.data,new Uint8Array(t.iv),{authTagLength:i}),a=s.slice(0,s.length-i),c=s.slice(s.length-i);t.additionalData&&o.setAAD(e.from(t.additionalData)),o.setAuthTag(c);let u=o.update(a);return u=e.concat([u,o.final()]),new Uint8Array(u).buffer}static async encryptAesKW(t,r,s){const i=n.createCipheriv(`id-aes${r.algorithm.length}-wrap`,r.data,this.AES_KW_IV);let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async decryptAesKW(t,r,s){const i=n.createDecipheriv(`id-aes${r.algorithm.length}-wrap`,r.data,this.AES_KW_IV);let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async encryptAesECB(t,r,s){const i=n.createCipheriv(`aes-${r.algorithm.length}-ecb`,r.data,new Uint8Array(0));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptAesECB(t,r,s){const i=n.createDecipheriv(`aes-${r.algorithm.length}-ecb`,r.data,new Uint8Array(0));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}}Qn.AES_KW_IV=e.from("A6A6A6A6A6A6A6A6","hex");const es=new WeakMap;function ts(e){const t=es.get(e);if(!t)throw new Er("Cannot get CryptoKey from secure storage");return t}function rs(e){const t=zr.create(e.algorithm,e.type,e.extractable,e.usages);return Object.freeze(t),es.set(t,e),t}class ns extends Ur{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}const ss=e.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),is=e.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135]),os=16;function as(t){const r=e.alloc(t.length),n=t.length-1;for(let e=0;e<n;e++)r[e]=t[e]<<1,128&t[e+1]&&(r[e]+=1);return r[n]=t[n]<<1,r}function cs(t,r){const n=Math.min(t.length,r.length),s=e.alloc(n);for(let e=0;e<n;e++)s[e]=t[e]^r[e];return s}function us(e,t){const r=n.createCipheriv("aes"+(e.length<<3),e,ss),s=r.update(t);return r.final(),s}function ls(t,r){const n=e.alloc(os),s=r*os,i=s+os;return t.copy(n,0,s,i),n}function hs(t,r){const n=function(e){const t=us(e,ss);let r=as(t);128&t[0]&&(r=cs(r,is));let n=as(r);return 128&r[0]&&(n=cs(n,is)),{subkey1:r,subkey2:n}}(t);let s,i,o=Math.ceil(r.length/os);0===o?(o=1,s=!1):s=r.length%os===0;const a=o-1;i=s?cs(ls(r,a),n.subkey1):cs(function(t,r){const n=e.alloc(os),s=r*os,i=t.length;return n.fill(0),t.copy(n,0,s,i),n[i-s]=128,n}(r,a),n.subkey2);let c,u=ss;for(let e=0;e<a;e++)c=cs(u,ls(r,e)),u=us(t,c);return c=cs(i,u),us(t,c)}class ys extends Pr{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onSign(t,r,n){const s=hs(ts(r).data,e.from(n));return new Uint8Array(s).buffer}async onVerify(t,r,n,s){const i=await this.sign(t,r,s);return 0===e.from(n).compare(e.from(i))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class fs extends Ir{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class ps extends Hr{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class gs extends Tr{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class ms extends Or{async onGenerateKey(e,t,r){return rs(await Qn.generateKey({name:this.name,length:e.length},t,r))}async onEncrypt(e,t,r){return Qn.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return Qn.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return Qn.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Qn.importKey(e,t,{name:r.name},n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Zn))throw new TypeError("key: Is not a AesCryptoKey")}}class ds extends Yn{get alg(){switch(this.algorithm.name.toUpperCase()){case"DES-CBC":return"DES-CBC";case"DES-EDE3-CBC":return"3DES-CBC";default:throw new Sr("Unsupported algorithm name")}}set alg(e){}}r([br({name:"k",converter:qn})],ds.prototype,"data",void 0);class ws{static async generateKey(e,t,r){const s=new ds;return s.algorithm=e,s.extractable=t,s.usages=r,s.data=n.randomBytes(e.length>>3),s}static async exportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"raw":return new Uint8Array(t.data).buffer;default:throw new Er("format: Must be 'jwk' or 'raw'")}}static async importKey(t,r,n,s,i){let o;switch(t.toLowerCase()){case"jwk":o=Ar.fromJSON(r,{targetSchema:ds});break;case"raw":o=new ds,o.data=e.from(r);break;default:throw new Er("format: Must be 'jwk' or 'raw'")}return o.algorithm=n,o.extractable=s,o.usages=i,o}static async encrypt(t,r,n){switch(t.name.toUpperCase()){case"DES-CBC":return this.encryptDesCBC(t,r,e.from(n));case"DES-EDE3-CBC":return this.encryptDesEDE3CBC(t,r,e.from(n));default:throw new Er("algorithm: Is not recognized")}}static async decrypt(t,r,n){if(!(r instanceof ds))throw new Error("key: Is not DesCryptoKey");switch(t.name.toUpperCase()){case"DES-CBC":return this.decryptDesCBC(t,r,e.from(n));case"DES-EDE3-CBC":return this.decryptDesEDE3CBC(t,r,e.from(n));default:throw new Er("algorithm: Is not recognized")}}static async encryptDesCBC(t,r,s){const i=n.createCipheriv("des-cbc",r.data,new Uint8Array(t.iv));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptDesCBC(t,r,s){const i=n.createDecipheriv("des-cbc",r.data,new Uint8Array(t.iv));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}static async encryptDesEDE3CBC(t,r,s){const i=n.createCipheriv("des-ede3-cbc",r.data,e.from(t.iv));let o=i.update(s);o=e.concat([o,i.final()]);return new Uint8Array(o).buffer}static async decryptDesEDE3CBC(t,r,s){const i=n.createDecipheriv("des-ede3-cbc",r.data,new Uint8Array(t.iv));let o=i.update(s);return o=e.concat([o,i.final()]),new Uint8Array(o).buffer}}class vs extends Lr{constructor(){super(...arguments),this.keySizeBits=64,this.ivSize=8,this.name="DES-CBC"}async onGenerateKey(e,t,r){return rs(await ws.generateKey({name:this.name,length:this.keySizeBits},t,r))}async onEncrypt(e,t,r){return ws.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return ws.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return ws.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){const i=await ws.importKey(e,t,{name:this.name,length:this.keySizeBits},n,s);if(i.data.length!==this.keySizeBits>>3)throw new Er("keyData: Wrong key size");return rs(i)}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ds))throw new TypeError("key: Is not a DesCryptoKey")}}class As extends Lr{constructor(){super(...arguments),this.keySizeBits=192,this.ivSize=8,this.name="DES-EDE3-CBC"}async onGenerateKey(e,t,r){return rs(await ws.generateKey({name:this.name,length:this.keySizeBits},t,r))}async onEncrypt(e,t,r){return ws.encrypt(e,ts(t),new Uint8Array(r))}async onDecrypt(e,t,r){return ws.decrypt(e,ts(t),new Uint8Array(r))}async onExportKey(e,t){return ws.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){const i=await ws.importKey(e,t,{name:this.name,length:this.keySizeBits},n,s);if(i.data.length!==this.keySizeBits>>3)throw new Er("keyData: Wrong key size");return rs(i)}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ds))throw new TypeError("key: Is not a DesCryptoKey")}}function bs(e){switch(e.name.toUpperCase()){case"RSA-OAEP":{const t=/(\d+)$/.exec(e.hash.name)[1];return"RSA-OAEP"+("1"!==t?`-${t}`:"")}case"RSASSA-PKCS1-V1_5":return`RS${/(\d+)$/.exec(e.hash.name)[1]}`;case"RSA-PSS":return`PS${/(\d+)$/.exec(e.hash.name)[1]}`;case"RSA-PKCS1":return"RS1";default:throw new Er("algorithm: Is not recognized")}}class ks extends Xn{constructor(){super(...arguments),this.type="private"}getKey(){const e=Qt.parse(this.data,On.PrivateKeyInfo);return Qt.parse(e.privateKey,On.RsaPrivateKey)}toJSON(){const e=this.getKey(),t={kty:"RSA",alg:bs(this.algorithm),key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){const r=Ar.fromJSON(t,{targetSchema:On.RsaPrivateKey}),n=new On.PrivateKeyInfo;n.privateKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",n.privateKeyAlgorithm.parameters=null,n.privateKey=er.serialize(r),this.data=e.from(er.serialize(n))}}class Ss extends Xn{constructor(){super(...arguments),this.type="public"}getKey(){const e=Qt.parse(this.data,On.PublicKeyInfo);return Qt.parse(e.publicKey,On.RsaPublicKey)}toJSON(){const e=this.getKey(),t={kty:"RSA",alg:bs(this.algorithm),key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){const r=Ar.fromJSON(t,{targetSchema:On.RsaPublicKey}),n=new On.PublicKeyInfo;n.publicKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",n.publicKeyAlgorithm.parameters=null,n.publicKey=er.serialize(r),this.data=e.from(er.serialize(n))}}class Bs{static async generateKey(t,r,s){const i=new ks;i.algorithm=t,i.extractable=r,i.usages=s.filter(e=>-1!==this.privateKeyUsages.indexOf(e));const o=new Ss;o.algorithm=t,o.extractable=!0,o.usages=s.filter(e=>-1!==this.publicKeyUsages.indexOf(e));const a=e.concat([e.alloc(4-t.publicExponent.byteLength,0),e.from(t.publicExponent)]).readInt32BE(0),c=n.generateKeyPairSync("rsa",{modulusLength:t.modulusLength,publicExponent:a,publicKeyEncoding:{format:"der",type:"spki"},privateKeyEncoding:{format:"der",type:"pkcs8"}});i.data=c.privateKey,o.data=c.publicKey;return{privateKey:i,publicKey:o}}static async exportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"pkcs8":case"spki":return new Uint8Array(t.data).buffer;default:throw new Er("format: Must be 'jwk', 'pkcs8' or 'spki'")}}static async importKey(e,t,r,n,s){switch(e.toLowerCase()){case"jwk":if(t.d){const e=Ar.fromJSON(t,{targetSchema:On.RsaPrivateKey});return this.importPrivateKey(e,r,n,s)}{const e=Ar.fromJSON(t,{targetSchema:On.RsaPublicKey});return this.importPublicKey(e,r,n,s)}case"spki":{const e=Qt.parse(new Uint8Array(t),On.PublicKeyInfo),i=Qt.parse(e.publicKey,On.RsaPublicKey);return this.importPublicKey(i,r,n,s)}case"pkcs8":{const e=Qt.parse(new Uint8Array(t),On.PrivateKeyInfo),i=Qt.parse(e.privateKey,On.RsaPrivateKey);return this.importPrivateKey(i,r,n,s)}default:throw new Er("format: Must be 'jwk', 'pkcs8' or 'spki'")}}static async sign(e,t,r){switch(e.name.toUpperCase()){case"RSA-PSS":case"RSASSA-PKCS1-V1_5":return this.signRsa(e,t,r);default:throw new Er("algorithm: Is not recognized")}}static async verify(e,t,r,n){switch(e.name.toUpperCase()){case"RSA-PSS":case"RSASSA-PKCS1-V1_5":return this.verifySSA(e,t,n,r);default:throw new Er("algorithm: Is not recognized")}}static async encrypt(e,t,r){if("RSA-OAEP"===e.name.toUpperCase())return this.encryptOAEP(e,t,r);throw new Er("algorithm: Is not recognized")}static async decrypt(e,t,r){if("RSA-OAEP"===e.name.toUpperCase())return this.decryptOAEP(e,t,r);throw new Er("algorithm: Is not recognized")}static importPrivateKey(t,r,n,s){const i=new On.PrivateKeyInfo;i.privateKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",i.privateKeyAlgorithm.parameters=null,i.privateKey=er.serialize(t);const o=new ks;return o.data=e.from(er.serialize(i)),o.algorithm=Object.assign({},r),o.algorithm.publicExponent=new Uint8Array(t.publicExponent),o.algorithm.modulusLength=t.modulus.byteLength<<3,o.extractable=n,o.usages=s,o}static importPublicKey(t,r,n,s){const i=new On.PublicKeyInfo;i.publicKeyAlgorithm.algorithm="1.2.840.113549.1.1.1",i.publicKeyAlgorithm.parameters=null,i.publicKey=er.serialize(t);const o=new Ss;return o.data=e.from(er.serialize(i)),o.algorithm=Object.assign({},r),o.algorithm.publicExponent=new Uint8Array(t.publicExponent),o.algorithm.modulusLength=t.modulus.byteLength<<3,o.extractable=n,o.usages=s,o}static getCryptoAlgorithm(e){switch(e.hash.name.toUpperCase()){case"SHA-1":return"RSA-SHA1";case"SHA-256":return"RSA-SHA256";case"SHA-384":return"RSA-SHA384";case"SHA-512":return"RSA-SHA512";case"SHA3-256":return"RSA-SHA3-256";case"SHA3-384":return"RSA-SHA3-384";case"SHA3-512":return"RSA-SHA3-512";default:throw new Er("algorithm.hash: Is not recognized")}}static signRsa(t,r,s){const i=this.getCryptoAlgorithm(r.algorithm),o=n.createSign(i);o.update(e.from(s)),r.pem||(r.pem=`-----BEGIN PRIVATE KEY-----\n${r.data.toString("base64")}\n-----END PRIVATE KEY-----`);const a={key:r.pem};"RSA-PSS"===t.name.toUpperCase()&&(a.padding=n.constants.RSA_PKCS1_PSS_PADDING,a.saltLength=t.saltLength);const c=o.sign(a);return new Uint8Array(c).buffer}static verifySSA(t,r,s,i){const o=this.getCryptoAlgorithm(r.algorithm),a=n.createVerify(o);a.update(e.from(s)),r.pem||(r.pem=`-----BEGIN PUBLIC KEY-----\n${r.data.toString("base64")}\n-----END PUBLIC KEY-----`);const c={key:r.pem};"RSA-PSS"===t.name.toUpperCase()&&(c.padding=n.constants.RSA_PKCS1_PSS_PADDING,c.saltLength=t.saltLength);return a.verify(c,i)}static encryptOAEP(e,t,r){const s={key:`-----BEGIN PUBLIC KEY-----\n${t.data.toString("base64")}\n-----END PUBLIC KEY-----`,padding:n.constants.RSA_PKCS1_OAEP_PADDING};return e.label,new Uint8Array(n.publicEncrypt(s,r)).buffer}static decryptOAEP(e,t,r){const s={key:`-----BEGIN PRIVATE KEY-----\n${t.data.toString("base64")}\n-----END PRIVATE KEY-----`,padding:n.constants.RSA_PKCS1_OAEP_PADDING};return e.label,new Uint8Array(n.privateDecrypt(s,r)).buffer}}Bs.publicKeyUsages=["verify","encrypt","wrapKey"],Bs.privateKeyUsages=["sign","decrypt","unwrapKey"];class Es extends Vr{constructor(){super(...arguments),this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512","shake128","shake256","SHA3-256","SHA3-384","SHA3-512"]}async onGenerateKey(e,t,r){const n=await Bs.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){return Bs.sign(e,ts(t),new Uint8Array(r))}async onVerify(e,t,r,n){return Bs.verify(e,ts(t),new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){return Bs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Bs.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof ks||r instanceof Ss))throw new TypeError("key: Is not RSA CryptoKey")}}class Ks extends Rr{constructor(){super(...arguments),this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512","shake128","shake256","SHA3-256","SHA3-384","SHA3-512"]}async onGenerateKey(e,t,r){const n=await Bs.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){return Bs.sign(e,ts(t),new Uint8Array(r))}async onVerify(e,t,r,n){return Bs.verify(e,ts(t),new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){return Bs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Bs.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof ks||r instanceof Ss))throw new TypeError("key: Is not RSA CryptoKey")}}class Cs{static size(e){switch(e.name.toUpperCase()){case"SHA-1":return 160;case"SHA-256":case"SHA3-256":return 256;case"SHA-384":case"SHA3-384":return 384;case"SHA-512":case"SHA3-512":return 512;default:throw new Error("Unrecognized name")}}static getAlgorithmName(e){switch(e.name.toUpperCase()){case"SHA-1":return"sha1";case"SHA-256":return"sha256";case"SHA-384":return"sha384";case"SHA-512":return"sha512";case"SHA3-256":return"sha3-256";case"SHA3-384":return"sha3-384";case"SHA3-512":return"sha3-512";default:throw new Error("Unrecognized name")}}static digest(t,r){const s=this.getAlgorithmName(t),i=n.createHash(s).update(e.from(r)).digest();return new Uint8Array(i).buffer}}class xs extends Mr{async onGenerateKey(e,t,r){const n=await Bs.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onEncrypt(t,r,s){const i=ts(r),a=new Uint8Array(s),c=Math.ceil(i.algorithm.modulusLength>>3),u=Cs.size(i.algorithm.hash)>>3,l=a.byteLength,h=c-l-2*u-2;if(l>c-2*u-2)throw new Error("Data too large");const y=new Uint8Array(c),f=y.subarray(1,u+1),p=y.subarray(u+1);p.set(a,u+h+1);const g=n.createHash(i.algorithm.hash.name.replace("-","")).update(o.BufferSourceConverter.toUint8Array(t.label||new Uint8Array(0))).digest();p.set(g,0),p[u+h]=1,n.randomFillSync(f);const m=this.mgf1(i.algorithm.hash,f,p.length);for(let e=0;e<p.length;e++)p[e]^=m[e];const d=this.mgf1(i.algorithm.hash,p,f.length);for(let e=0;e<f.length;e++)f[e]^=d[e];i.pem||(i.pem=`-----BEGIN PUBLIC KEY-----\n${i.data.toString("base64")}\n-----END PUBLIC KEY-----`);const w=n.publicEncrypt({key:i.pem,padding:n.constants.RSA_NO_PADDING},e.from(y));return new Uint8Array(w).buffer}async onDecrypt(t,r,s){const i=ts(r),a=Math.ceil(i.algorithm.modulusLength>>3),c=Cs.size(i.algorithm.hash)>>3;if(s.byteLength!==a)throw new Error("Bad data");i.pem||(i.pem=`-----BEGIN PRIVATE KEY-----\n${i.data.toString("base64")}\n-----END PRIVATE KEY-----`);let u=n.privateDecrypt({key:i.pem,padding:n.constants.RSA_NO_PADDING},e.from(s));const l=u[0],h=u.subarray(1,c+1),y=u.subarray(c+1);if(0!==l)throw new Error("Decryption failed");const f=this.mgf1(i.algorithm.hash,y,h.length);for(let e=0;e<h.length;e++)h[e]^=f[e];const p=this.mgf1(i.algorithm.hash,h,y.length);for(let e=0;e<y.length;e++)y[e]^=p[e];const g=n.createHash(i.algorithm.hash.name.replace("-","")).update(o.BufferSourceConverter.toUint8Array(t.label||new Uint8Array(0))).digest();for(let e=0;e<c;e++)if(g[e]!==y[e])throw new Error("Decryption failed");let m=c;for(;m<y.length;m++){const e=y[m];if(1===e)break;if(0!==e)throw new Error("Decryption failed")}if(m===y.length)throw new Error("Decryption failed");return u=y.subarray(m+1),new Uint8Array(u).buffer}async onExportKey(e,t){return Bs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Bs.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof ks||r instanceof Ss))throw new TypeError("key: Is not RSA CryptoKey")}mgf1(e,t,r=0){const s=Cs.size(e)>>3,i=new Uint8Array(r),o=new Uint8Array(4),a=Math.ceil(r/s);for(let r=0;r<a;r++){o[0]=r>>>24,o[1]=r>>>16&255,o[2]=r>>>8&255,o[3]=255&r;const a=i.subarray(r*s);let c=n.createHash(e.name.replace("-","")).update(t).update(o).digest();c.length>a.length&&(c=c.subarray(0,a.length)),a.set(c)}return i}}class Ns extends xr{constructor(){super(...arguments),this.name="RSAES-PKCS1-v1_5",this.usages={publicKey:["encrypt","wrapKey"],privateKey:["decrypt","unwrapKey"]}}async onGenerateKey(e,t,r){const n=await Bs.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}checkGenerateKeyParams(e){if(this.checkRequiredProperty(e,"publicExponent"),!(e.publicExponent&&e.publicExponent instanceof Uint8Array))throw new TypeError("publicExponent: Missing or not a Uint8Array");const t=o.Convert.ToBase64(e.publicExponent);if("Aw=="!==t&&"AQAB"!==t)throw new TypeError("publicExponent: Must be [3] or [1,0,1]");switch(this.checkRequiredProperty(e,"modulusLength"),e.modulusLength){case 1024:case 2048:case 4096:break;default:throw new TypeError("modulusLength: Must be 1024, 2048, or 4096")}}async onEncrypt(e,t,r){const s=this.toCryptoOptions(t),i=n.publicEncrypt(s,new Uint8Array(r));return new Uint8Array(i).buffer}async onDecrypt(e,t,r){const s=this.toCryptoOptions(t),i=n.privateDecrypt(s,new Uint8Array(r));return new Uint8Array(i).buffer}async onExportKey(e,t){return Bs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await Bs.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof ks||r instanceof Ss))throw new TypeError("key: Is not RSA CryptoKey")}toCryptoOptions(e){const t=e.type.toUpperCase();return{key:`-----BEGIN ${t} KEY-----\n${ts(e).data.toString("base64")}\n-----END ${t} KEY-----`,padding:n.constants.RSA_PKCS1_PADDING}}}const Us={"1.2.840.10045.3.1.7":"P-256","P-256":"1.2.840.10045.3.1.7","1.3.132.0.34":"P-384","P-384":"1.3.132.0.34","1.3.132.0.35":"P-521","P-521":"1.3.132.0.35","1.3.132.0.10":"K-256","K-256":"1.3.132.0.10",brainpoolP160r1:"1.3.36.3.3.2.8.1.1.1","1.3.36.3.3.2.8.1.1.1":"brainpoolP160r1",brainpoolP160t1:"1.3.36.3.3.2.8.1.1.2","1.3.36.3.3.2.8.1.1.2":"brainpoolP160t1",brainpoolP192r1:"1.3.36.3.3.2.8.1.1.3","1.3.36.3.3.2.8.1.1.3":"brainpoolP192r1",brainpoolP192t1:"1.3.36.3.3.2.8.1.1.4","1.3.36.3.3.2.8.1.1.4":"brainpoolP192t1",brainpoolP224r1:"1.3.36.3.3.2.8.1.1.5","1.3.36.3.3.2.8.1.1.5":"brainpoolP224r1",brainpoolP224t1:"1.3.36.3.3.2.8.1.1.6","1.3.36.3.3.2.8.1.1.6":"brainpoolP224t1",brainpoolP256r1:"1.3.36.3.3.2.8.1.1.7","1.3.36.3.3.2.8.1.1.7":"brainpoolP256r1",brainpoolP256t1:"1.3.36.3.3.2.8.1.1.8","1.3.36.3.3.2.8.1.1.8":"brainpoolP256t1",brainpoolP320r1:"1.3.36.3.3.2.8.1.1.9","1.3.36.3.3.2.8.1.1.9":"brainpoolP320r1",brainpoolP320t1:"1.3.36.3.3.2.8.1.1.10","1.3.36.3.3.2.8.1.1.10":"brainpoolP320t1",brainpoolP384r1:"1.3.36.3.3.2.8.1.1.11","1.3.36.3.3.2.8.1.1.11":"brainpoolP384r1",brainpoolP384t1:"1.3.36.3.3.2.8.1.1.12","1.3.36.3.3.2.8.1.1.12":"brainpoolP384t1",brainpoolP512r1:"1.3.36.3.3.2.8.1.1.13","1.3.36.3.3.2.8.1.1.13":"brainpoolP512r1",brainpoolP512t1:"1.3.36.3.3.2.8.1.1.14","1.3.36.3.3.2.8.1.1.14":"brainpoolP512t1"};function Ps(e){const t=Us[e];if(!t)throw new Er(`Cannot convert WebCrypto named curve '${e}' to OID`);return t}class Is extends Xn{constructor(){super(...arguments),this.type="private"}getKey(){const e=Qt.parse(this.data,On.PrivateKeyInfo);return Qt.parse(e.privateKey,On.EcPrivateKey)}toJSON(){const e=this.getKey(),t={kty:"EC",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){if(!t.crv)throw new Er("Cannot get named curve from JWK. Property 'crv' is required");const r=new On.PrivateKeyInfo;r.privateKeyAlgorithm.algorithm="1.2.840.10045.2.1",r.privateKeyAlgorithm.parameters=er.serialize(new On.ObjectIdentifier(Ps(t.crv)));const n=Ar.fromJSON(t,{targetSchema:On.EcPrivateKey});return r.privateKey=er.serialize(n),this.data=e.from(er.serialize(r)),this}}class Os extends Xn{constructor(){super(...arguments),this.type="public"}getKey(){const e=Qt.parse(this.data,On.PublicKeyInfo);return new On.EcPublicKey(e.publicKey)}toJSON(){const e=this.getKey(),t={kty:"EC",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){if(!t.crv)throw new Er("Cannot get named curve from JWK. Property 'crv' is required");const r=Ar.fromJSON(t,{targetSchema:On.EcPublicKey}),n=new On.PublicKeyInfo;return n.publicKeyAlgorithm.algorithm="1.2.840.10045.2.1",n.publicKeyAlgorithm.parameters=er.serialize(new On.ObjectIdentifier(Ps(t.crv))),n.publicKey=er.toASN(r).valueHex,this.data=e.from(er.serialize(n)),this}}class Hs extends xr{constructor(){super(...arguments),this.name="SHA-1",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Ts extends xr{constructor(){super(...arguments),this.name="SHA-256",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Ls extends xr{constructor(){super(...arguments),this.name="SHA-384",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Ds extends xr{constructor(){super(...arguments),this.name="SHA-512",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Vs extends xr{constructor(){super(...arguments),this.name="SHA3-256",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Rs extends xr{constructor(){super(...arguments),this.name="SHA3-384",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class Ms extends xr{constructor(){super(...arguments),this.name="SHA3-512",this.usages=[]}async onDigest(e,t){return Cs.digest(e,t)}}class $s{static async generateKey(e,t,r){const s=new Is;s.algorithm=e,s.extractable=t,s.usages=r.filter(e=>-1!==this.privateKeyUsages.indexOf(e));const i=new Os;i.algorithm=e,i.extractable=!0,i.usages=r.filter(e=>-1!==this.publicKeyUsages.indexOf(e));const o=n.generateKeyPairSync("ec",{namedCurve:this.getOpenSSLNamedCurve(e.namedCurve),publicKeyEncoding:{format:"der",type:"spki"},privateKeyEncoding:{format:"der",type:"pkcs8"}});s.data=o.privateKey,i.data=o.publicKey;return{privateKey:s,publicKey:i}}static async sign(t,r,s){const i=Cs.getAlgorithmName(t.hash),o=n.createSign(i);o.update(e.from(s)),r.pem||(r.pem=`-----BEGIN PRIVATE KEY-----\n${r.data.toString("base64")}\n-----END PRIVATE KEY-----`);const a={key:r.pem},c=o.sign(a),u=Qt.parse(c,On.EcDsaSignature);return an.encodeSignature(u,Hn.get(r.algorithm.namedCurve).size).buffer}static async verify(t,r,s,i){const a=Cs.getAlgorithmName(t.hash),c=n.createVerify(a);c.update(e.from(i)),r.pem||(r.pem=`-----BEGIN PUBLIC KEY-----\n${r.data.toString("base64")}\n-----END PUBLIC KEY-----`);const u={key:r.pem},l=new On.EcDsaSignature,h=Hn.get(r.algorithm.namedCurve),y=an.decodeSignature(s,h.size);l.r=o.BufferSourceConverter.toArrayBuffer(y.r),l.s=o.BufferSourceConverter.toArrayBuffer(y.s);const f=e.from(er.serialize(l));return c.verify(u,f)}static async deriveBits(t,r,s){const i=this.getOpenSSLNamedCurve(r.algorithm.namedCurve),o=n.createECDH(i),a=Qt.parse(r.data,On.PrivateKeyInfo),c=Qt.parse(a.privateKey,On.EcPrivateKey);o.setPrivateKey(e.from(c.privateKey));const u=Qt.parse(t.public.data,On.PublicKeyInfo),l=o.computeSecret(e.from(u.publicKey));return null===s?l:new Uint8Array(l).buffer.slice(0,s>>3)}static async exportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"pkcs8":case"spki":return new Uint8Array(t.data).buffer;case"raw":return Qt.parse(t.data,On.PublicKeyInfo).publicKey;default:throw new Er("format: Must be 'jwk', 'raw', pkcs8' or 'spki'")}}static async importKey(e,t,r,n,s){switch(e.toLowerCase()){case"jwk":if(t.d){const e=Ar.fromJSON(t,{targetSchema:On.EcPrivateKey});return this.importPrivateKey(e,r,n,s)}{const e=Ar.fromJSON(t,{targetSchema:On.EcPublicKey});return this.importPublicKey(e,r,n,s)}case"raw":{const e=new On.EcPublicKey(t);return this.importPublicKey(e,r,n,s)}case"spki":{const e=Qt.parse(new Uint8Array(t),On.PublicKeyInfo),i=new On.EcPublicKey(e.publicKey);return this.assertKeyParameters(e.publicKeyAlgorithm.parameters,r.namedCurve),this.importPublicKey(i,r,n,s)}case"pkcs8":{const e=Qt.parse(new Uint8Array(t),On.PrivateKeyInfo),i=Qt.parse(e.privateKey,On.EcPrivateKey);return this.assertKeyParameters(e.privateKeyAlgorithm.parameters,r.namedCurve),this.importPrivateKey(i,r,n,s)}default:throw new Er("format: Must be 'jwk', 'raw', 'pkcs8' or 'spki'")}}static assertKeyParameters(e,t){if(!e)throw new kr("Key info doesn't have required parameters");let r="";try{r=Qt.parse(e,On.ObjectIdentifier).value}catch(e){throw new kr("Cannot read key info parameters")}if(Ps(t)!==r)throw new kr("Key info parameter doesn't match to named curve")}static async importPrivateKey(t,r,n,s){const i=new On.PrivateKeyInfo;i.privateKeyAlgorithm.algorithm="1.2.840.10045.2.1",i.privateKeyAlgorithm.parameters=er.serialize(new On.ObjectIdentifier(Ps(r.namedCurve))),i.privateKey=er.serialize(t);const o=new Is;return o.data=e.from(er.serialize(i)),o.algorithm=Object.assign({},r),o.extractable=n,o.usages=s,o}static async importPublicKey(t,r,n,s){const i=new On.PublicKeyInfo;i.publicKeyAlgorithm.algorithm="1.2.840.10045.2.1";const o=Ps(r.namedCurve);i.publicKeyAlgorithm.parameters=er.serialize(new On.ObjectIdentifier(o)),i.publicKey=t.value;const a=new Os;return a.data=e.from(er.serialize(i)),a.algorithm=Object.assign({},r),a.extractable=n,a.usages=s,a}static getOpenSSLNamedCurve(e){switch(e.toUpperCase()){case"P-256":return"prime256v1";case"K-256":return"secp256k1";case"P-384":return"secp384r1";case"P-521":return"secp521r1";default:return e}}}$s.publicKeyUsages=["verify"],$s.privateKeyUsages=["sign","deriveKey","deriveBits"];class Js extends Jr{constructor(){super(...arguments),this.namedCurves=Hn.names,this.hashAlgorithms=["SHA-1","SHA-256","SHA-384","SHA-512","shake128","shake256","SHA3-256","SHA3-384","SHA3-512"]}async onGenerateKey(e,t,r){const n=await $s.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){return $s.sign(e,ts(t),new Uint8Array(r))}async onVerify(e,t,r,n){return $s.verify(e,ts(t),new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){return $s.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await $s.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof Is||r instanceof Os))throw new TypeError("key: Is not EC CryptoKey")}}class js extends Fr{constructor(){super(...arguments),this.namedCurves=Hn.names}async onGenerateKey(e,t,r){const n=await $s.generateKey({...e,name:this.name},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onExportKey(e,t){return $s.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await $s.importKey(e,t,{...r,name:this.name},n,s))}checkCryptoKey(e,t){super.checkCryptoKey(e,t);const r=ts(e);if(!(r instanceof Is||r instanceof Os))throw new TypeError("key: Is not EC CryptoKey")}async onDeriveBits(e,t,r){return await $s.deriveBits({...e,public:ts(e.public)},ts(t),r)}}const zs={[On.idEd448]:"Ed448",ed448:On.idEd448,[On.idX448]:"X448",x448:On.idX448,[On.idEd25519]:"Ed25519",ed25519:On.idEd25519,[On.idX25519]:"X25519",x25519:On.idX25519};function Fs(e){const t=zs[e.toLowerCase()];if(!t)throw new Er(`Cannot convert WebCrypto named curve '${e}' to OID`);return t}class Gs extends Xn{constructor(){super(...arguments),this.type="private"}getKey(){const e=Qt.parse(this.data,On.PrivateKeyInfo);return Qt.parse(e.privateKey,On.CurvePrivateKey)}toJSON(){const e=this.getKey(),t={kty:"OKP",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,vr.toJSON(e))}fromJSON(t){if(!t.crv)throw new Er("Cannot get named curve from JWK. Property 'crv' is required");const r=new On.PrivateKeyInfo;r.privateKeyAlgorithm.algorithm=Fs(t.crv);const n=Ar.fromJSON(t,{targetSchema:On.CurvePrivateKey});return r.privateKey=er.serialize(n),this.data=e.from(er.serialize(r)),this}}class _s extends Xn{constructor(){super(...arguments),this.type="public"}getKey(){return Qt.parse(this.data,On.PublicKeyInfo).publicKey}toJSON(){const e=this.getKey(),t={kty:"OKP",crv:this.algorithm.namedCurve,key_ops:this.usages,ext:this.extractable};return Object.assign(t,{x:o.Convert.ToBase64Url(e)})}fromJSON(t){if(!t.crv)throw new Er("Cannot get named curve from JWK. Property 'crv' is required");if(!t.x)throw new Er("Cannot get property from JWK. Property 'x' is required");const r=new On.PublicKeyInfo;return r.publicKeyAlgorithm.algorithm=Fs(t.crv),r.publicKey=o.Convert.FromBase64Url(t.x),this.data=e.from(er.serialize(r)),this}}class qs{static async generateKey(e,t,r){const s=new Gs;s.algorithm=e,s.extractable=t,s.usages=r.filter(e=>-1!==this.privateKeyUsages.indexOf(e));const i=new _s;i.algorithm=e,i.extractable=!0,i.usages=r.filter(e=>-1!==this.publicKeyUsages.indexOf(e));const o=e.namedCurve.toLowerCase(),a=n.generateKeyPairSync(o,{publicKeyEncoding:{format:"der",type:"spki"},privateKeyEncoding:{format:"der",type:"pkcs8"}});s.data=a.privateKey,i.data=a.publicKey;return{privateKey:s,publicKey:i}}static async sign(t,r,s){r.pem||(r.pem=`-----BEGIN PRIVATE KEY-----\n${r.data.toString("base64")}\n-----END PRIVATE KEY-----`);const i={key:r.pem},a=n.sign(null,e.from(s),i);return o.BufferSourceConverter.toArrayBuffer(a)}static async verify(t,r,s,i){r.pem||(r.pem=`-----BEGIN PUBLIC KEY-----\n${r.data.toString("base64")}\n-----END PUBLIC KEY-----`);const o={key:r.pem};return n.verify(null,e.from(i),o,e.from(s))}static async deriveBits(e,t,r){const s=n.createPublicKey({key:e.public.data,format:"der",type:"spki"}),i=n.createPrivateKey({key:t.data,format:"der",type:"pkcs8"}),o=n.diffieHellman({publicKey:s,privateKey:i});return new Uint8Array(o).buffer.slice(0,r>>3)}static async exportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(t);case"pkcs8":case"spki":return new Uint8Array(t.data).buffer;case"raw":return Qt.parse(t.data,On.PublicKeyInfo).publicKey;default:throw new Er("format: Must be 'jwk', 'raw', pkcs8' or 'spki'")}}static async importKey(e,t,r,n,s){switch(e.toLowerCase()){case"jwk":{const e=t;if(e.d){const e=Ar.fromJSON(t,{targetSchema:On.CurvePrivateKey});return this.importPrivateKey(e,r,n,s)}if(!e.x)throw new TypeError("keyData: Cannot get required 'x' filed");return this.importPublicKey(o.Convert.FromBase64Url(e.x),r,n,s)}case"raw":return this.importPublicKey(t,r,n,s);case"spki":{const e=Qt.parse(new Uint8Array(t),On.PublicKeyInfo);return this.importPublicKey(e.publicKey,r,n,s)}case"pkcs8":{const e=Qt.parse(new Uint8Array(t),On.PrivateKeyInfo),i=Qt.parse(e.privateKey,On.CurvePrivateKey);return this.importPrivateKey(i,r,n,s)}default:throw new Er("format: Must be 'jwk', 'raw', 'pkcs8' or 'spki'")}}static importPrivateKey(e,t,r,n){const s=new Gs;return s.fromJSON({crv:t.namedCurve,d:o.Convert.ToBase64Url(e.d)}),s.algorithm=Object.assign({},t),s.extractable=r,s.usages=n,s}static async importPublicKey(e,t,r,n){const s=new _s;return s.fromJSON({crv:t.namedCurve,x:o.Convert.ToBase64Url(e)}),s.algorithm=Object.assign({},t),s.extractable=r,s.usages=n,s}}qs.publicKeyUsages=["verify"],qs.privateKeyUsages=["sign","deriveKey","deriveBits"];class Ws extends _r{async onGenerateKey(e,t,r){const n=await qs.generateKey({name:this.name,namedCurve:e.namedCurve.replace(/^ed/i,"Ed")},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){return qs.sign(e,ts(t),new Uint8Array(r))}async onVerify(e,t,r,n){return qs.verify(e,ts(t),new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){return qs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await qs.importKey(e,t,{...r,name:this.name},n,s))}}class Ys extends Gr{async onGenerateKey(e,t,r){const n=await qs.generateKey({name:this.name,namedCurve:e.namedCurve.toUpperCase()},t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onDeriveBits(e,t,r){return await qs.deriveBits({...e,public:ts(e.public)},ts(t),r)}async onExportKey(e,t){return qs.exportKey(e,ts(t))}async onImportKey(e,t,r,n,s){return rs(await qs.importKey(e,t,{...r,name:this.name},n,s))}}class Xs extends Wn{constructor(t,r,n,s){super(),this.algorithm=t,this.extractable=r,this.usages=n,this.data=e.from(s)}toJWK(){return{kty:"OKP",crv:this.algorithm.name,key_ops:this.usages,ext:this.extractable}}}class Zs extends Xs{constructor(){super(...arguments),this.type="private"}toJWK(){const t=n.createPublicKey({key:this.data,format:"pem"}).export({format:"jwk"}),r=Cr.toUint8Array(this.data.toString()),s=tr.parse(r,On.PrivateKeyInfo),i=tr.parse(s.privateKey,On.EdPrivateKey).value;return{...super.toJWK(),...t,d:e.from(new Uint8Array(i)).toString("base64url")}}}class Qs extends Xs{constructor(){super(...arguments),this.type="public"}toJWK(){const e=n.createPublicKey({key:this.data,format:"pem"}).export({format:"jwk"});return{...super.toJWK(),...e}}}class ei{static async generateKey(e,t,r){const s=e.name.toLowerCase(),i=n.generateKeyPairSync(s,{publicKeyEncoding:{format:"pem",type:"spki"},privateKeyEncoding:{format:"pem",type:"pkcs8"}}),o={name:"ed25519"===s?"Ed25519":"X25519"},a=r.filter(e=>this.privateKeyUsages.includes(e)),c=r.filter(e=>this.publicKeyUsages.includes(e));return{privateKey:new Zs(o,t,a,i.privateKey),publicKey:new Qs(o,!0,c,i.publicKey)}}static async sign(t,r,s){const i=n.sign(null,e.from(s),r.data);return o.BufferSourceConverter.toArrayBuffer(i)}static async verify(t,r,s,i){return n.verify(null,e.from(i),r.data,s)}static async exportKey(e,t){switch(e){case"jwk":return t.toJWK();case"pkcs8":case"spki":return Cr.toArrayBuffer(t.data.toString());case"raw":{const e=t.toJWK();return o.Convert.FromBase64Url(e.x)}default:return Promise.reject(new Er("format: Must be 'jwk', 'raw', pkcs8' or 'spki'"))}}static async importKey(t,r,s,i,a){switch(t){case"jwk":{const t=r;if(t.d){const r=new On.EdPrivateKey;r.value=o.BufferSourceConverter.toArrayBuffer(e.from(t.d,"base64url"));const n=new On.PrivateKeyInfo;n.privateKeyAlgorithm.algorithm="ed25519"===s.name.toLowerCase()?On.idEd25519:On.idX25519,n.privateKey=tr.serialize(r);const c=tr.serialize(n),u=Cr.fromBufferSource(c,"PRIVATE KEY");return new Zs(s,i,a,u)}if(t.x){const e=n.createPublicKey({format:"jwk",key:t}).export({format:"pem",type:"spki"});return new Qs(s,i,a,e)}throw new Er("keyData: Cannot import JWK. 'd' or 'x' must be presented")}case"pkcs8":{const e=Cr.fromBufferSource(r,"PRIVATE KEY");return new Zs(s,i,a,e)}case"spki":{const e=Cr.fromBufferSource(r,"PUBLIC KEY");return new Qs(s,i,a,e)}case"raw":{const e=r,t=n.createPublicKey({format:"jwk",key:{kty:"OKP",crv:"ed25519"===s.name.toLowerCase()?"Ed25519":"X25519",x:o.Convert.ToBase64Url(e)}}).export({format:"pem",type:"spki"});return new Qs(s,i,a,t)}default:return Promise.reject(new Er("format: Must be 'jwk', 'raw', pkcs8' or 'spki'"))}}}ei.privateKeyUsages=["sign","deriveBits","deriveKey"],ei.publicKeyUsages=["verify"];class ti extends Ln{async onGenerateKey(e,t,r){const n=await ei.generateKey(e,t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onSign(e,t,r){const n=ts(t);return ei.sign(e,n,new Uint8Array(r))}onVerify(e,t,r,n){const s=ts(t);return ei.verify(e,s,new Uint8Array(r),new Uint8Array(n))}async onExportKey(e,t){const r=ts(t);return ei.exportKey(e,r)}async onImportKey(e,t,r,n,s){return rs(await ei.importKey(e,t,r,n,s))}}class ri extends Tn{async onGenerateKey(e,t,r){const n=await ei.generateKey(e,t,r);return{privateKey:rs(n.privateKey),publicKey:rs(n.publicKey)}}async onDeriveBits(e,t,r){const s=ts(t),i=ts(e.public),o=n.createPublicKey({key:i.data.toString(),format:"pem",type:"spki"}),a=n.createPrivateKey({key:s.data.toString(),format:"pem",type:"pkcs8"}),c=n.diffieHellman({publicKey:o,privateKey:a});return new Uint8Array(c).buffer.slice(0,r>>3)}async onExportKey(e,t){const r=ts(t);return ei.exportKey(e,r)}async onImportKey(e,t,r,n,s){return rs(await ei.importKey(e,t,r,n,s))}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof Xs))throw new TypeError("key: Is not a Ed25519CryptoKey")}}class ni extends Wn{}class si extends Vn{async onDeriveBits(t,r,s){return new Promise((i,a)=>{const c=o.BufferSourceConverter.toArrayBuffer(t.salt),u=t.hash.name.replace("-","");n.pbkdf2(ts(r).data,e.from(c),t.iterations,s>>3,u,(e,t)=>{e?a(e):i(new Uint8Array(t).buffer)})})}async onImportKey(t,r,n,s,i){if("raw"===t){const t=new ni;return t.data=e.from(r),t.algorithm={name:this.name},t.extractable=!1,t.usages=i,rs(t)}throw new Er("format: Must be 'raw'")}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ni))throw new TypeError("key: Is not PBKDF CryptoKey")}}class ii extends Wn{get alg(){return`HS${this.algorithm.hash.name.toUpperCase().replace("SHA-","")}`}set alg(e){}}r([br({name:"k",converter:qn})],ii.prototype,"data",void 0);class oi extends Dn{async onGenerateKey(e,t,r){const s=(e.length||this.getDefaultLength(e.hash.name))>>3<<3,i=new ii;return i.algorithm={...e,length:s,name:this.name},i.extractable=t,i.usages=r,i.data=n.randomBytes(s>>3),rs(i)}async onSign(t,r,s){const i=Cs.getAlgorithmName(r.algorithm.hash),o=n.createHmac(i,ts(r).data).update(e.from(s)).digest();return new Uint8Array(o).buffer}async onVerify(t,r,s,i){const o=Cs.getAlgorithmName(r.algorithm.hash);return 0===n.createHmac(o,ts(r).data).update(e.from(i)).digest().compare(e.from(s))}async onImportKey(t,r,n,s,i){let o;switch(t.toLowerCase()){case"jwk":o=Ar.fromJSON(r,{targetSchema:ii});break;case"raw":o=new ii,o.data=e.from(r);break;default:throw new Er("format: Must be 'jwk' or 'raw'")}return o.algorithm={hash:{name:n.hash.name},name:this.name,length:o.data.length<<3},o.extractable=s,o.usages=i,rs(o)}async onExportKey(e,t){switch(e.toLowerCase()){case"jwk":return vr.toJSON(ts(t));case"raw":return new Uint8Array(ts(t).data).buffer;default:throw new Er("format: Must be 'jwk' or 'raw'")}}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ii))throw new TypeError("key: Is not HMAC CryptoKey")}}class ai extends Wn{}class ci extends Rn{async onImportKey(t,r,n,s,i){if("raw"!==t.toLowerCase())throw new Er("Operation not supported");const o=new ai;return o.data=e.from(r),o.algorithm={name:this.name},o.extractable=s,o.usages=i,rs(o)}async onDeriveBits(t,r,s){const i=t.hash.name.replace("-",""),a=n.createHash(i).digest().length,c=s/8,u=o.BufferSourceConverter.toUint8Array(t.info),l=n.createHmac(i,o.BufferSourceConverter.toUint8Array(t.salt)).update(o.BufferSourceConverter.toUint8Array(ts(r).data)).digest(),h=[e.alloc(0)],y=Math.ceil(c/a)+1;for(let t=1;t<y;++t)h.push(n.createHmac(i,l).update(e.concat([h[t-1],u,e.from([t])])).digest());return e.concat(h).slice(0,c)}checkCryptoKey(e,t){if(super.checkCryptoKey(e,t),!(ts(e)instanceof ai))throw new TypeError("key: Is not HKDF CryptoKey")}}class ui{static digest(t,r){const s=n.createHash(t.name.toLowerCase(),{outputLength:t.length}).update(e.from(r)).digest();return new Uint8Array(s).buffer}}class li extends $n{async onDigest(e,t){return ui.digest(e,t)}}class hi extends Jn{async onDigest(e,t){return ui.digest(e,t)}}class yi extends _n{constructor(){var e;super(),this.providers.set(new ns),this.providers.set(new fs),this.providers.set(new ps),this.providers.set(new ys),this.providers.set(new gs),this.providers.set(new ms);n.getCiphers().includes("des-cbc")&&this.providers.set(new vs),this.providers.set(new As),this.providers.set(new Es),this.providers.set(new Ks),this.providers.set(new xs),this.providers.set(new Ns),this.providers.set(new Js),this.providers.set(new js),this.providers.set(new Hs),this.providers.set(new Ts),this.providers.set(new Ls),this.providers.set(new Ds),this.providers.set(new si),this.providers.set(new oi),this.providers.set(new ci);const r=null===(e=/^v(\d+)/.exec(t))||void 0===e?void 0:e[1];r&&parseInt(r,10)>=12&&(this.providers.set(new li),this.providers.set(new hi));const s=n.getHashes();s.includes("sha3-256")&&this.providers.set(new Vs),s.includes("sha3-384")&&this.providers.set(new Rs),s.includes("sha3-512")&&this.providers.set(new Ms),r&&parseInt(r,10)>=14&&(this.providers.set(new Ws),this.providers.set(new Ys),this.providers.set(new ti),this.providers.set(new ri))}}class fi extends jn{constructor(){super(...arguments),this.subtle=new yi}getRandomValues(t){if(!ArrayBuffer.isView(t))throw new TypeError("Failed to execute 'getRandomValues' on 'Crypto': parameter 1 is not of type 'ArrayBufferView'");const r=e.from(t.buffer,t.byteOffset,t.byteLength);return n.randomFillSync(r),t}}export{fi as Crypto,zr as CryptoKey};
|
|
File without changes
|
/package/dist/{ensureNotRevoked-ByWaYoog-BheL-ZKZ.js → ensureNotRevoked-CNUfpW4F-BheL-ZKZ.js}
RENAMED
|
File without changes
|
|
File without changes
|