@strivacity/sdk-core 3.0.2 → 4.0.0-beta.0
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.
- package/CHANGELOG.md +11 -0
- package/README.md +1873 -340
- package/dist/assets/oidc.cjs +2 -0
- package/dist/assets/oidc.cjs.map +1 -0
- package/dist/assets/oidc.mjs +2 -0
- package/dist/assets/oidc.mjs.map +1 -0
- package/dist/assets/server.cjs +2 -0
- package/dist/assets/server.cjs.map +1 -0
- package/dist/assets/server.mjs +2 -0
- package/dist/assets/server.mjs.map +1 -0
- package/dist/flows/base.cjs +2 -0
- package/dist/flows/base.cjs.map +1 -0
- package/dist/flows/base.d.ts +26 -0
- package/dist/flows/base.mjs +2 -0
- package/dist/flows/base.mjs.map +1 -0
- package/dist/flows/embedded.cjs +2 -0
- package/dist/flows/embedded.cjs.map +1 -0
- package/dist/flows/embedded.d.ts +9 -0
- package/dist/flows/embedded.mjs +2 -0
- package/dist/flows/embedded.mjs.map +1 -0
- package/dist/flows/index.cjs +1 -0
- package/dist/flows/index.d.ts +5 -0
- package/dist/flows/index.mjs +1 -0
- package/dist/flows/native.cjs +2 -0
- package/dist/flows/native.cjs.map +1 -0
- package/dist/flows/native.d.ts +9 -0
- package/dist/flows/native.mjs +2 -0
- package/dist/flows/native.mjs.map +1 -0
- package/dist/flows/popup.cjs +2 -0
- package/dist/flows/popup.cjs.map +1 -0
- package/dist/flows/popup.d.ts +9 -0
- package/dist/flows/popup.mjs +2 -0
- package/dist/flows/popup.mjs.map +1 -0
- package/dist/flows/redirect.cjs +2 -0
- package/dist/flows/redirect.cjs.map +1 -0
- package/dist/flows/redirect.d.ts +9 -0
- package/dist/flows/redirect.mjs +2 -0
- package/dist/flows/redirect.mjs.map +1 -0
- package/dist/handlers/embedded.cjs +2 -0
- package/dist/handlers/embedded.cjs.map +1 -0
- package/dist/handlers/embedded.d.ts +37 -0
- package/dist/handlers/embedded.mjs +2 -0
- package/dist/handlers/embedded.mjs.map +1 -0
- package/dist/handlers/index.cjs +1 -0
- package/dist/handlers/index.d.ts +2 -0
- package/dist/handlers/index.mjs +1 -0
- package/dist/handlers/native.cjs +2 -0
- package/dist/handlers/native.cjs.map +1 -0
- package/dist/handlers/native.d.ts +56 -0
- package/dist/handlers/native.mjs +2 -0
- package/dist/handlers/native.mjs.map +1 -0
- package/dist/handlers/popup.cjs +2 -0
- package/dist/handlers/popup.cjs.map +1 -0
- package/dist/handlers/popup.d.ts +21 -0
- package/dist/handlers/popup.mjs +2 -0
- package/dist/handlers/popup.mjs.map +1 -0
- package/dist/handlers/redirect.cjs +2 -0
- package/dist/handlers/redirect.cjs.map +1 -0
- package/dist/handlers/redirect.d.ts +18 -0
- package/dist/handlers/redirect.mjs +2 -0
- package/dist/handlers/redirect.mjs.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -21
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/server/base.cjs +2 -0
- package/dist/server/base.cjs.map +1 -0
- package/dist/server/base.d.ts +15 -0
- package/dist/server/base.mjs +2 -0
- package/dist/server/base.mjs.map +1 -0
- package/dist/server/index.cjs +1 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.mjs +1 -0
- package/dist/storages/cache.cjs +2 -0
- package/dist/storages/cache.cjs.map +1 -0
- package/dist/storages/cache.d.ts +11 -0
- package/dist/storages/cache.mjs +2 -0
- package/dist/storages/cache.mjs.map +1 -0
- package/dist/storages/index.cjs +1 -0
- package/dist/storages/index.d.ts +7 -0
- package/dist/storages/index.mjs +1 -0
- package/dist/storages/indexeddb.cjs +2 -0
- package/dist/storages/indexeddb.cjs.map +1 -0
- package/dist/storages/indexeddb.d.ts +10 -0
- package/dist/storages/indexeddb.mjs +2 -0
- package/dist/storages/indexeddb.mjs.map +1 -0
- package/dist/storages/local.cjs +2 -0
- package/dist/storages/local.cjs.map +1 -0
- package/dist/storages/local.d.ts +7 -0
- package/dist/storages/local.mjs +2 -0
- package/dist/storages/local.mjs.map +1 -0
- package/dist/storages/memory.cjs +2 -0
- package/dist/storages/memory.cjs.map +1 -0
- package/dist/storages/memory.d.ts +8 -0
- package/dist/storages/memory.mjs +2 -0
- package/dist/storages/memory.mjs.map +1 -0
- package/dist/storages/server.cjs +1 -0
- package/dist/storages/server.d.ts +39 -0
- package/dist/storages/server.mjs +1 -0
- package/dist/storages/session.cjs +2 -0
- package/dist/storages/session.cjs.map +1 -0
- package/dist/storages/session.d.ts +7 -0
- package/dist/storages/session.mjs +2 -0
- package/dist/storages/session.mjs.map +1 -0
- package/dist/storages/worker.cjs +2 -0
- package/dist/storages/worker.cjs.map +1 -0
- package/dist/storages/worker.d.ts +46 -0
- package/dist/storages/worker.mjs +2 -0
- package/dist/storages/worker.mjs.map +1 -0
- package/dist/types/common.cjs +0 -0
- package/dist/types/common.d.ts +145 -0
- package/dist/types/common.mjs +0 -0
- package/dist/types/embedded.cjs +0 -0
- package/dist/types/embedded.d.ts +103 -0
- package/dist/types/embedded.mjs +0 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/native.cjs +0 -0
- package/dist/types/native.d.ts +385 -0
- package/dist/types/native.mjs +0 -0
- package/dist/types/oidc.cjs +2 -0
- package/dist/types/oidc.cjs.map +1 -0
- package/dist/types/oidc.d.ts +768 -0
- package/dist/types/oidc.mjs +2 -0
- package/dist/types/oidc.mjs.map +1 -0
- package/dist/types/popup.cjs +0 -0
- package/dist/types/popup.d.ts +69 -0
- package/dist/types/popup.mjs +0 -0
- package/dist/types/redirect.cjs +0 -0
- package/dist/types/redirect.d.ts +21 -0
- package/dist/types/redirect.mjs +0 -0
- package/dist/types/server.cjs +0 -0
- package/dist/types/server.d.ts +200 -0
- package/dist/types/server.mjs +0 -0
- package/dist/utils/base64url.cjs +2 -0
- package/dist/utils/base64url.cjs.map +1 -0
- package/dist/utils/base64url.d.ts +14 -0
- package/dist/utils/base64url.mjs +2 -0
- package/dist/utils/base64url.mjs.map +1 -0
- package/dist/utils/common.cjs +2 -0
- package/dist/utils/common.cjs.map +1 -0
- package/dist/utils/common.d.ts +23 -0
- package/dist/utils/common.mjs +2 -0
- package/dist/utils/common.mjs.map +1 -0
- package/dist/utils/credentials.cjs +2 -2
- package/dist/utils/credentials.cjs.map +1 -1
- package/dist/utils/credentials.d.ts +19 -3
- package/dist/utils/credentials.mjs +2 -2
- package/dist/utils/credentials.mjs.map +1 -1
- package/dist/utils/crypto.cjs +2 -2
- package/dist/utils/crypto.cjs.map +1 -1
- package/dist/utils/crypto.d.ts +16 -26
- package/dist/utils/crypto.mjs +2 -2
- package/dist/utils/crypto.mjs.map +1 -1
- package/dist/utils/dom.cjs +2 -0
- package/dist/utils/dom.cjs.map +1 -0
- package/dist/utils/dom.d.ts +7 -0
- package/dist/utils/dom.mjs +2 -0
- package/dist/utils/dom.mjs.map +1 -0
- package/dist/utils/errors.cjs +2 -2
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.d.ts +62 -1
- package/dist/utils/errors.mjs +2 -2
- package/dist/utils/errors.mjs.map +1 -1
- package/dist/utils/httpClient.cjs +2 -0
- package/dist/utils/httpClient.cjs.map +1 -0
- package/dist/utils/httpClient.d.ts +2 -0
- package/dist/utils/httpClient.mjs +2 -0
- package/dist/utils/httpClient.mjs.map +1 -0
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.mjs +1 -0
- package/dist/utils/logging.cjs +2 -0
- package/dist/utils/logging.cjs.map +1 -0
- package/dist/utils/logging.d.ts +2 -0
- package/dist/utils/logging.mjs +2 -0
- package/dist/utils/logging.mjs.map +1 -0
- package/dist/utils/oidc.cjs +1 -0
- package/dist/utils/oidc.d.ts +264 -0
- package/dist/utils/oidc.mjs +1 -0
- package/dist/utils/server.cjs +1 -0
- package/dist/utils/server.d.ts +72 -0
- package/dist/utils/server.mjs +1 -0
- package/dist/utils/session.cjs +2 -0
- package/dist/utils/session.cjs.map +1 -0
- package/dist/utils/session.d.ts +29 -0
- package/dist/utils/session.mjs +2 -0
- package/dist/utils/session.mjs.map +1 -0
- package/dist/utils/state.cjs +1 -0
- package/dist/utils/state.d.ts +23 -0
- package/dist/utils/state.mjs +1 -0
- package/package.json +53 -1
- package/testing/tests/flows/base.spec.ts +1030 -0
- package/testing/tests/flows/embedded.spec.ts +443 -0
- package/testing/tests/flows/index.spec.ts +8 -0
- package/testing/tests/flows/native.spec.ts +487 -0
- package/testing/tests/flows/popup.spec.ts +400 -0
- package/testing/tests/flows/redirect.spec.ts +369 -0
- package/testing/tests/handlers/embedded.spec.ts +199 -0
- package/testing/tests/handlers/index.spec.ts +8 -0
- package/testing/tests/handlers/native.spec.ts +283 -0
- package/testing/tests/handlers/popup.spec.ts +206 -0
- package/testing/tests/handlers/redirect.spec.ts +70 -0
- package/testing/tests/index.spec.ts +78 -0
- package/testing/tests/server/base.spec.ts +846 -0
- package/testing/tests/server/index.spec.ts +15 -0
- package/testing/tests/storages/cache.spec.ts +107 -0
- package/testing/tests/storages/index.spec.ts +22 -0
- package/testing/tests/storages/indexeddb.spec.ts +113 -0
- package/testing/tests/storages/local.spec.ts +46 -0
- package/testing/tests/storages/memory.spec.ts +51 -0
- package/testing/tests/storages/server.spec.ts +435 -0
- package/testing/tests/storages/session.spec.ts +46 -0
- package/testing/tests/storages/worker.spec.ts +106 -0
- package/testing/tests/utils/common.spec.ts +77 -0
- package/testing/tests/utils/credentials.spec.ts +195 -0
- package/testing/tests/utils/dom.spec.ts +37 -0
- package/testing/tests/utils/index.spec.ts +71 -0
- package/testing/tests/utils/logging.spec.ts +82 -0
- package/testing/tests/utils/oidc.spec.ts +744 -0
- package/testing/tests/utils/server.spec.ts +235 -0
- package/dist/flows/BaseFlow.cjs +0 -2
- package/dist/flows/BaseFlow.cjs.map +0 -1
- package/dist/flows/BaseFlow.d.ts +0 -191
- package/dist/flows/BaseFlow.mjs +0 -2
- package/dist/flows/BaseFlow.mjs.map +0 -1
- package/dist/flows/EmbeddedFlow.cjs +0 -2
- package/dist/flows/EmbeddedFlow.cjs.map +0 -1
- package/dist/flows/EmbeddedFlow.d.ts +0 -26
- package/dist/flows/EmbeddedFlow.mjs +0 -2
- package/dist/flows/EmbeddedFlow.mjs.map +0 -1
- package/dist/flows/NativeFlow.cjs +0 -2
- package/dist/flows/NativeFlow.cjs.map +0 -1
- package/dist/flows/NativeFlow.d.ts +0 -34
- package/dist/flows/NativeFlow.mjs +0 -2
- package/dist/flows/NativeFlow.mjs.map +0 -1
- package/dist/flows/PopupFlow.cjs +0 -2
- package/dist/flows/PopupFlow.cjs.map +0 -1
- package/dist/flows/PopupFlow.d.ts +0 -36
- package/dist/flows/PopupFlow.mjs +0 -2
- package/dist/flows/PopupFlow.mjs.map +0 -1
- package/dist/flows/RedirectFlow.cjs +0 -2
- package/dist/flows/RedirectFlow.cjs.map +0 -1
- package/dist/flows/RedirectFlow.d.ts +0 -38
- package/dist/flows/RedirectFlow.mjs +0 -2
- package/dist/flows/RedirectFlow.mjs.map +0 -1
- package/dist/handlers/BaseFlowHandler.cjs +0 -2
- package/dist/handlers/BaseFlowHandler.cjs.map +0 -1
- package/dist/handlers/BaseFlowHandler.d.ts +0 -61
- package/dist/handlers/BaseFlowHandler.mjs +0 -2
- package/dist/handlers/BaseFlowHandler.mjs.map +0 -1
- package/dist/handlers/EmbeddedFlowHandler.cjs +0 -2
- package/dist/handlers/EmbeddedFlowHandler.cjs.map +0 -1
- package/dist/handlers/EmbeddedFlowHandler.d.ts +0 -28
- package/dist/handlers/EmbeddedFlowHandler.mjs +0 -2
- package/dist/handlers/EmbeddedFlowHandler.mjs.map +0 -1
- package/dist/handlers/NativeFlowHandler.cjs +0 -2
- package/dist/handlers/NativeFlowHandler.cjs.map +0 -1
- package/dist/handlers/NativeFlowHandler.d.ts +0 -31
- package/dist/handlers/NativeFlowHandler.mjs +0 -2
- package/dist/handlers/NativeFlowHandler.mjs.map +0 -1
- package/dist/storages/LocalStorage.cjs +0 -2
- package/dist/storages/LocalStorage.cjs.map +0 -1
- package/dist/storages/LocalStorage.d.ts +0 -23
- package/dist/storages/LocalStorage.mjs +0 -2
- package/dist/storages/LocalStorage.mjs.map +0 -1
- package/dist/storages/SessionStorage.cjs +0 -2
- package/dist/storages/SessionStorage.cjs.map +0 -1
- package/dist/storages/SessionStorage.d.ts +0 -23
- package/dist/storages/SessionStorage.mjs +0 -2
- package/dist/storages/SessionStorage.mjs.map +0 -1
- package/dist/types.cjs +0 -2
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.ts +0 -1263
- package/dist/types.mjs +0 -2
- package/dist/types.mjs.map +0 -1
- package/dist/utils/HttpClient.cjs +0 -2
- package/dist/utils/HttpClient.cjs.map +0 -1
- package/dist/utils/HttpClient.d.ts +0 -4
- package/dist/utils/HttpClient.mjs +0 -2
- package/dist/utils/HttpClient.mjs.map +0 -1
- package/dist/utils/Logging.cjs +0 -2
- package/dist/utils/Logging.cjs.map +0 -1
- package/dist/utils/Logging.d.ts +0 -8
- package/dist/utils/Logging.mjs +0 -2
- package/dist/utils/Logging.mjs.map +0 -1
- package/dist/utils/Metadata.cjs +0 -2
- package/dist/utils/Metadata.cjs.map +0 -1
- package/dist/utils/Metadata.d.ts +0 -98
- package/dist/utils/Metadata.mjs +0 -2
- package/dist/utils/Metadata.mjs.map +0 -1
- package/dist/utils/Session.cjs +0 -2
- package/dist/utils/Session.cjs.map +0 -1
- package/dist/utils/Session.d.ts +0 -82
- package/dist/utils/Session.mjs +0 -2
- package/dist/utils/Session.mjs.map +0 -1
- package/dist/utils/State.cjs +0 -2
- package/dist/utils/State.cjs.map +0 -1
- package/dist/utils/State.d.ts +0 -43
- package/dist/utils/State.mjs +0 -2
- package/dist/utils/State.mjs.map +0 -1
- package/dist/utils/base64Url.cjs +0 -2
- package/dist/utils/base64Url.cjs.map +0 -1
- package/dist/utils/base64Url.d.ts +0 -27
- package/dist/utils/base64Url.mjs +0 -2
- package/dist/utils/base64Url.mjs.map +0 -1
- package/dist/utils/date.cjs +0 -2
- package/dist/utils/date.cjs.map +0 -1
- package/dist/utils/date.d.ts +0 -6
- package/dist/utils/date.mjs +0 -2
- package/dist/utils/date.mjs.map +0 -1
- package/dist/utils/handlers.cjs +0 -2
- package/dist/utils/handlers.cjs.map +0 -1
- package/dist/utils/handlers.d.ts +0 -35
- package/dist/utils/handlers.mjs +0 -2
- package/dist/utils/handlers.mjs.map +0 -1
- package/dist/utils/jwt.cjs +0 -2
- package/dist/utils/jwt.cjs.map +0 -1
- package/dist/utils/jwt.d.ts +0 -34
- package/dist/utils/jwt.mjs +0 -2
- package/dist/utils/jwt.mjs.map +0 -1
- package/dist/utils/object.cjs +0 -2
- package/dist/utils/object.cjs.map +0 -1
- package/dist/utils/object.d.ts +0 -1
- package/dist/utils/object.mjs +0 -2
- package/dist/utils/object.mjs.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{BaseFlowHandler as g}from"./BaseFlowHandler.mjs";import{State as h}from"../utils/State.mjs";import{FallbackError as n}from"../utils/errors.mjs";import"../utils/crypto.mjs";import"../utils/base64Url.mjs";import"../utils/date.mjs";class m extends g{async startSession(i,a){if(this.sdk.logging&&(this.sdk.logging.xEventId=void 0,this.sdk.logging.info("Starting login flow session")),a&&(this.language=a),i)return this.sessionId=i,this.submitForm();const t=await h.create(),s=await this.sdk.getAuthorizationUrl(this.params);s.searchParams.append("sdk",this.params.sdk||"web"),s.searchParams.append("state",t.id),s.searchParams.append("code_challenge",t.codeChallenge),s.searchParams.append("nonce",t.nonce),await this.sdk.storage.set(`sty.${t.id}`,JSON.stringify(t));const o=await this.sdk.httpClient.request(s.toString(),{method:"GET",credentials:"include",headers:{"Accept-language":this.language}});if(!o.ok){const r=new Error(`Authorization request failed with status ${o.status}`);throw this.sdk.logging?.error("Authorization request error",r),r}let e;try{e=new URL(await o.text())}catch{e=new URL(o.url)}if(e.searchParams.has("code")){if(typeof this.sdk.options.callbackHandler!="function"){const r=new Error("Missing option: callbackHandler");throw this.sdk.logging?.error("Required option missing",r),r}if(!e.toString().startsWith(this.sdk.options.redirectUri)){const r=new Error("Invalid redirect URI");throw this.sdk.logging?.error("Invalid redirect URI",r),r}return await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(e.toString(),this.sdk.options.responseMode||"fragment"))}if(e.searchParams.has("error")){const r=new Error(`${e.searchParams.get("error")}: ${e.searchParams.get("error_description")}`);throw this.sdk.logging?.error("Authorization error",r),r}if(!e.searchParams.has("session_id")){const r=new Error('"session_id" is missing from the response');throw this.sdk.logging?.error("Failed to start a session",r),r}return e.searchParams.has("language")&&(this.language=e.searchParams.get("language")),this.sessionId=e.searchParams.get("session_id"),this.submitForm()}async finalizeSession(i){this.sdk.logging?.debug("Finalizing login flow session");const a=await this.sdk.httpClient.request(i.toString(),{method:"GET",headers:{Authorization:`Bearer ${this.sessionId}`,"Accept-language":this.language},credentials:"include"}),t=new URL(await a.text());if(typeof this.sdk.options.callbackHandler!="function"){const s=new Error("Missing option: callbackHandler");throw this.sdk.logging?.error("Required option missing",s),s}if(!t.toString().startsWith(this.sdk.options.redirectUri)){const s=new Error("Invalid redirect URI");throw this.sdk.logging?.error("Finalize session error",s),s}await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(t.toString(),this.sdk.options.responseMode||"fragment"))}async submitForm(i,a={}){i&&this.sdk.logging?.debug(`Submitting form: ${i}`);const t=await this.sdk.httpClient.request(new URL(`/flow/api/v1/${i?`form/${i}`:"init"}`,this.sdk.options.issuer).toString(),{method:"POST",headers:{Authorization:`Bearer ${this.sessionId}`,"Content-Type":"application/json","Accept-language":this.language},body:JSON.stringify(a),credentials:"include"}),s=await t.json();if(!t.ok&&t.status>=400&&t.status<500){if(t.status!==403&&s?.hostedUrl&&!s.messages)throw this.sdk.logging?.warn(`Triggering fallback due to: Received HTTP ${t.status} without messages`),new n(new URL(s.hostedUrl));if(t.status!==400){const o=new Error(`HTTP ${t.status}: ${t.statusText}`);throw this.sdk.logging?.error("Form submission error",o),o}}if(s.finalizeUrl)await this.finalizeSession(s.finalizeUrl);else{if(s.hostedUrl&&!s.forms&&!s.messages)throw this.sdk.logging?.warn("Triggering fallback due to: No forms or messages in response"),new n(new URL(s.hostedUrl));s.screen&&this.sdk.logging?.info(`Rendering screen: ${s.screen}`)}return s}}export{m as NativeFlowHandler};
|
|
2
|
-
//# sourceMappingURL=NativeFlowHandler.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NativeFlowHandler.mjs","sources":["../../src/handlers/NativeFlowHandler.ts"],"sourcesContent":["import type { LoginFlowState } from '../types';\nimport { BaseFlowHandler } from './BaseFlowHandler';\nimport { State } from '../utils/State';\nimport { FallbackError } from '../utils/errors';\n\nexport class NativeFlowHandler extends BaseFlowHandler {\n\t/**\n\t * Starts a new session.\n\t *\n\t * @param {string} [sessionId] - The session ID to start the session with. If not provided, a new session will be created.\n\t * @param {string} [language] - The language to use for the authentication flow. If not provided, the browser's language setting will be used.\n\t * @returns {Promise<LoginFlowState | void>}\n\t *\n\t * @throws {Error} Throws an error if callback handler is not defined, redirect URI is invalid, authorization error occurs, or session ID is missing.\n\t */\n\tasync startSession(sessionId?: string | null, language?: string | null): Promise<LoginFlowState | void> {\n\t\tif (this.sdk.logging) {\n\t\t\tthis.sdk.logging.xEventId = undefined;\n\t\t\tthis.sdk.logging.info('Starting login flow session');\n\t\t}\n\n\t\tif (language) {\n\t\t\tthis.language = language;\n\t\t}\n\n\t\tif (sessionId) {\n\t\t\tthis.sessionId = sessionId;\n\t\t\treturn this.submitForm();\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst authorizationUrl = await this.sdk.getAuthorizationUrl(this.params);\n\n\t\tauthorizationUrl.searchParams.append('sdk', this.params.sdk || 'web');\n\t\tauthorizationUrl.searchParams.append('state', state.id);\n\t\tauthorizationUrl.searchParams.append('code_challenge', state.codeChallenge);\n\t\tauthorizationUrl.searchParams.append('nonce', state.nonce);\n\n\t\tawait this.sdk.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tconst response = await this.sdk.httpClient.request(authorizationUrl.toString(), {\n\t\t\tmethod: 'GET',\n\t\t\tcredentials: 'include',\n\t\t\theaders: { 'Accept-language': this.language },\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst error = new Error(`Authorization request failed with status ${response.status}`);\n\t\t\tthis.sdk.logging?.error('Authorization request error', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tlet uri: URL;\n\n\t\ttry {\n\t\t\turi = new URL(await response.text());\n\t\t} catch {\n\t\t\turi = new URL(response.url);\n\t\t}\n\n\t\tif (uri.searchParams.has('code')) {\n\t\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\t\tconst error = new Error('Missing option: callbackHandler');\n\t\t\t\tthis.sdk.logging?.error('Required option missing', error);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (!uri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\t\tconst error = new Error('Invalid redirect URI');\n\t\t\t\tthis.sdk.logging?.error('Invalid redirect URI', error);\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn await this.sdk.tokenExchange(\n\t\t\t\t(await this.sdk.options.callbackHandler(uri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t\t);\n\t\t}\n\n\t\tif (uri.searchParams.has('error')) {\n\t\t\tconst error = new Error(`${uri.searchParams.get('error')}: ${uri.searchParams.get('error_description')}`);\n\t\t\tthis.sdk.logging?.error('Authorization error', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!uri.searchParams.has('session_id')) {\n\t\t\tconst error = new Error('\"session_id\" is missing from the response');\n\t\t\tthis.sdk.logging?.error('Failed to start a session', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (uri.searchParams.has('language')) {\n\t\t\tthis.language = uri.searchParams.get('language')!;\n\t\t}\n\n\t\tthis.sessionId = uri.searchParams.get('session_id');\n\n\t\treturn this.submitForm();\n\t}\n\n\t/**\n\t * Finalizes the session using the provided [finalizeUrl].\n\t *\n\t * @param {string} finalizeUrl The URL to finalize the session.\n\t *\n\t * @throws {Error} Throws an error if callback handler is not defined or redirect URI is invalid.\n\t */\n\tasync finalizeSession(finalizeUrl: URL | string): Promise<void> {\n\t\tthis.sdk.logging?.debug('Finalizing login flow session');\n\n\t\tconst response = await this.sdk.httpClient.request(finalizeUrl.toString(), {\n\t\t\tmethod: 'GET',\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${this.sessionId}`,\n\t\t\t\t'Accept-language': this.language,\n\t\t\t},\n\t\t\tcredentials: 'include',\n\t\t});\n\t\tconst redirectUri = new URL(await response.text());\n\n\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\tconst error = new Error('Missing option: callbackHandler');\n\t\t\tthis.sdk.logging?.error('Required option missing', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!redirectUri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\tconst error = new Error('Invalid redirect URI');\n\t\t\tthis.sdk.logging?.error('Finalize session error', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\tawait this.sdk.tokenExchange(\n\t\t\t(await this.sdk.options.callbackHandler(redirectUri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t);\n\t}\n\n\t/**\n\t * Submits a form with the provided [formId] and [data].\n\t *\n\t * @returns {Promise<LoginFlowState>}\n\t *\n\t * @throws {Error} Throws an error if form submission fails.\n\t * @throws {FallbackError} Throws a fallback error if response indicates fallback is needed.\n\t */\n\tasync submitForm(formId?: string, body: Record<string, unknown> = {}): Promise<LoginFlowState> {\n\t\tif (formId) {\n\t\t\tthis.sdk.logging?.debug(`Submitting form: ${formId}`);\n\t\t}\n\n\t\tconst response = await this.sdk.httpClient.request<LoginFlowState>(\n\t\t\tnew URL(`/flow/api/v1/${formId ? `form/${formId}` : 'init'}`, this.sdk.options.issuer).toString(),\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\tAuthorization: `Bearer ${this.sessionId}`,\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t'Accept-language': this.language,\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\tcredentials: 'include',\n\t\t\t},\n\t\t);\n\t\tconst data = await response.json();\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status >= 400 && response.status < 500) {\n\t\t\t\tif (response.status !== 403 && data?.hostedUrl && !data.messages) {\n\t\t\t\t\tthis.sdk.logging?.warn(`Triggering fallback due to: Received HTTP ${response.status} without messages`);\n\t\t\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t\t\t}\n\n\t\t\t\tif (response.status !== 400) {\n\t\t\t\t\tconst error = new Error(`HTTP ${response.status}: ${response.statusText}`);\n\t\t\t\t\tthis.sdk.logging?.error(`Form submission error`, error);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (data.finalizeUrl) {\n\t\t\tawait this.finalizeSession(data.finalizeUrl);\n\t\t} else if (data.hostedUrl && !data.forms && !data.messages) {\n\t\t\tthis.sdk.logging?.warn(`Triggering fallback due to: No forms or messages in response`);\n\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t} else if (data.screen) {\n\t\t\tthis.sdk.logging?.info(`Rendering screen: ${data.screen}`);\n\t\t}\n\n\t\treturn data;\n\t}\n}\n"],"names":["NativeFlowHandler","BaseFlowHandler","sessionId","language","state","State","authorizationUrl","response","error","uri","finalizeUrl","redirectUri","formId","body","data","FallbackError"],"mappings":"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"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class a{async get(e){return await Promise.resolve(globalThis?.window?.localStorage?.getItem(e))}async delete(e){await Promise.resolve(globalThis?.window?.localStorage.removeItem(e))}async set(e,o){await Promise.resolve(globalThis?.window?.localStorage.setItem(e,o))}}exports.LocalStorage=a;
|
|
2
|
-
//# sourceMappingURL=LocalStorage.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalStorage.cjs","sources":["../../src/storages/LocalStorage.ts"],"sourcesContent":["import type { SDKStorage } from '../types';\n\n/**\n * Implements local storage operations using the browser's `localStorage`.\n */\nexport class LocalStorage implements SDKStorage {\n\t/**\n\t * Retrieves a value from local storage by key.\n\t * @param {string} key The key to retrieve the value for.\n\t * @returns {string | null} The value associated with the key, or null if not found.\n\t */\n\tasync get(key: string): Promise<string | null> {\n\t\treturn await Promise.resolve(globalThis?.window?.localStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from local storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in local storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.setItem(key, value));\n\t}\n}\n"],"names":["LocalStorage","key","value"],"mappings":"gFAKO,MAAMA,CAAmC,CAM/C,MAAM,IAAIC,EAAqC,CAC9C,OAAO,MAAM,QAAQ,QAAQ,YAAY,QAAQ,cAAc,QAAQA,CAAG,CAAC,CAC5E,CAMA,MAAM,OAAOA,EAA4B,CACxC,MAAM,QAAQ,QAAQ,YAAY,QAAQ,aAAa,WAAWA,CAAG,CAAC,CACvE,CAOA,MAAM,IAAIA,EAAaC,EAA8B,CACpD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,aAAa,QAAQD,EAAKC,CAAK,CAAC,CAC3E,CACD"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SDKStorage } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Implements local storage operations using the browser's `localStorage`.
|
|
4
|
-
*/
|
|
5
|
-
export declare class LocalStorage implements SDKStorage {
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves a value from local storage by key.
|
|
8
|
-
* @param {string} key The key to retrieve the value for.
|
|
9
|
-
* @returns {string | null} The value associated with the key, or null if not found.
|
|
10
|
-
*/
|
|
11
|
-
get(key: string): Promise<string | null>;
|
|
12
|
-
/**
|
|
13
|
-
* Deletes a key-value pair from local storage.
|
|
14
|
-
* @param {string} key The key to delete.
|
|
15
|
-
*/
|
|
16
|
-
delete(key: string): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Sets a key-value pair in local storage.
|
|
19
|
-
* @param {string} key The key to set.
|
|
20
|
-
* @param {string} value The value to associate with the key.
|
|
21
|
-
*/
|
|
22
|
-
set(key: string, value: string): Promise<void>;
|
|
23
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
class l{async get(e){return await Promise.resolve(globalThis?.window?.localStorage?.getItem(e))}async delete(e){await Promise.resolve(globalThis?.window?.localStorage.removeItem(e))}async set(e,o){await Promise.resolve(globalThis?.window?.localStorage.setItem(e,o))}}export{l as LocalStorage};
|
|
2
|
-
//# sourceMappingURL=LocalStorage.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalStorage.mjs","sources":["../../src/storages/LocalStorage.ts"],"sourcesContent":["import type { SDKStorage } from '../types';\n\n/**\n * Implements local storage operations using the browser's `localStorage`.\n */\nexport class LocalStorage implements SDKStorage {\n\t/**\n\t * Retrieves a value from local storage by key.\n\t * @param {string} key The key to retrieve the value for.\n\t * @returns {string | null} The value associated with the key, or null if not found.\n\t */\n\tasync get(key: string): Promise<string | null> {\n\t\treturn await Promise.resolve(globalThis?.window?.localStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from local storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in local storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.setItem(key, value));\n\t}\n}\n"],"names":["LocalStorage","key","value"],"mappings":"AAKO,MAAMA,CAAmC,CAM/C,MAAM,IAAIC,EAAqC,CAC9C,OAAO,MAAM,QAAQ,QAAQ,YAAY,QAAQ,cAAc,QAAQA,CAAG,CAAC,CAC5E,CAMA,MAAM,OAAOA,EAA4B,CACxC,MAAM,QAAQ,QAAQ,YAAY,QAAQ,aAAa,WAAWA,CAAG,CAAC,CACvE,CAOA,MAAM,IAAIA,EAAaC,EAA8B,CACpD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,aAAa,QAAQD,EAAKC,CAAK,CAAC,CAC3E,CACD"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o{async get(e){return Promise.resolve(globalThis?.window?.sessionStorage?.getItem(e))}async delete(e){await Promise.resolve(globalThis?.window?.sessionStorage.removeItem(e))}async set(e,s){await Promise.resolve(globalThis?.window?.sessionStorage.setItem(e,s))}}exports.SessionStorage=o;
|
|
2
|
-
//# sourceMappingURL=SessionStorage.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SessionStorage.cjs","sources":["../../src/storages/SessionStorage.ts"],"sourcesContent":["import type { SDKStorage } from '../types';\n\n/**\n * Implements session storage operations using the browser's `sessionStorage`.\n */\nexport class SessionStorage implements SDKStorage {\n\t/**\n\t * Retrieves a value from session storage by key.\n\t * @param {string} key The key to retrieve the value for.\n\t * @returns {string | null} The value associated with the key, or null if not found.\n\t */\n\tasync get(key: string): Promise<string | null> {\n\t\treturn Promise.resolve(globalThis?.window?.sessionStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from session storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in session storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.setItem(key, value));\n\t}\n}\n"],"names":["SessionStorage","key","value"],"mappings":"gFAKO,MAAMA,CAAqC,CAMjD,MAAM,IAAIC,EAAqC,CAC9C,OAAO,QAAQ,QAAQ,YAAY,QAAQ,gBAAgB,QAAQA,CAAG,CAAC,CACxE,CAMA,MAAM,OAAOA,EAA4B,CACxC,MAAM,QAAQ,QAAQ,YAAY,QAAQ,eAAe,WAAWA,CAAG,CAAC,CACzE,CAOA,MAAM,IAAIA,EAAaC,EAA8B,CACpD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,eAAe,QAAQD,EAAKC,CAAK,CAAC,CAC7E,CACD"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SDKStorage } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Implements session storage operations using the browser's `sessionStorage`.
|
|
4
|
-
*/
|
|
5
|
-
export declare class SessionStorage implements SDKStorage {
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves a value from session storage by key.
|
|
8
|
-
* @param {string} key The key to retrieve the value for.
|
|
9
|
-
* @returns {string | null} The value associated with the key, or null if not found.
|
|
10
|
-
*/
|
|
11
|
-
get(key: string): Promise<string | null>;
|
|
12
|
-
/**
|
|
13
|
-
* Deletes a key-value pair from session storage.
|
|
14
|
-
* @param {string} key The key to delete.
|
|
15
|
-
*/
|
|
16
|
-
delete(key: string): Promise<void>;
|
|
17
|
-
/**
|
|
18
|
-
* Sets a key-value pair in session storage.
|
|
19
|
-
* @param {string} key The key to set.
|
|
20
|
-
* @param {string} value The value to associate with the key.
|
|
21
|
-
*/
|
|
22
|
-
set(key: string, value: string): Promise<void>;
|
|
23
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
class t{async get(e){return Promise.resolve(globalThis?.window?.sessionStorage?.getItem(e))}async delete(e){await Promise.resolve(globalThis?.window?.sessionStorage.removeItem(e))}async set(e,s){await Promise.resolve(globalThis?.window?.sessionStorage.setItem(e,s))}}export{t as SessionStorage};
|
|
2
|
-
//# sourceMappingURL=SessionStorage.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SessionStorage.mjs","sources":["../../src/storages/SessionStorage.ts"],"sourcesContent":["import type { SDKStorage } from '../types';\n\n/**\n * Implements session storage operations using the browser's `sessionStorage`.\n */\nexport class SessionStorage implements SDKStorage {\n\t/**\n\t * Retrieves a value from session storage by key.\n\t * @param {string} key The key to retrieve the value for.\n\t * @returns {string | null} The value associated with the key, or null if not found.\n\t */\n\tasync get(key: string): Promise<string | null> {\n\t\treturn Promise.resolve(globalThis?.window?.sessionStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from session storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in session storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.setItem(key, value));\n\t}\n}\n"],"names":["SessionStorage","key","value"],"mappings":"AAKO,MAAMA,CAAqC,CAMjD,MAAM,IAAIC,EAAqC,CAC9C,OAAO,QAAQ,QAAQ,YAAY,QAAQ,gBAAgB,QAAQA,CAAG,CAAC,CACxE,CAMA,MAAM,OAAOA,EAA4B,CACxC,MAAM,QAAQ,QAAQ,YAAY,QAAQ,eAAe,WAAWA,CAAG,CAAC,CACzE,CAOA,MAAM,IAAIA,EAAaC,EAA8B,CACpD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,eAAe,QAAQD,EAAKC,CAAK,CAAC,CAC7E,CACD"}
|
package/dist/types.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=["code","id_token"],o=["query","fragment"],s=["none"],n=["authorization_code","refresh_token"],i=["RS256"],p=["public"],c=["none","login","create"],r=["redirect","popup"];class L{}class a{xEventId}class g{logging}exports.AlgorithmTypeList=i;exports.FallbackModeTypeList=r;exports.GrantTypeList=n;exports.PromptTypeList=c;exports.ResponseModeList=o;exports.ResponseTypeList=e;exports.SDKHttpClient=g;exports.SDKLogging=a;exports.SDKStorage=L;exports.SubjectTypeList=p;exports.TokenEndpointAuthMethodList=s;
|
|
2
|
-
//# sourceMappingURL=types.cjs.map
|
package/dist/types.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sources":["../src/types.ts"],"sourcesContent":["import type { BaseFlow } from './flows/BaseFlow';\n\n/**\n * Makes properties of `T` required based on the keys provided in `K`.\n *\n * @template T - The type from which properties will be made required.\n * @template K - The keys of `T` that should be required.\n * @example\n * type MyType = { a?: string; b?: number; c?: boolean };\n * type RequiredAB = Mandatory<MyType, 'a' | 'b'>; // { a: string; b: number; c?: boolean }\n */\nexport type Mandatory<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;\n\n/**\n * A type representing a partial record of key-value pairs where keys are of type `K` and values are of type `T`.\n *\n * @template K - The type of the keys in the record.\n * @template T - The type of the values in the record.\n * @example\n * type StringMap = PartialRecord<string, string>; // { [key: string]: string | undefined }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PartialRecord<K extends keyof any, T> = {\n\t[P in K]?: T;\n};\n\n// region SDK\n\n/**\n * List of supported response types.\n */\nexport const ResponseTypeList = ['code', 'id_token'] as const;\n/**\n * Type representing valid response types.\n */\nexport type ResponseType = (typeof ResponseTypeList)[number];\n\n/**\n * List of supported response modes.\n */\nexport const ResponseModeList = ['query', 'fragment'] as const;\n/**\n * Type representing valid response modes.\n */\nexport type ResponseMode = (typeof ResponseModeList)[number];\n\n/**\n * List of supported token endpoint authentication methods.\n */\nexport const TokenEndpointAuthMethodList = ['none'] as const;\n/**\n * Type representing valid token endpoint authentication methods.\n */\nexport type TokenEndpointAuthMethod = (typeof TokenEndpointAuthMethodList)[number];\n\n/**\n * List of supported grant types.\n */\nexport const GrantTypeList = ['authorization_code', 'refresh_token'] as const;\n/**\n * Type representing valid grant types.\n */\nexport type GrantType = (typeof GrantTypeList)[number];\n\n/**\n * List of supported algorithm types.\n */\nexport const AlgorithmTypeList = ['RS256'] as const;\n/**\n * Type representing valid algorithm types.\n */\nexport type AlgorithmType = (typeof AlgorithmTypeList)[number];\n\n/**\n * List of supported subject types.\n */\nexport const SubjectTypeList = ['public'] as const;\n/**\n * Type representing valid subject types.\n */\nexport type SubjectType = (typeof SubjectTypeList)[number];\n\n/**\n * List of supported prompt types.\n */\nexport const PromptTypeList = ['none', 'login', 'create'] as const;\n/**\n * Type representing valid prompt types.\n */\nexport type PromptType = (typeof PromptTypeList)[number];\n\n/**\n * List of supported fallback modes.\n */\nexport const FallbackModeTypeList = ['redirect', 'popup'] as const;\n/**\n * Type representing valid fallback modes.\n */\nexport type FallbackMode = (typeof FallbackModeTypeList)[number];\n\n/**\n * Represents a signing key used in cryptographic operations, such as signing JSON Web Tokens (JWTs).\n *\n * This type defines the key's properties, including its usage, type, identifier, algorithm, and key material.\n */\nexport type SigningKey = {\n\t/**\n\t * The intended use of the key. Common values include \"sig\" for signature and \"enc\" for encryption.\n\t *\n\t * @type {string}\n\t * @example 'sig'\n\t */\n\tuse: string;\n\n\t/**\n\t * The key type. For example, \"RSA\" for RSA keys or \"EC\" for Elliptic Curve keys.\n\t *\n\t * @type {string}\n\t * @example 'RSA'\n\t */\n\tkty: string;\n\n\t/**\n\t * A unique identifier for the key. This is used to distinguish the key from others.\n\t *\n\t * @type {string}\n\t * @example 'key-id-1234'\n\t */\n\tkid: string;\n\n\t/**\n\t * The algorithm used with the key. For example, \"RS256\" for RSA SHA-256.\n\t *\n\t * @type {AlgorithmType}\n\t * @example 'RS256'\n\t */\n\talg: AlgorithmType;\n\n\t/**\n\t * The modulus of the RSA key, encoded in base64url format. For RSA keys, this is a required property.\n\t *\n\t * @type {string}\n\t * @example 'base64url-encoded-modulus'\n\t */\n\tn: string;\n\n\t/**\n\t * The exponent of the RSA key, encoded in base64url format. For RSA keys, this is a required property.\n\t *\n\t * @type {string}\n\t * @example 'base64url-encoded-exponent'\n\t */\n\te: string;\n};\n\n/**\n * Represents the metadata options provided by an authorization server.\n *\n * This metadata includes information about the server's endpoints, supported features, and supported claims.\n */\nexport type MetadataOptions = {\n\t/**\n\t * The issuer of the tokens. This is the authorization server or entity that issues the tokens.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tissuer: string;\n\n\t/**\n\t * The URL of the authorization endpoint where authentication requests are sent.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/authorize'\n\t */\n\tauthorization_endpoint: string;\n\n\t/**\n\t * The URL of the token endpoint where tokens are exchanged.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/token'\n\t */\n\ttoken_endpoint: string;\n\n\t/**\n\t * The URL of the JSON Web Key Set (JWKS) endpoint where public keys are available.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/jwks'\n\t */\n\tjwks_uri: string;\n\n\t/**\n\t * The types of subjects that are supported by the authorization server.\n\t *\n\t * @type {Array<SubjectType>}\n\t * @example ['public']\n\t */\n\tsubject_types_supported: Array<SubjectType>;\n\n\t/**\n\t * The types of responses supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['code', 'id_token']\n\t */\n\tresponse_types_supported: Array<string>;\n\n\t/**\n\t * The claims supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['sub', 'name', 'email']\n\t */\n\tclaims_supported: Array<string>;\n\n\t/**\n\t * The grant types supported by the authorization server.\n\t *\n\t * @type {Array<GrantType>}\n\t * @example ['authorization_code', 'refresh_token']\n\t */\n\tgrant_types_supported: Array<GrantType>;\n\n\t/**\n\t * The response modes supported by the authorization server.\n\t *\n\t * @type {Array<ResponseMode>}\n\t * @example ['query', 'fragment']\n\t */\n\tresponse_modes_supported: Array<ResponseMode>;\n\n\t/**\n\t * The URL of the user info endpoint where user information can be retrieved.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/userinfo'\n\t */\n\tuserinfo_endpoint: string;\n\n\t/**\n\t * The scopes supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['openid', 'profile', 'email']\n\t */\n\tscopes_supported: Array<string>;\n\n\t/**\n\t * The authentication methods supported for token endpoint authentication.\n\t *\n\t * @type {Array<TokenEndpointAuthMethod>}\n\t * @example ['none']\n\t */\n\ttoken_endpoint_auth_methods_supported: Array<TokenEndpointAuthMethod>;\n\n\t/**\n\t * The algorithms supported for signing tokens used in the user info endpoint.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tuserinfo_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms supported for signing ID tokens.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tid_token_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms used to sign ID tokens in response.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tid_token_signed_response_alg: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms used to sign responses from the user info endpoint.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tuserinfo_signed_response_alg: Array<AlgorithmType>;\n\n\t/**\n\t * Indicates whether the request parameter is supported in requests.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequest_parameter_supported: boolean;\n\n\t/**\n\t * Indicates whether the request URI parameter is supported in requests.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequest_uri_parameter_supported: boolean;\n\n\t/**\n\t * Indicates whether request URI registration is required.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequire_request_uri_registration: boolean;\n\n\t/**\n\t * Indicates whether the claims parameter is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tclaims_parameter_supported: boolean;\n\n\t/**\n\t * The URL of the revocation endpoint for revoking tokens.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/revoke'\n\t */\n\trevocation_endpoint: string;\n\n\t/**\n\t * Indicates whether backchannel logout is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tbackchannel_logout_supported: boolean;\n\n\t/**\n\t * Indicates whether backchannel logout session support is provided.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tbackchannel_logout_session_supported: boolean;\n\n\t/**\n\t * Indicates whether frontchannel logout is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tfrontchannel_logout_supported: boolean;\n\n\t/**\n\t * Indicates whether frontchannel logout session support is provided.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tfrontchannel_logout_session_supported: boolean;\n\n\t/**\n\t * The URL of the endpoint where end-session requests can be sent.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/logout'\n\t */\n\tend_session_endpoint: string;\n\n\t/**\n\t * The algorithms supported for signing request objects.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\trequest_object_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The code challenge methods supported by the authorization server.\n\t *\n\t * @type {Array<'S256'>}\n\t * @example ['S256']\n\t */\n\tcode_challenge_methods_supported: Array<'S256'>;\n};\n\n/**\n * Represents the standard claims in a JSON Web Token (JWT).\n *\n * These claims are part of the payload in a JWT and convey information about the token, such as its issuer, subject, and expiration.\n */\nexport type JwtClaims = {\n\t/**\n\t * The issuer of the token. This typically represents the authorization server or entity that issued the JWT.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tiss?: string;\n\n\t/**\n\t * The subject of the token. This is the identifier for the entity the token represents, such as a user ID.\n\t *\n\t * @type {string}\n\t * @example 'user123'\n\t */\n\tsub?: string;\n\n\t/**\n\t * The audience for which the token is intended. This can be a single identifier or an array of identifiers.\n\t *\n\t * @type {string | Array<string>}\n\t * @example 'your-client-id' | ['client1', 'client2']\n\t */\n\taud?: string | Array<string>;\n\n\t/**\n\t * The expiration time of the token, expressed as a Unix timestamp (number of seconds since January 1, 1970).\n\t *\n\t * @type {number}\n\t * @example 1633024800\n\t */\n\texp?: number;\n\n\t/**\n\t * The not-before time of the token, expressed as a Unix timestamp. The token must not be accepted before this time.\n\t *\n\t * @type {number}\n\t * @example 1633021200\n\t */\n\tnbf?: number;\n\n\t/**\n\t * The issued-at time of the token, expressed as a Unix timestamp (number of seconds since January 1, 1970).\n\t *\n\t * @type {number}\n\t * @example 1633022400\n\t */\n\tiat?: number;\n\n\t/**\n\t * A unique identifier for the token. This can be used to prevent token replay attacks.\n\t *\n\t * @type {string}\n\t * @example 'unique-jwt-id-1234'\n\t */\n\tjti?: string;\n};\n\n/**\n * Represents the claims included in an ID token, extending standard JWT claims with additional properties specific to identity tokens.\n *\n * ID tokens are used to authenticate and provide identity information about the user.\n */\nexport type IdTokenClaims = Mandatory<JwtClaims, 'iss' | 'sub' | 'aud' | 'exp' | 'iat'> & {\n\t/**\n\t * The authentication time, indicating when the user was authenticated.\n\t *\n\t * @type {number}\n\t * @example 1633022400\n\t */\n\tauth_time?: number;\n\n\t/**\n\t * A nonce value used to associate a client session with an ID token, preventing replay attacks.\n\t *\n\t * @type {string}\n\t * @example 'nonce-value-1234'\n\t */\n\tnonce?: string;\n\n\t/**\n\t * The Authentication Context Class Reference, indicating the authentication methods used.\n\t *\n\t * @type {string}\n\t * @example '2'\n\t */\n\tacr?: string;\n\n\t/**\n\t * The Authentication Methods References, providing information about the authentication methods used.\n\t *\n\t * @type {unknown}\n\t */\n\tamr?: unknown;\n\n\t/**\n\t * Authorized party, the client that the ID token is intended for.\n\t *\n\t * @type {string}\n\t * @example 'client-id'\n\t */\n\tazp?: string;\n\n\t/**\n\t * Session ID for the user, which can be used to manage user sessions.\n\t *\n\t * @type {string}\n\t * @example 'session-id-1234'\n\t */\n\tsid?: string;\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t[key: string]: any;\n};\n\n/**\n * Options for configuring the SDK.\n */\nexport type SDKOptions = {\n\t/**\n\t * Specifies the mode of the SDK operation, either 'popup' or 'redirect'.\n\t *\n\t * @type {'popup' | 'redirect' | 'native' | 'embedded' | 'custom'}\n\t * @default 'redirect'\n\t */\n\tmode?: 'popup' | 'redirect' | 'native' | 'embedded' | 'custom';\n\n\t/**\n\t * The issuer of the tokens, typically the URL of the authorization server.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tissuer: string;\n\n\t/**\n\t * The client ID issued by the authorization server, used to identify the application.\n\t *\n\t * @type {string}\n\t * @example 'your-client-id'\n\t */\n\tclientId: string;\n\n\t/**\n\t * The URI to which the user will be redirected after authentication or authorization.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/callback'\n\t */\n\tredirectUri: string;\n\n\t/**\n\t * A list of scopes requested by the application, defining the access levels for the tokens.\n\t *\n\t * @type {Array<string>}\n\t * @default ['openid']\n\t * @example ['openid', 'profile']\n\t */\n\tscopes?: Array<string>;\n\n\t/**\n\t * The type of response expected from the authorization server.\n\t *\n\t * @type {ResponseType}\n\t * @default 'code'\n\t */\n\tresponseType?: ResponseType;\n\n\t/**\n\t * The mode in which the response is returned from the authorization server.\n\t *\n\t * @type {ResponseMode}\n\t * @default 'query'\n\t */\n\tresponseMode?: ResponseMode;\n\n\t/**\n\t * The name of the token in storage used to persist authentication information.\n\t *\n\t * @type {string}\n\t * @default 'sty.session'\n\t * @example 'accessToken'\n\t */\n\tstorageTokenName?: string;\n\n\t/**\n\t * The storage mechanism used to save and retrieve authentication information.\n\t *\n\t * @type {SDKStorageType}\n\t * @default LocalStorage\n\t */\n\tstorage?: SDKStorageType;\n\n\t/**\n\t * The HTTP client used for making requests to the authorization server.\n\t *\n\t * @type {SDKHttpClientType}\n\t * @default HttpClient\n\t */\n\thttpClient?: SDKHttpClientType;\n\n\t/**\n\t * The logging mechanism used for logging messages and errors.\n\t *\n\t * @type {SDKLoggingType}\n\t */\n\tlogging?: SDKLoggingType;\n\n\t/**\n\t * A custom flow handler that extends the BaseFlow class. This allows you to implement a custom authentication flow by providing your own handler.\n\t *\n\t * @type {FlowType}\n\t */\n\tcustomFlow?: FlowType;\n\n\t/**\n\t * Handles the URL redirection to the specified target.\n\t * You can use this method to implement custom URL handling logic, such as opening a new window or navigating to a different page.\n\t *\n\t * @param {string} url - The URL to handle.\n\t * @param {Record<string, unknown>} params - Optional parameters for redirection.\n\t * @returns - A promise that resolves when the redirection is handled.\n\t */\n\turlHandler?: (url: string, params?: Record<string, unknown>) => Promise<unknown>;\n\n\t/**\n\t * Handles the callback from the authorization server after a successful authentication or authorization.\n\t * You can use this method to implement custom logic for processing the response from the authorization server.\n\t *\n\t * @param url - The URL containing the response from the authorization server.\n\t * @param responseMode - The mode in which the response is returned (e.g., 'query', 'fragment').\n\t * @returns - A promise that resolves when the callback is handled.\n\t */\n\tcallbackHandler?: (url: string, responseMode?: ResponseMode) => Promise<unknown>;\n};\n\n/**\n * Abstract class for SDK storage mechanisms.\n */\nexport abstract class SDKStorage {\n\t/**\n\t * Retrieves an item from the storage by key.\n\t *\n\t * @param {string} key - The key of the item to retrieve.\n\t * @returns {string | null} The value associated with the key, or `null` if not found.\n\t */\n\tabstract get(key: string): Promise<string | null>;\n\n\t/**\n\t * Deletes an item from the storage by key.\n\t *\n\t * @param {string} key - The key of the item to delete.\n\t */\n\tabstract delete(key: string): Promise<void>;\n\n\t/**\n\t * Sets an item in the storage with the specified key and value.\n\t *\n\t * @param {string} key - The key to associate with the value.\n\t * @param {string} value - The value to store.\n\t */\n\tabstract set(key: string, value: string): Promise<void>;\n}\n\nexport abstract class SDKLogging {\n\t/*\n\t * Identifier for the login session - can be used to provide additional context for log messages\n\t */\n\txEventId: string | undefined;\n\n\tabstract debug(message: string): void;\n\tabstract info(message: string): void;\n\tabstract warn(message: string): void;\n\tabstract error(message: string, error: Error): void;\n}\n\n/**\n * Abstract class for HTTP client used in the SDK.\n */\nexport abstract class SDKHttpClient {\n\tlogging?: SDKLogging;\n\n\t/**\n\t * Makes an HTTP request to the specified URL with optional options.\n\t * @param {string} url - The URL to which the request is sent.\n\t * @param {RequestInit} options - Optional request options, such as method, headers, body, etc.\n\t */\n\tabstract request<T>(url: string, options?: RequestInit): Promise<HttpClientResponse<T>>;\n}\n\n/**\n * Type representing a constructor function for SDKStorage.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SDKStorageType = new (...args: Array<any>) => SDKStorage;\n\n/**\n * Type representing a constructor function for SDKHttpClient.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SDKHttpClientType = new (...args: Array<any>) => SDKHttpClient;\n\n/**\n * Type representing a constructor function for SDKHttpClient.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SDKLoggingType = new (...args: Array<any>) => SDKLogging;\n\n/**\n * Type representing a constructor function for a custom flow that extends BaseFlow.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FlowType = new (...args: Array<any>) => BaseFlow;\n\n/**\n * Http client response type.\n */\nexport type HttpClientResponse<T> = {\n\treadonly headers: Headers;\n\treadonly ok: boolean;\n\treadonly status: number;\n\treadonly statusText: string;\n\treadonly url: string;\n\tjson(): Promise<T>;\n\ttext(): Promise<string>;\n};\n\n/**\n * A collection of functions used to handle various events that occur within the SDK.\n */\nexport type EventFunctions = {\n\t/**\n\t * Handler called when an access token has expired.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The expired access token.\n\t * @param {string | null} [params.refreshToken] - The refresh token associated with the access token, if available.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\taccessTokenExpired: (params?: { accessToken?: string; refreshToken?: string | null }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when the SDK is initialized.\n\t *\n\t * @returns {Promise<void> | void} A promise that resolves when the initialization is complete, or void if no asynchronous operation is needed.\n\t */\n\tinit: () => Promise<void> | void;\n\n\t/**\n\t * Handler called when a user has successfully logged in.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The access token obtained after login.\n\t * @param {string | null} [params.refreshToken] - The refresh token obtained after login, if available.\n\t * @param {IdTokenClaims} params.claims - The claims extracted from the ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\tloggedIn: (params?: { accessToken?: string; refreshToken?: string | null; claims?: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when login has been initiated.\n\t *\n\t * @returns {Promise<void> | void} A promise that resolves when the login initiation process is complete, or void if no asynchronous operation is needed.\n\t */\n\tloginInitiated: () => Promise<void> | void;\n\n\t/**\n\t * Handler called when a logout request has been initiated.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.idToken - The ID token associated with the logout request.\n\t * @param {IdTokenClaims} params.claims - The claims associated with the ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the logout initiation process is complete, or void if no asynchronous operation is needed.\n\t */\n\tlogoutInitiated: (params?: { idToken?: string; claims?: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a user session has been successfully loaded.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The access token associated with the loaded session.\n\t * @param {string | null} [params.refreshToken] - The refresh token associated with the session, if available.\n\t * @param {IdTokenClaims} params.claims - The claims associated with the ID token in the session.\n\t * @returns {Promise<void> | void} A promise that resolves when the session loading is complete, or void if no asynchronous operation is needed.\n\t */\n\tsessionLoaded: (params?: { accessToken?: string; refreshToken?: string | null; claims?: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when an access token has been successfully refreshed.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The new access token obtained after the refresh.\n\t * @param {string} params.refreshToken - The refresh token used to obtain the new access token.\n\t * @param {IdTokenClaims} params.claims - The claims extracted from the new ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the token refresh is complete, or void if no asynchronous operation is needed.\n\t */\n\ttokenRefreshed: (params?: { accessToken?: string; refreshToken?: string; claims?: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token refresh operation fails.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.refreshToken - The refresh token that was used in the failed refresh operation.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRefreshFailed: (params?: { refreshToken?: string }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token has been successfully revoked.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.token - The token that was revoked.\n\t * @param {'refresh_token' | 'access_token'} params.tokenTypeHint - The type of token that was revoked.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRevoked: (params?: { token?: string; tokenTypeHint?: 'refresh_token' | 'access_token' }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token revocation operation fails.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.token - The token that was attempted to be revoked.\n\t * @param {'refresh_token' | 'access_token'} params.tokenTypeHint - The type of token that was attempted to be revoked.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRevokeFailed: (params?: { token?: string; tokenTypeHint?: 'refresh_token' | 'access_token' }) => Promise<void> | void;\n};\n\n// endregion\n\n// region Flows\n\n/**\n * Extra parameters that can be used in requests.\n */\n/**\n * Additional parameters that can be included in authentication or authorization requests.\n */\nexport type ExtraRequestArgs = {\n\t/**\n\t * Specifies the type of prompt to display to the user during authentication or authorization.\n\t *\n\t * @type {PromptType}\n\t * @example 'none' | 'login' | 'create'\n\t */\n\tprompt?: PromptType;\n\n\t/**\n\t * Provides a hint to the authorization server about the user's email or username.\n\t *\n\t * @type {string}\n\t * @example 'user@example.com'\n\t */\n\tloginHint?: string;\n\n\t/**\n\t * A list of values used to request specific authentication contexts or levels of assurance.\n\t *\n\t * This parameter allows requesting specific authentication contexts (e.g., multi-factor authentication)\n\t * or other criteria that the authorization server should consider when authenticating the user.\n\t *\n\t * @type {Array<string>}\n\t * @example ['urn:mace:incommon:iap:bronze', 'urn:mace:incommon:iap:silver']\n\t */\n\tacrValues?: Array<string>;\n\n\t/**\n\t * A list of locale codes to request specific language and regional preferences for the user interface.\n\t *\n\t * This parameter allows requesting the user interface to be presented in specific languages or regional formats.\n\t *\n\t * @type {Array<string>}\n\t * @example ['en-US', 'fr-CA']\n\t */\n\tuiLocales?: Array<string>;\n\n\t/**\n\t * A list of audience values to specify the intended recipients of the token.\n\t *\n\t * This parameter allows requesting that the issued token is intended for specific audiences.\n\t *\n\t * @type {Array<string>}\n\t * @example ['https://api.example.com', 'https://service.example.com']\n\t */\n\taudiences?: Array<string>;\n};\n\n/**\n * Params for configuring logout behavior.\n */\nexport type LogoutParams = {\n\t/**\n\t * The URI to redirect to after a successful logout.\n\t *\n\t * If specified, the user will be redirected to this URI upon completing the logout process.\n\t * This is often used to send users back to the main application or a custom post-logout page.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/home'\n\t */\n\tpostLogoutRedirectUri?: string;\n};\n\n/**\n * Parameters for redirect authentication flow.\n */\nexport type RedirectParams = ExtraRequestArgs & {\n\t/**\n\t * The method used to update the browser's location after authentication or authorization.\n\t *\n\t * Determines whether the new URL should replace the current URL in the history or be added to it.\n\t *\n\t * @type {'replace' | 'assign'}\n\t * @default 'assign'\n\t */\n\tlocationMethod?: 'replace' | 'assign';\n\n\t/**\n\t * The window in which the redirect should occur.\n\t *\n\t * Specifies whether the redirect should happen in the top-level window or the current window.\n\t *\n\t * @type {'top' | 'self'}\n\t * @default 'self'\n\t */\n\ttargetWindow?: 'top' | 'self';\n};\n\n/**\n * Features for customizing the popup window.\n */\nexport type PopupWindowFeatures = {\n\t/**\n\t * The horizontal position of the popup window relative to the left edge of the screen.\n\t *\n\t * @type {number}\n\t * @example 100\n\t */\n\tleft?: number;\n\n\t/**\n\t * The vertical position of the popup window relative to the top edge of the screen.\n\t *\n\t * @type {number}\n\t * @example 100\n\t */\n\ttop?: number;\n\n\t/**\n\t * The width of the popup window.\n\t *\n\t * @type {number}\n\t * @example 600\n\t */\n\twidth?: number;\n\n\t/**\n\t * The height of the popup window.\n\t *\n\t * @type {number}\n\t * @example 400\n\t */\n\theight?: number;\n\n\t/**\n\t * Whether the popup window should display a menubar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tmenubar?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display a toolbar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\ttoolbar?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display the address/location bar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tlocation?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display a status bar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tstatus?: boolean | string;\n\n\t/**\n\t * Whether the popup window should be resizable.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example false\n\t */\n\tresizable?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display scrollbars.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example false\n\t */\n\tscrollbars?: boolean | string;\n\n\t[key: string]: boolean | string | number | undefined;\n};\n\n/**\n * Parameters for popup authentication flow.\n */\nexport type PopupParams = ExtraRequestArgs & {\n\t/**\n\t * Configuration options for the popup window, including size, position, and other features.\n\t *\n\t * @type {PopupWindowFeatures}\n\t */\n\tpopupWindowFeatures?: PopupWindowFeatures;\n\n\t/**\n\t * The target of the popup window, which specifies where the popup should be opened.\n\t *\n\t * @type {string}\n\t * @example '_blank' | '_self' | '_parent' | '_top'\n\t */\n\tpopupWindowTarget?: string;\n\n\t/**\n\t * Whether to check the origin of messages received from the popup window.\n\t *\n\t * If set to `true`, the SDK will verify that messages received from the popup window originate from the expected domain.\n\t * This is a security measure to prevent malicious scripts from sending unauthorized messages to the application.\n\t *\n\t * @type {boolean}\n\t * @default true\n\t */\n\tcheckOrigin?: boolean;\n};\n\n/**\n * Parameters for native authentication flow.\n */\nexport type NativeParams = RedirectParams & { sdk?: string };\n\nexport declare const WidgetTypeList: readonly [\n\t'layout',\n\t'submit',\n\t'close',\n\t'static',\n\t'input',\n\t'checkbox',\n\t'password',\n\t'select',\n\t'multiSelect',\n\t'passcode',\n\t'date',\n\t'phone',\n\t'loading',\n\t'passkeyLogin',\n\t'passkeyEnroll',\n\t'webauthnLogin',\n\t'webauthnEnroll',\n];\nexport type WidgetType = (typeof WidgetTypeList)[number];\nexport declare const SelectOptionTypeList: readonly ['item', 'group'];\nexport type SelectOptionType = (typeof SelectOptionTypeList)[number];\nexport type BrandingData = {\n\tlogoUrl: string | null;\n\tbrandName: string | null;\n\tcopyright: string | null;\n\tprivacyPolicyUrl: string | null;\n\tsiteTermsUrl: string | null;\n};\nexport type CheckboxWidget = {\n\tid: string;\n\ttype: 'checkbox';\n\tlabel?: string;\n\treadonly?: boolean;\n\tvalue?: boolean;\n\trender?: {\n\t\ttype: 'checkboxHidden' | 'checkboxShown';\n\t\tlabelType: 'text' | 'html';\n\t};\n\tvalidator?: {\n\t\trequired?: boolean;\n\t};\n};\nexport type DateWidget = {\n\tid: string;\n\ttype: 'date';\n\tlabel?: string;\n\treadonly?: boolean;\n\tvalue?: string;\n\trender?: {\n\t\ttype: 'native' | 'fieldSet';\n\t};\n\tvalidator?: {\n\t\tnotBefore?: string;\n\t\tnotAfter?: string;\n\t\trequired?: boolean;\n\t};\n};\nexport type InputWidget = {\n\tid: string;\n\ttype: 'input';\n\tlabel?: string;\n\tvalue?: string;\n\treadonly?: boolean;\n\tautocomplete?: string;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinputmode: any;\n\trender?: {\n\t\tautocompleteHint?: string;\n\t};\n\tvalidator?: {\n\t\trequired?: boolean;\n\t\tminLength?: number;\n\t\tmaxLength?: number;\n\t\tregex?: string;\n\t};\n};\nexport type PasscodeWidget = {\n\tid: string;\n\ttype: 'passcode';\n\tlabel?: string;\n\tvalidator?: {\n\t\tlength?: number;\n\t};\n};\nexport type PasswordWidget = {\n\tid: string;\n\ttype: 'password';\n\tlabel?: string;\n\tqualityIndicator?: boolean;\n\tvalidator?: {\n\t\tminLength?: number;\n\t\tmaxLength?: number;\n\t\tmaxNumericCharacterSequences?: number;\n\t\tmaxRepeatedCharacters?: number;\n\t\tmustContain?: Array<'UPPERCASE' | 'LOWERCASE' | 'NUMERIC' | 'SPECIAL'>;\n\t\trestrictedCharacters?: string;\n\t};\n};\nexport type PhoneWidget = {\n\tid: string;\n\ttype: 'phone';\n\tlabel?: string;\n\treadonly?: boolean;\n\tvalue?: string;\n\tvalidator?: {\n\t\trequired?: boolean;\n\t};\n};\nexport type SelectWidgetOption = {\n\ttype: 'item';\n\tlabel?: string;\n\tvalue: string;\n};\nexport type SelectWidgetOptionGroup = {\n\ttype: 'group';\n\tlabel?: string;\n\toptions: Array<SelectWidgetOption>;\n};\nexport type SelectWidget = {\n\tid: string;\n\ttype: 'select';\n\tlabel?: string;\n\treadonly?: boolean;\n\tvalue?: string;\n\trender?: {\n\t\ttype: 'dropdown' | 'radio';\n\t};\n\toptions: Array<SelectWidgetOptionGroup | SelectWidgetOption>;\n\tvalidator?: {\n\t\trequired?: boolean;\n\t};\n};\nexport type MultiSelectWidget = {\n\tid: string;\n\ttype: 'multiSelect';\n\tlabel?: string;\n\treadonly?: boolean;\n\tvalue?: Array<string>;\n\toptions: Array<SelectWidgetOptionGroup | SelectWidgetOption>;\n\tvalidator?: {\n\t\tminSelectable?: number;\n\t\tmaxSelectable?: number;\n\t};\n};\nexport type StaticWidget = {\n\tid: string;\n\ttype: 'static';\n\tvalue: string;\n\trender?: {\n\t\ttype: 'html' | 'text';\n\t};\n};\nexport type SubmitWidget = {\n\tid: string;\n\ttype: 'submit';\n\tlabel?: string;\n\trender?: {\n\t\ttype: 'button' | 'link';\n\t\ttextColor?: string;\n\t\tbgColor?: string;\n\t\thint?: {\n\t\t\ticon?: string;\n\t\t\tvariant?: string;\n\t\t};\n\t};\n};\nexport type CloseWidget = {\n\tid: string;\n\ttype: 'close';\n\tlabel?: string;\n\trender?: {\n\t\ttype: 'button' | 'link';\n\t\ttextColor?: string;\n\t\tbgColor?: string;\n\t\thint?: {\n\t\t\ticon?: string;\n\t\t\tvariant?: string;\n\t\t};\n\t};\n};\nexport type FormWidget = {\n\tid: string;\n\ttype: 'form';\n\twidgets: Array<\n\t\tCheckboxWidget | DateWidget | InputWidget | PasscodeWidget | PasswordWidget | PhoneWidget | SelectWidget | MultiSelectWidget | StaticWidget | SubmitWidget\n\t>;\n};\nexport type Widget = {\n\ttype: 'widget';\n\tformId: string;\n\twidgetId: string;\n};\nexport type LayoutWidget = {\n\ttype: 'vertical' | 'horizontal';\n\titems: Array<Widget | LayoutWidget>;\n};\nexport type PasskeyLoginWidget = {\n\tid: string;\n\tlabel?: string;\n\trender?: {\n\t\ttype: 'button';\n\t\thint?: {\n\t\t\tvariant?: string;\n\t\t};\n\t};\n\tassertionOptions: PublicKeyCredentialRequestOptions;\n};\nexport type PasskeyEnrollWidget = {\n\tid: string;\n\tlabel?: string;\n\trender?: {\n\t\ttype: 'button';\n\t\thint?: {\n\t\t\tvariant?: string;\n\t\t};\n\t};\n\tenrollOptions: PublicKeyCredentialCreationOptions;\n};\nexport type WebauthnLoginWidget = {\n\tid: string;\n\tlabel?: string;\n\tauthenticatorType: 'deviceBiometrics' | 'securityKey';\n\trender?: {\n\t\ttype: 'button';\n\t\thint?: {\n\t\t\tvariant?: string;\n\t\t};\n\t};\n\tassertionOptions: PublicKeyCredentialRequestOptions;\n};\nexport type WebauthnEnrollWidget = {\n\tid: string;\n\tlabel?: string;\n\tauthenticatorType: 'deviceBiometrics' | 'securityKey';\n\trender?: {\n\t\ttype: 'button';\n\t\thint?: {\n\t\t\tvariant?: string;\n\t\t};\n\t};\n\tenrollOptions: PublicKeyCredentialCreationOptions;\n};\nexport type LoginFlowMessage = {\n\ttype: string;\n\ttext: string;\n};\nexport type LoginFlowState = {\n\thostedUrl?: string;\n\tfinalizeUrl?: string;\n\tscreen?: string;\n\tbranding?: BrandingData;\n\tforms?: Array<FormWidget>;\n\tlayout?: LayoutWidget;\n\tmessages?: Record<string, Record<string, LoginFlowMessage>> & {\n\t\tglobal?: LoginFlowMessage;\n\t};\n};\nexport type AssertionPublicKeyCredential = PublicKeyCredential & {\n\tresponse: AuthenticatorAssertionResponse;\n};\nexport type AssertionCredentialData = {\n\tid: string;\n\ttype: string;\n\trawId: string;\n\tresponse: {\n\t\tclientDataJSON: string;\n\t\tauthenticatorData: string;\n\t\tsignature: string;\n\t\tuserHandle: string;\n\t};\n};\nexport type AttestationPublicKeyCredential = PublicKeyCredential & {\n\tresponse: AuthenticatorAttestationResponse;\n};\nexport type AttestationCredentialData = {\n\tid: string;\n\ttype: string;\n\trawId: string;\n\tauthenticatorAttachment: string | null;\n\tresponse: {\n\t\tclientDataJSON: string;\n\t\tattestationObject: string;\n\t\ttransports: Array<string>;\n\t};\n};\n\nexport declare class LanguageSelectorComponent extends HTMLElement {}\n\nexport declare class NotificationComponent extends HTMLElement {\n\tdevMode: boolean;\n}\n\nexport declare class LandingComponent extends HTMLElement {\n\tactiveBlock: string;\n\tbaseUrl: string;\n\tlazy: boolean;\n\tlang: string;\n\tdebug: boolean;\n\tinitialized?: boolean;\n}\n\nexport declare class LoginComponent extends HTMLElement {\n\tmode?: string;\n\tbaseUrl?: string;\n\tsessionId?: string;\n\tlazy: boolean;\n\tparams: ExtraRequestArgs;\n\tlang: string;\n\tdebug: boolean;\n\tinitialized?: boolean;\n}\n\ndeclare global {\n\tinterface HTMLElementTagNameMap {\n\t\t'sty-language-selector': LanguageSelectorComponent;\n\t\t'sty-notifications': NotificationComponent;\n\t\t'sty-landing': LandingComponent;\n\t\t'sty-login': LoginComponent;\n\t}\n}\n\n// endregion\n"],"names":["ResponseTypeList","ResponseModeList","TokenEndpointAuthMethodList","GrantTypeList","AlgorithmTypeList","SubjectTypeList","PromptTypeList","FallbackModeTypeList","SDKStorage","SDKLogging","SDKHttpClient"],"mappings":"gFA+BO,MAAMA,EAAmB,CAAC,OAAQ,UAAU,EAStCC,EAAmB,CAAC,QAAS,UAAU,EASvCC,EAA8B,CAAC,MAAM,EASrCC,EAAgB,CAAC,qBAAsB,eAAe,EAStDC,EAAoB,CAAC,OAAO,EAS5BC,EAAkB,CAAC,QAAQ,EAS3BC,EAAiB,CAAC,OAAQ,QAAS,QAAQ,EAS3CC,EAAuB,CAAC,WAAY,OAAO,EAwhBjD,MAAeC,CAAW,CAuBjC,CAEO,MAAeC,CAAW,CAIhC,QAMD,CAKO,MAAeC,CAAc,CACnC,OAQD"}
|