openpgp
Version:
OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.
3 lines • 233 kB
JavaScript
/*! OpenPGP.js v6.3.1 - 2026-06-04 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
const e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},t=Symbol("doneWritingPromise"),r=Symbol("doneWritingResolve"),i=Symbol("doneWritingReject"),n=Symbol("readingIndex");class s extends Array{constructor(){super(),Object.setPrototypeOf(this,s.prototype),this[t]=new Promise(((e,t)=>{this[r]=e,this[i]=t})),this[t].catch((()=>{}))}}function a(e){return e&&e.getReader&&Array.isArray(e)}function o(e){if(!a(e)){const t=e.getWriter(),r=t.releaseLock;return t.releaseLock=()=>{t.closed.catch((function(){})),r.call(t)},t}this.stream=e}function c(t){if(a(t))return"array";if(e.ReadableStream&&e.ReadableStream.prototype.isPrototypeOf(t))return"web";if(t&&!(e.ReadableStream&&t instanceof e.ReadableStream)&&"function"==typeof t._read&&"object"==typeof t._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!(!t||!t.getReader)&&"web-like"}function u(e){return Uint8Array.prototype.isPrototypeOf(e)}function h(e){if(1===e.length)return e[0];let t=0;for(let r=0;r<e.length;r++){if(!u(e[r]))throw Error("concatUint8Array: Data must be in the form of a Uint8Array");t+=e[r].length}const r=new Uint8Array(t);let i=0;return e.forEach((function(e){r.set(e,i),i+=e.length})),r}s.prototype.getReader=function(){return void 0===this[n]&&(this[n]=0),{read:async()=>(await this[t],this[n]===this.length?{value:void 0,done:!0}:{value:this[this[n]++],done:!1})}},s.prototype.readToEnd=async function(e){await this[t];const r=e(this.slice(this[n]));return this.length=0,r},s.prototype.clone=function(){const e=new s;return e[t]=this[t].then((()=>{e.push(...this)})),e},o.prototype.write=async function(e){this.stream.push(e)},o.prototype.close=async function(){this.stream[r]()},o.prototype.abort=async function(e){return this.stream[i](e),e},o.prototype.releaseLock=function(){},"object"==typeof e.process&&e.process.versions;const y=new WeakSet,l=Symbol("externalBuffer");function p(e){if(this.stream=e,e[l]&&(this[l]=e[l].slice()),a(e)){const t=e.getReader();return this._read=t.read.bind(t),this._releaseLock=()=>{},void(this._cancel=()=>{})}if(c(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||y.has(e)?{value:void 0,done:!0}:(t=!0,{value:e,done:!1}),this._releaseLock=()=>{if(t)try{y.add(e)}catch{}}}function g(e){return c(e)?e:new ReadableStream({start(t){t.enqueue(e),t.close()}})}function d(e){const t=c(e);if(t){if("array"!==t)throw Error("Can't convert Stream to ArrayStream here, call `readToEnd` first");return e}const r=new s;return(async()=>{const t=T(r);await t.write(e),await t.close()})(),r}function f(e){return e.some((e=>c(e)&&!a(e)))?function(e){const t=e.map(g),r=m((async function(e){await Promise.all(n.map((t=>x(t,e))))}));let i=Promise.resolve();const n=t.map(((e,n)=>A(e,((e,s)=>(i=i.then((()=>w(e,r.writable,{preventClose:n!==t.length-1}))),i)))));return r.readable}(e):e.some((e=>a(e)))?function(e){const t=new s;let r=Promise.resolve();return e.forEach(((i,n)=>(r=r.then((()=>w(i,t,{preventClose:n!==e.length-1}))),r))),t}(e):"string"==typeof e[0]?e.join(""):h(e)}async function w(e,t,{preventClose:r=!1,preventAbort:i=!1,preventCancel:n=!1}={}){if(c(e)&&!a(e)&&!a(t)){e=g(e);try{if(e[l]){const r=T(t);for(let t=0;t<e[l].length;t++)await r.ready,await r.write(e[l][t]);r.releaseLock()}await e.pipeTo(t,{preventClose:r,preventAbort:i,preventCancel:n})}catch{}return}c(e)||(e=d(e));const s=C(e),o=T(t);try{for(;;){await o.ready;const{done:e,value:t}=await s.read();if(e){r||await o.close();break}await o.write(t)}}catch(e){i||await o.abort(e)}finally{s.releaseLock(),o.releaseLock()}}function m(e){let t,r,i,n=!1,s=!1;return{readable:new ReadableStream({start(e){i=e},pull(){t?t():n=!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");i.enqueue(e),n?n=!1:(await new Promise(((e,i)=>{t=e,r=i})),t=null,r=null)},close:i.close.bind(i),abort:i.error.bind(i)})}}function b(e,t=()=>{},r=()=>{},i={highWaterMark:0}){if(c(e))return v(e,t,r,i);const n=t(e),s=r();return void 0!==n&&void 0!==s?f([n,s]):void 0!==n?n:s}async function k(e,t=async()=>{},r=async()=>{},i={highWaterMark:1}){if(c(e))return v(e,t,r,i);const n=await t(e),s=await r();return void 0!==n&&void 0!==s?f([n,s]):void 0!==n?n:s}function v(e,t,r,i){if(a(e)){const i=new s;return(async()=>{const n=T(i);try{const i=await D(e),s=await t(i),a=await r();let o;o=void 0!==s&&void 0!==a?f([s,a]):void 0!==s?s:a,await n.write(o),await n.close()}catch(e){await n.abort(e)}})(),i}if(c(e)){let n,s=!1;return new ReadableStream({start(){n=e.getReader()},async pull(i){if(s)return i.close(),void e.releaseLock();try{for(;;){const{value:a,done:o}=await n.read();s=o;const c=await(o?r:t)(a);if(void 0!==c)return void i.enqueue(c);if(o)return i.close(),void e.releaseLock()}}catch(e){i.error(e)}},async cancel(e){await n.cancel(e)}},i)}throw Error("Unreachable")}function A(e,t){if(c(e)&&!a(e)){let r;const i=new TransformStream({start(e){r=e}}),n=w(e,i.writable),s=m((async function(e){r.error(e),await n,await new Promise((e=>setTimeout(e)))}));return t(i.readable,s.writable),s.readable}e=d(e);const r=new s;return t(e,r),r}function K(e,t){let r;const i=A(e,((e,n)=>{const s=C(e);s.remainder=()=>(s.releaseLock(),w(e,n),i),r=t(s)}));return r}function E(e){if(a(e))return e.clone();if(c(e)){const t=function(e){if(a(e))throw Error("ArrayStream cannot be tee()d, use clone() instead");if(c(e)){const t=g(e).tee();return t[0][l]=t[1][l]=e[l],t}return[U(e),U(e)]}(e);return P(e,t[0]),t[1]}return U(e)}function S(e){return a(e)?E(e):c(e)?new ReadableStream({start(t){const r=A(e,(async(e,r)=>{const i=C(e),n=T(r);try{for(;;){await n.ready;const{done:e,value:r}=await i.read();if(e){try{t.close()}catch{}return void await n.close()}try{t.enqueue(r)}catch{}await n.write(r)}}catch(e){t.error(e),await n.abort(e)}}));P(e,r)}}):U(e)}function P(e,t){Object.entries(Object.getOwnPropertyDescriptors(e.constructor.prototype)).forEach((([r,i])=>{"constructor"!==r&&(i.value?i.value=i.value.bind(t):i.get=i.get.bind(t),Object.defineProperty(e,r,i))}))}function U(e,t=0,r=1/0){if(a(e))throw Error("Not implemented");if(c(e)){if(t>=0&&r>=0){let i,n=0;return new ReadableStream({start(){i=e.getReader()},async pull(s){try{for(;;){if(!(n<r))return s.close(),void e.releaseLock();{const{value:a,done:o}=await i.read();if(o)return s.close(),void e.releaseLock();let c;if(n+a.length>=t&&(c=U(a,Math.max(t-n,0),r-n)),n+=a.length,c)return void s.enqueue(c)}}}catch(e){s.error(e)}},async cancel(e){await i.cancel(e)}},{highWaterMark:0})}if(t<0&&(r<0||r===1/0)){let i=[];return b(e,(e=>{e.length>=-t?i=[e]:i.push(e)}),(()=>U(f(i),t,r)))}if(0===t&&r<0){let i;return b(e,(e=>{const n=i?f([i,e]):e;if(n.length>=-r)return i=U(n,r),U(n,t,r);i=n}))}return console.warn(`stream.slice(input, ${t}, ${r}) not implemented efficiently.`),I((async()=>U(await D(e),t,r)))}return e[l]&&(e=f(e[l].concat([e]))),u(e)?e.subarray(t,r===1/0?e.length:r):e.slice(t,r)}async function D(e,t=f){return a(e)?e.readToEnd(t):c(e)?C(e).readToEnd(t):e}async function x(e,t){if(c(e)){if(e.cancel){const r=await e.cancel(t);return await new Promise((e=>setTimeout(e))),r}if(e.destroy)return e.destroy(t),await new Promise((e=>setTimeout(e))),t}}function I(e){const t=new s;return(async()=>{const r=T(t);try{await r.write(await e()),await r.close()}catch(e){await r.abort(e)}})(),t}function C(e){return new p(e)}function T(e){return new o(e)}p.prototype.read=async function(){if(this[l]&&this[l].length){return{done:!1,value:this[l].shift()}}return this._read()},p.prototype.releaseLock=function(){this[l]&&(this.stream[l]=this[l]),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:i}=await this.read();if(i+="",r)return t.length?f(t):void 0;const n=i.indexOf("\n")+1;n&&(e=f(t.concat(i.substr(0,n))),t=[]),n!==i.length&&t.push(i.substr(n))}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(U(t,1)),r},p.prototype.readBytes=async function(e){const t=[];let r=0;for(;;){const{done:i,value:n}=await this.read();if(i)return t.length?f(t):void 0;if(t.push(n),r+=n.length,r>=e){const r=f(t);return this.unshift(U(r,e)),U(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[l]||(this[l]=[]),1===e.length&&u(e[0])&&this[l].length&&e[0].length&&this[l][0].byteOffset>=e[0].length?this[l][0]=new Uint8Array(this[l][0].buffer,this[l][0].byteOffset-e[0].length,this[l][0].byteLength+e[0].length):this[l].unshift(...e.filter((e=>e&&e.length)))},p.prototype.readToEnd=async function(e=f){const t=[];for(;;){const{done:e,value:r}=await this.read();if(e)break;t.push(r)}return e(t)};const B=Symbol("byValue");var M={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"},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},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,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[B]||(e[B]=[],Object.entries(e).forEach((([t,r])=>{e[B][r]=t}))),void 0!==e[B][t])return e[B][t];throw Error("Invalid enum value.")}};const L={preferredHashAlgorithm:M.hash.sha512,preferredSymmetricAlgorithm:M.symmetric.aes256,preferredCompressionAlgorithm:M.compression.uncompressed,aeadProtect:!1,parseAEADEncryptedV4KeysAsLegacy:!1,preferredAEADAlgorithm:M.aead.gcm,aeadChunkSizeByte:12,v6Keys:!1,enableParsingV5Entities:!1,s2kType:M.s2k.iterated,s2kIterationCountByte:224,s2kArgon2Params:{passes:3,parallelism:4,memoryExponent:16},maxArgon2MemoryExponent:30,allowUnauthenticatedMessages:!1,allowUnauthenticatedStream:!1,minRSABits:2047,passwordCollisionCheck:!1,allowInsecureDecryptionWithSigningKeys:!1,allowInsecureVerificationWithReformattedKeys:!1,allowMissingKeyFlags:!1,constantTimePKCS1Decryption:!1,constantTimePKCS1DecryptionSupportedSymmetricAlgorithms:new Set([M.symmetric.aes128,M.symmetric.aes192,M.symmetric.aes256]),ignoreUnsupportedPackets:!0,ignoreMalformedPackets:!1,enforceGrammar:!0,additionalAllowedPackets:[],showVersion:!1,showComment:!1,versionString:"OpenPGP.js 6.3.1",commentString:"https://openpgpjs.org",maxUserIDLength:5120,maxDecompressedMessageSize:1/0,knownNotations:[],nonDeterministicSignaturesViaNotation:!0,useEllipticFallback:!0,rejectHashAlgorithms:new Set([M.hash.md5,M.hash.ripemd]),rejectMessageHashAlgorithms:new Set([M.hash.md5,M.hash.ripemd,M.hash.sha1]),rejectPublicKeyAlgorithms:new Set([M.publicKey.elgamal,M.publicKey.dsa]),rejectCurves:new Set([M.curve.secp256k1])},F=(()=>{try{return"development"===process.env.NODE_ENV}catch{}return!1})(),N={isString:function(e){return"string"==typeof e||e instanceof String},nodeRequire:()=>{},isArray:function(e){return e instanceof Array},isUint8Array:u,isStream:c,getNobleCurve:async(e,t)=>{if(!L.useEllipticFallback)throw Error("This curve is only supported in the full build of OpenPGP.js");const{nobleCurves:r}=await import("./noble_curves.min.mjs");switch(e){case M.publicKey.ecdh:case M.publicKey.ecdsa:{const e=r.get(t);if(!e)throw Error("Unsupported curve");return e}case M.publicKey.x448:return r.get("x448");case M.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 i=0;i<t;i++)r[i]=e>>8*(t-i-1)&255;return r},readDate:function(e){const t=N.readNumber(e);return new Date(1e3*t)},writeDate:function(e){const t=Math.floor(e.getTime()/1e3);return N.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 N.readExactSubarray(e,2,2+t)},readExactSubarray:function(e,t,r){if(e.length<r)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),i=t-e.length;return r.set(e,i),r},uint8ArrayToMPI:function(e){const t=N.uint8ArrayBitLength(e);if(0===t)throw Error("Zero MPI");const r=e.subarray(e.length-Math.ceil(t/8)),i=new Uint8Array([(65280&t)>>8,255&t]);return N.concatUint8Array([i,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)+N.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 b(e,(e=>{if(!N.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,i=(e=new Uint8Array(e)).length;for(let n=0;n<i;n+=r)t.push(String.fromCharCode.apply(String,e.subarray(n,n+r<i?n+r:i)));return t.join("")},encodeUTF8:function(e){const t=new TextEncoder("utf-8");function r(e,r=!1){return t.encode(e,{stream:!r})}return b(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 b(e,r,(()=>r(new Uint8Array,!0)))},concat:f,concatUint8Array:h,equalsUint8Array:function(e,t){if(!N.isUint8Array(e)||!N.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 N.writeNumber(t,2)},printDebug:function(e){F&&console.log("[OpenPGP.js debug]",e)},printDebugError:function(e){F&&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 i=0;i<r;i++)t[i]=e[i]<<1^e[i+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 t=void 0!==e&&e.crypto&&e.crypto.subtle||this.getNodeCrypto()?.webcrypto.subtle;if(!t)throw Error("The WebCrypto API is not available");return t},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(!N.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 b(e,(e=>{let r;t&&(e=N.concatUint8Array([new Uint8Array([13]),e])),13===e[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;const i=[];for(let t=0;r=e.indexOf(10,t)+1,r;t=r)13!==e[r-2]&&i.push(r);if(!i.length)return e;const n=new Uint8Array(e.length+i.length);let s=0;for(let t=0;t<i.length;t++){const r=e.subarray(i[t-1]||0,i[t]);n.set(r,s),s+=r.length,n[s-1]=13,n[s]=10,s++}return n.set(e.subarray(i[i.length-1]||0),s),n}),(()=>t?new Uint8Array([13]):void 0))},nativeEOL:function(e){let t=!1;return b(e,(e=>{let r;13===(e=t&&10!==e[0]?N.concatUint8Array([new Uint8Array([13]),e]):new Uint8Array(e))[e.length-1]?(t=!0,e=e.subarray(0,-1)):t=!1;let i=0;for(let t=0;t!==e.length;t=r){r=e.indexOf(13,t)+1,r||(r=e.length);const n=r-(10===e[r]?1:0);t&&e.copyWithin(i,t,n),i+=n-t}return e.subarray(0,i)}),(()=>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{}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(((t,r)=>{let i;Promise.all(e.map((async e=>{try{t(await e)}catch(e){i=e}}))).then((()=>{r(i)}))}))},selectUint8Array:function(e,t,r){const i=Math.max(t.length,r.length),n=new Uint8Array(i);let s=0;for(let i=0;i<n.length;i++)n[i]=t[i]&256-e|r[i]&255+e,s+=e&i<t.length|1-e&i<r.length;return n.subarray(0,s)},selectUint8:function(e,t,r){return t&256-e|r&255+e},isAES:function(e){return e===M.symmetric.aes128||e===M.symmetric.aes192||e===M.symmetric.aes256}},z=N.getNodeBuffer();let R,O;function j(e){let t=new Uint8Array;return b(e,(e=>{t=N.concatUint8Array([t,e]);const r=[],i=Math.floor(t.length/45),n=45*i,s=R(t.subarray(0,n));for(let e=0;e<i;e++)r.push(s.substr(60*e,60)),r.push("\n");return t=t.subarray(n),r.join("")}),(()=>t.length?R(t)+"\n":""))}function H(e){let t="";return b(e,(e=>{t+=e;let r=0;const i=[" ","\t","\r","\n"];for(let e=0;e<i.length;e++){const n=i[e];for(let e=t.indexOf(n);-1!==e;e=t.indexOf(n,e+1))r++}let n=t.length;for(;n>0&&(n-r)%4!=0;n--)i.includes(t[n])&&r--;const s=O(t.substr(0,n));return t=t.substr(n),s}),(()=>O(t)))}function G(e){return H(e.replace(/-/g,"+").replace(/_/g,"/"))}function _(e,t){let r=j(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])?M.armor.multipartSection:/MESSAGE, PART \d+/.test(t[1])?M.armor.multipartLast:/SIGNED MESSAGE/.test(t[1])?M.armor.signed:/MESSAGE/.test(t[1])?M.armor.message:/PUBLIC KEY BLOCK/.test(t[1])?M.armor.publicKey:/PRIVATE KEY BLOCK/.test(t[1])?M.armor.privateKey:/SIGNATURE/.test(t[1])?M.armor.signature:void 0}function W(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 b(e,(e=>{const r=X?Math.floor(e.length/4):0,i=new Uint32Array(e.buffer,e.byteOffset,r);for(let e=0;e<r;e++)t^=i[e],t=$[0][t>>24&255]^$[1][t>>16&255]^$[2][t>>8&255]^$[3][255&t];for(let i=4*r;i<e.length;i++)t=t>>8^$[0][255&t^e[i]]}),(()=>new Uint8Array([t,t>>8,t>>16])))}(e);return j(t)}z?(R=e=>z.from(e).toString("base64"),O=e=>{const t=z.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}):(R=e=>btoa(N.uint8ArrayToString(e)),O=e=>N.stringToUint8Array(atob(e)));const $=[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);$[0][e]=(16711680&t)>>16|65280&t|(255&t)<<16}for(let e=0;e<=255;e++)$[1][e]=$[0][e]>>8^$[0][255&$[0][e]];for(let e=0;e<=255;e++)$[2][e]=$[1][e]>>8^$[0][255&$[1][e]];for(let e=0;e<=255;e++)$[3][e]=$[2][e]>>8^$[0][255&$[2][e]];const X=function(){const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,255,!0),255===new Int16Array(e)[0]}();function Q(e){for(let t=0;t<e.length;t++)/^([^\s:]|[^\s:][^:]*[^\s:]): .+$/.test(e[t])||N.printDebugError(Error("Improperly formatted armor header: "+e[t])),/^(Version|Comment|MessageID|Hash|Charset): .+$/.test(e[t])||N.printDebugError(Error("Unknown header: "+e[t]))}function Y(e){let t=e;const r=e.lastIndexOf("=");return r>=0&&r!==e.length-1&&(t=e.slice(0,r)),t}function Z(e){return new Promise(((t,r)=>{try{const i=/^-----[^-]+-----$/m,n=/^[ \f\r\t\u00a0\u2000-\u200a\u202f\u205f\u3000]*$/;let s;const a=[];let o,c,u=a,h=[];const y=H(A(e,(async(e,l)=>{const p=C(e);try{for(;;){let e=await p.readLine();if(void 0===e)throw Error("Misformed armored text");if(e=N.removeTrailingSpaces(e.replace(/[\r\n]/g,"")),s)if(o)c||s!==M.armor.signed||(i.test(e)?(h=h.join("\r\n"),c=!0,Q(u),u=[],o=!1):h.push(e.replace(/^- /,"")));else if(i.test(e)&&r(Error("Mandatory blank line missing between armor headers and armor data")),n.test(e)){if(Q(u),o=!0,c||s!==M.armor.signed){t({text:h,data:y,headers:a,type:s});break}}else u.push(e);else i.test(e)&&(s=q(e))}}catch(e){return void r(e)}const g=T(l);try{for(;;){await g.ready;const{done:e,value:t}=await p.read();if(e)throw Error("Misformed armored text");const r=t+"";if(-1!==r.indexOf("=")||-1!==r.indexOf("-")){let e=await p.readToEnd();e.length||(e=""),e=r+e,e=N.removeTrailingSpaces(e.replace(/\r/g,""));const t=e.split(i);if(1===t.length)throw Error("Misformed armored text");const n=Y(t[0].slice(0,-1));await g.write(n);break}await g.write(r)}await g.ready,await g.close()}catch(e){await g.abort(e)}})))}catch(e){r(e)}})).then((async e=>(a(e.data)&&(e.data=await D(e.data)),e)))}function J(e,t,r,i,n,s=!1,a=L){let o,c;e===M.armor.signed&&(o=t.text,c=t.hash,t=t.data);const u=s&&S(t),h=[];switch(e){case M.armor.multipartSection:h.push("-----BEGIN PGP MESSAGE, PART "+r+"/"+i+"-----\n"),h.push(W(n,a)),h.push(j(t)),u&&h.push("=",V(u)),h.push("-----END PGP MESSAGE, PART "+r+"/"+i+"-----\n");break;case M.armor.multipartLast:h.push("-----BEGIN PGP MESSAGE, PART "+r+"-----\n"),h.push(W(n,a)),h.push(j(t)),u&&h.push("=",V(u)),h.push("-----END PGP MESSAGE, PART "+r+"-----\n");break;case M.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(W(n,a)),h.push(j(t)),u&&h.push("=",V(u)),h.push("-----END PGP SIGNATURE-----\n");break;case M.armor.message:h.push("-----BEGIN PGP MESSAGE-----\n"),h.push(W(n,a)),h.push(j(t)),u&&h.push("=",V(u)),h.push("-----END PGP MESSAGE-----\n");break;case M.armor.publicKey:h.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),h.push(W(n,a)),h.push(j(t)),u&&h.push("=",V(u)),h.push("-----END PGP PUBLIC KEY BLOCK-----\n");break;case M.armor.privateKey:h.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\n"),h.push(W(n,a)),h.push(j(t)),u&&h.push("=",V(u)),h.push("-----END PGP PRIVATE KEY BLOCK-----\n");break;case M.armor.signature:h.push("-----BEGIN PGP SIGNATURE-----\n"),h.push(W(n,a)),h.push(j(t)),u&&h.push("=",V(u)),h.push("-----END PGP SIGNATURE-----\n")}return N.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 ie(e,t){const r=e%t;return r<ee?r+t:r}function ne(e,t,r){const i=-e;return t&i|r&~i}function se(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 i=t,n=e;n%=r;let s=BigInt(1);for(;i>ee;){const e=i&te;i>>=te;s=ne(e,s*n%r,s),n=n*n%r}return s}function ae(e){return e>=ee?e:-e}function oe(e,t){const{gcd:r,x:i}=function(e,t){let r=BigInt(0),i=BigInt(1),n=BigInt(1),s=BigInt(0),a=ae(e),o=ae(t);const c=e<ee,u=t<ee;for(;o!==ee;){const e=a/o;let t=r;r=n-e*r,n=t,t=i,i=s-e*i,s=t,t=o,o=a%o,a=t}return{x:c?-n:n,y:u?-s:s,gcd:a}}(e,t);if(r!==te)throw Error("Inverse does not exist");return ie(i+t,t)}function ce(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 ue(e,t){return(e>>BigInt(t)&te)===ee?0:1}function he(e){const t=e<ee?BigInt(-1):ee;let r=1,i=e;for(;(i>>=te)!==t;)r++;return r}function ye(e){const t=e<ee?BigInt(-1):ee,r=BigInt(8);let i=1,n=e;for(;(n>>=r)!==t;)i++;return i}function le(e,t="be",r){let i=e.toString(16);i.length%2==1&&(i="0"+i);const n=i.length/2,s=new Uint8Array(r||n),a=r?r-n:0;let o=0;for(;o<n;)s[o+a]=parseInt(i.slice(2*o,2*o+2),16),o++;return"be"!==t&&s.reverse(),s}const pe=N.getNodeCrypto();function ge(e){const t="undefined"!=typeof crypto?crypto:pe?.webcrypto;if(t?.getRandomValues){const r=new Uint8Array(e);return t.getRandomValues(r)}throw Error("No secure random number generator available.")}function de(e,t){if(t<e)throw Error("Illegal parameter value: max <= min");const r=t-e;return ie(re(ge(ye(r)+8)),r)+e}const fe=BigInt(1);function we(e,t,r){const i=BigInt(30),n=fe<<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=de(n,n<<fe),o=ce(ie(a,i));do{a+=BigInt(s[o]),o=(o+s[o])%s.length,he(a)>e&&(a=ie(a,n<<fe),a+=n,o=ce(ie(a,i)))}while(!me(a,t,r));return a}function me(e,t,r){return(!t||function(e,t){let r=e,i=t;for(;i!==ee;){const e=i;i=r%i,r=e}return r}(e-fe,t)===fe)&&(!!function(e){const t=BigInt(0);return be.every((r=>ie(e,r)!==t))}(e)&&(!!function(e,t=BigInt(2)){return se(t,e-fe,e)===fe}(e)&&!!function(e,t){const r=he(e);t||(t=Math.max(1,r/48|0));const i=e-fe;let n=0;for(;!ue(i,n);)n++;const s=e>>BigInt(n);for(;t>0;t--){let t,r=se(de(BigInt(2),i),s,e);if(r!==fe&&r!==i){for(t=1;t<n;t++){if(r=ie(r*r,e),r===fe)return!1;if(r===i)break}if(t===n)return!1}}return!0}(e,r)))}const be=[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 ke=N.getWebCrypto(),ve=N.getNodeCrypto(),Ae=ve&&ve.getHashes();function Ke(e){if(ve&&Ae.includes(e))return async function(t){const r=ve.createHash(e);return b(t,(e=>{r.update(e)}),(()=>new Uint8Array(r.digest())))}}function Ee(e,t){const r=async()=>{const{nobleHashes:t}=await import("./noble_hashes.min.mjs"),r=t.get(e);if(!r)throw Error("Unsupported hash");return r};return async function(e){if(a(e)&&(e=await D(e)),N.isStream(e)){const t=(await r()).create();return b(e,(e=>{t.update(e)}),(()=>t.digest()))}if(ke&&t)return new Uint8Array(await ke.digest(t,e));return(await r())(e)}}const Se=Ke("md5")||Ee("md5"),Pe=Ke("sha1")||Ee("sha1","SHA-1"),Ue=Ke("sha224")||Ee("sha224"),De=Ke("sha256")||Ee("sha256","SHA-256"),xe=Ke("sha384")||Ee("sha384","SHA-384"),Ie=Ke("sha512")||Ee("sha512","SHA-512"),Ce=Ke("ripemd160")||Ee("ripemd160"),Te=Ke("sha3-256")||Ee("sha3_256"),Be=Ke("sha3-512")||Ee("sha3_512");function Me(e,t){switch(e){case M.hash.md5:return Se(t);case M.hash.sha1:return Pe(t);case M.hash.ripemd:return Ce(t);case M.hash.sha256:return De(t);case M.hash.sha384:return xe(t);case M.hash.sha512:return Ie(t);case M.hash.sha224:return Ue(t);case M.hash.sha3_256:return Te(t);case M.hash.sha3_512:return Be(t);default:throw Error("Unsupported hash function")}}function Le(e){switch(e){case M.hash.md5:return 16;case M.hash.sha1:case M.hash.ripemd:return 20;case M.hash.sha256:return 32;case M.hash.sha384:return 48;case M.hash.sha512:return 64;case M.hash.sha224:return 28;case M.hash.sha3_256:return 32;case M.hash.sha3_512:return 64;default:throw Error("Invalid hash algorithm.")}}const Fe=[];function Ne(e,t){const r=e.length;if(r>t-11)throw Error("Message too long");const i=function(e){const t=new Uint8Array(e);let r=0;for(;r<e;){const i=ge(e-r);for(let e=0;e<i.length;e++)0!==i[e]&&(t[r++]=i[e])}return t}(t-r-3),n=new Uint8Array(t);return n[1]=2,n.set(i,2),n.set(e,t-r),n}function ze(e,t){let r=2,i=1;for(let t=r;t<e.length;t++)i&=0!==e[t],r+=i;const n=r-2,s=e.subarray(r+1),a=0===e[0]&2===e[1]&n>=8&!i;if(t)return N.selectUint8Array(a,s,t);if(a)return s;throw Error("Decryption error")}function Re(e,t,r){let i;if(t.length!==Le(e))throw Error("Invalid hash length");const n=new Uint8Array(Fe[e].length);for(i=0;i<Fe[e].length;i++)n[i]=Fe[e][i];const s=n.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(n,r-s),o.set(t,r-t.length),o}Fe[1]=[48,32,48,12,6,8,42,134,72,134,247,13,2,5,5,0,4,16],Fe[2]=[48,33,48,9,6,5,43,14,3,2,26,5,0,4,20],Fe[3]=[48,33,48,9,6,5,43,36,3,2,1,5,0,4,20],Fe[8]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32],Fe[9]=[48,65,48,13,6,9,96,134,72,1,101,3,4,2,2,5,0,4,48],Fe[10]=[48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64],Fe[11]=[48,45,48,13,6,9,96,134,72,1,101,3,4,2,4,5,0,4,28],Fe[12]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,8,5,0,4,32],Fe[14]=[48,81,48,13,6,9,96,134,72,1,101,3,4,2,10,5,0,4,64];const Oe=N.getWebCrypto(),je=N.getNodeCrypto(),He=BigInt(1);async function Ge(e,t,r,i,n,s,a,o,c){if(Le(e)>=r.length)throw Error("Digest size cannot exceed key modulus size");if(t&&!N.isStream(t))if(N.getWebCrypto())try{return await async function(e,t,r,i,n,s,a,o){const c=Ve(r,i,n,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))}(M.read(M.webHash,e),t,r,i,n,s,a,o)}catch(e){N.printDebugError(e)}else if(N.getNodeCrypto())return function(e,t,r,i,n,s,a,o){const c=je.createSign(M.read(M.hash,e));c.write(t),c.end();const u=Ve(r,i,n,s,a,o);return new Uint8Array(c.sign({key:u,format:"jwk",type:"pkcs1"}))}(e,t,r,i,n,s,a,o);return function(e,t,r,i){t=re(t);const n=re(Re(e,i,ye(t)));return r=re(r),le(se(n,r,t),"be",ye(t))}(e,r,n,c)}async function _e(e,t,r,i,n,s){if(t&&!N.isStream(t))if(N.getWebCrypto())try{return await async function(e,t,r,i,n){const s=$e(i,n),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)}(M.read(M.webHash,e),t,r,i,n)}catch(e){N.printDebugError(e)}else if(N.getNodeCrypto())return function(e,t,r,i,n){const s=$e(i,n),a={key:s,format:"jwk",type:"pkcs1"},o=je.createVerify(M.read(M.hash,e));o.write(t),o.end();try{return o.verify(a,r)}catch{return!1}}(e,t,r,i,n);return function(e,t,r,i,n){if(r=re(r),t=re(t),i=re(i),t>=r)throw Error("Signature size cannot exceed modulus size");const s=le(se(t,i,r),"be",ye(r)),a=Re(e,n,ye(r));return N.equalsUint8Array(s,a)}(e,r,i,n,s)}async function qe(e,t,r){return N.getNodeCrypto()?function(e,t,r){const i=$e(t,r),n={key:i,format:"jwk",type:"pkcs1",padding:je.constants.RSA_PKCS1_PADDING};return new Uint8Array(je.publicEncrypt(n,e))}(e,t,r):function(e,t,r){if(t=re(t),e=re(Ne(e,ye(t))),r=re(r),e>=t)throw Error("Message size cannot exceed modulus size");return le(se(e,r,t),"be",ye(t))}(e,t,r)}async function We(e,t,r,i,n,s,a,o){if(N.getNodeCrypto()&&!o)try{return function(e,t,r,i,n,s,a){const o=Ve(t,r,i,n,s,a),c={key:o,format:"jwk",type:"pkcs1",padding:je.constants.RSA_PKCS1_PADDING};try{return new Uint8Array(je.privateDecrypt(c,e))}catch{throw Error("Decryption error")}}(e,t,r,i,n,s,a)}catch(e){N.printDebugError(e)}return function(e,t,r,i,n,s,a,o){if(e=re(e),t=re(t),r=re(r),i=re(i),n=re(n),s=re(s),a=re(a),e>=t)throw Error("Data too large.");const c=ie(i,s-He),u=ie(i,n-He),h=de(BigInt(2),t),y=se(oe(h,t),r,t);e=ie(e*y,t);const l=se(e,u,n),p=se(e,c,s),g=ie(a*(p-l),s);let d=g*n+l;return d=ie(d*h,t),ze(le(d,"be",ye(t)),o)}(e,t,r,i,n,s,a,o)}function Ve(e,t,r,i,n,s){const a=re(i),o=re(n),c=re(r);let u=ie(c,o-He),h=ie(c,a-He);return h=le(h),u=le(u),{kty:"RSA",n:_(e),e:_(t),d:_(r),p:_(n),q:_(i),dp:_(u),dq:_(h),qi:_(s),ext:!0}}function $e(e,t){return{kty:"RSA",n:_(e),e:_(t),ext:!0}}function Xe(e,t){return{n:G(e.n),e:le(t),d:G(e.d),p:G(e.q),q:G(e.p),u:G(e.qi)}}const Qe=BigInt(1);const Ye={"2a8648ce3d030107":M.curve.nistP256,"2b81040022":M.curve.nistP384,"2b81040023":M.curve.nistP521,"2b8104000a":M.curve.secp256k1,"2b06010401da470f01":M.curve.ed25519Legacy,"2b060104019755010501":M.curve.curve25519Legacy,"2b2403030208010107":M.curve.brainpoolP256r1,"2b240303020801010b":M.curve.brainpoolP384r1,"2b240303020801010d":M.curve.brainpoolP512r1};class Ze{constructor(e){if(e instanceof Ze)this.oid=e.oid;else if(N.isArray(e)||N.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 N.concatUint8Array([new Uint8Array([this.oid.length]),this.oid])}toHex(){return N.uint8ArrayToHex(this.oid)}getName(){const e=Ye[this.toHex()];if(!e)throw Error("Unknown curve object identifier.");return e}}function Je(e){let t,r=0;const i=e[0];return i<192?([r]=e,t=1):i<255?(r=(e[0]-192<<8)+e[1]+192,t=2):255===i&&(r=N.readNumber(e.subarray(1,5)),t=5),{len:r,offset:t}}function et(e){return e<192?new Uint8Array([e]):e>191&&e<8384?new Uint8Array([192+(e-192>>8),e-192&255]):N.concatUint8Array([new Uint8Array([255]),N.writeNumber(e,4)])}function tt(e){if(e<0||e>30)throw Error("Partial Length power must be between 1 and 30");return new Uint8Array([224+e])}function rt(e){return new Uint8Array([192|e])}function it(e,t){return N.concatUint8Array([rt(e),et(t)])}function nt(e){return[M.packet.literalData,M.packet.compressedData,M.packet.symmetricallyEncryptedData,M.packet.symEncryptedIntegrityProtectedData,M.packet.aeadEncryptedData].includes(e)}async function st(e,t,r){let i,n;try{const a=await e.peekBytes(2);if(!a||a.length<2||!(128&a[0]))throw Error("Error during parsing. This message / key probably does not conform to a valid OpenPGP format.");const o=await e.readByte();let c,u,h=-1,y=-1;y=0,64&o&&(y=1),y?h=63&o:(h=(63&o)>>2,u=3&o);const l=nt(h);let p,g=null;if(t&&l){if("array"===t){const e=new s;i=T(e),g=e}else{const e=new TransformStream;i=T(e.writable),g=e.readable}n=r({tag:h,packet:g})}else g=[];do{if(y){const t=await e.readByte();if(p=!1,t<192)c=t;else if(t>=192&&t<224)c=(t-192<<8)+await e.readByte()+192;else if(t>223&&t<255){if(c=1<<(31&t),p=!0,!l)throw new TypeError("This packet type does not support partial lengths.")}else c=await e.readByte()<<24|await e.readByte()<<16|await e.readByte()<<8|await e.readByte()}else switch(u){case 0:c=await e.readByte();break;case 1:c=await e.readByte()<<8|await e.readByte();break;case 2:c=await e.readByte()<<24|await e.readByte()<<16|await e.readByte()<<8|await e.readByte();break;default:c=1/0}if(c>0){let t=0;for(;;){i&&await i.ready;const{done:r,value:n}=await e.read();if(r){if(c===1/0)break;throw Error("Unexpected end of packet")}const s=c===1/0?n:n.subarray(0,c-t);if(i?await i.write(s):g.push(s),t+=n.length,t>=c){e.unshift(n.subarray(c-t+n.length));break}}}}while(p);i?(await i.ready,await i.close()):(g=N.concatUint8Array(g),await r({tag:h,packet:g}))}catch(e){if(i)return await i.abort(e),!0;throw e}finally{i&&await n}}class at extends Error{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,at),this.name="UnsupportedError"}}class ot extends at{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,at),this.name="UnknownPacketError"}}class ct extends at{constructor(...e){super(...e),Error.captureStackTrace&&Error.captureStackTrace(this,at),this.name="MalformedPacketError"}}class ut{constructor(e,t){this.tag=e,this.rawContent=t}write(){return this.rawContent}}async function ht(e){switch(e){case M.publicKey.ed25519:try{const e=N.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),i=await e.exportKey("jwk",t.publicKey);return{A:new Uint8Array(G(i.x)),seed:G(r.d)}}catch(t){if("NotSupportedError"!==t.name)throw t;const{default:r}=await import("./nacl-fast.min.mjs"),i=ge(gt(e)),{publicKey:n}=r.sign.keyPair.fromSeed(i);return{A:n,seed:i}}case M.publicKey.ed448:{const e=await N.getNobleCurve(M.publicKey.ed448),{secretKey:t,publicKey:r}=e.keygen();return{A:r,seed:t}}default:throw Error("Unsupported EdDSA algorithm")}}async function yt(e,t,r,i,n,s){if(Le(t)<Le(dt(e)))throw Error("Hash algorithm too weak for EdDSA.");switch(e){case M.publicKey.ed25519:try{const t=N.getWebCrypto(),r=wt(e,i,n),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 import("./nacl-fast.min.mjs"),r=N.concatUint8Array([n,i]);return{RS:t.sign.detached(s,r)}}case M.publicKey.ed448:return{RS:(await N.getNobleCurve(M.publicKey.ed448)).sign(s,n)};default:throw Error("Unsupported EdDSA algorithm")}}async function lt(e,t,{RS:r},i,n,s){if(Le(t)<Le(dt(e)))throw Error("Hash algorithm too weak for EdDSA.");switch(e){case M.publicKey.ed25519:try{const t=N.getWebCrypto(),i=ft(e,n),a=await t.importKey("jwk",i,"Ed25519",!1,["verify"]);return await t.verify("Ed25519",a,r,s)}catch(e){if("NotSupportedError"!==e.name)throw e;const{default:t}=await import("./nacl-fast.min.mjs");return t.sign.detached.verify(s,r,n)}case M.publicKey.ed448:return(await N.getNobleCurve(M.publicKey.ed448)).verify(r,s,n);default:throw Error("Unsupported EdDSA algorithm")}}async function pt(e,t,r){switch(e){case M.publicKey.ed25519:try{const i=N.getWebCrypto(),n=wt(e,t,r),s=ft(e,t),a=await i.importKey("jwk",n,"Ed25519",!1,["sign"]),o=await i.importKey("jwk",s,"Ed25519",!1,["verify"]),c=ge(8),u=new Uint8Array(await i.sign("Ed25519",a,c));return await i.verify("Ed25519",o,u,c)}catch(e){if("NotSupportedError"!==e.name)return!1;const{default:i}=await import("./nacl-fast.min.mjs"),{publicKey:n}=i.sign.keyPair.fromSeed(r);return N.equalsUint8Array(t,n)}case M.publicKey.ed448:{const e=(await N.getNobleCurve(M.publicKey.ed448)).getPublicKey(r);return N.equalsUint8Array(t,e)}default:return!1}}function gt(e){switch(e){case M.publicKey.ed25519:return 32;case M.publicKey.ed448:return 57;default:throw Error("Unsupported EdDSA algorithm")}}function dt(e){switch(e){case M.publicKey.ed25519:return M.hash.sha256;case M.publicKey.ed448:return M.hash.sha512;default:throw Error("Unknown EdDSA algo")}}const ft=(e,t)=>{if(e===M.publicKey.ed25519){return{kty:"OKP",crv:"Ed25519",x:_(t),ext:!0}}throw Error("Unsupported EdDSA algorithm")},wt=(e,t,r)=>{if(e===M.publicKey.ed25519){const i=ft(e,t);return i.d=_(r),i}throw Error("Unsupported EdDSA algorithm")};var mt=/*#__PURE__*/Object.freeze({__proto__:null,generate:ht,getPayloadSize:gt,getPreferredHashAlgo:dt,sign:yt,validateParams:pt,verify:lt});
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function bt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function kt(e,...t){if(!bt(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 vt(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 At(e,t){kt(e);const r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}function Kt(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Et(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function St(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Pt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const Ut=/* @__PURE__ */(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Dt(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(!bt(e))throw Error("Uint8Array expected, got "+typeof e);e=Ft(e)}return e}function xt(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function It(e,t){if(xt(e,t)&&e.byteOffset<t.byteOffset)throw Error("complex overlap of input and output is not supported")}function Ct(e,t){if(e.length!==t.length)return!1;let r=0;for(let i=0;i<e.length;i++)r|=e[i]^t[i];return 0===r}const Tt=(e,t)=>{function r(r,...i){if(kt(r),!Ut)throw Error("Non little-endian hardware is not yet supported");if(void 0!==e.nonceLength){const t=i[0];if(!t)throw Error("nonce / iv required");e.varSizeNonce?kt(t):kt(t,e.nonceLength)}const n=e.tagLength;n&&void 0!==i[1]&&kt(i[1]);const s=t(r,...i),a=(e,t)=>{if(void 0!==t){if(2!==e)throw Error("cipher output not supported");kt(t)}};let o=!1;return{encrypt(e,t){if(o)throw Error("cannot encrypt() twice with same key + nonce");return o=!0,kt(e),a(s.encrypt.length,t),s.encrypt(e,t)},decrypt(e,t){if(kt(e),n&&e.length<n)throw Error("invalid ciphertext length: smaller than tagLength="+n);return a(s.decrypt.length,t),s.decrypt(e,t)}}}return Object.assign(r,e),r};function Bt(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&&!Lt(t))throw Error("invalid output, must be aligned");return t}function Mt(e,t,r,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,i);const n=BigInt(32),s=BigInt(4294967295),a=Number(r>>n&s),o=Number(r&s);e.setUint32(t+0,a,i),e.setUint32(t+4,o,i)}function Lt(e){return e.byteOffset%4==0}function Ft(e){return Uint8Array.from(e)}const Nt=16,zt=/* @__PURE__ */new Uint8Array(16),Rt=Et(zt),Ot=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255;class jt{constructor(e,t){this.blockLen=Nt,this.outputLen=Nt,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,kt(e=Dt(e),16);const r=Pt(e);let i=r.getUint32(0,!1),n=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(i),s1:Ot(n),s2:Ot(s),s3:Ot(a)}),({s0:i,s1:n,s2:s,s3:a}={s3:(h=s)<<31|(y=a)>>>1,s2:(u=n)<<31|h>>>1,s1:(c=i)<<31|u>>>1,s0:c>>>1^225<<24&-(1&y)});var c,u,h,y;const l=(p=t||1024)>65536?8:p>1024?4:2;var p;if(![1,2,4,8].includes(l))throw Error("ghash: invalid window size, expected 2, 4 or 8");this.W=l;const g=128/l,d=this.windowSize=2**l,f=[];for(let e=0;e<g;e++)for(let t=0;t<d;t++){let r=0,i=0,n=0,s=0;for(let a=0;a<l;a++){if(!(t>>>l-a-1&1))continue;const{s0:c,s1:u,s2:h,s3:y}=o[l*e+a];r^=c,i^=u,n^=h,s^=y}f.push({s0:r,s1:i,s2:n,s3:s})}this.t=f}_updateBlock(e,t,r,i){e^=this.s0,t^=this.s1,r^=this.s2,i^=this.s3;const{W:n,t:s,windowSize:a}=this;let o=0,c=0,u=0,h=0;const y=(1<<n)-1;let l=0;for(const p of[e,t,r,i])for(let e=0;e<4;e++){const t=p>>>8*e&255;for(let e=8/n-1;e>=0;e--){const r=t>>>n*e&y,{s0:i,s1:p,s2:g,s3:d}=s[l*a+r];o^=i,c^=p,u^=g,h^=d,l+=1}}this.s0=o,this.s1=c,this.s2=u,this.s3=h}update(e){vt(this),kt(e=Dt(e));const t=Et(e),r=Math.floor(e.length/Nt),i=e.length%Nt;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 i&&(zt.set(e.subarray(r*Nt)),this._updateBlock(Rt[0],Rt[1],Rt[2],Rt[3]),St(Rt)),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){vt(this),At(e,this),this.finished=!0;const{s0:t,s1:r,s2:i,s3:n}=this,s=Et(e);return s[0]=t,s[1]=r,s[2]=i,s[3]=n,e}digest(){const e=new Uint8Array(Nt);return this.digestInto(e),this.destroy(),e}}class Ht extends jt{constructor(e,t){kt(e=Dt(e));const r=function(e){e.reverse();const t=1&e[15];let r=0;for(let t=0;t<e.length;t++){const i=e[t];e[t]=i>>>1|r,r=(1&i)<<7}return e[0]^=225&-t,e}(Ft(e));super(r,t),St(r)}update(e){e=Dt(e),vt(this);const t=Et(e),r=e.length%Nt,i=Math.floor(e.length/Nt);for(let e=0;e<i;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&&(zt.set(e.subarray(i*Nt)),this._updateBlock(Ot(Rt[3]),Ot(Rt[2]),Ot(Rt[1]),Ot(Rt[0])),St(Rt)),this}digestInto(e){vt(this),At(e,this),this.finished=!0;const{s0:t,s1:r,s2:i,s3:n}=this,s=Et(e);return s[0]=t,s[1]=r,s[2]=i,s[3]=n,e.reverse()}}function Gt(e){const t=(t,r)=>e(r,t.length).update(Dt(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 _t=Gt(((e,t)=>new jt(e,t)));Gt(((e,t)=>new Ht(e,t)));const qt=16,Wt=/* @__PURE__ */new Uint8Array(qt);function Vt(e){return e<<1^283&-(e>>7)}function $t(e,t){let r=0;for(;t>0;t>>=1)r^=e&-(1&t),e=Vt(e);return r}const Xt=/* @__PURE__ */(()=>{const e=new Uint8Array(256);for(let t=0,r=1;t<256;t++,r^=Vt(r))e[t]=r;const t=new Uint8Array(256);t[0]=99;for(let r=0;r<255;r++){let i=e[255-r];i|=i<<8,t[e[r]]=255&(i^i>>4^i>>5^i>>6^i>>7^99)}return St(e),t})(),Qt=/* @__PURE__ */Xt.map(((e,t)=>Xt.indexOf(t))),Yt=e=>e<<8|e>>>24,Zt=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Jt(e,t){if(256!==e.length)throw Error("Wrong sbox length");const r=new Uint32Array(256).map(((r,i)=>t