UNPKG

openpgp

Version:

OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.

3 lines 396 kB
/*! OpenPGP.js v6.2.1 - 2025-08-26 - 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 o extends Array{constructor(){super(),Object.setPrototypeOf(this,o.prototype),this[n]=new Promise(((e,t)=>{this[i]=e,this[s]=t})),this[n].catch((()=>{}))}}function c(e){return e&&e.getReader&&Array.isArray(e)}function u(e){if(!c(e)){const t=e.getWriter(),r=t.releaseLock;return t.releaseLock=()=>{t.closed.catch((function(){})),r.call(t)},t}this.stream=e}function h(e){if(c(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 f(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(!f(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}o.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})}},o.prototype.readToEnd=async function(e){await this[n];const t=e(this.slice(this[a]));return this.length=0,t},o.prototype.clone=function(){const e=new o;return e[n]=this[n].then((()=>{e.push(...this)})),e},u.prototype.write=async function(e){this.stream.push(e)},u.prototype.close=async function(){this.stream[i]()},u.prototype.abort=async function(e){return this.stream[s](e),e},u.prototype.releaseLock=function(){},"object"==typeof t.process&&t.process.versions;const y=new WeakSet,g=Symbol("externalBuffer");function p(e){if(this.stream=e,e[g]&&(this[g]=e[g].slice()),c(e)){const t=e.getReader();return this._read=t.read.bind(t),this._releaseLock=()=>{},void(this._cancel=()=>{})}if(h(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(e){}}}function d(e){return h(e)?e:new ReadableStream({start(t){t.enqueue(e),t.close()}})}function A(e){if(h(e))return e;const t=new o;return(async()=>{const r=Q(t);await r.write(e),await r.close()})(),t}function w(e){return e.some((e=>h(e)&&!c(e)))?function(e){e=e.map(d);const t=k((async function(e){await Promise.all(n.map((t=>U(t,e))))}));let r=Promise.resolve();const n=e.map(((n,i)=>v(n,((n,s)=>(r=r.then((()=>m(n,t.writable,{preventClose:i!==e.length-1}))),r)))));return t.readable}(e):e.some((e=>c(e)))?function(e){const t=new o;let r=Promise.resolve();return e.forEach(((n,i)=>(r=r.then((()=>m(n,t,{preventClose:i!==e.length-1}))),r))),t}(e):"string"==typeof e[0]?e.join(""):l(e)}async function m(e,t,{preventClose:r=!1,preventAbort:n=!1,preventCancel:i=!1}={}){if(h(e)&&!c(e)){e=d(e);try{if(e[g]){const r=Q(t);for(let t=0;t<e[g].length;t++)await r.ready,await r.write(e[g][t]);r.releaseLock()}await e.pipeTo(t,{preventClose:r,preventAbort:n,preventCancel:i})}catch(e){}return}const s=x(e=A(e)),a=Q(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 b(e,t){const r=new TransformStream(t);return m(e,r.writable),r.readable}function k(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 E(e,t=()=>{},r=()=>{}){if(c(e)){const n=new o;return(async()=>{const i=Q(n);try{const n=await D(e),s=t(n),a=r();let o;o=void 0!==s&&void 0!==a?w([s,a]):void 0!==s?s:a,await i.write(o),await i.close()}catch(e){await i.abort(e)}})(),n}if(h(e))return b(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?w([n,i]):void 0!==n?n:i}function v(e,t){if(h(e)&&!c(e)){let r;const n=new TransformStream({start(e){r=e}}),i=m(e,n.writable),s=k((async function(e){r.error(e),await i,await new Promise(setTimeout)}));return t(n.readable,s.writable),s.readable}e=A(e);const r=new o;return t(e,r),r}function B(e,t){let r;const n=v(e,((e,i)=>{const s=x(e);s.remainder=()=>(s.releaseLock(),m(e,i),n),r=t(s)}));return r}function I(e){if(c(e))return e.clone();if(h(e)){const t=function(e){if(c(e))throw Error("ArrayStream cannot be tee()d, use clone() instead");if(h(e)){const t=d(e).tee();return t[0][g]=t[1][g]=e[g],t}return[C(e),C(e)]}(e);return K(e,t[0]),t[1]}return C(e)}function S(e){return c(e)?I(e):h(e)?new ReadableStream({start(t){const r=v(e,(async(e,r)=>{const n=x(e),i=Q(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)}}));K(e,r)}}):C(e)}function K(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 C(e,t=0,r=1/0){if(c(e))throw Error("Not implemented");if(h(e)){if(t>=0&&r>=0){let n=0;return b(e,{transform(e,i){n<r?(n+e.length>=t&&i.enqueue(C(e,Math.max(t-n,0),r-n)),n+=e.length):i.terminate()}})}if(t<0&&(r<0||r===1/0)){let n=[];return E(e,(e=>{e.length>=-t?n=[e]:n.push(e)}),(()=>C(w(n),t,r)))}if(0===t&&r<0){let n;return E(e,(e=>{const i=n?w([n,e]):e;if(i.length>=-r)return n=C(i,r),C(i,t,r);n=i}))}return console.warn(`stream.slice(input, ${t}, ${r}) not implemented efficiently.`),P((async()=>C(await D(e),t,r)))}return e[g]&&(e=w(e[g].concat([e]))),f(e)?e.subarray(t,r===1/0?e.length:r):e.slice(t,r)}async function D(e,t=w){return c(e)?e.readToEnd(t):h(e)?x(e).readToEnd(t):e}async function U(e,t){if(h(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 o;return(async()=>{const r=Q(t);try{await r.write(await e()),await r.close()}catch(e){await r.abort(e)}})(),t}function x(e){return new p(e)}function Q(e){return new u(e)}p.prototype.read=async function(){if(this[g]&&this[g].length){return{done:!1,value:this[g].shift()}}return this._read()},p.prototype.releaseLock=function(){this[g]&&(this.stream[g]=this[g]),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?w(t):void 0;const i=n.indexOf("\n")+1;i&&(e=w(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(C(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?w(t):void 0;if(t.push(i),r+=i.length,r>=e){const r=w(t);return this.unshift(C(r,e)),C(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[g]||(this[g]=[]),1===e.length&&f(e[0])&&this[g].length&&e[0].length&&this[g][0].byteOffset>=e[0].length?this[g][0]=new Uint8Array(this[g][0].buffer,this[g][0].byteOffset-e[0].length,this[g][0].byteLength+e[0].length):this[g].unshift(...e.filter((e=>e&&e.length)))},p.prototype.readToEnd=async function(e=w){const t=[];for(;;){const{done:e,value:r}=await this.read();if(e)break;t.push(r)}return e(t)};const R=Symbol("byValue");var T={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[R]||(e[R]=[],Object.entries(e).forEach((([t,r])=>{e[R][r]=t}))),void 0!==e[R][t])return e[R][t];throw Error("Invalid enum value.")}},M={preferredHashAlgorithm:T.hash.sha512,preferredSymmetricAlgorithm:T.symmetric.aes256,preferredCompressionAlgorithm:T.compression.uncompressed,aeadProtect:!1,parseAEADEncryptedV4KeysAsLegacy:!1,preferredAEADAlgorithm:T.aead.gcm,aeadChunkSizeByte:12,v6Keys:!1,enableParsingV5Entities:!1,s2kType:T.s2k.iterated,s2kIterationCountByte:224,s2kArgon2Params:{passes:3,parallelism:4,memoryExponent:16},allowUnauthenticatedMessages:!1,allowUnauthenticatedStream:!1,minRSABits:2047,passwordCollisionCheck:!1,allowInsecureDecryptionWithSigningKeys:!1,allowInsecureVerificationWithReformattedKeys:!1,allowMissingKeyFlags:!1,constantTimePKCS1Decryption:!1,constantTimePKCS1DecryptionSupportedSymmetricAlgorithms:new Set([T.symmetric.aes128,T.symmetric.aes192,T.symmetric.aes256]),ignoreUnsupportedPackets:!0,ignoreMalformedPackets:!1,enforceGrammar:!0,additionalAllowedPackets:[],showVersion:!1,showComment:!1,versionString:"OpenPGP.js 6.2.1",commentString:"https://openpgpjs.org",maxUserIDLength:5120,knownNotations:[],nonDeterministicSignaturesViaNotation:!0,useEllipticFallback:!0,rejectHashAlgorithms:new Set([T.hash.md5,T.hash.ripemd]),rejectMessageHashAlgorithms:new Set([T.hash.md5,T.hash.ripemd,T.hash.sha1]),rejectPublicKeyAlgorithms:new Set([T.publicKey.elgamal,T.publicKey.dsa]),rejectCurves:new Set([T.curve.secp256k1])};const F=(()=>{try{return"development"===process.env.NODE_ENV}catch(e){}return!1})(),N={isString:function(e){return"string"==typeof e||e instanceof String},nodeRequire:()=>{},isArray:function(e){return e instanceof Array},isUint8Array:f,isStream:h,getNobleCurve:async(e,t)=>{if(!M.useEllipticFallback)throw Error("This curve is only supported in the full build of OpenPGP.js");const{nobleCurves:r}=await Promise.resolve().then((function(){return yf}));switch(e){case T.publicKey.ecdh:case T.publicKey.ecdsa:{const e=r.get(t);if(!e)throw Error("Unsupported curve");return e}case T.publicKey.x448:return r.get("x448");case T.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=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-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=N.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 N.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)+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 E(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,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 E(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 E(e,r,(()=>r(new Uint8Array,!0)))},concat:w,concatUint8Array:l,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 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(!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 E(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 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 E(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 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===T.symmetric.aes128||e===T.symmetric.aes192||e===T.symmetric.aes256}},L=N.getNodeBuffer();let O,H;function z(e){let t=new Uint8Array;return E(e,(e=>{t=N.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 G(e){let t="";return E(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=H(t.substr(0,i));return t=t.substr(i),s}),(()=>H(t)))}function _(e){return G(e.replace(/-/g,"+").replace(/_/g,"/"))}function j(e,t){let r=z(e).replace(/[\r\n]/g,"");return r=r.replace(/[+]/g,"-").replace(/[/]/g,"_").replace(/[=]/g,""),r}function V(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])?T.armor.multipartSection:/MESSAGE, PART \d+/.test(t[1])?T.armor.multipartLast:/SIGNED MESSAGE/.test(t[1])?T.armor.signed:/MESSAGE/.test(t[1])?T.armor.message:/PUBLIC KEY BLOCK/.test(t[1])?T.armor.publicKey:/PRIVATE KEY BLOCK/.test(t[1])?T.armor.privateKey:/SIGNATURE/.test(t[1])?T.armor.signature:void 0}function q(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 Y(e){const t=function(e){let t=13501623;return E(e,(e=>{const r=J?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=Z[0][t>>24&255]^Z[1][t>>16&255]^Z[2][t>>8&255]^Z[3][255&t];for(let n=4*r;n<e.length;n++)t=t>>8^Z[0][255&t^e[n]]}),(()=>new Uint8Array([t,t>>8,t>>16])))}(e);return z(t)}L?(O=e=>L.from(e).toString("base64"),H=e=>{const t=L.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}):(O=e=>btoa(N.uint8ArrayToString(e)),H=e=>N.stringToUint8Array(atob(e)));const Z=[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);Z[0][e]=(16711680&t)>>16|65280&t|(255&t)<<16}for(let e=0;e<=255;e++)Z[1][e]=Z[0][e]>>8^Z[0][255&Z[0][e]];for(let e=0;e<=255;e++)Z[2][e]=Z[1][e]>>8^Z[0][255&Z[1][e]];for(let e=0;e<=255;e++)Z[3][e]=Z[2][e]>>8^Z[0][255&Z[2][e]];const J=function(){const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,255,!0),255===new Int16Array(e)[0]}();function W(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 X(e){let t=e;const r=e.lastIndexOf("=");return r>=0&&r!==e.length-1&&(t=e.slice(0,r)),t}function $(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 f=G(v(e,(async(e,l)=>{const y=x(e);try{for(;;){let e=await y.readLine();if(void 0===e)throw Error("Misformed armored text");if(e=N.removeTrailingSpaces(e.replace(/[\r\n]/g,"")),s)if(o)c||s!==T.armor.signed||(n.test(e)?(h=h.join("\r\n"),c=!0,W(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(W(u),o=!0,c||s!==T.armor.signed){t({text:h,data:f,headers:a,type:s});break}}else u.push(e);else n.test(e)&&(s=V(e))}}catch(e){return void r(e)}const g=Q(l);try{for(;;){await g.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=N.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 g.write(i);break}await g.write(r)}await g.ready,await g.close()}catch(e){await g.abort(e)}})))}catch(e){r(e)}})).then((async e=>(c(e.data)&&(e.data=await D(e.data)),e)))}function ee(e,t,r,n,i,s=!1,a=M){let o,c;e===T.armor.signed&&(o=t.text,c=t.hash,t=t.data);const u=s&&S(t),h=[];switch(e){case T.armor.multipartSection:h.push("-----BEGIN PGP MESSAGE, PART "+r+"/"+n+"-----\n"),h.push(q(i,a)),h.push(z(t)),u&&h.push("=",Y(u)),h.push("-----END PGP MESSAGE, PART "+r+"/"+n+"-----\n");break;case T.armor.multipartLast:h.push("-----BEGIN PGP MESSAGE, PART "+r+"-----\n"),h.push(q(i,a)),h.push(z(t)),u&&h.push("=",Y(u)),h.push("-----END PGP MESSAGE, PART "+r+"-----\n");break;case T.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(q(i,a)),h.push(z(t)),u&&h.push("=",Y(u)),h.push("-----END PGP SIGNATURE-----\n");break;case T.armor.message:h.push("-----BEGIN PGP MESSAGE-----\n"),h.push(q(i,a)),h.push(z(t)),u&&h.push("=",Y(u)),h.push("-----END PGP MESSAGE-----\n");break;case T.armor.publicKey:h.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),h.push(q(i,a)),h.push(z(t)),u&&h.push("=",Y(u)),h.push("-----END PGP PUBLIC KEY BLOCK-----\n");break;case T.armor.privateKey:h.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\n"),h.push(q(i,a)),h.push(z(t)),u&&h.push("=",Y(u)),h.push("-----END PGP PRIVATE KEY BLOCK-----\n");break;case T.armor.signature:h.push("-----BEGIN PGP SIGNATURE-----\n"),h.push(q(i,a)),h.push(z(t)),u&&h.push("=",Y(u)),h.push("-----END PGP SIGNATURE-----\n")}return N.concat(h)}const te=BigInt(0),re=BigInt(1);function ne(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<te?r+t:r}function se(e,t,r){if(r===te)throw Error("Modulo cannot be zero");if(r===re)return BigInt(0);if(t<te)throw Error("Unsopported negative exponent");let n=t,i=e;i%=r;let s=BigInt(1);for(;n>te;){const e=n&re;n>>=re;s=e?s*i%r:s,i=i*i%r}return s}function ae(e){return e>=te?e:-e}function oe(e,t){const{gcd:r,x:n}=function(e,t){let r=BigInt(0),n=BigInt(1),i=BigInt(1),s=BigInt(0),a=ae(e),o=ae(t);const c=e<te,u=t<te;for(;o!==te;){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!==re)throw Error("Inverse does not exist");return ie(n+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)&re)===te?0:1}function he(e){const t=e<te?BigInt(-1):te;let r=1,n=e;for(;(n>>=re)!==t;)r++;return r}function fe(e){const t=e<te?BigInt(-1):te,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 ye=N.getNodeCrypto();function ge(e){const t="undefined"!=typeof crypto?crypto:ye?.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 ie(ne(ge(fe(r)+8)),r)+e}const de=BigInt(1);function Ae(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=ce(ie(a,n));do{a+=BigInt(s[o]),o=(o+s[o])%s.length,he(a)>e&&(a=ie(a,i<<de),a+=i,o=ce(ie(a,n)))}while(!we(a,t,r));return a}function we(e,t,r){return(!t||function(e,t){let r=e,n=t;for(;n!==te;){const e=n;n=r%n,r=e}return r}(e-de,t)===de)&&(!!function(e){const t=BigInt(0);return me.every((r=>ie(e,r)!==t))}(e)&&(!!function(e,t=BigInt(2)){return se(t,e-de,e)===de}(e)&&!!function(e,t){const r=he(e);t||(t=Math.max(1,r/48|0));const n=e-de;let i=0;for(;!ue(n,i);)i++;const s=e>>BigInt(i);for(;t>0;t--){let t,r=se(pe(BigInt(2),n),s,e);if(r!==de&&r!==n){for(t=1;t<i;t++){if(r=ie(r*r,e),r===de)return!1;if(r===n)break}if(t===i)return!1}}return!0}(e,r)))}const me=[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 be=N.getWebCrypto(),ke=N.getNodeCrypto(),Ee=ke&&ke.getHashes();function ve(e){if(ke&&Ee.includes(e))return async function(t){const r=ke.createHash(e);return E(t,(e=>{r.update(e)}),(()=>new Uint8Array(r.digest())))}}function Be(e,t){const r=async()=>{const{nobleHashes:t}=await Promise.resolve().then((function(){return Of})),r=t.get(e);if(!r)throw Error("Unsupported hash");return r};return async function(e){if(c(e)&&(e=await D(e)),N.isStream(e)){const t=(await r()).create();return E(e,(e=>{t.update(e)}),(()=>t.digest()))}if(be&&t)return new Uint8Array(await be.digest(t,e));return(await r())(e)}}const Ie=ve("md5")||Be("md5"),Se=ve("sha1")||Be("sha1","SHA-1"),Ke=ve("sha224")||Be("sha224"),Ce=ve("sha256")||Be("sha256","SHA-256"),De=ve("sha384")||Be("sha384","SHA-384"),Ue=ve("sha512")||Be("sha512","SHA-512"),Pe=ve("ripemd160")||Be("ripemd160"),xe=ve("sha3-256")||Be("sha3_256"),Qe=ve("sha3-512")||Be("sha3_512");function Re(e,t){switch(e){case T.hash.md5:return Ie(t);case T.hash.sha1:return Se(t);case T.hash.ripemd:return Pe(t);case T.hash.sha256:return Ce(t);case T.hash.sha384:return De(t);case T.hash.sha512:return Ue(t);case T.hash.sha224:return Ke(t);case T.hash.sha3_256:return xe(t);case T.hash.sha3_512:return Qe(t);default:throw Error("Unsupported hash function")}}function Te(e){switch(e){case T.hash.md5:return 16;case T.hash.sha1:case T.hash.ripemd:return 20;case T.hash.sha256:return 32;case T.hash.sha384:return 48;case T.hash.sha512:return 64;case T.hash.sha224:return 28;case T.hash.sha3_256:return 32;case T.hash.sha3_512:return 64;default:throw Error("Invalid hash algorithm.")}}const Me=[];function Fe(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=ge(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 Ne(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 N.selectUint8Array(a,s,t);if(a)return s;throw Error("Decryption error")}function Le(e,t,r){let n;if(t.length!==Te(e))throw Error("Invalid hash length");const i=new Uint8Array(Me[e].length);for(n=0;n<Me[e].length;n++)i[n]=Me[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}Me[1]=[48,32,48,12,6,8,42,134,72,134,247,13,2,5,5,0,4,16],Me[2]=[48,33,48,9,6,5,43,14,3,2,26,5,0,4,20],Me[3]=[48,33,48,9,6,5,43,36,3,2,1,5,0,4,20],Me[8]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32],Me[9]=[48,65,48,13,6,9,96,134,72,1,101,3,4,2,2,5,0,4,48],Me[10]=[48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64],Me[11]=[48,45,48,13,6,9,96,134,72,1,101,3,4,2,4,5,0,4,28];const Oe=N.getWebCrypto(),He=N.getNodeCrypto(),ze=BigInt(1);async function Ge(e,t,r,n,i,s,a,o,c){if(Te(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,n,i,s,a,o){const c=await qe(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))}(T.read(T.webHash,e),t,r,n,i,s,a,o)}catch(e){N.printDebugError(e)}else if(N.getNodeCrypto())return async function(e,t,r,n,i,s,a,o){const c=He.createSign(T.read(T.hash,e));c.write(t),c.end();const u=await qe(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=ne(t);const i=ne(Le(e,n,fe(t)));return r=ne(r),le(se(i,r,t),"be",fe(t))}(e,r,i,c)}async function _e(e,t,r,n,i,s){if(t&&!N.isStream(t))if(N.getWebCrypto())try{return await async function(e,t,r,n,i){const s=Ye(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)}(T.read(T.webHash,e),t,r,n,i)}catch(e){N.printDebugError(e)}else if(N.getNodeCrypto())return async function(e,t,r,n,i){const s=Ye(n,i),a={key:s,format:"jwk",type:"pkcs1"},o=He.createVerify(T.read(T.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=ne(r),t=ne(t),n=ne(n),t>=r)throw Error("Signature size cannot exceed modulus size");const s=le(se(t,n,r),"be",fe(r)),a=Le(e,i,fe(r));return N.equalsUint8Array(s,a)}(e,r,n,i,s)}async function je(e,t,r){return N.getNodeCrypto()?async function(e,t,r){const n=Ye(t,r),i={key:n,format:"jwk",type:"pkcs1",padding:He.constants.RSA_PKCS1_PADDING};return new Uint8Array(He.publicEncrypt(i,e))}(e,t,r):async function(e,t,r){if(t=ne(t),e=ne(Fe(e,fe(t))),r=ne(r),e>=t)throw Error("Message size cannot exceed modulus size");return le(se(e,r,t),"be",fe(t))}(e,t,r)}async function Ve(e,t,r,n,i,s,a,o){if(N.getNodeCrypto()&&!o)try{return await async function(e,t,r,n,i,s,a){const o=await qe(t,r,n,i,s,a),c={key:o,format:"jwk",type:"pkcs1",padding:He.constants.RSA_PKCS1_PADDING};try{return new Uint8Array(He.privateDecrypt(c,e))}catch(e){throw Error("Decryption error")}}(e,t,r,n,i,s,a)}catch(e){N.printDebugError(e)}return async function(e,t,r,n,i,s,a,o){if(e=ne(e),t=ne(t),r=ne(r),n=ne(n),i=ne(i),s=ne(s),a=ne(a),e>=t)throw Error("Data too large.");const c=ie(n,s-ze),u=ie(n,i-ze),h=pe(BigInt(2),t),f=se(oe(h,t),r,t);e=ie(e*f,t);const l=se(e,u,i),y=se(e,c,s),g=ie(a*(y-l),s);let p=g*i+l;return p=ie(p*h,t),Ne(le(p,"be",fe(t)),o)}(e,t,r,n,i,s,a,o)}async function qe(e,t,r,n,i,s){const a=ne(n),o=ne(i),c=ne(r);let u=ie(c,o-ze),h=ie(c,a-ze);return h=le(h),u=le(u),{kty:"RSA",n:j(e),e:j(t),d:j(r),p:j(i),q:j(n),dp:j(u),dq:j(h),qi:j(s),ext:!0}}function Ye(e,t){return{kty:"RSA",n:j(e),e:j(t),ext:!0}}function Ze(e,t){return{n:_(e.n),e:le(t),d:_(e.d),p:_(e.q),q:_(e.p),u:_(e.qi)}}const Je=BigInt(1);const We={"2a8648ce3d030107":T.curve.nistP256,"2b81040022":T.curve.nistP384,"2b81040023":T.curve.nistP521,"2b8104000a":T.curve.secp256k1,"2b06010401da470f01":T.curve.ed25519Legacy,"2b060104019755010501":T.curve.curve25519Legacy,"2b2403030208010107":T.curve.brainpoolP256r1,"2b240303020801010b":T.curve.brainpoolP384r1,"2b240303020801010d":T.curve.brainpoolP512r1};class Xe{constructor(e){if(e instanceof Xe)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=We[this.toHex()];if(!e)throw Error("Unknown curve object identifier.");return e}}function $e(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=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 nt(e,t){return N.concatUint8Array([rt(e),et(t)])}function it(e){return[T.packet.literalData,T.packet.compressedData,T.packet.symmetricallyEncryptedData,T.packet.symEncryptedIntegrityProtectedData,T.packet.aeadEncryptedData].includes(e)}async function st(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 c,u,h=-1,f=-1;f=0,64&a&&(f=1),f?h=63&a:(h=(63&a)>>2,u=3&a);const l=it(h);let y,g=null;if(t&&l){if("array"===t){const e=new o;n=Q(e),g=e}else{const e=new TransformStream;n=Q(e.writable),g=e.readable}i=r({tag:h,packet:g})}else g=[];do{if(f){const t=await e.readByte();if(y=!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),y=!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(;;){n&&await n.ready;const{done:r,value:i}=await e.read();if(r){if(c===1/0)break;throw Error("Unexpected end of packet")}const s=c===1/0?i:i.subarray(0,c-t);if(n?await n.write(s):g.push(s),t+=i.length,t>=c){e.unshift(i.subarray(c-t+i.length));break}}}}while(y);n?(await n.ready,await n.close()):(g=N.concatUint8Array(g),await r({tag:h,packet:g}))}catch(e){if(n)return await n.abort(e),!0;throw e}finally{n&&await i}}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 T.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),n=await e.exportKey("jwk",t.publicKey);return{A:new Uint8Array(_(n.x)),seed:_(r.d)}}catch(t){if("NotSupportedError"!==t.name)throw t;const{default:r}=await Promise.resolve().then((function(){return Pl})),n=ge(gt(e)),{publicKey:i}=r.sign.keyPair.fromSeed(n);return{A:i,seed:n}}case T.publicKey.ed448:{const e=await N.getNobleCurve(T.publicKey.ed448),{secretKey:t,publicKey:r}=e.keygen();return{A:r,seed:t}}default:throw Error("Unsupported EdDSA algorithm")}}async function ft(e,t,r,n,i,s){if(Te(t)<Te(pt(e)))throw Error("Hash algorithm too weak for EdDSA.");switch(e){case T.publicKey.ed25519:try{const t=N.getWebCrypto(),r=At(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 Pl})),r=N.concatUint8Array([i,n]);return{RS:t.sign.detached(s,r)}}case T.publicKey.ed448:return{RS:(await N.getNobleCurve(T.publicKey.ed448)).sign(s,i)};default:throw Error("Unsupported EdDSA algorithm")}}async function lt(e,t,{RS:r},n,i,s){if(Te(t)<Te(pt(e)))throw Error("Hash algorithm too weak for EdDSA.");switch(e){case T.publicKey.ed25519:try{const t=N.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 Pl}));return t.sign.detached.verify(s,r,i)}case T.publicKey.ed448:return(await N.getNobleCurve(T.publicKey.ed448)).verify(r,s,i);default:throw Error("Unsupported EdDSA algorithm")}}async function yt(e,t,r){switch(e){case T.publicKey.ed25519:try{const n=N.getWebCrypto(),i=At(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=ge(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 Pl})),{publicKey:i}=n.sign.keyPair.fromSeed(r);return N.equalsUint8Array(t,i)}case T.publicKey.ed448:{const e=(await N.getNobleCurve(T.publicKey.ed448)).getPublicKey(r);return N.equalsUint8Array(t,e)}default:return!1}}function gt(e){switch(e){case T.publicKey.ed25519:return 32;case T.publicKey.ed448:return 57;default:throw Error("Unsupported EdDSA algorithm")}}function pt(e){switch(e){case T.publicKey.ed25519:return T.hash.sha256;case T.publicKey.ed448:return T.hash.sha512;default:throw Error("Unknown EdDSA algo")}}const dt=(e,t)=>{if(e===T.publicKey.ed25519){return{kty:"OKP",crv:"Ed25519",x:j(t),ext:!0}}throw Error("Unsupported EdDSA algorithm")},At=(e,t,r)=>{if(e===T.publicKey.ed25519){const n=dt(e,t);return n.d=j(r),n}throw Error("Unsupported EdDSA algorithm")};var wt=/*#__PURE__*/Object.freeze({__proto__:null,generate:ht,getPayloadSize:gt,getPreferredHashAlgo:pt,sign:ft,validateParams:yt,verify:lt}); /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function mt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function bt(e,...t){if(!mt(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 kt(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 Et(e,t){bt(e);const r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}function vt(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function Bt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function It(...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 Kt=/* @__PURE__ */(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function Ct(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(!mt(e))throw Error("Uint8Array expected, got "+typeof e);e=Mt(e)}return e}function Dt(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function Ut(e,t){if(Dt(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 xt=(e,t)=>{function r(r,...n){if(bt(r),!Kt)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?bt(t):bt(t,e.nonceLength)}const i=e.tagLength;i&&void 0!==n[1]&&bt(n[1]);const s=t(r,...n),a=(e,t)=>{if(void 0!==t){if(2!==e)throw Error("cipher output not supported");bt(t)}};let o=!1;return{encrypt(e,t){if(o)throw Error("cannot encrypt() twice with same key + nonce");return o=!0,bt(e),a(s.encrypt.length,t),s.encrypt(e,t)},decrypt(e,t){if(bt(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 Qt(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&&!Tt(t))throw Error("invalid output, must be aligned");return t}function Rt(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 Tt(e){return e.byteOffset%4==0}function Mt(e){return Uint8Array.from(e)}const Ft=16,Nt=/* @__PURE__ */new Uint8Array(16),Lt=Bt(Nt),Ot=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255;class Ht{constructor(e,t){this.blockLen=Ft,this.outputLen=Ft,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,bt(e=Ct(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|(f=a)>>>1,s2:(u=i)<<31|h>>>1,s1:(c=n)<<31|u>>>1,s0:c>>>1^225<<24&-(1&f)});var c,u,h,f;const l=(y=t||1024)>65536?8:y>1024?4:2;var y;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,p=this.windowSize=2**l,d=[];for(let e=0;e<g;e++)for(let t=0;t<p;t++){let r=0,n=0,i=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:f}=o[l*e+a];r^=c,n^=u,i^=h,s^=f}d.push({s0:r,s1:n,s2:i,s3:s})}this.t=d}_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 f=(1<<i)-1;let l=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&f,{s0:n,s1:y,s2:g,s3:p}=s[l*a+r];o^=n,c^=y,u^=g,h^=p,l+=1}}this.s0=o,this.s1=c,this.s2=u,this.s3=h}update(e){kt(this),bt(e=Ct(e));const t=Bt(e),r=Math.floor(e.length/Ft),n=e.length%Ft;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&&(Nt.set(e.subarray(r*Ft)),this._updateBlock(Lt[0],Lt[1],Lt[2],Lt[3]),It(Lt)),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){kt(this),Et(e,this),this.finished=!0;const{s0:t,s1:r,s2:n,s3:i}=this,s=Bt(e);return s[0]=t,s[1]=r,s[2]=n,s[3]=i,e}digest(){const e=new Uint8Array(Ft);return this.digestInto(e),this.destroy(),e}}class zt extends Ht{constructor(e,t){bt(e=Ct(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}(Mt(e));super(r,t),It(r)}update(e){e=Ct(e),kt(this);const t=Bt(e),r=e.length%Ft,n=Math.floor(e.length/Ft);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&&(Nt.set(e.subarray(n*Ft)),this._updateBlock(Ot(Lt[3]),Ot(Lt[2]),Ot(Lt[1]),Ot(Lt[0])),It(Lt)),this}digestInto(e){kt(this),Et(e,this),this.finished=!0;const{s0:t,s1:r,s2:n,s3:i}=this,s=Bt(e);return s[0]=t,s[1]=r,s[2]=n,s[3]=i,e.reverse()}}function Gt(e){const t=(t,r)=>e(r,t.length).update(Ct(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 Ht(e,t)));Gt(((e,t)=>new zt(e,t)));const jt=16,Vt=/* @__PURE__ */new Uint8Array(jt);function qt(e){return e<<1^283&-(e>>7)}function Yt(e,t){let r=0;for(;t>0;t>>=1)r^=e&-(1&t),e=qt(e);return r}const Zt=/* @__PURE__ */(()=>{const e=new Uint8Array(256);for(let t=0,r=1;t<256;t++,r^=qt(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 It(e),t})(),Jt=/* @__PURE__ */Zt.map(((e,t)=>Zt.indexOf(t))),Wt=e=>e<<8|e>>>24,Xt=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function $t(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(Wt),i=n.map(Wt),s=i.map(Wt),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,T01:a,T23:o}}const er=/* @__PURE__ */$t(Zt,(e=>Yt(e,3)<<24|e<<16|e<<8|Yt(e,2))),tr=/* @__PURE__ */$t(Jt,(e=>Yt(e,11)<<24|Yt(e,13)<<16|Yt(e,9)<<8|Yt(e,14))),rr=/* @__PURE__ *