@teamhanko/hanko-frontend-sdk 0.2.0-alpha → 0.4.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.module.js","sources":["../src/lib/Errors.ts","../node_modules/js-cookie/dist/js.cookie.mjs","../src/lib/client/HttpClient.ts","../src/lib/client/Client.ts","../src/lib/client/ConfigClient.ts","../src/lib/state/State.ts","../src/lib/state/UserState.ts","../src/lib/state/PasscodeState.ts","../src/lib/client/PasscodeClient.ts","../src/lib/state/PasswordState.ts","../src/lib/client/PasswordClient.ts","../src/lib/client/UserClient.ts","../node_modules/@github/webauthn-json/dist/esm/webauthn-json.js","../src/lib/WebauthnSupport.ts","../src/lib/state/WebauthnState.ts","../src/lib/client/WebauthnClient.ts","../src/lib/client/EmailClient.ts","../src/lib/client/ThirdPartyClient.ts","../src/Hanko.ts"],"sourcesContent":["/**\n * Every error thrown in the SDK is an instance of 'HankoError'. The value of the 'code' property is eligible to\n * translate the error into an error message.\n *\n * @extends {Error}\n * @category SDK\n * @subcategory Errors\n * @param code {string} - An error code that refers to the error instance.\n * @param cause {Error=} - The original error\n */\nabstract class HankoError extends Error {\n code: string;\n cause?: Error;\n\n // eslint-disable-next-line require-jsdoc\n protected constructor(message: string, code: string, cause?: Error) {\n super(message);\n /**\n * @public\n * @type {string}\n */\n this.code = code;\n /**\n * @public\n * @type {Error=}\n */\n this.cause = cause;\n Object.setPrototypeOf(this, HankoError.prototype);\n }\n}\n\n/**\n * Every error that doesn't need to be handled in a special way is a 'TechnicalError'. Whenever you catch one, there is\n * usually nothing you can do but present an error to the user, e.g. \"Something went wrong\".\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass TechnicalError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Technical error\", \"somethingWentWrong\", cause);\n Object.setPrototypeOf(this, TechnicalError.prototype);\n }\n}\n\n/**\n * Attempting to create a resource that already exists results in a 'ConflictError'.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass ConflictError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(userID?: string, cause?: Error) {\n super(\"Conflict error\", \"conflict\", cause);\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n\n/**\n * A 'RequestTimeoutError' occurs when the specified timeout has been reached.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass RequestTimeoutError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Request timed out error\", \"requestTimeout\", cause);\n Object.setPrototypeOf(this, RequestTimeoutError.prototype);\n }\n}\n\n/**\n * A 'WebauthnRequestCancelledError' occurs during WebAuthn authentication or registration, when the WebAuthn API throws\n * an error. In most cases, this happens when the user cancels the browser's WebAuthn dialog.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass WebauthnRequestCancelledError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Request cancelled error\", \"requestCancelled\", cause);\n Object.setPrototypeOf(this, WebauthnRequestCancelledError.prototype);\n }\n}\n\n/**\n * An 'InvalidPasswordError' occurs when invalid credentials are provided when logging in with a password.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass InvalidPasswordError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Invalid password error\", \"invalidPassword\", cause);\n Object.setPrototypeOf(this, InvalidPasswordError.prototype);\n }\n}\n\n/**\n * An 'InvalidPasswordError' occurs when an incorrect code is entered when logging in with a passcode.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass InvalidPasscodeError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Invalid Passcode error\", \"invalidPasscode\", cause);\n Object.setPrototypeOf(this, InvalidPasscodeError.prototype);\n }\n}\n\n/**\n * An 'InvalidWebauthnCredentialError' occurs if invalid credentials were used when logging in with WebAuthn.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass InvalidWebauthnCredentialError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\n \"Invalid WebAuthn credential error\",\n \"invalidWebauthnCredential\",\n cause\n );\n Object.setPrototypeOf(this, InvalidWebauthnCredentialError.prototype);\n }\n}\n\n/**\n * A 'PasscodeExpiredError' occurs when the passcode has expired.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass PasscodeExpiredError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Passcode expired error\", \"passcodeExpired\", cause);\n Object.setPrototypeOf(this, PasscodeExpiredError.prototype);\n }\n}\n\n/**\n * A 'MaxNumOfPasscodeAttemptsReachedError' occurs when an incorrect passcode is provided too many times.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass MaxNumOfPasscodeAttemptsReachedError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\n \"Maximum number of Passcode attempts reached error\",\n \"passcodeAttemptsReached\",\n cause\n );\n Object.setPrototypeOf(this, MaxNumOfPasscodeAttemptsReachedError.prototype);\n }\n}\n\n/**\n * A 'NotFoundError' occurs when the requested resource was not found.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass NotFoundError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Not found error\", \"notFound\", cause);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\n/**\n * A 'TooManyRequestsError' occurs due to rate limiting when too many requests are made.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass TooManyRequestsError extends HankoError {\n retryAfter?: number;\n // eslint-disable-next-line require-jsdoc\n constructor(retryAfter?: number, cause?: Error) {\n super(\"Too many requests error\", \"tooManyRequests\", cause);\n this.retryAfter = retryAfter;\n Object.setPrototypeOf(this, TooManyRequestsError.prototype);\n }\n}\n\n/**\n * An 'UnauthorizedError' occurs when the user is not authorized to access the resource.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass UnauthorizedError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Unauthorized error\", \"unauthorized\", cause);\n Object.setPrototypeOf(this, UnauthorizedError.prototype);\n }\n}\n\n/**\n * A 'UserVerificationError' occurs when the user verification requirements\n * for a WebAuthn ceremony are not met.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass UserVerificationError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"User verification error\", \"userVerification\", cause);\n Object.setPrototypeOf(this, UserVerificationError.prototype);\n }\n}\n\n/**\n * A 'MaxNumOfEmailAddressesReachedError' occurs when the user tries to add a new email address while the maximum number\n * of email addresses (see backend configuration) equals the number of email addresses already registered.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass MaxNumOfEmailAddressesReachedError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\n \"Maximum number of email addresses reached error\",\n \"maxNumOfEmailAddressesReached\",\n cause\n );\n Object.setPrototypeOf(this, MaxNumOfEmailAddressesReachedError.prototype);\n }\n}\n\n/**\n * An 'EmailAddressAlreadyExistsError' occurs when the user tries to add a new email address which already exists.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass EmailAddressAlreadyExistsError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\n \"The email address already exists\",\n \"emailAddressAlreadyExistsError\",\n cause\n );\n Object.setPrototypeOf(this, EmailAddressAlreadyExistsError.prototype);\n }\n}\n\n/**\n * A `ThirdPartyError` may occur during a sign in/sign up with a third party\n * provider.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass ThirdPartyError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(code: string, cause?: Error) {\n super(\"An error occurred during third party sign up/sign in\", code, cause);\n Object.setPrototypeOf(this, ThirdPartyError.prototype);\n }\n}\n\nexport {\n HankoError,\n TechnicalError,\n ConflictError,\n RequestTimeoutError,\n WebauthnRequestCancelledError,\n InvalidPasswordError,\n InvalidPasscodeError,\n InvalidWebauthnCredentialError,\n PasscodeExpiredError,\n MaxNumOfPasscodeAttemptsReachedError,\n NotFoundError,\n TooManyRequestsError,\n UnauthorizedError,\n UserVerificationError,\n MaxNumOfEmailAddressesReachedError,\n EmailAddressAlreadyExistsError,\n ThirdPartyError,\n};\n","/*! js-cookie v3.0.1 | MIT */\n/* eslint-disable no-var */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n target[key] = source[key];\n }\n }\n return target\n}\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\n\nfunction init (converter, defaultAttributes) {\n function set (key, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n key = encodeURIComponent(key)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n key + '=' + converter.write(value, key) + stringifiedAttributes)\n }\n\n function get (key) {\n if (typeof document === 'undefined' || (arguments.length && !key)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var foundKey = decodeURIComponent(parts[0]);\n jar[foundKey] = converter.read(value, foundKey);\n\n if (key === foundKey) {\n break\n }\n } catch (e) {}\n }\n\n return key ? jar[key] : jar\n }\n\n return Object.create(\n {\n set: set,\n get: get,\n remove: function (key, attributes) {\n set(\n key,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n/* eslint-enable no-var */\n\nexport default api;\n","import Cookies from \"js-cookie\";\nimport { RequestTimeoutError, TechnicalError } from \"../Errors\";\n\n/**\n * This class wraps an XMLHttpRequest to maintain compatibility with the fetch API.\n *\n * @category SDK\n * @subcategory Internal\n * @param {XMLHttpRequest} xhr - The request to be wrapped.\n * @see HttpClient\n */\nclass Headers {\n _xhr: XMLHttpRequest;\n\n // eslint-disable-next-line require-jsdoc\n constructor(xhr: XMLHttpRequest) {\n this._xhr = xhr;\n }\n\n /**\n * Returns the response header with the given name.\n *\n * @param {string} name\n * @return {string}\n */\n get(name: string) {\n return this._xhr.getResponseHeader(name);\n }\n}\n\n/**\n * This class wraps an XMLHttpRequest to maintain compatibility with the fetch API.\n *\n * @category SDK\n * @subcategory Internal\n * @param {XMLHttpRequest} xhr - The request to be wrapped.\n * @see HttpClient\n */\nclass Response {\n headers: Headers;\n ok: boolean;\n status: number;\n statusText: string;\n url: string;\n _decodedJSON: any;\n private xhr: XMLHttpRequest;\n\n // eslint-disable-next-line require-jsdoc\n constructor(xhr: XMLHttpRequest) {\n /**\n * @public\n * @type {Headers}\n */\n this.headers = new Headers(xhr);\n /**\n * @public\n * @type {boolean}\n */\n this.ok = xhr.status >= 200 && xhr.status <= 299;\n /**\n * @public\n * @type {number}\n */\n this.status = xhr.status;\n /**\n * @public\n * @type {string}\n */\n this.statusText = xhr.statusText;\n /**\n * @public\n * @type {string}\n */\n this.url = xhr.responseURL;\n /**\n * @private\n * @type {XMLHttpRequest}\n */\n this.xhr = xhr;\n }\n\n /**\n * Returns the JSON decoded response.\n *\n * @return {any}\n */\n json() {\n if (!this._decodedJSON) {\n this._decodedJSON = JSON.parse(this.xhr.response);\n }\n return this._decodedJSON;\n }\n\n /**\n * Returns the value for Retry-After contained in the response header.\n *\n * @return {number}\n */\n parseRetryAfterHeader(): number {\n const result = parseInt(this.headers.get(\"Retry-After\"), 10);\n return isNaN(result) ? 0 : result;\n }\n}\n\n/**\n * Internally used for communication with the Hanko API. It also handles authorization tokens to enable authorized\n * requests.\n *\n * Currently, there is an issue with Safari and on iOS 15 devices where decoding a JSON response via the fetch API\n * breaks the user gesture and the user is not able to use the authenticator. Therefore, this class uses XMLHttpRequests\n * instead of the fetch API, but maintains compatibility by wrapping the XMLHttpRequests. So, if the issues are fixed,\n * we can easily return to the fetch API.\n *\n * @category SDK\n * @subcategory Internal\n * @param {string} api - The URL of your Hanko API instance\n * @param {number=} timeout - The request timeout in milliseconds\n */\nclass HttpClient {\n timeout: number;\n api: string;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n this.api = api;\n this.timeout = timeout;\n }\n\n // eslint-disable-next-line require-jsdoc\n _fetch(path: string, options: RequestInit, xhr = new XMLHttpRequest()) {\n const api = this.api;\n const url = api + path;\n const timeout = this.timeout;\n const cookieName = \"hanko\";\n const bearerToken = Cookies.get(cookieName);\n\n return new Promise<Response>(function (resolve, reject) {\n xhr.open(options.method, url, true);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n\n if (bearerToken) {\n xhr.setRequestHeader(\"Authorization\", `Bearer ${bearerToken}`);\n }\n\n xhr.timeout = timeout;\n xhr.withCredentials = true;\n xhr.onload = () => {\n const headers = xhr\n .getAllResponseHeaders()\n .split(\"\\r\\n\")\n .filter((h) => h.toLowerCase().startsWith(\"x-auth-token\"));\n\n if (headers.length) {\n const authToken = xhr.getResponseHeader(\"X-Auth-Token\");\n\n if (authToken) {\n const secure = !!api.match(\"^https://\");\n Cookies.set(cookieName, authToken, { secure });\n }\n }\n\n resolve(new Response(xhr));\n };\n\n xhr.onerror = () => {\n reject(new TechnicalError());\n };\n\n xhr.ontimeout = () => {\n reject(new RequestTimeoutError());\n };\n\n xhr.send(options.body ? options.body.toString() : null);\n });\n }\n\n /**\n * Performs a GET request.\n *\n * @param {string} path - The path to the requested resource.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n get(path: string) {\n return this._fetch(path, { method: \"GET\" });\n }\n\n /**\n * Performs a POST request.\n *\n * @param {string} path - The path to the requested resource.\n * @param {any=} body - The request body.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n post(path: string, body?: any) {\n return this._fetch(path, {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n }\n\n /**\n * Performs a PUT request.\n *\n * @param {string} path - The path to the requested resource.\n * @param {any=} body - The request body.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n put(path: string, body?: any) {\n return this._fetch(path, {\n method: \"PUT\",\n body: JSON.stringify(body),\n });\n }\n\n /**\n * Performs a PATCH request.\n *\n * @param {string} path - The path to the requested resource.\n * @param {any=} body - The request body.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n patch(path: string, body?: any) {\n return this._fetch(path, {\n method: \"PATCH\",\n body: JSON.stringify(body),\n });\n }\n\n /**\n * Performs a DELETE request.\n *\n * @param {string} path - The path to the requested resource.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n delete(path: string) {\n return this._fetch(path, {\n method: \"DELETE\",\n });\n }\n}\n\nexport { Headers, Response, HttpClient };\n","import { HttpClient } from \"./HttpClient\";\n\n/**\n * A class to be extended by the other client classes.\n *\n * @abstract\n * @category SDK\n * @subcategory Internal\n * @param {string} api - The URL of your Hanko API instance\n * @param {number=} timeout - The request timeout in milliseconds\n */\nabstract class Client {\n client: HttpClient;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n /**\n * @public\n * @type {HttpClient}\n */\n this.client = new HttpClient(api, timeout);\n }\n}\n\nexport { Client };\n","import { Config } from \"../Dto\";\nimport { TechnicalError } from \"../Errors\";\nimport { Client } from \"./Client\";\n\n/**\n * A class for retrieving configurations from the API.\n *\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass ConfigClient extends Client {\n /**\n * Retrieves the frontend configuration.\n * @return {Promise<Config>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/.well-known/operation/getConfig\n */\n async get(): Promise<Config> {\n const response = await this.client.get(\"/.well-known/config\");\n\n if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n}\n\nexport { ConfigClient };\n","import { LocalStorageUsers } from \"./UserState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {LocalStorageUsers=} users - The user states.\n */\ninterface LocalStorage {\n users?: LocalStorageUsers;\n}\n\n/**\n * A class to read and write local storage contents.\n *\n * @abstract\n * @param {string} key - The local storage key.\n * @category SDK\n * @subcategory Internal\n */\nabstract class State {\n private readonly key: string;\n ls: LocalStorage;\n\n // eslint-disable-next-line require-jsdoc\n constructor(key = \"hanko\") {\n /**\n * @private\n * @type {string}\n */\n this.key = key;\n /**\n * @type {LocalStorage}\n */\n this.ls = {};\n }\n\n /**\n * Reads and decodes the locally stored data.\n *\n * @return {State}\n */\n read(): State {\n let store: LocalStorage;\n\n try {\n const data = localStorage.getItem(this.key);\n const decoded = decodeURIComponent(decodeURI(window.atob(data)));\n store = JSON.parse(decoded);\n } catch (e) {\n this.ls = {};\n\n return this;\n }\n\n this.ls = store;\n\n return this;\n }\n\n /**\n * Encodes and writes the data to the local storage.\n *\n * @return {State}\n */\n write(): State {\n const data = JSON.stringify(this.ls);\n const encoded = window.btoa(encodeURI(encodeURIComponent(data)));\n\n localStorage.setItem(this.key, encoded);\n\n return this;\n }\n\n /**\n * Converts a timestamp into remaining seconds that you can count down.\n *\n * @static\n * @param {number} time - Timestamp in seconds (since January 1, 1970 00:00:00 UTC).\n * @return {number}\n */\n static timeToRemainingSeconds(time = 0) {\n return time - Math.floor(Date.now() / 1000);\n }\n\n /**\n * Converts a number of seconds into a timestamp.\n *\n * @static\n * @param {number} seconds - Remaining seconds to be converted into a timestamp.\n * @return {number}\n */\n static remainingSecondsToTime(seconds = 0) {\n return Math.floor(Date.now() / 1000) + seconds;\n }\n}\n\nexport { State };\nexport type { LocalStorage };\n","/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {Object.<string, LocalStorageUser>} - A dictionary for mapping users to their states.\n */\nimport { State } from \"./State\";\n\nimport { LocalStorageWebauthn } from \"./WebauthnState\";\nimport { LocalStoragePasscode } from \"./PasscodeState\";\nimport { LocalStoragePassword } from \"./PasswordState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {LocalStorageWebauthn=} webauthn - Information about WebAuthn credentials.\n * @property {LocalStoragePasscode=} passcode - Information about the active passcode.\n * @property {LocalStoragePassword=} password - Information about the password login attempts.\n */\ninterface LocalStorageUser {\n webauthn?: LocalStorageWebauthn;\n passcode?: LocalStoragePasscode;\n password?: LocalStoragePassword;\n}\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {Object.<string, LocalStorageUser>} - A dictionary for mapping users to their states.\n */\nexport interface LocalStorageUsers {\n [userID: string]: LocalStorageUser;\n}\n\n/**\n * A class to read and write local storage contents.\n *\n * @abstract\n * @extends State\n * @param {string} key - The local storage key.\n * @category SDK\n * @subcategory Internal\n */\nabstract class UserState extends State {\n /**\n * Gets the state of the specified user.\n *\n * @param {string} userID - The UUID of the user.\n * @return {LocalStorageUser}\n */\n getUserState(userID: string): LocalStorageUser {\n this.ls.users ||= {};\n\n if (!Object.prototype.hasOwnProperty.call(this.ls.users, userID)) {\n this.ls.users[userID] = {};\n }\n\n return this.ls.users[userID];\n }\n}\n\nexport { UserState };\n","import { State } from \"./State\";\nimport { UserState } from \"./UserState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {string=} id - The UUID of the active passcode.\n * @property {number=} ttl - Timestamp until when the passcode is valid in seconds (since January 1, 1970 00:00:00 UTC).\n * @property {number=} resendAfter - Seconds until a passcode can be resent.\n * @property {emailID=} emailID - The email address ID.\n */\nexport interface LocalStoragePasscode {\n id?: string;\n ttl?: number;\n resendAfter?: number;\n emailID?: string;\n}\n\n/**\n * A class that manages passcodes via local storage.\n *\n * @extends UserState\n * @category SDK\n * @subcategory Internal\n */\nclass PasscodeState extends UserState {\n /**\n * Get the passcode state.\n *\n * @private\n * @param {string} userID - The UUID of the user.\n * @return {LocalStoragePasscode}\n */\n private getState(userID: string): LocalStoragePasscode {\n return (super.getUserState(userID).passcode ||= {});\n }\n\n /**\n * Reads the current state.\n *\n * @public\n * @return {PasscodeState}\n */\n read(): PasscodeState {\n super.read();\n\n return this;\n }\n\n /**\n * Gets the UUID of the active passcode.\n *\n * @param {string} userID - The UUID of the user.\n * @return {string}\n */\n getActiveID(userID: string): string {\n return this.getState(userID).id;\n }\n\n /**\n * Sets the UUID of the active passcode.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} passcodeID - The UUID of the passcode to be set as active.\n * @return {PasscodeState}\n */\n setActiveID(userID: string, passcodeID: string): PasscodeState {\n this.getState(userID).id = passcodeID;\n\n return this;\n }\n\n /**\n * Gets the UUID of the email address.\n *\n * @param {string} userID - The UUID of the user.\n * @return {string}\n */\n getEmailID(userID: string): string {\n return this.getState(userID).emailID;\n }\n\n /**\n * Sets the UUID of the email address.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} emailID - The UUID of the email address.\n * @return {PasscodeState}\n */\n setEmailID(userID: string, emailID: string): PasscodeState {\n this.getState(userID).emailID = emailID;\n\n return this;\n }\n\n /**\n * Removes the active passcode.\n *\n * @param {string} userID - The UUID of the user.\n * @return {PasscodeState}\n */\n reset(userID: string): PasscodeState {\n const passcode = this.getState(userID);\n\n delete passcode.id;\n delete passcode.ttl;\n delete passcode.resendAfter;\n delete passcode.emailID;\n\n return this;\n }\n\n /**\n * Gets the TTL in seconds. When the seconds expire, the code is invalid.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getTTL(userID: string): number {\n return State.timeToRemainingSeconds(this.getState(userID).ttl);\n }\n\n /**\n * Sets the passcode's TTL and stores it to the local storage.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} seconds - Number of seconds the passcode is valid for.\n * @return {PasscodeState}\n */\n setTTL(userID: string, seconds: number): PasscodeState {\n this.getState(userID).ttl = State.remainingSecondsToTime(seconds);\n\n return this;\n }\n\n /**\n * Gets the number of seconds until when the next passcode can be sent.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getResendAfter(userID: string): number {\n return State.timeToRemainingSeconds(this.getState(userID).resendAfter);\n }\n\n /**\n * Sets the number of seconds until a new passcode can be sent.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} seconds - Number of seconds the passcode is valid for.\n * @return {PasscodeState}\n */\n setResendAfter(userID: string, seconds: number): PasscodeState {\n this.getState(userID).resendAfter = State.remainingSecondsToTime(seconds);\n\n return this;\n }\n}\n\nexport { PasscodeState };\n","import { PasscodeState } from \"../state/PasscodeState\";\nimport { Passcode } from \"../Dto\";\nimport {\n InvalidPasscodeError,\n MaxNumOfPasscodeAttemptsReachedError,\n PasscodeExpiredError,\n TechnicalError,\n TooManyRequestsError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\n\n/**\n * A class to handle passcodes.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass PasscodeClient extends Client {\n state: PasscodeState;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n super(api, timeout);\n /**\n * @public\n * @type {PasscodeState}\n */\n this.state = new PasscodeState();\n }\n\n /**\n * Causes the API to send a new passcode to the user's email address.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string=} emailID - The UUID of the email address. If unspecified, the email will be sent to the primary email address.\n * @param {boolean=} force - Indicates the passcode should be sent, even if there is another active passcode.\n * @return {Promise<Passcode>}\n * @throws {TooManyRequestsError}\n * @throws {RequestTimeoutError}\n * @throws {UnauthorizedError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Passcode/operation/passcodeInit\n */\n async initialize(\n userID: string,\n emailID?: string,\n force?: boolean\n ): Promise<Passcode> {\n this.state.read();\n\n const lastPasscodeTTL = this.state.getTTL(userID);\n const lastPasscodeID = this.state.getActiveID(userID);\n const lastEmailID = this.state.getEmailID(userID);\n let retryAfter = this.state.getResendAfter(userID);\n\n if (retryAfter > 0) {\n throw new TooManyRequestsError(retryAfter);\n }\n\n if (!force && lastPasscodeTTL > 0 && emailID === lastEmailID) {\n return {\n id: lastPasscodeID,\n ttl: lastPasscodeTTL,\n };\n }\n\n const body: any = { user_id: userID };\n\n if (emailID) {\n body.email_id = emailID;\n }\n\n const response = await this.client.post(`/passcode/login/initialize`, body);\n\n if (response.status === 429) {\n retryAfter = response.parseRetryAfterHeader();\n this.state.setResendAfter(userID, retryAfter).write();\n throw new TooManyRequestsError(retryAfter);\n } else if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n const passcode: Passcode = response.json();\n\n this.state.setActiveID(userID, passcode.id).setTTL(userID, passcode.ttl);\n\n if (emailID) {\n this.state.setEmailID(userID, emailID);\n }\n\n this.state.write();\n\n return passcode;\n }\n\n /**\n * Validates the passcode obtained from the email.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} code - The passcode digests.\n * @return {Promise<void>}\n * @throws {InvalidPasscodeError}\n * @throws {MaxNumOfPasscodeAttemptsReachedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Passcode/operation/passcodeFinal\n */\n async finalize(userID: string, code: string): Promise<void> {\n const passcodeID = this.state.read().getActiveID(userID);\n const ttl = this.state.getTTL(userID);\n\n if (ttl <= 0) {\n throw new PasscodeExpiredError();\n }\n\n const response = await this.client.post(\"/passcode/login/finalize\", {\n id: passcodeID,\n code,\n });\n\n if (response.status === 401) {\n throw new InvalidPasscodeError();\n } else if (response.status === 410) {\n this.state.reset(userID).write();\n throw new MaxNumOfPasscodeAttemptsReachedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n this.state.reset(userID).write();\n\n return;\n }\n\n /**\n * Returns the number of seconds the current passcode is active for.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getTTL(userID: string) {\n return this.state.read().getTTL(userID);\n }\n\n /**\n * Returns the number of seconds the rate limiting is active for.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getResendAfter(userID: string) {\n return this.state.read().getResendAfter(userID);\n }\n}\n\nexport { PasscodeClient };\n","import { State } from \"./State\";\nimport { UserState } from \"./UserState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {number=} retryAfter - Timestamp (in seconds since January 1, 1970 00:00:00 UTC) indicating when the next password login can be attempted.\n */\nexport interface LocalStoragePassword {\n retryAfter?: number;\n}\n\n/**\n * A class that manages the password login state.\n *\n * @extends UserState\n * @category SDK\n * @subcategory Internal\n */\nclass PasswordState extends UserState {\n /**\n * Get the password state.\n *\n * @private\n * @param {string} userID - The UUID of the user.\n * @return {LocalStoragePassword}\n */\n private getState(userID: string): LocalStoragePassword {\n return (super.getUserState(userID).password ||= {});\n }\n\n /**\n * Reads the current state.\n *\n * @public\n * @return {PasswordState}\n */\n read(): PasswordState {\n super.read();\n\n return this;\n }\n\n /**\n * Gets the number of seconds until when a new password login can be attempted.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getRetryAfter(userID: string): number {\n return State.timeToRemainingSeconds(this.getState(userID).retryAfter);\n }\n\n /**\n * Sets the number of seconds until a new password login can be attempted.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} seconds - Number of seconds the passcode is valid for.\n * @return {PasswordState}\n */\n setRetryAfter(userID: string, seconds: number): PasswordState {\n this.getState(userID).retryAfter = State.remainingSecondsToTime(seconds);\n\n return this;\n }\n}\n\nexport { PasswordState };\n","import { PasswordState } from \"../state/PasswordState\";\nimport { PasscodeState } from \"../state/PasscodeState\";\nimport {\n InvalidPasswordError,\n TechnicalError,\n TooManyRequestsError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\n\n/**\n * A class to handle passwords.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass PasswordClient extends Client {\n passwordState: PasswordState;\n passcodeState: PasscodeState;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n super(api, timeout);\n /**\n * @public\n * @type {PasswordState}\n */\n this.passwordState = new PasswordState();\n /**\n * @public\n * @type {PasscodeState}\n */\n this.passcodeState = new PasscodeState();\n }\n\n /**\n * Logs in a user with a password.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} password - The password.\n * @return {Promise<void>}\n * @throws {TooManyRequestsError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Password/operation/passwordLogin\n */\n async login(userID: string, password: string): Promise<void> {\n const response = await this.client.post(\"/password/login\", {\n user_id: userID,\n password,\n });\n\n if (response.status === 401) {\n throw new InvalidPasswordError();\n } else if (response.status === 429) {\n const retryAfter = response.parseRetryAfterHeader();\n this.passwordState.read().setRetryAfter(userID, retryAfter).write();\n throw new TooManyRequestsError(retryAfter);\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n this.passcodeState.read().reset(userID).write();\n\n return;\n }\n\n /**\n * Updates a password.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} password - The new password.\n * @return {Promise<void>}\n * @throws {RequestTimeoutError}\n * @throws {UnauthorizedError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Password/operation/password\n */\n async update(userID: string, password: string): Promise<void> {\n const response = await this.client.put(\"/password\", {\n user_id: userID,\n password,\n });\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n\n /**\n * Returns the number of seconds the rate limiting is active for.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getRetryAfter(userID: string) {\n return this.passwordState.read().getRetryAfter(userID);\n }\n}\n\nexport { PasswordClient };\n","import { Me, User, UserInfo } from \"../Dto\";\nimport {\n ConflictError,\n NotFoundError,\n TechnicalError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\n\n/**\n * A class to manage user information.\n *\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass UserClient extends Client {\n /**\n * Fetches basic information about the user identified by the given email address. Can be used while the user is logged out\n * and is helpful in deciding which type of login to choose. For example, if the user's email is not verified, you may\n * want to log in with a passcode, or if no WebAuthn credentials are registered, you may not want to use WebAuthn.\n *\n * @param {string} email - The user's email address.\n * @return {Promise<UserInfo>}\n * @throws {NotFoundError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/User-Management/operation/getUserId\n */\n async getInfo(email: string): Promise<UserInfo> {\n const response = await this.client.post(\"/user\", { email });\n\n if (response.status === 404) {\n throw new NotFoundError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n\n /**\n * Creates a new user. Afterwards, verify the email address via passcode. If a 'ConflictError'\n * occurred, you may want to prompt the user to log in.\n *\n * @param {string} email - The email address of the user to be created.\n * @return {Promise<User>}\n * @throws {ConflictError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/User-Management/operation/createUser\n */\n async create(email: string): Promise<User> {\n const response = await this.client.post(\"/users\", { email });\n\n if (response.status === 409) {\n throw new ConflictError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n\n /**\n * Fetches the current user.\n *\n * @return {Promise<User>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/User-Management/operation/IsUserAuthorized\n * @see https://docs.hanko.io/api/public#tag/User-Management/operation/listUser\n */\n async getCurrent(): Promise<User> {\n const meResponse = await this.client.get(\"/me\");\n\n if (\n meResponse.status === 400 ||\n meResponse.status === 401 ||\n meResponse.status === 404\n ) {\n throw new UnauthorizedError();\n } else if (!meResponse.ok) {\n throw new TechnicalError();\n }\n\n const me: Me = meResponse.json();\n const userResponse = await this.client.get(`/users/${me.id}`);\n\n if (\n userResponse.status === 400 ||\n userResponse.status === 401 ||\n userResponse.status === 404\n ) {\n throw new UnauthorizedError();\n } else if (!userResponse.ok) {\n throw new TechnicalError();\n }\n\n return userResponse.json();\n }\n}\n\nexport { UserClient };\n","// src/webauthn-json/base64url.ts\nfunction base64urlToBuffer(baseurl64String) {\n const padding = \"==\".slice(0, (4 - baseurl64String.length % 4) % 4);\n const base64String = baseurl64String.replace(/-/g, \"+\").replace(/_/g, \"/\") + padding;\n const str = atob(base64String);\n const buffer = new ArrayBuffer(str.length);\n const byteView = new Uint8Array(buffer);\n for (let i = 0; i < str.length; i++) {\n byteView[i] = str.charCodeAt(i);\n }\n return buffer;\n}\nfunction bufferToBase64url(buffer) {\n const byteView = new Uint8Array(buffer);\n let str = \"\";\n for (const charCode of byteView) {\n str += String.fromCharCode(charCode);\n }\n const base64String = btoa(str);\n const base64urlString = base64String.replace(/\\+/g, \"-\").replace(\n /\\//g,\n \"_\"\n ).replace(/=/g, \"\");\n return base64urlString;\n}\n\n// src/webauthn-json/convert.ts\nvar copyValue = \"copy\";\nvar convertValue = \"convert\";\nfunction convert(conversionFn, schema2, input) {\n if (schema2 === copyValue) {\n return input;\n }\n if (schema2 === convertValue) {\n return conversionFn(input);\n }\n if (schema2 instanceof Array) {\n return input.map((v) => convert(conversionFn, schema2[0], v));\n }\n if (schema2 instanceof Object) {\n const output = {};\n for (const [key, schemaField] of Object.entries(schema2)) {\n if (schemaField.derive) {\n const v = schemaField.derive(input);\n if (v !== void 0) {\n input[key] = v;\n }\n }\n if (!(key in input)) {\n if (schemaField.required) {\n throw new Error(`Missing key: ${key}`);\n }\n continue;\n }\n if (input[key] == null) {\n output[key] = null;\n continue;\n }\n output[key] = convert(\n conversionFn,\n schemaField.schema,\n input[key]\n );\n }\n return output;\n }\n}\nfunction derived(schema2, derive) {\n return {\n required: true,\n schema: schema2,\n derive\n };\n}\nfunction required(schema2) {\n return {\n required: true,\n schema: schema2\n };\n}\nfunction optional(schema2) {\n return {\n required: false,\n schema: schema2\n };\n}\n\n// src/webauthn-json/basic/schema.ts\nvar publicKeyCredentialDescriptorSchema = {\n type: required(copyValue),\n id: required(convertValue),\n transports: optional(copyValue)\n};\nvar simplifiedExtensionsSchema = {\n appid: optional(copyValue),\n appidExclude: optional(copyValue),\n credProps: optional(copyValue)\n};\nvar simplifiedClientExtensionResultsSchema = {\n appid: optional(copyValue),\n appidExclude: optional(copyValue),\n credProps: optional(copyValue)\n};\nvar credentialCreationOptions = {\n publicKey: required({\n rp: required(copyValue),\n user: required({\n id: required(convertValue),\n name: required(copyValue),\n displayName: required(copyValue)\n }),\n challenge: required(convertValue),\n pubKeyCredParams: required(copyValue),\n timeout: optional(copyValue),\n excludeCredentials: optional([publicKeyCredentialDescriptorSchema]),\n authenticatorSelection: optional(copyValue),\n attestation: optional(copyValue),\n extensions: optional(simplifiedExtensionsSchema)\n }),\n signal: optional(copyValue)\n};\nvar publicKeyCredentialWithAttestation = {\n type: required(copyValue),\n id: required(copyValue),\n rawId: required(convertValue),\n authenticatorAttachment: optional(copyValue),\n response: required({\n clientDataJSON: required(convertValue),\n attestationObject: required(convertValue),\n transports: derived(\n copyValue,\n (response) => {\n var _a;\n return ((_a = response.getTransports) == null ? void 0 : _a.call(response)) || [];\n }\n )\n }),\n clientExtensionResults: derived(\n simplifiedClientExtensionResultsSchema,\n (pkc) => pkc.getClientExtensionResults()\n )\n};\nvar credentialRequestOptions = {\n mediation: optional(copyValue),\n publicKey: required({\n challenge: required(convertValue),\n timeout: optional(copyValue),\n rpId: optional(copyValue),\n allowCredentials: optional([publicKeyCredentialDescriptorSchema]),\n userVerification: optional(copyValue),\n extensions: optional(simplifiedExtensionsSchema)\n }),\n signal: optional(copyValue)\n};\nvar publicKeyCredentialWithAssertion = {\n type: required(copyValue),\n id: required(copyValue),\n rawId: required(convertValue),\n authenticatorAttachment: optional(copyValue),\n response: required({\n clientDataJSON: required(convertValue),\n authenticatorData: required(convertValue),\n signature: required(convertValue),\n userHandle: required(convertValue)\n }),\n clientExtensionResults: derived(\n simplifiedClientExtensionResultsSchema,\n (pkc) => pkc.getClientExtensionResults()\n )\n};\nvar schema = {\n credentialCreationOptions,\n publicKeyCredentialWithAttestation,\n credentialRequestOptions,\n publicKeyCredentialWithAssertion\n};\n\n// src/webauthn-json/basic/api.ts\nfunction createRequestFromJSON(requestJSON) {\n return convert(base64urlToBuffer, credentialCreationOptions, requestJSON);\n}\nfunction createResponseToJSON(credential) {\n return convert(\n bufferToBase64url,\n publicKeyCredentialWithAttestation,\n credential\n );\n}\nasync function create(requestJSON) {\n const credential = await navigator.credentials.create(\n createRequestFromJSON(requestJSON)\n );\n return createResponseToJSON(credential);\n}\nfunction getRequestFromJSON(requestJSON) {\n return convert(base64urlToBuffer, credentialRequestOptions, requestJSON);\n}\nfunction getResponseToJSON(credential) {\n return convert(\n bufferToBase64url,\n publicKeyCredentialWithAssertion,\n credential\n );\n}\nasync function get(requestJSON) {\n const credential = await navigator.credentials.get(\n getRequestFromJSON(requestJSON)\n );\n return getResponseToJSON(credential);\n}\n\n// src/webauthn-json/basic/supported.ts\nfunction supported() {\n return !!(navigator.credentials && navigator.credentials.create && navigator.credentials.get && window.PublicKeyCredential);\n}\nexport {\n create,\n get,\n schema,\n supported\n};\n//# sourceMappingURL=webauthn-json.js.map\n","/**\n * A class to check the browser's WebAuthn support.\n *\n * @hideconstructor\n * @category SDK\n * @subcategory Utilities\n */\nclass WebauthnSupport {\n /**\n * Does a simple check to test for the credential management API functions we need, and an indication of\n * public key credential authentication support.\n *\n * @see https://developers.google.com/web/updates/2018/03/webauthn-credential-management\n * @return boolean\n */\n static supported(): boolean {\n return !!(\n navigator.credentials &&\n navigator.credentials.create &&\n navigator.credentials.get &&\n window.PublicKeyCredential\n );\n }\n\n /**\n * Checks whether a user-verifying platform authenticator is available.\n *\n * @return Promise<boolean>\n */\n static async isPlatformAuthenticatorAvailable(): Promise<boolean> {\n if (\n this.supported() &&\n window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable\n ) {\n return window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();\n }\n\n return false;\n }\n\n /**\n * Checks whether external CTAP2 security keys are supported.\n *\n * @return Promise<boolean>\n */\n static async isSecurityKeySupported(): Promise<boolean> {\n if (\n window.PublicKeyCredential !== undefined &&\n // @ts-ignore\n window.PublicKeyCredential.isExternalCTAP2SecurityKeySupported\n ) {\n // @ts-ignore\n return window.PublicKeyCredential.isExternalCTAP2SecurityKeySupported();\n }\n\n return this.supported();\n }\n\n /**\n * Checks whether autofill assisted requests are supported.\n *\n * @return Promise<boolean>\n */\n static async isConditionalMediationAvailable(): Promise<boolean> {\n if (\n // @ts-ignore\n window.PublicKeyCredential &&\n // @ts-ignore\n window.PublicKeyCredential.isConditionalMediationAvailable\n ) {\n // @ts-ignore\n return window.PublicKeyCredential.isConditionalMediationAvailable();\n }\n\n return false;\n }\n}\n\nexport { WebauthnSupport };\n","import { UserState } from \"./UserState\";\nimport { Credential } from \"../Dto\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {string[]?} credentials - A list of known credential IDs on the current browser.\n */\nexport interface LocalStorageWebauthn {\n credentials?: string[];\n}\n\n/**\n * A class that manages WebAuthn credentials via local storage.\n *\n * @extends UserState\n * @category SDK\n * @subcategory Internal\n */\nclass WebauthnState extends UserState {\n /**\n * Gets the WebAuthn state.\n *\n * @private\n * @param {string} userID - The UUID of the user.\n * @return {LocalStorageWebauthn}\n */\n private getState(userID: string): LocalStorageWebauthn {\n return (super.getUserState(userID).webauthn ||= {});\n }\n\n /**\n * Reads the current state.\n *\n * @public\n * @return {WebauthnState}\n */\n read(): WebauthnState {\n super.read();\n\n return this;\n }\n\n /**\n * Gets the list of known credentials on the current browser.\n *\n * @param {string} userID - The UUID of the user.\n * @return {string[]}\n */\n getCredentials(userID: string): string[] {\n return (this.getState(userID).credentials ||= []);\n }\n\n /**\n * Adds the credential to the list of known credentials.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} credentialID - The WebAuthn credential ID.\n * @return {WebauthnState}\n */\n addCredential(userID: string, credentialID: string): WebauthnState {\n this.getCredentials(userID).push(credentialID);\n\n return this;\n }\n\n /**\n * Returns the intersection between the specified list of credentials and the known credentials stored in\n * the local storage.\n *\n * @param {string} userID - The UUID of the user.\n * @param {Credential[]} match - A list of credential IDs to be matched against the local storage.\n * @return {Credential[]}\n */\n matchCredentials(userID: string, match: Credential[]): Credential[] {\n return this.getCredentials(userID)\n .filter((id) => match.find((c) => c.id === id))\n .map((id: string) => ({ id } as Credential));\n }\n}\n\nexport { WebauthnState };\n","import {\n create as createWebauthnCredential,\n get as getWebauthnCredential,\n} from \"@github/webauthn-json\";\n\nimport { WebauthnSupport } from \"../WebauthnSupport\";\nimport { Client } from \"./Client\";\nimport { PasscodeState } from \"../state/PasscodeState\";\n\nimport { WebauthnState } from \"../state/WebauthnState\";\n\nimport {\n InvalidWebauthnCredentialError,\n TechnicalError,\n UnauthorizedError,\n WebauthnRequestCancelledError,\n UserVerificationError,\n} from \"../Errors\";\n\nimport {\n Attestation,\n User,\n WebauthnFinalized,\n WebauthnCredentials,\n} from \"../Dto\";\n\n/**\n * A class that handles WebAuthn authentication and registration.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass WebauthnClient extends Client {\n webauthnState: WebauthnState;\n passcodeState: PasscodeState;\n controller: AbortController;\n\n _getCredential = getWebauthnCredential;\n _createCredential = createWebauthnCredential;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n super(api, timeout);\n /**\n * @public\n * @type {WebauthnState}\n */\n this.webauthnState = new WebauthnState();\n /**\n * @public\n * @type {PasscodeState}\n */\n this.passcodeState = new PasscodeState();\n }\n\n /**\n * Performs a WebAuthn authentication ceremony. When 'userID' is specified, the API provides a list of\n * allowed credentials and the browser is able to present a list of suitable credentials to the user.\n *\n * @param {string=} userID - The user's UUID.\n * @param {boolean=} useConditionalMediation - Enables autofill assisted login.\n * @return {Promise<void>}\n * @throws {WebauthnRequestCancelledError}\n * @throws {InvalidWebauthnCredentialError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/webauthnLoginInit\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/webauthnLoginFinal\n * @see https://www.w3.org/TR/webauthn-2/#authentication-ceremony\n */\n async login(\n userID?: string,\n useConditionalMediation?: boolean\n ): Promise<void> {\n const challengeResponse = await this.client.post(\n \"/webauthn/login/initialize\",\n { user_id: userID }\n );\n\n if (!challengeResponse.ok) {\n throw new TechnicalError();\n }\n\n const challenge = challengeResponse.json();\n challenge.signal = this._createAbortSignal();\n\n if (useConditionalMediation) {\n // `CredentialMediationRequirement` doesn't support \"conditional\" in the current typescript version.\n challenge.mediation = \"conditional\" as CredentialMediationRequirement;\n }\n\n let assertion;\n try {\n assertion = await this._getCredential(challenge);\n } catch (e) {\n throw new WebauthnRequestCancelledError(e);\n }\n\n const assertionResponse = await this.client.post(\n \"/webauthn/login/finalize\",\n assertion\n );\n\n if (assertionResponse.status === 400 || assertionResponse.status === 401) {\n throw new InvalidWebauthnCredentialError();\n } else if (!assertionResponse.ok) {\n throw new TechnicalError();\n }\n\n const finalizeResponse: WebauthnFinalized = assertionResponse.json();\n\n this.webauthnState\n .read()\n .addCredential(finalizeResponse.user_id, finalizeResponse.credential_id)\n .write();\n\n this.passcodeState.read().reset(userID).write();\n\n return;\n }\n\n /**\n * Performs a WebAuthn registration ceremony.\n *\n * @return {Promise<void>}\n * @throws {WebauthnRequestCancelledError}\n * @throws {RequestTimeoutError}\n * @throws {UnauthorizedError}\n * @throws {TechnicalError}\n * @throws {UserVerificationError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/webauthnRegInit\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/webauthnRegFinal\n * @see https://www.w3.org/TR/webauthn-2/#sctn-registering-a-new-credential\n */\n async register(): Promise<void> {\n const challengeResponse = await this.client.post(\n \"/webauthn/registration/initialize\"\n );\n\n if (challengeResponse.status >= 400 && challengeResponse.status <= 499) {\n throw new UnauthorizedError();\n } else if (!challengeResponse.ok) {\n throw new TechnicalError();\n }\n\n const challenge = challengeResponse.json();\n challenge.signal = this._createAbortSignal();\n\n let attestation;\n try {\n attestation = (await this._createCredential(challenge)) as Attestation;\n } catch (e) {\n throw new WebauthnRequestCancelledError(e);\n }\n\n // The generated PublicKeyCredentialWithAttestationJSON object does not align with the API. The list of\n // supported transports must be available under a different path.\n attestation.transports = attestation.response.transports;\n\n const attestationResponse = await this.client.post(\n \"/webauthn/registration/finalize\",\n attestation\n );\n\n if (\n attestationResponse.status >= 400 &&\n attestationResponse.status <= 499\n ) {\n if (attestationResponse.status === 422) {\n throw new UserVerificationError();\n }\n throw new UnauthorizedError();\n }\n if (!attestationResponse.ok) {\n throw new TechnicalError();\n }\n\n const finalizeResponse: WebauthnFinalized = attestationResponse.json();\n this.webauthnState\n .read()\n .addCredential(finalizeResponse.user_id, finalizeResponse.credential_id)\n .write();\n\n return;\n }\n\n /**\n * Returns a list of all WebAuthn credentials assigned to the current user.\n *\n * @return {Promise<WebauthnCredentials>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/listCredentials\n */\n async listCredentials(): Promise<WebauthnCredentials> {\n const response = await this.client.get(\"/webauthn/credentials\");\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n\n /**\n * Updates the WebAuthn credential.\n *\n * @param {string=} credentialID - The credential's UUID.\n * @param {string} name - The new credential name.\n * @return {Promise<void>}\n * @throws {NotFoundError}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/updateCredential\n */\n async updateCredential(credentialID: string, name: string): Promise<void> {\n const response = await this.client.patch(\n `/webauthn/credentials/${credentialID}`,\n {\n name,\n }\n );\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n\n /**\n * Deletes the WebAuthn credential.\n *\n * @param {string=} credentialID - The credential's UUID.\n * @return {Promise<void>}\n * @throws {NotFoundError}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/deleteCredential\n */\n async deleteCredential(credentialID: string): Promise<void> {\n const response = await this.client.delete(\n `/webauthn/credentials/${credentialID}`\n );\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n\n /**\n * Determines whether a credential registration ceremony should be performed. Returns 'true' when WebAuthn\n * is supported and the user's credentials do not intersect with the credentials already known on the\n * current browser/device.\n *\n * @param {User} user - The user object.\n * @return {Promise<boolean>}\n */\n async shouldRegister(user: User): Promise<boolean> {\n const supported = WebauthnSupport.supported();\n\n if (!user.webauthn_credentials || !user.webauthn_credentials.length) {\n return supported;\n }\n\n const matches = this.webauthnState\n .read()\n .matchCredentials(user.id, user.webauthn_credentials);\n\n return supported && !matches.length;\n }\n\n // eslint-disable-next-line require-jsdoc\n _createAbortSignal() {\n if (this.controller) {\n this.controller.abort();\n }\n\n this.controller = new AbortController();\n return this.controller.signal;\n }\n}\n\nexport { WebauthnClient };\n","import { Client } from \"./Client\";\nimport {\n EmailAddressAlreadyExistsError,\n MaxNumOfEmailAddressesReachedError,\n TechnicalError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Email, Emails } from \"../Dto\";\n\n/**\n * Manages email addresses of the current user.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass EmailClient extends Client {\n /**\n * Returns a list of all email addresses assigned to the current user.\n *\n * @return {Promise<Emails>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/listEmails\n */\n async list(): Promise<Emails> {\n const response = await this.client.get(\"/emails\");\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n\n /**\n * Adds a new email address to the current user.\n *\n * @param {string} address - The email address to be added.\n * @return {Promise<Email>}\n * @throws {EmailAddressAlreadyExistsError}\n * @throws {MaxNumOfEmailAddressesReachedError}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/createEmail\n */\n async create(address: string): Promise<Email> {\n const response = await this.client.post(\"/emails\", { address });\n\n if (response.ok) {\n return response.json();\n }\n\n if (response.status === 400) {\n throw new EmailAddressAlreadyExistsError();\n } else if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (response.status === 409) {\n throw new MaxNumOfEmailAddressesReachedError();\n }\n\n throw new TechnicalError();\n }\n\n /**\n * Marks the specified email address as primary.\n *\n * @param {string} emailID - The ID of the email address to be updated\n * @return {Promise<void>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/setPrimaryEmail\n */\n async setPrimaryEmail(emailID: string): Promise<void> {\n const response = await this.client.post(`/emails/${emailID}/set_primary`);\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n\n /**\n * Deletes the specified email address.\n *\n * @param {string} emailID - The ID of the email address to be deleted\n * @return {Promise<void>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/deleteEmail\n */\n async delete(emailID: string): Promise<void> {\n const response = await this.client.delete(`/emails/${emailID}`);\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n}\n\nexport { EmailClient };\n","import { Client } from \"./Client\";\nimport { ThirdPartyError } from \"../Errors\";\n\n/**\n * A class that handles communication with the Hanko API for the purposes\n * of authenticating through a third party provider.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nexport class ThirdPartyClient extends Client {\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n super(api, timeout);\n }\n\n /**\n * Performs a request to the Hanko API that redirects to the given\n * third party provider.\n *\n * @param {string} provider - The name of the third party provider\n * @param {string} redirectTo - The URL to redirect to after a successful third party authentication\n * @throws {ThirdPartyError}\n * @see http://docs.hanko.io/api/public#tag/Third-Party/operation/thirdPartyAuth\n */\n async auth(provider: string, redirectTo: string): Promise<void> {\n const url = new URL(\"/thirdparty/auth\", this.client.api);\n\n if (!provider) {\n throw new ThirdPartyError(\n \"somethingWentWrong\",\n new Error(\"provider missing from request\")\n );\n }\n\n if (!redirectTo) {\n throw new ThirdPartyError(\n \"somethingWentWrong\",\n new Error(\"redirectTo missing from request\")\n );\n }\n\n url.searchParams.append(\"provider\", provider);\n url.searchParams.append(\"redirect_to\", redirectTo);\n\n window.location.assign(url.href);\n }\n\n /**\n * Get a third party error from the current location's query params.\n * @returns {(ThirdPartyError|undefined)} The ThirdPartyError.\n */\n getError() {\n const params = new URLSearchParams(window.location.search);\n const error = params.get(\"error\");\n const errorDescription = params.get(\"error_description\");\n if (error) {\n let code = \"\";\n switch (error) {\n case \"access_denied\":\n code = \"thirdPartyAccessDenied\";\n break;\n case \"user_conflict\":\n code = \"emailAddressAlreadyExistsError\";\n break;\n case \"multiple_accounts\":\n code = \"thirdPartyMultipleAccounts\";\n break;\n case \"unverified_email\":\n code = \"thirdPartyUnverifiedEmail\";\n break;\n case \"email_maxnum\":\n code = \"maxNumOfEmailAddressesReached\";\n break;\n default:\n code = \"somethingWentWrong\";\n }\n\n return new ThirdPartyError(code, new Error(errorDescription));\n }\n }\n}\n","import { ConfigClient } from \"./lib/client/ConfigClient\";\nimport { PasscodeClient } from \"./lib/client/PasscodeClient\";\nimport { PasswordClient } from \"./lib/client/PasswordClient\";\nimport { UserClient } from \"./lib/client/UserClient\";\nimport { WebauthnClient } from \"./lib/client/WebauthnClient\";\nimport { EmailClient } from \"./lib/client/EmailClient\";\nimport { ThirdPartyClient } from \"./lib/client/ThirdPartyClient\";\n\n/**\n * A class that bundles all available SDK functions.\n *\n * @param {string} api - The URL of your Hanko API instance\n * @param {number=} timeout - The request timeout in milliseconds\n */\nclass Hanko {\n api: string;\n config: ConfigClient;\n user: UserClient;\n webauthn: WebauthnClient;\n password: PasswordClient;\n passcode: PasscodeClient;\n email: EmailClient;\n thirdParty: ThirdPartyClient;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n this.api = api;\n /**\n * @public\n * @type {ConfigClient}\n */\n this.config = new ConfigClient(api, timeout);\n /**\n * @public\n * @type {UserClient}\n */\n this.user = new UserClient(api, timeout);\n /**\n * @public\n * @type {WebauthnClient}\n */\n this.webauthn = new WebauthnClient(api, timeout);\n /**\n * @public\n * @type {PasswordClient}\n */\n this.password = new PasswordClient(api, timeout);\n /**\n * @public\n * @type {PasscodeClient}\n */\n this.passcode = new PasscodeClient(api, timeout);\n /**\n * @public\n * @type {EmailClient}\n */\n this.email = new EmailClient(api, timeout);\n /**\n * @public\n * @type {ThirdPartyClient}\n */\n this.thirdParty = new ThirdPartyClient(api, timeout);\n }\n}\n\nexport { Hanko };\n"],"names":["HankoError","message","code","cause","_this","this","Object","setPrototypeOf","_assertThisInitialized","prototype","Error","TechnicalError","_HankoError","_this2","call","_inheritsLoose","userID","_this3","_HankoError2","ConflictError","_this4","_HankoError3","RequestTimeoutError","_this5","_HankoError4","WebauthnRequestCancelledError","InvalidPasswordError","_HankoError5","_this6","InvalidPasscodeError","_HankoError6","_this7","InvalidWebauthnCredentialError","_HankoError7","_this8","PasscodeExpiredError","_HankoError8","_this9","MaxNumOfPasscodeAttemptsReachedError","_this10","_HankoError9","_this11","_HankoError10","NotFoundError","retryAfter","_this12","_HankoError11","TooManyRequestsError","_this13","_HankoError12","UnauthorizedError","_this14","_HankoError13","UserVerificationError","MaxNumOfEmailAddressesReachedError","_HankoError14","_this15","EmailAddressAlreadyExistsError","_HankoError15","_this16","ThirdPartyError","_HankoError16","_this17","assign","target","i","arguments","length","source","key","api","init","converter","defaultAttributes","set","value","attributes","document","expires","Date","now","toUTCString","encodeURIComponent","replace","decodeURIComponent","escape","stringifiedAttributes","attributeName","split","cookie","write","create","get","cookies","jar","parts","slice","join","foundKey","read","e","remove","withAttributes","withConverter","freeze","path","Headers","xhr","_xhr","name","getResponseHeader","headers","ok","status","statusText","url","_decodedJSON","responseURL","HttpClient","json","JSON","parse","response","parseRetryAfterHeader","result","parseInt","isNaN","timeout","_fetch","options","XMLHttpRequest","cookieName","bearerToken","Cookies","resolve","reject","open","method","setRequestHeader","withCredentials","onload","getAllResponseHeaders","filter","h","toLowerCase","startsWith","authToken","secure","match","Response","onerror","ontimeout","send","body","toString","post","stringify","put","patch","_proto3","client","ConfigClient","Client","Promise","ls","data","localStorage","getItem","decoded","decodeURI","window","atob","store","encoded","btoa","encodeURI","setItem","timeToRemainingSeconds","time","Math","floor","remainingSecondsToTime","seconds","State","UserState","getUserState","_this$ls","users","hasOwnProperty","PasscodeState","getState","_UserState$prototype$","passcode","_UserState","getActiveID","id","setActiveID","passcodeID","getEmailID","emailID","setEmailID","reset","ttl","resendAfter","getTTL","setTTL","getResendAfter","setResendAfter","PasscodeClient","_Client","state","initialize","force","lastPasscodeTTL","lastPasscodeID","lastEmailID","user_id","email_id","finalize","then","password","getRetryAfter","setRetryAfter","passwordState","passcodeState","PasswordState","login","update","UserClient","getInfo","email","getCurrent","meResponse","me","userResponse","base64urlToBuffer","baseurl64String","padding","base64String","str","buffer","ArrayBuffer","byteView","Uint8Array","charCodeAt","bufferToBase64url","charCode","String","fromCharCode","convert","conversionFn","schema2","input","Array","map","v","output","schemaField","entries","derive","schema","required","derived","optional","publicKeyCredentialDescriptorSchema","type","transports","simplifiedExtensionsSchema","appid","appidExclude","credProps","simplifiedClientExtensionResultsSchema","credentialCreationOptions","publicKey","rp","user","displayName","challenge","pubKeyCredParams","excludeCredentials","authenticatorSelection","attestation","extensions","signal","publicKeyCredentialWithAttestation","rawId","authenticatorAttachment","clientDataJSON","attestationObject","_a","getTransports","clientExtensionResults","pkc","getClientExtensionResults","credentialRequestOptions","mediation","rpId","allowCredentials","userVerification","publicKeyCredentialWithAssertion","authenticatorData","signature","userHandle","async","requestJSON","credential","navigator","credentials","createRequestFromJSON","createResponseToJSON","getRequestFromJSON","getResponseToJSON","WebauthnSupport","supported","PublicKeyCredential","isPlatformAuthenticatorAvailable","isUserVerifyingPlatformAuthenticatorAvailable","isSecurityKeySupported","undefined","isExternalCTAP2SecurityKeySupported","isConditionalMediationAvailable","WebauthnState","webauthn","getCredentials","_this$getState","addCredential","credentialID","push","matchCredentials","find","c","WebauthnClient","webauthnState","controller","_getCredential","getWebauthnCredential","_createCredential","createWebauthnCredential","useConditionalMediation","challengeResponse","_temp2","_result","assertion","assertionResponse","finalizeResponse","credential_id","_createAbortSignal","_temp","_catch","_this2$_getCredential","register","attestationResponse","_this4$_createCredent","listCredentials","updateCredential","deleteCredential","shouldRegister","webauthn_credentials","matches","abort","AbortController","EmailClient","list","address","setPrimaryEmail","ThirdPartyClient","_proto","auth","provider","redirectTo","URL","searchParams","append","location","href","getError","params","URLSearchParams","search","error","errorDescription","Hanko","config","thirdParty","PasswordClient"],"mappings":"43CAUeA,+BAKb,SAAsBC,EAAAA,EAAiBC,EAAcC,GAAa,IAAAC,EAAA,OAChEA,EAAMH,EAAAA,KAAAA,KAAAA,IAD0DI,MAJlEH,UAIkE,EAAAE,EAHlED,WAGkE,EAMhEC,EAAKF,KAAOA,EAKZE,EAAKD,MAAQA,EACbG,OAAOC,eAAPC,EAAAJ,GAA4BJ,EAAWS,WACxCL,CAAA,eAlB+BM,CAAAA,eAAAA,EAAAA,QA6B5BC,eAEJ,SAAAC,GAAA,SAAAD,EAAYR,GACV,IAAAU,EADuB,OACvBA,EAAAD,EAAAE,KAAAT,KAAM,kBAAmB,qBAAsBF,IAA/CE,KACAC,OAAOC,e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CAAA,CAAA,CAAsC3M,GCEhC2N,GAWJ,SAAYvT,EAAayD,QAAe,IAAfA,IAAAA,EAAU,MAVnCzD,KAAAA,SACAwT,EAAAA,KAAAA,mBACA3G,UAQwC,EAAA9Q,KAPxC6T,cAOwC,EAAA7T,KANxCuN,cAMwC,EAAAvN,KALxC2L,cAKwC,EAAA3L,KAJxCiO,WACAyJ,EAAAA,KAAAA,gBAIE,EAAA1X,KAAKiE,IAAMA,EAKXjE,KAAKyX,OAAS,IAAA7N,EAAiB3F,EAAKyD,GAKpC1H,KAAK8Q,KAAO,MAAe7M,EAAKyD,GAKhC1H,KAAK6T,SAAW,IAAIS,GAAerQ,EAAKyD,GAKxC1H,KAAKuN,SAAW,IAAAoK,EAAmB1T,EAAKyD,GAKxC1H,KAAK2L,SAAW,MAAmB1H,EAAKyD,GAKxC1H,KAAKiO,MAAQ,IAAAmI,GAAgBnS,EAAKyD,GAKlC1H,KAAK0X,WAAa,IAAIlB,GAAiBvS,EAAKyD,EAC7C"}
1
+ {"version":3,"file":"sdk.module.js","sources":["../src/lib/Errors.ts","../../node_modules/js-cookie/dist/js.cookie.mjs","../src/lib/client/HttpClient.ts","../src/lib/client/Client.ts","../src/lib/client/ConfigClient.ts","../src/lib/state/State.ts","../src/lib/state/UserState.ts","../src/lib/state/PasscodeState.ts","../src/lib/client/PasscodeClient.ts","../src/lib/state/PasswordState.ts","../src/lib/client/PasswordClient.ts","../src/lib/client/UserClient.ts","../../node_modules/@github/webauthn-json/dist/esm/webauthn-json.js","../src/lib/WebauthnSupport.ts","../src/lib/state/WebauthnState.ts","../src/lib/client/WebauthnClient.ts","../src/lib/client/EmailClient.ts","../src/lib/client/ThirdPartyClient.ts","../src/lib/client/TokenClient.ts","../src/Hanko.ts"],"sourcesContent":["/**\n * Every error thrown in the SDK is an instance of 'HankoError'. The value of the 'code' property is eligible to\n * translate the error into an error message.\n *\n * @extends {Error}\n * @category SDK\n * @subcategory Errors\n * @param code {string} - An error code that refers to the error instance.\n * @param cause {Error=} - The original error\n */\nabstract class HankoError extends Error {\n code: string;\n cause?: Error;\n\n // eslint-disable-next-line require-jsdoc\n protected constructor(message: string, code: string, cause?: Error) {\n super(message);\n /**\n * @public\n * @type {string}\n */\n this.code = code;\n /**\n * @public\n * @type {Error=}\n */\n this.cause = cause;\n Object.setPrototypeOf(this, HankoError.prototype);\n }\n}\n\n/**\n * Every error that doesn't need to be handled in a special way is a 'TechnicalError'. Whenever you catch one, there is\n * usually nothing you can do but present an error to the user, e.g. \"Something went wrong\".\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass TechnicalError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Technical error\", \"somethingWentWrong\", cause);\n Object.setPrototypeOf(this, TechnicalError.prototype);\n }\n}\n\n/**\n * Attempting to create a resource that already exists results in a 'ConflictError'.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass ConflictError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(userID?: string, cause?: Error) {\n super(\"Conflict error\", \"conflict\", cause);\n Object.setPrototypeOf(this, ConflictError.prototype);\n }\n}\n\n/**\n * A 'RequestTimeoutError' occurs when the specified timeout has been reached.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass RequestTimeoutError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Request timed out error\", \"requestTimeout\", cause);\n Object.setPrototypeOf(this, RequestTimeoutError.prototype);\n }\n}\n\n/**\n * A 'WebauthnRequestCancelledError' occurs during WebAuthn authentication or registration, when the WebAuthn API throws\n * an error. In most cases, this happens when the user cancels the browser's WebAuthn dialog.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass WebauthnRequestCancelledError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Request cancelled error\", \"requestCancelled\", cause);\n Object.setPrototypeOf(this, WebauthnRequestCancelledError.prototype);\n }\n}\n\n/**\n * An 'InvalidPasswordError' occurs when invalid credentials are provided when logging in with a password.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass InvalidPasswordError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Invalid password error\", \"invalidPassword\", cause);\n Object.setPrototypeOf(this, InvalidPasswordError.prototype);\n }\n}\n\n/**\n * An 'InvalidPasswordError' occurs when an incorrect code is entered when logging in with a passcode.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass InvalidPasscodeError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Invalid Passcode error\", \"invalidPasscode\", cause);\n Object.setPrototypeOf(this, InvalidPasscodeError.prototype);\n }\n}\n\n/**\n * An 'InvalidWebauthnCredentialError' occurs if invalid credentials were used when logging in with WebAuthn.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass InvalidWebauthnCredentialError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\n \"Invalid WebAuthn credential error\",\n \"invalidWebauthnCredential\",\n cause\n );\n Object.setPrototypeOf(this, InvalidWebauthnCredentialError.prototype);\n }\n}\n\n/**\n * A 'PasscodeExpiredError' occurs when the passcode has expired.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass PasscodeExpiredError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Passcode expired error\", \"passcodeExpired\", cause);\n Object.setPrototypeOf(this, PasscodeExpiredError.prototype);\n }\n}\n\n/**\n * A 'MaxNumOfPasscodeAttemptsReachedError' occurs when an incorrect passcode is provided too many times.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass MaxNumOfPasscodeAttemptsReachedError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\n \"Maximum number of Passcode attempts reached error\",\n \"passcodeAttemptsReached\",\n cause\n );\n Object.setPrototypeOf(this, MaxNumOfPasscodeAttemptsReachedError.prototype);\n }\n}\n\n/**\n * A 'NotFoundError' occurs when the requested resource was not found.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass NotFoundError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Not found error\", \"notFound\", cause);\n Object.setPrototypeOf(this, NotFoundError.prototype);\n }\n}\n\n/**\n * A 'TooManyRequestsError' occurs due to rate limiting when too many requests are made.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass TooManyRequestsError extends HankoError {\n retryAfter?: number;\n // eslint-disable-next-line require-jsdoc\n constructor(retryAfter?: number, cause?: Error) {\n super(\"Too many requests error\", \"tooManyRequests\", cause);\n this.retryAfter = retryAfter;\n Object.setPrototypeOf(this, TooManyRequestsError.prototype);\n }\n}\n\n/**\n * An 'UnauthorizedError' occurs when the user is not authorized to access the resource.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass UnauthorizedError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Unauthorized error\", \"unauthorized\", cause);\n Object.setPrototypeOf(this, UnauthorizedError.prototype);\n }\n}\n\n/**\n * A 'UserVerificationError' occurs when the user verification requirements\n * for a WebAuthn ceremony are not met.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass UserVerificationError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"User verification error\", \"userVerification\", cause);\n Object.setPrototypeOf(this, UserVerificationError.prototype);\n }\n}\n\n/**\n * A 'MaxNumOfEmailAddressesReachedError' occurs when the user tries to add a new email address while the maximum number\n * of email addresses (see backend configuration) equals the number of email addresses already registered.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass MaxNumOfEmailAddressesReachedError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\n \"Maximum number of email addresses reached error\",\n \"maxNumOfEmailAddressesReached\",\n cause\n );\n Object.setPrototypeOf(this, MaxNumOfEmailAddressesReachedError.prototype);\n }\n}\n\n/**\n * An 'EmailAddressAlreadyExistsError' occurs when the user tries to add a new email address which already exists.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass EmailAddressAlreadyExistsError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\n \"The email address already exists\",\n \"emailAddressAlreadyExistsError\",\n cause\n );\n Object.setPrototypeOf(this, EmailAddressAlreadyExistsError.prototype);\n }\n}\n\n/**\n * A `ThirdPartyError` may occur during a sign in/sign up with a third party\n * provider.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass ThirdPartyError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(code: string, cause?: Error) {\n super(\"An error occurred during third party sign up/sign in\", code, cause);\n Object.setPrototypeOf(this, ThirdPartyError.prototype);\n }\n}\n\nexport {\n HankoError,\n TechnicalError,\n ConflictError,\n RequestTimeoutError,\n WebauthnRequestCancelledError,\n InvalidPasswordError,\n InvalidPasscodeError,\n InvalidWebauthnCredentialError,\n PasscodeExpiredError,\n MaxNumOfPasscodeAttemptsReachedError,\n NotFoundError,\n TooManyRequestsError,\n UnauthorizedError,\n UserVerificationError,\n MaxNumOfEmailAddressesReachedError,\n EmailAddressAlreadyExistsError,\n ThirdPartyError,\n};\n","/*! js-cookie v3.0.1 | MIT */\n/* eslint-disable no-var */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n target[key] = source[key];\n }\n }\n return target\n}\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\n\nfunction init (converter, defaultAttributes) {\n function set (key, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n key = encodeURIComponent(key)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n key + '=' + converter.write(value, key) + stringifiedAttributes)\n }\n\n function get (key) {\n if (typeof document === 'undefined' || (arguments.length && !key)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var foundKey = decodeURIComponent(parts[0]);\n jar[foundKey] = converter.read(value, foundKey);\n\n if (key === foundKey) {\n break\n }\n } catch (e) {}\n }\n\n return key ? jar[key] : jar\n }\n\n return Object.create(\n {\n set: set,\n get: get,\n remove: function (key, attributes) {\n set(\n key,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n/* eslint-enable no-var */\n\nexport default api;\n","import Cookies from \"js-cookie\";\nimport { RequestTimeoutError, TechnicalError } from \"../Errors\";\n\n/**\n * This class wraps an XMLHttpRequest to maintain compatibility with the fetch API.\n *\n * @category SDK\n * @subcategory Internal\n * @param {XMLHttpRequest} xhr - The request to be wrapped.\n * @see HttpClient\n */\nclass Headers {\n _xhr: XMLHttpRequest;\n\n // eslint-disable-next-line require-jsdoc\n constructor(xhr: XMLHttpRequest) {\n this._xhr = xhr;\n }\n\n /**\n * Returns the response header with the given name.\n *\n * @param {string} name\n * @return {string}\n */\n get(name: string) {\n return this._xhr.getResponseHeader(name);\n }\n}\n\n/**\n * This class wraps an XMLHttpRequest to maintain compatibility with the fetch API.\n *\n * @category SDK\n * @subcategory Internal\n * @param {XMLHttpRequest} xhr - The request to be wrapped.\n * @see HttpClient\n */\nclass Response {\n headers: Headers;\n ok: boolean;\n status: number;\n statusText: string;\n url: string;\n _decodedJSON: any;\n private xhr: XMLHttpRequest;\n\n // eslint-disable-next-line require-jsdoc\n constructor(xhr: XMLHttpRequest) {\n /**\n * @public\n * @type {Headers}\n */\n this.headers = new Headers(xhr);\n /**\n * @public\n * @type {boolean}\n */\n this.ok = xhr.status >= 200 && xhr.status <= 299;\n /**\n * @public\n * @type {number}\n */\n this.status = xhr.status;\n /**\n * @public\n * @type {string}\n */\n this.statusText = xhr.statusText;\n /**\n * @public\n * @type {string}\n */\n this.url = xhr.responseURL;\n /**\n * @private\n * @type {XMLHttpRequest}\n */\n this.xhr = xhr;\n }\n\n /**\n * Returns the JSON decoded response.\n *\n * @return {any}\n */\n json() {\n if (!this._decodedJSON) {\n this._decodedJSON = JSON.parse(this.xhr.response);\n }\n return this._decodedJSON;\n }\n\n /**\n * Returns the value for Retry-After contained in the response header.\n *\n * @return {number}\n */\n parseRetryAfterHeader(): number {\n const result = parseInt(this.headers.get(\"Retry-After\"), 10);\n return isNaN(result) ? 0 : result;\n }\n}\n\n/**\n * Internally used for communication with the Hanko API. It also handles authorization tokens to enable authorized\n * requests.\n *\n * Currently, there is an issue with Safari and on iOS 15 devices where decoding a JSON response via the fetch API\n * breaks the user gesture and the user is not able to use the authenticator. Therefore, this class uses XMLHttpRequests\n * instead of the fetch API, but maintains compatibility by wrapping the XMLHttpRequests. So, if the issues are fixed,\n * we can easily return to the fetch API.\n *\n * @category SDK\n * @subcategory Internal\n * @param {string} api - The URL of your Hanko API instance\n * @param {number=} timeout - The request timeout in milliseconds\n */\nclass HttpClient {\n timeout: number;\n api: string;\n authCookieName = \"hanko\";\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n this.api = api;\n this.timeout = timeout;\n }\n\n // eslint-disable-next-line require-jsdoc\n _fetch(path: string, options: RequestInit, xhr = new XMLHttpRequest()) {\n const self = this;\n const url = this.api + path;\n const timeout = this.timeout;\n const bearerToken = this._getAuthCookie();\n\n return new Promise<Response>(function (resolve, reject) {\n xhr.open(options.method, url, true);\n xhr.setRequestHeader(\"Accept\", \"application/json\");\n xhr.setRequestHeader(\"Content-Type\", \"application/json\");\n\n if (bearerToken) {\n xhr.setRequestHeader(\"Authorization\", `Bearer ${bearerToken}`);\n }\n\n xhr.timeout = timeout;\n xhr.withCredentials = true;\n xhr.onload = () => {\n const headers = xhr\n .getAllResponseHeaders()\n .split(\"\\r\\n\")\n .filter((h) => h.toLowerCase().startsWith(\"x-auth-token\"));\n\n if (headers.length) {\n const authToken = xhr.getResponseHeader(\"X-Auth-Token\");\n if (authToken) self._setAuthCookie(authToken);\n }\n\n resolve(new Response(xhr));\n };\n\n xhr.onerror = () => {\n reject(new TechnicalError());\n };\n\n xhr.ontimeout = () => {\n reject(new RequestTimeoutError());\n };\n\n xhr.send(options.body ? options.body.toString() : null);\n });\n }\n\n /**\n * Returns the authentication token that was stored in the cookie.\n *\n * @return {string}\n * @return {string}\n */\n _getAuthCookie(): string {\n return Cookies.get(this.authCookieName);\n }\n\n /**\n * Stores the authentication token to the cookie.\n *\n * @param {string} token - The authentication token to be stored.\n */\n _setAuthCookie(token: string) {\n const secure = !!this.api.match(\"^https://\");\n Cookies.set(this.authCookieName, token, { secure });\n }\n\n /**\n * Removes the cookie used for authentication.\n *\n * @param {string} token - The authorization token to be stored.\n */\n removeAuthCookie() {\n Cookies.remove(this.authCookieName);\n }\n\n /**\n * Performs a GET request.\n *\n * @param {string} path - The path to the requested resource.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n get(path: string) {\n return this._fetch(path, { method: \"GET\" });\n }\n\n /**\n * Performs a POST request.\n *\n * @param {string} path - The path to the requested resource.\n * @param {any=} body - The request body.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n post(path: string, body?: any) {\n return this._fetch(path, {\n method: \"POST\",\n body: JSON.stringify(body),\n });\n }\n\n /**\n * Performs a PUT request.\n *\n * @param {string} path - The path to the requested resource.\n * @param {any=} body - The request body.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n put(path: string, body?: any) {\n return this._fetch(path, {\n method: \"PUT\",\n body: JSON.stringify(body),\n });\n }\n\n /**\n * Performs a PATCH request.\n *\n * @param {string} path - The path to the requested resource.\n * @param {any=} body - The request body.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n patch(path: string, body?: any) {\n return this._fetch(path, {\n method: \"PATCH\",\n body: JSON.stringify(body),\n });\n }\n\n /**\n * Performs a DELETE request.\n *\n * @param {string} path - The path to the requested resource.\n * @return {Promise<Response>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n */\n delete(path: string) {\n return this._fetch(path, {\n method: \"DELETE\",\n });\n }\n}\n\nexport { Headers, Response, HttpClient };\n","import { HttpClient } from \"./HttpClient\";\n\n/**\n * A class to be extended by the other client classes.\n *\n * @abstract\n * @category SDK\n * @subcategory Internal\n * @param {string} api - The URL of your Hanko API instance\n * @param {number=} timeout - The request timeout in milliseconds\n */\nabstract class Client {\n client: HttpClient;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n /**\n * @public\n * @type {HttpClient}\n */\n this.client = new HttpClient(api, timeout);\n }\n}\n\nexport { Client };\n","import { Config } from \"../Dto\";\nimport { TechnicalError } from \"../Errors\";\nimport { Client } from \"./Client\";\n\n/**\n * A class for retrieving configurations from the API.\n *\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass ConfigClient extends Client {\n /**\n * Retrieves the frontend configuration.\n * @return {Promise<Config>}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/.well-known/operation/getConfig\n */\n async get(): Promise<Config> {\n const response = await this.client.get(\"/.well-known/config\");\n\n if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n}\n\nexport { ConfigClient };\n","import { LocalStorageUsers } from \"./UserState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {LocalStorageUsers=} users - The user states.\n */\ninterface LocalStorage {\n users?: LocalStorageUsers;\n}\n\n/**\n * A class to read and write local storage contents.\n *\n * @abstract\n * @param {string} key - The local storage key.\n * @category SDK\n * @subcategory Internal\n */\nabstract class State {\n private readonly key: string;\n ls: LocalStorage;\n\n // eslint-disable-next-line require-jsdoc\n constructor(key = \"hanko\") {\n /**\n * @private\n * @type {string}\n */\n this.key = key;\n /**\n * @type {LocalStorage}\n */\n this.ls = {};\n }\n\n /**\n * Reads and decodes the locally stored data.\n *\n * @return {State}\n */\n read(): State {\n let store: LocalStorage;\n\n try {\n const data = localStorage.getItem(this.key);\n const decoded = decodeURIComponent(decodeURI(window.atob(data)));\n store = JSON.parse(decoded);\n } catch (e) {\n this.ls = {};\n\n return this;\n }\n\n this.ls = store;\n\n return this;\n }\n\n /**\n * Encodes and writes the data to the local storage.\n *\n * @return {State}\n */\n write(): State {\n const data = JSON.stringify(this.ls);\n const encoded = window.btoa(encodeURI(encodeURIComponent(data)));\n\n localStorage.setItem(this.key, encoded);\n\n return this;\n }\n\n /**\n * Converts a timestamp into remaining seconds that you can count down.\n *\n * @static\n * @param {number} time - Timestamp in seconds (since January 1, 1970 00:00:00 UTC).\n * @return {number}\n */\n static timeToRemainingSeconds(time = 0) {\n return time - Math.floor(Date.now() / 1000);\n }\n\n /**\n * Converts a number of seconds into a timestamp.\n *\n * @static\n * @param {number} seconds - Remaining seconds to be converted into a timestamp.\n * @return {number}\n */\n static remainingSecondsToTime(seconds = 0) {\n return Math.floor(Date.now() / 1000) + seconds;\n }\n}\n\nexport { State };\nexport type { LocalStorage };\n","/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {Object.<string, LocalStorageUser>} - A dictionary for mapping users to their states.\n */\nimport { State } from \"./State\";\n\nimport { LocalStorageWebauthn } from \"./WebauthnState\";\nimport { LocalStoragePasscode } from \"./PasscodeState\";\nimport { LocalStoragePassword } from \"./PasswordState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {LocalStorageWebauthn=} webauthn - Information about WebAuthn credentials.\n * @property {LocalStoragePasscode=} passcode - Information about the active passcode.\n * @property {LocalStoragePassword=} password - Information about the password login attempts.\n */\ninterface LocalStorageUser {\n webauthn?: LocalStorageWebauthn;\n passcode?: LocalStoragePasscode;\n password?: LocalStoragePassword;\n}\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {Object.<string, LocalStorageUser>} - A dictionary for mapping users to their states.\n */\nexport interface LocalStorageUsers {\n [userID: string]: LocalStorageUser;\n}\n\n/**\n * A class to read and write local storage contents.\n *\n * @abstract\n * @extends State\n * @param {string} key - The local storage key.\n * @category SDK\n * @subcategory Internal\n */\nabstract class UserState extends State {\n /**\n * Gets the state of the specified user.\n *\n * @param {string} userID - The UUID of the user.\n * @return {LocalStorageUser}\n */\n getUserState(userID: string): LocalStorageUser {\n this.ls.users ||= {};\n\n if (!Object.prototype.hasOwnProperty.call(this.ls.users, userID)) {\n this.ls.users[userID] = {};\n }\n\n return this.ls.users[userID];\n }\n}\n\nexport { UserState };\n","import { State } from \"./State\";\nimport { UserState } from \"./UserState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {string=} id - The UUID of the active passcode.\n * @property {number=} ttl - Timestamp until when the passcode is valid in seconds (since January 1, 1970 00:00:00 UTC).\n * @property {number=} resendAfter - Seconds until a passcode can be resent.\n * @property {emailID=} emailID - The email address ID.\n */\nexport interface LocalStoragePasscode {\n id?: string;\n ttl?: number;\n resendAfter?: number;\n emailID?: string;\n}\n\n/**\n * A class that manages passcodes via local storage.\n *\n * @extends UserState\n * @category SDK\n * @subcategory Internal\n */\nclass PasscodeState extends UserState {\n /**\n * Get the passcode state.\n *\n * @private\n * @param {string} userID - The UUID of the user.\n * @return {LocalStoragePasscode}\n */\n private getState(userID: string): LocalStoragePasscode {\n return (super.getUserState(userID).passcode ||= {});\n }\n\n /**\n * Reads the current state.\n *\n * @public\n * @return {PasscodeState}\n */\n read(): PasscodeState {\n super.read();\n\n return this;\n }\n\n /**\n * Gets the UUID of the active passcode.\n *\n * @param {string} userID - The UUID of the user.\n * @return {string}\n */\n getActiveID(userID: string): string {\n return this.getState(userID).id;\n }\n\n /**\n * Sets the UUID of the active passcode.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} passcodeID - The UUID of the passcode to be set as active.\n * @return {PasscodeState}\n */\n setActiveID(userID: string, passcodeID: string): PasscodeState {\n this.getState(userID).id = passcodeID;\n\n return this;\n }\n\n /**\n * Gets the UUID of the email address.\n *\n * @param {string} userID - The UUID of the user.\n * @return {string}\n */\n getEmailID(userID: string): string {\n return this.getState(userID).emailID;\n }\n\n /**\n * Sets the UUID of the email address.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} emailID - The UUID of the email address.\n * @return {PasscodeState}\n */\n setEmailID(userID: string, emailID: string): PasscodeState {\n this.getState(userID).emailID = emailID;\n\n return this;\n }\n\n /**\n * Removes the active passcode.\n *\n * @param {string} userID - The UUID of the user.\n * @return {PasscodeState}\n */\n reset(userID: string): PasscodeState {\n const passcode = this.getState(userID);\n\n delete passcode.id;\n delete passcode.ttl;\n delete passcode.resendAfter;\n delete passcode.emailID;\n\n return this;\n }\n\n /**\n * Gets the TTL in seconds. When the seconds expire, the code is invalid.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getTTL(userID: string): number {\n return State.timeToRemainingSeconds(this.getState(userID).ttl);\n }\n\n /**\n * Sets the passcode's TTL and stores it to the local storage.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} seconds - Number of seconds the passcode is valid for.\n * @return {PasscodeState}\n */\n setTTL(userID: string, seconds: number): PasscodeState {\n this.getState(userID).ttl = State.remainingSecondsToTime(seconds);\n\n return this;\n }\n\n /**\n * Gets the number of seconds until when the next passcode can be sent.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getResendAfter(userID: string): number {\n return State.timeToRemainingSeconds(this.getState(userID).resendAfter);\n }\n\n /**\n * Sets the number of seconds until a new passcode can be sent.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} seconds - Number of seconds the passcode is valid for.\n * @return {PasscodeState}\n */\n setResendAfter(userID: string, seconds: number): PasscodeState {\n this.getState(userID).resendAfter = State.remainingSecondsToTime(seconds);\n\n return this;\n }\n}\n\nexport { PasscodeState };\n","import { PasscodeState } from \"../state/PasscodeState\";\nimport { Passcode } from \"../Dto\";\nimport {\n InvalidPasscodeError,\n MaxNumOfPasscodeAttemptsReachedError,\n PasscodeExpiredError,\n TechnicalError,\n TooManyRequestsError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\n\n/**\n * A class to handle passcodes.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass PasscodeClient extends Client {\n state: PasscodeState;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n super(api, timeout);\n /**\n * @public\n * @type {PasscodeState}\n */\n this.state = new PasscodeState();\n }\n\n /**\n * Causes the API to send a new passcode to the user's email address.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string=} emailID - The UUID of the email address. If unspecified, the email will be sent to the primary email address.\n * @param {boolean=} force - Indicates the passcode should be sent, even if there is another active passcode.\n * @return {Promise<Passcode>}\n * @throws {TooManyRequestsError}\n * @throws {RequestTimeoutError}\n * @throws {UnauthorizedError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Passcode/operation/passcodeInit\n */\n async initialize(\n userID: string,\n emailID?: string,\n force?: boolean\n ): Promise<Passcode> {\n this.state.read();\n\n const lastPasscodeTTL = this.state.getTTL(userID);\n const lastPasscodeID = this.state.getActiveID(userID);\n const lastEmailID = this.state.getEmailID(userID);\n let retryAfter = this.state.getResendAfter(userID);\n\n if (retryAfter > 0) {\n throw new TooManyRequestsError(retryAfter);\n }\n\n if (!force && lastPasscodeTTL > 0 && emailID === lastEmailID) {\n return {\n id: lastPasscodeID,\n ttl: lastPasscodeTTL,\n };\n }\n\n const body: any = { user_id: userID };\n\n if (emailID) {\n body.email_id = emailID;\n }\n\n const response = await this.client.post(`/passcode/login/initialize`, body);\n\n if (response.status === 429) {\n retryAfter = response.parseRetryAfterHeader();\n this.state.setResendAfter(userID, retryAfter).write();\n throw new TooManyRequestsError(retryAfter);\n } else if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n const passcode: Passcode = response.json();\n\n this.state.setActiveID(userID, passcode.id).setTTL(userID, passcode.ttl);\n\n if (emailID) {\n this.state.setEmailID(userID, emailID);\n }\n\n this.state.write();\n\n return passcode;\n }\n\n /**\n * Validates the passcode obtained from the email.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} code - The passcode digests.\n * @return {Promise<void>}\n * @throws {InvalidPasscodeError}\n * @throws {MaxNumOfPasscodeAttemptsReachedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Passcode/operation/passcodeFinal\n */\n async finalize(userID: string, code: string): Promise<void> {\n const passcodeID = this.state.read().getActiveID(userID);\n const ttl = this.state.getTTL(userID);\n\n if (ttl <= 0) {\n throw new PasscodeExpiredError();\n }\n\n const response = await this.client.post(\"/passcode/login/finalize\", {\n id: passcodeID,\n code,\n });\n\n if (response.status === 401) {\n throw new InvalidPasscodeError();\n } else if (response.status === 410) {\n this.state.reset(userID).write();\n throw new MaxNumOfPasscodeAttemptsReachedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n this.state.reset(userID).write();\n\n return;\n }\n\n /**\n * Returns the number of seconds the current passcode is active for.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getTTL(userID: string) {\n return this.state.read().getTTL(userID);\n }\n\n /**\n * Returns the number of seconds the rate limiting is active for.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getResendAfter(userID: string) {\n return this.state.read().getResendAfter(userID);\n }\n}\n\nexport { PasscodeClient };\n","import { State } from \"./State\";\nimport { UserState } from \"./UserState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {number=} retryAfter - Timestamp (in seconds since January 1, 1970 00:00:00 UTC) indicating when the next password login can be attempted.\n */\nexport interface LocalStoragePassword {\n retryAfter?: number;\n}\n\n/**\n * A class that manages the password login state.\n *\n * @extends UserState\n * @category SDK\n * @subcategory Internal\n */\nclass PasswordState extends UserState {\n /**\n * Get the password state.\n *\n * @private\n * @param {string} userID - The UUID of the user.\n * @return {LocalStoragePassword}\n */\n private getState(userID: string): LocalStoragePassword {\n return (super.getUserState(userID).password ||= {});\n }\n\n /**\n * Reads the current state.\n *\n * @public\n * @return {PasswordState}\n */\n read(): PasswordState {\n super.read();\n\n return this;\n }\n\n /**\n * Gets the number of seconds until when a new password login can be attempted.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getRetryAfter(userID: string): number {\n return State.timeToRemainingSeconds(this.getState(userID).retryAfter);\n }\n\n /**\n * Sets the number of seconds until a new password login can be attempted.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} seconds - Number of seconds the passcode is valid for.\n * @return {PasswordState}\n */\n setRetryAfter(userID: string, seconds: number): PasswordState {\n this.getState(userID).retryAfter = State.remainingSecondsToTime(seconds);\n\n return this;\n }\n}\n\nexport { PasswordState };\n","import { PasswordState } from \"../state/PasswordState\";\nimport { PasscodeState } from \"../state/PasscodeState\";\nimport {\n InvalidPasswordError,\n TechnicalError,\n TooManyRequestsError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\n\n/**\n * A class to handle passwords.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass PasswordClient extends Client {\n passwordState: PasswordState;\n passcodeState: PasscodeState;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n super(api, timeout);\n /**\n * @public\n * @type {PasswordState}\n */\n this.passwordState = new PasswordState();\n /**\n * @public\n * @type {PasscodeState}\n */\n this.passcodeState = new PasscodeState();\n }\n\n /**\n * Logs in a user with a password.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} password - The password.\n * @return {Promise<void>}\n * @throws {TooManyRequestsError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Password/operation/passwordLogin\n */\n async login(userID: string, password: string): Promise<void> {\n const response = await this.client.post(\"/password/login\", {\n user_id: userID,\n password,\n });\n\n if (response.status === 401) {\n throw new InvalidPasswordError();\n } else if (response.status === 429) {\n const retryAfter = response.parseRetryAfterHeader();\n this.passwordState.read().setRetryAfter(userID, retryAfter).write();\n throw new TooManyRequestsError(retryAfter);\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n this.passcodeState.read().reset(userID).write();\n\n return;\n }\n\n /**\n * Updates a password.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} password - The new password.\n * @return {Promise<void>}\n * @throws {RequestTimeoutError}\n * @throws {UnauthorizedError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Password/operation/password\n */\n async update(userID: string, password: string): Promise<void> {\n const response = await this.client.put(\"/password\", {\n user_id: userID,\n password,\n });\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n\n /**\n * Returns the number of seconds the rate limiting is active for.\n *\n * @param {string} userID - The UUID of the user.\n * @return {number}\n */\n getRetryAfter(userID: string) {\n return this.passwordState.read().getRetryAfter(userID);\n }\n}\n\nexport { PasswordClient };\n","import { Me, User, UserInfo } from \"../Dto\";\nimport {\n ConflictError,\n NotFoundError,\n TechnicalError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\n\n/**\n * A class to manage user information.\n *\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass UserClient extends Client {\n /**\n * Fetches basic information about the user identified by the given email address. Can be used while the user is logged out\n * and is helpful in deciding which type of login to choose. For example, if the user's email is not verified, you may\n * want to log in with a passcode, or if no WebAuthn credentials are registered, you may not want to use WebAuthn.\n *\n * @param {string} email - The user's email address.\n * @return {Promise<UserInfo>}\n * @throws {NotFoundError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/User-Management/operation/getUserId\n */\n async getInfo(email: string): Promise<UserInfo> {\n const response = await this.client.post(\"/user\", { email });\n\n if (response.status === 404) {\n throw new NotFoundError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n\n /**\n * Creates a new user. Afterwards, verify the email address via passcode. If a 'ConflictError'\n * occurred, you may want to prompt the user to log in.\n *\n * @param {string} email - The email address of the user to be created.\n * @return {Promise<User>}\n * @throws {ConflictError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/User-Management/operation/createUser\n */\n async create(email: string): Promise<User> {\n const response = await this.client.post(\"/users\", { email });\n\n if (response.status === 409) {\n throw new ConflictError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n\n /**\n * Fetches the current user.\n *\n * @return {Promise<User>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/User-Management/operation/IsUserAuthorized\n * @see https://docs.hanko.io/api/public#tag/User-Management/operation/listUser\n */\n async getCurrent(): Promise<User> {\n const meResponse = await this.client.get(\"/me\");\n\n if (\n meResponse.status === 400 ||\n meResponse.status === 401 ||\n meResponse.status === 404\n ) {\n throw new UnauthorizedError();\n } else if (!meResponse.ok) {\n throw new TechnicalError();\n }\n\n const me: Me = meResponse.json();\n const userResponse = await this.client.get(`/users/${me.id}`);\n\n if (\n userResponse.status === 400 ||\n userResponse.status === 401 ||\n userResponse.status === 404\n ) {\n throw new UnauthorizedError();\n } else if (!userResponse.ok) {\n throw new TechnicalError();\n }\n\n return userResponse.json();\n }\n\n /**\n * Deletes the current user and expires the existing session cookie.\n *\n * @return {Promise<void>}\n * @throws {TechnicalError}\n */\n async delete(): Promise<void> {\n const response = await this.client.delete(\"/user\");\n\n if (response.ok) {\n this.client.removeAuthCookie();\n return;\n } else if (response.status === 401) {\n throw new UnauthorizedError();\n }\n\n throw new TechnicalError();\n }\n\n /**\n * Logs out the current user and expires the existing session cookie. A valid session cookie is required to call the logout endpoint.\n *\n * @return {Promise<void>}\n * @throws {TechnicalError}\n */\n async logout(): Promise<void> {\n const logoutResponse = await this.client.post(\"/logout\");\n\n // For cross-domain operations, the frontend SDK creates the cookie by reading the \"X-Auth-Token\" header, and\n // \"Set-Cookie\" headers sent by the backend have no effect due to the browser's security policy, which means that\n // the cookie must also be removed client-side in that case.\n this.client.removeAuthCookie();\n\n if (logoutResponse.status === 401) {\n return; // The user is logged out already\n } else if (!logoutResponse.ok) {\n throw new TechnicalError();\n }\n }\n}\n\nexport { UserClient };\n","// src/webauthn-json/base64url.ts\nfunction base64urlToBuffer(baseurl64String) {\n const padding = \"==\".slice(0, (4 - baseurl64String.length % 4) % 4);\n const base64String = baseurl64String.replace(/-/g, \"+\").replace(/_/g, \"/\") + padding;\n const str = atob(base64String);\n const buffer = new ArrayBuffer(str.length);\n const byteView = new Uint8Array(buffer);\n for (let i = 0; i < str.length; i++) {\n byteView[i] = str.charCodeAt(i);\n }\n return buffer;\n}\nfunction bufferToBase64url(buffer) {\n const byteView = new Uint8Array(buffer);\n let str = \"\";\n for (const charCode of byteView) {\n str += String.fromCharCode(charCode);\n }\n const base64String = btoa(str);\n const base64urlString = base64String.replace(/\\+/g, \"-\").replace(\n /\\//g,\n \"_\"\n ).replace(/=/g, \"\");\n return base64urlString;\n}\n\n// src/webauthn-json/convert.ts\nvar copyValue = \"copy\";\nvar convertValue = \"convert\";\nfunction convert(conversionFn, schema2, input) {\n if (schema2 === copyValue) {\n return input;\n }\n if (schema2 === convertValue) {\n return conversionFn(input);\n }\n if (schema2 instanceof Array) {\n return input.map((v) => convert(conversionFn, schema2[0], v));\n }\n if (schema2 instanceof Object) {\n const output = {};\n for (const [key, schemaField] of Object.entries(schema2)) {\n if (schemaField.derive) {\n const v = schemaField.derive(input);\n if (v !== void 0) {\n input[key] = v;\n }\n }\n if (!(key in input)) {\n if (schemaField.required) {\n throw new Error(`Missing key: ${key}`);\n }\n continue;\n }\n if (input[key] == null) {\n output[key] = null;\n continue;\n }\n output[key] = convert(\n conversionFn,\n schemaField.schema,\n input[key]\n );\n }\n return output;\n }\n}\nfunction derived(schema2, derive) {\n return {\n required: true,\n schema: schema2,\n derive\n };\n}\nfunction required(schema2) {\n return {\n required: true,\n schema: schema2\n };\n}\nfunction optional(schema2) {\n return {\n required: false,\n schema: schema2\n };\n}\n\n// src/webauthn-json/basic/schema.ts\nvar publicKeyCredentialDescriptorSchema = {\n type: required(copyValue),\n id: required(convertValue),\n transports: optional(copyValue)\n};\nvar simplifiedExtensionsSchema = {\n appid: optional(copyValue),\n appidExclude: optional(copyValue),\n credProps: optional(copyValue)\n};\nvar simplifiedClientExtensionResultsSchema = {\n appid: optional(copyValue),\n appidExclude: optional(copyValue),\n credProps: optional(copyValue)\n};\nvar credentialCreationOptions = {\n publicKey: required({\n rp: required(copyValue),\n user: required({\n id: required(convertValue),\n name: required(copyValue),\n displayName: required(copyValue)\n }),\n challenge: required(convertValue),\n pubKeyCredParams: required(copyValue),\n timeout: optional(copyValue),\n excludeCredentials: optional([publicKeyCredentialDescriptorSchema]),\n authenticatorSelection: optional(copyValue),\n attestation: optional(copyValue),\n extensions: optional(simplifiedExtensionsSchema)\n }),\n signal: optional(copyValue)\n};\nvar publicKeyCredentialWithAttestation = {\n type: required(copyValue),\n id: required(copyValue),\n rawId: required(convertValue),\n authenticatorAttachment: optional(copyValue),\n response: required({\n clientDataJSON: required(convertValue),\n attestationObject: required(convertValue),\n transports: derived(\n copyValue,\n (response) => {\n var _a;\n return ((_a = response.getTransports) == null ? void 0 : _a.call(response)) || [];\n }\n )\n }),\n clientExtensionResults: derived(\n simplifiedClientExtensionResultsSchema,\n (pkc) => pkc.getClientExtensionResults()\n )\n};\nvar credentialRequestOptions = {\n mediation: optional(copyValue),\n publicKey: required({\n challenge: required(convertValue),\n timeout: optional(copyValue),\n rpId: optional(copyValue),\n allowCredentials: optional([publicKeyCredentialDescriptorSchema]),\n userVerification: optional(copyValue),\n extensions: optional(simplifiedExtensionsSchema)\n }),\n signal: optional(copyValue)\n};\nvar publicKeyCredentialWithAssertion = {\n type: required(copyValue),\n id: required(copyValue),\n rawId: required(convertValue),\n authenticatorAttachment: optional(copyValue),\n response: required({\n clientDataJSON: required(convertValue),\n authenticatorData: required(convertValue),\n signature: required(convertValue),\n userHandle: required(convertValue)\n }),\n clientExtensionResults: derived(\n simplifiedClientExtensionResultsSchema,\n (pkc) => pkc.getClientExtensionResults()\n )\n};\nvar schema = {\n credentialCreationOptions,\n publicKeyCredentialWithAttestation,\n credentialRequestOptions,\n publicKeyCredentialWithAssertion\n};\n\n// src/webauthn-json/basic/api.ts\nfunction createRequestFromJSON(requestJSON) {\n return convert(base64urlToBuffer, credentialCreationOptions, requestJSON);\n}\nfunction createResponseToJSON(credential) {\n return convert(\n bufferToBase64url,\n publicKeyCredentialWithAttestation,\n credential\n );\n}\nasync function create(requestJSON) {\n const credential = await navigator.credentials.create(\n createRequestFromJSON(requestJSON)\n );\n return createResponseToJSON(credential);\n}\nfunction getRequestFromJSON(requestJSON) {\n return convert(base64urlToBuffer, credentialRequestOptions, requestJSON);\n}\nfunction getResponseToJSON(credential) {\n return convert(\n bufferToBase64url,\n publicKeyCredentialWithAssertion,\n credential\n );\n}\nasync function get(requestJSON) {\n const credential = await navigator.credentials.get(\n getRequestFromJSON(requestJSON)\n );\n return getResponseToJSON(credential);\n}\n\n// src/webauthn-json/basic/supported.ts\nfunction supported() {\n return !!(navigator.credentials && navigator.credentials.create && navigator.credentials.get && window.PublicKeyCredential);\n}\nexport {\n create,\n get,\n schema,\n supported\n};\n//# sourceMappingURL=webauthn-json.js.map\n","/**\n * A class to check the browser's WebAuthn support.\n *\n * @hideconstructor\n * @category SDK\n * @subcategory Utilities\n */\nclass WebauthnSupport {\n /**\n * Does a simple check to test for the credential management API functions we need, and an indication of\n * public key credential authentication support.\n *\n * @see https://developers.google.com/web/updates/2018/03/webauthn-credential-management\n * @return boolean\n */\n static supported(): boolean {\n return !!(\n navigator.credentials &&\n navigator.credentials.create &&\n navigator.credentials.get &&\n window.PublicKeyCredential\n );\n }\n\n /**\n * Checks whether a user-verifying platform authenticator is available.\n *\n * @return Promise<boolean>\n */\n static async isPlatformAuthenticatorAvailable(): Promise<boolean> {\n if (\n this.supported() &&\n window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable\n ) {\n return window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable();\n }\n\n return false;\n }\n\n /**\n * Checks whether external CTAP2 security keys are supported.\n *\n * @return Promise<boolean>\n */\n static async isSecurityKeySupported(): Promise<boolean> {\n if (\n window.PublicKeyCredential !== undefined &&\n // @ts-ignore\n window.PublicKeyCredential.isExternalCTAP2SecurityKeySupported\n ) {\n // @ts-ignore\n return window.PublicKeyCredential.isExternalCTAP2SecurityKeySupported();\n }\n\n return this.supported();\n }\n\n /**\n * Checks whether autofill assisted requests are supported.\n *\n * @return Promise<boolean>\n */\n static async isConditionalMediationAvailable(): Promise<boolean> {\n if (\n // @ts-ignore\n window.PublicKeyCredential &&\n // @ts-ignore\n window.PublicKeyCredential.isConditionalMediationAvailable\n ) {\n // @ts-ignore\n return window.PublicKeyCredential.isConditionalMediationAvailable();\n }\n\n return false;\n }\n}\n\nexport { WebauthnSupport };\n","import { UserState } from \"./UserState\";\nimport { Credential } from \"../Dto\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {string[]?} credentials - A list of known credential IDs on the current browser.\n */\nexport interface LocalStorageWebauthn {\n credentials?: string[];\n}\n\n/**\n * A class that manages WebAuthn credentials via local storage.\n *\n * @extends UserState\n * @category SDK\n * @subcategory Internal\n */\nclass WebauthnState extends UserState {\n /**\n * Gets the WebAuthn state.\n *\n * @private\n * @param {string} userID - The UUID of the user.\n * @return {LocalStorageWebauthn}\n */\n private getState(userID: string): LocalStorageWebauthn {\n return (super.getUserState(userID).webauthn ||= {});\n }\n\n /**\n * Reads the current state.\n *\n * @public\n * @return {WebauthnState}\n */\n read(): WebauthnState {\n super.read();\n\n return this;\n }\n\n /**\n * Gets the list of known credentials on the current browser.\n *\n * @param {string} userID - The UUID of the user.\n * @return {string[]}\n */\n getCredentials(userID: string): string[] {\n return (this.getState(userID).credentials ||= []);\n }\n\n /**\n * Adds the credential to the list of known credentials.\n *\n * @param {string} userID - The UUID of the user.\n * @param {string} credentialID - The WebAuthn credential ID.\n * @return {WebauthnState}\n */\n addCredential(userID: string, credentialID: string): WebauthnState {\n this.getCredentials(userID).push(credentialID);\n\n return this;\n }\n\n /**\n * Returns the intersection between the specified list of credentials and the known credentials stored in\n * the local storage.\n *\n * @param {string} userID - The UUID of the user.\n * @param {Credential[]} match - A list of credential IDs to be matched against the local storage.\n * @return {Credential[]}\n */\n matchCredentials(userID: string, match: Credential[]): Credential[] {\n return this.getCredentials(userID)\n .filter((id) => match.find((c) => c.id === id))\n .map((id: string) => ({ id } as Credential));\n }\n}\n\nexport { WebauthnState };\n","import {\n create as createWebauthnCredential,\n get as getWebauthnCredential,\n} from \"@github/webauthn-json\";\n\nimport { WebauthnSupport } from \"../WebauthnSupport\";\nimport { Client } from \"./Client\";\nimport { PasscodeState } from \"../state/PasscodeState\";\n\nimport { WebauthnState } from \"../state/WebauthnState\";\n\nimport {\n InvalidWebauthnCredentialError,\n TechnicalError,\n UnauthorizedError,\n UserVerificationError,\n WebauthnRequestCancelledError,\n} from \"../Errors\";\n\nimport {\n Attestation,\n User,\n WebauthnCredentials,\n WebauthnFinalized,\n} from \"../Dto\";\n\n/**\n * A class that handles WebAuthn authentication and registration.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass WebauthnClient extends Client {\n webauthnState: WebauthnState;\n passcodeState: PasscodeState;\n controller: AbortController;\n\n _getCredential = getWebauthnCredential;\n _createCredential = createWebauthnCredential;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n super(api, timeout);\n /**\n * @public\n * @type {WebauthnState}\n */\n this.webauthnState = new WebauthnState();\n /**\n * @public\n * @type {PasscodeState}\n */\n this.passcodeState = new PasscodeState();\n }\n\n /**\n * Performs a WebAuthn authentication ceremony. When 'userID' is specified, the API provides a list of\n * allowed credentials and the browser is able to present a list of suitable credentials to the user.\n *\n * @param {string=} userID - The user's UUID.\n * @param {boolean=} useConditionalMediation - Enables autofill assisted login.\n * @return {Promise<void>}\n * @throws {WebauthnRequestCancelledError}\n * @throws {InvalidWebauthnCredentialError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/webauthnLoginInit\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/webauthnLoginFinal\n * @see https://www.w3.org/TR/webauthn-2/#authentication-ceremony\n */\n async login(\n userID?: string,\n useConditionalMediation?: boolean\n ): Promise<void> {\n const challengeResponse = await this.client.post(\n \"/webauthn/login/initialize\",\n { user_id: userID }\n );\n\n if (!challengeResponse.ok) {\n throw new TechnicalError();\n }\n\n const challenge = challengeResponse.json();\n challenge.signal = this._createAbortSignal();\n\n if (useConditionalMediation) {\n // `CredentialMediationRequirement` doesn't support \"conditional\" in the current typescript version.\n challenge.mediation = \"conditional\" as CredentialMediationRequirement;\n }\n\n let assertion;\n try {\n assertion = await this._getCredential(challenge);\n } catch (e) {\n throw new WebauthnRequestCancelledError(e);\n }\n\n const assertionResponse = await this.client.post(\n \"/webauthn/login/finalize\",\n assertion\n );\n\n if (assertionResponse.status === 400 || assertionResponse.status === 401) {\n throw new InvalidWebauthnCredentialError();\n } else if (!assertionResponse.ok) {\n throw new TechnicalError();\n }\n\n const finalizeResponse: WebauthnFinalized = assertionResponse.json();\n\n this.webauthnState\n .read()\n .addCredential(finalizeResponse.user_id, finalizeResponse.credential_id)\n .write();\n\n this.passcodeState.read().reset(userID).write();\n\n return;\n }\n\n /**\n * Performs a WebAuthn registration ceremony.\n *\n * @return {Promise<void>}\n * @throws {WebauthnRequestCancelledError}\n * @throws {RequestTimeoutError}\n * @throws {UnauthorizedError}\n * @throws {TechnicalError}\n * @throws {UserVerificationError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/webauthnRegInit\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/webauthnRegFinal\n * @see https://www.w3.org/TR/webauthn-2/#sctn-registering-a-new-credential\n */\n async register(): Promise<void> {\n const challengeResponse = await this.client.post(\n \"/webauthn/registration/initialize\"\n );\n\n if (challengeResponse.status >= 400 && challengeResponse.status <= 499) {\n throw new UnauthorizedError();\n } else if (!challengeResponse.ok) {\n throw new TechnicalError();\n }\n\n const challenge = challengeResponse.json();\n challenge.signal = this._createAbortSignal();\n\n let attestation;\n try {\n attestation = (await this._createCredential(challenge)) as Attestation;\n } catch (e) {\n throw new WebauthnRequestCancelledError(e);\n }\n\n // The generated PublicKeyCredentialWithAttestationJSON object does not align with the API. The list of\n // supported transports must be available under a different path.\n attestation.transports = attestation.response.transports;\n\n const attestationResponse = await this.client.post(\n \"/webauthn/registration/finalize\",\n attestation\n );\n\n if (\n attestationResponse.status >= 400 &&\n attestationResponse.status <= 499\n ) {\n if (attestationResponse.status === 422) {\n throw new UserVerificationError();\n }\n throw new UnauthorizedError();\n }\n if (!attestationResponse.ok) {\n throw new TechnicalError();\n }\n\n const finalizeResponse: WebauthnFinalized = attestationResponse.json();\n this.webauthnState\n .read()\n .addCredential(finalizeResponse.user_id, finalizeResponse.credential_id)\n .write();\n\n return;\n }\n\n /**\n * Returns a list of all WebAuthn credentials assigned to the current user.\n *\n * @return {Promise<WebauthnCredentials>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/listCredentials\n */\n async listCredentials(): Promise<WebauthnCredentials> {\n const response = await this.client.get(\"/webauthn/credentials\");\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n\n /**\n * Updates the WebAuthn credential.\n *\n * @param {string=} credentialID - The credential's UUID.\n * @param {string} name - The new credential name.\n * @return {Promise<void>}\n * @throws {NotFoundError}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/updateCredential\n */\n async updateCredential(credentialID: string, name: string): Promise<void> {\n const response = await this.client.patch(\n `/webauthn/credentials/${credentialID}`,\n {\n name,\n }\n );\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n\n /**\n * Deletes the WebAuthn credential.\n *\n * @param {string=} credentialID - The credential's UUID.\n * @return {Promise<void>}\n * @throws {NotFoundError}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/WebAuthn/operation/deleteCredential\n */\n async deleteCredential(credentialID: string): Promise<void> {\n const response = await this.client.delete(\n `/webauthn/credentials/${credentialID}`\n );\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n\n /**\n * Determines whether a credential registration ceremony should be performed. Returns 'true' when WebAuthn\n * is supported and the user's credentials do not intersect with the credentials already known on the\n * current browser/device.\n *\n * @param {User} user - The user object.\n * @return {Promise<boolean>}\n */\n async shouldRegister(user: User): Promise<boolean> {\n const supported = WebauthnSupport.supported();\n\n if (!user.webauthn_credentials || !user.webauthn_credentials.length) {\n return supported;\n }\n\n const matches = this.webauthnState\n .read()\n .matchCredentials(user.id, user.webauthn_credentials);\n\n return supported && !matches.length;\n }\n\n // eslint-disable-next-line require-jsdoc\n _createAbortSignal() {\n if (this.controller) {\n this.controller.abort();\n }\n\n this.controller = new AbortController();\n return this.controller.signal;\n }\n}\n\nexport { WebauthnClient };\n","import { Client } from \"./Client\";\nimport {\n EmailAddressAlreadyExistsError,\n MaxNumOfEmailAddressesReachedError,\n TechnicalError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Email, Emails } from \"../Dto\";\n\n/**\n * Manages email addresses of the current user.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nclass EmailClient extends Client {\n /**\n * Returns a list of all email addresses assigned to the current user.\n *\n * @return {Promise<Emails>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/listEmails\n */\n async list(): Promise<Emails> {\n const response = await this.client.get(\"/emails\");\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return response.json();\n }\n\n /**\n * Adds a new email address to the current user.\n *\n * @param {string} address - The email address to be added.\n * @return {Promise<Email>}\n * @throws {EmailAddressAlreadyExistsError}\n * @throws {MaxNumOfEmailAddressesReachedError}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/createEmail\n */\n async create(address: string): Promise<Email> {\n const response = await this.client.post(\"/emails\", { address });\n\n if (response.ok) {\n return response.json();\n }\n\n if (response.status === 400) {\n throw new EmailAddressAlreadyExistsError();\n } else if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (response.status === 409) {\n throw new MaxNumOfEmailAddressesReachedError();\n }\n\n throw new TechnicalError();\n }\n\n /**\n * Marks the specified email address as primary.\n *\n * @param {string} emailID - The ID of the email address to be updated\n * @return {Promise<void>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/setPrimaryEmail\n */\n async setPrimaryEmail(emailID: string): Promise<void> {\n const response = await this.client.post(`/emails/${emailID}/set_primary`);\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n\n /**\n * Deletes the specified email address.\n *\n * @param {string} emailID - The ID of the email address to be deleted\n * @return {Promise<void>}\n * @throws {UnauthorizedError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @see https://docs.hanko.io/api/public#tag/Email-Management/operation/deleteEmail\n */\n async delete(emailID: string): Promise<void> {\n const response = await this.client.delete(`/emails/${emailID}`);\n\n if (response.status === 401) {\n throw new UnauthorizedError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n return;\n }\n}\n\nexport { EmailClient };\n","import { Client } from \"./Client\";\nimport { ThirdPartyError } from \"../Errors\";\n\n/**\n * A class that handles communication with the Hanko API for the purposes\n * of authenticating through a third party provider.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nexport class ThirdPartyClient extends Client {\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n super(api, timeout);\n }\n\n /**\n * Performs a request to the Hanko API that redirects to the given\n * third party provider.\n *\n * @param {string} provider - The name of the third party provider\n * @param {string} redirectTo - The URL to redirect to after a successful third party authentication\n * @throws {ThirdPartyError}\n * @see http://docs.hanko.io/api/public#tag/Third-Party/operation/thirdPartyAuth\n */\n async auth(provider: string, redirectTo: string): Promise<void> {\n const url = new URL(\"/thirdparty/auth\", this.client.api);\n\n if (!provider) {\n throw new ThirdPartyError(\n \"somethingWentWrong\",\n new Error(\"provider missing from request\")\n );\n }\n\n if (!redirectTo) {\n throw new ThirdPartyError(\n \"somethingWentWrong\",\n new Error(\"redirectTo missing from request\")\n );\n }\n\n url.searchParams.append(\"provider\", provider);\n url.searchParams.append(\"redirect_to\", redirectTo);\n\n window.location.assign(url.href);\n }\n\n /**\n * Get a third party error from the current location's query params.\n * @returns {(ThirdPartyError|undefined)} The ThirdPartyError.\n */\n getError() {\n const params = new URLSearchParams(window.location.search);\n const error = params.get(\"error\");\n const errorDescription = params.get(\"error_description\");\n if (error) {\n let code = \"\";\n switch (error) {\n case \"access_denied\":\n code = \"thirdPartyAccessDenied\";\n break;\n case \"user_conflict\":\n code = \"emailAddressAlreadyExistsError\";\n break;\n case \"multiple_accounts\":\n code = \"thirdPartyMultipleAccounts\";\n break;\n case \"unverified_email\":\n code = \"thirdPartyUnverifiedEmail\";\n break;\n case \"email_maxnum\":\n code = \"maxNumOfEmailAddressesReached\";\n break;\n default:\n code = \"somethingWentWrong\";\n }\n\n return new ThirdPartyError(code, new Error(errorDescription));\n }\n }\n}\n","import { Client } from \"./Client\";\nimport { TechnicalError } from \"../Errors\";\n\n/**\n * Client responsible for exchanging one time tokens for session JWTs.\n *\n * @constructor\n * @category SDK\n * @subcategory Clients\n * @extends {Client}\n */\nexport class TokenClient extends Client {\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n super(api, timeout);\n }\n\n /**\n * Validate a one time token to retrieve a session JWT. Does nothing\n * if the current window location does not contain a 'hanko_token' in the\n * search query.\n *\n * @return {Promise<void>}\n * @throws {TechnicalError}\n * https://docs.hanko.io/api/api/public#tag/Token/operation/token\n */\n async validate(): Promise<void> {\n const params = new URLSearchParams(window.location.search);\n const token = params.get(\"hanko_token\");\n\n if (!token) return;\n\n window.history.replaceState(null, null, window.location.pathname);\n\n const response = await this.client.post(\"/token\", { value: token });\n if (!response.ok) {\n throw new TechnicalError();\n }\n }\n}\n","import { ConfigClient } from \"./lib/client/ConfigClient\";\nimport { PasscodeClient } from \"./lib/client/PasscodeClient\";\nimport { PasswordClient } from \"./lib/client/PasswordClient\";\nimport { UserClient } from \"./lib/client/UserClient\";\nimport { WebauthnClient } from \"./lib/client/WebauthnClient\";\nimport { EmailClient } from \"./lib/client/EmailClient\";\nimport { ThirdPartyClient } from \"./lib/client/ThirdPartyClient\";\nimport { TokenClient } from \"./lib/client/TokenClient\";\n\n/**\n * A class that bundles all available SDK functions.\n *\n * @param {string} api - The URL of your Hanko API instance\n * @param {number=} timeout - The request timeout in milliseconds\n */\nclass Hanko {\n api: string;\n config: ConfigClient;\n user: UserClient;\n webauthn: WebauthnClient;\n password: PasswordClient;\n passcode: PasscodeClient;\n email: EmailClient;\n thirdParty: ThirdPartyClient;\n token: TokenClient;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, timeout = 13000) {\n this.api = api;\n /**\n * @public\n * @type {ConfigClient}\n */\n this.config = new ConfigClient(api, timeout);\n /**\n * @public\n * @type {UserClient}\n */\n this.user = new UserClient(api, timeout);\n /**\n * @public\n * @type {WebauthnClient}\n */\n this.webauthn = new WebauthnClient(api, timeout);\n /**\n * @public\n * @type {PasswordClient}\n */\n this.password = new PasswordClient(api, timeout);\n /**\n * @public\n * @type {PasscodeClient}\n */\n this.passcode = new PasscodeClient(api, timeout);\n /**\n * @public\n * @type {EmailClient}\n */\n this.email = new EmailClient(api, timeout);\n /**\n * @public\n * @type {ThirdPartyClient}\n */\n this.thirdParty = new ThirdPartyClient(api, timeout);\n /**\n * @public\n * @type {TokenClient}\n */\n this.token = new TokenClient(api, timeout);\n }\n}\n\nexport { Hanko };\n"],"names":["HankoError","_Error","message","code","cause","_this","call","this","Object","setPrototypeOf","prototype","_inheritsLoose","Error","TechnicalError","_HankoError","_this2","_assertThisInitialized","ConflictError","_HankoError2","userID","_this3","RequestTimeoutError","_HankoError3","_this4","WebauthnRequestCancelledError","_HankoError4","_this5","InvalidPasswordError","_HankoError5","_this6","InvalidPasscodeError","_HankoError6","_this7","InvalidWebauthnCredentialError","_HankoError7","_this8","PasscodeExpiredError","_HankoError8","_this9","MaxNumOfPasscodeAttemptsReachedError","_HankoError9","_this10","NotFoundError","_HankoError10","_this11","TooManyRequestsError","_HankoError11","retryAfter","_this12","UnauthorizedError","_HankoError12","_this13","UserVerificationError","_HankoError13","_this14","MaxNumOfEmailAddressesReachedError","_HankoError14","_this15","EmailAddressAlreadyExistsError","_HankoError15","_this16","ThirdPartyError","_HankoError16","_this17","assign","target","i","arguments","length","source","key","api","init","converter","defaultAttributes","set","value","attributes","document","expires","Date","now","toUTCString","encodeURIComponent","replace","decodeURIComponent","escape","stringifiedAttributes","attributeName","split","cookie","write","create","get","cookies","jar","parts","slice","join","foundKey","read","e","remove","withAttributes","withConverter","freeze","path","Headers","xhr","_xhr","name","getResponseHeader","Response","headers","ok","status","statusText","url","_decodedJSON","responseURL","_proto2","json","JSON","parse","response","parseRetryAfterHeader","result","parseInt","HttpClient","timeout","authCookieName","_fetch","options","XMLHttpRequest","self","bearerToken","_getAuthCookie","resolve","reject","open","method","setRequestHeader","withCredentials","onload","getAllResponseHeaders","filter","h","toLowerCase","startsWith","authToken","_setAuthCookie","onerror","ontimeout","send","body","toString","Cookies","token","secure","match","removeAuthCookie","post","stringify","put","_proto3","patch","Client","client","ConfigClient","Promise","State","ls","_proto","store","localStorage","getItem","decoded","decodeURI","window","atob","data","encoded","btoa","encodeURI","setItem","timeToRemainingSeconds","time","Math","floor","remainingSecondsToTime","seconds","UserState","_State","apply","getUserState","_this$ls","users","hasOwnProperty","PasscodeState","_UserState","getState","_UserState$prototype$","passcode","getActiveID","id","setActiveID","passcodeID","getEmailID","emailID","setEmailID","reset","ttl","resendAfter","getTTL","setTTL","getResendAfter","setResendAfter","PasscodeClient","_Client","state","initialize","force","lastPasscodeTTL","lastEmailID","lastPasscodeID","user_id","email_id","finalize","password","getRetryAfter","setRetryAfter","PasswordClient","passwordState","passcodeState","PasswordState","login","then","update","getInfo","email","getCurrent","meResponse","me","userResponse","logout","logoutResponse","base64urlToBuffer","baseurl64String","padding","base64String","str","buffer","ArrayBuffer","byteView","Uint8Array","charCodeAt","bufferToBase64url","charCode","String","fromCharCode","copyValue","convertValue","convert","conversionFn","schema2","input","Array","map","v","output","schemaField","entries","derive","schema","required","derived","optional","publicKeyCredentialDescriptorSchema","type","transports","simplifiedExtensionsSchema","appid","appidExclude","credProps","simplifiedClientExtensionResultsSchema","credentialCreationOptions","publicKey","rp","user","displayName","challenge","pubKeyCredParams","excludeCredentials","authenticatorSelection","attestation","extensions","signal","publicKeyCredentialWithAttestation","rawId","authenticatorAttachment","clientDataJSON","attestationObject","_a","getTransports","clientExtensionResults","pkc","getClientExtensionResults","credentialRequestOptions","mediation","rpId","allowCredentials","userVerification","publicKeyCredentialWithAssertion","authenticatorData","signature","userHandle","async","requestJSON","credential","navigator","credentials","createRequestFromJSON","createResponseToJSON","getRequestFromJSON","getResponseToJSON","WebauthnSupport","supported","PublicKeyCredential","isPlatformAuthenticatorAvailable","isUserVerifyingPlatformAuthenticatorAvailable","isSecurityKeySupported","undefined","isExternalCTAP2SecurityKeySupported","isConditionalMediationAvailable","WebauthnState","webauthn","getCredentials","_this$getState","addCredential","credentialID","push","matchCredentials","find","c","WebauthnClient","webauthnState","controller","_getCredential","getWebauthnCredential","_createCredential","createWebauthnCredential","useConditionalMediation","challengeResponse","_exit","_temp2","_result","assertion","assertionResponse","finalizeResponse","credential_id","_createAbortSignal","_this2$_getCredential","register","attestationResponse","_temp3","_catch","_this3$_createCredent","_temp4","listCredentials","updateCredential","deleteCredential","shouldRegister","webauthn_credentials","matches","abort","EmailClient","list","address","setPrimaryEmail","ThirdPartyClient","auth","provider","redirectTo","URL","searchParams","append","location","href","getError","params","URLSearchParams","search","error","errorDescription","TokenClient","validate","history","replaceState","pathname","config","thirdParty","UserClient"],"mappings":"y3CAUeA,IAAAA,eAKb,SAAAC,GAAA,SAAAD,EAAsBE,EAAiBC,EAAcC,GACnD,IAAAC,EAWkD,OAXlDA,EAAAJ,EAAAK,KAAAC,KAAML,IAASK,MALjBJ,UAAI,EAAAE,EACJD,WAAK,EASHC,EAAKF,KAAOA,EAKZE,EAAKD,MAAQA,EACbI,OAAOC,eAAqBT,EAAAA,GAAAA,EAAWU,WACzCL,CAAA,CAAC,OAbDM,EAAAX,EAAAC,GALgCW,CAAAA,CAKhC,cALgCA,EAAAA,QA6B5BC,eAEJ,SAAAC,GAAA,SAAAD,EAAYT,GAAa,IAAAW,EAE+B,OADtDA,EAAMD,EAAAR,KAAAC,KAAA,kBAAmB,qBAAsBH,IAAMG,KACrDC,OAAOC,eAAcO,EAAAD,GAAOF,EAAeH,WAC7CK,CAAA,CAAC,OAHDJ,EAAAE,EAAAC,GAF2Bd,CAAAA,CAE3B,CAF2BA,GAevBiB,eAEJ,SAAAC,GAAA,SAAAD,EAAYE,EAAiBf,GAC3B,IAAAgB,EACqD,OADrDA,EAAAF,EAAAZ,KAAAC,KAAM,iBAAkB,WAAYH,IAAMG,KAC1CC,OAAOC,eAAcO,EAAAI,GAAOH,EAAcP,WAAWU,CACvD,CAAC,OAHDT,EAAAM,EAAA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