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