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:{};import{createRequire as e}from"module";import*as r from"node:crypto";function n(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 i=Symbol("doneWritingPromise"),s=Symbol("doneWritingResolve"),a=Symbol("doneWritingReject"),o=Symbol("readingIndex");class c extends Array{constructor(){super(),Object.setPrototypeOf(this,c.prototype),this[i]=new Promise(((t,e)=>{this[s]=t,this[a]=e})),this[i].catch((()=>{}))}}function u(t){return t&&t.getReader&&Array.isArray(t)}function h(t){if(!u(t)){const e=t.getWriter(),r=e.releaseLock;return e.releaseLock=()=>{e.closed.catch((function(){})),r.call(e)},e}this.stream=t}function f(e){if(u(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 l(t){return Uint8Array.prototype.isPrototypeOf(t)}function y(t){if(1===t.length)return t[0];let e=0;for(let r=0;r<t.length;r++){if(!l(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}c.prototype.getReader=function(){return void 0===this[o]&&(this[o]=0),{read:async()=>(await this[i],this[o]===this.length?{value:void 0,done:!0}:{value:this[this[o]++],done:!1})}},c.prototype.readToEnd=async function(t){await this[i];const e=t(this.slice(this[o]));return this.length=0,e},c.prototype.clone=function(){const t=new c;return t[i]=this[i].then((()=>{t.push(...this)})),t},h.prototype.write=async function(t){this.stream.push(t)},h.prototype.close=async function(){this.stream[s]()},h.prototype.abort=async function(t){return this.stream[a](t),t},h.prototype.releaseLock=function(){},"object"==typeof t.process&&t.process.versions;const g=new WeakSet,p=Symbol("externalBuffer");function d(t){if(this.stream=t,t[p]&&(this[p]=t[p].slice()),u(t)){const e=t.getReader();return this._read=e.read.bind(e),this._releaseLock=()=>{},void(this._cancel=()=>{})}if(f(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||g.has(t)?{value:void 0,done:!0}:(e=!0,{value:t,done:!1}),this._releaseLock=()=>{if(e)try{g.add(t)}catch(t){}}}function A(t){return f(t)?t:new ReadableStream({start(e){e.enqueue(t),e.close()}})}function w(t){if(f(t))return t;const e=new c;return(async()=>{const r=R(e);await r.write(t),await r.close()})(),e}function m(t){return t.some((t=>f(t)&&!u(t)))?function(t){t=t.map(A);const e=E((async function(t){await Promise.all(n.map((e=>P(e,t))))}));let r=Promise.resolve();const n=t.map(((n,i)=>B(n,((n,s)=>(r=r.then((()=>b(n,e.writable,{preventClose:i!==t.length-1}))),r)))));return e.readable}(t):t.some((t=>u(t)))?function(t){const e=new c;let r=Promise.resolve();return t.forEach(((n,i)=>(r=r.then((()=>b(n,e,{preventClose:i!==t.length-1}))),r))),e}(t):"string"==typeof t[0]?t.join(""):y(t)}async function b(t,e,{preventClose:r=!1,preventAbort:n=!1,preventCancel:i=!1}={}){if(f(t)&&!u(t)){t=A(t);try{if(t[p]){const r=R(e);for(let e=0;e<t[p].length;e++)await r.ready,await r.write(t[p][e]);r.releaseLock()}await t.pipeTo(e,{preventClose:r,preventAbort:n,preventCancel:i})}catch(t){}return}const s=Q(t=w(t)),a=R(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 k(t,e){const r=new TransformStream(e);return b(t,r.writable),r.readable}function E(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 v(t,e=()=>{},r=()=>{}){if(u(t)){const n=new c;return(async()=>{const i=R(n);try{const n=await U(t),s=e(n),a=r();let o;o=void 0!==s&&void 0!==a?m([s,a]):void 0!==s?s:a,await i.write(o),await i.close()}catch(t){await i.abort(t)}})(),n}if(f(t))return k(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?m([n,i]):void 0!==n?n:i}function B(t,e){if(f(t)&&!u(t)){let r;const n=new TransformStream({start(t){r=t}}),i=b(t,n.writable),s=E((async function(t){r.error(t),await i,await new Promise(setTimeout)}));return e(n.readable,s.writable),s.readable}t=w(t);const r=new c;return e(t,r),r}function I(t,e){let r;const n=B(t,((t,i)=>{const s=Q(t);s.remainder=()=>(s.releaseLock(),b(t,i),n),r=e(s)}));return r}function S(t){if(u(t))return t.clone();if(f(t)){const e=function(t){if(u(t))throw Error("ArrayStream cannot be tee()d, use clone() instead");if(f(t)){const e=A(t).tee();return e[0][p]=e[1][p]=t[p],e}return[D(t),D(t)]}(t);return C(t,e[0]),e[1]}return D(t)}function K(t){return u(t)?S(t):f(t)?new ReadableStream({start(e){const r=B(t,(async(t,r)=>{const n=Q(t),i=R(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)}}));C(t,r)}}):D(t)}function C(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 D(t,e=0,r=1/0){if(u(t))throw Error("Not implemented");if(f(t)){if(e>=0&&r>=0){let n=0;return k(t,{transform(t,i){n<r?(n+t.length>=e&&i.enqueue(D(t,Math.max(e-n,0),r-n)),n+=t.length):i.terminate()}})}if(e<0&&(r<0||r===1/0)){let n=[];return v(t,(t=>{t.length>=-e?n=[t]:n.push(t)}),(()=>D(m(n),e,r)))}if(0===e&&r<0){let n;return v(t,(t=>{const i=n?m([n,t]):t;if(i.length>=-r)return n=D(i,r),D(i,e,r);n=i}))}return console.warn(`stream.slice(input, ${e}, ${r}) not implemented efficiently.`),x((async()=>D(await U(t),e,r)))}return t[p]&&(t=m(t[p].concat([t]))),l(t)?t.subarray(e,r===1/0?t.length:r):t.slice(e,r)}async function U(t,e=m){return u(t)?t.readToEnd(e):f(t)?Q(t).readToEnd(e):t}async function P(t,e){if(f(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 x(t){const e=new c;return(async()=>{const r=R(e);try{await r.write(await t()),await r.close()}catch(t){await r.abort(t)}})(),e}function Q(t){return new d(t)}function R(t){return new h(t)}d.prototype.read=async function(){if(this[p]&&this[p].length){return{done:!1,value:this[p].shift()}}return this._read()},d.prototype.releaseLock=function(){this[p]&&(this.stream[p]=this[p]),this._releaseLock()},d.prototype.cancel=function(t){return this._cancel(t)},d.prototype.readLine=async function(){let t,e=[];for(;!t;){let{done:r,value:n}=await this.read();if(n+="",r)return e.length?m(e):void 0;const i=n.indexOf("\n")+1;i&&(t=m(e.concat(n.substr(0,i))),e=[]),i!==n.length&&e.push(n.substr(i))}return this.unshift(...e),t},d.prototype.readByte=async function(){const{done:t,value:e}=await this.read();if(t)return;const r=e[0];return this.unshift(D(e,1)),r},d.prototype.readBytes=async function(t){const e=[];let r=0;for(;;){const{done:n,value:i}=await this.read();if(n)return e.length?m(e):void 0;if(e.push(i),r+=i.length,r>=t){const r=m(e);return this.unshift(D(r,t)),D(r,0,t)}}},d.prototype.peekBytes=async function(t){const e=await this.readBytes(t);return this.unshift(e),e},d.prototype.unshift=function(...t){this[p]||(this[p]=[]),1===t.length&&l(t[0])&&this[p].length&&t[0].length&&this[p][0].byteOffset>=t[0].length?this[p][0]=new Uint8Array(this[p][0].buffer,this[p][0].byteOffset-t[0].length,this[p][0].byteLength+t[0].length):this[p].unshift(...t.filter((t=>t&&t.length)))},d.prototype.readToEnd=async function(t=m){const e=[];for(;;){const{done:t,value:r}=await this.read();if(t)break;e.push(r)}return t(e)};const T=Symbol("byValue");var M={curve:{nistP256:"nistP256",p256:"nistP256",nistP384:"nistP384",p384:"nistP384",nistP521:"nistP521",p521:"nistP521",secp256k1:"secp256k1",ed25519Legacy:"ed25519Legacy",ed25519:"ed25519Legacy",curve25519Legacy:"curve25519Legacy",curve25519:"curve25519Legacy",brainpoolP256r1:"brainpoolP256r1",brainpoolP384r1:"brainpoolP384r1",brainpoolP512r1:"brainpoolP512r1"},s2k:{simple:0,salted:1,iterated:3,argon2:4,gnu:101},publicKey:{rsaEncryptSign:1,rsaEncrypt:2,rsaSign:3,elgamal:16,dsa:17,ecdh:18,ecdsa:19,eddsaLegacy:22,aedh:23,aedsa:24,x25519:25,x448:26,ed25519:27,ed448:28},symmetric:{idea:1,tripledes:2,cast5:3,blowfish:4,aes128:7,aes192:8,aes256:9,twofish:10},compression:{uncompressed:0,zip:1,zlib:2,bzip2:3},hash:{md5:1,sha1:2,ripemd:3,sha256:8,sha384:9,sha512:10,sha224:11,sha3_256:12,sha3_512:14},webHash:{"SHA-1":2,"SHA-256":8,"SHA-384":9,"SHA-512":10},aead:{eax:1,ocb:2,gcm:3,experimentalGCM:100},packet:{publicKeyEncryptedSessionKey:1,signature:2,symEncryptedSessionKey:3,onePassSignature:4,secretKey:5,publicKey:6,secretSubkey:7,compressedData:8,symmetricallyEncryptedData:9,marker:10,literalData:11,trust:12,userID:13,publicSubkey:14,userAttribute:17,symEncryptedIntegrityProtectedData:18,modificationDetectionCode:19,aeadEncryptedData:20,padding:21},literal:{binary:98,text:116,utf8:117,mime:109},signature:{binary:0,text:1,standalone:2,certGeneric:16,certPersona:17,certCasual:18,certPositive:19,certRevocation:48,subkeyBinding:24,keyBinding:25,key:31,keyRevocation:32,subkeyRevocation:40,timestamp:64,thirdParty:80},signatureSubpacket:{signatureCreationTime:2,signatureExpirationTime:3,exportableCertification:4,trustSignature:5,regularExpression:6,revocable:7,keyExpirationTime:9,placeholderBackwardsCompatibility:10,preferredSymmetricAlgorithms:11,revocationKey:12,issuerKeyID:16,notationData:20,preferredHashAlgorithms:21,preferredCompressionAlgorithms:22,keyServerPreferences:23,preferredKeyServer:24,primaryUserID:25,policyURI:26,keyFlags:27,signersUserID:28,reasonForRevocation:29,features:30,signatureTarget:31,embeddedSignature:32,issuerFingerprint:33,preferredAEADAlgorithms:34,preferredCipherSuites:39},keyFlags:{certifyKeys:1,signData:2,encryptCommunication:4,encryptStorage:8,splitPrivateKey:16,authentication:32,sharedPrivateKey:128},armor:{multipartSection:0,multipartLast:1,signed:2,message:3,publicKey:4,privateKey:5,signature:6},reasonForRevocation:{noReason:0,keySuperseded:1,keyCompromised:2,keyRetired:3,userIDInvalid:32},features:{modificationDetection:1,aead:2,v5Keys:4,seipdv2:8},write:function(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[T]||(t[T]=[],Object.entries(t).forEach((([e,r])=>{t[T][r]=e}))),void 0!==t[T][e])return t[T][e];throw Error("Invalid enum value.")}},F={preferredHashAlgorithm:M.hash.sha512,preferredSymmetricAlgorithm:M.symmetric.aes256,preferredCompressionAlgorithm:M.compression.uncompressed,aeadProtect:!1,parseAEADEncryptedV4KeysAsLegacy:!1,preferredAEADAlgorithm:M.aead.gcm,aeadChunkSizeByte:12,v6Keys:!1,enableParsingV5Entities:!1,s2kType:M.s2k.iterated,s2kIterationCountByte:224,s2kArgon2Params:{passes:3,parallelism:4,memoryExponent:16},allowUnauthenticatedMessages:!1,allowUnauthenticatedStream:!1,minRSABits:2047,passwordCollisionCheck:!1,allowInsecureDecryptionWithSigningKeys:!1,allowInsecureVerificationWithReformattedKeys:!1,allowMissingKeyFlags:!1,constantTimePKCS1Decryption:!1,constantTimePKCS1DecryptionSupportedSymmetricAlgorithms:new Set([M.symmetric.aes128,M.symmetric.aes192,M.symmetric.aes256]),ignoreUnsupportedPackets:!0,ignoreMalformedPackets:!1,enforceGrammar:!0,additionalAllowedPackets:[],showVersion:!1,showComment:!1,versionString:"OpenPGP.js 6.2.1",commentString:"https://openpgpjs.org",maxUserIDLength:5120,knownNotations:[],nonDeterministicSignaturesViaNotation:!0,useEllipticFallback:!0,rejectHashAlgorithms:new Set([M.hash.md5,M.hash.ripemd]),rejectMessageHashAlgorithms:new Set([M.hash.md5,M.hash.ripemd,M.hash.sha1]),rejectPublicKeyAlgorithms:new Set([M.publicKey.elgamal,M.publicKey.dsa]),rejectCurves:new Set([M.curve.secp256k1])};const N=(()=>{try{return"development"===process.env.NODE_ENV}catch(t){}return!1})(),L={isString:function(t){return"string"==typeof t||t instanceof String},nodeRequire:e(import.meta.url),isArray:function(t){return t instanceof Array},isUint8Array:l,isStream:f,getNobleCurve:async(t,e)=>{if(!F.useEllipticFallback)throw Error("This curve is only supported in the full build of OpenPGP.js");const{nobleCurves:r}=await Promise.resolve().then((function(){return Lf}));switch(t){case M.publicKey.ecdh:case M.publicKey.ecdsa:{const t=r.get(e);if(!t)throw Error("Unsupported curve");return t}case M.publicKey.x448:return r.get("x448");case M.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=L.readNumber(t);return new Date(1e3*e)},writeDate:function(t){const e=Math.floor(t.getTime()/1e3);return L.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 L.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=L.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 L.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)+L.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 v(t,(t=>{if(!L.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 v(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 v(t,r,(()=>r(new Uint8Array,!0)))},concat:m,concatUint8Array:y,equalsUint8Array:function(t,e){if(!L.isUint8Array(t)||!L.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 L.writeNumber(e,2)},printDebug:function(t){N&&console.log("[OpenPGP.js debug]",t)},printDebugError:function(t){N&&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(!L.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 v(t,(t=>{let r;e&&(t=L.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 v(t,(t=>{let r;13===(t=e&&10!==t[0]?L.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===M.symmetric.aes128||t===M.symmetric.aes192||t===M.symmetric.aes256}},O=L.getNodeBuffer();let H,z;function G(t){let e=new Uint8Array;return v(t,(t=>{e=L.concatUint8Array([e,t]);const r=[],n=Math.floor(e.length/45),i=45*n,s=H(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?H(e)+"\n":""))}function _(t){let e="";return v(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=z(e.substr(0,i));return e=e.substr(i),s}),(()=>z(e)))}function j(t){return _(t.replace(/-/g,"+").replace(/_/g,"/"))}function V(t,e){let r=G(t).replace(/[\r\n]/g,"");return r=r.replace(/[+]/g,"-").replace(/[/]/g,"_").replace(/[=]/g,""),r}function q(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])?M.armor.multipartSection:/MESSAGE, PART \d+/.test(e[1])?M.armor.multipartLast:/SIGNED MESSAGE/.test(e[1])?M.armor.signed:/MESSAGE/.test(e[1])?M.armor.message:/PUBLIC KEY BLOCK/.test(e[1])?M.armor.publicKey:/PRIVATE KEY BLOCK/.test(e[1])?M.armor.privateKey:/SIGNATURE/.test(e[1])?M.armor.signature:void 0}function Y(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 Z(t){const e=function(t){let e=13501623;return v(t,(t=>{const r=W?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=J[0][e>>24&255]^J[1][e>>16&255]^J[2][e>>8&255]^J[3][255&e];for(let n=4*r;n<t.length;n++)e=e>>8^J[0][255&e^t[n]]}),(()=>new Uint8Array([e,e>>8,e>>16])))}(t);return G(e)}O?(H=t=>O.from(t).toString("base64"),z=t=>{const e=O.from(t,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}):(H=t=>btoa(L.uint8ArrayToString(t)),z=t=>L.stringToUint8Array(atob(t)));const J=[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);J[0][t]=(16711680&e)>>16|65280&e|(255&e)<<16}for(let t=0;t<=255;t++)J[1][t]=J[0][t]>>8^J[0][255&J[0][t]];for(let t=0;t<=255;t++)J[2][t]=J[1][t]>>8^J[0][255&J[1][t]];for(let t=0;t<=255;t++)J[3][t]=J[2][t]>>8^J[0][255&J[2][t]];const W=function(){const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,255,!0),255===new Int16Array(t)[0]}();function X(t){for(let e=0;e<t.length;e++)/^([^\s:]|[^\s:][^:]*[^\s:]): .+$/.test(t[e])||L.printDebugError(Error("Improperly formatted armor header: "+t[e])),/^(Version|Comment|MessageID|Hash|Charset): .+$/.test(t[e])||L.printDebugError(Error("Unknown header: "+t[e]))}function $(t){let e=t;const r=t.lastIndexOf("=");return r>=0&&r!==t.length-1&&(e=t.slice(0,r)),e}function tt(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=_(B(t,(async(t,l)=>{const y=Q(t);try{for(;;){let t=await y.readLine();if(void 0===t)throw Error("Misformed armored text");if(t=L.removeTrailingSpaces(t.replace(/[\r\n]/g,"")),s)if(o)c||s!==M.armor.signed||(n.test(t)?(h=h.join("\r\n"),c=!0,X(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(X(u),o=!0,c||s!==M.armor.signed){e({text:h,data:f,headers:a,type:s});break}}else u.push(t);else n.test(t)&&(s=q(t))}}catch(t){return void r(t)}const g=R(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=L.removeTrailingSpaces(t.replace(/\r/g,""));const e=t.split(n);if(1===e.length)throw Error("Misformed armored text");const i=$(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=>(u(t.data)&&(t.data=await U(t.data)),t)))}function et(t,e,r,n,i,s=!1,a=F){let o,c;t===M.armor.signed&&(o=e.text,c=e.hash,e=e.data);const u=s&&K(e),h=[];switch(t){case M.armor.multipartSection:h.push("-----BEGIN PGP MESSAGE, PART "+r+"/"+n+"-----\n"),h.push(Y(i,a)),h.push(G(e)),u&&h.push("=",Z(u)),h.push("-----END PGP MESSAGE, PART "+r+"/"+n+"-----\n");break;case M.armor.multipartLast:h.push("-----BEGIN PGP MESSAGE, PART "+r+"-----\n"),h.push(Y(i,a)),h.push(G(e)),u&&h.push("=",Z(u)),h.push("-----END PGP MESSAGE, PART "+r+"-----\n");break;case M.armor.signed:h.push("-----BEGIN PGP SIGNED MESSAGE-----\n"),h.push(c?`Hash: ${c}\n\n`:"\n"),h.push(o.replace(/^-/gm,"- -")),h.push("\n-----BEGIN PGP SIGNATURE-----\n"),h.push(Y(i,a)),h.push(G(e)),u&&h.push("=",Z(u)),h.push("-----END PGP SIGNATURE-----\n");break;case M.armor.message:h.push("-----BEGIN PGP MESSAGE-----\n"),h.push(Y(i,a)),h.push(G(e)),u&&h.push("=",Z(u)),h.push("-----END PGP MESSAGE-----\n");break;case M.armor.publicKey:h.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),h.push(Y(i,a)),h.push(G(e)),u&&h.push("=",Z(u)),h.push("-----END PGP PUBLIC KEY BLOCK-----\n");break;case M.armor.privateKey:h.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\n"),h.push(Y(i,a)),h.push(G(e)),u&&h.push("=",Z(u)),h.push("-----END PGP PRIVATE KEY BLOCK-----\n");break;case M.armor.signature:h.push("-----BEGIN PGP SIGNATURE-----\n"),h.push(Y(i,a)),h.push(G(e)),u&&h.push("=",Z(u)),h.push("-----END PGP SIGNATURE-----\n")}return L.concat(h)}const rt=BigInt(0),nt=BigInt(1);function it(t){const e="0123456789ABCDEF";let r="";return t.forEach((t=>{r+=e[t>>4]+e[15&t]})),BigInt("0x0"+r)}function st(t,e){const r=t%e;return r<rt?r+e:r}function at(t,e,r){if(r===rt)throw Error("Modulo cannot be zero");if(r===nt)return BigInt(0);if(e<rt)throw Error("Unsopported negative exponent");let n=e,i=t;i%=r;let s=BigInt(1);for(;n>rt;){const t=n&nt;n>>=nt;s=t?s*i%r:s,i=i*i%r}return s}function ot(t){return t>=rt?t:-t}function ct(t,e){const{gcd:r,x:n}=function(t,e){let r=BigInt(0),n=BigInt(1),i=BigInt(1),s=BigInt(0),a=ot(t),o=ot(e);const c=t<rt,u=e<rt;for(;o!==rt;){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!==nt)throw Error("Inverse does not exist");return st(n+e,e)}function ut(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 ht(t,e){return(t>>BigInt(e)&nt)===rt?0:1}function ft(t){const e=t<rt?BigInt(-1):rt;let r=1,n=t;for(;(n>>=nt)!==e;)r++;return r}function lt(t){const e=t<rt?BigInt(-1):rt,r=BigInt(8);let n=1,i=t;for(;(i>>=r)!==e;)n++;return n}function yt(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 gt=L.getNodeCrypto();function pt(t){const e="undefined"!=typeof crypto?crypto:gt?.webcrypto;if(e?.getRandomValues){const r=new Uint8Array(t);return e.getRandomValues(r)}throw Error("No secure random number generator available.")}function dt(t,e){if(e<t)throw Error("Illegal parameter value: max <= min");const r=e-t;return st(it(pt(lt(r)+8)),r)+t}const At=BigInt(1);function wt(t,e,r){const n=BigInt(30),i=At<<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=dt(i,i<<At),o=ut(st(a,n));do{a+=BigInt(s[o]),o=(o+s[o])%s.length,ft(a)>t&&(a=st(a,i<<At),a+=i,o=ut(st(a,n)))}while(!mt(a,e,r));return a}function mt(t,e,r){return(!e||function(t,e){let r=t,n=e;for(;n!==rt;){const t=n;n=r%n,r=t}return r}(t-At,e)===At)&&(!!function(t){const e=BigInt(0);return bt.every((r=>st(t,r)!==e))}(t)&&(!!function(t,e=BigInt(2)){return at(e,t-At,t)===At}(t)&&!!function(t,e){const r=ft(t);e||(e=Math.max(1,r/48|0));const n=t-At;let i=0;for(;!ht(n,i);)i++;const s=t>>BigInt(i);for(;e>0;e--){let e,r=at(dt(BigInt(2),n),s,t);if(r!==At&&r!==n){for(e=1;e<i;e++){if(r=st(r*r,t),r===At)return!1;if(r===n)break}if(e===i)return!1}}return!0}(t,r)))}const bt=[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 kt=L.getWebCrypto(),Et=L.getNodeCrypto(),vt=Et&&Et.getHashes();function Bt(t){if(Et&&vt.includes(t))return async function(e){const r=Et.createHash(t);return v(e,(t=>{r.update(t)}),(()=>new Uint8Array(r.digest())))}}function It(t,e){const r=async()=>{const{nobleHashes:e}=await Promise.resolve().then((function(){return ll})),r=e.get(t);if(!r)throw Error("Unsupported hash");return r};return async function(t){if(u(t)&&(t=await U(t)),L.isStream(t)){const e=(await r()).create();return v(t,(t=>{e.update(t)}),(()=>e.digest()))}if(kt&&e)return new Uint8Array(await kt.digest(e,t));return(await r())(t)}}const St=Bt("md5")||It("md5"),Kt=Bt("sha1")||It("sha1","SHA-1"),Ct=Bt("sha224")||It("sha224"),Dt=Bt("sha256")||It("sha256","SHA-256"),Ut=Bt("sha384")||It("sha384","SHA-384"),Pt=Bt("sha512")||It("sha512","SHA-512"),xt=Bt("ripemd160")||It("ripemd160"),Qt=Bt("sha3-256")||It("sha3_256"),Rt=Bt("sha3-512")||It("sha3_512");function Tt(t,e){switch(t){case M.hash.md5:return St(e);case M.hash.sha1:return Kt(e);case M.hash.ripemd:return xt(e);case M.hash.sha256:return Dt(e);case M.hash.sha384:return Ut(e);case M.hash.sha512:return Pt(e);case M.hash.sha224:return Ct(e);case M.hash.sha3_256:return Qt(e);case M.hash.sha3_512:return Rt(e);default:throw Error("Unsupported hash function")}}function Mt(t){switch(t){case M.hash.md5:return 16;case M.hash.sha1:case M.hash.ripemd:return 20;case M.hash.sha256:return 32;case M.hash.sha384:return 48;case M.hash.sha512:return 64;case M.hash.sha224:return 28;case M.hash.sha3_256:return 32;case M.hash.sha3_512:return 64;default:throw Error("Invalid hash algorithm.")}}const Ft=[];function Nt(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=pt(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 Lt(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 L.selectUint8Array(a,s,e);if(a)return s;throw Error("Decryption error")}function Ot(t,e,r){let n;if(e.length!==Mt(t))throw Error("Invalid hash length");const i=new Uint8Array(Ft[t].length);for(n=0;n<Ft[t].length;n++)i[n]=Ft[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}Ft[1]=[48,32,48,12,6,8,42,134,72,134,247,13,2,5,5,0,4,16],Ft[2]=[48,33,48,9,6,5,43,14,3,2,26,5,0,4,20],Ft[3]=[48,33,48,9,6,5,43,36,3,2,1,5,0,4,20],Ft[8]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32],Ft[9]=[48,65,48,13,6,9,96,134,72,1,101,3,4,2,2,5,0,4,48],Ft[10]=[48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64],Ft[11]=[48,45,48,13,6,9,96,134,72,1,101,3,4,2,4,5,0,4,28];const Ht=L.getWebCrypto(),zt=L.getNodeCrypto(),Gt=BigInt(1);async function _t(t,e,r,n,i,s,a,o,c){if(Mt(t)>=r.length)throw Error("Digest size cannot exceed key modulus size");if(e&&!L.isStream(e))if(L.getWebCrypto())try{return await async function(t,e,r,n,i,s,a,o){const c=await Yt(r,n,i,s,a,o),u={name:"RSASSA-PKCS1-v1_5",hash:{name:t}},h=await Ht.importKey("jwk",c,u,!1,["sign"]);return new Uint8Array(await Ht.sign("RSASSA-PKCS1-v1_5",h,e))}(M.read(M.webHash,t),e,r,n,i,s,a,o)}catch(t){L.printDebugError(t)}else if(L.getNodeCrypto())return async function(t,e,r,n,i,s,a,o){const c=zt.createSign(M.read(M.hash,t));c.write(e),c.end();const u=await Yt(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=it(e);const i=it(Ot(t,n,lt(e)));return r=it(r),yt(at(i,r,e),"be",lt(e))}(t,r,i,c)}async function jt(t,e,r,n,i,s){if(e&&!L.isStream(e))if(L.getWebCrypto())try{return await async function(t,e,r,n,i){const s=Zt(n,i),a=await Ht.importKey("jwk",s,{name:"RSASSA-PKCS1-v1_5",hash:{name:t}},!1,["verify"]);return Ht.verify("RSASSA-PKCS1-v1_5",a,r,e)}(M.read(M.webHash,t),e,r,n,i)}catch(t){L.printDebugError(t)}else if(L.getNodeCrypto())return async function(t,e,r,n,i){const s=Zt(n,i),a={key:s,format:"jwk",type:"pkcs1"},o=zt.createVerify(M.read(M.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=it(r),e=it(e),n=it(n),e>=r)throw Error("Signature size cannot exceed modulus size");const s=yt(at(e,n,r),"be",lt(r)),a=Ot(t,i,lt(r));return L.equalsUint8Array(s,a)}(t,r,n,i,s)}async function Vt(t,e,r){return L.getNodeCrypto()?async function(t,e,r){const n=Zt(e,r),i={key:n,format:"jwk",type:"pkcs1",padding:zt.constants.RSA_PKCS1_PADDING};return new Uint8Array(zt.publicEncrypt(i,t))}(t,e,r):async function(t,e,r){if(e=it(e),t=it(Nt(t,lt(e))),r=it(r),t>=e)throw Error("Message size cannot exceed modulus size");return yt(at(t,r,e),"be",lt(e))}(t,e,r)}async function qt(t,e,r,n,i,s,a,o){if(L.getNodeCrypto()&&!o)try{return await async function(t,e,r,n,i,s,a){const o=await Yt(e,r,n,i,s,a),c={key:o,format:"jwk",type:"pkcs1",padding:zt.constants.RSA_PKCS1_PADDING};try{return new Uint8Array(zt.privateDecrypt(c,t))}catch(t){throw Error("Decryption error")}}(t,e,r,n,i,s,a)}catch(t){L.printDebugError(t)}return async function(t,e,r,n,i,s,a,o){if(t=it(t),e=it(e),r=it(r),n=it(n),i=it(i),s=it(s),a=it(a),t>=e)throw Error("Data too large.");const c=st(n,s-Gt),u=st(n,i-Gt),h=dt(BigInt(2),e),f=at(ct(h,e),r,e);t=st(t*f,e);const l=at(t,u,i),y=at(t,c,s),g=st(a*(y-l),s);let p=g*i+l;return p=st(p*h,e),Lt(yt(p,"be",lt(e)),o)}(t,e,r,n,i,s,a,o)}async function Yt(t,e,r,n,i,s){const a=it(n),o=it(i),c=it(r);let u=st(c,o-Gt),h=st(c,a-Gt);return h=yt(h),u=yt(u),{kty:"RSA",n:V(t),e:V(e),d:V(r),p:V(i),q:V(n),dp:V(u),dq:V(h),qi:V(s),ext:!0}}function Zt(t,e){return{kty:"RSA",n:V(t),e:V(e),ext:!0}}function Jt(t,e){return{n:j(t.n),e:yt(e),d:j(t.d),p:j(t.q),q:j(t.p),u:j(t.qi)}}const Wt=BigInt(1);const Xt={"2a8648ce3d030107":M.curve.nistP256,"2b81040022":M.curve.nistP384,"2b81040023":M.curve.nistP521,"2b8104000a":M.curve.secp256k1,"2b06010401da470f01":M.curve.ed25519Legacy,"2b060104019755010501":M.curve.curve25519Legacy,"2b2403030208010107":M.curve.brainpoolP256r1,"2b240303020801010b":M.curve.brainpoolP384r1,"2b240303020801010d":M.curve.brainpoolP512r1};class $t{constructor(t){if(t instanceof $t)this.oid=t.oid;else if(L.isArray(t)||L.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 L.concatUint8Array([new Uint8Array([this.oid.length]),this.oid])}toHex(){return L.uint8ArrayToHex(this.oid)}getName(){const t=Xt[this.toHex()];if(!t)throw Error("Unknown curve object identifier.");return t}}function te(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=L.readNumber(t.subarray(1,5)),e=5),{len:r,offset:e}}function ee(t){return t<192?new Uint8Array([t]):t>191&&t<8384?new Uint8Array([192+(t-192>>8),t-192&255]):L.concatUint8Array([new Uint8Array([255]),L.writeNumber(t,4)])}function re(t){if(t<0||t>30)throw Error("Partial Length power must be between 1 and 30");return new Uint8Array([224+t])}function ne(t){return new Uint8Array([192|t])}function ie(t,e){return L.concatUint8Array([ne(t),ee(e)])}function se(t){return[M.packet.literalData,M.packet.compressedData,M.packet.symmetricallyEncryptedData,M.packet.symEncryptedIntegrityProtectedData,M.packet.aeadEncryptedData].includes(t)}async function ae(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 a=await t.readByte();let o,u,h=-1,f=-1;f=0,64&a&&(f=1),f?h=63&a:(h=(63&a)>>2,u=3&a);const l=se(h);let y,g=null;if(e&&l){if("array"===e){const t=new c;n=R(t),g=t}else{const t=new TransformStream;n=R(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)o=e;else if(e>=192&&e<224)o=(e-192<<8)+await t.readByte()+192;else if(e>223&&e<255){if(o=1<<(31&e),y=!0,!l)throw new TypeError("This packet type does not support partial lengths.")}else o=await t.readByte()<<24|await t.readByte()<<16|await t.readByte()<<8|await t.readByte()}else switch(u){case 0:o=await t.readByte();break;case 1:o=await t.readByte()<<8|await t.readByte();break;case 2:o=await t.readByte()<<24|await t.readByte()<<16|await t.readByte()<<8|await t.readByte();break;default:o=1/0}if(o>0){let e=0;for(;;){n&&await n.ready;const{done:r,value:i}=await t.read();if(r){if(o===1/0)break;throw Error("Unexpected end of packet")}const s=o===1/0?i:i.subarray(0,o-e);if(n?await n.write(s):g.push(s),e+=i.length,e>=o){t.unshift(i.subarray(o-e+i.length));break}}}}while(y);n?(await n.ready,await n.close()):(g=L.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 oe extends Error{constructor(...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,oe),this.name="UnsupportedError"}}class ce extends oe{constructor(...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,oe),this.name="UnknownPacketError"}}class ue extends oe{constructor(...t){super(...t),Error.captureStackTrace&&Error.captureStackTrace(this,oe),this.name="MalformedPacketError"}}class he{constructor(t,e){this.tag=t,this.rawContent=e}write(){return this.rawContent}}async function fe(t){switch(t){case M.publicKey.ed25519:try{const t=L.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(j(n.x)),seed:j(r.d)}}catch(e){if("NotSupportedError"!==e.name)throw e;const{default:r}=await Promise.resolve().then((function(){return ny})),n=pt(pe(t)),{publicKey:i}=r.sign.keyPair.fromSeed(n);return{A:i,seed:n}}case M.publicKey.ed448:{const t=await L.getNobleCurve(M.publicKey.ed448),{secretKey:e,publicKey:r}=t.keygen();return{A:r,seed:e}}default:throw Error("Unsupported EdDSA algorithm")}}async function le(t,e,r,n,i,s){if(Mt(e)<Mt(de(t)))throw Error("Hash algorithm too weak for EdDSA.");switch(t){case M.publicKey.ed25519:try{const e=L.getWebCrypto(),r=we(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 ny})),r=L.concatUint8Array([i,n]);return{RS:e.sign.detached(s,r)}}case M.publicKey.ed448:return{RS:(await L.getNobleCurve(M.publicKey.ed448)).sign(s,i)};default:throw Error("Unsupported EdDSA algorithm")}}async function ye(t,e,{RS:r},n,i,s){if(Mt(e)<Mt(de(t)))throw Error("Hash algorithm too weak for EdDSA.");switch(t){case M.publicKey.ed25519:try{const e=L.getWebCrypto(),n=Ae(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 ny}));return e.sign.detached.verify(s,r,i)}case M.publicKey.ed448:return(await L.getNobleCurve(M.publicKey.ed448)).verify(r,s,i);default:throw Error("Unsupported EdDSA algorithm")}}async function ge(t,e,r){switch(t){case M.publicKey.ed25519:try{const n=L.getWebCrypto(),i=we(t,e,r),s=Ae(t,e),a=await n.importKey("jwk",i,"Ed25519",!1,["sign"]),o=await n.importKey("jwk",s,"Ed25519",!1,["verify"]),c=pt(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 ny})),{publicKey:i}=n.sign.keyPair.fromSeed(r);return L.equalsUint8Array(e,i)}case M.publicKey.ed448:{const t=(await L.getNobleCurve(M.publicKey.ed448)).getPublicKey(r);return L.equalsUint8Array(e,t)}default:return!1}}function pe(t){switch(t){case M.publicKey.ed25519:return 32;case M.publicKey.ed448:return 57;default:throw Error("Unsupported EdDSA algorithm")}}function de(t){switch(t){case M.publicKey.ed25519:return M.hash.sha256;case M.publicKey.ed448:return M.hash.sha512;default:throw Error("Unknown EdDSA algo")}}const Ae=(t,e)=>{if(t===M.publicKey.ed25519){return{kty:"OKP",crv:"Ed25519",x:V(e),ext:!0}}throw Error("Unsupported EdDSA algorithm")},we=(t,e,r)=>{if(t===M.publicKey.ed25519){const n=Ae(t,e);return n.d=V(r),n}throw Error("Unsupported EdDSA algorithm")};var me=/*#__PURE__*/Object.freeze({__proto__:null,generate:fe,getPayloadSize:pe,getPreferredHashAlgo:de,sign:le,validateParams:ge,verify:ye}); /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function be(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function ke(t,...e){if(!be(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 Ee(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 ve(t,e){ke(t);const r=e.outputLen;if(t.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}function Be(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Ie(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Se(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Ke(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const Ce=/* @__PURE__ */(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function De(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(!be(t))throw Error("Uint8Array expected, got "+typeof t);t=Fe(t)}return t}function Ue(t,e){return t.buffer===e.buffer&&t.byteOffset<e.byteOffset+e.byteLength&&e.byteOffset<t.byteOffset+t.byteLength}function Pe(t,e){if(Ue(t,e)&&t.byteOffset<e.byteOffset)throw Error("complex overlap of input and output is not supported")}function xe(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 Qe=(t,e)=>{function r(r,...n){if(ke(r),!Ce)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?ke(e):ke(e,t.nonceLength)}const i=t.tagLength;i&&void 0!==n[1]&&ke(n[1]);const s=e(r,...n),a=(t,e)=>{if(void 0!==e){if(2!==t)throw Error("cipher output not supported");ke(e)}};let o=!1;return{encrypt(t,e){if(o)throw Error("cannot encrypt() twice with same key + nonce");return o=!0,ke(t),a(s.encrypt.length,e),s.encrypt(t,e)},decrypt(t,e){if(ke(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 Re(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&&!Me(e))throw Error("invalid output, must be aligned");return e}function Te(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 Me(t){return t.byteOffset%4==0}function Fe(t){return Uint8Array.from(t)}const Ne=16,Le=/* @__PURE__ */new Uint8Array(16),Oe=Ie(Le),He=t=>(t>>>0&255)<<24|(t>>>8&255)<<16|(t>>>16&255)<<8|t>>>24&255;class ze{constructor(t,e){this.blockLen=Ne,this.outputLen=Ne,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,ke(t=De(t),16);const r=Ke(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:He(n),s1:He(i),s2:He(s),s3:He(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){Ee(this),ke(t=De(t));const e=Ie(t),r=Math.floor(t.length/Ne),n=t.length%Ne;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&&(Le.set(t.subarray(r*Ne)),this._updateBlock(Oe[0],Oe[1],Oe[2],Oe[3]),Se(Oe)),this}destroy(){const{t}=this;for(const e of t)e.s0=0,e.s1=0,e.s2=0,e.s3=0}digestInto(t){Ee(this),ve(t,this),this.finished=!0;const{s0:e,s1:r,s2:n,s3:i}=this,s=Ie(t);return s[0]=e,s[1]=r,s[2]=n,s[3]=i,t}digest(){const t=new Uint8Array(Ne);return this.digestInto(t),this.destroy(),t}}class Ge extends ze{constructor(t,e){ke(t=De(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}(Fe(t));super(r,e),Se(r)}update(t){t=De(t),Ee(this);const e=Ie(t),r=t.length%Ne,n=Math.floor(t.length/Ne);for(let t=0;t<n;t++)this._updateBlock(He(e[4*t+3]),He(e[4*t+2]),He(e[4*t+1]),He(e[4*t+0]));return r&&(Le.set(t.subarray(n*Ne)),this._updateBlock(He(Oe[3]),He(Oe[2]),He(Oe[1]),He(Oe[0])),Se(Oe)),this}digestInto(t){Ee(this),ve(t,this),this.finished=!0;const{s0:e,s1:r,s2:n,s3:i}=this,s=Ie(t);return s[0]=e,s[1]=r,s[2]=n,s[3]=i,t.reverse()}}function _e(t){const e=(e,r)=>t(r,e.length).update(De(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 je=_e(((t,e)=>new ze(t,e)));_e(((t,e)=>new Ge(t,e)));const Ve=16,qe=/* @__PURE__ */new Uint8Array(Ve);function Ye(t){return t<<1^283&-(t>>7)}function Ze(t,e){let r=0;for(;e>0;e>>=1)r^=t&-(1&e),t=Ye(t);return r}const Je=/* @__PURE__ */(()=>{const t=new Uint8Array(256);for(let e=0,r=1;e<256;e++,r^=Ye(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 Se(t),e})(),We=/* @__PURE__ */Je.map(((t,e)=>Je.indexOf(e))),Xe=t=>t<<8|t>>>24,$e=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;function tr(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(Xe),i=n.map(Xe),s=i.map(Xe),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 er=/* @__PURE__ */tr(Je,(t=>Ze(t,3)<<24|t<<16|t<<8|Ze(t,2))),rr=/* @__PURE__ */tr(We,(t=>Ze(t,11)<<24|Ze(t,13)<