Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@peculiar/acme-client

Package Overview
Dependencies
Maintainers
6
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@peculiar/acme-client - npm Package Compare versions

Comparing version 1.5.1 to 1.5.2

2

build/acme.js

@@ -1,1 +0,1 @@

var acme=function(t){"use strict";var e,r,n,o,i,s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(t){!function(e){var r="object"==typeof s?s:"object"==typeof self?self:"object"==typeof this?this:Function("return this;")(),n=o(t);function o(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===r.Reflect?r.Reflect=t:n=o(r.Reflect,n),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(!J(t))throw new TypeError;if(!G(e))throw new TypeError;return b(t,e)}if(!J(t))throw new TypeError;if(!M(e))throw new TypeError;if(!M(n)&&!j(n)&&!N(n))throw new TypeError;return N(n)&&(n=void 0),_(t,e,r=D(r),n)}function d(t,e){function r(r,n){if(!M(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(!M(r))throw new TypeError;return j(n)||(n=D(n)),K(t,e,r,n)}function v(t,e,r){if(!M(e))throw new TypeError;return j(r)||(r=D(r)),k(t,e,r)}function w(t,e,r){if(!M(e))throw new TypeError;return j(r)||(r=D(r)),P(t,e,r)}function m(t,e,r){if(!M(e))throw new TypeError;return j(r)||(r=D(r)),T(t,e,r)}function S(t,e,r){if(!M(e))throw new TypeError;return j(r)||(r=D(r)),O(t,e,r)}function A(t,e){if(!M(t))throw new TypeError;return j(e)||(e=D(e)),H(t,e)}function C(t,e){if(!M(t))throw new TypeError;return j(e)||(e=D(e)),B(t,e)}function E(t,e,r){if(!M(e))throw new TypeError;j(r)||(r=D(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 b(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!j(n)&&!N(n)){if(!G(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)&&!N(i)){if(!M(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(P(t,e,r))return!0;var n=X(e);return!N(n)&&k(t,n,r)}function P(t,e,r){var n=R(e,r,!1);return!j(n)&&W(n.has(t))}function T(t,e,r){if(P(t,e,r))return O(t,e,r);var n=X(e);return N(n)?void 0:T(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=B(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 B(t,e){var r=[],n=R(t,e,!1);if(j(n))return r;for(var o=V(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 N(t){return null===t}function I(t){return"symbol"==typeof t}function M(t){return"object"==typeof t?null!==t:"function"==typeof t}function U(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=q(t,n);if(void 0!==o){var i=o.call(t,r);if(M(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(z(r))if(!M(o=r.call(t)))return o;if(z(n=t.valueOf))if(!M(o=n.call(t)))return o}else{var n;if(z(n=t.valueOf))if(!M(o=n.call(t)))return o;var o,i=t.toString;if(z(i))if(!M(o=i.call(t)))return o}throw new TypeError}function W(t){return!!t}function F(t){return""+t}function D(t){var e=U(t,3);return I(e)?e:F(e)}function J(t){return Array.isArray?Array.isArray(t):t instanceof Object?t instanceof Array:"[object Array]"===Object.prototype.toString.call(t)}function z(t){return"function"==typeof t}function G(t){return"function"==typeof t}function $(t){switch(x(t)){case 3:case 4:return!0;default:return!1}}function q(t,e){var r=t[e];if(null!=r){if(!z(r))throw new TypeError;return r}}function V(t){var e=q(t,o);if(!z(e))throw new TypeError;var r=e.call(t);if(!M(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",v),t("hasOwnMetadata",w),t("getMetadata",m),t("getOwnMetadata",S),t("getMetadataKeys",A),t("getOwnMetadataKeys",C),t("deleteMetadata",E)}(n)}()}(e||(e={}));class a{static toArrayBuffer(t){const e=this.toUint8Array(t);return e.byteOffset||e.length?e.buffer.slice(e.byteOffset,e.byteOffset+e.length):e.buffer}static toUint8Array(t){if("undefined"!=typeof Buffer&&Buffer.isBuffer(t))return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(t instanceof ArrayBuffer)return new Uint8Array(t);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||t instanceof ArrayBuffer}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&t.buffer instanceof ArrayBuffer}}function c(t){return"undefined"!=typeof Buffer&&Buffer.isBuffer(t)?new Uint8Array(t):a.isArrayBufferView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t)}class u{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=c(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);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);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){const e=c(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(!u.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(!u.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){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 ToUtf8String(t){const e=c(t),r=String.fromCharCode.apply(null,e);return decodeURIComponent(escape(r))}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=c(t);let r="";const n=e.length;for(let t=0;t<n;t++)r+=String.fromCharCode(e[t]);return r}static ToHex(t){const e=c(t),r=[],n=e.length;for(let t=0;t<n;t++){const n=e[t].toString(16);r.push(1===n.length?"0"+n:n)}return r.join("")}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!u.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 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,""))||""}}!function(t){t[t.ok=200]="ok",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"}(r||(r={}));class h extends Error{constructor(t,e="",n=r.internalServerError,o){super(e),this.type=t,this.message=e,this.status=n,this.inner=o,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"}(n||(n={}));class f{constructor(t,e){var r;if(this.content=new ArrayBuffer(0),"string"==typeof t)this.content=u.FromUtf8String(t),this.type=n.pem;else if(t instanceof h)this.content=u.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=n.problemJson;else if(a.isBufferSource(t)){if(!e)throw new TypeError("Cannot get required argument 'type'");this.content=a.toArrayBuffer(t),this.type=e}else{const r=e?JSON.stringify(t,null," "):JSON.stringify(t);this.content=u.FromUtf8String(r),this.type=n.json}}toJSON(){return JSON.parse(this.toString())}toString(){return u.ToUtf8String(this.content)}}class l extends Map{get location(){return this.get(l.LOCATION)||null}set location(t){t?this.set(l.LOCATION,t):this.delete(l.LOCATION)}get contentType(){var t,e;const r=this.get(l.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(l.LINK);return t?t.split(",").map((t=>t.trim())):null}setLink(t){let e=this.get(l.LINK);e?e+=`,${t}`:e=t,this.set(l.LINK,e)}get cacheControl(){return this.get(l.CACHE_CONTROL)||null}set cacheControl(t){t?this.set(l.CACHE_CONTROL,t):this.delete(l.CACHE_CONTROL)}get replayNonce(){return this.get(l.REPLAY_NONCE)||null}set replayNonce(t){t?this.set(l.REPLAY_NONCE,t):this.delete(l.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)}}l.REPLAY_NONCE="Replay-Nonce",l.LINK="Link",l.CONTENT_TYPE="Content-Type",l.LOCATION="Location",l.CACHE_CONTROL="Cache-Control";class p{constructor(){this.status=r.ok,this.headers=new l}json(){if(this.content)return this.content.toJSON();throw new Error("No content in ACME response")}}function y(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return 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"}(o||(o={})),function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"}(i||(i={}));var d=i,g=function(t,e){return(g=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}g(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function w(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 m(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 S(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(m(arguments[e]));return t}function A(t){return!!t.useClass}function C(t){return!!t.useFactory}var E=function(){function t(t){this.wrap=t,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct"]}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,S(e))}})),e},t}();function b(t){return"string"==typeof t||"symbol"==typeof t}function _(t){return"object"==typeof t&&"token"in t&&"transform"in t}function R(t){return!!t.useToken}function k(t){return null!=t.useValue}var P=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}(),T=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(P),O=function(){this.scopedResolutions=new Map};function K(t,e,r){var n,o,i=m(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=" "),S([n],r.message.split("\n").map((function(t){return o+t}))).join("\n")}var H,B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(P),x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(P),j=function(){this.preResolution=new B,this.postResolution=new x},N=new Map,I=new(function(){function t(t){this.parent=t,this._registry=new T,this.interceptors=new j}return t.prototype.register=function(t,e,r){var n;if(void 0===r&&(r={lifecycle:d.Transient}),n=function(t){return A(t)||k(t)||R(t)||C(t)}(e)?e:{useClass:e},R(n))for(var o=[t],i=n;null!=i;){var s=i.useToken;if(o.includes(s))throw new Error("Token registration cycle detected! "+S(o,[s]).join(" -> "));o.push(s);var a=this._registry.get(s);i=a&&R(a.provider)?a.provider:null}if((r.lifecycle===d.Singleton||r.lifecycle==d.ContainerScoped||r.lifecycle==d.ResolutionScoped)&&(k(n)||C(n)))throw new Error('Cannot use lifecycle "'+d[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(t,{provider:n,options:r}),this},t.prototype.registerType=function(t,e){return b(e)?this.register(t,{useToken:e}):this.register(t,{useClass:e})},t.prototype.registerInstance=function(t,e){return this.register(t,{useValue:e})},t.prototype.registerSingleton=function(t,e){if(b(t)){if(b(e))return this.register(t,{useToken:e},{lifecycle:d.Singleton});if(e)return this.register(t,{useClass:e},{lifecycle:d.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=t;return e&&!b(e)&&(r=e),this.register(t,{useClass:r},{lifecycle:d.Singleton})},t.prototype.resolve=function(t,e){void 0===e&&(e=new O);var r=this.getRegistration(t);if(!r&&b(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 E}(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=w(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=w(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(t.options.lifecycle===d.ResolutionScoped&&e.scopedResolutions.has(t))return e.scopedResolutions.get(t);var r,n=t.options.lifecycle===d.Singleton,o=t.options.lifecycle===d.ContainerScoped,i=n||o;return r=k(t.provider)?t.provider.useValue:R(t.provider)?i?t.instance||(t.instance=this.resolve(t.provider.useToken,e)):this.resolve(t.provider.useToken,e):A(t.provider)?i?t.instance||(t.instance=this.construct(t.provider.useClass,e)):this.construct(t.provider.useClass,e):C(t.provider)?t.provider.useFactory(this):this.construct(t.provider,e),t.options.lifecycle===d.ResolutionScoped&&e.scopedResolutions.set(t,r),r},t.prototype.resolveAll=function(t,e){var r=this;void 0===e&&(e=new O);var n=this.getAllRegistrations(t);if(!n&&b(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._registry.has(t)||e&&(this.parent||!1)&&this.parent.isRegistered(t,!0)},t.prototype.reset=function(){this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var t,e;try{for(var r=w(this._registry.entries()),n=r.next();!n.done;n=r.next()){var o=m(n.value,2),i=o[0],s=o[1];this._registry.setAll(i,s.filter((function(t){return!k(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,n=new t(this);try{for(var o=w(this._registry.entries()),i=o.next();!i.done;i=o.next()){var s=m(i.value,2),a=s[0],c=s[1];c.some((function(t){return t.options.lifecycle===d.ContainerScoped}))&&n._registry.setAll(a,c.map((function(t){return t.options.lifecycle===d.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.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 E)return t.createProxy((function(t){return r.resolve(t,e)}));var n=N.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(this.resolveParams(e,t));return new(t.bind.apply(t,S([void 0],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?_(n)?n.multiple?(i=r.resolve(n.transform)).transform.apply(i,S([r.resolveAll(n.token)],n.transformArgs)):(s=r.resolve(n.transform)).transform.apply(s,S([r.resolve(n.token,t)],n.transformArgs)):n.multiple?r.resolveAll(n.token):r.resolve(n.token,t):_(n)?(a=r.resolve(n.transform,t)).transform.apply(a,S([r.resolve(n.token,t)],n.transformArgs)):r.resolve(n,t)}catch(t){throw new Error(K(e,o,t))}}},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"}(H||(H={}));let M=class t{constructor(){this.level=H.info}error(t,e){this.write(H.error,t,e)}info(t,e){this.write(H.info,t,e)}warn(t,e){this.write(H.warn,t,e)}debug(t,e){this.write(H.debug,t,e)}write(t,e,r){if(this.checkLevel(t)){const n={level:H[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){const e=/at ([a-zA-Z0-9_.]+) \(/gm,r=t.stack;let n=null,o=3;for(;n=e.exec(r);)if(!o--)return n[1].split(".")[0];return"undefined"}}};M=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){N.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))}],M),I.register("ACME.Logger",M,{lifecycle:d.Singleton});class U{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 L,W,F,D;!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"}(L||(L={})),function(t){t.EC="EC",t.RSA="RSA",t.OctetSequence="oct",t.OctetStringKeyPairs="OKP"}(W||(W={}));class J{constructor(t,e={}){F.set(this,void 0),Object.assign(this,e),function(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");e.set(t,r)}(this,F,t)}async exportKey(...t){let e,r=["verify"],n=y(this,F);if(arguments.length<2)switch(n=t[0]||n,this.kty){case W.RSA:e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"};break;case W.EC:e={name:"ECDSA",namedCurve:this.crv};break;case W.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=L.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 L.SHA256:return u.ToHex(await this.digest(r,"SHA-256"));case L.SHA1:return u.ToHex(await this.digest(r,"SHA-1"));default:throw new Error(`Unsupported algorithm: ${t}`)}}async digest(t,e){return await y(this,F).subtle.digest({name:e},a.toUint8Array(u.FromUtf8String(t)))}async getPublicKey(){if(this.kty===W.EC)return this.getEcdsaPublicKey();if(this.kty===W.RSA)return this.getRsaPublicKey();throw new Error(`Unsupported type ${this.kty}`)}async getEcdsaPublicKey(){const t={name:"ECDSA",namedCurve:this.crv};return await y(this,F).subtle.importKey("jwk",this,t,!0,["verify"])}async getRsaPublicKey(){return await y(this,F).subtle.importKey("jwk",this,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}}F=new WeakMap;class z{constructor(t={},e){this.cryptoProvider=e,this.protected="e30",this.payload="",this.signature="",t.protected&&this.setProtected(t.protected),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 J(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=this.write(t)}getSignature(){return u.FromBase64Url(this.signature)}setSignature(t){this.signature=u.ToBase64Url(t)}read(t){const e=u.FromBase64Url(t),r=u.ToUtf8String(e);return""===r?"":JSON.parse(r)}write(t){const e=JSON.stringify(t),r=u.FromUtf8String(e);return u.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=U.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=u.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=U.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=U.fromAlgorithm({...t,...e.algorithm});if(!o)throw new Error("Cannot convert WebCrypto algorithm to JWA");n.alg=o,this.setProtected(n);const i=u.FromUtf8String(this.toStringSign()),s=await this.getCryptoProvider(r).subtle.sign(t,e,i);this.setSignature(s)}toStringSign(){return`${this.protected}.${this.payload}`}toJSON(){const t={};return this.protected&&(t.protected=this.protected),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 G{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,i;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 s=this.options.fetch;let a;if("GET"===e.method||"HEAD"===e.method)a=await s(t,{method:e.method,headers:e.headers||{}});else{const r=this.getCrypto(),o=e,i={method:"POST"},c={url:t,nonce:o.nonce};if("string"==typeof o.kid)c.kid=o.kid;else{const t=await this.getCrypto().subtle.exportKey("jwk",o.kid);c.jwk=new J(r,t)}const u=new z({protected:c,payload:o.method&&"POST-as-GET"!==o.method?o.body:""},this.getCrypto());await u.sign({hash:o.hash||this.options.defaultHash,...o.key.algorithm},o.key,r),i.body=u.toString(),i.headers={"Content-Type":n.joseJson},a=await s(t,i)}const c=new p;c.status=a.status,a.headers.forEach(((t,e)=>c.headers.set(e,t)));const u=await a.arrayBuffer();if(c.content=new f(u,(null===(r=c.headers.contentType)||void 0===r?void 0:r.mediaType)||n.json),this.options.debug&&console.log(`RESPONSE ${e.method} ${t}`),c.content&&(c.status<200||c.status>299)){if((null===(i=c.headers.contentType)||void 0===i?void 0:i.mediaType)===n.problemJson){const t=c.content.toJSON();throw this.options.debug&&console.log("RESPONSE",t),new h(t.type,t.detail,c.status)}{const t=c.content.toString();throw this.options.debug&&console.log("RESPONSE",t),new h(o.serverInternal,"Wrong Content-Type of ACME response. Must be application/problem+json. See inner exception for more details.",c.status,new globalThis.Error(t))}}const l=G.createResponse(c,e.convert(c));return this.options.debug&&console.log("RESPONSE",l),l}getCrypto(){if(!this.options.crypto)throw new Error("Cannot get 'crypto' option");return this.options.crypto}}(D=t.CRLReasons||(t.CRLReasons={}))[D.unspecified=0]="unspecified",D[D.keyCompromise=1]="keyCompromise",D[D.cACompromise=2]="cACompromise",D[D.affiliationChanged=3]="affiliationChanged",D[D.superseded=4]="superseded",D[D.cessationOfOperation=5]="cessationOfOperation",D[D.certificateHold=6]="certificateHold",D[D.removeFromCRL=8]="removeFromCRL",D[D.privilegeWithdrawn=9]="privilegeWithdrawn",D[D.aACompromise=10]="aACompromise";class $ extends G{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 $(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="");const r=await super.fetch(t,e);return this.readNonce(r),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={contact:t.contact,onlyReturnExisting:t.onlyReturnExisting,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 z({protected:{url:this.directory.keyChange,jwk:new J(r,await r.subtle.exportKey("jwk",t.publicKey))},payload:{account:e,oldKey:new J(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||$.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||$.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:u.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"){const r=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()});return"POST"===e&&await this.pause(2e3),r}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 retryAuthorization(t,e={}){let r="string"==typeof t?await this.getOrder(t):t,n=e.retries||$.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||$.INTERVAL)}return r}async getCertificate(t){return await this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>{if(!t.content)throw new Error("Cannot get content from ACME response");switch(t.content.type){case n.pem:return this.decodePem(t.content.toString());case n.pkix:return[t.content.content];case n.pkcs7:throw new Error("Not implemented");default:throw new Error("Not supported content type for certificate")}}})}async getEndpoint(t){return this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()})}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",u.FromBase64Url(t),{name:"HMAC",hash:"SHA-256"},!0,["sign"]),n=await this.getCrypto().subtle.exportKey("jwk",this.accountKey.publicKey),o=new z({protected:{kid:e},payload:n},this.getCrypto());return await o.sign(r.algorithm,r,this.getCrypto()),o}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(u.FromBase64(t))}return r}}return $.RETRIES=10,$.INTERVAL=1e3,t.ApiClient=$,t.BaseClient=G,Object.defineProperty(t,"__esModule",{value:!0}),t}({});
var acme=function(t){"use strict";var e,r,n,o,i,s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(t){!function(e){var r="object"==typeof s?s:"object"==typeof self?self:"object"==typeof this?this:Function("return this;")(),n=o(t);function o(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===r.Reflect?r.Reflect=t:n=o(r.Reflect,n),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(!z(t))throw new TypeError;if(!G(e))throw new TypeError;return b(t,e)}if(!z(t))throw new TypeError;if(!M(e))throw new TypeError;if(!M(n)&&!j(n)&&!N(n))throw new TypeError;return N(n)&&(n=void 0),_(t,e,r=D(r),n)}function d(t,e){function r(r,n){if(!M(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(!M(r))throw new TypeError;return j(n)||(n=D(n)),K(t,e,r,n)}function v(t,e,r){if(!M(e))throw new TypeError;return j(r)||(r=D(r)),k(t,e,r)}function w(t,e,r){if(!M(e))throw new TypeError;return j(r)||(r=D(r)),P(t,e,r)}function m(t,e,r){if(!M(e))throw new TypeError;return j(r)||(r=D(r)),T(t,e,r)}function S(t,e,r){if(!M(e))throw new TypeError;return j(r)||(r=D(r)),O(t,e,r)}function A(t,e){if(!M(t))throw new TypeError;return j(e)||(e=D(e)),H(t,e)}function C(t,e){if(!M(t))throw new TypeError;return j(e)||(e=D(e)),B(t,e)}function E(t,e,r){if(!M(e))throw new TypeError;j(r)||(r=D(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 b(t,e){for(var r=t.length-1;r>=0;--r){var n=(0,t[r])(e);if(!j(n)&&!N(n)){if(!G(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)&&!N(i)){if(!M(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(P(t,e,r))return!0;var n=X(e);return!N(n)&&k(t,n,r)}function P(t,e,r){var n=R(e,r,!1);return!j(n)&&W(n.has(t))}function T(t,e,r){if(P(t,e,r))return O(t,e,r);var n=X(e);return N(n)?void 0:T(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=B(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 B(t,e){var r=[],n=R(t,e,!1);if(j(n))return r;for(var o=V(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 N(t){return null===t}function I(t){return"symbol"==typeof t}function M(t){return"object"==typeof t?null!==t:"function"==typeof t}function U(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=q(t,n);if(void 0!==o){var i=o.call(t,r);if(M(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(!M(o=r.call(t)))return o;if(J(n=t.valueOf))if(!M(o=n.call(t)))return o}else{var n;if(J(n=t.valueOf))if(!M(o=n.call(t)))return o;var o,i=t.toString;if(J(i))if(!M(o=i.call(t)))return o}throw new TypeError}function W(t){return!!t}function F(t){return""+t}function D(t){var e=U(t,3);return I(e)?e:F(e)}function z(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 G(t){return"function"==typeof t}function $(t){switch(x(t)){case 3:case 4:return!0;default:return!1}}function q(t,e){var r=t[e];if(null!=r){if(!J(r))throw new TypeError;return r}}function V(t){var e=q(t,o);if(!J(e))throw new TypeError;var r=e.call(t);if(!M(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",v),t("hasOwnMetadata",w),t("getMetadata",m),t("getOwnMetadata",S),t("getMetadataKeys",A),t("getOwnMetadataKeys",C),t("deleteMetadata",E)}(n)}()}(e||(e={}));class a{static isArrayBuffer(t){return"[object ArrayBuffer]"===Object.prototype.toString.call(t)}static toArrayBuffer(t){const e=this.toUint8Array(t);return e.byteOffset||e.length?e.buffer.slice(e.byteOffset,e.byteOffset+e.length):e.buffer}static toUint8Array(t){if("undefined"!=typeof Buffer&&Buffer.isBuffer(t))return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(this.isArrayBuffer(t))return new Uint8Array(t);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)}}function c(t){return"undefined"!=typeof Buffer&&Buffer.isBuffer(t)?new Uint8Array(t):a.isArrayBufferView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t)}class u{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=c(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);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);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){const e=c(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(!u.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(!u.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){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 ToUtf8String(t){const e=c(t),r=String.fromCharCode.apply(null,e);return decodeURIComponent(escape(r))}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=c(t);let r="";const n=e.length;for(let t=0;t<n;t++)r+=String.fromCharCode(e[t]);return r}static ToHex(t){const e=c(t),r=[],n=e.length;for(let t=0;t<n;t++){const n=e[t].toString(16);r.push(1===n.length?"0"+n:n)}return r.join("")}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!u.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 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,""))||""}}!function(t){t[t.ok=200]="ok",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"}(r||(r={}));class h extends Error{constructor(t,e="",n=r.internalServerError,o){super(e),this.type=t,this.message=e,this.status=n,this.inner=o,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"}(n||(n={}));class f{constructor(t,e){var r;if(this.content=new ArrayBuffer(0),"string"==typeof t)this.content=u.FromUtf8String(t),this.type=n.pem;else if(t instanceof h)this.content=u.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=n.problemJson;else if(a.isBufferSource(t)){if(!e)throw new TypeError("Cannot get required argument 'type'");this.content=a.toArrayBuffer(t),this.type=e}else{const r=e?JSON.stringify(t,null," "):JSON.stringify(t);this.content=u.FromUtf8String(r),this.type=n.json}}toJSON(){return JSON.parse(this.toString())}toString(){return u.ToUtf8String(this.content)}}class l extends Map{get location(){return this.get(l.LOCATION)||null}set location(t){t?this.set(l.LOCATION,t):this.delete(l.LOCATION)}get contentType(){var t,e;const r=this.get(l.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(l.LINK);return t?t.split(",").map((t=>t.trim())):null}setLink(t){let e=this.get(l.LINK);e?e+=`,${t}`:e=t,this.set(l.LINK,e)}get cacheControl(){return this.get(l.CACHE_CONTROL)||null}set cacheControl(t){t?this.set(l.CACHE_CONTROL,t):this.delete(l.CACHE_CONTROL)}get replayNonce(){return this.get(l.REPLAY_NONCE)||null}set replayNonce(t){t?this.set(l.REPLAY_NONCE,t):this.delete(l.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)}}l.REPLAY_NONCE="Replay-Nonce",l.LINK="Link",l.CONTENT_TYPE="Content-Type",l.LOCATION="Location",l.CACHE_CONTROL="Cache-Control";class p{constructor(){this.status=r.ok,this.headers=new l}json(){if(this.content)return this.content.toJSON();throw new Error("No content in ACME response")}}function y(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return 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"}(o||(o={})),function(t){t[t.Transient=0]="Transient",t[t.Singleton=1]="Singleton",t[t.ResolutionScoped=2]="ResolutionScoped",t[t.ContainerScoped=3]="ContainerScoped"}(i||(i={}));var d=i,g=function(t,e){return(g=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}g(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function w(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 m(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 S(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(m(arguments[e]));return t}function A(t){return!!t.useClass}function C(t){return!!t.useFactory}var E=function(){function t(t){this.wrap=t,this.reflectMethods=["get","getPrototypeOf","setPrototypeOf","getOwnPropertyDescriptor","defineProperty","has","set","deleteProperty","apply","construct"]}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,S(e))}})),e},t}();function b(t){return"string"==typeof t||"symbol"==typeof t}function _(t){return"object"==typeof t&&"token"in t&&"transform"in t}function R(t){return!!t.useToken}function k(t){return null!=t.useValue}var P=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}(),T=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(P),O=function(){this.scopedResolutions=new Map};function K(t,e,r){var n,o,i=m(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=" "),S([n],r.message.split("\n").map((function(t){return o+t}))).join("\n")}var H,B=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(P),x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return v(e,t),e}(P),j=function(){this.preResolution=new B,this.postResolution=new x},N=new Map,I=new(function(){function t(t){this.parent=t,this._registry=new T,this.interceptors=new j}return t.prototype.register=function(t,e,r){var n;if(void 0===r&&(r={lifecycle:d.Transient}),n=function(t){return A(t)||k(t)||R(t)||C(t)}(e)?e:{useClass:e},R(n))for(var o=[t],i=n;null!=i;){var s=i.useToken;if(o.includes(s))throw new Error("Token registration cycle detected! "+S(o,[s]).join(" -> "));o.push(s);var a=this._registry.get(s);i=a&&R(a.provider)?a.provider:null}if((r.lifecycle===d.Singleton||r.lifecycle==d.ContainerScoped||r.lifecycle==d.ResolutionScoped)&&(k(n)||C(n)))throw new Error('Cannot use lifecycle "'+d[r.lifecycle]+'" with ValueProviders or FactoryProviders');return this._registry.set(t,{provider:n,options:r}),this},t.prototype.registerType=function(t,e){return b(e)?this.register(t,{useToken:e}):this.register(t,{useClass:e})},t.prototype.registerInstance=function(t,e){return this.register(t,{useValue:e})},t.prototype.registerSingleton=function(t,e){if(b(t)){if(b(e))return this.register(t,{useToken:e},{lifecycle:d.Singleton});if(e)return this.register(t,{useClass:e},{lifecycle:d.Singleton});throw new Error('Cannot register a type name as a singleton without a "to" token')}var r=t;return e&&!b(e)&&(r=e),this.register(t,{useClass:r},{lifecycle:d.Singleton})},t.prototype.resolve=function(t,e){void 0===e&&(e=new O);var r=this.getRegistration(t);if(!r&&b(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 E}(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=w(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=w(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(t.options.lifecycle===d.ResolutionScoped&&e.scopedResolutions.has(t))return e.scopedResolutions.get(t);var r,n=t.options.lifecycle===d.Singleton,o=t.options.lifecycle===d.ContainerScoped,i=n||o;return r=k(t.provider)?t.provider.useValue:R(t.provider)?i?t.instance||(t.instance=this.resolve(t.provider.useToken,e)):this.resolve(t.provider.useToken,e):A(t.provider)?i?t.instance||(t.instance=this.construct(t.provider.useClass,e)):this.construct(t.provider.useClass,e):C(t.provider)?t.provider.useFactory(this):this.construct(t.provider,e),t.options.lifecycle===d.ResolutionScoped&&e.scopedResolutions.set(t,r),r},t.prototype.resolveAll=function(t,e){var r=this;void 0===e&&(e=new O);var n=this.getAllRegistrations(t);if(!n&&b(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._registry.has(t)||e&&(this.parent||!1)&&this.parent.isRegistered(t,!0)},t.prototype.reset=function(){this._registry.clear(),this.interceptors.preResolution.clear(),this.interceptors.postResolution.clear()},t.prototype.clearInstances=function(){var t,e;try{for(var r=w(this._registry.entries()),n=r.next();!n.done;n=r.next()){var o=m(n.value,2),i=o[0],s=o[1];this._registry.setAll(i,s.filter((function(t){return!k(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,n=new t(this);try{for(var o=w(this._registry.entries()),i=o.next();!i.done;i=o.next()){var s=m(i.value,2),a=s[0],c=s[1];c.some((function(t){return t.options.lifecycle===d.ContainerScoped}))&&n._registry.setAll(a,c.map((function(t){return t.options.lifecycle===d.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.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 E)return t.createProxy((function(t){return r.resolve(t,e)}));var n=N.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(this.resolveParams(e,t));return new(t.bind.apply(t,S([void 0],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?_(n)?n.multiple?(i=r.resolve(n.transform)).transform.apply(i,S([r.resolveAll(n.token)],n.transformArgs)):(s=r.resolve(n.transform)).transform.apply(s,S([r.resolve(n.token,t)],n.transformArgs)):n.multiple?r.resolveAll(n.token):r.resolve(n.token,t):_(n)?(a=r.resolve(n.transform,t)).transform.apply(a,S([r.resolve(n.token,t)],n.transformArgs)):r.resolve(n,t)}catch(t){throw new Error(K(e,o,t))}}},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"}(H||(H={}));let M=class t{constructor(){this.level=H.info}error(t,e){this.write(H.error,t,e)}info(t,e){this.write(H.info,t,e)}warn(t,e){this.write(H.warn,t,e)}debug(t,e){this.write(H.debug,t,e)}write(t,e,r){if(this.checkLevel(t)){const n={level:H[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){const e=/at ([a-zA-Z0-9_.]+) \(/gm,r=t.stack;let n=null,o=3;for(;n=e.exec(r);)if(!o--)return n[1].split(".")[0];return"undefined"}}};M=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){N.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))}],M),I.register("ACME.Logger",M,{lifecycle:d.Singleton});class U{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 L,W,F,D;!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"}(L||(L={})),function(t){t.EC="EC",t.RSA="RSA",t.OctetSequence="oct",t.OctetStringKeyPairs="OKP"}(W||(W={}));class z{constructor(t,e={}){F.set(this,void 0),Object.assign(this,e),function(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");e.set(t,r)}(this,F,t)}async exportKey(...t){let e,r=["verify"],n=y(this,F);if(arguments.length<2)switch(n=t[0]||n,this.kty){case W.RSA:e={name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"};break;case W.EC:e={name:"ECDSA",namedCurve:this.crv};break;case W.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=L.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 L.SHA256:return u.ToHex(await this.digest(r,"SHA-256"));case L.SHA1:return u.ToHex(await this.digest(r,"SHA-1"));default:throw new Error(`Unsupported algorithm: ${t}`)}}async digest(t,e){return await y(this,F).subtle.digest({name:e},a.toUint8Array(u.FromUtf8String(t)))}async getPublicKey(){if(this.kty===W.EC)return this.getEcdsaPublicKey();if(this.kty===W.RSA)return this.getRsaPublicKey();throw new Error(`Unsupported type ${this.kty}`)}async getEcdsaPublicKey(){const t={name:"ECDSA",namedCurve:this.crv};return await y(this,F).subtle.importKey("jwk",this,t,!0,["verify"])}async getRsaPublicKey(){return await y(this,F).subtle.importKey("jwk",this,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}}F=new WeakMap;class J{constructor(t={},e){this.cryptoProvider=e,this.protected="e30",this.payload="",this.signature="",t.protected&&this.setProtected(t.protected),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 z(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=this.write(t)}getSignature(){return u.FromBase64Url(this.signature)}setSignature(t){this.signature=u.ToBase64Url(t)}read(t){const e=u.FromBase64Url(t),r=u.ToUtf8String(e);return""===r?"":JSON.parse(r)}write(t){const e=JSON.stringify(t),r=u.FromUtf8String(e);return u.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=U.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=u.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=U.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=U.fromAlgorithm({...t,...e.algorithm});if(!o)throw new Error("Cannot convert WebCrypto algorithm to JWA");n.alg=o,this.setProtected(n);const i=u.FromUtf8String(this.toStringSign()),s=await this.getCryptoProvider(r).subtle.sign(t,e,i);this.setSignature(s)}toStringSign(){return`${this.protected}.${this.payload}`}toJSON(){const t={};return this.protected&&(t.protected=this.protected),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 G{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,i;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 s=this.options.fetch;let a;if("GET"===e.method||"HEAD"===e.method)a=await s(t,{method:e.method,headers:e.headers||{}});else{const r=this.getCrypto(),o=e,i={method:"POST"},c={url:t,nonce:o.nonce};if("string"==typeof o.kid)c.kid=o.kid;else{const t=await this.getCrypto().subtle.exportKey("jwk",o.kid);c.jwk=new z(r,t)}const u=new J({protected:c,payload:o.method&&"POST-as-GET"!==o.method?o.body:""},this.getCrypto());await u.sign({hash:o.hash||this.options.defaultHash,...o.key.algorithm},o.key,r),i.body=u.toString(),i.headers={"Content-Type":n.joseJson},a=await s(t,i)}const c=new p;c.status=a.status,a.headers.forEach(((t,e)=>c.headers.set(e,t)));const u=await a.arrayBuffer();if(c.content=new f(u,(null===(r=c.headers.contentType)||void 0===r?void 0:r.mediaType)||n.json),this.options.debug&&console.log(`RESPONSE ${e.method} ${t}`),c.content&&(c.status<200||c.status>299)){if((null===(i=c.headers.contentType)||void 0===i?void 0:i.mediaType)===n.problemJson){const t=c.content.toJSON();throw this.options.debug&&console.log("RESPONSE",t),new h(t.type,t.detail,c.status)}{const t=c.content.toString();throw this.options.debug&&console.log("RESPONSE",t),new h(o.serverInternal,"Wrong Content-Type of ACME response. Must be application/problem+json. See inner exception for more details.",c.status,new globalThis.Error(t))}}const l=G.createResponse(c,e.convert(c));return this.options.debug&&console.log("RESPONSE",l),l}getCrypto(){if(!this.options.crypto)throw new Error("Cannot get 'crypto' option");return this.options.crypto}}t.CRLReasons=void 0,(D=t.CRLReasons||(t.CRLReasons={}))[D.unspecified=0]="unspecified",D[D.keyCompromise=1]="keyCompromise",D[D.cACompromise=2]="cACompromise",D[D.affiliationChanged=3]="affiliationChanged",D[D.superseded=4]="superseded",D[D.cessationOfOperation=5]="cessationOfOperation",D[D.certificateHold=6]="certificateHold",D[D.removeFromCRL=8]="removeFromCRL",D[D.privilegeWithdrawn=9]="privilegeWithdrawn",D[D.aACompromise=10]="aACompromise";class $ extends G{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 $(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="");const r=await super.fetch(t,e);return this.readNonce(r),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={contact:t.contact,onlyReturnExisting:t.onlyReturnExisting,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 J({protected:{url:this.directory.keyChange,jwk:new z(r,await r.subtle.exportKey("jwk",t.publicKey))},payload:{account:e,oldKey:new z(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||$.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||$.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:u.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"){const r=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()});return"POST"===e&&await this.pause(2e3),r}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||$.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||$.INTERVAL)}return r}async getCertificate(t){return await this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>{if(!t.content)throw new Error("Cannot get content from ACME response");switch(t.content.type){case n.pem:return this.decodePem(t.content.toString());case n.pkix:return[t.content.content];case n.pkcs7:throw new Error("Not implemented");default:throw new Error("Not supported content type for certificate")}}})}async getEndpoint(t){return this.fetch(t,{method:"POST-as-GET",kid:this.getAccountId(),nonce:this.nonce,key:this.accountKey.privateKey,convert:t=>t.json()})}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",u.FromBase64Url(t),{name:"HMAC",hash:"SHA-256"},!0,["sign"]),n=await this.getCrypto().subtle.exportKey("jwk",this.accountKey.publicKey),o=new J({protected:{kid:e},payload:n},this.getCrypto());return await o.sign(r.algorithm,r,this.getCrypto()),o}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(u.FromBase64(t))}return r}}return $.RETRIES=10,$.INTERVAL=1e3,t.ApiClient=$,t.BaseClient=G,Object.defineProperty(t,"__esModule",{value:!0}),t}({});

@@ -223,2 +223,15 @@ "use strict";

}
async newAuthorization(params) {
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: params,
convert: (resp) => resp.json(),
});
}
async retryAuthorization(param, options = {}) {

@@ -225,0 +238,0 @@ let authz = typeof param === "string"

@@ -220,2 +220,15 @@ import { ContentType } from "@peculiar/acme-core";

}
async newAuthorization(params) {
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: params,
convert: (resp) => resp.json(),
});
}
async retryAuthorization(param, options = {}) {

@@ -222,0 +235,0 @@ let authz = typeof param === "string"

@@ -181,2 +181,3 @@ import { Response, Content } from "@peculiar/acme-core";

getAuthorization(url: string): Promise<ApiResponse<protocol.Authorization>>;
newAuthorization(params: protocol.AuthorizationCreateParams): Promise<ApiResponse<protocol.Authorization>>;
retryAuthorization(order: ApiResponse<protocol.Authorization>, options?: RetryOptions): Promise<ApiResponse<protocol.Authorization>>;

@@ -183,0 +184,0 @@ retryAuthorization(url: string, options?: RetryOptions): Promise<ApiResponse<protocol.Authorization>>;

@@ -6,2 +6,13 @@ # Change Log

## [1.5.2](https://github.com/PeculiarVentures/acme-ts/compare/v1.5.1...v1.5.2) (2021-02-26)
### Features
* Implement new-authz controller ([26fdb14](https://github.com/PeculiarVentures/acme-ts/commit/26fdb1453fb8ac559573fb79f29f1875629ee88a))
## [1.5.1](https://github.com/PeculiarVentures/acme-ts/compare/v1.5.0...v1.5.1) (2021-02-08)

@@ -8,0 +19,0 @@

{
"name": "@peculiar/acme-client",
"version": "1.5.1",
"version": "1.5.2",
"description": "Automatic Certificate Management Environment (ACME) client",

@@ -47,19 +47,19 @@ "keywords": [

"dependencies": {
"@peculiar/acme-core": "^1.5.1",
"@peculiar/acme-core": "^1.5.2",
"@peculiar/acme-protocol": "^1.4.2",
"@peculiar/asn1-x509": "2.0.27",
"@peculiar/jose": "^1.4.2",
"pvtsutils": "1.1.1"
"@peculiar/jose": "^1.5.2",
"pvtsutils": "1.1.2"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/preset-env": "^7.12.7",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-node-resolve": "^11.0.0",
"rollup": "^2.34.2",
"@babel/core": "^7.13.1",
"@babel/preset-env": "^7.13.5",
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"rollup": "^2.39.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.29.0"
"rollup-plugin-typescript2": "^0.30.0"
},
"gitHead": "b42ea0844fec223916352dd50858f52bfebcbfd3"
"gitHead": "df8eb06e75fea6e81b60a8d042107ace04979b12"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc