@protontech/openpgp
Version:
OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.
3 lines • 429 kB
JavaScript
/*! OpenPGP.js v6.2.2 - 2025-09-02 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
var openpgp=function(e){"use strict";const t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(r){if("default"!==r&&!(r in e)){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}))})),Object.freeze(e)}const n=Symbol("doneWritingPromise"),i=Symbol("doneWritingResolve"),s=Symbol("doneWritingReject"),a=Symbol("readingIndex");class ArrayStream extends Array{constructor(){super(),Object.setPrototypeOf(this,ArrayStream.prototype),this[n]=new Promise(((e,t)=>{this[i]=e,this[s]=t})),this[n].catch((()=>{}))}}function o(e){return e&&e.getReader&&Array.isArray(e)}function c(e){if(!o(e)){const t=e.getWriter(),r=t.releaseLock;return t.releaseLock=()=>{t.closed.catch((function(){})),r.call(t)},t}this.stream=e}function u(e){if(o(e))return"array";if(t.ReadableStream&&t.ReadableStream.prototype.isPrototypeOf(e))return"web";if(e&&!(t.ReadableStream&&e instanceof t.ReadableStream)&&"function"==typeof e._read&&"object"==typeof e._readableState)throw Error("Native Node streams are no longer supported: please manually convert the stream to a WebStream, using e.g. `stream.Readable.toWeb`");return!(!e||!e.getReader)&&"web-like"}function h(e){return Uint8Array.prototype.isPrototypeOf(e)}function l(e){if(1===e.length)return e[0];let t=0;for(let r=0;r<e.length;r++){if(!h(e[r]))throw Error("concatUint8Array: Data must be in the form of a Uint8Array");t+=e[r].length}const r=new Uint8Array(t);let n=0;return e.forEach((function(e){r.set(e,n),n+=e.length})),r}ArrayStream.prototype.getReader=function(){return void 0===this[a]&&(this[a]=0),{read:async()=>(await this[n],this[a]===this.length?{value:void 0,done:!0}:{value:this[this[a]++],done:!1})}},ArrayStream.prototype.readToEnd=async function(e){await this[n];const t=e(this.slice(this[a]));return this.length=0,t},ArrayStream.prototype.clone=function(){const e=new ArrayStream;return e[n]=this[n].then((()=>{e.push(...this)})),e},c.prototype.write=async function(e){this.stream.push(e)},c.prototype.close=async function(){this.stream[i]()},c.prototype.abort=async function(e){return this.stream[s](e),e},c.prototype.releaseLock=function(){},"object"==typeof t.process&&t.process.versions;const f=new WeakSet,y=Symbol("externalBuffer");function p(e){if(this.stream=e,e[y]&&(this[y]=e[y].slice()),o(e)){const t=e.getReader();return this._read=t.read.bind(t),this._releaseLock=()=>{},void(this._cancel=()=>{})}if(u(e)){const t=e.getReader();return this._read=t.read.bind(t),this._releaseLock=()=>{t.closed.catch((function(){})),t.releaseLock()},void(this._cancel=t.cancel.bind(t))}let t=!1;this._read=async()=>t||f.has(e)?{value:void 0,done:!0}:(t=!0,{value:e,done:!1}),this._releaseLock=()=>{if(t)try{f.add(e)}catch(e){}}}function d(e){return u(e)?e:new ReadableStream({start(t){t.enqueue(e),t.close()}})}function g(e){if(u(e))return e;const t=new ArrayStream;return(async()=>{const r=x(t);await r.write(e),await r.close()})(),t}function A(e){return e.some((e=>u(e)&&!o(e)))?function(e){e=e.map(d);const t=b((async function(e){await Promise.all(n.map((t=>U(t,e))))}));let r=Promise.resolve();const n=e.map(((n,i)=>E(n,((n,s)=>(r=r.then((()=>w(n,t.writable,{preventClose:i!==e.length-1}))),r)))));return t.readable}(e):e.some((e=>o(e)))?function(e){const t=new ArrayStream;let r=Promise.resolve();return e.forEach(((n,i)=>(r=r.then((()=>w(n,t,{preventClose:i!==e.length-1}))),r))),t}(e):"string"==typeof e[0]?e.join(""):l(e)}async function w(e,t,{preventClose:r=!1,preventAbort:n=!1,preventCancel:i=!1}={}){if(u(e)&&!o(e)){e=d(e);try{if(e[y]){const r=x(t);for(let t=0;t<e[y].length;t++)await r.ready,await r.write(e[y][t]);r.releaseLock()}await e.pipeTo(t,{preventClose:r,preventAbort:n,preventCancel:i})}catch(e){}return}const s=D(e=g(e)),a=x(t);try{for(;;){await a.ready;const{done:e,value:t}=await s.read();if(e){r||await a.close();break}await a.write(t)}}catch(e){n||await a.abort(e)}finally{s.releaseLock(),a.releaseLock()}}function m(e,t){const r=new TransformStream(t);return w(e,r.writable),r.readable}function b(e){let t,r,n,i=!1,s=!1;return{readable:new ReadableStream({start(e){n=e},pull(){t?t():i=!0},async cancel(t){s=!0,e&&await e(t),r&&r(t)}},{highWaterMark:0}),writable:new WritableStream({write:async function(e){if(s)throw Error("Stream is cancelled");n.enqueue(e),i?i=!1:(await new Promise(((e,n)=>{t=e,r=n})),t=null,r=null)},close:n.close.bind(n),abort:n.error.bind(n)})}}function k(e,t=()=>{},r=()=>{}){if(o(e)){const n=new ArrayStream;return(async()=>{const i=x(n);try{const n=await C(e),s=t(n),a=r();let o;o=void 0!==s&&void 0!==a?A([s,a]):void 0!==s?s:a,await i.write(o),await i.close()}catch(e){await i.abort(e)}})(),n}if(u(e))return m(e,{async transform(e,r){try{const n=await t(e);void 0!==n&&r.enqueue(n)}catch(e){r.error(e)}},async flush(e){try{const t=await r();void 0!==t&&e.enqueue(t)}catch(t){e.error(t)}}});const n=t(e),i=r();return void 0!==n&&void 0!==i?A([n,i]):void 0!==n?n:i}function E(e,t){if(u(e)&&!o(e)){let r;const n=new TransformStream({start(e){r=e}}),i=w(e,n.writable),s=b((async function(e){r.error(e),await i,await new Promise(setTimeout)}));return t(n.readable,s.writable),s.readable}e=g(e);const r=new ArrayStream;return t(e,r),r}function v(e,t){let r;const n=E(e,((e,i)=>{const s=D(e);s.remainder=()=>(s.releaseLock(),w(e,i),n),r=t(s)}));return r}function K(e){if(o(e))return e.clone();if(u(e)){const t=function(e){if(o(e))throw Error("ArrayStream cannot be tee()d, use clone() instead");if(u(e)){const t=d(e).tee();return t[0][y]=t[1][y]=e[y],t}return[B(e),B(e)]}(e);return I(e,t[0]),t[1]}return B(e)}function S(e){return o(e)?K(e):u(e)?new ReadableStream({start(t){const r=E(e,(async(e,r)=>{const n=D(e),i=x(r);try{for(;;){await i.ready;const{done:e,value:r}=await n.read();if(e){try{t.close()}catch(e){}return void await i.close()}try{t.enqueue(r)}catch(e){}await i.write(r)}}catch(e){t.error(e),await i.abort(e)}}));I(e,r)}}):B(e)}function I(e,t){Object.entries(Object.getOwnPropertyDescriptors(e.constructor.prototype)).forEach((([r,n])=>{"constructor"!==r&&(n.value?n.value=n.value.bind(t):n.get=n.get.bind(t),Object.defineProperty(e,r,n))}))}function B(e,t=0,r=1/0){if(o(e))throw Error("Not implemented");if(u(e)){if(t>=0&&r>=0){let n=0;return m(e,{transform(e,i){n<r?(n+e.length>=t&&i.enqueue(B(e,Math.max(t-n,0),r-n)),n+=e.length):i.terminate()}})}if(t<0&&(r<0||r===1/0)){let n=[];return k(e,(e=>{e.length>=-t?n=[e]:n.push(e)}),(()=>B(A(n),t,r)))}if(0===t&&r<0){let n;return k(e,(e=>{const i=n?A([n,e]):e;if(i.length>=-r)return n=B(i,r),B(i,t,r);n=i}))}return console.warn(`stream.slice(input, ${t}, ${r}) not implemented efficiently.`),P((async()=>B(await C(e),t,r)))}return e[y]&&(e=A(e[y].concat([e]))),h(e)?e.subarray(t,r===1/0?e.length:r):e.slice(t,r)}async function C(e,t=A){return o(e)?e.readToEnd(t):u(e)?D(e).readToEnd(t):e}async function U(e,t){if(u(e)){if(e.cancel){const r=await e.cancel(t);return await new Promise(setTimeout),r}if(e.destroy)return e.destroy(t),await new Promise(setTimeout),t}}function P(e){const t=new ArrayStream;return(async()=>{const r=x(t);try{await r.write(await e()),await r.close()}catch(e){await r.abort(e)}})(),t}function D(e){return new p(e)}function x(e){return new c(e)}p.prototype.read=async function(){if(this[y]&&this[y].length){return{done:!1,value:this[y].shift()}}return this._read()},p.prototype.releaseLock=function(){this[y]&&(this.stream[y]=this[y]),this._releaseLock()},p.prototype.cancel=function(e){return this._cancel(e)},p.prototype.readLine=async function(){let e,t=[];for(;!e;){let{done:r,value:n}=await this.read();if(n+="",r)return t.length?A(t):void 0;const i=n.indexOf("\n")+1;i&&(e=A(t.concat(n.substr(0,i))),t=[]),i!==n.length&&t.push(n.substr(i))}return this.unshift(...t),e},p.prototype.readByte=async function(){const{done:e,value:t}=await this.read();if(e)return;const r=t[0];return this.unshift(B(t,1)),r},p.prototype.readBytes=async function(e){const t=[];let r=0;for(;;){const{done:n,value:i}=await this.read();if(n)return t.length?A(t):void 0;if(t.push(i),r+=i.length,r>=e){const r=A(t);return this.unshift(B(r,e)),B(r,0,e)}}},p.prototype.peekBytes=async function(e){const t=await this.readBytes(e);return this.unshift(t),t},p.prototype.unshift=function(...e){this[y]||(this[y]=[]),1===e.length&&h(e[0])&&this[y].length&&e[0].length&&this[y][0].byteOffset>=e[0].length?this[y][0]=new Uint8Array(this[y][0].buffer,this[y][0].byteOffset-e[0].length,this[y][0].byteLength+e[0].length):this[y].unshift(...e.filter((e=>e&&e.length)))},p.prototype.readToEnd=async function(e=A){const t=[];for(;;){const{done:e,value:r}=await this.read();if(e)break;t.push(r)}return e(t)};const Q=Symbol("byValue");var R={curve:{nistP256:"nistP256",p256:"nistP256",nistP384:"nistP384",p384:"nistP384",nistP521:"nistP521",p521:"nistP521",secp256k1:"secp256k1",ed25519Legacy:"ed25519Legacy",ed25519:"ed25519Legacy",curve25519Legacy:"curve25519Legacy",curve25519:"curve25519Legacy",brainpoolP256r1:"brainpoolP256r1",brainpoolP384r1:"brainpoolP384r1",brainpoolP512r1:"brainpoolP512r1"},kdfFlags:{replace_fingerprint:1,replace_kdf_params:2},s2k:{simple:0,salted:1,iterated:3,argon2:4,gnu:101},publicKey:{rsaEncryptSign:1,rsaEncrypt:2,rsaSign:3,elgamal:16,dsa:17,ecdh:18,ecdsa:19,eddsaLegacy:22,aedh:23,aedsa:24,x25519:25,x448:26,ed25519:27,ed448:28,pqc_mldsa_ed25519:30,pqc_mlkem_x25519:35,aead:100,hmac:101},symmetric:{idea:1,tripledes:2,cast5:3,blowfish:4,aes128:7,aes192:8,aes256:9,twofish:10},compression:{uncompressed:0,zip:1,zlib:2,bzip2:3},hash:{md5:1,sha1:2,ripemd:3,sha256:8,sha384:9,sha512:10,sha224:11,sha3_256:12,sha3_512:14},webHash:{"SHA-1":2,"SHA-256":8,"SHA-384":9,"SHA-512":10},aead:{eax:1,ocb:2,gcm:3,experimentalGCM:100},packet:{publicKeyEncryptedSessionKey:1,signature:2,symEncryptedSessionKey:3,onePassSignature:4,secretKey:5,publicKey:6,secretSubkey:7,compressedData:8,symmetricallyEncryptedData:9,marker:10,literalData:11,trust:12,userID:13,publicSubkey:14,userAttribute:17,symEncryptedIntegrityProtectedData:18,modificationDetectionCode:19,aeadEncryptedData:20,padding:21},literal:{binary:98,text:116,utf8:117,mime:109},signature:{binary:0,text:1,standalone:2,certGeneric:16,certPersona:17,certCasual:18,certPositive:19,certRevocation:48,subkeyBinding:24,keyBinding:25,key:31,keyRevocation:32,subkeyRevocation:40,timestamp:64,thirdParty:80},signatureSubpacket:{signatureCreationTime:2,signatureExpirationTime:3,exportableCertification:4,trustSignature:5,regularExpression:6,revocable:7,keyExpirationTime:9,placeholderBackwardsCompatibility:10,preferredSymmetricAlgorithms:11,revocationKey:12,issuerKeyID:16,notationData:20,preferredHashAlgorithms:21,preferredCompressionAlgorithms:22,keyServerPreferences:23,preferredKeyServer:24,primaryUserID:25,policyURI:26,keyFlags:27,signersUserID:28,reasonForRevocation:29,features:30,signatureTarget:31,embeddedSignature:32,issuerFingerprint:33,preferredAEADAlgorithms:34,preferredCipherSuites:39},keyFlags:{certifyKeys:1,signData:2,encryptCommunication:4,encryptStorage:8,splitPrivateKey:16,authentication:32,forwardedCommunication:64,sharedPrivateKey:128},armor:{multipartSection:0,multipartLast:1,signed:2,message:3,publicKey:4,privateKey:5,signature:6},reasonForRevocation:{noReason:0,keySuperseded:1,keyCompromised:2,keyRetired:3,userIDInvalid:32},features:{modificationDetection:1,aead:2,v5Keys:4,seipdv2:8},write:function(e,t){if("number"==typeof t&&(t=this.read(e,t)),void 0!==e[t])return e[t];throw Error("Invalid enum value.")},read:function(e,t){if(e[Q]||(e[Q]=[],Object.entries(e).forEach((([t,r])=>{e[Q][r]=t}))),void 0!==e[Q][t])return e[Q][t];throw Error("Invalid enum value.")}},T={preferredHashAlgorithm:R.hash.sha512,preferredSymmetricAlgorithm:R.symmetric.aes256,preferredCompressionAlgorithm:R.compression.uncompressed,aeadProtect:!1,ignoreSEIPDv2FeatureFlag:!1,parseAEADEncryptedV4KeysAsLegacy:!1,preferredAEADAlgorithm:R.aead.gcm,aeadChunkSizeByte:12,v6Keys:!1,enableParsingV5Entities:!1,s2kType:R.s2k.iterated,s2kIterationCountByte:224,s2kArgon2Params:{passes:3,parallelism:4,memoryExponent:16},allowUnauthenticatedMessages:!1,allowUnauthenticatedStream:!1,allowForwardedMessages:!1,minRSABits:2047,passwordCollisionCheck:!1,allowInsecureDecryptionWithSigningKeys:!1,allowInsecureVerificationWithReformattedKeys:!1,allowMissingKeyFlags:!1,constantTimePKCS1Decryption:!1,constantTimePKCS1DecryptionSupportedSymmetricAlgorithms:new Set([R.symmetric.aes128,R.symmetric.aes192,R.symmetric.aes256]),ignoreUnsupportedPackets:!0,ignoreMalformedPackets:!1,enforceGrammar:!0,additionalAllowedPackets:[],showVersion:!1,showComment:!1,versionString:"OpenPGP.js 6.2.2",commentString:"https://openpgpjs.org",maxUserIDLength:5120,knownNotations:[],nonDeterministicSignaturesViaNotation:!0,useEllipticFallback:!0,rejectHashAlgorithms:new Set([R.hash.md5,R.hash.ripemd]),rejectMessageHashAlgorithms:new Set([R.hash.md5,R.hash.ripemd,R.hash.sha1]),rejectPublicKeyAlgorithms:new Set([R.publicKey.elgamal,R.publicKey.dsa]),rejectCurves:new Set([R.curve.secp256k1])};const M=(()=>{try{return"development"===process.env.NODE_ENV}catch(e){}return!1})(),L={isString:function(e){return"string"==typeof e||e instanceof String},nodeRequire:()=>{},isArray:function(e){return e instanceof Array},isUint8Array:h,isStream:u,getNobleCurve:async(e,t)=>{if(!T.useEllipticFallback)throw Error("This curve is only supported in the full build of OpenPGP.js");const{nobleCurves:r}=await Promise.resolve().then((function(){return Tl}));switch(e){case R.publicKey.ecdh:case R.publicKey.ecdsa:{const e=r.get(t);if(!e)throw Error("Unsupported curve");return e}case R.publicKey.x448:return r.get("x448");case R.publicKey.ed448:return r.get("ed448");default:throw Error("Unsupported curve")}},readNumber:function(e){let t=0;for(let r=0;r<e.length;r++)t+=256**r*e[e.length-1-r];return t},writeNumber:function(e,t){const r=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e>>8*(t-n-1)&255;return r},readDate:function(e){const t=L.readNumber(e);return new Date(1e3*t)},writeDate:function(e){const t=Math.floor(e.getTime()/1e3);return L.writeNumber(t,4)},normalizeDate:function(e=Date.now()){return null===e||e===1/0?e:new Date(1e3*Math.floor(+e/1e3))},readMPI:function(e){const t=(e[0]<<8|e[1])+7>>>3;return L.readExactSubarray(e,2,2+t)},readExactSubarray:function(e,t,r){if(e.length<r-t)throw Error("Input array too short");return e.subarray(t,r)},leftPad(e,t){if(e.length>t)throw Error("Input array too long");const r=new Uint8Array(t),n=t-e.length;return r.set(e,n),r},uint8ArrayToMPI:function(e){const t=L.uint8ArrayBitLength(e);if(0===t)throw Error("Zero MPI");const r=e.subarray(e.length-Math.ceil(t/8)),n=new Uint8Array([(65280&t)>>8,255&t]);return L.concatUint8Array([n,r])},uint8ArrayBitLength:function(e){let t;for(t=0;t<e.length&&0===e[t];t++);if(t===e.length)return 0;const r=e.subarray(t);return 8*(r.length-1)+L.nbits(r[0])},hexToUint8Array:function(e){const t=new Uint8Array(e.length>>1);for(let r=0;r<e.length>>1;r++)t[r]=parseInt(e.substr(r<<1,2),16);return t},uint8ArrayToHex:function(e){const t="0123456789abcdef";let r="";return e.forEach((e=>{r+=t[e>>4]+t[15&e]})),r},stringToUint8Array:function(e){return k(e,(e=>{if(!L.isString(e))throw Error("stringToUint8Array: Data must be in the form of a string");const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}))},uint8ArrayToString:function(e){const t=[],r=16384,n=(e=new Uint8Array(e)).length;for(let i=0;i<n;i+=r)t.push(String.fromCharCode.apply(String,e.subarray(i,i+r<n?i+r:n)));return t.join("")},encodeUTF8:function(e){const t=new TextEncoder("utf-8");function r(e,r=!1){return t.encode(e,{stream:!r})}return k(e,r,(()=>r("",!0)))},decodeUTF8:function(e){const t=new TextDecoder("utf-8");function r(e,r=!1){return t.decode(e,{stream:!r})}return k(e,r,(()=>r(new Uint8Array,!0)))},concat:A,concatUint8Array:l,equalsUint8Array:function(e,t){if(!L.isUint8Array(e)||!L.isUint8Array(t))throw Error("Data must be in the form of a Uint8Array");if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0},findLastIndex:function(e,t){for(let r=e.length;r>=0;r--)if(t(e[r],r,e))return r;return-1},writeChecksum:function(e){let t=0;for(let r=0;r<e.length;r++)t=t+e[r]&65535;return L.writeNumber(t,2)},printDebug:function(e){M&&console.log("[OpenPGP.js debug]",e)},printDebugError:function(e){M&&console.error("[OpenPGP.js debug]",e)},nbits:function(e){let t=1,r=e>>>16;return 0!==r&&(e=r,t+=16),r=e>>8,0!==r&&(e=r,t+=8),r=e>>4,0!==r&&(e=r,t+=4),r=e>>2,0!==r&&(e=r,t+=2),r=e>>1,0!==r&&(e=r,t+=1),t},double:function(e){const t=new Uint8Array(e.length),r=e.length-1;for(let n=0;n<r;n++)t[n]=e[n]<<1^e[n+1]>>7;return t[r]=e[r]<<1^135*(e[0]>>7),t},shiftRight:function(e,t){if(t)for(let r=e.length-1;r>=0;r--)e[r]>>=t,r>0&&(e[r]|=e[r-1]<<8-t);return e},getWebCrypto:function(){const e=void 0!==t&&t.crypto&&t.crypto.subtle||this.getNodeCrypto()?.webcrypto.subtle;if(!e)throw Error("The WebCrypto API is not available");return e},getNodeCrypto:function(){return this.nodeRequire("crypto")},getNodeZlib:function(){return this.nodeRequire("zlib")},getNodeBuffer:function(){return(this.nodeRequire("buffer")||{}).Buffer},getHardwareConcurrency:function(){if("undefined"!=typeof navigator)return navigator.hardwareConcurrency||1;return this.nodeRequire("os").cpus().length},isEmailAddress:function(e){if(!L.isString(e))return!1;return/^[^\p{C}\p{Z}@<>\\]+@[^\p{C}\p{Z}@<>\\]+[^\p{C}\p{Z}\p{P}]$/u.test(e)},canonicalizeEOL:function(e){let t=!1;return k(e,(e=>{let r;t&&(e=L.concatUint8Array([new Uint8Array([13]),e])),13===e[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;const n=[];for(let t=0;r=e.indexOf(10,t)+1,r;t=r)13!==e[r-2]&&n.push(r);if(!n.length)return e;const i=new Uint8Array(e.length+n.length);let s=0;for(let t=0;t<n.length;t++){const r=e.subarray(n[t-1]||0,n[t]);i.set(r,s),s+=r.length,i[s-1]=13,i[s]=10,s++}return i.set(e.subarray(n[n.length-1]||0),s),i}),(()=>t?new Uint8Array([13]):void 0))},nativeEOL:function(e){let t=!1;return k(e,(e=>{let r;13===(e=t&&10!==e[0]?L.concatUint8Array([new Uint8Array([13]),e]):new Uint8Array(e))[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;let n=0;for(let t=0;t!==e.length;t=r){r=e.indexOf(13,t)+1,r||(r=e.length);const i=r-(10===e[r]?1:0);t&&e.copyWithin(n,t,i),n+=i-t}return e.subarray(0,n)}),(()=>t?new Uint8Array([13]):void 0))},removeTrailingSpaces:function(e){return e.split("\n").map((e=>{let t=e.length-1;for(;t>=0&&(" "===e[t]||"\t"===e[t]||"\r"===e[t]);t--);return e.substr(0,t+1)})).join("\n")},wrapError:function(e,t){if(!t)return e instanceof Error?e:Error(e);if(e instanceof Error){try{e.message+=": "+t.message,e.cause=t}catch(e){}return e}return Error(e+": "+t.message,{cause:t})},constructAllowedPackets:function(e){const t={};return e.forEach((e=>{if(!e.tag)throw Error("Invalid input: expected a packet class");t[e.tag]=e})),t},anyPromise:function(e){return new Promise((async(t,r)=>{let n;await Promise.all(e.map((async e=>{try{t(await e)}catch(e){n=e}}))),r(n)}))},selectUint8Array:function(e,t,r){const n=Math.max(t.length,r.length),i=new Uint8Array(n);let s=0;for(let n=0;n<i.length;n++)i[n]=t[n]&256-e|r[n]&255+e,s+=e&n<t.length|1-e&n<r.length;return i.subarray(0,s)},selectUint8:function(e,t,r){return t&256-e|r&255+e},isAES:function(e){return e===R.symmetric.aes128||e===R.symmetric.aes192||e===R.symmetric.aes256}},F=L.getNodeBuffer();let O,N;function _(e){let t=new Uint8Array;return k(e,(e=>{t=L.concatUint8Array([t,e]);const r=[],n=Math.floor(t.length/45),i=45*n,s=O(t.subarray(0,i));for(let e=0;e<n;e++)r.push(s.substr(60*e,60)),r.push("\n");return t=t.subarray(i),r.join("")}),(()=>t.length?O(t)+"\n":""))}function H(e){let t="";return k(e,(e=>{t+=e;let r=0;const n=[" ","\t","\r","\n"];for(let e=0;e<n.length;e++){const i=n[e];for(let e=t.indexOf(i);-1!==e;e=t.indexOf(i,e+1))r++}let i=t.length;for(;i>0&&(i-r)%4!=0;i--)n.includes(t[i])&&r--;const s=N(t.substr(0,i));return t=t.substr(i),s}),(()=>N(t)))}function z(e){return H(e.replace(/-/g,"+").replace(/_/g,"/"))}function G(e,t){let r=_(e).replace(/[\r\n]/g,"");return r=r.replace(/[+]/g,"-").replace(/[/]/g,"_").replace(/[=]/g,""),r}function q(e){const t=e.match(/^-----BEGIN PGP (MESSAGE, PART \d+\/\d+|MESSAGE, PART \d+|SIGNED MESSAGE|MESSAGE|PUBLIC KEY BLOCK|PRIVATE KEY BLOCK|SIGNATURE)-----$/m);if(!t)throw Error("Unknown ASCII armor type");return/MESSAGE, PART \d+\/\d+/.test(t[1])?R.armor.multipartSection:/MESSAGE, PART \d+/.test(t[1])?R.armor.multipartLast:/SIGNED MESSAGE/.test(t[1])?R.armor.signed:/MESSAGE/.test(t[1])?R.armor.message:/PUBLIC KEY BLOCK/.test(t[1])?R.armor.publicKey:/PRIVATE KEY BLOCK/.test(t[1])?R.armor.privateKey:/SIGNATURE/.test(t[1])?R.armor.signature:void 0}function j(e,t){let r="";return t.showVersion&&(r+="Version: "+t.versionString+"\n"),t.showComment&&(r+="Comment: "+t.commentString+"\n"),e&&(r+="Comment: "+e+"\n"),r+="\n",r}function V(e){const t=function(e){let t=13501623;return k(e,(e=>{const r=Z?Math.floor(e.length/4):0,n=new Uint32Array(e.buffer,e.byteOffset,r);for(let e=0;e<r;e++)t^=n[e],t=Y[0][t>>24&255]^Y[1][t>>16&255]^Y[2][t>>8&255]^Y[3][255&t];for(let n=4*r;n<e.length;n++)t=t>>8^Y[0][255&t^e[n]]}),(()=>new Uint8Array([t,t>>8,t>>16])))}(e);return _(t)}F?(O=e=>F.from(e).toString("base64"),N=e=>{const t=F.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}):(O=e=>btoa(L.uint8ArrayToString(e)),N=e=>L.stringToUint8Array(atob(e)));const Y=[Array(255),Array(255),Array(255),Array(255)];for(let e=0;e<=255;e++){let t=e<<16;for(let e=0;e<8;e++)t=t<<1^(8388608&t?8801531:0);Y[0][e]=(16711680&t)>>16|65280&t|(255&t)<<16}for(let e=0;e<=255;e++)Y[1][e]=Y[0][e]>>8^Y[0][255&Y[0][e]];for(let e=0;e<=255;e++)Y[2][e]=Y[1][e]>>8^Y[0][255&Y[1][e]];for(let e=0;e<=255;e++)Y[3][e]=Y[2][e]>>8^Y[0][255&Y[2][e]];const Z=function(){const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,255,!0),255===new Int16Array(e)[0]}();function J(e){for(let t=0;t<e.length;t++)/^([^\s:]|[^\s:][^:]*[^\s:]): .+$/.test(e[t])||L.printDebugError(Error("Improperly formatted armor header: "+e[t])),/^(Version|Comment|MessageID|Hash|Charset): .+$/.test(e[t])||L.printDebugError(Error("Unknown header: "+e[t]))}function X(e){let t=e;const r=e.lastIndexOf("=");return r>=0&&r!==e.length-1&&(t=e.slice(0,r)),t}function W(e){return new Promise((async(t,r)=>{try{const n=/^-----[^-]+-----$/m,i=/^[ \f\r\t\u00a0\u2000-\u200a\u202f\u205f\u3000]*$/;let s;const a=[];let o,c,u=a,h=[];const l=H(E(e,(async(e,f)=>{const y=D(e);try{for(;;){let e=await y.readLine();if(void 0===e)throw Error("Misformed armored text");if(e=L.removeTrailingSpaces(e.replace(/[\r\n]/g,"")),s)if(o)c||s!==R.armor.signed||(n.test(e)?(h=h.join("\r\n"),c=!0,J(u),u=[],o=!1):h.push(e.replace(/^- /,"")));else if(n.test(e)&&r(Error("Mandatory blank line missing between armor headers and armor data")),i.test(e)){if(J(u),o=!0,c||s!==R.armor.signed){t({text:h,data:l,headers:a,type:s});break}}else u.push(e);else n.test(e)&&(s=q(e))}}catch(e){return void r(e)}const p=x(f);try{for(;;){await p.ready;const{done:e,value:t}=await y.read();if(e)throw Error("Misformed armored text");const r=t+"";if(-1!==r.indexOf("=")||-1!==r.indexOf("-")){let e=await y.readToEnd();e.length||(e=""),e=r+e,e=L.removeTrailingSpaces(e.replace(/\r/g,""));const t=e.split(n);if(1===t.length)throw Error("Misformed armored text");const i=X(t[0].slice(0,-1));await p.write(i);break}await p.write(r)}await p.ready,await p.close()}catch(e){await p.abort(e)}})))}catch(e){r(e)}})).then((async e=>(o(e.data)&&(e.data=await C(e.data)),e)))}function $(e,t,r,n,i,s=!1,a=T){let o,c;e===R.armor.signed&&(o=t.text,c=t.hash,t=t.data);const u=s&&S(t),h=[];switch(e){case R.armor.multipartSection:h.push("-----BEGIN PGP MESSAGE, PART "+r+"/"+n+"-----\n"),h.push(j(i,a)),h.push(_(t)),u&&h.push("=",V(u)),h.push("-----END PGP MESSAGE, PART "+r+"/"+n+"-----\n");break;case R.armor.multipartLast:h.push("-----BEGIN PGP MESSAGE, PART "+r+"-----\n"),h.push(j(i,a)),h.push(_(t)),u&&h.push("=",V(u)),h.push("-----END PGP MESSAGE, PART "+r+"-----\n");break;case R.armor.signed:h.push("-----BEGIN PGP SIGNED MESSAGE-----\n"),h.push(c?`Hash: ${c}\n\n`:"\n"),h.push(o.replace(/^-/gm,"- -")),h.push("\n-----BEGIN PGP SIGNATURE-----\n"),h.push(j(i,a)),h.push(_(t)),u&&h.push("=",V(u)),h.push("-----END PGP SIGNATURE-----\n");break;case R.armor.message:h.push("-----BEGIN PGP MESSAGE-----\n"),h.push(j(i,a)),h.push(_(t)),u&&h.push("=",V(u)),h.push("-----END PGP MESSAGE-----\n");break;case R.armor.publicKey:h.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),h.push(j(i,a)),h.push(_(t)),u&&h.push("=",V(u)),h.push("-----END PGP PUBLIC KEY BLOCK-----\n");break;case R.armor.privateKey:h.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\n"),h.push(j(i,a)),h.push(_(t)),u&&h.push("=",V(u)),h.push("-----END PGP PRIVATE KEY BLOCK-----\n");break;case R.armor.signature:h.push("-----BEGIN PGP SIGNATURE-----\n"),h.push(j(i,a)),h.push(_(t)),u&&h.push("=",V(u)),h.push("-----END PGP SIGNATURE-----\n")}return L.concat(h)}const ee=BigInt(0),te=BigInt(1);function re(e){const t="0123456789ABCDEF";let r="";return e.forEach((e=>{r+=t[e>>4]+t[15&e]})),BigInt("0x0"+r)}function ne(e,t){const r=e%t;return r<ee?r+t:r}function ie(e,t,r){if(r===ee)throw Error("Modulo cannot be zero");if(r===te)return BigInt(0);if(t<ee)throw Error("Unsopported negative exponent");let n=t,i=e;i%=r;let s=BigInt(1);for(;n>ee;){const e=n&te;n>>=te;s=e?s*i%r:s,i=i*i%r}return s}function se(e){return e>=ee?e:-e}function ae(e,t){const{gcd:r,x:n}=function(e,t){let r=BigInt(0),n=BigInt(1),i=BigInt(1),s=BigInt(0),a=se(e),o=se(t);const c=e<ee,u=t<ee;for(;o!==ee;){const e=a/o;let t=r;r=i-e*r,i=t,t=n,n=s-e*n,s=t,t=o,o=a%o,a=t}return{x:c?-i:i,y:u?-s:s,gcd:a}}(e,t);if(r!==te)throw Error("Inverse does not exist");return ne(n+t,t)}function oe(e){const t=Number(e);if(t>Number.MAX_SAFE_INTEGER)throw Error("Number can only safely store up to 53 bits");return t}function ce(e,t){return(e>>BigInt(t)&te)===ee?0:1}function ue(e){const t=e<ee?BigInt(-1):ee;let r=1,n=e;for(;(n>>=te)!==t;)r++;return r}function he(e){const t=e<ee?BigInt(-1):ee,r=BigInt(8);let n=1,i=e;for(;(i>>=r)!==t;)n++;return n}function le(e,t="be",r){let n=e.toString(16);n.length%2==1&&(n="0"+n);const i=n.length/2,s=new Uint8Array(r||i),a=r?r-i:0;let o=0;for(;o<i;)s[o+a]=parseInt(n.slice(2*o,2*o+2),16),o++;return"be"!==t&&s.reverse(),s}const fe=L.getNodeCrypto();function ye(e){const t="undefined"!=typeof crypto?crypto:fe?.webcrypto;if(t?.getRandomValues){const r=new Uint8Array(e);return t.getRandomValues(r)}throw Error("No secure random number generator available.")}function pe(e,t){if(t<e)throw Error("Illegal parameter value: max <= min");const r=t-e;return ne(re(ye(he(r)+8)),r)+e}const de=BigInt(1);function ge(e,t,r){const n=BigInt(30),i=de<<BigInt(e-1),s=[1,6,5,4,3,2,1,4,3,2,1,2,1,4,3,2,1,2,1,4,3,2,1,6,5,4,3,2,1,2];let a=pe(i,i<<de),o=oe(ne(a,n));do{a+=BigInt(s[o]),o=(o+s[o])%s.length,ue(a)>e&&(a=ne(a,i<<de),a+=i,o=oe(ne(a,n)))}while(!Ae(a,t,r));return a}function Ae(e,t,r){return(!t||function(e,t){let r=e,n=t;for(;n!==ee;){const e=n;n=r%n,r=e}return r}(e-de,t)===de)&&(!!function(e){const t=BigInt(0);return we.every((r=>ne(e,r)!==t))}(e)&&(!!function(e,t=BigInt(2)){return ie(t,e-de,e)===de}(e)&&!!function(e,t){const r=ue(e);t||(t=Math.max(1,r/48|0));const n=e-de;let i=0;for(;!ce(n,i);)i++;const s=e>>BigInt(i);for(;t>0;t--){let t,r=ie(pe(BigInt(2),n),s,e);if(r!==de&&r!==n){for(t=1;t<i;t++){if(r=ne(r*r,e),r===de)return!1;if(r===n)break}if(t===i)return!1}}return!0}(e,r)))}const we=[7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999,3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999].map((e=>BigInt(e)));const me=L.getWebCrypto(),be=L.getNodeCrypto(),ke=be&&be.getHashes();function Ee(e){if(be&&ke.includes(e))return async function(t){const r=be.createHash(e);return k(t,(e=>{r.update(e)}),(()=>new Uint8Array(r.digest())))}}function ve(e,t){const r=async()=>{const{nobleHashes:t}=await Promise.resolve().then((function(){return uf})),r=t.get(e);if(!r)throw Error("Unsupported hash");return r};return async function(e){if(o(e)&&(e=await C(e)),L.isStream(e)){const t=(await r()).create();return k(e,(e=>{t.update(e)}),(()=>t.digest()))}if(me&&t)return new Uint8Array(await me.digest(t,e));return(await r())(e)}}const Ke=Ee("md5")||ve("md5"),Se=Ee("sha1")||ve("sha1","SHA-1"),Ie=Ee("sha224")||ve("sha224"),Be=Ee("sha256")||ve("sha256","SHA-256"),Ce=Ee("sha384")||ve("sha384","SHA-384"),Ue=Ee("sha512")||ve("sha512","SHA-512"),Pe=Ee("ripemd160")||ve("ripemd160"),De=Ee("sha3-256")||ve("sha3_256"),xe=Ee("sha3-512")||ve("sha3_512");function Qe(e,t){switch(e){case R.hash.md5:return Ke(t);case R.hash.sha1:return Se(t);case R.hash.ripemd:return Pe(t);case R.hash.sha256:return Be(t);case R.hash.sha384:return Ce(t);case R.hash.sha512:return Ue(t);case R.hash.sha224:return Ie(t);case R.hash.sha3_256:return De(t);case R.hash.sha3_512:return xe(t);default:throw Error("Unsupported hash function")}}function Re(e){switch(e){case R.hash.md5:return 16;case R.hash.sha1:case R.hash.ripemd:return 20;case R.hash.sha256:return 32;case R.hash.sha384:return 48;case R.hash.sha512:return 64;case R.hash.sha224:return 28;case R.hash.sha3_256:return 32;case R.hash.sha3_512:return 64;default:throw Error("Invalid hash algorithm.")}}const Te=[];function Me(e,t){const r=e.length;if(r>t-11)throw Error("Message too long");const n=function(e){const t=new Uint8Array(e);let r=0;for(;r<e;){const n=ye(e-r);for(let e=0;e<n.length;e++)0!==n[e]&&(t[r++]=n[e])}return t}(t-r-3),i=new Uint8Array(t);return i[1]=2,i.set(n,2),i.set(e,t-r),i}function Le(e,t){let r=2,n=1;for(let t=r;t<e.length;t++)n&=0!==e[t],r+=n;const i=r-2,s=e.subarray(r+1),a=0===e[0]&2===e[1]&i>=8&!n;if(t)return L.selectUint8Array(a,s,t);if(a)return s;throw Error("Decryption error")}function Fe(e,t,r){let n;if(t.length!==Re(e))throw Error("Invalid hash length");const i=new Uint8Array(Te[e].length);for(n=0;n<Te[e].length;n++)i[n]=Te[e][n];const s=i.length+t.length;if(r<s+11)throw Error("Intended encoded message length too short");const a=new Uint8Array(r-s-3).fill(255),o=new Uint8Array(r);return o[1]=1,o.set(a,2),o.set(i,r-s),o.set(t,r-t.length),o}Te[1]=[48,32,48,12,6,8,42,134,72,134,247,13,2,5,5,0,4,16],Te[2]=[48,33,48,9,6,5,43,14,3,2,26,5,0,4,20],Te[3]=[48,33,48,9,6,5,43,36,3,2,1,5,0,4,20],Te[8]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32],Te[9]=[48,65,48,13,6,9,96,134,72,1,101,3,4,2,2,5,0,4,48],Te[10]=[48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64],Te[11]=[48,45,48,13,6,9,96,134,72,1,101,3,4,2,4,5,0,4,28];const Oe=L.getWebCrypto(),Ne=L.getNodeCrypto(),_e=BigInt(1);async function He(e,t,r,n,i,s,a,o,c){if(Re(e)>=r.length)throw Error("Digest size cannot exceed key modulus size");if(t&&!L.isStream(t))if(L.getWebCrypto())try{return await async function(e,t,r,n,i,s,a,o){const c=await je(r,n,i,s,a,o),u={name:"RSASSA-PKCS1-v1_5",hash:{name:e}},h=await Oe.importKey("jwk",c,u,!1,["sign"]);return new Uint8Array(await Oe.sign("RSASSA-PKCS1-v1_5",h,t))}(R.read(R.webHash,e),t,r,n,i,s,a,o)}catch(e){L.printDebugError(e)}else if(L.getNodeCrypto())return async function(e,t,r,n,i,s,a,o){const c=Ne.createSign(R.read(R.hash,e));c.write(t),c.end();const u=await je(r,n,i,s,a,o);return new Uint8Array(c.sign({key:u,format:"jwk",type:"pkcs1"}))}(e,t,r,n,i,s,a,o);return async function(e,t,r,n){t=re(t);const i=re(Fe(e,n,he(t)));return r=re(r),le(ie(i,r,t),"be",he(t))}(e,r,i,c)}async function ze(e,t,r,n,i,s){if(t&&!L.isStream(t))if(L.getWebCrypto())try{return await async function(e,t,r,n,i){const s=Ve(n,i),a=await Oe.importKey("jwk",s,{name:"RSASSA-PKCS1-v1_5",hash:{name:e}},!1,["verify"]);return Oe.verify("RSASSA-PKCS1-v1_5",a,r,t)}(R.read(R.webHash,e),t,r,n,i)}catch(e){L.printDebugError(e)}else if(L.getNodeCrypto())return async function(e,t,r,n,i){const s=Ve(n,i),a={key:s,format:"jwk",type:"pkcs1"},o=Ne.createVerify(R.read(R.hash,e));o.write(t),o.end();try{return o.verify(a,r)}catch(e){return!1}}(e,t,r,n,i);return async function(e,t,r,n,i){if(r=re(r),t=re(t),n=re(n),t>=r)throw Error("Signature size cannot exceed modulus size");const s=le(ie(t,n,r),"be",he(r)),a=Fe(e,i,he(r));return L.equalsUint8Array(s,a)}(e,r,n,i,s)}async function Ge(e,t,r){return L.getNodeCrypto()?async function(e,t,r){const n=Ve(t,r),i={key:n,format:"jwk",type:"pkcs1",padding:Ne.constants.RSA_PKCS1_PADDING};return new Uint8Array(Ne.publicEncrypt(i,e))}(e,t,r):async function(e,t,r){if(t=re(t),e=re(Me(e,he(t))),r=re(r),e>=t)throw Error("Message size cannot exceed modulus size");return le(ie(e,r,t),"be",he(t))}(e,t,r)}async function qe(e,t,r,n,i,s,a,o){if(L.getNodeCrypto()&&!o)try{return await async function(e,t,r,n,i,s,a){const o=await je(t,r,n,i,s,a),c={key:o,format:"jwk",type:"pkcs1",padding:Ne.constants.RSA_PKCS1_PADDING};try{return new Uint8Array(Ne.privateDecrypt(c,e))}catch(e){throw Error("Decryption error")}}(e,t,r,n,i,s,a)}catch(e){L.printDebugError(e)}return async function(e,t,r,n,i,s,a,o){if(e=re(e),t=re(t),r=re(r),n=re(n),i=re(i),s=re(s),a=re(a),e>=t)throw Error("Data too large.");const c=ne(n,s-_e),u=ne(n,i-_e),h=pe(BigInt(2),t),l=ie(ae(h,t),r,t);e=ne(e*l,t);const f=ie(e,u,i),y=ie(e,c,s),p=ne(a*(y-f),s);let d=p*i+f;return d=ne(d*h,t),Le(le(d,"be",he(t)),o)}(e,t,r,n,i,s,a,o)}async function je(e,t,r,n,i,s){const a=re(n),o=re(i),c=re(r);let u=ne(c,o-_e),h=ne(c,a-_e);return h=le(h),u=le(u),{kty:"RSA",n:G(e),e:G(t),d:G(r),p:G(i),q:G(n),dp:G(u),dq:G(h),qi:G(s),ext:!0}}function Ve(e,t){return{kty:"RSA",n:G(e),e:G(t),ext:!0}}function Ye(e,t){return{n:z(e.n),e:le(t),d:z(e.d),p:z(e.q),q:z(e.p),u:z(e.qi)}}const Ze=BigInt(1);const Je={"2a8648ce3d030107":R.curve.nistP256,"2b81040022":R.curve.nistP384,"2b81040023":R.curve.nistP521,"2b8104000a":R.curve.secp256k1,"2b06010401da470f01":R.curve.ed25519Legacy,"2b060104019755010501":R.curve.curve25519Legacy,"2b2403030208010107":R.curve.brainpoolP256r1,"2b240303020801010b":R.curve.brainpoolP384r1,"2b240303020801010d":R.curve.brainpoolP512r1};class Xe{constructor(e){if(e instanceof Xe)this.oid=e.oid;else if(L.isArray(e)||L.isUint8Array(e)){if(6===(e=new Uint8Array(e))[0]){if(e[1]!==e.length-2)throw Error("Length mismatch in DER encoded oid");e=e.subarray(2)}this.oid=e}else this.oid=""}read(e){if(e.length>=1){const t=e[0];if(e.length>=1+t)return this.oid=e.subarray(1,1+t),1+this.oid.length}throw Error("Invalid oid")}write(){return L.concatUint8Array([new Uint8Array([this.oid.length]),this.oid])}toHex(){return L.uint8ArrayToHex(this.oid)}getName(){const e=Je[this.toHex()];if(!e)throw Error("Unknown curve object identifier.");return e}}function We(e){let t,r=0;const n=e[0];return n<192?([r]=e,t=1):n<255?(r=(e[0]-192<<8)+e[1]+192,t=2):255===n&&(r=L.readNumber(e.subarray(1,5)),t=5),{len:r,offset:t}}function $e(e){return e<192?new Uint8Array([e]):e>191&&e<8384?new Uint8Array([192+(e-192>>8),e-192&255]):L.concatUint8Array([new Uint8Array([255]),L.writeNumber(e,4)])}function et(e){if(e<0||e>30)throw Error("Partial Length power must be between 1 and 30");return new Uint8Array([224+e])}function tt(e){return new Uint8Array([192|e])}function rt(e,t){return L.concatUint8Array([tt(e),$e(t)])}function nt(e){return[R.packet.literalData,R.packet.compressedData,R.packet.symmetricallyEncryptedData,R.packet.symEncryptedIntegrityProtectedData,R.packet.aeadEncryptedData].includes(e)}async function it(e,t,r){let n,i;try{const s=await e.peekBytes(2);if(!s||s.length<2||!(128&s[0]))throw Error("Error during parsing. This message / key probably does not conform to a valid OpenPGP format.");const a=await e.readByte();let o,c,u=-1,h=-1;h=0,64&a&&(h=1),h?u=63&a:(u=(63&a)>>2,c=3&a);const l=nt(u);let f,y=null;if(t&&l){if("array"===t){const e=new ArrayStream;n=x(e),y=e}else{const e=new TransformStream;n=x(e.writable),y=e.readable}i=r({tag:u,packet:y})}else y=[];do{if(h){const t=await e.readByte();if(f=!1,t<192)o=t;else if(t>=192&&t<224)o=(t-192<<8)+await e.readByte()+192;else if(t>223&&t<255){if(o=1<<(31&t),f=!0,!l)throw new TypeError("This packet type does not support partial lengths.")}else o=await e.readByte()<<24|await e.readByte()<<16|await e.readByte()<<8|await e.readByte()}else switch(c){case 0:o=await e.readByte();break;case 1:o=await e.readByte()<<8|await e.readByte();break;case 2:o=await e.readByte()<<24|await e.readByte()<<16|await e.readByte()<<8|await e.readByte();break;default:o=1/0}if(o>0){let t=0;for(;;){n&&await n.ready;const{done:r,value:i}=await e.read();if(r){if(o===1/0)break;throw Error("Unexpected end of packet")}const s=o===1/0?i:i.subarray(0,o-t);if(n?await n.write(s):y.push(s),t+=i.length,t>=o){e.unshift(i.subarray(o-t+i.length));break}}}}while(f);n?(await n.ready,await n.close()):(y=L.concatUint8Array(y),await r({tag:u,packet:y}))}catch(e){if(n)return await n.abort(e),!0;throw e}finally{n&&await i}}class st extends Error{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,st),this.name="UnsupportedError"}}class at extends st{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,st),this.name="UnknownPacketError"}}class ot extends st{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,st),this.name="MalformedPacketError"}}class ct{constructor(e,t){this.tag=e,this.rawContent=t}write(){return this.rawContent}}async function ut(e){switch(e){case R.publicKey.ed25519:try{const e=L.getWebCrypto(),t=await e.generateKey("Ed25519",!0,["sign","verify"]).catch((e=>{if("OperationError"===e.name){const e=Error("Unexpected key generation issue");throw e.name="NotSupportedError",e}throw e})),r=await e.exportKey("jwk",t.privateKey),n=await e.exportKey("jwk",t.publicKey);return{A:new Uint8Array(z(n.x)),seed:z(r.d)}}catch(t){if("NotSupportedError"!==t.name)throw t;const{default:r}=await Promise.resolve().then((function(){return ey})),n=ye(yt(e)),{publicKey:i}=r.sign.keyPair.fromSeed(n);return{A:i,seed:n}}case R.publicKey.ed448:{const e=await L.getNobleCurve(R.publicKey.ed448),{secretKey:t,publicKey:r}=e.keygen();return{A:r,seed:t}}default:throw Error("Unsupported EdDSA algorithm")}}async function ht(e,t,r,n,i,s){switch(e){case R.publicKey.ed25519:try{const t=L.getWebCrypto(),r=gt(e,n,i),a=await t.importKey("jwk",r,"Ed25519",!1,["sign"]);return{RS:new Uint8Array(await t.sign("Ed25519",a,s))}}catch(e){if("NotSupportedError"!==e.name)throw e;const{default:t}=await Promise.resolve().then((function(){return ey})),r=L.concatUint8Array([i,n]);return{RS:t.sign.detached(s,r)}}case R.publicKey.ed448:return{RS:(await L.getNobleCurve(R.publicKey.ed448)).sign(s,i)};default:throw Error("Unsupported EdDSA algorithm")}}async function lt(e,t,{RS:r},n,i,s){switch(e){case R.publicKey.ed25519:try{const t=L.getWebCrypto(),n=dt(e,i),a=await t.importKey("jwk",n,"Ed25519",!1,["verify"]);return await t.verify("Ed25519",a,r,s)}catch(e){if("NotSupportedError"!==e.name)throw e;const{default:t}=await Promise.resolve().then((function(){return ey}));return t.sign.detached.verify(s,r,i)}case R.publicKey.ed448:return(await L.getNobleCurve(R.publicKey.ed448)).verify(r,s,i);default:throw Error("Unsupported EdDSA algorithm")}}async function ft(e,t,r){switch(e){case R.publicKey.ed25519:try{const n=L.getWebCrypto(),i=gt(e,t,r),s=dt(e,t),a=await n.importKey("jwk",i,"Ed25519",!1,["sign"]),o=await n.importKey("jwk",s,"Ed25519",!1,["verify"]),c=ye(8),u=new Uint8Array(await n.sign("Ed25519",a,c));return await n.verify("Ed25519",o,u,c)}catch(e){if("NotSupportedError"!==e.name)return!1;const{default:n}=await Promise.resolve().then((function(){return ey})),{publicKey:i}=n.sign.keyPair.fromSeed(r);return L.equalsUint8Array(t,i)}case R.publicKey.ed448:{const e=(await L.getNobleCurve(R.publicKey.ed448)).getPublicKey(r);return L.equalsUint8Array(t,e)}default:return!1}}function yt(e){switch(e){case R.publicKey.ed25519:return 32;case R.publicKey.ed448:return 57;default:throw Error("Unsupported EdDSA algorithm")}}function pt(e){switch(e){case R.publicKey.ed25519:return R.hash.sha256;case R.publicKey.ed448:return R.hash.sha512;default:throw Error("Unknown EdDSA algo")}}const dt=(e,t)=>{if(e===R.publicKey.ed25519){return{kty:"OKP",crv:"Ed25519",x:G(t),ext:!0}}throw Error("Unsupported EdDSA algorithm")},gt=(e,t,r)=>{if(e===R.publicKey.ed25519){const n=dt(e,t);return n.d=G(r),n}throw Error("Unsupported EdDSA algorithm")};var At=/*#__PURE__*/Object.freeze({__proto__:null,generate:ut,getPayloadSize:yt,getPreferredHashAlgo:pt,sign:ht,validateParams:ft,verify:lt});
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function wt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function mt(e,...t){if(!wt(e))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function bt(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function kt(e,t){mt(e);const r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}function Et(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function vt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Kt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function St(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const It=/* @__PURE__ */(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Bt(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!wt(e))throw Error("Uint8Array expected, got "+typeof e);e=Tt(e)}return e}function Ct(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function Ut(e,t){if(Ct(e,t)&&e.byteOffset<t.byteOffset)throw Error("complex overlap of input and output is not supported")}function Pt(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return 0===r}const Dt=(e,t)=>{function r(r,...n){if(mt(r),!It)throw Error("Non little-endian hardware is not yet supported");if(void 0!==e.nonceLength){const t=n[0];if(!t)throw Error("nonce / iv required");e.varSizeNonce?mt(t):mt(t,e.nonceLength)}const i=e.tagLength;i&&void 0!==n[1]&&mt(n[1]);const s=t(r,...n),a=(e,t)=>{if(void 0!==t){if(2!==e)throw Error("cipher output not supported");mt(t)}};let o=!1;return{encrypt(e,t){if(o)throw Error("cannot encrypt() twice with same key + nonce");return o=!0,mt(e),a(s.encrypt.length,t),s.encrypt(e,t)},decrypt(e,t){if(mt(e),i&&e.length<i)throw Error("invalid ciphertext length: smaller than tagLength="+i);return a(s.decrypt.length,t),s.decrypt(e,t)}}}return Object.assign(r,e),r};function xt(e,t,r=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw Error("invalid output length, expected "+e+", got: "+t.length);if(r&&!Rt(t))throw Error("invalid output, must be aligned");return t}function Qt(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),s=BigInt(4294967295),a=Number(r>>i&s),o=Number(r&s);e.setUint32(t+0,a,n),e.setUint32(t+4,o,n)}function Rt(e){return e.byteOffset%4==0}function Tt(e){return Uint8Array.from(e)}const Mt=16,Lt=/* @__PURE__ */new Uint8Array(16),Ft=vt(Lt),Ot=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255;class Nt{constructor(e,t){this.blockLen=Mt,this.outputLen=Mt,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,mt(e=Bt(e),16);const r=St(e);let n=r.getUint32(0,!1),i=r.getUint32(4,!1),s=r.getUint32(8,!1),a=r.getUint32(12,!1);const o=[];for(let e=0;e<128;e++)o.push({s0:Ot(n),s1:Ot(i),s2:Ot(s),s3:Ot(a)}),({s0:n,s1:i,s2:s,s3:a}={s3:(h=s)<<31|(l=a)>>>1,s2:(u=i)<<31|h>>>1,s1:(c=n)<<31|u>>>1,s0:c>>>1^225<<24&-(1&l)});var c,u,h,l;const f=(y=t||1024)>65536?8:y>1024?4:2;var y;if(![1,2,4,8].includes(f))throw Error("ghash: invalid window size, expected 2, 4 or 8");this.W=f;const p=128/f,d=this.windowSize=2**f,g=[];for(let e=0;e<p;e++)for(let t=0;t<d;t++){let r=0,n=0,i=0,s=0;for(let a=0;a<f;a++){if(!(t>>>f-a-1&1))continue;const{s0:c,s1:u,s2:h,s3:l}=o[f*e+a];r^=c,n^=u,i^=h,s^=l}g.push({s0:r,s1:n,s2:i,s3:s})}this.t=g}_updateBlock(e,t,r,n){e^=this.s0,t^=this.s1,r^=this.s2,n^=this.s3;const{W:i,t:s,windowSize:a}=this;let o=0,c=0,u=0,h=0;const l=(1<<i)-1;let f=0;for(const y of[e,t,r,n])for(let e=0;e<4;e++){const t=y>>>8*e&255;for(let e=8/i-1;e>=0;e--){const r=t>>>i*e&l,{s0:n,s1:y,s2:p,s3:d}=s[f*a+r];o^=n,c^=y,u^=p,h^=d,f+=1}}this.s0=o,this.s1=c,this.s2=u,this.s3=h}update(e){bt(this),mt(e=Bt(e));const t=vt(e),r=Math.floor(e.length/Mt),n=e.length%Mt;for(let e=0;e<r;e++)this._updateBlock(t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]);return n&&(Lt.set(e.subarray(r*Mt)),this._updateBlock(Ft[0],Ft[1],Ft[2],Ft[3]),Kt(Ft)),this}destroy(){const{t:e}=this;for(const t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){bt(this),kt(e,this),this.finished=!0;const{s0:t,s1:r,s2:n,s3:i}=this,s=vt(e);return s[0]=t,s[1]=r,s[2]=n,s[3]=i,e}digest(){const e=new Uint8Array(Mt);return this.digestInto(e),this.destroy(),e}}class _t extends Nt{constructor(e,t){mt(e=Bt(e));const r=function(e){e.reverse();const t=1&e[15];let r=0;for(let t=0;t<e.length;t++){const n=e[t];e[t]=n>>>1|r,r=(1&n)<<7}return e[0]^=225&-t,e}(Tt(e));super(r,t),Kt(r)}update(e){e=Bt(e),bt(this);const t=vt(e),r=e.length%Mt,n=Math.floor(e.length/Mt);for(let e=0;e<n;e++)this._updateBlock(Ot(t[4*e+3]),Ot(t[4*e+2]),Ot(t[4*e+1]),Ot(t[4*e+0]));return r&&(Lt.set(e.subarray(n*Mt)),this._updateBlock(Ot(Ft[3]),Ot(Ft[2]),Ot(Ft[1]),Ot(Ft[0])),Kt(Ft)),this}digestInto(e){bt(this),kt(e,this),this.finished=!0;const{s0:t,s1:r,s2:n,s3:i}=this,s=vt(e);return s[0]=t,s[1]=r,s[2]=n,s[3]=i,e.reverse()}}function Ht(e){const t=(t,r)=>e(r,t.length).update(Bt(t)).digest(),r=e(new Uint8Array(16),0);return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=(t,r)=>e(t,r),t}const zt=Ht(((e,t)=>new Nt(e,t)));Ht(((e,t)=>new _t(e,t)));const Gt=16,qt=/* @__PURE__ */new Uint8Array(Gt);function jt(e){return e<<1^283&-(e>>7)}function Vt(e,t){let r=0;for(;t>0;t>>=1)r^=e&-(1&t),e=jt(e);return r}const Yt=/* @__PURE__ */(()=>{const e=new Uint8Array(256);for(let t=0,r=1;t<256;t++,r^=jt(r))e[t]=r;const t=new Uint8Array(256);t[0]=99;for(let r=0;r<255;r++){let n=e[255-r];n|=n<<8,t[e[r]]=255&(n^n>>4^n>>5^n>>6^n>>7^99)}return Kt(e),t})(),Zt=/* @__PURE__ */Yt.map(((e,t)=>Yt.indexOf(t))),Jt=e=>e<<8|e>>>24,Xt=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Wt(e,t){if(256!==e.length)throw Error("Wrong sbox length");const r=new Uint32Array(256).map(((r,n)=>t(e[n]))),n=r.map(Jt),i=n.map(Jt),s=i.map(Jt),a=new Uint32Array(65536),o=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let u=0;u<256;u++){const h=256*t+u;a[h]=r[t]^n[u],o[h]=i[t]^s[u],c[h]=e[t]<<8|e[u]}return{sbox:e,sbox2:c,T0:r,T1:n,T2:i,T3:s