@teamhanko/hanko-frontend-sdk 0.8.1 → 0.8.3

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.umd.js","sources":["../src/lib/Errors.ts","../src/lib/state/State.ts","../src/lib/state/session/SessionState.ts","../src/lib/state/users/UserState.ts","../src/lib/state/users/PasscodeState.ts","../src/lib/events/CustomEvents.ts","../src/lib/events/Dispatcher.ts","../../node_modules/js-cookie/dist/js.cookie.mjs","../src/lib/Cookie.ts","../src/lib/client/HttpClient.ts","../src/lib/client/Client.ts","../src/lib/client/ConfigClient.ts","../src/lib/client/PasscodeClient.ts","../src/lib/state/users/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/users/WebauthnState.ts","../src/lib/client/WebauthnClient.ts","../src/lib/client/EmailClient.ts","../src/lib/client/ThirdPartyClient.ts","../src/lib/client/TokenClient.ts","../src/lib/Throttle.ts","../src/lib/events/Listener.ts","../src/lib/events/Scheduler.ts","../src/lib/Session.ts","../src/lib/events/Relay.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","import { LocalStorageUsers } from \"./users/UserState\";\nimport { LocalStorageSession } from \"./session/SessionState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {LocalStorageUsers=} users - The user states.\n */\ninterface LocalStorage {\n users?: LocalStorageUsers;\n session?: LocalStorageSession;\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 key: string;\n ls: LocalStorage;\n\n // eslint-disable-next-line require-jsdoc\n constructor(key: string) {\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","import { State } from \"../State\";\n\n/**\n * Options for SessionState\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\ninterface SessionStateOptions {\n localStorageKey: string;\n}\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {Object.<string, LocalStorageSession>} - A dictionary for mapping users to their states.\n */\nexport interface LocalStorageSession {\n expiry: number;\n userID: string;\n authFlowCompleted: boolean;\n}\n\n/**\n * A class to read and write local storage contents regarding sessions.\n *\n * @extends State\n * @param {SessionStateOptions} options - The options that can be used\n * @category SDK\n * @subcategory Internal\n */\nclass SessionState extends State {\n // eslint-disable-next-line require-jsdoc\n constructor(options: SessionStateOptions) {\n super(`${options.localStorageKey}_session`);\n }\n\n /**\n * Reads the current state.\n *\n * @public\n * @return {SessionState}\n */\n read(): SessionState {\n super.read();\n\n return this;\n }\n\n /**\n * Gets the session state.\n *\n * @return {LocalStorageSession}\n */\n getState(): LocalStorageSession {\n this.ls.session ||= { expiry: 0, userID: \"\", authFlowCompleted: false };\n return this.ls.session;\n }\n\n /**\n * Gets the number of seconds until the active session is valid.\n *\n * @return {number}\n */\n getExpirationSeconds(): number {\n return State.timeToRemainingSeconds(this.getState().expiry);\n }\n\n /**\n * Sets the number of seconds until the active session is valid.\n *\n * @param {number} seconds - The number of seconds\n * @return {SessionState}\n */\n setExpirationSeconds(seconds: number): SessionState {\n this.getState().expiry = State.remainingSecondsToTime(seconds);\n return this;\n }\n\n /**\n * Gets the user id.\n */\n getUserID(): string {\n return this.getState().userID;\n }\n\n /**\n * Sets the user id.\n *\n * @param {string} userID - The user id\n * @return {SessionState}\n */\n setUserID(userID: string): SessionState {\n this.getState().userID = userID;\n return this;\n }\n\n /**\n * Gets the authFlowCompleted indicator.\n */\n getAuthFlowCompleted(): boolean {\n return this.getState().authFlowCompleted;\n }\n\n /**\n * Sets the authFlowCompleted indicator.\n *\n * @param {string} completed - The authFlowCompleted indicator.\n * @return {SessionState}\n */\n setAuthFlowCompleted(completed: boolean): SessionState {\n this.getState().authFlowCompleted = completed;\n return this;\n }\n\n /**\n * Removes the session details.\n *\n * @return {SessionState}\n */\n reset(): SessionState {\n const session = this.getState();\n\n delete session.expiry;\n delete session.userID;\n\n return this;\n }\n}\n\nexport { SessionState };\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 {number} 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","/**\n * The type of the `hanko-session-created` event.\n * @typedef {string} sessionCreatedType\n * @memberOf Listener\n */\nexport const sessionCreatedType: \"hanko-session-created\" =\n \"hanko-session-created\";\n\n/**\n * The type of the `hanko-session-expired` event.\n * @typedef {string} sessionExpiredType\n * @memberOf Listener\n */\nexport const sessionExpiredType: \"hanko-session-expired\" =\n \"hanko-session-expired\";\n\n/**\n * The type of the `hanko-user-logged-out` event.\n * @typedef {string} userLoggedOutType\n * @memberOf Listener\n */\nexport const userLoggedOutType: \"hanko-user-logged-out\" =\n \"hanko-user-logged-out\";\n\n/**\n * The type of the `hanko-user-deleted` event.\n * @typedef {string} userDeletedType\n * @memberOf Listener\n */\nexport const userDeletedType: \"hanko-user-deleted\" = \"hanko-user-deleted\";\n\n/**\n * The type of the `hanko-auth-flow-completed` event.\n * @typedef {string} authFlowCompletedType\n * @memberOf Listener\n */\nexport const authFlowCompletedType: \"hanko-auth-flow-completed\" =\n \"hanko-auth-flow-completed\";\n\n/**\n * The data passed in the `hanko-session-created` or `hanko-session-resumed` event.\n *\n * @interface\n * @category SDK\n * @subcategory Events\n * @property {string=} jwt - The JSON web token associated with the session. Only present when the Hanko-API allows the JWT to be accessible client-side.\n * @property {number} expirationSeconds - The number of seconds until the JWT expires.\n * @property {string} userID - The user associated with the session.\n */\nexport interface SessionDetail {\n jwt?: string;\n expirationSeconds: number;\n userID: string;\n}\n\n/**\n * The data passed in the `hanko-auth-flow-completed` event.\n *\n * @interface\n * @category SDK\n * @subcategory Events\n * @property {string} userID - The user associated with the removed session.\n */\nexport interface AuthFlowCompletedDetail {\n userID: string;\n}\n\n/**\n * A custom event that includes a detail object.\n *\n * @category SDK\n * @subcategory Events\n * @extends CustomEvent\n * @ignore\n * @param {string} type - The type of the event.\n * @param {T} detail - The detail object to include in the event.\n */\nexport class CustomEventWithDetail<T> extends CustomEvent<T> {\n // eslint-disable-next-line require-jsdoc\n constructor(type: string, detail: T) {\n super(type, { detail });\n }\n}\n","import {\n SessionDetail,\n CustomEventWithDetail,\n AuthFlowCompletedDetail,\n sessionCreatedType,\n sessionExpiredType,\n userDeletedType,\n authFlowCompletedType,\n userLoggedOutType,\n} from \"./CustomEvents\";\nimport { SessionState } from \"../state/session/SessionState\";\n\n/**\n * Options for Dispatcher\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\ninterface DispatcherOptions {\n localStorageKey: string;\n}\n\n/**\n * A class that dispatches custom events.\n *\n * @category SDK\n * @subcategory Internal\n * @param {DispatcherOptions} options - The options that can be used\n */\nexport class Dispatcher {\n _dispatchEvent = document.dispatchEvent.bind(document);\n _sessionState: SessionState;\n\n // eslint-disable-next-line require-jsdoc\n constructor(options: DispatcherOptions) {\n this._sessionState = new SessionState({ ...options });\n }\n\n /**\n * Dispatches a custom event.\n *\n * @param {string} type\n * @param {T} detail\n * @private\n */\n private dispatch<T>(type: string, detail: T) {\n this._dispatchEvent(new CustomEventWithDetail(type, detail));\n }\n\n /**\n * Dispatches a \"hanko-session-created\" event to the document with the specified detail.\n *\n * @param {SessionDetail} detail - The event detail.\n */\n public dispatchSessionCreatedEvent(detail: SessionDetail) {\n this.dispatch(sessionCreatedType, detail);\n }\n\n /**\n * Dispatches a \"hanko-session-expired\" event to the document.\n */\n public dispatchSessionExpiredEvent() {\n this.dispatch(sessionExpiredType, null);\n }\n\n /**\n * Dispatches a \"hanko-user-logged-out\" event to the document.\n */\n public dispatchUserLoggedOutEvent() {\n this.dispatch(userLoggedOutType, null);\n }\n\n /**\n * Dispatches a \"hanko-user-deleted\" event to the document.\n */\n public dispatchUserDeletedEvent() {\n this.dispatch(userDeletedType, null);\n }\n\n /**\n * Dispatches a \"hanko-auth-flow-completed\" event to the document with the specified detail.\n *\n * @param {AuthFlowCompletedDetail} detail - The event detail.\n */\n public dispatchAuthFlowCompletedEvent(detail: AuthFlowCompletedDetail) {\n this._sessionState.read().setAuthFlowCompleted(true).write();\n this.dispatch(authFlowCompletedType, detail);\n }\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 JSCookie from \"js-cookie\";\n\n/**\n * Options for Cookie\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} cookieName - The name of the session cookie set from the SDK.\n */\ninterface CookieOptions {\n cookieName: string;\n}\n\n/**\n * A class to manage cookies.\n *\n * @category SDK\n * @subcategory Internal\n * @param {CookieOptions} options - The options that can be used\n */\nexport class Cookie {\n authCookieName: string;\n\n // eslint-disable-next-line require-jsdoc\n constructor(options: CookieOptions) {\n this.authCookieName = options.cookieName;\n }\n\n /**\n * Returns the authentication token that was stored in the cookie.\n *\n * @return {string}\n */\n getAuthCookie(): string {\n return JSCookie.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 * @param {boolean=} secure - Indicates a secure cookie should be set. Default is `true`.\n */\n setAuthCookie(token: string, secure = true) {\n JSCookie.set(this.authCookieName, token, { secure });\n }\n\n /**\n * Removes the cookie used for authentication.\n */\n removeAuthCookie() {\n JSCookie.remove(this.authCookieName);\n }\n}\n","import { RequestTimeoutError, TechnicalError } from \"../Errors\";\nimport { SessionState } from \"../state/session/SessionState\";\nimport { PasscodeState } from \"../state/users/PasscodeState\";\nimport { Dispatcher } from \"../events/Dispatcher\";\nimport { Cookie } from \"../Cookie\";\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 getResponseHeader(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 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 response header value with the given `name` as a number. When the value is not a number the return\n * value will be 0.\n *\n * @param {string} name - The name of the header field\n * @return {number}\n */\n parseNumericHeader(name: string): number {\n const result = parseInt(this.headers.getResponseHeader(name), 10);\n return isNaN(result) ? 0 : result;\n }\n}\n\n/**\n * Options for the HttpClient\n *\n * @category SDK\n * @subcategory Internal\n * @property {number} timeout - The http request timeout in milliseconds.\n * @property {string} cookieName - The name of the session cookie set from the SDK.\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\nexport interface HttpClientOptions {\n timeout: number;\n cookieName: string;\n localStorageKey: string;\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 {HttpClientOptions} options - The options the HttpClient must be provided\n */\nclass HttpClient {\n timeout: number;\n api: string;\n sessionState: SessionState;\n passcodeState: PasscodeState;\n dispatcher: Dispatcher;\n cookie: Cookie;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, options: HttpClientOptions) {\n this.api = api;\n this.timeout = options.timeout;\n this.sessionState = new SessionState({ ...options });\n this.passcodeState = new PasscodeState(options.cookieName);\n this.dispatcher = new Dispatcher({ ...options });\n this.cookie = new Cookie({ ...options });\n }\n\n // eslint-disable-next-line require-jsdoc\n _fetch(path: string, options: RequestInit, xhr = new XMLHttpRequest()) {\n const url = this.api + path;\n const timeout = this.timeout;\n const bearerToken = this.cookie.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 response = new Response(xhr);\n resolve(response);\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 * Processes the response headers on login and extracts the JWT and expiration time. Also, the passcode state will be\n * removed, the session state updated und a `hanko-session-created` event will be dispatched.\n *\n * @param {string} userID - The user ID.\n * @param {Response} response - The HTTP response object.\n */\n processResponseHeadersOnLogin(userID: string, response: Response) {\n let jwt = \"\";\n let expirationSeconds = 0;\n\n response.xhr\n .getAllResponseHeaders()\n .split(\"\\r\\n\")\n .forEach((h) => {\n const header = h.toLowerCase();\n if (header.startsWith(\"x-auth-token\")) {\n jwt = response.headers.getResponseHeader(\"X-Auth-Token\");\n } else if (header.startsWith(\"x-session-lifetime\")) {\n expirationSeconds = parseInt(\n response.headers.getResponseHeader(\"X-Session-Lifetime\"),\n 10\n );\n }\n });\n\n if (jwt) {\n const secure = !!this.api.match(\"^https://\");\n this.cookie.setAuthCookie(jwt, secure);\n }\n\n this.passcodeState.read().reset(userID).write();\n\n if (expirationSeconds > 0) {\n this.sessionState.read();\n this.sessionState.setExpirationSeconds(expirationSeconds);\n this.sessionState.setUserID(userID);\n this.sessionState.setAuthFlowCompleted(false);\n this.sessionState.write();\n this.dispatcher.dispatchSessionCreatedEvent({\n jwt,\n userID,\n expirationSeconds,\n });\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, HttpClientOptions } 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 {HttpClientOptions} options - The options that can be used\n */\nabstract class Client {\n client: HttpClient;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, options: HttpClientOptions) {\n /**\n * @public\n * @type {HttpClient}\n */\n this.client = new HttpClient(api, options);\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 { PasscodeState } from \"../state/users/PasscodeState\";\nimport { Passcode } from \"../Dto\";\nimport {\n InvalidPasscodeError,\n MaxNumOfPasscodeAttemptsReachedError,\n PasscodeExpiredError,\n TechnicalError,\n TooManyRequestsError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\nimport { HttpClientOptions } from \"./HttpClient\";\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, options: HttpClientOptions) {\n super(api, options);\n /**\n * @public\n * @type {PasscodeState}\n */\n this.state = new PasscodeState(options.cookieName);\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {TooManyRequestsError}\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.parseNumericHeader(\"Retry-After\");\n this.state.setResendAfter(userID, retryAfter).write();\n throw new TooManyRequestsError(retryAfter);\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.client.processResponseHeadersOnLogin(userID, response);\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/users/PasswordState\";\nimport { PasscodeState } from \"../state/users/PasscodeState\";\nimport {\n InvalidPasswordError,\n TechnicalError,\n TooManyRequestsError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\nimport { HttpClientOptions } from \"./HttpClient\";\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, options: HttpClientOptions) {\n super(api, options);\n /**\n * @public\n * @type {PasswordState}\n */\n this.passwordState = new PasswordState(options.cookieName);\n /**\n * @public\n * @type {PasscodeState}\n */\n this.passcodeState = new PasscodeState(options.cookieName);\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 {InvalidPasswordError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {TooManyRequestsError}\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.parseNumericHeader(\"Retry-After\");\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.client.processResponseHeadersOnLogin(userID, response);\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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, UserCreated } 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<UserCreated>}\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<UserCreated> {\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 const createUser: UserCreated = response.json();\n if (createUser && createUser.user_id) {\n this.client.processResponseHeadersOnLogin(createUser.user_id, response);\n }\n return createUser;\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 (meResponse.status === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\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 (userResponse.status === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {UnauthorizedError}\n */\n async delete(): Promise<void> {\n const response = await this.client.delete(\"/user\");\n\n if (response.ok) {\n this.client.cookie.removeAuthCookie();\n this.client.sessionState.reset().write();\n this.client.dispatcher.dispatchUserDeletedEvent();\n return;\n } else if (response.status === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\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.cookie.removeAuthCookie();\n this.client.sessionState.reset().write();\n this.client.dispatcher.dispatchUserLoggedOutEvent();\n\n if (logoutResponse.status === 401) {\n // The user is logged out already\n return;\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/users/PasscodeState\";\nimport { WebauthnState } from \"../state/users/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\";\nimport { HttpClientOptions } from \"./HttpClient\";\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 _getCredential = getWebauthnCredential;\n _createCredential = createWebauthnCredential;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, options: HttpClientOptions) {\n super(api, options);\n /**\n * @public\n * @type {WebauthnState}\n */\n this.webauthnState = new WebauthnState(options.cookieName);\n /**\n * @public\n * @type {PasscodeState}\n */\n this.passcodeState = new PasscodeState(options.cookieName);\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 * @return {WebauthnFinalized}\n */\n async login(\n userID?: string,\n useConditionalMediation?: boolean\n ): Promise<WebauthnFinalized> {\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.client.processResponseHeadersOnLogin(\n finalizeResponse.user_id,\n assertionResponse\n );\n\n return finalizeResponse;\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 === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\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 (attestationResponse.status === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\n throw new UnauthorizedError();\n }\n if (attestationResponse.status === 422) {\n throw new UserVerificationError();\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {UnauthorizedError}\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {UnauthorizedError}\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {UnauthorizedError}\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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\";\nimport { HankoOptions } from \"../../Hanko\";\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 /**\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\";\nimport { TokenFinalized } from \"../Dto\";\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 /**\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 const tokenResponse: TokenFinalized = response.json();\n this.client.processResponseHeadersOnLogin(tokenResponse.user_id, response);\n }\n}\n","/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {boolean=} leading - Whether to allow the function to be called on the leading edge of the wait timeout.\n * @property {boolean=} trailing - Whether to allow the function to be called on the trailing edge of the wait timeout.\n */\ninterface ThrottleOptions {\n leading?: boolean;\n trailing?: boolean;\n}\n\n// eslint-disable-next-line no-unused-vars\ntype ThrottledFunction<T extends (...args: any[]) => any> = (\n // eslint-disable-next-line no-unused-vars\n ...args: Parameters<T>\n) => void;\n\n/**\n * Provides throttle functionality.\n *\n * @hideconstructor\n * @category SDK\n * @subcategory Internal\n */\nexport class Throttle {\n /**\n * Throttles a function, ensuring that it can only be called once per `wait` milliseconds.\n *\n * @static\n * @param {function} func - The function to throttle.\n * @param {number} wait - The number of milliseconds to wait between function invocations.\n * @param {ThrottleOptions} options - Optional configuration for the throttle.\n * @returns {function} A throttled version of the original function.\n */\n // eslint-disable-next-line no-unused-vars,require-jsdoc\n static throttle<T extends (...args: any[]) => any>(\n func: T,\n wait: number,\n options: ThrottleOptions = {}\n ): ThrottledFunction<T> {\n const { leading = true, trailing = true } = options;\n let context: any;\n let args: any;\n let timeoutID: number;\n let previous = 0;\n\n // This function is used to invoke the original function.\n const executeThrottledFunction = () => {\n // If 'leading' is false and this is not the first invocation of the throttled function, set 'previous' to 0 to\n // ensure that the function is not called immediately.\n previous = leading === false ? 0 : Date.now();\n timeoutID = null;\n // Invoke the original function.\n func.apply(context, args);\n };\n\n // This is the throttled function that will be returned.\n const throttled = function (...funcArgs: Parameters<T>) {\n const now = Date.now();\n\n // If this is the first time the throttled function is being called, and 'leading' is false,\n // set 'previous' to the current time to ensure that the function is not called immediately.\n if (!previous && leading === false) previous = now;\n\n // The remaining wait time.\n const remaining = wait - (now - previous);\n\n // Save the context and arguments of the function call.\n // eslint-disable-next-line no-invalid-this\n context = this;\n args = funcArgs;\n\n // Check whether it's time to call the function immediately based on the leading and trailing options. If leading\n // is enabled and there was no previous invocation, or if trailing is enabled and the wait time has already passed,\n // the function will be invoked immediately.\n if (remaining <= 0 || remaining > wait) {\n // If there is a pending timeout, clear it.\n if (timeoutID) {\n window.clearTimeout(timeoutID);\n timeoutID = null;\n }\n\n // Invoke the original function and update the previous timestamp.\n previous = now;\n func.apply(context, args);\n } else if (!timeoutID && trailing !== false) {\n // If there is no pending timeout and trailing is allowed, start a new timeout.\n timeoutID = window.setTimeout(executeThrottledFunction, remaining);\n }\n };\n\n return throttled;\n }\n}\n","import { Throttle } from \"../Throttle\";\nimport {\n CustomEventWithDetail,\n SessionDetail,\n AuthFlowCompletedDetail,\n sessionCreatedType,\n sessionExpiredType,\n userDeletedType,\n authFlowCompletedType,\n userLoggedOutType,\n} from \"./CustomEvents\";\n\n/**\n * A callback function to be executed when an event is triggered.\n *\n * @alias CallbackFunc\n * @typedef {function} CallbackFunc\n * @memberOf Listener\n */\n// eslint-disable-next-line no-unused-vars\ntype CallbackFunc<T> = (detail: T) => any;\n\n/**\n * A wrapped callback function that will execute the original callback.\n *\n * @ignore\n * @param {T} event - The event object passed in the event.\n */\n// eslint-disable-next-line no-unused-vars\ntype WrappedCallback<T> = (event: CustomEventWithDetail<T>) => void;\n\n/**\n * A function returned when adding an event listener. The function can be called to remove the corresponding event\n * listener.\n *\n * @alias CleanupFunc\n * @typedef {function} CleanupFunc\n * @memberOf Listener\n */\ntype CleanupFunc = () => void;\n\n/**\n * @interface\n * @ignore\n * @property {Function} callback - The function to be executed.\n * @property {boolean=} once - Whether the event listener should be removed after being called once.\n */\ninterface EventListenerParams<T> {\n callback: CallbackFunc<T>;\n once?: boolean;\n}\n\n/**\n * @interface\n * @ignore\n * @extends {EventListenerParams<T>}\n * @property {string} type - The type of the event.\n * @property {boolean=} throttle - Whether the event listener should be throttled.\n */\ninterface EventListenerWithTypeParams<T> extends EventListenerParams<T> {\n type: string;\n throttle?: boolean;\n}\n\n/**\n * A class to bind event listener for custom events.\n *\n * @category SDK\n * @subcategory Events\n */\nexport class Listener {\n public throttleLimit = 1000;\n _addEventListener = document.addEventListener.bind(document);\n _removeEventListener = document.removeEventListener.bind(document);\n _throttle = Throttle.throttle;\n\n /**\n * Wraps the given callback.\n *\n * @param callback\n * @param throttle\n * @private\n * @return {WrappedCallback}\n */\n private wrapCallback<T>(\n callback: CallbackFunc<T>,\n throttle: boolean\n ): WrappedCallback<T> {\n // The function that will be called when the event is triggered.\n const wrappedCallback = (event: CustomEventWithDetail<T>) => {\n callback(event.detail);\n };\n\n // Throttle the listener if multiple SDK instances could trigger the same event at the same time,\n // but the callback function should only be executed once.\n if (throttle) {\n return this._throttle(wrappedCallback, this.throttleLimit, {\n leading: true,\n trailing: false,\n });\n }\n\n return wrappedCallback;\n }\n\n /**\n * Adds an event listener with the specified type, callback function, and options.\n *\n * @private\n * @param {EventListenerWithTypeParams<T>} params - The parameters for the event listener.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n private addEventListenerWithType<T>({\n type,\n callback,\n once = false,\n throttle = false,\n }: EventListenerWithTypeParams<T>): CleanupFunc {\n const wrappedCallback = this.wrapCallback(callback, throttle);\n this._addEventListener(type, wrappedCallback, { once });\n return () => this._removeEventListener(type, wrappedCallback);\n }\n\n /**\n * Maps the parameters for an event listener to the `EventListenerWithTypeParams` interface.\n *\n * @static\n * @private\n * @param {string} type - The type of the event.\n * @param {EventListenerParams<T>} params - The parameters for the event listener.\n * @param {boolean} [throttle=false] - Whether the event listener should be throttled.\n * @returns {EventListenerWithTypeParams<T>}\n **/\n private static mapAddEventListenerParams<T>(\n type: string,\n { once, callback }: EventListenerParams<T>,\n throttle?: boolean\n ): EventListenerWithTypeParams<T> {\n return {\n type,\n callback,\n once,\n throttle,\n };\n }\n\n /**\n * Adds an event listener with the specified type, callback function, and options.\n *\n * @private\n * @param {string} type - The type of the event.\n * @param {EventListenerParams<T>} params - The parameters for the event listener.\n * @param {boolean=} throttle - Whether the event listener should be throttled.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n private addEventListener<T>(\n type: string,\n params: EventListenerParams<T>,\n throttle?: boolean\n ) {\n return this.addEventListenerWithType(\n Listener.mapAddEventListenerParams(type, params, throttle)\n );\n }\n\n /**\n * Adds an event listener for \"hanko-session-created\" events. Will be triggered across all browser windows, when the user\n * logs in, or when the page has been loaded or refreshed and there is a valid session.\n *\n * @param {CallbackFunc<SessionDetail>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onSessionCreated(\n callback: CallbackFunc<SessionDetail>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(sessionCreatedType, { callback, once }, true);\n }\n\n /**\n * Adds an event listener for \"hanko-session-expired\" events. The event will be triggered across all browser windows\n * as soon as the current JWT expires or the user logs out. It also triggers, when the user deletes the account in\n * another window.\n *\n * @param {CallbackFunc<null>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onSessionExpired(\n callback: CallbackFunc<null>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(sessionExpiredType, { callback, once }, true);\n }\n\n /**\n * Adds an event listener for hanko-user-deleted events. The event triggers, when the user has deleted the account in\n * the browser window where the deletion happened.\n *\n * @param {CallbackFunc<null>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onUserLoggedOut(\n callback: CallbackFunc<null>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(userLoggedOutType, { callback, once });\n }\n\n /**\n * Adds an event listener for hanko-user-deleted events. The event triggers, when the user has deleted the account.\n *\n * @param {CallbackFunc<null>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onUserDeleted(\n callback: CallbackFunc<null>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(userDeletedType, { callback, once });\n }\n\n /**\n * Adds an event listener for hanko-auth-flow-completed events. Will be triggered after the login or registration flow has been completed.\n *\n * @param {CallbackFunc<AuthFlowCompletedDetail>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onAuthFlowCompleted(\n callback: CallbackFunc<AuthFlowCompletedDetail>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(authFlowCompletedType, { callback, once });\n }\n}\n","/**\n * Represents a task to be scheduled in the scheduler.\n *\n * @ignore\n * @param {number} timeoutID - the ID returned by `setTimeout()`\n * @param {string} type - The type, helps to organize the tasks.\n * @param {Function} func - The function to be called within the task.\n */\nexport type Task = {\n timeoutID: number;\n type: string;\n func: () => any;\n};\n\n/**\n * A class that manages scheduled tasks.\n *\n * @category SDK\n * @subcategory Internal\n */\nexport class Scheduler {\n // An array of scheduled tasks.\n _tasks: Task[] = [];\n\n /**\n * Removes a task from the scheduler.\n *\n * @private\n * @param {Task} task - The task to be removed.\n */\n private removeTask(task: Task) {\n window.clearTimeout(task.timeoutID);\n this._tasks = this._tasks.filter((_task) => _task !== task);\n }\n\n /**\n * Removes all tasks with a given type from the scheduler.\n *\n * @param {string} type - The type of tasks to be removed.\n */\n removeTasksWithType(type: string) {\n const tasks = this._tasks.filter((task) => task.type === type);\n tasks.forEach((task) => this.removeTask(task));\n }\n\n /**\n * Schedules a task to be executed after a given timeout.\n *\n * @param {string} type - The type of the task.\n * @param {Function} func - The function to be executed when the task is triggered.\n * @param {number} timeoutSeconds - The timeout after which the task should be executed, in seconds.\n */\n scheduleTask(type: string, func: () => any, timeoutSeconds: number) {\n const task: Task = {\n timeoutID: window.setTimeout(() => {\n func();\n this.removeTask(task);\n }, timeoutSeconds * 1000),\n type,\n func,\n };\n this._tasks.push(task);\n }\n}\n","import { SessionDetail } from \"./events/CustomEvents\";\nimport { SessionState } from \"./state/session/SessionState\";\nimport { Cookie } from \"./Cookie\";\n\n/**\n * Options for Session\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} cookieName - The name of the session cookie set from the SDK.\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\ninterface SessionOptions {\n cookieName: string;\n localStorageKey: string;\n}\n\n/**\n A class representing a session.\n\n @category SDK\n @subcategory Session\n @param {SessionOptions} options - The options that can be used\n */\nexport class Session {\n _sessionState: SessionState;\n _cookie: Cookie;\n\n // eslint-disable-next-line require-jsdoc\n constructor(options: SessionOptions) {\n this._sessionState = new SessionState({ ...options });\n this._cookie = new Cookie({ ...options });\n }\n\n /**\n Retrieves the session details.\n\n @returns {SessionDetail} The session details.\n */\n public get(): SessionDetail {\n const detail = this._get();\n return Session.validate(detail) ? detail : null;\n }\n\n /**\n Checks if the user is logged in.\n\n @returns {boolean} true if the user is logged in, false otherwise.\n */\n public isValid(): boolean {\n const session = this._get();\n return Session.validate(session);\n }\n\n /**\n Retrieves the session details.\n\n @ignore\n @returns {SessionDetail} The session details.\n */\n public _get(): SessionDetail {\n this._sessionState.read();\n\n const userID = this._sessionState.getUserID();\n const expirationSeconds = this._sessionState.getExpirationSeconds();\n const jwt = this._cookie.getAuthCookie();\n\n return {\n userID,\n expirationSeconds,\n jwt,\n };\n }\n\n /**\n Checks if the auth flow is completed. The value resets after the next login attempt.\n\n @returns {boolean} Returns true if the authentication flow is completed, false otherwise\n */\n public isAuthFlowCompleted() {\n this._sessionState.read();\n return this._sessionState.getAuthFlowCompleted();\n }\n\n /**\n Validates the session.\n\n @private\n @param {SessionDetail} detail - The session details to validate.\n @returns {boolean} true if the session details are valid, false otherwise.\n */\n private static validate(detail: SessionDetail): boolean {\n return !!(detail.expirationSeconds > 0 && detail.userID?.length);\n }\n}\n","import { SessionDetail, sessionExpiredType } from \"./CustomEvents\";\nimport { Listener } from \"./Listener\";\nimport { Scheduler } from \"./Scheduler\";\nimport { Dispatcher } from \"./Dispatcher\";\nimport { Session } from \"../Session\";\n\n/**\n * Options for Relay\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} cookieName - The name of the session cookie set from the SDK.\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\ninterface RelayOptions {\n cookieName: string;\n localStorageKey: string;\n}\n\n/**\n * A class that dispatches events and scheduled events, based on other events.\n *\n * @category SDK\n * @subcategory Internal\n * @extends Dispatcher\n * @param {RelayOptions} options - The options that can be used\n */\nexport class Relay extends Dispatcher {\n _listener = new Listener();\n _scheduler = new Scheduler();\n _session: Session;\n\n // eslint-disable-next-line require-jsdoc\n constructor(options: RelayOptions) {\n super({ ...options });\n this._session = new Session({ ...options });\n this.listenEventDependencies();\n }\n\n /**\n * Removes the scheduled \"hanko-session-expired\" event and re-schedules a new event with updated expirationSeconds, to\n * ensure the \"hanko-session-expired\" event won't be triggered too early.\n *\n * @private\n * @param {SessionDetail} detail - The event detail.\n */\n private scheduleSessionExpiredEvent = (detail: SessionDetail) => {\n this._scheduler.removeTasksWithType(sessionExpiredType);\n this._scheduler.scheduleTask(\n sessionExpiredType,\n () => this.dispatchSessionExpiredEvent(),\n detail.expirationSeconds\n );\n };\n\n /**\n * Cancels scheduled \"hanko-session-expired\" events, to prevent it from being triggered again (e.g. when there are\n * multiple SDK instances).\n *\n * @private\n */\n private cancelSessionExpiredEvent = () => {\n this._scheduler.removeTasksWithType(sessionExpiredType);\n };\n\n /**\n * Handles the \"storage\" event in case the local storage entry, that contains the session detail has been changed by\n * another window. Depending on the new value of `expirationSeconds`, it either dispatches a \"hanko-session-created\"\n * or a \"hanko-session-expired\" event.\n *\n * @private\n * @param {StorageEvent} event - The storage event object.\n */\n private handleStorageEvent = (event: StorageEvent) => {\n if (event.key !== \"hanko_session\") return;\n\n const sessionDetail = this._session.get();\n\n if (!sessionDetail) {\n this.dispatchSessionExpiredEvent();\n return;\n }\n\n if (this._session.isAuthFlowCompleted()) {\n this.dispatchAuthFlowCompletedEvent({ userID: sessionDetail.userID });\n return;\n }\n\n this.dispatchSessionCreatedEvent(sessionDetail);\n };\n\n /**\n * Listens for events sent in the current browser.\n *\n * @private\n */\n private listenEventDependencies() {\n this._listener.onSessionCreated(this.scheduleSessionExpiredEvent);\n this._listener.onSessionExpired(this.cancelSessionExpiredEvent);\n this._listener.onUserDeleted(this.cancelSessionExpiredEvent);\n this._listener.onUserLoggedOut(this.cancelSessionExpiredEvent);\n\n // Handle cases, where the session has been changed by another window.\n window.addEventListener(\"storage\", this.handleStorageEvent);\n\n const sessionDetail = this._session.get();\n\n if (sessionDetail) {\n this.scheduleSessionExpiredEvent(sessionDetail);\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\";\nimport { Listener } from \"./lib/events/Listener\";\nimport { Relay } from \"./lib/events/Relay\";\nimport { Session } from \"./lib/Session\";\n\n/**\n * The options for the Hanko class\n *\n * @interface\n * @property {number=} timeout - The http request timeout in milliseconds. Defaults to 13000ms\n * @property {string=} cookieName - The name of the session cookie set from the SDK. Defaults to \"hanko\"\n * @property {string=} localStorageKey - The prefix / name of the local storage keys. Defaults to \"hanko\"\n */\nexport interface HankoOptions {\n timeout?: number;\n cookieName?: string;\n localStorageKey?: string;\n}\n\n/**\n * A class that bundles all available SDK functions.\n *\n * @extends {Listener}\n * @param {string} api - The URL of your Hanko API instance\n * @param {HankoOptions=} options - The options that can be used\n */\nclass Hanko extends Listener {\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 relay: Relay;\n session: Session;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, options?: HankoOptions) {\n super();\n const opts: InternalOptions = {\n timeout: 13000,\n cookieName: \"hanko\",\n localStorageKey: \"hanko\",\n };\n if (options?.cookieName !== undefined) {\n opts.cookieName = options.cookieName;\n }\n if (options?.timeout !== undefined) {\n opts.timeout = options.timeout;\n }\n if (options?.localStorageKey !== undefined) {\n opts.localStorageKey = options.localStorageKey;\n }\n\n this.api = api;\n /**\n * @public\n * @type {ConfigClient}\n */\n this.config = new ConfigClient(api, opts);\n /**\n * @public\n * @type {UserClient}\n */\n this.user = new UserClient(api, opts);\n /**\n * @public\n * @type {WebauthnClient}\n */\n this.webauthn = new WebauthnClient(api, opts);\n /**\n * @public\n * @type {PasswordClient}\n */\n this.password = new PasswordClient(api, opts);\n /**\n * @public\n * @type {PasscodeClient}\n */\n this.passcode = new PasscodeClient(api, opts);\n /**\n * @public\n * @type {EmailClient}\n */\n this.email = new EmailClient(api, opts);\n /**\n * @public\n * @type {ThirdPartyClient}\n */\n this.thirdParty = new ThirdPartyClient(api, opts);\n /**\n * @public\n * @type {TokenClient}\n */\n this.token = new TokenClient(api, opts);\n /**\n * @public\n * @type {Relay}\n */\n this.relay = new Relay({ ...opts });\n /**\n * @public\n * @type {Session}\n */\n this.session = new Session({ ...opts });\n }\n}\n\n// eslint-disable-next-line require-jsdoc\nexport interface InternalOptions {\n timeout: number;\n cookieName: string;\n localStorageKey: string;\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","State","key","ls","_proto","read","store","data","localStorage","getItem","decoded","decodeURIComponent","decodeURI","window","atob","JSON","parse","e","write","stringify","btoa","encodeURI","encodeURIComponent","setItem","encoded","timeToRemainingSeconds","time","Math","floor","Date","now","remainingSecondsToTime","seconds","SessionState","_State","options","localStorageKey","getState","_this$ls","session","expiry","authFlowCompleted","getExpirationSeconds","setExpirationSeconds","getUserID","setUserID","getAuthFlowCompleted","setAuthFlowCompleted","completed","reset","UserState","apply","arguments","getUserState","users","hasOwnProperty","PasscodeState","_UserState","_UserState$prototype$","passcode","getActiveID","id","setActiveID","passcodeID","getEmailID","emailID","setEmailID","ttl","resendAfter","getTTL","setTTL","getResendAfter","setResendAfter","sessionExpiredType","userLoggedOutType","userDeletedType","CustomEventWithDetail","type","detail","_wrapNativeSuper","CustomEvent","Dispatcher","_dispatchEvent","document","dispatchEvent","bind","_sessionState","dispatch","dispatchSessionCreatedEvent","sessionCreatedType","dispatchSessionExpiredEvent","dispatchUserLoggedOutEvent","dispatchUserDeletedEvent","dispatchAuthFlowCompletedEvent","authFlowCompletedType","assign","target","i","length","source","api","init","converter","defaultAttributes","set","value","attributes","expires","toUTCString","replace","escape","stringifiedAttributes","attributeName","split","cookie","create","get","cookies","jar","parts","slice","join","foundKey","remove","withAttributes","withConverter","freeze","path","Cookie","authCookieName","cookieName","getAuthCookie","JSCookie","setAuthCookie","token","secure","removeAuthCookie","Headers","xhr","_xhr","Response","getResponseHeader","name","headers","ok","status","statusText","url","_decodedJSON","responseURL","_proto2","HttpClient","json","response","parseNumericHeader","result","parseInt","isNaN","timeout","sessionState","passcodeState","dispatcher","_extends","_fetch","Promise","resolve","reject","open","method","setRequestHeader","bearerToken","withCredentials","onload","onerror","ontimeout","send","body","toString","processResponseHeadersOnLogin","jwt","getAllResponseHeaders","forEach","h","toLowerCase","header","startsWith","expirationSeconds","match","_proto3","post","put","patch","Client","client","ConfigClient","PasscodeClient","_Client","state","initialize","force","lastPasscodeTTL","lastEmailID","lastPasscodeID","user_id","email_id","then","finalize","password","getRetryAfter","setRetryAfter","PasswordClient","passwordState","PasswordState","login","update","getInfo","email","createUser","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","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","filter","find","c","WebauthnClient","webauthnState","controller","_getCredential","getWebauthnCredential","_createCredential","createWebauthnCredential","useConditionalMediation","challengeResponse","_exit","_temp2","_result","assertion","assertionResponse","finalizeResponse","credential_id","_createAbortSignal","_temp","_catch","_this2$_getCredential","register","_temp4","_result2","attestationResponse","_temp3","listCredentials","updateCredential","deleteCredential","shouldRegister","webauthn_credentials","matches","abort","AbortController","EmailClient","list","address","setPrimaryEmail","ThirdPartyClient","auth","provider","redirectTo","searchParams","append","location","href","getError","params","URLSearchParams","search","error","errorDescription","TokenClient","validate","history","replaceState","pathname","tokenResponse","Throttle","throttle","func","wait","context","args","timeoutID","_options$leading","leading","_options$trailing","trailing","previous","remaining","clearTimeout","setTimeout","executeThrottledFunction","throttleLimit","_addEventListener","addEventListener","_removeEventListener","removeEventListener","_throttle","wrapCallback","callback","wrappedCallback","event","addEventListenerWithType","once","_ref$once","_ref$throttle","Listener","mapAddEventListenerParams","onSessionCreated","onSessionExpired","onUserLoggedOut","onUserDeleted","onAuthFlowCompleted","Scheduler","_tasks","removeTask","task","_task","removeTasksWithType","scheduleTask","timeoutSeconds","Session","_cookie","_get","isValid","isAuthFlowCompleted","_detail$userID","Relay","_Dispatcher","_listener","_scheduler","_session","scheduleSessionExpiredEvent","cancelSessionExpiredEvent","handleStorageEvent","sessionDetail","listenEventDependencies","Hanko","_Listener","config","thirdParty","relay","opts","UserClient"],"mappings":"u0DAUeA,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,E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AAK,EAAAlR,EACLqf,gBAAU,EAAArf,EACVgM,WACAsT,EAAAA,EAAAA,WACArZ,EAAAA,EAAAA,aAKE,EAAA,IAAUsZ,EAAoB,CAC5B/R,QAAS,KACT5B,WAAY,QACZ9F,gBAAiB,SA8DqB,YA5DZgR,KAAjB,MAAPjR,OAAO,EAAPA,EAAS+F,cACX2T,EAAK3T,WAAa/F,EAAQ+F,iBAEHkL,WAArBjR,SAAAA,EAAS2H,WACX+R,EAAK/R,QAAU3H,EAAQ2H,cAEQsJ,KAAtB,MAAPjR,OAAO,EAAPA,EAASC,mBACXyZ,EAAKzZ,gBAAkBD,EAAQC,iBAGjC9F,EAAK8J,IAAMA,EAKX9J,EAAKof,OAAS,MAAiBtV,EAAKyV,GAKpCvf,EAAKmU,KAAO,IAAIqL,EAAW1V,EAAKyV,GAKhCvf,EAAKkX,SAAW,IAAIU,GAAe9N,EAAKyV,GAKxCvf,EAAKyQ,SAAW,IAAIG,EAAe9G,EAAKyV,GAKxCvf,EAAKqH,SAAW,IAAIwI,EAAe/F,EAAKyV,GAKxCvf,EAAKkR,MAAQ,IAAI2I,GAAY/P,EAAKyV,GAKlCvf,EAAKqf,WAAa,IAAIpF,GAAiBnQ,EAAKyV,GAK5Cvf,EAAKgM,MAAQ,IAAI+O,GAAYjR,EAAKyV,GAKlCvf,EAAKsf,MAAQ,IAAId,QAAWe,IAK5Bvf,EAAKiG,QAAU,IAAIiY,QAAaqB,IAAQvf,CAC1C,CAAC,cAAAkf,CAAA,EAlFiB/B"}
1
+ {"version":3,"file":"sdk.umd.js","sources":["../src/lib/Errors.ts","../src/lib/state/State.ts","../src/lib/state/session/SessionState.ts","../src/lib/state/users/UserState.ts","../src/lib/state/users/PasscodeState.ts","../src/lib/events/CustomEvents.ts","../src/lib/events/Dispatcher.ts","../../node_modules/js-cookie/dist/js.cookie.mjs","../src/lib/Cookie.ts","../src/lib/client/HttpClient.ts","../src/lib/client/Client.ts","../src/lib/client/ConfigClient.ts","../src/lib/client/PasscodeClient.ts","../src/lib/state/users/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/users/WebauthnState.ts","../src/lib/client/WebauthnClient.ts","../src/lib/client/EmailClient.ts","../src/lib/client/ThirdPartyClient.ts","../src/lib/client/TokenClient.ts","../src/lib/Throttle.ts","../src/lib/events/Listener.ts","../src/lib/events/Scheduler.ts","../src/lib/Session.ts","../src/lib/events/Relay.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 'ForbiddenError' occurs when the user is not allowed to perform the requested action.\n *\n * @category SDK\n * @subcategory Errors\n * @extends {HankoError}\n */\nclass ForbiddenError extends HankoError {\n // eslint-disable-next-line require-jsdoc\n constructor(cause?: Error) {\n super(\"Forbidden error\", \"forbidden\", cause);\n Object.setPrototypeOf(this, ForbiddenError.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 ForbiddenError,\n UserVerificationError,\n MaxNumOfEmailAddressesReachedError,\n EmailAddressAlreadyExistsError,\n ThirdPartyError,\n};\n","import { LocalStorageUsers } from \"./users/UserState\";\nimport { LocalStorageSession } from \"./session/SessionState\";\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {LocalStorageUsers=} users - The user states.\n */\ninterface LocalStorage {\n users?: LocalStorageUsers;\n session?: LocalStorageSession;\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 key: string;\n ls: LocalStorage;\n\n // eslint-disable-next-line require-jsdoc\n constructor(key: string) {\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","import { State } from \"../State\";\n\n/**\n * Options for SessionState\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\ninterface SessionStateOptions {\n localStorageKey: string;\n}\n\n/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {Object.<string, LocalStorageSession>} - A dictionary for mapping users to their states.\n */\nexport interface LocalStorageSession {\n expiry: number;\n userID: string;\n authFlowCompleted: boolean;\n}\n\n/**\n * A class to read and write local storage contents regarding sessions.\n *\n * @extends State\n * @param {SessionStateOptions} options - The options that can be used\n * @category SDK\n * @subcategory Internal\n */\nclass SessionState extends State {\n // eslint-disable-next-line require-jsdoc\n constructor(options: SessionStateOptions) {\n super(`${options.localStorageKey}_session`);\n }\n\n /**\n * Reads the current state.\n *\n * @public\n * @return {SessionState}\n */\n read(): SessionState {\n super.read();\n\n return this;\n }\n\n /**\n * Gets the session state.\n *\n * @return {LocalStorageSession}\n */\n getState(): LocalStorageSession {\n this.ls.session ||= { expiry: 0, userID: \"\", authFlowCompleted: false };\n return this.ls.session;\n }\n\n /**\n * Gets the number of seconds until the active session is valid.\n *\n * @return {number}\n */\n getExpirationSeconds(): number {\n return State.timeToRemainingSeconds(this.getState().expiry);\n }\n\n /**\n * Sets the number of seconds until the active session is valid.\n *\n * @param {number} seconds - The number of seconds\n * @return {SessionState}\n */\n setExpirationSeconds(seconds: number): SessionState {\n this.getState().expiry = State.remainingSecondsToTime(seconds);\n return this;\n }\n\n /**\n * Gets the user id.\n */\n getUserID(): string {\n return this.getState().userID;\n }\n\n /**\n * Sets the user id.\n *\n * @param {string} userID - The user id\n * @return {SessionState}\n */\n setUserID(userID: string): SessionState {\n this.getState().userID = userID;\n return this;\n }\n\n /**\n * Gets the authFlowCompleted indicator.\n */\n getAuthFlowCompleted(): boolean {\n return this.getState().authFlowCompleted;\n }\n\n /**\n * Sets the authFlowCompleted indicator.\n *\n * @param {string} completed - The authFlowCompleted indicator.\n * @return {SessionState}\n */\n setAuthFlowCompleted(completed: boolean): SessionState {\n this.getState().authFlowCompleted = completed;\n return this;\n }\n\n /**\n * Removes the session details.\n *\n * @return {SessionState}\n */\n reset(): SessionState {\n const session = this.getState();\n\n delete session.expiry;\n delete session.userID;\n\n return this;\n }\n}\n\nexport { SessionState };\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 {number} 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","/**\n * The type of the `hanko-session-created` event.\n * @typedef {string} sessionCreatedType\n * @memberOf Listener\n */\nexport const sessionCreatedType: \"hanko-session-created\" =\n \"hanko-session-created\";\n\n/**\n * The type of the `hanko-session-expired` event.\n * @typedef {string} sessionExpiredType\n * @memberOf Listener\n */\nexport const sessionExpiredType: \"hanko-session-expired\" =\n \"hanko-session-expired\";\n\n/**\n * The type of the `hanko-user-logged-out` event.\n * @typedef {string} userLoggedOutType\n * @memberOf Listener\n */\nexport const userLoggedOutType: \"hanko-user-logged-out\" =\n \"hanko-user-logged-out\";\n\n/**\n * The type of the `hanko-user-deleted` event.\n * @typedef {string} userDeletedType\n * @memberOf Listener\n */\nexport const userDeletedType: \"hanko-user-deleted\" = \"hanko-user-deleted\";\n\n/**\n * The type of the `hanko-auth-flow-completed` event.\n * @typedef {string} authFlowCompletedType\n * @memberOf Listener\n */\nexport const authFlowCompletedType: \"hanko-auth-flow-completed\" =\n \"hanko-auth-flow-completed\";\n\n/**\n * The data passed in the `hanko-session-created` or `hanko-session-resumed` event.\n *\n * @interface\n * @category SDK\n * @subcategory Events\n * @property {string=} jwt - The JSON web token associated with the session. Only present when the Hanko-API allows the JWT to be accessible client-side.\n * @property {number} expirationSeconds - The number of seconds until the JWT expires.\n * @property {string} userID - The user associated with the session.\n */\nexport interface SessionDetail {\n jwt?: string;\n expirationSeconds: number;\n userID: string;\n}\n\n/**\n * The data passed in the `hanko-auth-flow-completed` event.\n *\n * @interface\n * @category SDK\n * @subcategory Events\n * @property {string} userID - The user associated with the removed session.\n */\nexport interface AuthFlowCompletedDetail {\n userID: string;\n}\n\n/**\n * A custom event that includes a detail object.\n *\n * @category SDK\n * @subcategory Events\n * @extends CustomEvent\n * @ignore\n * @param {string} type - The type of the event.\n * @param {T} detail - The detail object to include in the event.\n */\nexport class CustomEventWithDetail<T> extends CustomEvent<T> {\n // eslint-disable-next-line require-jsdoc\n constructor(type: string, detail: T) {\n super(type, { detail });\n }\n}\n","import {\n SessionDetail,\n CustomEventWithDetail,\n AuthFlowCompletedDetail,\n sessionCreatedType,\n sessionExpiredType,\n userDeletedType,\n authFlowCompletedType,\n userLoggedOutType,\n} from \"./CustomEvents\";\nimport { SessionState } from \"../state/session/SessionState\";\n\n/**\n * Options for Dispatcher\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\ninterface DispatcherOptions {\n localStorageKey: string;\n}\n\n/**\n * A class that dispatches custom events.\n *\n * @category SDK\n * @subcategory Internal\n * @param {DispatcherOptions} options - The options that can be used\n */\nexport class Dispatcher {\n _dispatchEvent = document.dispatchEvent.bind(document);\n _sessionState: SessionState;\n\n // eslint-disable-next-line require-jsdoc\n constructor(options: DispatcherOptions) {\n this._sessionState = new SessionState({ ...options });\n }\n\n /**\n * Dispatches a custom event.\n *\n * @param {string} type\n * @param {T} detail\n * @private\n */\n private dispatch<T>(type: string, detail: T) {\n this._dispatchEvent(new CustomEventWithDetail(type, detail));\n }\n\n /**\n * Dispatches a \"hanko-session-created\" event to the document with the specified detail.\n *\n * @param {SessionDetail} detail - The event detail.\n */\n public dispatchSessionCreatedEvent(detail: SessionDetail) {\n this.dispatch(sessionCreatedType, detail);\n }\n\n /**\n * Dispatches a \"hanko-session-expired\" event to the document.\n */\n public dispatchSessionExpiredEvent() {\n this.dispatch(sessionExpiredType, null);\n }\n\n /**\n * Dispatches a \"hanko-user-logged-out\" event to the document.\n */\n public dispatchUserLoggedOutEvent() {\n this.dispatch(userLoggedOutType, null);\n }\n\n /**\n * Dispatches a \"hanko-user-deleted\" event to the document.\n */\n public dispatchUserDeletedEvent() {\n this.dispatch(userDeletedType, null);\n }\n\n /**\n * Dispatches a \"hanko-auth-flow-completed\" event to the document with the specified detail.\n *\n * @param {AuthFlowCompletedDetail} detail - The event detail.\n */\n public dispatchAuthFlowCompletedEvent(detail: AuthFlowCompletedDetail) {\n this._sessionState.read().setAuthFlowCompleted(true).write();\n this.dispatch(authFlowCompletedType, detail);\n }\n}\n","/*! js-cookie v3.0.5 | 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 (name, 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 name = encodeURIComponent(name)\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 name + '=' + converter.write(value, name) + stringifiedAttributes)\n }\n\n function get (name) {\n if (typeof document === 'undefined' || (arguments.length && !name)) {\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 found = decodeURIComponent(parts[0]);\n jar[found] = converter.read(value, found);\n\n if (name === found) {\n break\n }\n } catch (e) {}\n }\n\n return name ? jar[name] : jar\n }\n\n return Object.create(\n {\n set,\n get,\n remove: function (name, attributes) {\n set(\n name,\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 { api as default };\n","import JSCookie from \"js-cookie\";\n\n/**\n * Options for Cookie\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} cookieName - The name of the session cookie set from the SDK.\n */\ninterface CookieOptions {\n cookieName: string;\n}\n\n/**\n * A class to manage cookies.\n *\n * @category SDK\n * @subcategory Internal\n * @param {CookieOptions} options - The options that can be used\n */\nexport class Cookie {\n authCookieName: string;\n\n // eslint-disable-next-line require-jsdoc\n constructor(options: CookieOptions) {\n this.authCookieName = options.cookieName;\n }\n\n /**\n * Returns the authentication token that was stored in the cookie.\n *\n * @return {string}\n */\n getAuthCookie(): string {\n return JSCookie.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 * @param {boolean=} secure - Indicates a secure cookie should be set. Default is `true`.\n */\n setAuthCookie(token: string, secure = true) {\n JSCookie.set(this.authCookieName, token, { secure });\n }\n\n /**\n * Removes the cookie used for authentication.\n */\n removeAuthCookie() {\n JSCookie.remove(this.authCookieName);\n }\n}\n","import { RequestTimeoutError, TechnicalError } from \"../Errors\";\nimport { SessionState } from \"../state/session/SessionState\";\nimport { PasscodeState } from \"../state/users/PasscodeState\";\nimport { Dispatcher } from \"../events/Dispatcher\";\nimport { Cookie } from \"../Cookie\";\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 getResponseHeader(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 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 response header value with the given `name` as a number. When the value is not a number the return\n * value will be 0.\n *\n * @param {string} name - The name of the header field\n * @return {number}\n */\n parseNumericHeader(name: string): number {\n const result = parseInt(this.headers.getResponseHeader(name), 10);\n return isNaN(result) ? 0 : result;\n }\n}\n\n/**\n * Options for the HttpClient\n *\n * @category SDK\n * @subcategory Internal\n * @property {number} timeout - The http request timeout in milliseconds.\n * @property {string} cookieName - The name of the session cookie set from the SDK.\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\nexport interface HttpClientOptions {\n timeout: number;\n cookieName: string;\n localStorageKey: string;\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 {HttpClientOptions} options - The options the HttpClient must be provided\n */\nclass HttpClient {\n timeout: number;\n api: string;\n sessionState: SessionState;\n passcodeState: PasscodeState;\n dispatcher: Dispatcher;\n cookie: Cookie;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, options: HttpClientOptions) {\n this.api = api;\n this.timeout = options.timeout;\n this.sessionState = new SessionState({ ...options });\n this.passcodeState = new PasscodeState(options.cookieName);\n this.dispatcher = new Dispatcher({ ...options });\n this.cookie = new Cookie({ ...options });\n }\n\n // eslint-disable-next-line require-jsdoc\n _fetch(path: string, options: RequestInit, xhr = new XMLHttpRequest()) {\n const url = this.api + path;\n const timeout = this.timeout;\n const bearerToken = this.cookie.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 response = new Response(xhr);\n resolve(response);\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 * Processes the response headers on login and extracts the JWT and expiration time. Also, the passcode state will be\n * removed, the session state updated und a `hanko-session-created` event will be dispatched.\n *\n * @param {string} userID - The user ID.\n * @param {Response} response - The HTTP response object.\n */\n processResponseHeadersOnLogin(userID: string, response: Response) {\n let jwt = \"\";\n let expirationSeconds = 0;\n\n response.xhr\n .getAllResponseHeaders()\n .split(\"\\r\\n\")\n .forEach((h) => {\n const header = h.toLowerCase();\n if (header.startsWith(\"x-auth-token\")) {\n jwt = response.headers.getResponseHeader(\"X-Auth-Token\");\n } else if (header.startsWith(\"x-session-lifetime\")) {\n expirationSeconds = parseInt(\n response.headers.getResponseHeader(\"X-Session-Lifetime\"),\n 10\n );\n }\n });\n\n if (jwt) {\n const secure = !!this.api.match(\"^https://\");\n this.cookie.setAuthCookie(jwt, secure);\n }\n\n this.passcodeState.read().reset(userID).write();\n\n if (expirationSeconds > 0) {\n this.sessionState.read();\n this.sessionState.setExpirationSeconds(expirationSeconds);\n this.sessionState.setUserID(userID);\n this.sessionState.setAuthFlowCompleted(false);\n this.sessionState.write();\n this.dispatcher.dispatchSessionCreatedEvent({\n jwt,\n userID,\n expirationSeconds,\n });\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, HttpClientOptions } 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 {HttpClientOptions} options - The options that can be used\n */\nabstract class Client {\n client: HttpClient;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, options: HttpClientOptions) {\n /**\n * @public\n * @type {HttpClient}\n */\n this.client = new HttpClient(api, options);\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 { PasscodeState } from \"../state/users/PasscodeState\";\nimport { Passcode } from \"../Dto\";\nimport {\n InvalidPasscodeError,\n MaxNumOfPasscodeAttemptsReachedError,\n PasscodeExpiredError,\n TechnicalError,\n TooManyRequestsError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\nimport { HttpClientOptions } from \"./HttpClient\";\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, options: HttpClientOptions) {\n super(api, options);\n /**\n * @public\n * @type {PasscodeState}\n */\n this.state = new PasscodeState(options.cookieName);\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {TooManyRequestsError}\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.parseNumericHeader(\"Retry-After\");\n this.state.setResendAfter(userID, retryAfter).write();\n throw new TooManyRequestsError(retryAfter);\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.client.processResponseHeadersOnLogin(userID, response);\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/users/PasswordState\";\nimport { PasscodeState } from \"../state/users/PasscodeState\";\nimport {\n InvalidPasswordError,\n TechnicalError,\n TooManyRequestsError,\n UnauthorizedError,\n} from \"../Errors\";\nimport { Client } from \"./Client\";\nimport { HttpClientOptions } from \"./HttpClient\";\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, options: HttpClientOptions) {\n super(api, options);\n /**\n * @public\n * @type {PasswordState}\n */\n this.passwordState = new PasswordState(options.cookieName);\n /**\n * @public\n * @type {PasscodeState}\n */\n this.passcodeState = new PasscodeState(options.cookieName);\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 {InvalidPasswordError}\n * @throws {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {TooManyRequestsError}\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.parseNumericHeader(\"Retry-After\");\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.client.processResponseHeadersOnLogin(userID, response);\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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, UserCreated } from \"../Dto\";\nimport {\n ConflictError,\n NotFoundError,\n TechnicalError,\n UnauthorizedError,\n ForbiddenError,\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<UserCreated>}\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<UserCreated> {\n const response = await this.client.post(\"/users\", { email });\n\n if (response.status === 409) {\n throw new ConflictError();\n } if (response.status === 403) {\n throw new ForbiddenError();\n } else if (!response.ok) {\n throw new TechnicalError();\n }\n\n const createUser: UserCreated = response.json();\n if (createUser && createUser.user_id) {\n this.client.processResponseHeadersOnLogin(createUser.user_id, response);\n }\n return createUser;\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 (meResponse.status === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\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 (userResponse.status === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {UnauthorizedError}\n */\n async delete(): Promise<void> {\n const response = await this.client.delete(\"/user\");\n\n if (response.ok) {\n this.client.cookie.removeAuthCookie();\n this.client.sessionState.reset().write();\n this.client.dispatcher.dispatchUserDeletedEvent();\n return;\n } else if (response.status === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\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.cookie.removeAuthCookie();\n this.client.sessionState.reset().write();\n this.client.dispatcher.dispatchUserLoggedOutEvent();\n\n if (logoutResponse.status === 401) {\n // The user is logged out already\n return;\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/users/PasscodeState\";\nimport { WebauthnState } from \"../state/users/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\";\nimport { HttpClientOptions } from \"./HttpClient\";\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 _getCredential = getWebauthnCredential;\n _createCredential = createWebauthnCredential;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, options: HttpClientOptions) {\n super(api, options);\n /**\n * @public\n * @type {WebauthnState}\n */\n this.webauthnState = new WebauthnState(options.cookieName);\n /**\n * @public\n * @type {PasscodeState}\n */\n this.passcodeState = new PasscodeState(options.cookieName);\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 * @return {WebauthnFinalized}\n */\n async login(\n userID?: string,\n useConditionalMediation?: boolean\n ): Promise<WebauthnFinalized> {\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.client.processResponseHeadersOnLogin(\n finalizeResponse.user_id,\n assertionResponse\n );\n\n return finalizeResponse;\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 === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\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 (attestationResponse.status === 401) {\n this.client.dispatcher.dispatchSessionExpiredEvent();\n throw new UnauthorizedError();\n }\n if (attestationResponse.status === 422) {\n throw new UserVerificationError();\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {UnauthorizedError}\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {UnauthorizedError}\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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 {RequestTimeoutError}\n * @throws {TechnicalError}\n * @throws {UnauthorizedError}\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 this.client.dispatcher.dispatchSessionExpiredEvent();\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\";\nimport { HankoOptions } from \"../../Hanko\";\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 /**\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\";\nimport { TokenFinalized } from \"../Dto\";\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 /**\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 const tokenResponse: TokenFinalized = response.json();\n this.client.processResponseHeadersOnLogin(tokenResponse.user_id, response);\n }\n}\n","/**\n * @interface\n * @category SDK\n * @subcategory Internal\n * @property {boolean=} leading - Whether to allow the function to be called on the leading edge of the wait timeout.\n * @property {boolean=} trailing - Whether to allow the function to be called on the trailing edge of the wait timeout.\n */\ninterface ThrottleOptions {\n leading?: boolean;\n trailing?: boolean;\n}\n\n// eslint-disable-next-line no-unused-vars\ntype ThrottledFunction<T extends (...args: any[]) => any> = (\n // eslint-disable-next-line no-unused-vars\n ...args: Parameters<T>\n) => void;\n\n/**\n * Provides throttle functionality.\n *\n * @hideconstructor\n * @category SDK\n * @subcategory Internal\n */\nexport class Throttle {\n /**\n * Throttles a function, ensuring that it can only be called once per `wait` milliseconds.\n *\n * @static\n * @param {function} func - The function to throttle.\n * @param {number} wait - The number of milliseconds to wait between function invocations.\n * @param {ThrottleOptions} options - Optional configuration for the throttle.\n * @returns {function} A throttled version of the original function.\n */\n // eslint-disable-next-line no-unused-vars,require-jsdoc\n static throttle<T extends (...args: any[]) => any>(\n func: T,\n wait: number,\n options: ThrottleOptions = {}\n ): ThrottledFunction<T> {\n const { leading = true, trailing = true } = options;\n let context: any;\n let args: any;\n let timeoutID: number;\n let previous = 0;\n\n // This function is used to invoke the original function.\n const executeThrottledFunction = () => {\n // If 'leading' is false and this is not the first invocation of the throttled function, set 'previous' to 0 to\n // ensure that the function is not called immediately.\n previous = leading === false ? 0 : Date.now();\n timeoutID = null;\n // Invoke the original function.\n func.apply(context, args);\n };\n\n // This is the throttled function that will be returned.\n const throttled = function (...funcArgs: Parameters<T>) {\n const now = Date.now();\n\n // If this is the first time the throttled function is being called, and 'leading' is false,\n // set 'previous' to the current time to ensure that the function is not called immediately.\n if (!previous && leading === false) previous = now;\n\n // The remaining wait time.\n const remaining = wait - (now - previous);\n\n // Save the context and arguments of the function call.\n // eslint-disable-next-line no-invalid-this\n context = this;\n args = funcArgs;\n\n // Check whether it's time to call the function immediately based on the leading and trailing options. If leading\n // is enabled and there was no previous invocation, or if trailing is enabled and the wait time has already passed,\n // the function will be invoked immediately.\n if (remaining <= 0 || remaining > wait) {\n // If there is a pending timeout, clear it.\n if (timeoutID) {\n window.clearTimeout(timeoutID);\n timeoutID = null;\n }\n\n // Invoke the original function and update the previous timestamp.\n previous = now;\n func.apply(context, args);\n } else if (!timeoutID && trailing !== false) {\n // If there is no pending timeout and trailing is allowed, start a new timeout.\n timeoutID = window.setTimeout(executeThrottledFunction, remaining);\n }\n };\n\n return throttled;\n }\n}\n","import { Throttle } from \"../Throttle\";\nimport {\n CustomEventWithDetail,\n SessionDetail,\n AuthFlowCompletedDetail,\n sessionCreatedType,\n sessionExpiredType,\n userDeletedType,\n authFlowCompletedType,\n userLoggedOutType,\n} from \"./CustomEvents\";\n\n/**\n * A callback function to be executed when an event is triggered.\n *\n * @alias CallbackFunc\n * @typedef {function} CallbackFunc\n * @memberOf Listener\n */\n// eslint-disable-next-line no-unused-vars\ntype CallbackFunc<T> = (detail: T) => any;\n\n/**\n * A wrapped callback function that will execute the original callback.\n *\n * @ignore\n * @param {T} event - The event object passed in the event.\n */\n// eslint-disable-next-line no-unused-vars\ntype WrappedCallback<T> = (event: CustomEventWithDetail<T>) => void;\n\n/**\n * A function returned when adding an event listener. The function can be called to remove the corresponding event\n * listener.\n *\n * @alias CleanupFunc\n * @typedef {function} CleanupFunc\n * @memberOf Listener\n */\ntype CleanupFunc = () => void;\n\n/**\n * @interface\n * @ignore\n * @property {Function} callback - The function to be executed.\n * @property {boolean=} once - Whether the event listener should be removed after being called once.\n */\ninterface EventListenerParams<T> {\n callback: CallbackFunc<T>;\n once?: boolean;\n}\n\n/**\n * @interface\n * @ignore\n * @extends {EventListenerParams<T>}\n * @property {string} type - The type of the event.\n * @property {boolean=} throttle - Whether the event listener should be throttled.\n */\ninterface EventListenerWithTypeParams<T> extends EventListenerParams<T> {\n type: string;\n throttle?: boolean;\n}\n\n/**\n * A class to bind event listener for custom events.\n *\n * @category SDK\n * @subcategory Events\n */\nexport class Listener {\n public throttleLimit = 1000;\n _addEventListener = document.addEventListener.bind(document);\n _removeEventListener = document.removeEventListener.bind(document);\n _throttle = Throttle.throttle;\n\n /**\n * Wraps the given callback.\n *\n * @param callback\n * @param throttle\n * @private\n * @return {WrappedCallback}\n */\n private wrapCallback<T>(\n callback: CallbackFunc<T>,\n throttle: boolean\n ): WrappedCallback<T> {\n // The function that will be called when the event is triggered.\n const wrappedCallback = (event: CustomEventWithDetail<T>) => {\n callback(event.detail);\n };\n\n // Throttle the listener if multiple SDK instances could trigger the same event at the same time,\n // but the callback function should only be executed once.\n if (throttle) {\n return this._throttle(wrappedCallback, this.throttleLimit, {\n leading: true,\n trailing: false,\n });\n }\n\n return wrappedCallback;\n }\n\n /**\n * Adds an event listener with the specified type, callback function, and options.\n *\n * @private\n * @param {EventListenerWithTypeParams<T>} params - The parameters for the event listener.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n private addEventListenerWithType<T>({\n type,\n callback,\n once = false,\n throttle = false,\n }: EventListenerWithTypeParams<T>): CleanupFunc {\n const wrappedCallback = this.wrapCallback(callback, throttle);\n this._addEventListener(type, wrappedCallback, { once });\n return () => this._removeEventListener(type, wrappedCallback);\n }\n\n /**\n * Maps the parameters for an event listener to the `EventListenerWithTypeParams` interface.\n *\n * @static\n * @private\n * @param {string} type - The type of the event.\n * @param {EventListenerParams<T>} params - The parameters for the event listener.\n * @param {boolean} [throttle=false] - Whether the event listener should be throttled.\n * @returns {EventListenerWithTypeParams<T>}\n **/\n private static mapAddEventListenerParams<T>(\n type: string,\n { once, callback }: EventListenerParams<T>,\n throttle?: boolean\n ): EventListenerWithTypeParams<T> {\n return {\n type,\n callback,\n once,\n throttle,\n };\n }\n\n /**\n * Adds an event listener with the specified type, callback function, and options.\n *\n * @private\n * @param {string} type - The type of the event.\n * @param {EventListenerParams<T>} params - The parameters for the event listener.\n * @param {boolean=} throttle - Whether the event listener should be throttled.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n private addEventListener<T>(\n type: string,\n params: EventListenerParams<T>,\n throttle?: boolean\n ) {\n return this.addEventListenerWithType(\n Listener.mapAddEventListenerParams(type, params, throttle)\n );\n }\n\n /**\n * Adds an event listener for \"hanko-session-created\" events. Will be triggered across all browser windows, when the user\n * logs in, or when the page has been loaded or refreshed and there is a valid session.\n *\n * @param {CallbackFunc<SessionDetail>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onSessionCreated(\n callback: CallbackFunc<SessionDetail>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(sessionCreatedType, { callback, once }, true);\n }\n\n /**\n * Adds an event listener for \"hanko-session-expired\" events. The event will be triggered across all browser windows\n * as soon as the current JWT expires or the user logs out. It also triggers, when the user deletes the account in\n * another window.\n *\n * @param {CallbackFunc<null>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onSessionExpired(\n callback: CallbackFunc<null>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(sessionExpiredType, { callback, once }, true);\n }\n\n /**\n * Adds an event listener for hanko-user-deleted events. The event triggers, when the user has deleted the account in\n * the browser window where the deletion happened.\n *\n * @param {CallbackFunc<null>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onUserLoggedOut(\n callback: CallbackFunc<null>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(userLoggedOutType, { callback, once });\n }\n\n /**\n * Adds an event listener for hanko-user-deleted events. The event triggers, when the user has deleted the account.\n *\n * @param {CallbackFunc<null>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onUserDeleted(\n callback: CallbackFunc<null>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(userDeletedType, { callback, once });\n }\n\n /**\n * Adds an event listener for hanko-auth-flow-completed events. Will be triggered after the login or registration flow has been completed.\n *\n * @param {CallbackFunc<AuthFlowCompletedDetail>} callback - The function to be called when the event is triggered.\n * @param {boolean=} once - Whether the event listener should be removed after being called once.\n * @returns {CleanupFunc} This function can be called to remove the event listener.\n */\n public onAuthFlowCompleted(\n callback: CallbackFunc<AuthFlowCompletedDetail>,\n once?: boolean\n ): CleanupFunc {\n return this.addEventListener(authFlowCompletedType, { callback, once });\n }\n}\n","/**\n * Represents a task to be scheduled in the scheduler.\n *\n * @ignore\n * @param {number} timeoutID - the ID returned by `setTimeout()`\n * @param {string} type - The type, helps to organize the tasks.\n * @param {Function} func - The function to be called within the task.\n */\nexport type Task = {\n timeoutID: number;\n type: string;\n func: () => any;\n};\n\n/**\n * A class that manages scheduled tasks.\n *\n * @category SDK\n * @subcategory Internal\n */\nexport class Scheduler {\n // An array of scheduled tasks.\n _tasks: Task[] = [];\n\n /**\n * Removes a task from the scheduler.\n *\n * @private\n * @param {Task} task - The task to be removed.\n */\n private removeTask(task: Task) {\n window.clearTimeout(task.timeoutID);\n this._tasks = this._tasks.filter((_task) => _task !== task);\n }\n\n /**\n * Removes all tasks with a given type from the scheduler.\n *\n * @param {string} type - The type of tasks to be removed.\n */\n removeTasksWithType(type: string) {\n const tasks = this._tasks.filter((task) => task.type === type);\n tasks.forEach((task) => this.removeTask(task));\n }\n\n /**\n * Schedules a task to be executed after a given timeout.\n *\n * @param {string} type - The type of the task.\n * @param {Function} func - The function to be executed when the task is triggered.\n * @param {number} timeoutSeconds - The timeout after which the task should be executed, in seconds.\n */\n scheduleTask(type: string, func: () => any, timeoutSeconds: number) {\n const task: Task = {\n timeoutID: window.setTimeout(() => {\n func();\n this.removeTask(task);\n }, timeoutSeconds * 1000),\n type,\n func,\n };\n this._tasks.push(task);\n }\n}\n","import { SessionDetail } from \"./events/CustomEvents\";\nimport { SessionState } from \"./state/session/SessionState\";\nimport { Cookie } from \"./Cookie\";\n\n/**\n * Options for Session\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} cookieName - The name of the session cookie set from the SDK.\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\ninterface SessionOptions {\n cookieName: string;\n localStorageKey: string;\n}\n\n/**\n A class representing a session.\n\n @category SDK\n @subcategory Session\n @param {SessionOptions} options - The options that can be used\n */\nexport class Session {\n _sessionState: SessionState;\n _cookie: Cookie;\n\n // eslint-disable-next-line require-jsdoc\n constructor(options: SessionOptions) {\n this._sessionState = new SessionState({ ...options });\n this._cookie = new Cookie({ ...options });\n }\n\n /**\n Retrieves the session details.\n\n @returns {SessionDetail} The session details.\n */\n public get(): SessionDetail {\n const detail = this._get();\n return Session.validate(detail) ? detail : null;\n }\n\n /**\n Checks if the user is logged in.\n\n @returns {boolean} true if the user is logged in, false otherwise.\n */\n public isValid(): boolean {\n const session = this._get();\n return Session.validate(session);\n }\n\n /**\n Retrieves the session details.\n\n @ignore\n @returns {SessionDetail} The session details.\n */\n public _get(): SessionDetail {\n this._sessionState.read();\n\n const userID = this._sessionState.getUserID();\n const expirationSeconds = this._sessionState.getExpirationSeconds();\n const jwt = this._cookie.getAuthCookie();\n\n return {\n userID,\n expirationSeconds,\n jwt,\n };\n }\n\n /**\n Checks if the auth flow is completed. The value resets after the next login attempt.\n\n @returns {boolean} Returns true if the authentication flow is completed, false otherwise\n */\n public isAuthFlowCompleted() {\n this._sessionState.read();\n return this._sessionState.getAuthFlowCompleted();\n }\n\n /**\n Validates the session.\n\n @private\n @param {SessionDetail} detail - The session details to validate.\n @returns {boolean} true if the session details are valid, false otherwise.\n */\n private static validate(detail: SessionDetail): boolean {\n return !!(detail.expirationSeconds > 0 && detail.userID?.length);\n }\n}\n","import { SessionDetail, sessionExpiredType } from \"./CustomEvents\";\nimport { Listener } from \"./Listener\";\nimport { Scheduler } from \"./Scheduler\";\nimport { Dispatcher } from \"./Dispatcher\";\nimport { Session } from \"../Session\";\n\n/**\n * Options for Relay\n *\n * @category SDK\n * @subcategory Internal\n * @property {string} cookieName - The name of the session cookie set from the SDK.\n * @property {string} localStorageKey - The prefix / name of the local storage keys.\n */\ninterface RelayOptions {\n cookieName: string;\n localStorageKey: string;\n}\n\n/**\n * A class that dispatches events and scheduled events, based on other events.\n *\n * @category SDK\n * @subcategory Internal\n * @extends Dispatcher\n * @param {RelayOptions} options - The options that can be used\n */\nexport class Relay extends Dispatcher {\n _listener = new Listener();\n _scheduler = new Scheduler();\n _session: Session;\n\n // eslint-disable-next-line require-jsdoc\n constructor(options: RelayOptions) {\n super({ ...options });\n this._session = new Session({ ...options });\n this.listenEventDependencies();\n }\n\n /**\n * Removes the scheduled \"hanko-session-expired\" event and re-schedules a new event with updated expirationSeconds, to\n * ensure the \"hanko-session-expired\" event won't be triggered too early.\n *\n * @private\n * @param {SessionDetail} detail - The event detail.\n */\n private scheduleSessionExpiredEvent = (detail: SessionDetail) => {\n this._scheduler.removeTasksWithType(sessionExpiredType);\n this._scheduler.scheduleTask(\n sessionExpiredType,\n () => this.dispatchSessionExpiredEvent(),\n detail.expirationSeconds\n );\n };\n\n /**\n * Cancels scheduled \"hanko-session-expired\" events, to prevent it from being triggered again (e.g. when there are\n * multiple SDK instances).\n *\n * @private\n */\n private cancelSessionExpiredEvent = () => {\n this._scheduler.removeTasksWithType(sessionExpiredType);\n };\n\n /**\n * Handles the \"storage\" event in case the local storage entry, that contains the session detail has been changed by\n * another window. Depending on the new value of `expirationSeconds`, it either dispatches a \"hanko-session-created\"\n * or a \"hanko-session-expired\" event.\n *\n * @private\n * @param {StorageEvent} event - The storage event object.\n */\n private handleStorageEvent = (event: StorageEvent) => {\n if (event.key !== \"hanko_session\") return;\n\n const sessionDetail = this._session.get();\n\n if (!sessionDetail) {\n this.dispatchSessionExpiredEvent();\n return;\n }\n\n if (this._session.isAuthFlowCompleted()) {\n this.dispatchAuthFlowCompletedEvent({ userID: sessionDetail.userID });\n return;\n }\n\n this.dispatchSessionCreatedEvent(sessionDetail);\n };\n\n /**\n * Listens for events sent in the current browser.\n *\n * @private\n */\n private listenEventDependencies() {\n this._listener.onSessionCreated(this.scheduleSessionExpiredEvent);\n this._listener.onSessionExpired(this.cancelSessionExpiredEvent);\n this._listener.onUserDeleted(this.cancelSessionExpiredEvent);\n this._listener.onUserLoggedOut(this.cancelSessionExpiredEvent);\n\n // Handle cases, where the session has been changed by another window.\n window.addEventListener(\"storage\", this.handleStorageEvent);\n\n const sessionDetail = this._session.get();\n\n if (sessionDetail) {\n this.scheduleSessionExpiredEvent(sessionDetail);\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\";\nimport { Listener } from \"./lib/events/Listener\";\nimport { Relay } from \"./lib/events/Relay\";\nimport { Session } from \"./lib/Session\";\n\n/**\n * The options for the Hanko class\n *\n * @interface\n * @property {number=} timeout - The http request timeout in milliseconds. Defaults to 13000ms\n * @property {string=} cookieName - The name of the session cookie set from the SDK. Defaults to \"hanko\"\n * @property {string=} localStorageKey - The prefix / name of the local storage keys. Defaults to \"hanko\"\n */\nexport interface HankoOptions {\n timeout?: number;\n cookieName?: string;\n localStorageKey?: string;\n}\n\n/**\n * A class that bundles all available SDK functions.\n *\n * @extends {Listener}\n * @param {string} api - The URL of your Hanko API instance\n * @param {HankoOptions=} options - The options that can be used\n */\nclass Hanko extends Listener {\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 relay: Relay;\n session: Session;\n\n // eslint-disable-next-line require-jsdoc\n constructor(api: string, options?: HankoOptions) {\n super();\n const opts: InternalOptions = {\n timeout: 13000,\n cookieName: \"hanko\",\n localStorageKey: \"hanko\",\n };\n if (options?.cookieName !== undefined) {\n opts.cookieName = options.cookieName;\n }\n if (options?.timeout !== undefined) {\n opts.timeout = options.timeout;\n }\n if (options?.localStorageKey !== undefined) {\n opts.localStorageKey = options.localStorageKey;\n }\n\n this.api = api;\n /**\n * @public\n * @type {ConfigClient}\n */\n this.config = new ConfigClient(api, opts);\n /**\n * @public\n * @type {UserClient}\n */\n this.user = new UserClient(api, opts);\n /**\n * @public\n * @type {WebauthnClient}\n */\n this.webauthn = new WebauthnClient(api, opts);\n /**\n * @public\n * @type {PasswordClient}\n */\n this.password = new PasswordClient(api, opts);\n /**\n * @public\n * @type {PasscodeClient}\n */\n this.passcode = new PasscodeClient(api, opts);\n /**\n * @public\n * @type {EmailClient}\n */\n this.email = new EmailClient(api, opts);\n /**\n * @public\n * @type {ThirdPartyClient}\n */\n this.thirdParty = new ThirdPartyClient(api, opts);\n /**\n * @public\n * @type {TokenClient}\n */\n this.token = new TokenClient(api, opts);\n /**\n * @public\n * @type {Relay}\n */\n this.relay = new Relay({ ...opts });\n /**\n * @public\n * @type {Session}\n */\n this.session = new Session({ ...opts });\n }\n}\n\n// eslint-disable-next-line require-jsdoc\nexport interface InternalOptions {\n timeout: number;\n cookieName: string;\n localStorageKey: string;\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","_this4","_HankoError3","_HankoError4","WebauthnRequestCancelledError","_this5","InvalidPasswordError","_HankoError5","_this6","InvalidPasscodeError","_HankoError6","_this7","InvalidWebauthnCredentialError","_HankoError7","_this8","PasscodeExpiredError","_HankoError8","_this9","MaxNumOfPasscodeAttemptsReachedError","_HankoError9","_this10","NotFoundError","_this11","_HankoError10","_HankoError11","TooManyRequestsError","retryAfter","_this12","UnauthorizedError","_HankoError12","_this13","ForbiddenError","_HankoError13","_this14","UserVerificationError","_HankoError14","_this15","MaxNumOfEmailAddressesReachedError","_HankoError15","_this16","EmailAddressAlreadyExistsError","_HankoError16","_this17","ThirdPartyError","_this18","_HankoError17","State","key","ls","_proto","read","store","data","localStorage","getItem","decoded","decodeURIComponent","decodeURI","window","atob","JSON","parse","e","write","stringify","btoa","encodeURI","encodeURIComponent","setItem","encoded","timeToRemainingSeconds","time","Math","floor","Date","now","remainingSecondsToTime","seconds","SessionState","_State","options","localStorageKey","getState","_this$ls","session","expiry","authFlowCompleted","getExpirationSeconds","setExpirationSeconds","getUserID","setUserID","getAuthFlowCompleted","setAuthFlowCompleted","completed","reset","UserState","apply","arguments","getUserState","users","hasOwnProperty","PasscodeState","_UserState","_UserState$prototype$","passcode","getActiveID","id","setActiveID","passcodeID","getEmailID","emailID","setEmailID","ttl","resendAfter","getTTL","setTTL","getResendAfter","setResendAfter","sessionExpiredType","userLoggedOutType","userDeletedType","CustomEventWithDetail","type","detail","_wrapNativeSuper","CustomEvent","Dispatcher","_dispatchEvent","document","dispatchEvent","bind","_sessionState","dispatch","dispatchSessionCreatedEvent","sessionCreatedType","dispatchSessionExpiredEvent","dispatchUserLoggedOutEvent","dispatchUserDeletedEvent","dispatchAuthFlowCompletedEvent","authFlowCompletedType","assign","target","i","length","source","api","init","converter","defaultAttributes","set","name","value","attributes","expires","toUTCString","replace","escape","stringifiedAttributes","attributeName","split","cookie","create","get","cookies","jar","parts","slice","join","found","remove","withAttributes","withConverter","freeze","path","Cookie","authCookieName","cookieName","getAuthCookie","JSCookie","setAuthCookie","token","secure","removeAuthCookie","Headers","xhr","_xhr","Response","getResponseHeader","headers","ok","status","statusText","url","_decodedJSON","responseURL","_proto2","HttpClient","json","response","parseNumericHeader","result","parseInt","isNaN","timeout","sessionState","passcodeState","dispatcher","_extends","_fetch","Promise","resolve","reject","open","method","setRequestHeader","bearerToken","withCredentials","onload","onerror","ontimeout","send","body","toString","processResponseHeadersOnLogin","jwt","getAllResponseHeaders","forEach","h","toLowerCase","header","startsWith","expirationSeconds","match","_proto3","post","put","patch","Client","client","ConfigClient","PasscodeClient","_Client","state","initialize","force","lastPasscodeTTL","lastEmailID","lastPasscodeID","user_id","email_id","then","finalize","password","getRetryAfter","setRetryAfter","PasswordClient","passwordState","PasswordState","login","update","UserClient","getInfo","email","createUser","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","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","filter","find","c","WebauthnClient","webauthnState","controller","_getCredential","getWebauthnCredential","_createCredential","createWebauthnCredential","useConditionalMediation","challengeResponse","_exit","_temp2","_result","assertion","assertionResponse","finalizeResponse","credential_id","_createAbortSignal","_temp","_catch","_this2$_getCredential","register","_temp4","_result2","attestationResponse","_temp3","listCredentials","updateCredential","deleteCredential","shouldRegister","webauthn_credentials","matches","abort","AbortController","EmailClient","list","address","setPrimaryEmail","ThirdPartyClient","auth","provider","redirectTo","searchParams","append","location","href","getError","params","URLSearchParams","search","error","errorDescription","TokenClient","validate","history","replaceState","pathname","tokenResponse","Throttle","throttle","func","wait","context","args","timeoutID","_options$leading","leading","_options$trailing","trailing","previous","remaining","clearTimeout","setTimeout","executeThrottledFunction","throttleLimit","_addEventListener","addEventListener","_removeEventListener","removeEventListener","_throttle","wrapCallback","callback","wrappedCallback","event","addEventListenerWithType","once","_ref$once","_ref$throttle","Listener","mapAddEventListenerParams","onSessionCreated","onSessionExpired","onUserLoggedOut","onUserDeleted","onAuthFlowCompleted","Scheduler","_tasks","removeTask","task","_task","removeTasksWithType","scheduleTask","timeoutSeconds","Session","_cookie","_get","isValid","isAuthFlowCompleted","_detail$userID","Relay","_Dispatcher","_listener","_scheduler","_session","scheduleSessionExpiredEvent","cancelSessionExpiredEvent","handleStorageEvent","sessionDetail","listenEventDependencies","Hanko","_Listener","config","thirdParty","relay","opts"],"mappings":"u0DAUeA,IAAAA,eAKb,SAAAC,GAAA,SAAAD,EAAsBE,EAAiBC,EAAcC,GACnD,IAAAC,EAWkD,OAXlDA,EAAAJ,EAAAK,KAAAC,KAAML,UALRC,UACAC,EAAAA,EAAAA,WASE,EAAAC,EAAKF,KAAOA,EAKZE,EAAKD,MAAQA,EACbI,OAAOC,eAAqBT,EAAAA,GAAAA,EAAWU,WACzCL,CAAA,CAAC,OAbDM,EAAAX,EAAAC,KAAA,gBALgCW,QA6BbC,eAAA,SAAAC,GAEnB,SAAYV,EAAAA,GAAa,IAAAW,EAE+B,OADtDA,cAAM,kBAAmB,qBAAsBX,IAC/CI,KAAAA,OAAOC,eAAcO,EAAAD,GAAOF,EAAeH,WAAWK,CACxD,CAAC,OALkBJ,EAAAE,EAAAC,GAAQd,CAAAA,CAAR,CAAQA,GAevBiB,eAEJ,SAAAC,GAAA,SAAAD,EAAYE,EAAiBf,GAC3B,IAAAgB,EACqD,OADrDA,EAAAF,EAAAZ,KAAAC,KAAM,iBAAkB,WAAYH,IAAMG,KAC1CC,OAAOC,eAAcO,EAAA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