@peculiar/acme-client
Advanced tools
Comparing version 1.8.0 to 1.8.2
@@ -1,1 +0,1 @@ | ||
var acme=function(t){"use strict";var e,r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(t){!function(e){var n="object"==typeof r?r:"object"==typeof self?self:"object"==typeof this?this:Function("return this;")(),o=i(t);function i(t,e){return function(r,n){"function"!=typeof t[r]&&Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0===n.Reflect?n.Reflect=t:o=i(n.Reflect,o),function(t){var e=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,n=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=r&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,a=!i&&!s,c={create:i?function(){return nt(Object.create(null))}:s?function(){return nt({__proto__:null})}:function(){return nt({})},has:a?function(t,r){return e.call(t,r)}:function(t,e){return e in t},get:a?function(t,r){return e.call(t,r)?t[r]:void 0}:function(t,e){return t[e]}},u=Object.getPrototypeOf(Function),h="object"==typeof process&&process.env&&"true"===process.env.REFLECT_METADATA_USE_MAP_POLYFILL,f=h||"function"!=typeof Map||"function"!=typeof Map.prototype.entries?tt():Map,l=h||"function"!=typeof Set||"function"!=typeof Set.prototype.entries?et():Set,p=new(h||"function"!=typeof WeakMap?rt():WeakMap);function y(t,e,r,n){if(j(r)){if(!G(t))throw new TypeError;if(!z(e))throw new TypeError;return E(t,e)}if(!G(t))throw new TypeError;if(!I(e))throw new TypeError;if(!I(n)&&!j(n)&&!B(n))throw new TypeError;return B(n)&&(n=void 0),_(t,e,r=W(r),n)}function d(t,e){function r(r,n){if(!I(r))throw new TypeError;if(!j(n)&&!$(n))throw new TypeError;K(t,e,r,n)}return r}function g(t,e,r,n){if(!I(r))throw new TypeError;return j(n)||(n=W(n)),K(t,e,r,n)}function w(t,e,r){if(!I(e))throw new TypeError;return j(r)||(r=W(r)),k(t,e,r)}function v(t,e,r){if(!I(e))throw new TypeError;return j(r)||(r=W(r)),T(t,e,r)}function m(t,e,r){if(!I(e))throw new TypeError;return j(r)||(r=W(r)),P(t,e,r)}function S(t,e,r){if(!I(e))throw new TypeError;return j(r)||(r=W(r)),O(t,e,r)}function A(t,e){if(!I(t))throw new TypeError;return j(e)||(e=W(e)),H(t,e)}function C(t,e){if(!I(t))throw new TypeError;return j(e)||(e=W(e)),N(t,e)}function b(t,e,r){if(!I(e))throw new TypeError;j(r)||(r=W(r));var n=R(e,r,!1);if(j(n))return!1;if(!n.delete(t))return!1;if(n.size>0)return!0;var o=p.get(e);return o.delete(r),o.size>0||p.delete(e),!0}function E(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!j(n)&&!B(n)){if(!z(n))throw new TypeError;e=n}}return e}function _(t,e,r,n){for(var o=t.length-1;o>=0;--o){var i=(0,t[o])(e,r,n);if(!j(i)&&!B(i)){if(!I(i))throw new TypeError;n=i}}return n}function R(t,e,r){var n=p.get(t);if(j(n)){if(!r)return;n=new f,p.set(t,n)}var o=n.get(e);if(j(o)){if(!r)return;o=new f,n.set(e,o)}return o}function k(t,e,r){if(T(t,e,r))return!0;var n=X(e);return!B(n)&&k(t,n,r)}function T(t,e,r){var n=R(e,r,!1);return!j(n)&&D(n.has(t))}function P(t,e,r){if(T(t,e,r))return O(t,e,r);var n=X(e);return B(n)?void 0:P(t,n,r)}function O(t,e,r){var n=R(e,r,!1);if(!j(n))return n.get(t)}function K(t,e,r,n){R(r,n,!0).set(t,e)}function H(t,e){var r=N(t,e),n=X(t);if(null===n)return r;var o=H(n,e);if(o.length<=0)return r;if(r.length<=0)return o;for(var i=new l,s=[],a=0,c=r;a<c.length;a++){var u=c[a];i.has(u)||(i.add(u),s.push(u))}for(var h=0,f=o;h<f.length;h++){u=f[h];i.has(u)||(i.add(u),s.push(u))}return s}function N(t,e){var r=[],n=R(t,e,!1);if(j(n))return r;for(var o=q(n.keys()),i=0;;){var s=Z(o);if(!s)return r.length=i,r;var a=Y(s);try{r[i]=a}catch(t){try{Q(o)}finally{throw t}}i++}}function x(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function j(t){return void 0===t}function B(t){return null===t}function U(t){return"symbol"==typeof t}function I(t){return"object"==typeof t?null!==t:"function"==typeof t}function M(t,e){switch(x(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r=3===e?"string":5===e?"number":"default",o=V(t,n);if(void 0!==o){var i=o.call(t,r);if(I(i))throw new TypeError;return i}return L(t,"default"===r?"number":r)}function L(t,e){if("string"===e){var r=t.toString;if(J(r))if(!I(o=r.call(t)))return o;if(J(n=t.valueOf))if(!I(o=n.call(t)))return o}else{var n;if(J(n=t.valueOf))if(!I(o=n.call(t)))return o;var o,i=t.toString;if(J(i))if(!I(o=i.call(t)))return o}throw new TypeError}function D(t){return!!t}function F(t){return""+t}function W(t){var e=M(t,3);return U(e)?e:F(e)}function G(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function J(t){return"function"==typeof t}function z(t){return"function"==typeof t}function $(t){switch(x(t)){case 3:case 4:return!0;default:return!1}}function V(t,e){var r=t[e];if(null!=r){if(!J(r))throw new TypeError;return r}}function q(t){var e=V(t,o);if(!J(e))throw new TypeError;var r=e.call(t);if(!I(r))throw new TypeError;return r}function Y(t){return t.value}function Z(t){var e=t.next();return!e.done&&e}function Q(t){var e=t.return;e&&e.call(t)}function X(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===u)return e;if(e!==u)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var o=n.constructor;return"function"!=typeof o||o===t?e:o}function tt(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}();return function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,e===this._cacheKey&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,n)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){return this._cacheKey!==t&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=t)),this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();function n(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function et(){return function(){function t(){this._map=new f}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.values()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[o]=function(){return this.keys()},t}()}function rt(){var t=16,r=c.create(),n=o();return function(){function t(){this._key=o()}return t.prototype.has=function(t){var e=i(t,!1);return void 0!==e&&c.has(e,this._key)},t.prototype.get=function(t){var e=i(t,!1);return void 0!==e?c.get(e,this._key):void 0},t.prototype.set=function(t,e){return i(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=i(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=o()},t}();function o(){var t;do{t="@@WeakMap@@"+u()}while(c.has(r,t));return r[t]=!0,t}function i(t,r){if(!e.call(t,n)){if(!r)return;Object.defineProperty(t,n,{value:c.create()})}return t[n]}function s(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function a(t){return"function"==typeof Uint8Array?"undefined"!=typeof crypto?crypto.getRandomValues(new Uint8Array(t)):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(new Uint8Array(t)):s(new Uint8Array(t),t):s(new Array(t),t)}function u(){var e=a(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var r="",n=0;n<t;++n){var o=e[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function nt(t){return t.__=void 0,delete t.__,t}t("decorate",y),t("metadata",d),t("defineMetadata",g),t("hasMetadata",w),t("hasOwnMetadata",v),t("getMetadata",m),t("getOwnMetadata",S),t("getMetadataKeys",A),t("getOwnMetadataKeys",C),t("deleteMetadata",b)}(o)}()}(e||(e={}));class n{static isArrayBuffer(t){return"[object ArrayBuffer]"===Object.prototype.toString.call(t)}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t).slice().buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){const r=n.toUint8Array(t),o=n.toUint8Array(e);if(r.length!==o.byteLength)return!1;for(let t=0;t<r.length;t++)if(r[t]!==o[t])return!1;return!0}static concat(...t){if(Array.isArray(t[0])){const e=t[0];let r=0;for(const t of e)r+=t.byteLength;const n=new Uint8Array(r);let o=0;for(const t of e){const e=this.toUint8Array(t);n.set(e,o),o+=e.length}return t[1]?this.toView(n,t[1]):n.buffer}return this.concat(t)}}class o{static fromString(t){const e=unescape(encodeURIComponent(t)),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r.buffer}static toString(t){const e=n.toUint8Array(t);let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return decodeURIComponent(escape(r))}}class i{static toString(t,e=!1){const r=n.toArrayBuffer(t),o=new DataView(r);let i="";for(let t=0;t<r.byteLength;t+=2){const r=o.getUint16(t,e);i+=String.fromCharCode(r)}return i}static fromString(t,e=!1){const r=new ArrayBuffer(2*t.length),n=new DataView(r);for(let r=0;r<t.length;r++)n.setUint16(2*r,t.charCodeAt(r),e);return r}}class s{static isHex(t){return"string"==typeof t&&/^[a-z0-9]+$/i.test(t)}static isBase64(t){return"string"==typeof t&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}static isBase64Url(t){return"string"==typeof t&&/^[a-zA-Z0-9-_]+$/i.test(t)}static ToString(t,e="utf8"){const r=n.toUint8Array(t);switch(e.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return i.toString(r,!0);case"utf16":case"utf16be":return i.toString(r);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return i.fromString(t,!0);case"utf16":case"utf16be":return i.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){const e=n.toUint8Array(t);if("undefined"!=typeof btoa){const t=this.ToString(e,"binary");return btoa(t)}return Buffer.from(e).toString("base64")}static FromBase64(t){const e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!s.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return"undefined"!=typeof atob?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){const e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!s.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=s.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return o.fromString(t);case"utf16":case"utf16be":return i.fromString(t);case"utf16le":case"usc2":return i.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=s.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return o.toString(t);case"utf16":case"utf16be":return i.toString(t);case"utf16le":case"usc2":return i.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){const e=t.length,r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=t.charCodeAt(n);return r.buffer}static ToBinary(t){const e=n.toUint8Array(t);let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return r}static ToHex(t){const e=n.toUint8Array(t),r=[],o=e.length;for(let t=0;t<o;t++){const n=e[t].toString(16).padStart(2,"0");r.push(n)}return r.join("")}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!s.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);const r=new Uint8Array(e.length/2);for(let t=0;t<e.length;t+=2){const n=e.slice(t,t+2);r[t/2]=parseInt(n,16)}return r.buffer}static ToUtf16String(t,e=!1){return i.toString(t,e)}static FromUtf16String(t,e=!1){return i.fromString(t,e)}static Base64Padding(t){const e=4-t.length%4;if(e<4)for(let r=0;r<e;r++)t+="=";return t}static formatString(t){return(null==t?void 0:t.replace(/[\n\r\t ]/g,""))||""}}var a,c,u,h;s.DEFAULT_UTF8_ENCODING="utf8",function(t){t[t.ok=200]="ok",t[t.created=201]="created",t[t.noContent=204]="noContent",t[t.unauthorized=401]="unauthorized",t[t.badRequest=400]="badRequest",t[t.forbidden=403]="forbidden",t[t.notFound=404]="notFound",t[t.methodNotAllowed=405]="methodNotAllowed",t[t.internalServerError=500]="internalServerError"}(a||(a={}));class f extends Error{constructor(t,e="",r=a.internalServerError,n){super(e),this.type=t,this.message=e,this.status=r,this.inner=n,this.name="AcmeError"}}!function(t){t.json="application/json",t.joseJson="application/jose+json",t.problemJson="application/problem+json",t.pkix="application/pkix-cert",t.pem="application/pem-certificate-chain",t.pkcs7="application/pkcs7-mime"}(c||(c={}));class l{constructor(t,e){var r;if(this.content=new ArrayBuffer(0),"string"==typeof t)this.content=s.FromUtf8String(t),this.type=c.pem;else if(t instanceof f)this.content=s.FromUtf8String(JSON.stringify({detail:t.message,type:t.type,subproblems:null===(r=t.subproblems)||void 0===r?void 0:r.map((t=>({detail:t.message,type:t.type})))})),this.type=c.problemJson;else if(n.isBufferSource(t)){if(!e)throw new TypeError("Cannot get required argument 'type'");this.content=n.toArrayBuffer(t),this.type=e}else{const r=e?JSON.stringify(t,null," "):JSON.stringify(t);this.content=s.FromUtf8String(r),this.type=c.json}}toJSON(){return JSON.parse(this.toString())}toString(){return s.ToUtf8String(this.content)}}class p extends Map{get location(){return this.get(p.LOCATION)||null}set location(t){t?this.set(p.LOCATION,t):this.delete(p.LOCATION)}get contentType(){var t,e;const r=this.get(p.CONTENT_TYPE);return r?{mediaType:r.split(";")[0],charset:null===(t=/charset=([\w-]+)/i.exec(r))||void 0===t?void 0:t[1],boundary:null===(e=/boundary=([\w-]+)/i.exec(r))||void 0===e?void 0:e[1]}:null}get link(){const t=this.get(p.LINK);return t?t.split(",").map((t=>t.trim())):null}setLink(t){let e=this.get(p.LINK);e?e+=`,${t}`:e=t,this.set(p.LINK,e)}get cacheControl(){return this.get(p.CACHE_CONTROL)||null}set cacheControl(t){t?this.set(p.CACHE_CONTROL,t):this.delete(p.CACHE_CONTROL)}get replayNonce(){return this.get(p.REPLAY_NONCE)||null}set replayNonce(t){t?this.set(p.REPLAY_NONCE,t):this.delete(p.REPLAY_NONCE)}set(t,e){return super.set(t.toLowerCase(),e)}get(t){return super.get(t.toLowerCase())}append(t,e){const r=this.get(t);e?this.set(t,`${r}, ${e}`):this.set(t,e)}}p.REPLAY_NONCE="Replay-Nonce",p.LINK="Link",p.CONTENT_TYPE="Content-Type",p.LOCATION="Location",p.CACHE_CONTROL="Cache-Control";class y{constructor(){this.status=a.ok,this.headers=new p}json(){if(this.content)return this.content.toJSON();throw new Error("No content in ACME response")}}function d(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}!function(t){t.accountDoesNotExist="urn:ietf:params:acme:error:accountDoesNotExist",t.alreadyRevoked="urn:ietf:params:acme:error:alreadyRevoked",t.badCSR="urn:ietf:params:acme:error:badCSR",t.badNonce="urn:ietf:params:acme:error:badNonce",t.badPublicKey="urn:ietf:params:acme:error:badPublicKey",t.badRevocationReason="urn:ietf:params:acme:error:badRevocationReason",t.badSignatureAlgorithm="urn:ietf:params:acme:error:badSignatureAlgorithm",t.caa="urn:ietf:params:acme:error:caa",t.compound="urn:ietf:params:acme:error:compound",t.connection="urn:ietf:params:acme:error:connection",t.dns="urn:ietf:params:acme:error:dns",t.externalAccountRequired="urn:ietf:params:acme:error:externalAccountRequired",t.incorrectResponse="urn:ietf:params:acme:error:incorrectResponse",t.invalidContact="urn:ietf:params:acme:error:invalidContact",t.malformed="urn:ietf:params:acme:error:malformed",t.orderNotReady="urn:ietf:params:acme:error:orderNotReady",t.rateLimited="urn:ietf:params:acme:error:rateLimited",t.rejectedIdentifier="urn:ietf:params:acme:error:rejectedIdentifier",t.serverInternal="urn:ietf:params:acme:error:serverInternal",t.tls="urn:ietf:params:acme:error:tls",t.unauthorized="urn:ietf:params:acme:error:unauthorized",t.unsupportedContact="urn:ietf:params:acme:error:UnsupportedContact",t.unsupportedIdentifier="urn:ietf:params:acme:error:unsupportedIdentifier",t.userActionRequired="urn:ietf:params:acme:error:userActionRequired"}(u||(u={})),function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"}(h||(h={}));var g=h,w=function(t,e){return(w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function v(t,e){function r(){this.constructor=t}w(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function m(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))}function S(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function A(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function C(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function b(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(C(arguments[e]));return t}function E(t){return!!t.useClass}function _(t){return!!t.useFactory}var R=function(){function t(t){this.wrap=t,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return t.prototype.createProxy=function(t){var e,r=this,n=!1;return new Proxy({},this.createHandler((function(){return n||(e=t(r.wrap()),n=!0),e})))},t.prototype.createHandler=function(t){var e={};return this.reflectMethods.forEach((function(r){e[r]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e[0]=t();var o=Reflect[r];return o.apply(void 0,b(e))}})),e},t}();function k(t){return"string"==typeof t||"symbol"==typeof t}function T(t){return"object"==typeof t&&"token"in t&&"transform"in t}function P(t){return!!t.useToken}function O(t){return null!=t.useValue}var K=function(){function t(){this._registryMap=new Map}return t.prototype.entries=function(){return this._registryMap.entries()},t.prototype.getAll=function(t){return this.ensure(t),this._registryMap.get(t)},t.prototype.get=function(t){this.ensure(t);var e=this._registryMap.get(t);return e[e.length-1]||null},t.prototype.set=function(t,e){this.ensure(t),this._registryMap.get(t).push(e)},t.prototype.setAll=function(t,e){this._registryMap.set(t,e)},t.prototype.has=function(t){return this.ensure(t),this._registryMap.get(t).length>0},t.prototype.clear=function(){this._registryMap.clear()},t.prototype.ensure=function(t){this._registryMap.has(t)||this._registryMap.set(t,[])},t}(),H=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(K),N=function(){this.scopedResolutions=new Map};function x(t,e,r){var n,o,i=C(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2)[1],s=function(t,e){return null===t?"at position #"+e:'"'+t.split(",")[e].trim()+'" at position #'+e}(void 0===i?null:i,e);return n="Cannot inject the dependency "+s+' of "'+t.name+'" constructor. Reason:',void 0===o&&(o=" "),b([n],r.message.split("\n").map((function(t){return o+t}))).join("\n")}var j,B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(K),U=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(K),I=function(){this.preResolution=new B,this.postResolution=new U},M=new Map,L=new(function(){function t(t){this.parent=t,this._registry=new H,this.interceptors=new I,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(t,e,r){var n;if(void 0===r&&(r={lifecycle:g.Transient}),this.ensureNotDisposed(),n=function(t){return E(t)||O(t)||P(t)||_(t)}(e)?e:{useClass:e},P(n))for(var o=[t],i=n;null!=i;){var s=i.useToken;if(o.includes(s))throw new Error("Token registration cycle detected! "+b(o,[s]).join(" -> "));o.push(s);var a=this._registry.get(s);i=a&&P(a.provider)?a.provider:null}if((r.lifecycle===g.Singleton||r.lifecycle==g.ContainerScoped||r.lifecycle==g.ResolutionScoped)&&(O(n)||_(n)))throw new Error('Cannot use lifecycle "'+g[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(t,{provider:n,options:r}),this},t.prototype.registerType=function(t,e){return this.ensureNotDisposed(),k(e)?this.register(t,{useToken:e}):this.register(t,{useClass:e})},t.prototype.registerInstance=function(t,e){return this.ensureNotDisposed(),this.register(t,{useValue:e})},t.prototype.registerSingleton=function(t,e){if(this.ensureNotDisposed(),k(t)){if(k(e))return this.register(t,{useToken:e},{lifecycle:g.Singleton});if(e)return this.register(t,{useClass:e},{lifecycle:g.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=t;return e&&!k(e)&&(r=e),this.register(t,{useClass:r},{lifecycle:g.Singleton})},t.prototype.resolve=function(t,e){void 0===e&&(e=new N),this.ensureNotDisposed();var r=this.getRegistration(t);if(!r&&k(t))throw new Error('Attempted to resolve unregistered dependency token: "'+t.toString()+'"');if(this.executePreResolutionInterceptor(t,"Single"),r){var n=this.resolveRegistration(r,e);return this.executePostResolutionInterceptor(t,n,"Single"),n}if(function(t){return"function"==typeof t||t instanceof R}(t)){n=this.construct(t,e);return this.executePostResolutionInterceptor(t,n,"Single"),n}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},t.prototype.executePreResolutionInterceptor=function(t,e){var r,n;if(this.interceptors.preResolution.has(t)){var o=[];try{for(var i=A(this.interceptors.preResolution.getAll(t)),s=i.next();!s.done;s=i.next()){var a=s.value;"Once"!=a.options.frequency&&o.push(a),a.callback(t,e)}}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(t,o)}},t.prototype.executePostResolutionInterceptor=function(t,e,r){var n,o;if(this.interceptors.postResolution.has(t)){var i=[];try{for(var s=A(this.interceptors.postResolution.getAll(t)),a=s.next();!a.done;a=s.next()){var c=a.value;"Once"!=c.options.frequency&&i.push(c),c.callback(t,e,r)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}this.interceptors.postResolution.setAll(t,i)}},t.prototype.resolveRegistration=function(t,e){if(this.ensureNotDisposed(),t.options.lifecycle===g.ResolutionScoped&&e.scopedResolutions.has(t))return e.scopedResolutions.get(t);var r,n=t.options.lifecycle===g.Singleton,o=t.options.lifecycle===g.ContainerScoped,i=n||o;return r=O(t.provider)?t.provider.useValue:P(t.provider)?i?t.instance||(t.instance=this.resolve(t.provider.useToken,e)):this.resolve(t.provider.useToken,e):E(t.provider)?i?t.instance||(t.instance=this.construct(t.provider.useClass,e)):this.construct(t.provider.useClass,e):_(t.provider)?t.provider.useFactory(this):this.construct(t.provider,e),t.options.lifecycle===g.ResolutionScoped&&e.scopedResolutions.set(t,r),r},t.prototype.resolveAll=function(t,e){var r=this;void 0===e&&(e=new N),this.ensureNotDisposed();var n=this.getAllRegistrations(t);if(!n&&k(t))throw new Error('Attempted to resolve unregistered dependency token: "'+t.toString()+'"');if(this.executePreResolutionInterceptor(t,"All"),n){var o=n.map((function(t){return r.resolveRegistration(t,e)}));return this.executePostResolutionInterceptor(t,o,"All"),o}var i=[this.construct(t,e)];return this.executePostResolutionInterceptor(t,i,"All"),i},t.prototype.isRegistered=function(t,e){return void 0===e&&(e=!1),this.ensureNotDisposed(),this._registry.has(t)||e&&(this.parent||!1)&&this.parent.isRegistered(t,!0)},t.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var t,e;this.ensureNotDisposed();try{for(var r=A(this._registry.entries()),n=r.next();!n.done;n=r.next()){var o=C(n.value,2),i=o[0],s=o[1];this._registry.setAll(i,s.filter((function(t){return!O(t.provider)})).map((function(t){return t.instance=void 0,t})))}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}},t.prototype.createChildContainer=function(){var e,r;this.ensureNotDisposed();var n=new t(this);try{for(var o=A(this._registry.entries()),i=o.next();!i.done;i=o.next()){var s=C(i.value,2),a=s[0],c=s[1];c.some((function(t){return t.options.lifecycle===g.ContainerScoped}))&&n._registry.setAll(a,c.map((function(t){return t.options.lifecycle===g.ContainerScoped?{provider:t.provider,options:t.options}:t})))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return n},t.prototype.beforeResolution=function(t,e,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.preResolution.set(t,{callback:e,options:r})},t.prototype.afterResolution=function(t,e,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.postResolution.set(t,{callback:e,options:r})},t.prototype.dispose=function(){return m(this,void 0,void 0,(function(){var t;return S(this,(function(e){switch(e.label){case 0:return this.disposed=!0,t=[],this.disposables.forEach((function(e){var r=e.dispose();r&&t.push(r)})),[4,Promise.all(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getRegistration=function(t){return this.isRegistered(t)?this._registry.get(t):this.parent?this.parent.getRegistration(t):null},t.prototype.getAllRegistrations=function(t){return this.isRegistered(t)?this._registry.getAll(t):this.parent?this.parent.getAllRegistrations(t):null},t.prototype.construct=function(t,e){var r=this;if(t instanceof R)return t.createProxy((function(t){return r.resolve(t,e)}));var n,o=function(){var n=M.get(t);if(!n||0===n.length){if(0===t.length)return new t;throw new Error('TypeInfo not known for "'+t.name+'"')}var o=n.map(r.resolveParams(e,t));return new(t.bind.apply(t,b([void 0],o)))}();return"function"!=typeof(n=o).dispose||n.dispose.length>0||this.disposables.add(o),o},t.prototype.resolveParams=function(t,e){var r=this;return function(n,o){var i,s,a,c;try{return"object"==typeof(c=n)&&"token"in c&&"multiple"in c?T(n)?n.multiple?(i=r.resolve(n.transform)).transform.apply(i,b([r.resolveAll(n.token)],n.transformArgs)):(s=r.resolve(n.transform)).transform.apply(s,b([r.resolve(n.token,t)],n.transformArgs)):n.multiple?r.resolveAll(n.token):r.resolve(n.token,t):T(n)?(a=r.resolve(n.transform,t)).transform.apply(a,b([r.resolve(n.token,t)],n.transformArgs)):r.resolve(n,t)}catch(t){throw new Error(x(e,o,t))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}());if("undefined"==typeof Reflect||!Reflect.getMetadata)throw new Error("tsyringe requires a reflect polyfill. Please add 'import \"reflect-metadata\"' to the top of your entry point.");!function(t){t[t.error=0]="error",t[t.warn=1]="warn",t[t.info=2]="info",t[t.debug=3]="debug"}(j||(j={}));let D=class t{constructor(){this.level=j.info}error(t,e){this.write(j.error,t,e)}info(t,e){this.write(j.info,t,e)}warn(t,e){this.write(j.warn,t,e)}debug(t,e){this.write(j.debug,t,e)}write(t,e,r){if(this.checkLevel(t)){const n={level:j[t],timestamp:new Date,class:this.caller()};this.onWrite(n,e,r)}}onWrite(t,e,r){}checkLevel(t){return this.level>=t}caller(){try{throw new Error}catch(t){if(t instanceof Error){const e=/at ([a-zA-Z0-9_.]+) \(/gm,r=t.stack;if(r){let t=null,n=3;for(;t=e.exec(r);)if(!n--)return t[1].split(".")[0]}}return"undefined"}}};D=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}([function(t){M.set(t,function(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],r=Reflect.getOwnMetadata("injectionTokens",t)||{};return Object.keys(r).forEach((function(t){e[+t]=r[t]})),e}(t))}],D),L.register("ACME.Logger",D,{lifecycle:g.Singleton});class F{static toAlgorithm(t){switch(t){case"ES256":return{name:"ECDSA",hash:{name:"SHA-256"}};case"ES384":return{name:"ECDSA",hash:{name:"SHA-384"}};case"ES512":return{name:"ECDSA",hash:{name:"SHA-512"}};case"HS1":return{name:"HMAC",hash:{name:"SHA-1"}};case"HS256":return{name:"HMAC",hash:{name:"SHA-256"}};case"HS384":return{name:"HMAC",hash:{name:"SHA-384"}};case"HS512":return{name:"HMAC",hash:{name:"SHA-512"}};case"PS1":return{name:"RSA-PSS",hash:{name:"SHA-1"}};case"PS256":return{name:"RSA-PSS",hash:{name:"SHA-256"}};case"PS384":return{name:"RSA-PSS",hash:{name:"SHA-384"}};case"PS512":return{name:"RSA-PSS",hash:{name:"SHA-512"}};case"RS1":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"RS384":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case"RS512":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}}}return null}static fromAlgorithm(t){const e="string"==typeof t?{name:t}:t,r=e.name.toLowerCase(),n=e.hash?("string"==typeof e.hash?e.hash:e.hash.name).toLowerCase():"sha-256";switch(r){case"hmac":switch(n){case"sha-1":return"HS1";case"sha-256":return"HS256";case"sha-384":return"HS384";case"sha-512":return"HS512"}break;case"rsassa-pkcs1-v1_5":switch(n){case"sha-1":return"RS1";case"sha-256":return"RS256";case"sha-R84":return"RS384";case"sha-512":return"RS512"}break;case"rsa-pss":switch(n){case"sha-1":return"PS1";case"sha-256":return"PS256";case"sha-P84":return"PS384";case"sha-512":return"PS512"}break;case"ecdsa":switch(n){case"sha-256":return"ES256";case"sha-384":return"ES384";case"sha-512":return"ES512"}}return null}}var W,G,J,z;!function(t){t.hs256="HS256",t.hs384="HS384",t.hs512="HS512",t.RS256="RS256",t.RS384="RS384",t.RS512="RS512",t.ES256="ES256",t.ES384="ES384",t.ES512="ES512",t.PS1="PS1",t.PS256="PS256",t.PS384="PS384",t.PS512="PS512",t.RSA1_5="RSA1_5",t.RSA_OAEP="RSA-OAEP",t.RSA_OAEP_256="RSA-OAEP-256",t.A128KW="A128KW",t.A192KW="A192KW",t.A256KW="A256KW",t.Dir="dir",t.ECDH_ES="ECDH-ES",t.ECDH_ES_A128KW="ECDH-ES+A128KW",t.ECDH_ES_A192KW="ECDH-ES+A192KW",t.ECDH_ES_A256KW="ECDH-ES+A256KW",t.A128GCMKW="A128GCMKW",t.A192GCMKW="A192GCMKW",t.A256GCMKW="A256GCMKW",t.PBES2_HS256_A128KW="PBES2-HS256+A128KW",t.PBES2_HS384_A192KW="PBES2-HS384+A192KW",t.PBES2_HS512_A256KW="PBES2-HS512+A256KW",t.A128CBC_HS256="A128CBC-HS256",t.A192CBC_HS384="A192CBC-HS384",t.A256CBC_HS512="A256CBC-HS512",t.A128GCM="A128GCM",t.A192GCM="A192GCM",t.A256GCM="A256GCM",t.EdDSA="EdDSA",t.RS1="RS1",t.RSA_OAEP_384="RSA-OAEP-384",t.RSA_OAEP_512="RSA-OAEP-512",t.A128CBC="A128CBC",t.A192CBC="A192CBC",t.A256CBC="A256CBC",t.A128CTR="A128CTR",t.A192CTR="A192CTR",t.A256CTR="A256CTR",t.HS1="HS1",t.SHA1="SHA1",t.SHA256="SHA256"}(W||(W={})),function(t){t.EC="EC",t.RSA="RSA",t.OctetSequence="oct",t.OctetStringKeyPairs="OKP"}(G||(G={}));class ${constructor(t,e={}){J.set(this,void 0),Object.assign(this,e),function(t,e,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?o.call(t,r):o?o.value=r:e.set(t,r)}(this,J,t,"f")}async exportKey(...t){let e,r=["verify"],n=d(this,J,"f");if(arguments.length<2)switch(n=t[0]||n,this.kty){case G.RSA:e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"};break;case G.EC:e={name:"ECDSA",namedCurve:this.crv};break;case G.OctetSequence:e={name:"HMAC",hash:"SHA-256"};break;default:throw new Error("Unsupported type of JWK")}else e=t[0],r=t[1],n=t[2]||n;return await n.subtle.importKey("jwk",this,e,!0,r)}async getThumbprint(t=W.SHA256){const e={};this.crv&&(e.crv=this.crv.toString()),this.e&&(e.e=this.e),this.k&&(e.k=this.k),this.kty&&(e.kty=this.kty.toString()),this.n&&(e.n=this.n),this.x&&(e.x=this.x),this.y&&(e.y=this.y);const r=JSON.stringify(e);switch(t){case W.SHA256:return s.ToHex(await this.digest(r,"SHA-256"));case W.SHA1:return s.ToHex(await this.digest(r,"SHA-1"));default:throw new Error(`Unsupported algorithm: ${t}`)}}async digest(t,e){return await d(this,J,"f").subtle.digest({name:e},n.toUint8Array(s.FromUtf8String(t)))}async getPublicKey(){if(this.kty===G.EC)return this.getEcdsaPublicKey();if(this.kty===G.RSA)return this.getRsaPublicKey();throw new Error(`Unsupported type ${this.kty}`)}async getEcdsaPublicKey(){const t={name:"ECDSA",namedCurve:this.crv};return await d(this,J,"f").subtle.importKey("jwk",this,t,!0,["verify"])}async getRsaPublicKey(){return await d(this,J,"f").subtle.importKey("jwk",this,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}}J=new WeakMap;class V{constructor(t={},e){this.cryptoProvider=e,this.protected="e30",this.payload="",this.signature="",t.protected&&this.setProtected(t.protected),void 0!==t.payload&&this.setPayload(t.payload)}fromJSON(t){Object.assign(this,t)}isPayloadEmpty(){return!this.payload}isPayloadEmptyObject(){return"e30"===this.payload}getProtected(t){const e=this.read(this.protected);return e.jwk&&(e.jwk=new $(this.getCryptoProvider(t),e.jwk)),e}setProtected(t){this.protected=this.write(t)}getPayload(){return this.read(this.payload)}tryGetPayload(){try{return this.getPayload()}catch(t){return null}}setPayload(t){this.payload=""===t?"":this.write(t)}getSignature(){return s.FromBase64Url(this.signature)}setSignature(t){this.signature=s.ToBase64Url(t)}read(t){const e=s.FromBase64Url(t),r=s.ToUtf8String(e);return""===r?"":JSON.parse(r)}write(t){const e=JSON.stringify(t),r=s.FromUtf8String(e);return s.ToBase64Url(r)}async verify(t,e){const r=this.getProtected();if(!r.alg)throw new Error("JWS.protected doesn't have required parameter 'alg'");const n=F.toAlgorithm(r.alg);if(!n)throw new Error("Cannot convert JWA to WebCrypto algorithm");if(!t){const r=await this.getKey(e);if(!r)throw new Error("Cannot get JWK key");t=r}const o=s.FromUtf8String(this.toStringSign());return await this.getCryptoProvider(e).subtle.verify(n,t,this.getSignature(),o)}async getKey(t){const e=this.getProtected();if(!e.jwk)return null;if(!e.alg)throw new Error("JWS.protected doesn't have required parameter 'alg'");const r=F.toAlgorithm(e.alg);if(!r)throw new Error("Cannot convert JWA to WebCrypto algorithm");const n={...r};"ECDSA"===n.name&&(n.namedCurve=e.jwk.crv);return await this.getCryptoProvider(t).subtle.importKey("jwk",e.jwk,n,!0,["verify"])}async sign(t,e,r){const n=this.getProtected(),o=F.fromAlgorithm({...t,...e.algorithm});if(!o)throw new Error("Cannot convert WebCrypto algorithm to JWA");n.alg=o,this.setProtected(n);const i=s.FromUtf8String(this.toStringSign()),a=await this.getCryptoProvider(r).subtle.sign(t,e,i);this.setSignature(a)}toStringSign(){return`${this.protected}.${this.payload}`}toJSON(){const t={};return this.protected&&(t.protected=this.protected),void 0!==this.payload&&(t.payload=this.payload),this.signature&&(t.signature=this.signature),t}parse(t){if("{"===t[0]){const e=JSON.parse(t);this.protected=e.protected||"",this.payload=e.payload||"",this.signature=e.signature||""}else{const e=t.split(".");this.protected=e[0]||"",this.payload=e[1]||"",this.signature=e[2]||""}}toString(t=!1){return t?`${this.protected}.${this.payload}.${this.signature}`:JSON.stringify(this.toJSON())}getCryptoProvider(t){if(t)return t;if(this.cryptoProvider)return this.cryptoProvider;throw new Error("Cannot find Crypto")}}class q{constructor(t={}){if(this.options={crypto:"undefined"!=typeof self?self.crypto:void 0,debug:t.debug,defaultHash:"SHA-256",fetch:"undefined"!=typeof fetch?fetch:void 0,...t},!this.options.crypto)throw new Error("Cannot initialize ACME client. It requires crypto provider to be set.")}static createResponse(t,e){return{status:t.status,headers:t.headers,content:e}}async fetch(t,e){var r,n;if(!this.options.fetch)throw new Error("Cannot get 'fetch' option");this.options.debug&&(console.log(`REQUEST ${e.method} ${t}`),"body"in e&&console.log("REQUEST BODY",e.body));const o=this.options.fetch;let i;if("GET"===e.method||"HEAD"===e.method)i=await o(t,{method:e.method,headers:e.headers||{}});else{const r=this.getCrypto(),n=e,s={method:"POST"},a={url:t,nonce:n.nonce};if("string"==typeof n.kid)a.kid=n.kid;else{const t=await this.getCrypto().subtle.exportKey("jwk",n.kid);a.jwk=new $(r,t)}const u=new V({protected:a,payload:n.method&&"POST-as-GET"!==n.method?n.body:""},this.getCrypto());await u.sign({hash:n.hash||this.options.defaultHash,...n.key.algorithm},n.key,r),s.body=u.toString(),s.headers={"Content-Type":c.joseJson},i=await o(t,s)}const s=new y;s.status=i.status,i.headers.forEach(((t,e)=>s.headers.set(e,t)));const a=await i.arrayBuffer();if(s.content=new l(a,(null===(r=s.headers.contentType)||void 0===r?void 0:r.mediaType)||c.json),this.options.debug&&console.log(`RESPONSE ${e.method} ${t}`),s.content&&(s.status<200||s.status>299)){if((null===(n=s.headers.contentType)||void 0===n?void 0:n.mediaType)===c.problemJson){const t=s.content.toJSON();throw this.options.debug&&console.log("RESPONSE",t),new f(t.type,t.detail,s.status)}{const t=s.content.toString();throw this.options.debug&&console.log("RESPONSE",t),new f(u.serverInternal,"Wrong Content-Type of ACME response. Must be application/problem+json. See inner exception for more details.",s.status,new globalThis.Error(t))}}const h=q.createResponse(s,e.convert(s));return this.options.debug&&console.log("RESPONSE",h),h}getCrypto(){if(!this.options.crypto)throw new Error("Cannot get 'crypto' option");return this.options.crypto}}t.CRLReasons=void 0,(z=t.CRLReasons||(t.CRLReasons={}))[z.unspecified=0]="unspecified",z[z.keyCompromise=1]="keyCompromise",z[z.cACompromise=2]="cACompromise",z[z.affiliationChanged=3]="affiliationChanged",z[z.superseded=4]="superseded",z[z.cessationOfOperation=5]="cessationOfOperation",z[z.certificateHold=6]="certificateHold",z[z.removeFromCRL=8]="removeFromCRL",z[z.privilegeWithdrawn=9]="privilegeWithdrawn",z[z.aACompromise=10]="aACompromise";class Y extends q{constructor(t,e,r){super(r),this.accountKey=t,this.url=e,this.nonce="",this.accountId=""}static async create(t,e,r){const n=new this(t,e,r);return n.directory=await n.getDirectory(),n}async fetch(t,e){"POST"!==e.method&&"POST-as-GET"!==e.method||(this.nonce||await this.getNonce(),e.nonce=this.nonce,this.nonce="");try{const r=await super.fetch(t,e);return this.readNonce(r),r}catch(r){if(r instanceof f&&r.type===u.badNonce)return this.fetch(t,e);throw r}}async getDirectory(){return(await this.fetch(this.url,{method:"GET",convert:t=>t.json()})).content}async getNonce(t="HEAD"){const e=await this.fetch(this.directory.newNonce,{method:t,convert:()=>null});return this.readNonce(e)}async newAccount(t){const e={};t.contact&&(e.contact=t.contact),void 0!==t.onlyReturnExisting&&(e.onlyReturnExisting=t.onlyReturnExisting),void 0!==t.termsOfServiceAgreed&&(e.termsOfServiceAgreed=t.termsOfServiceAgreed),t.externalAccountBinding&&(e.externalAccountBinding=await this.createExternalAccountBinding(t.externalAccountBinding.challenge,t.externalAccountBinding.kid));const r=await this.fetch(this.directory.newAccount,{method:"POST",kid:this.accountKey.publicKey,nonce:this.nonce,key:this.accountKey.privateKey,body:e,convert:t=>t.json()});if(!r.headers.location)throw new Error("Cannot get Location header");return this.accountId=r.headers.location,r}async updateAccount(t){const e=this.getAccountId();return await this.fetch(e,{method:"POST",kid:e,nonce:this.nonce,key:this.accountKey.privateKey,body:t,convert:t=>t.json()})}getAccountId(){if(!this.accountId)throw new Error("Create or Find account first");return this.accountId}async deactivateAccount(){return this.deactivate(this.getAccountId(),(t=>t.json()))}async changeKey(t){const e=this.getAccountId(),r=this.getCrypto(),n=new V({protected:{url:this.directory.keyChange,jwk:new $(r,await r.subtle.exportKey("jwk",t.publicKey))},payload:{account:e,oldKey:new $(r,await r.subtle.exportKey("jwk",this.accountKey.publicKey))}},this.getCrypto());await n.sign({hash:this.options.defaultHash,...t.privateKey.algorithm},t.privateKey);const o=await this.fetch(this.directory.keyChange,{method:"POST",kid:e,nonce:this.nonce,key:this.accountKey.privateKey,body:n,convert:()=>null});return this.accountKey=t,o}async newOrder(t){return this.fetch(this.directory.newOrder,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:t,convert:t=>t.json()})}async getOrder(t){return this.fetch(t,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()})}async retryOrder(t,e={}){let r="string"==typeof t?await this.getOrder(t):t,n=e.retries||Y.RETRIES;for(;n--;){if(!r.headers.location)throw new Error("Cannot get location header from Order response");if(r=await this.getOrder(r.headers.location),"processing"!==r.content.status)break;await this.pause(e.interval||Y.INTERVAL)}return r}async revoke(e,r=t.CRLReasons.unspecified){return await this.fetch(this.directory.revokeCert,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:{certificate:s.ToBase64Url(e),reason:r},convert:()=>null})}async deactivate(t,e){return this.fetch(t,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:{status:"deactivated"},convert:e})}async deactivateAuthorization(t){return this.deactivate(t,(t=>t.json()))}async getChallenge(t,e="POST-as-GET"){if("string"==typeof e){return await this.fetch(t,{method:e,kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:"POST"===e?{}:void 0,convert:t=>t.json()})}if(e){return await this.fetch(t,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:e,convert:t=>t.json()})}return await this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()})}async finalize(t,e){return this.fetch(t,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:e,convert:t=>t.json()})}async getAuthorization(t){return this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()})}async newAuthorization(t){if(!this.directory.newAuthz)throw new Error("ACME service doesn't support new-authz controller");return this.fetch(this.directory.newAuthz,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:t,convert:t=>t.json()})}async retryAuthorization(t,e={}){let r="string"==typeof t?await this.getOrder(t):t,n=e.retries||Y.RETRIES;for(;n--;){if(!r.headers.location)throw new Error("Cannot get location header from Authorization response");if(r=await this.getAuthorization(r.headers.location),"pending"!==r.content.status)break;await this.pause(e.interval||Y.INTERVAL)}return r}async internalGetCertificate(t,e){const r=t=>{if(!t.content)throw new Error("Cannot get content from ACME response");switch(t.content.type){case c.pem:return this.decodePem(t.content.toString());case c.pkix:return[t.content.content];case c.pkcs7:throw new Error("Not implemented");default:throw new Error("Not supported content type for certificate")}};let n;switch(e){case"GET":n=await this.fetch(t,{method:e,convert:r});break;case"POST":default:n=await this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:r})}return n}async getCertificate(t){return this.internalGetCertificate(t,"POST")}async getCaCertificate(t){return this.internalGetCertificate(t,"GET")}async getEndpoint(t){let e;return e=this.accountId?await this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()}):await this.fetch(t,{method:"GET",convert:t=>t.json()}),e}readNonce(t){const e=t.headers.replayNonce;return this.nonce=e||"",e}async pause(t){return new Promise((e=>setTimeout(e,t)))}async createExternalAccountBinding(t,e){const r=await this.getCrypto().subtle.importKey("raw",s.FromBase64Url(t),{name:"HMAC",hash:"SHA-256"},!0,["sign"]),n=await this.getCrypto().subtle.exportKey("jwk",this.accountKey.publicKey),o=new V({protected:{kid:e},payload:n},this.getCrypto());return await o.sign(r.algorithm,r,this.getCrypto()),o.toJSON()}decodePem(t){const e=/-{5}BEGIN [A-Z0-9 ]+-{5}([a-zA-Z0-9=+/\n\r]+)-{5}END [A-Z0-9 ]+-{5}/g,r=[];let n=null;for(;n=e.exec(t);){const t=n[1].replace(/[\r\n]/g,"");r.push(s.FromBase64(t))}return r}}return Y.RETRIES=10,Y.INTERVAL=1e3,t.ApiClient=Y,t.BaseClient=q,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); | ||
var acme=function(t){"use strict";var e,r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(t){!function(e){var n="object"==typeof r?r:"object"==typeof self?self:"object"==typeof this?this:Function("return this;")(),o=i(t);function i(t,e){return function(r,n){"function"!=typeof t[r]&&Object.defineProperty(t,r,{configurable:!0,writable:!0,value:n}),e&&e(r,n)}}void 0===n.Reflect?n.Reflect=t:o=i(n.Reflect,o),function(t){var e=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,n=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",o=r&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",i="function"==typeof Object.create,s={__proto__:[]}instanceof Array,a=!i&&!s,c={create:i?function(){return nt(Object.create(null))}:s?function(){return nt({__proto__:null})}:function(){return nt({})},has:a?function(t,r){return e.call(t,r)}:function(t,e){return e in t},get:a?function(t,r){return e.call(t,r)?t[r]:void 0}:function(t,e){return t[e]}},u=Object.getPrototypeOf(Function),h="object"==typeof process&&process.env&&"true"===process.env.REFLECT_METADATA_USE_MAP_POLYFILL,f=h||"function"!=typeof Map||"function"!=typeof Map.prototype.entries?tt():Map,l=h||"function"!=typeof Set||"function"!=typeof Set.prototype.entries?et():Set,p=new(h||"function"!=typeof WeakMap?rt():WeakMap);function y(t,e,r,n){if(j(r)){if(!G(t))throw new TypeError;if(!z(e))throw new TypeError;return E(t,e)}if(!G(t))throw new TypeError;if(!I(e))throw new TypeError;if(!I(n)&&!j(n)&&!B(n))throw new TypeError;return B(n)&&(n=void 0),_(t,e,r=W(r),n)}function d(t,e){function r(r,n){if(!I(r))throw new TypeError;if(!j(n)&&!$(n))throw new TypeError;K(t,e,r,n)}return r}function g(t,e,r,n){if(!I(r))throw new TypeError;return j(n)||(n=W(n)),K(t,e,r,n)}function w(t,e,r){if(!I(e))throw new TypeError;return j(r)||(r=W(r)),k(t,e,r)}function v(t,e,r){if(!I(e))throw new TypeError;return j(r)||(r=W(r)),T(t,e,r)}function m(t,e,r){if(!I(e))throw new TypeError;return j(r)||(r=W(r)),P(t,e,r)}function S(t,e,r){if(!I(e))throw new TypeError;return j(r)||(r=W(r)),O(t,e,r)}function A(t,e){if(!I(t))throw new TypeError;return j(e)||(e=W(e)),H(t,e)}function C(t,e){if(!I(t))throw new TypeError;return j(e)||(e=W(e)),N(t,e)}function b(t,e,r){if(!I(e))throw new TypeError;j(r)||(r=W(r));var n=R(e,r,!1);if(j(n))return!1;if(!n.delete(t))return!1;if(n.size>0)return!0;var o=p.get(e);return o.delete(r),o.size>0||p.delete(e),!0}function E(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!j(n)&&!B(n)){if(!z(n))throw new TypeError;e=n}}return e}function _(t,e,r,n){for(var o=t.length-1;o>=0;--o){var i=(0,t[o])(e,r,n);if(!j(i)&&!B(i)){if(!I(i))throw new TypeError;n=i}}return n}function R(t,e,r){var n=p.get(t);if(j(n)){if(!r)return;n=new f,p.set(t,n)}var o=n.get(e);if(j(o)){if(!r)return;o=new f,n.set(e,o)}return o}function k(t,e,r){if(T(t,e,r))return!0;var n=X(e);return!B(n)&&k(t,n,r)}function T(t,e,r){var n=R(e,r,!1);return!j(n)&&D(n.has(t))}function P(t,e,r){if(T(t,e,r))return O(t,e,r);var n=X(e);return B(n)?void 0:P(t,n,r)}function O(t,e,r){var n=R(e,r,!1);if(!j(n))return n.get(t)}function K(t,e,r,n){R(r,n,!0).set(t,e)}function H(t,e){var r=N(t,e),n=X(t);if(null===n)return r;var o=H(n,e);if(o.length<=0)return r;if(r.length<=0)return o;for(var i=new l,s=[],a=0,c=r;a<c.length;a++){var u=c[a];i.has(u)||(i.add(u),s.push(u))}for(var h=0,f=o;h<f.length;h++){u=f[h];i.has(u)||(i.add(u),s.push(u))}return s}function N(t,e){var r=[],n=R(t,e,!1);if(j(n))return r;for(var o=q(n.keys()),i=0;;){var s=Z(o);if(!s)return r.length=i,r;var a=Y(s);try{r[i]=a}catch(t){try{Q(o)}finally{throw t}}i++}}function x(t){if(null===t)return 1;switch(typeof t){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===t?1:6;default:return 6}}function j(t){return void 0===t}function B(t){return null===t}function U(t){return"symbol"==typeof t}function I(t){return"object"==typeof t?null!==t:"function"==typeof t}function M(t,e){switch(x(t)){case 0:case 1:case 2:case 3:case 4:case 5:return t}var r=3===e?"string":5===e?"number":"default",o=V(t,n);if(void 0!==o){var i=o.call(t,r);if(I(i))throw new TypeError;return i}return L(t,"default"===r?"number":r)}function L(t,e){if("string"===e){var r=t.toString;if(J(r))if(!I(o=r.call(t)))return o;if(J(n=t.valueOf))if(!I(o=n.call(t)))return o}else{var n;if(J(n=t.valueOf))if(!I(o=n.call(t)))return o;var o,i=t.toString;if(J(i))if(!I(o=i.call(t)))return o}throw new TypeError}function D(t){return!!t}function F(t){return""+t}function W(t){var e=M(t,3);return U(e)?e:F(e)}function G(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function J(t){return"function"==typeof t}function z(t){return"function"==typeof t}function $(t){switch(x(t)){case 3:case 4:return!0;default:return!1}}function V(t,e){var r=t[e];if(null!=r){if(!J(r))throw new TypeError;return r}}function q(t){var e=V(t,o);if(!J(e))throw new TypeError;var r=e.call(t);if(!I(r))throw new TypeError;return r}function Y(t){return t.value}function Z(t){var e=t.next();return!e.done&&e}function Q(t){var e=t.return;e&&e.call(t)}function X(t){var e=Object.getPrototypeOf(t);if("function"!=typeof t||t===u)return e;if(e!==u)return e;var r=t.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return e;var o=n.constructor;return"function"!=typeof o||o===t?e:o}function tt(){var t={},e=[],r=function(){function t(t,e,r){this._index=0,this._keys=t,this._values=e,this._selector=r}return t.prototype["@@iterator"]=function(){return this},t.prototype[o]=function(){return this},t.prototype.next=function(){var t=this._index;if(t>=0&&t<this._keys.length){var r=this._selector(this._keys[t],this._values[t]);return t+1>=this._keys.length?(this._index=-1,this._keys=e,this._values=e):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},t.prototype.throw=function(t){throw this._index>=0&&(this._index=-1,this._keys=e,this._values=e),t},t.prototype.return=function(t){return this._index>=0&&(this._index=-1,this._keys=e,this._values=e),{value:t,done:!0}},t}();return function(){function e(){this._keys=[],this._values=[],this._cacheKey=t,this._cacheIndex=-2}return Object.defineProperty(e.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),e.prototype.has=function(t){return this._find(t,!1)>=0},e.prototype.get=function(t){var e=this._find(t,!1);return e>=0?this._values[e]:void 0},e.prototype.set=function(t,e){var r=this._find(t,!0);return this._values[r]=e,this},e.prototype.delete=function(e){var r=this._find(e,!1);if(r>=0){for(var n=this._keys.length,o=r+1;o<n;o++)this._keys[o-1]=this._keys[o],this._values[o-1]=this._values[o];return this._keys.length--,this._values.length--,e===this._cacheKey&&(this._cacheKey=t,this._cacheIndex=-2),!0}return!1},e.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=t,this._cacheIndex=-2},e.prototype.keys=function(){return new r(this._keys,this._values,n)},e.prototype.values=function(){return new r(this._keys,this._values,i)},e.prototype.entries=function(){return new r(this._keys,this._values,s)},e.prototype["@@iterator"]=function(){return this.entries()},e.prototype[o]=function(){return this.entries()},e.prototype._find=function(t,e){return this._cacheKey!==t&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=t)),this._cacheIndex<0&&e&&(this._cacheIndex=this._keys.length,this._keys.push(t),this._values.push(void 0)),this._cacheIndex},e}();function n(t,e){return t}function i(t,e){return e}function s(t,e){return[t,e]}}function et(){return function(){function t(){this._map=new f}return Object.defineProperty(t.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),t.prototype.has=function(t){return this._map.has(t)},t.prototype.add=function(t){return this._map.set(t,t),this},t.prototype.delete=function(t){return this._map.delete(t)},t.prototype.clear=function(){this._map.clear()},t.prototype.keys=function(){return this._map.keys()},t.prototype.values=function(){return this._map.values()},t.prototype.entries=function(){return this._map.entries()},t.prototype["@@iterator"]=function(){return this.keys()},t.prototype[o]=function(){return this.keys()},t}()}function rt(){var t=16,r=c.create(),n=o();return function(){function t(){this._key=o()}return t.prototype.has=function(t){var e=i(t,!1);return void 0!==e&&c.has(e,this._key)},t.prototype.get=function(t){var e=i(t,!1);return void 0!==e?c.get(e,this._key):void 0},t.prototype.set=function(t,e){return i(t,!0)[this._key]=e,this},t.prototype.delete=function(t){var e=i(t,!1);return void 0!==e&&delete e[this._key]},t.prototype.clear=function(){this._key=o()},t}();function o(){var t;do{t="@@WeakMap@@"+u()}while(c.has(r,t));return r[t]=!0,t}function i(t,r){if(!e.call(t,n)){if(!r)return;Object.defineProperty(t,n,{value:c.create()})}return t[n]}function s(t,e){for(var r=0;r<e;++r)t[r]=255*Math.random()|0;return t}function a(t){return"function"==typeof Uint8Array?"undefined"!=typeof crypto?crypto.getRandomValues(new Uint8Array(t)):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(new Uint8Array(t)):s(new Uint8Array(t),t):s(new Array(t),t)}function u(){var e=a(t);e[6]=79&e[6]|64,e[8]=191&e[8]|128;for(var r="",n=0;n<t;++n){var o=e[n];4!==n&&6!==n&&8!==n||(r+="-"),o<16&&(r+="0"),r+=o.toString(16).toLowerCase()}return r}}function nt(t){return t.__=void 0,delete t.__,t}t("decorate",y),t("metadata",d),t("defineMetadata",g),t("hasMetadata",w),t("hasOwnMetadata",v),t("getMetadata",m),t("getOwnMetadata",S),t("getMetadataKeys",A),t("getOwnMetadataKeys",C),t("deleteMetadata",b)}(o)}()}(e||(e={}));class n{static isArrayBuffer(t){return"[object ArrayBuffer]"===Object.prototype.toString.call(t)}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t).slice().buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){const r=n.toUint8Array(t),o=n.toUint8Array(e);if(r.length!==o.byteLength)return!1;for(let t=0;t<r.length;t++)if(r[t]!==o[t])return!1;return!0}static concat(...t){if(Array.isArray(t[0])){const e=t[0];let r=0;for(const t of e)r+=t.byteLength;const n=new Uint8Array(r);let o=0;for(const t of e){const e=this.toUint8Array(t);n.set(e,o),o+=e.length}return t[1]?this.toView(n,t[1]):n.buffer}return this.concat(t)}}class o{static fromString(t){const e=unescape(encodeURIComponent(t)),r=new Uint8Array(e.length);for(let t=0;t<e.length;t++)r[t]=e.charCodeAt(t);return r.buffer}static toString(t){const e=n.toUint8Array(t);let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return decodeURIComponent(escape(r))}}class i{static toString(t,e=!1){const r=n.toArrayBuffer(t),o=new DataView(r);let i="";for(let t=0;t<r.byteLength;t+=2){const r=o.getUint16(t,e);i+=String.fromCharCode(r)}return i}static fromString(t,e=!1){const r=new ArrayBuffer(2*t.length),n=new DataView(r);for(let r=0;r<t.length;r++)n.setUint16(2*r,t.charCodeAt(r),e);return r}}class s{static isHex(t){return"string"==typeof t&&/^[a-z0-9]+$/i.test(t)}static isBase64(t){return"string"==typeof t&&/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(t)}static isBase64Url(t){return"string"==typeof t&&/^[a-zA-Z0-9-_]+$/i.test(t)}static ToString(t,e="utf8"){const r=n.toUint8Array(t);switch(e.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return i.toString(r,!0);case"utf16":case"utf16be":return i.toString(r);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return i.fromString(t,!0);case"utf16":case"utf16be":return i.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){const e=n.toUint8Array(t);if("undefined"!=typeof btoa){const t=this.ToString(e,"binary");return btoa(t)}return Buffer.from(e).toString("base64")}static FromBase64(t){const e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!s.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return"undefined"!=typeof atob?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){const e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!s.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=s.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return o.fromString(t);case"utf16":case"utf16be":return i.fromString(t);case"utf16le":case"usc2":return i.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=s.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return o.toString(t);case"utf16":case"utf16be":return i.toString(t);case"utf16le":case"usc2":return i.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){const e=t.length,r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=t.charCodeAt(n);return r.buffer}static ToBinary(t){const e=n.toUint8Array(t);let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return r}static ToHex(t){const e=n.toUint8Array(t),r=[],o=e.length;for(let t=0;t<o;t++){const n=e[t].toString(16).padStart(2,"0");r.push(n)}return r.join("")}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!s.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);const r=new Uint8Array(e.length/2);for(let t=0;t<e.length;t+=2){const n=e.slice(t,t+2);r[t/2]=parseInt(n,16)}return r.buffer}static ToUtf16String(t,e=!1){return i.toString(t,e)}static FromUtf16String(t,e=!1){return i.fromString(t,e)}static Base64Padding(t){const e=4-t.length%4;if(e<4)for(let r=0;r<e;r++)t+="=";return t}static formatString(t){return(null==t?void 0:t.replace(/[\n\r\t ]/g,""))||""}}var a,c,u,h;s.DEFAULT_UTF8_ENCODING="utf8",function(t){t[t.ok=200]="ok",t[t.created=201]="created",t[t.noContent=204]="noContent",t[t.unauthorized=401]="unauthorized",t[t.badRequest=400]="badRequest",t[t.forbidden=403]="forbidden",t[t.notFound=404]="notFound",t[t.methodNotAllowed=405]="methodNotAllowed",t[t.internalServerError=500]="internalServerError"}(a||(a={}));class f extends Error{constructor(t,e="",r=a.internalServerError,n){super(e),this.type=t,this.message=e,this.status=r,this.inner=n,this.name="AcmeError"}}!function(t){t.json="application/json",t.joseJson="application/jose+json",t.problemJson="application/problem+json",t.pkix="application/pkix-cert",t.pem="application/pem-certificate-chain",t.pkcs7="application/pkcs7-mime"}(c||(c={}));class l{constructor(t,e){var r;if(this.content=new ArrayBuffer(0),"string"==typeof t)this.content=s.FromUtf8String(t),this.type=c.pem;else if(t instanceof f)this.content=s.FromUtf8String(JSON.stringify({detail:t.message,type:t.type,subproblems:null===(r=t.subproblems)||void 0===r?void 0:r.map((t=>({detail:t.message,type:t.type})))})),this.type=c.problemJson;else if(n.isBufferSource(t)){if(!e)throw new TypeError("Cannot get required argument 'type'");this.content=n.toArrayBuffer(t),this.type=e}else{const r=e?JSON.stringify(t,null," "):JSON.stringify(t);this.content=s.FromUtf8String(r),this.type=c.json}}toJSON(){return JSON.parse(this.toString())}toString(){return s.ToUtf8String(this.content)}}class p extends Map{get location(){return this.get(p.LOCATION)||null}set location(t){t?this.set(p.LOCATION,t):this.delete(p.LOCATION)}get contentType(){var t,e;const r=this.get(p.CONTENT_TYPE);return r?{mediaType:r.split(";")[0],charset:null===(t=/charset=([\w-]+)/i.exec(r))||void 0===t?void 0:t[1],boundary:null===(e=/boundary=([\w-]+)/i.exec(r))||void 0===e?void 0:e[1]}:null}get link(){const t=this.get(p.LINK);return t?t.split(",").map((t=>t.trim())):null}setLink(t){let e=this.get(p.LINK);e?e+=`,${t}`:e=t,this.set(p.LINK,e)}get cacheControl(){return this.get(p.CACHE_CONTROL)||null}set cacheControl(t){t?this.set(p.CACHE_CONTROL,t):this.delete(p.CACHE_CONTROL)}get replayNonce(){return this.get(p.REPLAY_NONCE)||null}set replayNonce(t){t?this.set(p.REPLAY_NONCE,t):this.delete(p.REPLAY_NONCE)}set(t,e){return super.set(t.toLowerCase(),e)}get(t){return super.get(t.toLowerCase())}append(t,e){const r=this.get(t);e?this.set(t,`${r}, ${e}`):this.set(t,e)}}p.REPLAY_NONCE="Replay-Nonce",p.LINK="Link",p.CONTENT_TYPE="Content-Type",p.LOCATION="Location",p.CACHE_CONTROL="Cache-Control";class y{constructor(){this.status=a.ok,this.headers=new p}json(){if(this.content)return this.content.toJSON();throw new Error("No content in ACME response")}}function d(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)}!function(t){t.accountDoesNotExist="urn:ietf:params:acme:error:accountDoesNotExist",t.alreadyRevoked="urn:ietf:params:acme:error:alreadyRevoked",t.badCSR="urn:ietf:params:acme:error:badCSR",t.badNonce="urn:ietf:params:acme:error:badNonce",t.badPublicKey="urn:ietf:params:acme:error:badPublicKey",t.badRevocationReason="urn:ietf:params:acme:error:badRevocationReason",t.badSignatureAlgorithm="urn:ietf:params:acme:error:badSignatureAlgorithm",t.caa="urn:ietf:params:acme:error:caa",t.compound="urn:ietf:params:acme:error:compound",t.connection="urn:ietf:params:acme:error:connection",t.dns="urn:ietf:params:acme:error:dns",t.externalAccountRequired="urn:ietf:params:acme:error:externalAccountRequired",t.incorrectResponse="urn:ietf:params:acme:error:incorrectResponse",t.invalidContact="urn:ietf:params:acme:error:invalidContact",t.malformed="urn:ietf:params:acme:error:malformed",t.orderNotReady="urn:ietf:params:acme:error:orderNotReady",t.rateLimited="urn:ietf:params:acme:error:rateLimited",t.rejectedIdentifier="urn:ietf:params:acme:error:rejectedIdentifier",t.serverInternal="urn:ietf:params:acme:error:serverInternal",t.tls="urn:ietf:params:acme:error:tls",t.unauthorized="urn:ietf:params:acme:error:unauthorized",t.unsupportedContact="urn:ietf:params:acme:error:UnsupportedContact",t.unsupportedIdentifier="urn:ietf:params:acme:error:unsupportedIdentifier",t.userActionRequired="urn:ietf:params:acme:error:userActionRequired"}(u||(u={})),"function"==typeof SuppressedError&&SuppressedError,function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"}(h||(h={}));var g=h,w=function(t,e){return(w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function v(t,e){function r(){this.constructor=t}w(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function m(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{c(n.next(t))}catch(t){i(t)}}function a(t){try{c(n.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}c((n=n.apply(t,e||[])).next())}))}function S(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function A(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function C(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function b(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(C(arguments[e]));return t}function E(t){return!!t.useClass}function _(t){return!!t.useFactory}var R=function(){function t(t){this.wrap=t,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct","ownKeys"]}return t.prototype.createProxy=function(t){var e,r=this,n=!1;return new Proxy({},this.createHandler((function(){return n||(e=t(r.wrap()),n=!0),e})))},t.prototype.createHandler=function(t){var e={};return this.reflectMethods.forEach((function(r){e[r]=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];e[0]=t();var o=Reflect[r];return o.apply(void 0,b(e))}})),e},t}();function k(t){return"string"==typeof t||"symbol"==typeof t}function T(t){return"object"==typeof t&&"token"in t&&"transform"in t}function P(t){return!!t.useToken}function O(t){return null!=t.useValue}var K=function(){function t(){this._registryMap=new Map}return t.prototype.entries=function(){return this._registryMap.entries()},t.prototype.getAll=function(t){return this.ensure(t),this._registryMap.get(t)},t.prototype.get=function(t){this.ensure(t);var e=this._registryMap.get(t);return e[e.length-1]||null},t.prototype.set=function(t,e){this.ensure(t),this._registryMap.get(t).push(e)},t.prototype.setAll=function(t,e){this._registryMap.set(t,e)},t.prototype.has=function(t){return this.ensure(t),this._registryMap.get(t).length>0},t.prototype.clear=function(){this._registryMap.clear()},t.prototype.ensure=function(t){this._registryMap.has(t)||this._registryMap.set(t,[])},t}(),H=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(K),N=function(){this.scopedResolutions=new Map};function x(t,e,r){var n,o,i=C(t.toString().match(/constructor\(([\w, ]+)\)/)||[],2)[1],s=function(t,e){return null===t?"at position #"+e:'"'+t.split(",")[e].trim()+'" at position #'+e}(void 0===i?null:i,e);return n="Cannot inject the dependency "+s+' of "'+t.name+'" constructor. Reason:',void 0===o&&(o=" "),b([n],r.message.split("\n").map((function(t){return o+t}))).join("\n")}var j,B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(K),U=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(K),I=function(){this.preResolution=new B,this.postResolution=new U},M=new Map,L=new(function(){function t(t){this.parent=t,this._registry=new H,this.interceptors=new I,this.disposed=!1,this.disposables=new Set}return t.prototype.register=function(t,e,r){var n;if(void 0===r&&(r={lifecycle:g.Transient}),this.ensureNotDisposed(),n=function(t){return E(t)||O(t)||P(t)||_(t)}(e)?e:{useClass:e},P(n))for(var o=[t],i=n;null!=i;){var s=i.useToken;if(o.includes(s))throw new Error("Token registration cycle detected! "+b(o,[s]).join(" -> "));o.push(s);var a=this._registry.get(s);i=a&&P(a.provider)?a.provider:null}if((r.lifecycle===g.Singleton||r.lifecycle==g.ContainerScoped||r.lifecycle==g.ResolutionScoped)&&(O(n)||_(n)))throw new Error('Cannot use lifecycle "'+g[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(t,{provider:n,options:r}),this},t.prototype.registerType=function(t,e){return this.ensureNotDisposed(),k(e)?this.register(t,{useToken:e}):this.register(t,{useClass:e})},t.prototype.registerInstance=function(t,e){return this.ensureNotDisposed(),this.register(t,{useValue:e})},t.prototype.registerSingleton=function(t,e){if(this.ensureNotDisposed(),k(t)){if(k(e))return this.register(t,{useToken:e},{lifecycle:g.Singleton});if(e)return this.register(t,{useClass:e},{lifecycle:g.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=t;return e&&!k(e)&&(r=e),this.register(t,{useClass:r},{lifecycle:g.Singleton})},t.prototype.resolve=function(t,e){void 0===e&&(e=new N),this.ensureNotDisposed();var r=this.getRegistration(t);if(!r&&k(t))throw new Error('Attempted to resolve unregistered dependency token: "'+t.toString()+'"');if(this.executePreResolutionInterceptor(t,"Single"),r){var n=this.resolveRegistration(r,e);return this.executePostResolutionInterceptor(t,n,"Single"),n}if(function(t){return"function"==typeof t||t instanceof R}(t)){n=this.construct(t,e);return this.executePostResolutionInterceptor(t,n,"Single"),n}throw new Error("Attempted to construct an undefined constructor. Could mean a circular dependency problem. Try using `delay` function.")},t.prototype.executePreResolutionInterceptor=function(t,e){var r,n;if(this.interceptors.preResolution.has(t)){var o=[];try{for(var i=A(this.interceptors.preResolution.getAll(t)),s=i.next();!s.done;s=i.next()){var a=s.value;"Once"!=a.options.frequency&&o.push(a),a.callback(t,e)}}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}this.interceptors.preResolution.setAll(t,o)}},t.prototype.executePostResolutionInterceptor=function(t,e,r){var n,o;if(this.interceptors.postResolution.has(t)){var i=[];try{for(var s=A(this.interceptors.postResolution.getAll(t)),a=s.next();!a.done;a=s.next()){var c=a.value;"Once"!=c.options.frequency&&i.push(c),c.callback(t,e,r)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(o=s.return)&&o.call(s)}finally{if(n)throw n.error}}this.interceptors.postResolution.setAll(t,i)}},t.prototype.resolveRegistration=function(t,e){if(this.ensureNotDisposed(),t.options.lifecycle===g.ResolutionScoped&&e.scopedResolutions.has(t))return e.scopedResolutions.get(t);var r,n=t.options.lifecycle===g.Singleton,o=t.options.lifecycle===g.ContainerScoped,i=n||o;return r=O(t.provider)?t.provider.useValue:P(t.provider)?i?t.instance||(t.instance=this.resolve(t.provider.useToken,e)):this.resolve(t.provider.useToken,e):E(t.provider)?i?t.instance||(t.instance=this.construct(t.provider.useClass,e)):this.construct(t.provider.useClass,e):_(t.provider)?t.provider.useFactory(this):this.construct(t.provider,e),t.options.lifecycle===g.ResolutionScoped&&e.scopedResolutions.set(t,r),r},t.prototype.resolveAll=function(t,e){var r=this;void 0===e&&(e=new N),this.ensureNotDisposed();var n=this.getAllRegistrations(t);if(!n&&k(t))throw new Error('Attempted to resolve unregistered dependency token: "'+t.toString()+'"');if(this.executePreResolutionInterceptor(t,"All"),n){var o=n.map((function(t){return r.resolveRegistration(t,e)}));return this.executePostResolutionInterceptor(t,o,"All"),o}var i=[this.construct(t,e)];return this.executePostResolutionInterceptor(t,i,"All"),i},t.prototype.isRegistered=function(t,e){return void 0===e&&(e=!1),this.ensureNotDisposed(),this._registry.has(t)||e&&(this.parent||!1)&&this.parent.isRegistered(t,!0)},t.prototype.reset=function(){this.ensureNotDisposed(),this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var t,e;this.ensureNotDisposed();try{for(var r=A(this._registry.entries()),n=r.next();!n.done;n=r.next()){var o=C(n.value,2),i=o[0],s=o[1];this._registry.setAll(i,s.filter((function(t){return!O(t.provider)})).map((function(t){return t.instance=void 0,t})))}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=r.return)&&e.call(r)}finally{if(t)throw t.error}}},t.prototype.createChildContainer=function(){var e,r;this.ensureNotDisposed();var n=new t(this);try{for(var o=A(this._registry.entries()),i=o.next();!i.done;i=o.next()){var s=C(i.value,2),a=s[0],c=s[1];c.some((function(t){return t.options.lifecycle===g.ContainerScoped}))&&n._registry.setAll(a,c.map((function(t){return t.options.lifecycle===g.ContainerScoped?{provider:t.provider,options:t.options}:t})))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}return n},t.prototype.beforeResolution=function(t,e,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.preResolution.set(t,{callback:e,options:r})},t.prototype.afterResolution=function(t,e,r){void 0===r&&(r={frequency:"Always"}),this.interceptors.postResolution.set(t,{callback:e,options:r})},t.prototype.dispose=function(){return m(this,void 0,void 0,(function(){var t;return S(this,(function(e){switch(e.label){case 0:return this.disposed=!0,t=[],this.disposables.forEach((function(e){var r=e.dispose();r&&t.push(r)})),[4,Promise.all(t)];case 1:return e.sent(),[2]}}))}))},t.prototype.getRegistration=function(t){return this.isRegistered(t)?this._registry.get(t):this.parent?this.parent.getRegistration(t):null},t.prototype.getAllRegistrations=function(t){return this.isRegistered(t)?this._registry.getAll(t):this.parent?this.parent.getAllRegistrations(t):null},t.prototype.construct=function(t,e){var r=this;if(t instanceof R)return t.createProxy((function(t){return r.resolve(t,e)}));var n,o=function(){var n=M.get(t);if(!n||0===n.length){if(0===t.length)return new t;throw new Error('TypeInfo not known for "'+t.name+'"')}var o=n.map(r.resolveParams(e,t));return new(t.bind.apply(t,b([void 0],o)))}();return"function"!=typeof(n=o).dispose||n.dispose.length>0||this.disposables.add(o),o},t.prototype.resolveParams=function(t,e){var r=this;return function(n,o){var i,s,a,c;try{return"object"==typeof(c=n)&&"token"in c&&"multiple"in c?T(n)?n.multiple?(i=r.resolve(n.transform)).transform.apply(i,b([r.resolveAll(n.token)],n.transformArgs)):(s=r.resolve(n.transform)).transform.apply(s,b([r.resolve(n.token,t)],n.transformArgs)):n.multiple?r.resolveAll(n.token):r.resolve(n.token,t):T(n)?(a=r.resolve(n.transform,t)).transform.apply(a,b([r.resolve(n.token,t)],n.transformArgs)):r.resolve(n,t)}catch(t){throw new Error(x(e,o,t))}}},t.prototype.ensureNotDisposed=function(){if(this.disposed)throw new Error("This container has been disposed, you cannot interact with a disposed container")},t}());if("undefined"==typeof Reflect||!Reflect.getMetadata)throw new Error("tsyringe requires a reflect polyfill. Please add 'import \"reflect-metadata\"' to the top of your entry point.");!function(t){t[t.error=0]="error",t[t.warn=1]="warn",t[t.info=2]="info",t[t.debug=3]="debug"}(j||(j={}));let D=class t{constructor(){this.level=j.info}error(t,e){this.write(j.error,t,e)}info(t,e){this.write(j.info,t,e)}warn(t,e){this.write(j.warn,t,e)}debug(t,e){this.write(j.debug,t,e)}write(t,e,r){if(this.checkLevel(t)){const n={level:j[t],timestamp:new Date,class:this.caller()};this.onWrite(n,e,r)}}onWrite(t,e,r){}checkLevel(t){return this.level>=t}caller(){try{throw new Error}catch(t){if(t instanceof Error){const e=/at ([a-zA-Z0-9_.]+) \(/gm,r=t.stack;if(r){let t=null,n=3;for(;t=e.exec(r);)if(!n--)return t[1].split(".")[0]}}return"undefined"}}};D=function(t,e,r,n){var o,i=arguments.length,s=i<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,r,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,r,s):o(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}([function(t){M.set(t,function(t){var e=Reflect.getMetadata("design:paramtypes",t)||[],r=Reflect.getOwnMetadata("injectionTokens",t)||{};return Object.keys(r).forEach((function(t){e[+t]=r[t]})),e}(t))}],D),L.register("ACME.Logger",D,{lifecycle:g.Singleton});class F{static toAlgorithm(t){switch(t){case"ES256":return{name:"ECDSA",hash:{name:"SHA-256"}};case"ES384":return{name:"ECDSA",hash:{name:"SHA-384"}};case"ES512":return{name:"ECDSA",hash:{name:"SHA-512"}};case"HS1":return{name:"HMAC",hash:{name:"SHA-1"}};case"HS256":return{name:"HMAC",hash:{name:"SHA-256"}};case"HS384":return{name:"HMAC",hash:{name:"SHA-384"}};case"HS512":return{name:"HMAC",hash:{name:"SHA-512"}};case"PS1":return{name:"RSA-PSS",hash:{name:"SHA-1"}};case"PS256":return{name:"RSA-PSS",hash:{name:"SHA-256"}};case"PS384":return{name:"RSA-PSS",hash:{name:"SHA-384"}};case"PS512":return{name:"RSA-PSS",hash:{name:"SHA-512"}};case"RS1":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"RS384":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case"RS512":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}}}return null}static fromAlgorithm(t){const e="string"==typeof t?{name:t}:t,r=e.name.toLowerCase(),n=e.hash?("string"==typeof e.hash?e.hash:e.hash.name).toLowerCase():"sha-256";switch(r){case"hmac":switch(n){case"sha-1":return"HS1";case"sha-256":return"HS256";case"sha-384":return"HS384";case"sha-512":return"HS512"}break;case"rsassa-pkcs1-v1_5":switch(n){case"sha-1":return"RS1";case"sha-256":return"RS256";case"sha-R84":return"RS384";case"sha-512":return"RS512"}break;case"rsa-pss":switch(n){case"sha-1":return"PS1";case"sha-256":return"PS256";case"sha-P84":return"PS384";case"sha-512":return"PS512"}break;case"ecdsa":switch(n){case"sha-256":return"ES256";case"sha-384":return"ES384";case"sha-512":return"ES512"}}return null}}var W,G,J,z;!function(t){t.hs256="HS256",t.hs384="HS384",t.hs512="HS512",t.RS256="RS256",t.RS384="RS384",t.RS512="RS512",t.ES256="ES256",t.ES384="ES384",t.ES512="ES512",t.PS1="PS1",t.PS256="PS256",t.PS384="PS384",t.PS512="PS512",t.RSA1_5="RSA1_5",t.RSA_OAEP="RSA-OAEP",t.RSA_OAEP_256="RSA-OAEP-256",t.A128KW="A128KW",t.A192KW="A192KW",t.A256KW="A256KW",t.Dir="dir",t.ECDH_ES="ECDH-ES",t.ECDH_ES_A128KW="ECDH-ES+A128KW",t.ECDH_ES_A192KW="ECDH-ES+A192KW",t.ECDH_ES_A256KW="ECDH-ES+A256KW",t.A128GCMKW="A128GCMKW",t.A192GCMKW="A192GCMKW",t.A256GCMKW="A256GCMKW",t.PBES2_HS256_A128KW="PBES2-HS256+A128KW",t.PBES2_HS384_A192KW="PBES2-HS384+A192KW",t.PBES2_HS512_A256KW="PBES2-HS512+A256KW",t.A128CBC_HS256="A128CBC-HS256",t.A192CBC_HS384="A192CBC-HS384",t.A256CBC_HS512="A256CBC-HS512",t.A128GCM="A128GCM",t.A192GCM="A192GCM",t.A256GCM="A256GCM",t.EdDSA="EdDSA",t.RS1="RS1",t.RSA_OAEP_384="RSA-OAEP-384",t.RSA_OAEP_512="RSA-OAEP-512",t.A128CBC="A128CBC",t.A192CBC="A192CBC",t.A256CBC="A256CBC",t.A128CTR="A128CTR",t.A192CTR="A192CTR",t.A256CTR="A256CTR",t.HS1="HS1",t.SHA1="SHA1",t.SHA256="SHA256"}(W||(W={})),function(t){t.EC="EC",t.RSA="RSA",t.OctetSequence="oct",t.OctetStringKeyPairs="OKP"}(G||(G={}));class ${constructor(t,e={}){J.set(this,void 0),Object.assign(this,e),function(t,e,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===n?o.call(t,r):o?o.value=r:e.set(t,r)}(this,J,t,"f")}async exportKey(...t){let e,r=["verify"],n=d(this,J,"f");if(arguments.length<2)switch(n=t[0]||n,this.kty){case G.RSA:e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"};break;case G.EC:e={name:"ECDSA",namedCurve:this.crv};break;case G.OctetSequence:e={name:"HMAC",hash:"SHA-256"};break;default:throw new Error("Unsupported type of JWK")}else e=t[0],r=t[1],n=t[2]||n;return await n.subtle.importKey("jwk",this,e,!0,r)}async getThumbprint(t=W.SHA256){const e={};this.crv&&(e.crv=this.crv.toString()),this.e&&(e.e=this.e),this.k&&(e.k=this.k),this.kty&&(e.kty=this.kty.toString()),this.n&&(e.n=this.n),this.x&&(e.x=this.x),this.y&&(e.y=this.y);const r=JSON.stringify(e);switch(t){case W.SHA256:return s.ToHex(await this.digest(r,"SHA-256"));case W.SHA1:return s.ToHex(await this.digest(r,"SHA-1"));default:throw new Error(`Unsupported algorithm: ${t}`)}}async digest(t,e){return await d(this,J,"f").subtle.digest({name:e},n.toUint8Array(s.FromUtf8String(t)))}async getPublicKey(){if(this.kty===G.EC)return this.getEcdsaPublicKey();if(this.kty===G.RSA)return this.getRsaPublicKey();throw new Error(`Unsupported type ${this.kty}`)}async getEcdsaPublicKey(){const t={name:"ECDSA",namedCurve:this.crv};return await d(this,J,"f").subtle.importKey("jwk",this,t,!0,["verify"])}async getRsaPublicKey(){return await d(this,J,"f").subtle.importKey("jwk",this,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}}J=new WeakMap;class V{constructor(t={},e){this.cryptoProvider=e,this.protected="e30",this.payload="",this.signature="",t.protected&&this.setProtected(t.protected),void 0!==t.payload&&this.setPayload(t.payload)}fromJSON(t){Object.assign(this,t)}isPayloadEmpty(){return!this.payload}isPayloadEmptyObject(){return"e30"===this.payload}getProtected(t){const e=this.read(this.protected);return e.jwk&&(e.jwk=new $(this.getCryptoProvider(t),e.jwk)),e}setProtected(t){this.protected=this.write(t)}getPayload(){return this.read(this.payload)}tryGetPayload(){try{return this.getPayload()}catch(t){return null}}setPayload(t){this.payload=""===t?"":this.write(t)}getSignature(){return s.FromBase64Url(this.signature)}setSignature(t){this.signature=s.ToBase64Url(t)}read(t){const e=s.FromBase64Url(t),r=s.ToUtf8String(e);return""===r?"":JSON.parse(r)}write(t){const e=JSON.stringify(t),r=s.FromUtf8String(e);return s.ToBase64Url(r)}async verify(t,e){const r=this.getProtected();if(!r.alg)throw new Error("JWS.protected doesn't have required parameter 'alg'");const n=F.toAlgorithm(r.alg);if(!n)throw new Error("Cannot convert JWA to WebCrypto algorithm");if(!t){const r=await this.getKey(e);if(!r)throw new Error("Cannot get JWK key");t=r}const o=s.FromUtf8String(this.toStringSign());return await this.getCryptoProvider(e).subtle.verify(n,t,this.getSignature(),o)}async getKey(t){const e=this.getProtected();if(!e.jwk)return null;if(!e.alg)throw new Error("JWS.protected doesn't have required parameter 'alg'");const r=F.toAlgorithm(e.alg);if(!r)throw new Error("Cannot convert JWA to WebCrypto algorithm");const n={...r};"ECDSA"===n.name&&(n.namedCurve=e.jwk.crv);return await this.getCryptoProvider(t).subtle.importKey("jwk",e.jwk,n,!0,["verify"])}async sign(t,e,r){const n=this.getProtected(),o=F.fromAlgorithm({...t,...e.algorithm});if(!o)throw new Error("Cannot convert WebCrypto algorithm to JWA");n.alg=o,this.setProtected(n);const i=s.FromUtf8String(this.toStringSign()),a=await this.getCryptoProvider(r).subtle.sign(t,e,i);this.setSignature(a)}toStringSign(){return`${this.protected}.${this.payload}`}toJSON(){const t={};return this.protected&&(t.protected=this.protected),void 0!==this.payload&&(t.payload=this.payload),this.signature&&(t.signature=this.signature),t}parse(t){if("{"===t[0]){const e=JSON.parse(t);this.protected=e.protected||"",this.payload=e.payload||"",this.signature=e.signature||""}else{const e=t.split(".");this.protected=e[0]||"",this.payload=e[1]||"",this.signature=e[2]||""}}toString(t=!1){return t?`${this.protected}.${this.payload}.${this.signature}`:JSON.stringify(this.toJSON())}getCryptoProvider(t){if(t)return t;if(this.cryptoProvider)return this.cryptoProvider;throw new Error("Cannot find Crypto")}}class q{constructor(t={}){if(this.options={crypto:"undefined"!=typeof self?self.crypto:void 0,debug:t.debug,defaultHash:"SHA-256",fetch:"undefined"!=typeof fetch?fetch:void 0,...t},!this.options.crypto)throw new Error("Cannot initialize ACME client. It requires crypto provider to be set.")}static createResponse(t,e){return{status:t.status,headers:t.headers,content:e}}async fetch(t,e){var r,n;if(!this.options.fetch)throw new Error("Cannot get 'fetch' option");this.options.debug&&(console.log(`REQUEST ${e.method} ${t}`),"body"in e&&console.log("REQUEST BODY",e.body));const o=this.options.fetch;let i;if("GET"===e.method||"HEAD"===e.method)i=await o(t,{method:e.method,headers:e.headers||{}});else{const r=this.getCrypto(),n=e,s={method:"POST"},a={url:t,nonce:n.nonce};if("string"==typeof n.kid)a.kid=n.kid;else{const t=await this.getCrypto().subtle.exportKey("jwk",n.kid);a.jwk=new $(r,t)}const u=new V({protected:a,payload:n.method&&"POST-as-GET"!==n.method?n.body:""},this.getCrypto());await u.sign({hash:n.hash||this.options.defaultHash,...n.key.algorithm},n.key,r),s.body=u.toString(),s.headers={"Content-Type":c.joseJson},i=await o(t,s)}const s=new y;s.status=i.status,i.headers.forEach(((t,e)=>s.headers.set(e,t)));const a=await i.arrayBuffer();if(s.content=new l(a,(null===(r=s.headers.contentType)||void 0===r?void 0:r.mediaType)||c.json),this.options.debug&&console.log(`RESPONSE ${e.method} ${t}`),s.content&&(s.status<200||s.status>299)){if((null===(n=s.headers.contentType)||void 0===n?void 0:n.mediaType)===c.problemJson){const t=s.content.toJSON();throw this.options.debug&&console.log("RESPONSE",t),new f(t.type,t.detail,s.status)}{const t=s.content.toString();throw this.options.debug&&console.log("RESPONSE",t),new f(u.serverInternal,"Wrong Content-Type of ACME response. Must be application/problem+json. See inner exception for more details.",s.status,new globalThis.Error(t))}}const h=q.createResponse(s,e.convert(s));return this.options.debug&&console.log("RESPONSE",h),h}getCrypto(){if(!this.options.crypto)throw new Error("Cannot get 'crypto' option");return this.options.crypto}}t.CRLReasons=void 0,(z=t.CRLReasons||(t.CRLReasons={}))[z.unspecified=0]="unspecified",z[z.keyCompromise=1]="keyCompromise",z[z.cACompromise=2]="cACompromise",z[z.affiliationChanged=3]="affiliationChanged",z[z.superseded=4]="superseded",z[z.cessationOfOperation=5]="cessationOfOperation",z[z.certificateHold=6]="certificateHold",z[z.removeFromCRL=8]="removeFromCRL",z[z.privilegeWithdrawn=9]="privilegeWithdrawn",z[z.aACompromise=10]="aACompromise";class Y extends q{constructor(t,e,r){super(r),this.accountKey=t,this.url=e,this.nonce="",this.accountId=""}static async create(t,e,r){const n=new this(t,e,r);return n.directory=await n.getDirectory(),n}async fetch(t,e){"POST"!==e.method&&"POST-as-GET"!==e.method||(this.nonce||await this.getNonce(),e.nonce=this.nonce,this.nonce="");try{const r=await super.fetch(t,e);return this.readNonce(r),r}catch(r){if(r instanceof f&&r.type===u.badNonce)return this.fetch(t,e);throw r}}async getDirectory(){return(await this.fetch(this.url,{method:"GET",convert:t=>t.json()})).content}async getNonce(t="HEAD"){const e=await this.fetch(this.directory.newNonce,{method:t,convert:()=>null});return this.readNonce(e)}async newAccount(t){const e={};t.contact&&(e.contact=t.contact),void 0!==t.onlyReturnExisting&&(e.onlyReturnExisting=t.onlyReturnExisting),void 0!==t.termsOfServiceAgreed&&(e.termsOfServiceAgreed=t.termsOfServiceAgreed),t.externalAccountBinding&&(e.externalAccountBinding=await this.createExternalAccountBinding(t.externalAccountBinding.challenge,t.externalAccountBinding.kid));const r=await this.fetch(this.directory.newAccount,{method:"POST",kid:this.accountKey.publicKey,nonce:this.nonce,key:this.accountKey.privateKey,body:e,convert:t=>t.json()});if(!r.headers.location)throw new Error("Cannot get Location header");return this.accountId=r.headers.location,r}async updateAccount(t){const e=this.getAccountId();return await this.fetch(e,{method:"POST",kid:e,nonce:this.nonce,key:this.accountKey.privateKey,body:t,convert:t=>t.json()})}getAccountId(){if(!this.accountId)throw new Error("Create or Find account first");return this.accountId}async deactivateAccount(){return this.deactivate(this.getAccountId(),(t=>t.json()))}async changeKey(t){const e=this.getAccountId(),r=this.getCrypto(),n=new V({protected:{url:this.directory.keyChange,jwk:new $(r,await r.subtle.exportKey("jwk",t.publicKey))},payload:{account:e,oldKey:new $(r,await r.subtle.exportKey("jwk",this.accountKey.publicKey))}},this.getCrypto());await n.sign({hash:this.options.defaultHash,...t.privateKey.algorithm},t.privateKey);const o=await this.fetch(this.directory.keyChange,{method:"POST",kid:e,nonce:this.nonce,key:this.accountKey.privateKey,body:n,convert:()=>null});return this.accountKey=t,o}async newOrder(t){return this.fetch(this.directory.newOrder,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:t,convert:t=>t.json()})}async getOrder(t){return this.fetch(t,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()})}async retryOrder(t,e={}){let r="string"==typeof t?await this.getOrder(t):t,n=e.retries||Y.RETRIES;for(;n--;){if(!r.headers.location)throw new Error("Cannot get location header from Order response");if(r=await this.getOrder(r.headers.location),"processing"!==r.content.status)break;await this.pause(e.interval||Y.INTERVAL)}return r}async revoke(e,r=t.CRLReasons.unspecified){return await this.fetch(this.directory.revokeCert,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:{certificate:s.ToBase64Url(e),reason:r},convert:()=>null})}async deactivate(t,e){return this.fetch(t,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:{status:"deactivated"},convert:e})}async deactivateAuthorization(t){return this.deactivate(t,(t=>t.json()))}async getChallenge(t,e="POST-as-GET"){if("string"==typeof e){return await this.fetch(t,{method:e,kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:"POST"===e?{}:void 0,convert:t=>t.json()})}if(e){return await this.fetch(t,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:e,convert:t=>t.json()})}return await this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()})}async finalize(t,e){return this.fetch(t,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:e,convert:t=>t.json()})}async getAuthorization(t){return this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()})}async newAuthorization(t){if(!this.directory.newAuthz)throw new Error("ACME service doesn't support new-authz controller");return this.fetch(this.directory.newAuthz,{method:"POST",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,body:t,convert:t=>t.json()})}async retryAuthorization(t,e={}){let r="string"==typeof t?await this.getOrder(t):t,n=e.retries||Y.RETRIES;for(;n--;){if(!r.headers.location)throw new Error("Cannot get location header from Authorization response");if(r=await this.getAuthorization(r.headers.location),"pending"!==r.content.status)break;await this.pause(e.interval||Y.INTERVAL)}return r}async internalGetCertificate(t,e){const r=t=>{if(!t.content)throw new Error("Cannot get content from ACME response");switch(t.content.type){case c.pem:return this.decodePem(t.content.toString());case c.pkix:return[t.content.content];case c.pkcs7:throw new Error("Not implemented");default:throw new Error("Not supported content type for certificate")}};let n;switch(e){case"GET":n=await this.fetch(t,{method:e,convert:r});break;case"POST":default:n=await this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:r})}return n}async getCertificate(t){return this.internalGetCertificate(t,"POST")}async getCaCertificate(t){return this.internalGetCertificate(t,"GET")}async getEndpoint(t){let e;return e=this.accountId?await this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()}):await this.fetch(t,{method:"GET",convert:t=>t.json()}),e}readNonce(t){const e=t.headers.replayNonce;return this.nonce=e||"",e}async pause(t){return new Promise((e=>setTimeout(e,t)))}async createExternalAccountBinding(t,e){const r=await this.getCrypto().subtle.importKey("raw",s.FromBase64Url(t),{name:"HMAC",hash:"SHA-256"},!0,["sign"]),n=await this.getCrypto().subtle.exportKey("jwk",this.accountKey.publicKey),o=new V({protected:{kid:e},payload:n},this.getCrypto());return await o.sign(r.algorithm,r,this.getCrypto()),o.toJSON()}decodePem(t){const e=/-{5}BEGIN [A-Z0-9 ]+-{5}([a-zA-Z0-9=+/\n\r]+)-{5}END [A-Z0-9 ]+-{5}/g,r=[];let n=null;for(;n=e.exec(t);){const t=n[1].replace(/[\r\n]/g,"");r.push(s.FromBase64(t))}return r}}return Y.RETRIES=10,Y.INTERVAL=1e3,t.ApiClient=Y,t.BaseClient=q,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); |
{ | ||
"name": "@peculiar/acme-client", | ||
"version": "1.8.0", | ||
"version": "1.8.2", | ||
"description": "Automatic Certificate Management Environment (ACME) client", | ||
@@ -47,6 +47,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@peculiar/acme-core": "^1.8.0", | ||
"@peculiar/acme-protocol": "^1.8.0", | ||
"@peculiar/acme-core": "^1.8.2", | ||
"@peculiar/acme-protocol": "^1.8.2", | ||
"@peculiar/asn1-x509": "^2.0.44", | ||
"@peculiar/jose": "^1.7.2", | ||
"@peculiar/jose": "^1.8.2", | ||
"pvtsutils": "^1.2.1" | ||
@@ -64,3 +64,3 @@ }, | ||
}, | ||
"gitHead": "6b7ef607e077ae32d16c77b7a400a0d26b0dce52" | ||
"gitHead": "1284b8f912200b9ef98dceb641a0baee169b91b9" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
134498
Updated@peculiar/acme-core@^1.8.2
Updated@peculiar/jose@^1.8.2