UNPKG

@cryptr/cryptr-spa-js

Version:

Cryptr SDK for Single Page Applications using passwordless authentication and/or SSO

125 lines (69 loc) 130 kB
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; function commonjsRequire () { throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs'); } function unwrapExports (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } function getCjsExportFromNamespace (n) { return n && n['default'] || n; } var asyncToGenerator=createCommonjsModule((function(o){function e(o,e,r,n,t,s,a){try{var c=o[s](a),u=c.value;}catch(o){return void r(o)}c.done?e(u):Promise.resolve(u).then(n,t);}o.exports=function(o){return function(){var r=this,n=arguments;return new Promise((function(t,s){var a=o.apply(r,n);function c(o){e(a,t,s,c,u,"next",o);}function u(o){e(a,t,s,c,u,"throw",o);}c(void 0);}))}},o.exports.__esModule=!0,o.exports.default=o.exports;}));var _asyncToGenerator = unwrapExports(asyncToGenerator); var _typeof_1=createCommonjsModule((function(o){function e(t){return o.exports=e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},o.exports.__esModule=!0,o.exports.default=o.exports,e(t)}o.exports=e,o.exports.__esModule=!0,o.exports.default=o.exports;}));unwrapExports(_typeof_1); var regeneratorRuntime$1=createCommonjsModule((function(t){var r=_typeof_1.default;function e(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */t.exports=e=function(){return o},t.exports.__esModule=!0,t.exports.default=t.exports;var n,o={},i=Object.prototype,a=i.hasOwnProperty,c=Object.defineProperty||function(t,r,e){t[r]=e.value;},u="function"==typeof Symbol?Symbol:{},s=u.iterator||"@@iterator",l=u.asyncIterator||"@@asyncIterator",f=u.toStringTag||"@@toStringTag";function h(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{h({},"");}catch(n){h=function(t,r,e){return t[r]=e};}function p(t,r,e,n){var o=r&&r.prototype instanceof x?r:x,i=Object.create(o.prototype),a=new F(n||[]);return c(i,"_invoke",{value:N(t,e,a)}),i}function y(t,r,e){try{return {type:"normal",arg:t.call(r,e)}}catch(t){return {type:"throw",arg:t}}}o.wrap=p;var v="suspendedStart",d="suspendedYield",m="executing",g="completed",w={};function x(){}function L(){}function b(){}var E={};h(E,s,(function(){return this}));var j=Object.getPrototypeOf,_=j&&j(j(H([])));_&&_!==i&&a.call(_,s)&&(E=_);var O=b.prototype=x.prototype=Object.create(E);function k(t){["next","throw","return"].forEach((function(r){h(t,r,(function(t){return this._invoke(r,t)}));}));}function G(t,e){function n(o,i,c,u){var s=y(t[o],t,i);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==r(f)&&a.call(f,"__await")?e.resolve(f.__await).then((function(t){n("next",t,c,u);}),(function(t){n("throw",t,c,u);})):e.resolve(f).then((function(t){l.value=t,c(l);}),(function(t){return n("throw",t,c,u)}))}u(s.arg);}var o;c(this,"_invoke",{value:function(t,r){function i(){return new e((function(e,o){n(t,r,e,o);}))}return o=o?o.then(i,i):i()}});}function N(t,r,e){var o=v;return function(i,a){if(o===m)throw new Error("Generator is already running");if(o===g){if("throw"===i)throw a;return {value:n,done:!0}}for(e.method=i,e.arg=a;;){var c=e.delegate;if(c){var u=P(c,e);if(u){if(u===w)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if(o===v)throw o=g,e.arg;e.dispatchException(e.arg);}else "return"===e.method&&e.abrupt("return",e.arg);o=m;var s=y(t,r,e);if("normal"===s.type){if(o=e.done?g:d,s.arg===w)continue;return {value:s.arg,done:e.done}}"throw"===s.type&&(o=g,e.method="throw",e.arg=s.arg);}}}function P(t,r){var e=r.method,o=t.iterator[e];if(o===n)return r.delegate=null,"throw"===e&&t.iterator.return&&(r.method="return",r.arg=n,P(t,r),"throw"===r.method)||"return"!==e&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+e+"' method")),w;var i=y(o,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,w;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=n),r.delegate=null,w):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,w)}function S(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r);}function T(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r;}function F(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0);}function H(t){if(t||""===t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(a.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=n,r.done=!0,r};return i.next=i}}throw new TypeError(r(t)+" is not iterable")}return L.prototype=b,c(O,"constructor",{value:b,configurable:!0}),c(b,"constructor",{value:L,configurable:!0}),L.displayName=h(b,f,"GeneratorFunction"),o.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return !!r&&(r===L||"GeneratorFunction"===(r.displayName||r.name))},o.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,h(t,f,"GeneratorFunction")),t.prototype=Object.create(O),t},o.awrap=function(t){return {__await:t}},k(G.prototype),h(G.prototype,l,(function(){return this})),o.AsyncIterator=G,o.async=function(t,r,e,n,i){void 0===i&&(i=Promise);var a=new G(p(t,r,e,n),i);return o.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(O),h(O,f,"Generator"),h(O,s,(function(){return this})),h(O,"toString",(function(){return "[object Generator]"})),o.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},o.values=H,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=n,this.done=!1,this.delegate=null,this.method="next",this.arg=n,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=n);},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function e(e,o){return c.type="throw",c.arg=t,r.next=e,o&&(r.method="next",r.arg=n),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return e("end");if(i.tryLoc<=this.prev){var u=a.call(i,"catchLoc"),s=a.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return e(i.catchLoc,!0);if(this.prev<i.finallyLoc)return e(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return e(i.catchLoc,!0)}else {if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return e(i.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=r,o?(this.method="next",this.next=o.finallyLoc,w):this.complete(i)},complete:function(t,r){if("throw"===t.type)throw t.arg;return "break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),w},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),T(e),w}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;T(e);}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:H(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=n),w}},o}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports;}));unwrapExports(regeneratorRuntime$1); var runtime=regeneratorRuntime$1(),regenerator=runtime;try{regeneratorRuntime=runtime;}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=runtime:Function("r","regeneratorRuntime = r")(runtime);} var arrayLikeToArray=createCommonjsModule((function(r){r.exports=function(r,e){(null==e||e>r.length)&&(e=r.length);for(var o=0,s=new Array(e);o<e;o++)s[o]=r[o];return s},r.exports.__esModule=!0,r.exports.default=r.exports;}));unwrapExports(arrayLikeToArray); var arrayWithoutHoles=createCommonjsModule((function(r){r.exports=function(r){if(Array.isArray(r))return arrayLikeToArray(r)},r.exports.__esModule=!0,r.exports.default=r.exports;}));unwrapExports(arrayWithoutHoles); var iterableToArray=createCommonjsModule((function(r){r.exports=function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)},r.exports.__esModule=!0,r.exports.default=r.exports;}));unwrapExports(iterableToArray); var unsupportedIterableToArray=createCommonjsModule((function(r){r.exports=function(r,o){if(r){if("string"==typeof r)return arrayLikeToArray(r,o);var e=Object.prototype.toString.call(r).slice(8,-1);return "Object"===e&&r.constructor&&(e=r.constructor.name),"Map"===e||"Set"===e?Array.from(r):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?arrayLikeToArray(r,o):void 0}},r.exports.__esModule=!0,r.exports.default=r.exports;}));unwrapExports(unsupportedIterableToArray); var nonIterableSpread=createCommonjsModule((function(e){e.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.__esModule=!0,e.exports.default=e.exports;}));unwrapExports(nonIterableSpread); var toConsumableArray=createCommonjsModule((function(r){r.exports=function(r){return arrayWithoutHoles(r)||iterableToArray(r)||unsupportedIterableToArray(r)||nonIterableSpread()},r.exports.__esModule=!0,r.exports.default=r.exports;}));var _toConsumableArray = unwrapExports(toConsumableArray); var classCallCheck=createCommonjsModule((function(o){o.exports=function(o,s){if(!(o instanceof s))throw new TypeError("Cannot call a class as a function")},o.exports.__esModule=!0,o.exports.default=o.exports;}));var _classCallCheck = unwrapExports(classCallCheck); var toPrimitive_1=createCommonjsModule((function(r){var e=_typeof_1.default;r.exports=function(r,o){if("object"!=e(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var i=t.call(r,o||"default");if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===o?String:Number)(r)},r.exports.__esModule=!0,r.exports.default=r.exports;}));unwrapExports(toPrimitive_1); var toPropertyKey_1=createCommonjsModule((function(o){var r=_typeof_1.default;o.exports=function(o){var e=toPrimitive_1(o,"string");return "symbol"==r(e)?e:String(e)},o.exports.__esModule=!0,o.exports.default=o.exports;}));unwrapExports(toPropertyKey_1); var createClass=createCommonjsModule((function(e){function o(e,o){for(var r=0;r<o.length;r++){var t=o[r];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(e,toPropertyKey_1(t.key),t);}}e.exports=function(e,r,t){return r&&o(e.prototype,r),t&&o(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports;}));var _createClass = unwrapExports(createClass); var defineProperty=createCommonjsModule((function(e){e.exports=function(e,o,r){return (o=toPropertyKey_1(o))in e?Object.defineProperty(e,o,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[o]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports;}));var _defineProperty = unwrapExports(defineProperty); var EXPIRATION_DAYS=30;var DEFAULT_REFRESH_ROTATION_DURATION=864e5*EXPIRATION_DAYS;var DEFAULT_LEEWAY_IN_SECONDS=60;var DEFAULT_REFRESH_RETRY=5;var DEFAULT_REFRESH_EXPIRATION=2592e3;var DEFAULT_SCOPE="openid email profile";var JWT="JWT";var RS256="RS256";var SHA256="S256";var STORAGE_KEY_PREFIX="$cryptr-spa-js$";var ALLOWED_LOCALES=["en","fr"];var ALLOWED_REGIONS=["eu","us"];var CRYPTR_EU_BASE_URL="https://auth.cryptr.eu",CRYPTR_US_BASE_URL="https://auth.cryptr.us";var cryptrBaseUrl=function(r){var e="You must provide region in values ".concat(ALLOWED_REGIONS," found '").concat(r.region,"', if not provide your cryptr_base_url");switch(r.region){case"eu":return CRYPTR_EU_BASE_URL;case"us":return CRYPTR_US_BASE_URL;case void 0:if(r.cryptr_base_url)return r.cryptr_base_url;throw new Error(e);default:throw new Error(e)}}; var Sign=function(r){return r.Refresh="refresh",r.Sso="sso",r}({}); function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o);}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}var locationSearch=function(){return null!=window&&void 0!==window.location?window.location.search:""};var parseRedirectParams=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:locationSearch(),t=new URLSearchParams(e);if(t.get("state")&&t.get("authorization_id")&&t.get("code")){var r={state:t.get("state")||"",authorization:{id:t.get("authorization_id")||"",code:t.get("code")||""}},o=t.get("organization_domain");null!=o&&""!=o&&(r=_objectSpread(_objectSpread({},r),{},{organization_domain:o}));var n=t.get("request_id");return null!=n&&""!=n&&(r=_objectSpread(_objectSpread({},r),{},{request_id:n})),r}throw new Error("Can not parse authorization params")};var organizationDomain=function(e){return e&&e.includes(".")?e.split(".")[0]:void 0}; class HTTPError extends Error{constructor(e,t,r){const s=`${e.status||0===e.status?e.status:""} ${e.statusText||""}`.trim();super(`Request failed with ${s?`status code ${s}`:"an unknown error"}`),Object.defineProperty(this,"response",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="HTTPError",this.response=e,this.request=t,this.options=r;}} class TimeoutError extends Error{constructor(e){super("Request timed out"),Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="TimeoutError",this.request=e;}} const isObject=t=>null!==t&&"object"==typeof t; const validateAndMerge=(...e)=>{for(const r of e)if((!isObject(r)||Array.isArray(r))&&void 0!==r)throw new TypeError("The `options` argument must be an object");return deepMerge({},...e)};const mergeHeaders=(e={},r={})=>{const s=new globalThis.Headers(e),t=r instanceof globalThis.Headers,o=new globalThis.Headers(r);for(const[e,r]of o.entries())t&&"undefined"===r||void 0===r?s.delete(e):s.set(e,r);return s};const deepMerge=(...e)=>{let r={},s={};for(const t of e)if(Array.isArray(t))Array.isArray(r)||(r=[]),r=[...r,...t];else if(isObject(t)){for(let[e,s]of Object.entries(t))isObject(s)&&e in r&&(s=deepMerge(r[e],s)),r={...r,[e]:s};isObject(t.headers)&&(s=mergeHeaders(s,t.headers),r.headers=s);}return r}; const supportsRequestStreams=(()=>{let e=!1,t=!1;const o="function"==typeof globalThis.ReadableStream,r="function"==typeof globalThis.Request;return o&&r&&(t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")),e&&!t})();const supportsAbortController="function"==typeof globalThis.AbortController;const supportsResponseStreams="function"==typeof globalThis.ReadableStream;const supportsFormData="function"==typeof globalThis.FormData;const requestMethods=["get","post","put","patch","head","delete"];const responseTypes={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*"};const maxSafeTimeout=2147483647;const stop=Symbol("stop");const kyOptionKeys={json:!0,parseJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,fetch:!0};const requestOptionsRegistry={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,dispatcher:!0,duplex:!0}; const normalizeRequestMethod=t=>requestMethods.includes(t)?t.toUpperCase():t;const retryMethods=["get","put","head","delete","options","trace"],retryStatusCodes=[408,413,429,500,502,503,504],retryAfterStatusCodes=[413,429,503],defaultRetryOptions={limit:2,methods:retryMethods,statusCodes:retryStatusCodes,afterStatusCodes:retryAfterStatusCodes,maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3};const normalizeRetryOptions=(t={})=>{if("number"==typeof t)return {...defaultRetryOptions,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return {...defaultRetryOptions,...t,afterStatusCodes:retryAfterStatusCodes}}; async function timeout(t,r,e,o){return new Promise(((i,m)=>{const u=setTimeout((()=>{e&&e.abort(),m(new TimeoutError(t));}),o.timeout);o.fetch(t,r).then(i).catch(m).then((()=>{clearTimeout(u);}));}))} async function delay(e,{signal:t}){return new Promise(((n,o)=>{function r(){clearTimeout(a),o(t.reason);}t&&(t.throwIfAborted(),t.addEventListener("abort",r,{once:!0}));const a=setTimeout((()=>{t?.removeEventListener("abort",r),n();}),e);}))} const findUnknownOptions=(n,t)=>{const o={};for(const s in t)s in requestOptionsRegistry||s in kyOptionKeys||s in n||(o[s]=t[s]);return o}; class Ky{static create(t,e){const s=new Ky(t,e),o=async()=>{if("number"==typeof s._options.timeout&&s._options.timeout>maxSafeTimeout)throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);await Promise.resolve();let t=await s._fetch();for(const e of s._options.hooks.afterResponse){const o=await e(s.request,s._options,s._decorateResponse(t.clone()));o instanceof globalThis.Response&&(t=o);}if(s._decorateResponse(t),!t.ok&&s._options.throwHttpErrors){let e=new HTTPError(t,s.request,s._options);for(const t of s._options.hooks.beforeError)e=await t(e);throw e}if(s._options.onDownloadProgress){if("function"!=typeof s._options.onDownloadProgress)throw new TypeError("The `onDownloadProgress` option must be a function");if(!supportsResponseStreams)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return s._stream(t.clone(),s._options.onDownloadProgress)}return t},r=s._options.retry.methods.includes(s.request.method.toLowerCase())?s._retry(o):o();for(const[t,o]of Object.entries(responseTypes))r[t]=async()=>{s.request.headers.set("accept",s.request.headers.get("accept")||o);const i=(await r).clone();if("json"===t){if(204===i.status)return "";if(0===(await i.clone().arrayBuffer()).byteLength)return "";if(e.parseJson)return e.parseJson(await i.text())}return i[t]()};return r}constructor(t,e={}){Object.defineProperty(this,"request",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"abortController",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_retryCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"_input",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_options",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._input=t;const s="credentials"in Request.prototype;if(this._options={credentials:s?this._input.credentials:void 0,...e,headers:mergeHeaders(this._input.headers,e.headers),hooks:deepMerge({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},e.hooks),method:normalizeRequestMethod(e.method??this._input.method),prefixUrl:String(e.prefixUrl||""),retry:normalizeRetryOptions(e.retry),throwHttpErrors:!1!==e.throwHttpErrors,timeout:e.timeout??1e4,fetch:e.fetch??globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input;}if(supportsAbortController){if(this.abortController=new globalThis.AbortController,this._options.signal){const t=this._options.signal;this._options.signal.addEventListener("abort",(()=>{this.abortController.abort(t.reason);}));}this._options.signal=this.abortController.signal;}if(supportsRequestStreams&&(this._options.duplex="half"),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const t="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^\?/,""):new URLSearchParams(this._options.searchParams).toString()),e=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,t);!(supportsFormData&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(e,{...this.request}),this._options);}void 0!==this._options.json&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",this._options.headers.get("content-type")??"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}));}_calculateRetryDelay(t){if(this._retryCount++,this._retryCount<=this._options.retry.limit&&!(t instanceof TimeoutError)){if(t instanceof HTTPError){if(!this._options.retry.statusCodes.includes(t.response.status))return 0;const e=t.response.headers.get("Retry-After");if(e&&this._options.retry.afterStatusCodes.includes(t.response.status)){let t=Number(e);return Number.isNaN(t)?t=Date.parse(e)-Date.now():t*=1e3,void 0!==this._options.retry.maxRetryAfter&&t>this._options.retry.maxRetryAfter?0:t}if(413===t.response.status)return 0}const e=this._options.retry.delay(this._retryCount);return Math.min(this._options.retry.backoffLimit,e)}return 0}_decorateResponse(t){return this._options.parseJson&&(t.json=async()=>this._options.parseJson(await t.text())),t}async _retry(t){try{return await t()}catch(e){const s=Math.min(this._calculateRetryDelay(e),maxSafeTimeout);if(0!==s&&this._retryCount>0){await delay(s,{signal:this._options.signal});for(const t of this._options.hooks.beforeRetry){if(await t({request:this.request,options:this._options,error:e,retryCount:this._retryCount})===stop)return}return this._retry(t)}throw e}}async _fetch(){for(const t of this._options.hooks.beforeRequest){const e=await t(this.request,this._options);if(e instanceof Request){this.request=e;break}if(e instanceof Response)return e}const t=findUnknownOptions(this.request,this._options);return !1===this._options.timeout?this._options.fetch(this.request.clone(),t):timeout(this.request.clone(),t,this.abortController,this._options)}_stream(t,e){const s=Number(t.headers.get("content-length"))||0;let o=0;return 204===t.status?(e&&e({percent:1,totalBytes:s,transferredBytes:o},new Uint8Array),new globalThis.Response(null,{status:t.status,statusText:t.statusText,headers:t.headers})):new globalThis.Response(new globalThis.ReadableStream({async start(r){const i=t.body.getReader();e&&e({percent:0,transferredBytes:0,totalBytes:s},new Uint8Array),await async function t(){const{done:n,value:a}=await i.read();if(n)r.close();else {if(e){o+=a.byteLength;e({percent:0===s?0:o/s,transferredBytes:o,totalBytes:s},a);}r.enqueue(a),await t();}}();}}),{status:t.status,statusText:t.statusText,headers:t.headers})}} /*! MIT License © Sindre Sorhus */ const createInstance=e=>{const r=(r,t)=>Ky.create(r,validateAndMerge(e,t));for(const t of requestMethods)r[t]=(r,o)=>Ky.create(r,validateAndMerge(e,o,{method:t}));return r.create=e=>createInstance(validateAndMerge(e)),r.extend=r=>createInstance(validateAndMerge(e,r)),r.stop=stop,r},ky=createInstance(); var API_VERSION="v1";var universalTokenParams=function(e,r,n,t){return {grant_type:"authorization_code",client_id:e.client_id,authorization_id:r.id,code:r.code,code_verifier:n.pkce.code_verifier,nonce:n.nonce,request_id:t,client_state:n.pkce.state}};var refreshTokensParams=function(e,r,n){return {client_id:e.client_id,grant_type:"refresh_token",nonce:r.nonce,token:n}};var revokeTokenUrl=function(e){return "".concat(cryptrBaseUrl(e),"/oauth/revoke")};var sloAfterRevokeTokenUrl=function(e,r,n,t){var o=organizationDomain(t),a=new URL(cryptrBaseUrl(e));return a.pathname="/api/".concat(API_VERSION,"/tenants/").concat(o||e.tenant_domain,"/").concat(e.client_id,"/oauth/token/slo-after-revoke-token"),a.searchParams.append("slo_code",r),a.searchParams.append("target_url",n),a};var decoratedKyOptions=function(e){return void 0!==e?{headers:{Authorization:"Bearer ".concat(e)}}:{}};var universalTokenUrl=function(e,r){return [cryptrBaseUrl(e),"org",r,"oauth2","token"].join("/")};var refreshTokensUrl=function(e){return "".concat(cryptrBaseUrl(e),"/oauth/token")};var Request$1={postUniversalAuthorizationCode:function(){var e=_asyncToGenerator(regenerator.mark((function e(r,n,t,o,a){var i,c;return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=universalTokenUrl(r,a),c=universalTokenParams(r,n,t,o),e.abrupt("return",ky.post(i,{json:c}).json());case 3:case"end":return e.stop()}}),e)})));return function(r,n,t,o,a){return e.apply(this,arguments)}}(),revokeAccessToken:function(){var e=_asyncToGenerator(regenerator.mark((function e(r,n){var t;return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=revokeTokenUrl(r),e.abrupt("return",ky.post(t,{json:{token:n,token_type_hint:"access_token",client_id:r.client_id}}).json());case 2:case"end":return e.stop()}}),e)})));return function(r,n){return e.apply(this,arguments)}}(),revokeRefreshToken:function(){var e=_asyncToGenerator(regenerator.mark((function e(r,n){var t;return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=revokeTokenUrl(r),e.abrupt("return",ky.post(t,{json:{token:n,token_type_hint:"refresh_token",client_id:r.client_id}}).json());case 2:case"end":return e.stop()}}),e)})));return function(r,n){return e.apply(this,arguments)}}(),refreshTokens:function(){var e=_asyncToGenerator(regenerator.mark((function e(r,n,t){var o;return regenerator.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=refreshTokensUrl(r),e.abrupt("return",ky.post(o,{json:refreshTokensParams(r,n,t)}).json());case 2:case"end":return e.stop()}}),e)})));return function(r,n,t){return e.apply(this,arguments)}}(),decoratedRequest:function(e,r,n){return ky.create(n||{}).extend(decoratedKyOptions(r))(e)}}; function stringifyAttribute(e,t){if(!t)return "";let n="; "+e;return !0===t?n:n+"="+t}function stringifyAttributes(e){if("number"==typeof e.expires){const t=Math.min(Date.now()+864e5*e.expires,864e13);e.expires=new Date(t);}return stringifyAttribute("Expires",e.expires?e.expires.toUTCString():"")+stringifyAttribute("Domain",e.domain)+stringifyAttribute("Path",e.path)+stringifyAttribute("Secure",e.secure)+stringifyAttribute("Partitioned",e.partitioned)+stringifyAttribute("SameSite",e.sameSite)}function encode(e,t,n){return encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/\(/g,"%28").replace(/\)/g,"%29")+"="+encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)+stringifyAttributes(n)}function parse(e){let t={};const n=e?e.split("; "):[];for(let e of n){const n=e.split("=");let i=n.slice(1).join("=");'"'===i[0]&&(i=i.slice(1,-1));try{t[decodeURIComponent(n[0])]=i.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent);}catch(e){}}return t}function getAll(){return parse(document.cookie)}function get(e){return getAll()[e]}function set(e,t,n){document.cookie=encode(e,t,{path:"/",...n});}function remove(e,t){set(e,"",{...t,expires:-1});} var storageKey=function(e){return "".concat(STORAGE_KEY_PREFIX,".store.").concat(e)},Storage={createCookie:function(e,o,t){if(t<new Date)throw new Error("cannot create cookie in past");var r={key:storageKey(e),body:JSON.stringify(o)},n={};return void 0!==window&&void 0!==window.location&&"https:"===window.location.protocol&&(n={secure:!0,sameSite:"none"}),n.expires=t,"undefined"!=typeof document&&set(r.key,r.body,n),r},getCookie:function(e){var o;return "undefined"!=typeof document&&(o=get(storageKey(e))),void 0===o?{}:JSON.parse(o)},deleteCookie:function(e){return "undefined"!=typeof document&&remove(storageKey(e)),!0},clearCookies:function(e){var o=storageKey(e);if("undefined"!=typeof document){var t=getAll();Object.keys(t).forEach((function(e){e.startsWith(storageKey("".concat(STORAGE_KEY_PREFIX,".transaction")))&&remove(e),e.startsWith(storageKey("".concat(STORAGE_KEY_PREFIX,".refresh")))&&remove(e);})),remove(o);}return !0}}; var getRandomValues,rnds8=new Uint8Array(16);function rng(){if(!getRandomValues&&!(getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)} var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; function validate(t){return "string"==typeof t&&REGEX.test(t)} for(var byteToHex=[],i=0;i<256;++i)byteToHex.push((i+256).toString(16).substr(1));function stringify(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=(byteToHex[e[t+0]]+byteToHex[e[t+1]]+byteToHex[e[t+2]]+byteToHex[e[t+3]]+"-"+byteToHex[e[t+4]]+byteToHex[e[t+5]]+"-"+byteToHex[e[t+6]]+byteToHex[e[t+7]]+"-"+byteToHex[e[t+8]]+byteToHex[e[t+9]]+"-"+byteToHex[e[t+10]]+byteToHex[e[t+11]]+byteToHex[e[t+12]]+byteToHex[e[t+13]]+byteToHex[e[t+14]]+byteToHex[e[t+15]]).toLowerCase();if(!validate(o))throw TypeError("Stringified UUID is invalid");return o} function v4(r,n,i){var t=(r=r||{}).random||(r.rng||rng)();if(t[6]=15&t[6]|64,t[8]=63&t[8]|128,n){i=i||0;for(var f=0;f<16;++f)n[i+f]=t[f];return n}return stringify(t)} var defaults=createCommonjsModule((function(s,e){Object.defineProperty(e,"__esModule",{value:!0}),e.endsInPath=e.hasProtocol=e.isHttps=e.DEFAULT_TESTING_CONFIG=void 0,e.DEFAULT_TESTING_CONFIG={disableHttpsCheck:!1},e.isHttps=new RegExp("^https://"),e.hasProtocol=new RegExp("://"),e.endsInPath=new RegExp("/$");}));unwrapExports(defaults);var defaults_1=defaults.endsInPath;var defaults_2=defaults.hasProtocol;var defaults_3=defaults.isHttps;var defaults_4=defaults.DEFAULT_TESTING_CONFIG; var functions=createCommonjsModule((function(t,e){var i,o=commonjsGlobal&&commonjsGlobal.__extends||(i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e;}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);},i(t,e)},function(t,e){function o(){this.constructor=t;}i(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o);});Object.defineProperty(e,"__esModule",{value:!0}),e.validAppBaseUrl=e.validRedirectUri=e.validClientSecret=e.validClientId=e.validIssuer=void 0;var r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return o(e,t),e}(Error);e.validIssuer=function(t,e){void 0===t&&(t=""),void 0===e&&(e=defaults.DEFAULT_TESTING_CONFIG);if(e.disableHttpsCheck){console.warn("Warning: HTTPS check is disabled.This allows for insecure configurations and is NOT recommended for production use.");}if(!t||""==t)throw new r("Your Cryptr URL issuer is missing.");if(!e.disableHttpsCheck&&!t.match(defaults.isHttps))throw new r("Your Cryptr URL issuer must start with https.Current value: "+t+". You can copy your domain from the Cryptr Developer ");if(t.match(/{yourCryptrDomain}/))throw new r("Replace {yourCryptrDomain} with your Cryptr domain.")},e.validClientId=function(t){if(void 0===t&&(t=""),!t||""==t)throw new r("Your client ID is missing.");if(t.match(/{client_id}/))throw new r("Replace "+t+" (client_id in cryptr.config.json) with the client ID of your Application.")},e.validClientSecret=function(t){if(void 0===t&&(t=""),!t||""==t)throw new r("Your client secret is missing.");if(t.match(/{clientSecret}/))throw new r("Replace {clientSecret} with the client secret of your Application.")},e.validRedirectUri=function(t){if(void 0===t&&(t=""),!t||""==t)throw new r("Your redirect URI is missing.");if(t.match(/{redirectUri}/))throw new r("Replace {redirectUri} with the redirect URI of your Application.")},e.validAppBaseUrl=function(t){if(void 0===t&&(t=""),!t||""==t)throw new r("Your appBaseUrl is missing.");if(t.match(/{appBaseUrl}/))throw new r("Replace {appBaseUrl} with the base URL of your Application.");if(!t.match(defaults.hasProtocol))throw new r("Your appBaseUrl must contain a protocol (e.g. https://). Current value: "+t+".");if(t.match(defaults.endsInPath))throw new r("Your appBaseUrl must not end in a '/'. Current value: "+t+".")};}));unwrapExports(functions);var functions_1=functions.validAppBaseUrl;var functions_2=functions.validRedirectUri;var functions_3=functions.validClientSecret;var functions_4=functions.validClientId;var functions_5=functions.validIssuer; var dist=createCommonjsModule((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.validClientId=t.validRedirectUri=t.validIssuer=t.validClientSecret=t.validAppBaseUrl=void 0,Object.defineProperty(t,"validAppBaseUrl",{enumerable:!0,get:function(){return functions.validAppBaseUrl}}),Object.defineProperty(t,"validClientSecret",{enumerable:!0,get:function(){return functions.validClientSecret}}),Object.defineProperty(t,"validIssuer",{enumerable:!0,get:function(){return functions.validIssuer}}),Object.defineProperty(t,"validRedirectUri",{enumerable:!0,get:function(){return functions.validRedirectUri}}),Object.defineProperty(t,"validClientId",{enumerable:!0,get:function(){return functions.validClientId}});}));unwrapExports(dist);var dist_1=dist.validClientId;var dist_2=dist.validRedirectUri;var dist_3=dist.validIssuer;var dist_4=dist.validClientSecret;var dist_5=dist.validAppBaseUrl; var sha256_1=function(r,n){function t(r,n){var t=(65535&r)+(65535&n);return (r>>16)+(n>>16)+(t>>16)<<16|65535&t}function e(r,n){return r>>>n|r<<32-n}function a(r,n){return r>>>n}function o(r,n,t){return r&n^~r&t}function u(r,n,t){return r&n^r&t^n&t}function f(r){return e(r,2)^e(r,13)^e(r,22)}function h(r){return e(r,6)^e(r,11)^e(r,25)}function c(r){return e(r,7)^e(r,18)^a(r,3)}var i,C=function(r){for(var n="0123456789abcdef",t="",e=0;e<4*r.length;e++)t+=n.charAt(r[e>>2]>>8*(3-e%4)+4&15)+n.charAt(r[e>>2]>>8*(3-e%4)&15);return t}(function(r,n){var i,C,g,l,d,s,p,v,A,m,S,x=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),y=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),_=new Array(64);r[n>>5]|=128<<24-n%32,r[15+(n+64>>9<<4)]=n;for(var b=0;b<r.length;b+=16){i=y[0],C=y[1],g=y[2],l=y[3],d=y[4],s=y[5],p=y[6],v=y[7];for(var w=0;w<64;w++)_[w]=w<16?r[w+b]:t(t(t(e(S=_[w-2],17)^e(S,19)^a(S,10),_[w-7]),c(_[w-15])),_[w-16]),A=t(t(t(t(v,h(d)),o(d,s,p)),x[w]),_[w]),m=t(f(i),u(i,C,g)),v=p,p=s,s=d,d=t(l,A),l=g,g=C,C=i,i=t(A,m);y[0]=t(i,y[0]),y[1]=t(C,y[1]),y[2]=t(g,y[2]),y[3]=t(l,y[3]),y[4]=t(d,y[4]),y[5]=t(s,y[5]),y[6]=t(p,y[6]),y[7]=t(v,y[7]);}return y}(function(r){for(var n=Array(),t=0;t<8*r.length;t+=8)n[t>>5]|=(255&r.charCodeAt(t/8))<<24-t%32;return n}(r=function(r){r=r.replace(/\r\n/g,"\n");for(var n="",t=0;t<r.length;t++){var e=r.charCodeAt(t);e<128?n+=String.fromCharCode(e):e>127&&e<2048?(n+=String.fromCharCode(e>>6|192),n+=String.fromCharCode(63&e|128)):(n+=String.fromCharCode(e>>12|224),n+=String.fromCharCode(e>>6&63|128),n+=String.fromCharCode(63&e|128));}return n}(r)),8*r.length));return "hex"==n?C:"base64"==n?(i=C,btoa(String.fromCharCode.apply(null,i.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")))):void 0}; var _nodeResolve_empty = {}; var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({ __proto__: null, 'default': _nodeResolve_empty }); var require$$0 = getCjsExportFromNamespace(_nodeResolve_empty$1); var core=createCommonjsModule((function(t,n){var e;e=function(){var t=t||function(t,n){var e;if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),"undefined"!=typeof self&&self.crypto&&(e=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(e=globalThis.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==commonjsGlobal&&commonjsGlobal.crypto&&(e=commonjsGlobal.crypto),!e&&"function"==typeof commonjsRequire)try{e=require$$0;}catch(t){}var r=function(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(n){var e;return t.prototype=n,e=new t,t.prototype=null,e}}(),i={},s=i.lib={},c=s.Base={extend:function(t){var n=o(this);return t&&n.mixIn(t),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments);}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}},a=s.WordArray=c.extend({init:function(t,n){t=this.words=t||[],this.sigBytes=null!=n?n:4*t.length;},toString:function(t){return (t||f).stringify(this)},concat:function(t){var n=this.words,e=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=e[i>>>2]>>>24-i%4*8&255;n[r+i>>>2]|=s<<24-(r+i)%4*8;}else for(var c=0;c<o;c+=4)n[r+c>>>2]=e[c>>>2];return this.sigBytes+=o,this},clamp:function(){var n=this.words,e=this.sigBytes;n[e>>>2]&=4294967295<<32-e%4*8,n.length=t.ceil(e/4);},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var n=[],e=0;e<t;e+=4)n.push(r());return new a.init(n,t)}}),u=i.enc={},f=u.Hex={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16));}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r+=2)e[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(e,n/2)}},p=u.Latin1={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i));}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r++)e[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(e,n)}},l=u.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=s.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new a.init,this._nDataBytes=0;},_append:function(t){"string"==typeof t&&(t=l.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(n){var e,r=this._data,o=r.words,i=r.sigBytes,s=this.blockSize,c=i/(4*s),u=(c=n?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*s,f=t.min(4*u,i);if(u){for(var p=0;p<u;p+=s)this._doProcessBlock(o,p);e=o.splice(0,u),r.sigBytes-=f;}return new a.init(e,f)},clone:function(){var t=c.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),h=(s.Hasher=d.extend({cfg:c.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset();},reset:function(){d.reset.call(this),this._doReset();},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(n,e){return new t.init(e).finalize(n)}},_createHmacHelper:function(t){return function(n,e){return new h.HMAC.init(t,e).finalize(n)}}}),i.algo={});return i}(Math);return t},t.exports=e();})); var x64Core=createCommonjsModule((function(o,r){var e;e=function(o){var r,e,t,s,n;return e=(r=o).lib,t=e.Base,s=e.WordArray,(n=r.x64={}).Word=t.extend({init:function(o,r){this.high=o,this.low=r;}}),n.WordArray=t.extend({init:function(o,r){o=this.words=o||[],this.sigBytes=null!=r?r:8*o.length;},toX32:function(){for(var o=this.words,r=o.length,e=[],t=0;t<r;t++){var n=o[t];e.push(n.high),e.push(n.low);}return s.create(e,this.sigBytes)},clone:function(){for(var o=t.clone.call(this),r=o.words=this.words.slice(0),e=r.length,s=0;s<e;s++)r[s]=r[s].clone();return o}}),o},o.exports=e(core);})); var libTypedarrays=createCommonjsModule((function(r,e){var n;n=function(r){return function(){if("function"==typeof ArrayBuffer){var e=r.lib.WordArray,n=e.init,o=e.init=function(r){if(r instanceof ArrayBuffer&&(r=new Uint8Array(r)),(r instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&r instanceof Uint8ClampedArray||r instanceof Int16Array||r instanceof Uint16Array||r instanceof Int32Array||r instanceof Uint32Array||r instanceof Float32Array||r instanceof Float64Array)&&(r=new Uint8Array(r.buffer,r.byteOffset,r.byteLength)),r instanceof Uint8Array){for(var e=r.byteLength,o=[],t=0;t<e;t++)o[t>>>2]|=r[t]<<24-t%4*8;n.call(this,o,e);}else n.apply(this,arguments);};o.prototype=e;}}(),r.lib.WordArray},r.exports=n(core);})); var encUtf16=createCommonjsModule((function(r,o){var e;e=function(r){return function(){var o=r,e=o.lib.WordArray,n=o.enc;function t(r){return r<<8&4278255360|r>>>8&16711935}n.Utf16=n.Utf16BE={stringify:function(r){for(var o=r.words,e=r.sigBytes,n=[],t=0;t<e;t+=2){var s=o[t>>>2]>>>16-t%4*8&65535;n.push(String.fromCharCode(s));}return n.join("")},parse:function(r){for(var o=r.length,n=[],t=0;t<o;t++)n[t>>>1]|=r.charCodeAt(t)<<16-t%2*16;return e.create(n,2*o)}},n.Utf16LE={stringify:function(r){for(var o=r.words,e=r.sigBytes,n=[],s=0;s<e;s+=2){var c=t(o[s>>>2]>>>16-s%4*8&65535);n.push(String.fromCharCode(c));}return n.join("")},parse:function(r){for(var o=r.length,n=[],s=0;s<o;s++)n[s>>>1]|=t(r.charCodeAt(s)<<16-s%2*16);return e.create(n,2*o)}};}(),r.enc.Utf16},r.exports=e(core);})); var encBase64=createCommonjsModule((function(r,e){var o;o=function(r){var e,o;return o=(e=r).lib.WordArray,e.enc.Base64={stringify:function(r){var e=r.words,o=r.sigBytes,a=this._map;r.clamp();for(var s=[],t=0;t<o;t+=3)for(var n=(e[t>>>2]>>>24-t%4*8&255)<<16|(e[t+1>>>2]>>>24-(t+1)%4*8&255)<<8|e[t+2>>>2]>>>24-(t+2)%4*8&255,c=0;c<4&&t+.75*c<o;c++)s.push(a.charAt(n>>>6*(3-c)&63));var i=a.charAt(64);if(i)for(;s.length%4;)s.push(i);return s.join("")},parse:function(r){var e=r.length,a=this._map,s=this._reverseMap;if(!s){s=this._reverseMap=[];for(var t=0;t<a.length;t++)s[a.charCodeAt(t)]=t;}var n=a.charAt(64);if(n){var c=r.indexOf(n);-1!==c&&(e=c);}return function(r,e,a){for(var s=[],t=0,n=0;n<e;n++)if(n%4){var c=a[r.charCodeAt(n-1)]<<n%4*2|a[r.charCodeAt(n)]>>>6-n%4*2;s[t>>>2]|=c<<24-t%4*8,t++;}return o.create(s,t)}(r,e,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},r.enc.Base64},r.exports=o(core);})); var encBase64url=createCommonjsModule((function(r,e){var o;o=function(r){var e,o;return o=(e=r).lib.WordArray,e.enc.Base64url={stringify:function(r,e){void 0===e&&(e=!0);var o=r.words,a=r.sigBytes,s=e?this._safe_map:this._map;r.clamp();for(var t=[],n=0;n<a;n+=3)for(var i=(o[n>>>2]>>>24-n%4*8&255)<<16|(o[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|o[n+2>>>2]>>>24-(n+2)%4*8&255,c=0;c<4&&n+.75*c<a;c++)t.push(s.charAt(i>>>6*(3-c)&63));var m=s.charAt(64);if(m)for(;t.length%4;)t.push(m);return t.join("")},parse:function(r,e){void 0===e&&(e=!0);var a=r.length,s=e?this._safe_map:this._map,t=this._reverseMap;if(!t){t=this._reverseMap=[];for(var n=0;n<s.length;n++)t[s.charCodeAt(n)]=n;}var i=s.charAt(64);if(i){var c=r.indexOf(i);-1!==c&&(a=c);}return function(r,e,a){for(var s=[],t=0,n=0;n<e;n++)if(n%4){var i=a[r.charCodeAt(n-1)]<<n%4*2|a[r.charCodeAt(n)]>>>6-n%4*2;s[t>>>2]|=i<<24-t%4*8,t++;}return o.create(s,t)}(r,a,t)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"},r.enc.Base64url},r.exports=o(core);})); var md5=createCommonjsModule((function(r,o){var e;e=function(r){return function(o){var e=r,n=e.lib,t=n.WordArray,s=n.Hasher,a=e.algo,i=[];!function(){for(var r=0;r<64;r++)i[r]=4294967296*o.abs(o.sin(r+1))|0;}();var c=a.MD5=s.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878]);},_doProcessBlock:function(r,o){for(var e=0;e<16;e++){var n=o+e,t=r[n];r[n]=16711935&(t<<8|t>>>24)|4278255360&(t<<24|t>>>8);}var s=this._hash.words,a=r[o+0],c=r[o+1],f=r[o+2],v=r[o+3],d=r[o+4],p=r[o+5],_=r[o+6],H=r[o+7],j=r[o+8],x=r[o+9],M=r[o+10],y=r[o+11],D=r[o+12],g=r[o+13],w=r[o+14],B=r[o+15],$=s[0],b=s[1],q=s[2],k=s[3];$=m($,b,q,k,a,7,i[0]),k=m(k,$,b,q,c,12,i[1]),q=m(q,k,$,b,f,17,i[2]),b=m(b,q,k,$,v,22,i[3]),$=m($,b,q,k,d,7,i[4]),k=m(k,$,b,q,p,12,i[5]),q=m(q,k,$,b,_,17,i[6]),b=m(b,q,k,$,H,22,i[7]),$=m($,b,q,k,j,7,i[8]),k=m(k,$,b,q,x,12,i[9]),q=m(q,k,$,b,M,17,i[10]),b=m(b,q,k,$,y,22,i[11]),$=m($,b,q,k,D,7,i[12]),k=m(k,$,b,q,g,12,i[13]),q=m(q,k,$,b,w,17,i[14]),$=u($,b=m(b,q,k,$,B,22,i[15]),q,k,c,5,i[16]),k=u(k,$,b,q,_,9,i[17]),q=u(q,k,$,b,y,14,i[18]),b=u(b,q,k,$,a,20,i[19]),$=u($,b,q,k,p,5,i[20]),k=u(k,$,b,q,M,9,i[21]),q=u(q,k,$,b,B,14,i[22]),b=u(b,q,k,$,d,20,i[23]),$=u($,b,q,k,x,5,i[24]),k=u(k,$,b,q,w,9,i[25]),q=u(q,k,$,b,v,14,i[26]),b=u(b,q,k,$,j,20,i[27]),$=u($,b,q,k,g,5,i[28]),k=u(k,$,b,q,f,9,i[29]),q=u(q,k,$,b,H,14,i[30]),$=l($,b=u(b,q,k,$,D,20,i[31]),q,k,p,4,i[32]),k=l(k,$,b,q,j,11,i[33]),q=l(q,k,$,b,y,16,i[34]),b=l(b,q,k,$,w,23,i[35]),$=l($,b,q,k,c,4,i[36]),k=l(k,$,b,q,d,11,i[37]),q=l(q,k,$,b,H,16,i[38]),b=l(b,q,k,$,M,23,i[39]),$=l($,b,q,k,g,4,i[40]),k=l(k,$,b,q,a,11,i[41]),q=l(q,k,$,b,v,16,i[42]),b=l(b,q,k,$,_,23,i[43]),$=l($,b,q,k,x,4,i[44]),k=l(k,$,b,q,D,11,i[45]),q=l(q,k,$,b,B,16,i[46]),$=h($,b=l(b,q,k,$,f,23,i[47]),q,k,a,6,i[48]),k=h(k,$,b,q,H,10,i[49]),q=h(q,k,$,b,w,15,i[50]),b=h(b,q,k,$,p,21,i[51]),$=h($,b,q,k,D,6,i[52]),k=h(k,$,b,q,v,10,i[53]),q=h(q,k,$,b,M,15,i[54]),b=h(b,q,k,$,c,21,i[55]),$=h($,b,q,k,j,6,i[56]),k=h(k,$,b,q,B,10,i[57]),q=h(q,k,$,b,_,15,i[58]),b=h(b,q,k,$,g,21,i[59]),$=h($,b,q,k,d,6,i[60]),k=h(k,$,b,q,y,10,i[61]),q=h(q,k,$,b,f,15,i[62]),b=h(b,q,k,$,x,21,i[63]),s[0]=s[0]+$|0,s[1]=s[1]+b|0,s[2]=s[2]+q|0,s[3]=s[3]+k|0;},_doFinalize:function(){var r=this._data,e=r.words,n=8*this._nDataBytes,t=8*r.sigBytes;e[t>>>5]|=128<<24-t%32;var s=o.floor(n/4294967296),a=n;e[15+(t+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),e[14+(t+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),r.sigBytes=4*(e.length+1),this._process();for(var i=this._hash,c=i.words,m=0;m<4;m++){var u=c[m];c[m]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8);}return i},clone:function(){var r=s.clone.call(this);return r._hash=this._hash.clone(),r}});function m(r,o,e,n,t,s,a){var i=r+(o&e|~o&n)+t+a;return (i<<s|i>>>32-s)+o}function u(r,o,e,n,t,s,a){var i=r+(o&n|e&~n)+t+a;return (i<<s|i>>>32-s)+o}function l(r,o,e,n,t,s,a){var i=r+(o^e^n)+t+a;return (i<<s|i>>>32-s)+o}function h(r,o,e,n,t,s,a){var i=r+(e^(o|~n))+t+a;return (i<<s|i>>>32-s)+o}e.MD5=s._createHelper(c),e.HmacMD5=s._createHmacHelper(c);}(Math),r.MD5},r.exports=e(core);})); var sha1=createCommonjsModule((function(e,o){var r;r=function(e){var o,r,s,t,a,n,i;return r=(o=e).lib,s=r.WordArray,t=r.Hasher,a=o.algo,n=[],i=a.SHA1=t.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(e,o){for(var r=this._hash.words,s=r[0],t=r[1],a=r[2],i=r[3],c=r[4],h=0;h<80;h++){if(h<16)n[h]=0|e[o+h];else {var l=n[h-3]^n[h-8]^n[h-14]^n[h-16];n[h]=l<<1|l>>>31;}var m=(