@strivacity/sdk-core 1.0.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 +6 -0
- package/LICENSE +21 -0
- package/README.md +54 -0
- package/dist/Metadata.cjs +2 -0
- package/dist/Metadata.cjs.map +1 -0
- package/dist/Metadata.d.ts +74 -0
- package/dist/Metadata.mjs +2 -0
- package/dist/Metadata.mjs.map +1 -0
- package/dist/Session.cjs +2 -0
- package/dist/Session.cjs.map +1 -0
- package/dist/Session.d.ts +82 -0
- package/dist/Session.mjs +2 -0
- package/dist/Session.mjs.map +1 -0
- package/dist/State.cjs +2 -0
- package/dist/State.cjs.map +1 -0
- package/dist/State.d.ts +43 -0
- package/dist/State.mjs +2 -0
- package/dist/State.mjs.map +1 -0
- package/dist/flows/BaseFlow.cjs +2 -0
- package/dist/flows/BaseFlow.cjs.map +1 -0
- package/dist/flows/BaseFlow.d.ts +177 -0
- package/dist/flows/BaseFlow.mjs +2 -0
- package/dist/flows/BaseFlow.mjs.map +1 -0
- package/dist/flows/PopupFlow.cjs +2 -0
- package/dist/flows/PopupFlow.cjs.map +1 -0
- package/dist/flows/PopupFlow.d.ts +31 -0
- package/dist/flows/PopupFlow.mjs +2 -0
- package/dist/flows/PopupFlow.mjs.map +1 -0
- package/dist/flows/RedirectFlow.cjs +2 -0
- package/dist/flows/RedirectFlow.cjs.map +1 -0
- package/dist/flows/RedirectFlow.d.ts +32 -0
- package/dist/flows/RedirectFlow.mjs +2 -0
- package/dist/flows/RedirectFlow.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/storages/LocalStorage.cjs +2 -0
- package/dist/storages/LocalStorage.cjs.map +1 -0
- package/dist/storages/LocalStorage.d.ts +23 -0
- package/dist/storages/LocalStorage.mjs +2 -0
- package/dist/storages/LocalStorage.mjs.map +1 -0
- package/dist/storages/SessionStorage.cjs +2 -0
- package/dist/storages/SessionStorage.cjs.map +1 -0
- package/dist/storages/SessionStorage.d.ts +23 -0
- package/dist/storages/SessionStorage.mjs +2 -0
- package/dist/storages/SessionStorage.mjs.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.ts +861 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils/base64Url.cjs +2 -0
- package/dist/utils/base64Url.cjs.map +1 -0
- package/dist/utils/base64Url.d.ts +27 -0
- package/dist/utils/base64Url.mjs +2 -0
- package/dist/utils/base64Url.mjs.map +1 -0
- package/dist/utils/constants.cjs +2 -0
- package/dist/utils/constants.cjs.map +1 -0
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/constants.mjs +2 -0
- package/dist/utils/constants.mjs.map +1 -0
- package/dist/utils/crypto.cjs +2 -0
- package/dist/utils/crypto.cjs.map +1 -0
- package/dist/utils/crypto.d.ts +32 -0
- package/dist/utils/crypto.mjs +2 -0
- package/dist/utils/crypto.mjs.map +1 -0
- package/dist/utils/date.cjs +2 -0
- package/dist/utils/date.cjs.map +1 -0
- package/dist/utils/date.d.ts +6 -0
- package/dist/utils/date.mjs +2 -0
- package/dist/utils/date.mjs.map +1 -0
- package/dist/utils/fetch.cjs +2 -0
- package/dist/utils/fetch.cjs.map +1 -0
- package/dist/utils/fetch.d.ts +2 -0
- package/dist/utils/fetch.mjs +2 -0
- package/dist/utils/fetch.mjs.map +1 -0
- package/dist/utils/handlers.cjs +2 -0
- package/dist/utils/handlers.cjs.map +1 -0
- package/dist/utils/handlers.d.ts +34 -0
- package/dist/utils/handlers.mjs +2 -0
- package/dist/utils/handlers.mjs.map +1 -0
- package/dist/utils/jwt.cjs +2 -0
- package/dist/utils/jwt.cjs.map +1 -0
- package/dist/utils/jwt.d.ts +34 -0
- package/dist/utils/jwt.mjs +2 -0
- package/dist/utils/jwt.mjs.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var m=Object.defineProperty;var u=(o,e,s)=>e in o?m(o,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[e]=s;var i=(o,e,s)=>u(o,typeof e!="symbol"?e+"":e,s);import{isBrowser as _}from"../utils/constants.mjs";import{jwt as l}from"../utils/jwt.mjs";import{fetch as g}from"../utils/fetch.mjs";import{timestamp as T}from"../utils/date.mjs";import{Metadata as w}from"../Metadata.mjs";import{Session as f}from"../Session.mjs";import{State as y}from"../State.mjs";import"../utils/base64Url.mjs";import"../utils/crypto.mjs";const r={accessTokenExpired:new Set,init:new Set,loggedIn:new Set,loginInitiated:new Set,logoutInitiated:new Set,sessionLoaded:new Set,tokenRefreshed:new Set,tokenRefreshFailed:new Set,tokenRevoked:new Set,tokenRevokeFailed:new Set};class N{constructor(e,s){i(this,"isAuthPromise",null);i(this,"httpClient");i(this,"options");i(this,"storage");i(this,"metadata");i(this,"session",null);if(!e.issuer)throw Error("Missing option: issuer");if(!e.clientId)throw Error("Missing option: clientId");if(!e.redirectUri)throw Error("Missing option: redirectUri");if(e.scopes&&!Array.isArray(e.scopes))throw Error("Invalid option: scopes");e.scopes||(e.scopes=["openid"]),e.responseType||(e.responseType="code"),e.responseMode||(e.responseMode="query"),e.storageTokenName||(e.storageTokenName="sty.session"),this.httpClient=g.create({retry:0}),this.options=e,this.storage=s,this.metadata=new w(`${e.issuer}/.well-known/openid-configuration`),this.session=f.load(this.storage.get(this.options.storageTokenName)),setTimeout(()=>{this.dispatchEvent("init",[]),this.session&&this.accessToken&&this.idTokenClaims&&this.dispatchEvent("sessionLoaded",[{accessToken:this.accessToken,refreshToken:this.refreshToken,claims:this.idTokenClaims}]),this.accessToken&&this.accessTokenExpired&&this.dispatchEvent("accessTokenExpired",[{accessToken:this.accessToken,refreshToken:this.refreshToken}])})}get idTokenClaims(){var e;return(e=this.session)==null?void 0:e.claims}get accessToken(){var e;return(e=this.session)==null?void 0:e.access_token}get refreshToken(){var e;return(e=this.session)==null?void 0:e.refresh_token}get accessTokenExpired(){var e;return!((e=this.session)!=null&&e.expires_at)||this.session.expires_at<=T()}get accessTokenExpirationDate(){var e;return(e=this.session)==null?void 0:e.expires_at}get isAuthenticated(){return this.isAuthPromise?this.isAuthPromise:(this.isAuthPromise=new Promise(async e=>{try{this.refreshToken&&this.accessTokenExpired&&await this.refresh()}catch{}setTimeout(()=>{var s,t;e(!!((s=this.session)!=null&&s.access_token)||!!((t=this.session)!=null&&t.refresh_token)),this.isAuthPromise=null})}),this.isAuthPromise)}async logout(e){if(!_)return;const s=this.session;if(this.storage.delete(this.options.storageTokenName),this.session=null,s!=null&&s.id_token){const t=new URL(await this.metadata.endSessionEndpoint);t.searchParams.append("id_token_hint",s==null?void 0:s.id_token),e!=null&&e.postLogoutRedirectUri&&t.searchParams.append("post_logout_redirect_uri",e.postLogoutRedirectUri),this.dispatchEvent("logoutInitiated",[{idToken:s.id_token,claims:s.claims}]);try{await this.urlHandler(t,e)}catch{}}}async refresh(){var s,t;if(typeof((s=this.session)==null?void 0:s.refresh_token)!="string")throw Error("No refresh token available");const e=this.session;try{const n=await this.sendTokenRequest(await this.metadata.tokenEndpoint,{grant_type:"refresh_token",client_id:this.options.clientId,refresh_token:(t=this.session)==null?void 0:t.refresh_token});Object.assign(this.session,await n.json()),this.session.id_token&&(this.session.claims=l.decode(this.session.id_token)),this.storage.set(this.options.storageTokenName,JSON.stringify(this.session)),this.accessToken&&this.refreshToken&&this.idTokenClaims&&this.dispatchEvent("tokenRefreshed",[{accessToken:this.accessToken,refreshToken:this.refreshToken,claims:this.idTokenClaims}])}catch{this.session=null,this.storage.delete(this.options.storageTokenName),this.dispatchEvent("tokenRefreshFailed",[{refreshToken:e.refresh_token}])}}async revoke(){const e=this.session;let s=!0;try{e!=null&&e.refresh_token?await this.sendTokenRequest(await this.metadata.revocationEndpoint,{client_id:this.options.clientId,token_type_hint:"refresh_token",token:e.refresh_token}):e!=null&&e.access_token&&await this.sendTokenRequest(await this.metadata.revocationEndpoint,{client_id:this.options.clientId,token_type_hint:"access_token",token:e.access_token})}catch{s=!1}finally{this.session=null,this.storage.delete(this.options.storageTokenName),e!=null&&e.refresh_token?this.dispatchEvent(s?"tokenRevoked":"tokenRevokeFailed",[{token:e.refresh_token,tokenTypeHint:"refresh_token"}]):e!=null&&e.access_token&&this.dispatchEvent(s?"tokenRevoked":"tokenRevokeFailed",[{token:e.access_token,tokenTypeHint:"access_token"}])}}async exchangeCodeForTokens(e={}){var n,a,h,c,d,p;if(this.session=new f,Object.assign(this.session,e),this.session.error)throw Error(`${this.session.error}: ${this.session.error_description}`);if(!this.session.code)throw Error("Invalid or missing code");let s;try{const k=this.storage.get(`sty.${this.session.state}`);if(!k)throw Error();s=y.fromSerializedData(k),this.storage.delete(`sty.${this.session.state}`)}catch{throw Error("Invalid or missing state")}const t=await this.sendTokenRequest(await this.metadata.tokenEndpoint,{grant_type:"authorization_code",client_id:this.options.clientId,redirect_uri:this.options.redirectUri,code_verifier:s.codeVerifier,code:this.session.code});if(Object.assign(this.session,await t.json()),this.session.id_token&&(this.session.claims=l.decode(this.session.id_token)),this.session.scope!==((n=this.options.scopes)==null?void 0:n.join(" ")))throw Error("Invalid scope");if(((a=this.session.claims)==null?void 0:a.nonce)!==s.nonce)throw Error("Invalid nonce");if(((h=this.session.claims)==null?void 0:h.iss)!==await this.metadata.issuer)throw Error("Invalid iss");if(Array.isArray((c=this.session.claims)==null?void 0:c.aud)?((d=this.session.claims)==null?void 0:d.aud[0])!==this.options.clientId:((p=this.session.claims)==null?void 0:p.aud)!==this.options.clientId)throw Error("Invalid aud");this.storage.set(this.options.storageTokenName,JSON.stringify(this.session))}subscribeToEvent(e,s){return r[e].add(s),{dispose:()=>{r[e].delete(s)}}}dispatchEvent(e,s){for(const t of r[e])t(...s)}async getAuthorizationUrl(e={}){var t;const s=new URL(await this.metadata.authorizationEndpoint);return s.searchParams.append("client_id",this.options.clientId),s.searchParams.append("redirect_uri",this.options.redirectUri),s.searchParams.append("response_type",this.options.responseType||"code"),s.searchParams.append("response_mode",this.options.responseMode||"fragment"),s.searchParams.append("scope",(t=this.options.scopes)==null?void 0:t.join(" ")),s.searchParams.append("code_challenge_method","S256"),e.prompt&&s.searchParams.append("prompt",e.prompt),e.acrValues&&s.searchParams.append("acr_values",e.acrValues.join(" ")),e.loginHint&&s.searchParams.append("login_hint",e.loginHint),e.uiLocales&&s.searchParams.append("ui_locales",e.uiLocales.join(" ")),s}async sendTokenRequest(e,s={}){return await this.httpClient.post(e,{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(s)})}}export{N as BaseFlow};
|
|
2
|
+
//# sourceMappingURL=BaseFlow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseFlow.mjs","sources":["../../src/flows/BaseFlow.ts"],"sourcesContent":["import type { KyInstance } from 'ky';\nimport type { IdTokenClaims, SDKOptions, SDKStorage, EventFunctions, ExtraRequestArgs, LogoutOptions } from '../types';\nimport { isBrowser } from '../utils/constants';\nimport { jwt } from '../utils/jwt';\nimport { fetch } from '../utils/fetch';\nimport { timestamp } from '../utils/date';\nimport { Metadata } from '../Metadata';\nimport { Session } from '../Session';\nimport { State } from '../State';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst eventCallbacks: Record<keyof EventFunctions, Set<(...args: Array<any>) => Promise<void> | void>> = {\n\taccessTokenExpired: new Set(),\n\tinit: new Set(),\n\tloggedIn: new Set(),\n\tloginInitiated: new Set(),\n\tlogoutInitiated: new Set(),\n\tsessionLoaded: new Set(),\n\ttokenRefreshed: new Set(),\n\ttokenRefreshFailed: new Set(),\n\ttokenRevoked: new Set(),\n\ttokenRevokeFailed: new Set(),\n};\n\n/**\n * An abstract base class that provides common functionality for different OIDC flows.\n *\n * @template Options - The options type extending `SDKOptions` used for configuring the flow.\n * @template URLHandlerOptions - The options type extending `ExtraRequestArgs` used for URL handling.\n */\nexport abstract class BaseFlow<Options extends SDKOptions, URLHandlerOptions extends ExtraRequestArgs> {\n\t/**\n\t * A promise that resolves to indicate whether authentication has been verified.\n\t *\n\t * @type {Promise<boolean> | null}\n\t */\n\tprotected isAuthPromise: Promise<boolean> | null = null;\n\n\t/**\n\t * An instance of the HTTP client used for making requests.\n\t *\n\t * @type {KyInstance}\n\t */\n\tprotected httpClient!: KyInstance;\n\n\t/**\n\t * The configuration options for the flow.\n\t *\n\t * @type {Options}\n\t */\n\tprotected options: Options;\n\n\t/**\n\t * The storage mechanism used to persist session data.\n\t *\n\t * @type {SDKStorage}\n\t */\n\tprotected storage: SDKStorage;\n\n\t/**\n\t * Metadata information about the authorization server.\n\t *\n\t * @type {Metadata}\n\t */\n\tprotected metadata: Metadata;\n\n\t/**\n\t * The current session data.\n\t *\n\t * @type {Session | null}\n\t */\n\tprotected session: Session | null = null;\n\n\t/**\n\t * Retrieves the ID token claims from the current session.\n\t *\n\t * @type {IdTokenClaims | null | undefined}\n\t */\n\tget idTokenClaims(): IdTokenClaims | null | undefined {\n\t\treturn this.session?.claims;\n\t}\n\n\t/**\n\t * Retrieves the access token from the current session.\n\t *\n\t * @type {string | null | undefined}\n\t */\n\tget accessToken(): string | null | undefined {\n\t\treturn this.session?.access_token;\n\t}\n\n\t/**\n\t * Retrieves the refresh token from the current session.\n\t *\n\t * @type {string | null | undefined}\n\t */\n\tget refreshToken(): string | null | undefined {\n\t\treturn this.session?.refresh_token;\n\t}\n\n\t/**\n\t * Determines if the access token has expired.\n\t *\n\t * @type {boolean}\n\t */\n\tget accessTokenExpired(): boolean {\n\t\treturn !this.session?.expires_at || this.session.expires_at <= timestamp();\n\t}\n\n\t/**\n\t * Retrieves the access token expiration date.\n\t *\n\t * @type {number | null | undefined}\n\t */\n\tget accessTokenExpirationDate(): number | null | undefined {\n\t\treturn this.session?.expires_at;\n\t}\n\n\t/**\n\t * Checks if the user is authenticated by evaluating the presence of access or refresh tokens.\n\t *\n\t * @returns {Promise<boolean>} - A promise that resolves to `true` if the user is authenticated, otherwise `false`.\n\t */\n\tget isAuthenticated(): Promise<boolean> {\n\t\tif (this.isAuthPromise) {\n\t\t\treturn this.isAuthPromise;\n\t\t}\n\n\t\t// eslint-disable-next-line no-async-promise-executor\n\t\tthis.isAuthPromise = new Promise(async (resolve) => {\n\t\t\ttry {\n\t\t\t\tif (this.refreshToken && this.accessTokenExpired) {\n\t\t\t\t\tawait this.refresh();\n\t\t\t\t}\n\t\t\t} catch {}\n\n\t\t\tsetTimeout(() => {\n\t\t\t\tresolve(!!this.session?.access_token || !!this.session?.refresh_token);\n\t\t\t\tthis.isAuthPromise = null;\n\t\t\t});\n\t\t});\n\n\t\treturn this.isAuthPromise;\n\t}\n\n\t/**\n\t * Constructs a new instance of the `BaseFlow` class.\n\t *\n\t * @param {Options} options - Configuration options for the flow.\n\t * @param {SDKStorage} storage - Storage mechanism for session data.\n\t *\n\t * @throws {Error} Throws an error if required options are missing or invalid.\n\t */\n\tconstructor(options: Options, storage: SDKStorage) {\n\t\tif (!options.issuer) {\n\t\t\tthrow Error('Missing option: issuer');\n\t\t}\n\t\tif (!options.clientId) {\n\t\t\tthrow Error('Missing option: clientId');\n\t\t}\n\t\tif (!options.redirectUri) {\n\t\t\tthrow Error('Missing option: redirectUri');\n\t\t}\n\t\tif (options.scopes && !Array.isArray(options.scopes)) {\n\t\t\tthrow Error('Invalid option: scopes');\n\t\t}\n\n\t\tif (!options.scopes) {\n\t\t\toptions.scopes = ['openid'];\n\t\t}\n\t\tif (!options.responseType) {\n\t\t\toptions.responseType = 'code';\n\t\t}\n\t\tif (!options.responseMode) {\n\t\t\toptions.responseMode = 'query';\n\t\t}\n\t\tif (!options.storageTokenName) {\n\t\t\toptions.storageTokenName = 'sty.session';\n\t\t}\n\n\t\tthis.httpClient = fetch.create({ retry: 0 });\n\t\tthis.options = options as Options;\n\t\tthis.storage = storage;\n\t\tthis.metadata = new Metadata(`${options.issuer}/.well-known/openid-configuration`);\n\t\tthis.session = Session.load(this.storage.get(this.options.storageTokenName as string));\n\n\t\tsetTimeout(() => {\n\t\t\tthis.dispatchEvent('init', []);\n\n\t\t\tif (this.session && this.accessToken && this.idTokenClaims) {\n\t\t\t\tthis.dispatchEvent('sessionLoaded', [{ accessToken: this.accessToken, refreshToken: this.refreshToken, claims: this.idTokenClaims }]);\n\t\t\t}\n\n\t\t\tif (this.accessToken && this.accessTokenExpired) {\n\t\t\t\tthis.dispatchEvent('accessTokenExpired', [{ accessToken: this.accessToken, refreshToken: this.refreshToken }]);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Initiates the login process. Subclasses should implement this method to handle the specific login flow.\n\t *\n\t * @param {URLHandlerOptions} [options] - Additional options for handling URLs during login.\n\t * @returns {Promise<void>} - A promise that resolves when the login process is complete.\n\t */\n\tabstract login(options?: URLHandlerOptions): Promise<void>;\n\n\t/**\n\t * Registers a new user. Subclasses should implement this method to handle the specific registration flow.\n\t *\n\t * @param {URLHandlerOptions} [options] - Additional options for handling URLs during registration.\n\t * @returns {Promise<void>} - A promise that resolves when the registration process is complete.\n\t */\n\tabstract register(options?: URLHandlerOptions): Promise<void>;\n\n\t/**\n\t * Logs out the current user and optionally redirects to a post-logout URI.\n\t *\n\t * @param {URLHandlerOptions & LogoutOptions} [options] - Additional options for handling URLs during logout.\n\t * @returns {Promise<void>} - A promise that resolves when the logout process is complete.\n\t */\n\tasync logout(options?: URLHandlerOptions & LogoutOptions): Promise<void> {\n\t\tif (!isBrowser) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst session = this.session;\n\n\t\tthis.storage.delete(this.options.storageTokenName as string);\n\t\tthis.session = null;\n\n\t\tif (session?.id_token) {\n\t\t\tconst url = new URL(await this.metadata.endSessionEndpoint);\n\n\t\t\turl.searchParams.append('id_token_hint', session?.id_token);\n\n\t\t\tif (options?.postLogoutRedirectUri) {\n\t\t\t\turl.searchParams.append('post_logout_redirect_uri', options.postLogoutRedirectUri);\n\t\t\t}\n\n\t\t\tthis.dispatchEvent('logoutInitiated', [{ idToken: session.id_token, claims: session.claims as IdTokenClaims }]);\n\n\t\t\ttry {\n\t\t\t\tawait this.urlHandler(url, options as URLHandlerOptions);\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\t/**\n\t * Refreshes the access token using the refresh token.\n\t *\n\t * @returns {Promise<void>} - A promise that resolves when the token refresh is complete.\n\t *\n\t * @throws {Error} Throws an error if no refresh token is available or if the refresh fails.\n\t */\n\tasync refresh(): Promise<void> {\n\t\tif (typeof this.session?.refresh_token !== 'string') {\n\t\t\tthrow Error('No refresh token available');\n\t\t}\n\n\t\tconst session = this.session;\n\n\t\ttry {\n\t\t\tconst request = await this.sendTokenRequest(await this.metadata.tokenEndpoint, {\n\t\t\t\tgrant_type: 'refresh_token',\n\t\t\t\tclient_id: this.options.clientId,\n\t\t\t\trefresh_token: this.session?.refresh_token,\n\t\t\t});\n\n\t\t\tObject.assign(this.session, await request.json());\n\n\t\t\tif (this.session.id_token) {\n\t\t\t\tthis.session.claims = jwt.decode<IdTokenClaims>(this.session.id_token);\n\t\t\t}\n\n\t\t\tthis.storage.set(this.options.storageTokenName as string, JSON.stringify(this.session));\n\n\t\t\tif (this.accessToken && this.refreshToken && this.idTokenClaims) {\n\t\t\t\tthis.dispatchEvent('tokenRefreshed', [{ accessToken: this.accessToken, refreshToken: this.refreshToken, claims: this.idTokenClaims }]);\n\t\t\t}\n\t\t} catch {\n\t\t\tthis.session = null;\n\t\t\tthis.storage.delete(this.options.storageTokenName as string);\n\n\t\t\tthis.dispatchEvent('tokenRefreshFailed', [{ refreshToken: session.refresh_token as string }]);\n\t\t}\n\t}\n\n\t/**\n\t * Revokes the current access or refresh token.\n\t *\n\t * @returns {Promise<void>} - A promise that resolves when the token revocation is complete.\n\t */\n\tasync revoke(): Promise<void> {\n\t\tconst session = this.session;\n\t\tlet success = true;\n\n\t\ttry {\n\t\t\tif (session?.refresh_token) {\n\t\t\t\tawait this.sendTokenRequest(await this.metadata.revocationEndpoint, {\n\t\t\t\t\tclient_id: this.options.clientId,\n\t\t\t\t\ttoken_type_hint: 'refresh_token',\n\t\t\t\t\ttoken: session.refresh_token,\n\t\t\t\t});\n\t\t\t} else if (session?.access_token) {\n\t\t\t\tawait this.sendTokenRequest(await this.metadata.revocationEndpoint, {\n\t\t\t\t\tclient_id: this.options.clientId,\n\t\t\t\t\ttoken_type_hint: 'access_token',\n\t\t\t\t\ttoken: session.access_token,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch {\n\t\t\tsuccess = false;\n\t\t} finally {\n\t\t\tthis.session = null;\n\t\t\tthis.storage.delete(this.options.storageTokenName as string);\n\n\t\t\tif (session?.refresh_token) {\n\t\t\t\tthis.dispatchEvent(success ? 'tokenRevoked' : 'tokenRevokeFailed', [{ token: session.refresh_token as string, tokenTypeHint: 'refresh_token' }]);\n\t\t\t} else if (session?.access_token) {\n\t\t\t\tthis.dispatchEvent(success ? 'tokenRevoked' : 'tokenRevokeFailed', [{ token: session.access_token as string, tokenTypeHint: 'access_token' }]);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Exchanges an authorization code for access and refresh tokens.\n\t *\n\t * @param {Record<string, string>} [params={}] - Parameters containing the authorization code and other required values.\n\t * @returns {Promise<void>} - A promise that resolves when the token exchange is complete.\n\t *\n\t * @throws {Error} Throws an error if the authorization code is invalid or if there are issues with state, nonce, or tokens.\n\t */\n\tasync exchangeCodeForTokens(params: Record<string, string> = {}): Promise<void> {\n\t\tthis.session = new Session();\n\n\t\tObject.assign(this.session, params);\n\n\t\tif (this.session.error) {\n\t\t\tthrow Error(`${this.session.error}: ${this.session.error_description}`);\n\t\t}\n\t\tif (!this.session.code) {\n\t\t\tthrow Error('Invalid or missing code');\n\t\t}\n\n\t\tlet state: State;\n\n\t\ttry {\n\t\t\tconst serializedState = this.storage.get(`sty.${this.session.state}`);\n\n\t\t\tif (!serializedState) {\n\t\t\t\tthrow Error();\n\t\t\t}\n\n\t\t\tstate = State.fromSerializedData(serializedState);\n\n\t\t\tthis.storage.delete(`sty.${this.session.state}`);\n\t\t} catch {\n\t\t\tthrow Error('Invalid or missing state');\n\t\t}\n\n\t\tconst request = await this.sendTokenRequest(await this.metadata.tokenEndpoint, {\n\t\t\tgrant_type: 'authorization_code',\n\t\t\tclient_id: this.options.clientId,\n\t\t\tredirect_uri: this.options.redirectUri,\n\t\t\tcode_verifier: state.codeVerifier,\n\t\t\tcode: this.session.code,\n\t\t});\n\n\t\tObject.assign(this.session, await request.json());\n\n\t\tif (this.session.id_token) {\n\t\t\tthis.session.claims = jwt.decode<IdTokenClaims>(this.session.id_token);\n\t\t}\n\n\t\tif (this.session.scope !== this.options.scopes?.join(' ')) {\n\t\t\tthrow Error('Invalid scope');\n\t\t}\n\t\tif (this.session.claims?.nonce !== state.nonce) {\n\t\t\tthrow Error('Invalid nonce');\n\t\t}\n\t\tif (this.session.claims?.iss !== (await this.metadata.issuer)) {\n\t\t\tthrow Error('Invalid iss');\n\t\t}\n\t\tif (Array.isArray(this.session.claims?.aud) ? this.session.claims?.aud[0] !== this.options.clientId : this.session.claims?.aud !== this.options.clientId) {\n\t\t\tthrow Error('Invalid aud');\n\t\t}\n\n\t\tthis.storage.set(this.options.storageTokenName as string, JSON.stringify(this.session));\n\t}\n\n\t/**\n\t * Subscribes a callback function to an event.\n\t *\n\t * @param {T} eventName - The name of the event to subscribe to.\n\t * @param {(...params: Parameters<EventFunctions[T]>) => Promise<void> | void} callbackFn - The callback function to execute when the event is dispatched.\n\t * @returns {{ dispose: () => void }} - An object with a `dispose` method to remove the subscription.\n\t */\n\tsubscribeToEvent<T extends keyof EventFunctions>(\n\t\teventName: T,\n\t\tcallbackFn: (...params: Parameters<EventFunctions[T]>) => Promise<void> | void,\n\t): { dispose: () => void } {\n\t\teventCallbacks[eventName].add(callbackFn);\n\n\t\treturn {\n\t\t\tdispose: () => {\n\t\t\t\teventCallbacks[eventName].delete(callbackFn);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Dispatches an event to all subscribed callback functions.\n\t *\n\t * @param {T} eventName - The name of the event to dispatch.\n\t * @param {Parameters<EventFunctions[T]>} args - The arguments to pass to the callback functions.\n\t */\n\tprotected dispatchEvent<T extends keyof EventFunctions>(eventName: T, args: Parameters<EventFunctions[T]>): void {\n\t\tfor (const eventFn of eventCallbacks[eventName]) {\n\t\t\tvoid eventFn(...args);\n\t\t}\n\t}\n\n\t/**\n\t * Constructs the authorization URL for initiating the authorization flow.\n\t *\n\t * @param {ExtraRequestArgs} [options={}] - Additional options to include in the authorization URL.\n\t * @returns {Promise<URL>} - A promise that resolves to the constructed authorization URL.\n\t */\n\tprotected async getAuthorizationUrl(options: ExtraRequestArgs = {}): Promise<URL> {\n\t\tconst url = new URL(await this.metadata.authorizationEndpoint);\n\n\t\turl.searchParams.append('client_id', this.options.clientId);\n\t\turl.searchParams.append('redirect_uri', this.options.redirectUri);\n\t\turl.searchParams.append('response_type', this.options.responseType || 'code');\n\t\turl.searchParams.append('response_mode', this.options.responseMode || 'fragment');\n\t\turl.searchParams.append('scope', this.options.scopes?.join(' ') as string);\n\t\turl.searchParams.append('code_challenge_method', 'S256');\n\n\t\tif (options.prompt) {\n\t\t\turl.searchParams.append('prompt', options.prompt);\n\t\t}\n\t\tif (options.acrValues) {\n\t\t\turl.searchParams.append('acr_values', options.acrValues.join(' '));\n\t\t}\n\t\tif (options.loginHint) {\n\t\t\turl.searchParams.append('login_hint', options.loginHint);\n\t\t}\n\t\tif (options.uiLocales) {\n\t\t\turl.searchParams.append('ui_locales', options.uiLocales.join(' '));\n\t\t}\n\n\t\treturn url;\n\t}\n\n\t/**\n\t * Handles URL redirections for authentication and authorization processes.\n\t *\n\t * @param {string | URL} url - The URL to handle.\n\t * @param {URLHandlerOptions} [options] - Additional options for URL handling.\n\t * @returns {Promise<unknown>} - A promise that resolves when the URL handling is complete.\n\t */\n\tprotected abstract urlHandler(url: string | URL, options?: URLHandlerOptions): Promise<unknown>;\n\n\t/**\n\t * Sends a token request to the specified URL with the given data.\n\t *\n\t * @param {string | URL} url - The URL to send the request to.\n\t * @param {Record<string, string>} [data={}] - The data to include in the request body.\n\t * @returns {Promise<Response>} - A promise that resolves to the response from the request.\n\t */\n\tprotected async sendTokenRequest(url: string | URL, data: Record<string, string> = {}): Promise<Response> {\n\t\treturn await this.httpClient.post(url, {\n\t\t\theaders: { 'Content-Type': 'application/x-www-form-urlencoded' },\n\t\t\tbody: new URLSearchParams(data),\n\t\t});\n\t}\n}\n"],"names":["eventCallbacks","BaseFlow","options","storage","__publicField","fetch","Metadata","Session","_a","timestamp","resolve","_b","isBrowser","session","url","request","jwt","success","params","state","serializedState","State","_c","_d","_e","_f","eventName","callbackFn","args","eventFn","data"],"mappings":"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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../utils/handlers.cjs"),t=require("../utils/constants.cjs"),n=require("../State.cjs"),o=require("./BaseFlow.cjs");require("../utils/crypto.cjs");require("../utils/base64Url.cjs");require("../utils/date.cjs");require("../utils/jwt.cjs");require("../utils/fetch.cjs");require("../Metadata.cjs");require("../Session.cjs");class c extends o.BaseFlow{async login(e={}){if(!t.isBrowser)return;const s=await n.State.create(),a=await this.getAuthorizationUrl(e);a.searchParams.append("state",s.id),a.searchParams.append("code_challenge",s.codeChallenge),a.searchParams.append("nonce",s.nonce),a.searchParams.append("display","popup"),this.storage.set(`sty.${s.id}`,JSON.stringify(s)),this.dispatchEvent("loginInitiated",[]);const i=await this.urlHandler(a,e);await this.exchangeCodeForTokens(i),this.accessToken&&this.idTokenClaims&&this.dispatchEvent("loggedIn",[{accessToken:this.accessToken,refreshToken:this.refreshToken,claims:this.idTokenClaims}])}async register(e={}){t.isBrowser&&(e.prompt="create",await this.login(e))}async handleCallback(){r.popupCallbackHandler(this.options.responseMode||"fragment")}async urlHandler(e,s){return r.popupUrlHandler(e,s)}}exports.PopupFlow=c;
|
|
2
|
+
//# sourceMappingURL=PopupFlow.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopupFlow.cjs","sources":["../../src/flows/PopupFlow.ts"],"sourcesContent":["import type { SDKOptions, PopupWindowParams } from '../types';\nimport { popupCallbackHandler, popupUrlHandler } from '../utils/handlers';\nimport { isBrowser } from '../utils/constants';\nimport { State } from '../State';\nimport { BaseFlow } from './BaseFlow';\n\n/**\n * Implements the Popup flow for authentication using a popup window.\n */\nexport class PopupFlow extends BaseFlow<SDKOptions, PopupWindowParams> {\n\t/**\n\t * Initiates the login process via a popup window.\n\t * @param {PopupWindowParams} [options={}] Optional parameters for popup window configuration.\n\t * @returns {Promise<void>} A promise that resolves when the login process completes.\n\t */\n\tasync login(options: PopupWindowParams = {}): Promise<void> {\n\t\tif (!isBrowser) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst url = await this.getAuthorizationUrl(options);\n\n\t\turl.searchParams.append('state', state.id);\n\t\turl.searchParams.append('code_challenge', state.codeChallenge);\n\t\turl.searchParams.append('nonce', state.nonce);\n\t\turl.searchParams.append('display', 'popup');\n\n\t\tthis.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tthis.dispatchEvent('loginInitiated', []);\n\n\t\tconst data = await this.urlHandler(url, options);\n\n\t\tawait this.exchangeCodeForTokens(data);\n\n\t\tif (this.accessToken && this.idTokenClaims) {\n\t\t\tthis.dispatchEvent('loggedIn', [{ accessToken: this.accessToken, refreshToken: this.refreshToken, claims: this.idTokenClaims }]);\n\t\t}\n\t}\n\n\t/**\n\t * Initiates the registration process via a popup window.\n\t * @param {PopupWindowParams} [options={}] Optional parameters for popup window configuration.\n\t * @returns {Promise<void>} A promise that resolves when the registration process completes.\n\t */\n\tasync register(options: PopupWindowParams = {}): Promise<void> {\n\t\tif (!isBrowser) {\n\t\t\treturn;\n\t\t}\n\n\t\toptions.prompt = 'create';\n\n\t\tawait this.login(options);\n\t}\n\n\t/**\n\t * Handles the callback after login or registration via a popup window.\n\t * @returns {Promise<void>} A promise that resolves when the callback is handled.\n\t */\n\tasync handleCallback(): Promise<void> {\n\t\tpopupCallbackHandler(this.options.responseMode || 'fragment');\n\t}\n\n\t/**\n\t * Handles the URL redirection to a popup window.\n\t * @param {URL} url The URL to handle.\n\t * @param {PopupWindowParams} [options] Optional parameters for popup window configuration.\n\t * @returns {Promise<Record<string, string>>} A promise that resolves to the data returned from the popup window.\n\t */\n\tasync urlHandler(url: URL, options?: PopupWindowParams): Promise<Record<string, string>> {\n\t\treturn popupUrlHandler(url, options);\n\t}\n}\n"],"names":["PopupFlow","BaseFlow","options","isBrowser","state","State","url","data","popupCallbackHandler","popupUrlHandler"],"mappings":"gaASO,MAAMA,UAAkBC,EAAAA,QAAwC,CAMtE,MAAM,MAAMC,EAA6B,GAAmB,CAC3D,GAAI,CAACC,EAAAA,UACJ,OAGK,MAAAC,EAAQ,MAAMC,QAAM,SACpBC,EAAM,MAAM,KAAK,oBAAoBJ,CAAO,EAElDI,EAAI,aAAa,OAAO,QAASF,EAAM,EAAE,EACzCE,EAAI,aAAa,OAAO,iBAAkBF,EAAM,aAAa,EAC7DE,EAAI,aAAa,OAAO,QAASF,EAAM,KAAK,EACxCE,EAAA,aAAa,OAAO,UAAW,OAAO,EAErC,KAAA,QAAQ,IAAI,OAAOF,EAAM,EAAE,GAAI,KAAK,UAAUA,CAAK,CAAC,EAEpD,KAAA,cAAc,iBAAkB,CAAA,CAAE,EAEvC,MAAMG,EAAO,MAAM,KAAK,WAAWD,EAAKJ,CAAO,EAEzC,MAAA,KAAK,sBAAsBK,CAAI,EAEjC,KAAK,aAAe,KAAK,eAC5B,KAAK,cAAc,WAAY,CAAC,CAAE,YAAa,KAAK,YAAa,aAAc,KAAK,aAAc,OAAQ,KAAK,aAAA,CAAe,CAAC,CAEjI,CAOA,MAAM,SAASL,EAA6B,GAAmB,CACzDC,EAAAA,YAILD,EAAQ,OAAS,SAEX,MAAA,KAAK,MAAMA,CAAO,EACzB,CAMA,MAAM,gBAAgC,CAChBM,EAAAA,qBAAA,KAAK,QAAQ,cAAgB,UAAU,CAC7D,CAQA,MAAM,WAAWF,EAAUJ,EAA8D,CACjF,OAAAO,EAAA,gBAAgBH,EAAKJ,CAAO,CACpC,CACD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SDKOptions, PopupWindowParams } from '../types';
|
|
2
|
+
import { BaseFlow } from './BaseFlow';
|
|
3
|
+
/**
|
|
4
|
+
* Implements the Popup flow for authentication using a popup window.
|
|
5
|
+
*/
|
|
6
|
+
export declare class PopupFlow extends BaseFlow<SDKOptions, PopupWindowParams> {
|
|
7
|
+
/**
|
|
8
|
+
* Initiates the login process via a popup window.
|
|
9
|
+
* @param {PopupWindowParams} [options={}] Optional parameters for popup window configuration.
|
|
10
|
+
* @returns {Promise<void>} A promise that resolves when the login process completes.
|
|
11
|
+
*/
|
|
12
|
+
login(options?: PopupWindowParams): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Initiates the registration process via a popup window.
|
|
15
|
+
* @param {PopupWindowParams} [options={}] Optional parameters for popup window configuration.
|
|
16
|
+
* @returns {Promise<void>} A promise that resolves when the registration process completes.
|
|
17
|
+
*/
|
|
18
|
+
register(options?: PopupWindowParams): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Handles the callback after login or registration via a popup window.
|
|
21
|
+
* @returns {Promise<void>} A promise that resolves when the callback is handled.
|
|
22
|
+
*/
|
|
23
|
+
handleCallback(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Handles the URL redirection to a popup window.
|
|
26
|
+
* @param {URL} url The URL to handle.
|
|
27
|
+
* @param {PopupWindowParams} [options] Optional parameters for popup window configuration.
|
|
28
|
+
* @returns {Promise<Record<string, string>>} A promise that resolves to the data returned from the popup window.
|
|
29
|
+
*/
|
|
30
|
+
urlHandler(url: URL, options?: PopupWindowParams): Promise<Record<string, string>>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{popupCallbackHandler as i,popupUrlHandler as o}from"../utils/handlers.mjs";import{isBrowser as s}from"../utils/constants.mjs";import{State as n}from"../State.mjs";import{BaseFlow as p}from"./BaseFlow.mjs";import"../utils/crypto.mjs";import"../utils/base64Url.mjs";import"../utils/date.mjs";import"../utils/jwt.mjs";import"../utils/fetch.mjs";import"../Metadata.mjs";import"../Session.mjs";class C extends p{async login(e={}){if(!s)return;const a=await n.create(),t=await this.getAuthorizationUrl(e);t.searchParams.append("state",a.id),t.searchParams.append("code_challenge",a.codeChallenge),t.searchParams.append("nonce",a.nonce),t.searchParams.append("display","popup"),this.storage.set(`sty.${a.id}`,JSON.stringify(a)),this.dispatchEvent("loginInitiated",[]);const r=await this.urlHandler(t,e);await this.exchangeCodeForTokens(r),this.accessToken&&this.idTokenClaims&&this.dispatchEvent("loggedIn",[{accessToken:this.accessToken,refreshToken:this.refreshToken,claims:this.idTokenClaims}])}async register(e={}){s&&(e.prompt="create",await this.login(e))}async handleCallback(){i(this.options.responseMode||"fragment")}async urlHandler(e,a){return o(e,a)}}export{C as PopupFlow};
|
|
2
|
+
//# sourceMappingURL=PopupFlow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PopupFlow.mjs","sources":["../../src/flows/PopupFlow.ts"],"sourcesContent":["import type { SDKOptions, PopupWindowParams } from '../types';\nimport { popupCallbackHandler, popupUrlHandler } from '../utils/handlers';\nimport { isBrowser } from '../utils/constants';\nimport { State } from '../State';\nimport { BaseFlow } from './BaseFlow';\n\n/**\n * Implements the Popup flow for authentication using a popup window.\n */\nexport class PopupFlow extends BaseFlow<SDKOptions, PopupWindowParams> {\n\t/**\n\t * Initiates the login process via a popup window.\n\t * @param {PopupWindowParams} [options={}] Optional parameters for popup window configuration.\n\t * @returns {Promise<void>} A promise that resolves when the login process completes.\n\t */\n\tasync login(options: PopupWindowParams = {}): Promise<void> {\n\t\tif (!isBrowser) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst url = await this.getAuthorizationUrl(options);\n\n\t\turl.searchParams.append('state', state.id);\n\t\turl.searchParams.append('code_challenge', state.codeChallenge);\n\t\turl.searchParams.append('nonce', state.nonce);\n\t\turl.searchParams.append('display', 'popup');\n\n\t\tthis.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tthis.dispatchEvent('loginInitiated', []);\n\n\t\tconst data = await this.urlHandler(url, options);\n\n\t\tawait this.exchangeCodeForTokens(data);\n\n\t\tif (this.accessToken && this.idTokenClaims) {\n\t\t\tthis.dispatchEvent('loggedIn', [{ accessToken: this.accessToken, refreshToken: this.refreshToken, claims: this.idTokenClaims }]);\n\t\t}\n\t}\n\n\t/**\n\t * Initiates the registration process via a popup window.\n\t * @param {PopupWindowParams} [options={}] Optional parameters for popup window configuration.\n\t * @returns {Promise<void>} A promise that resolves when the registration process completes.\n\t */\n\tasync register(options: PopupWindowParams = {}): Promise<void> {\n\t\tif (!isBrowser) {\n\t\t\treturn;\n\t\t}\n\n\t\toptions.prompt = 'create';\n\n\t\tawait this.login(options);\n\t}\n\n\t/**\n\t * Handles the callback after login or registration via a popup window.\n\t * @returns {Promise<void>} A promise that resolves when the callback is handled.\n\t */\n\tasync handleCallback(): Promise<void> {\n\t\tpopupCallbackHandler(this.options.responseMode || 'fragment');\n\t}\n\n\t/**\n\t * Handles the URL redirection to a popup window.\n\t * @param {URL} url The URL to handle.\n\t * @param {PopupWindowParams} [options] Optional parameters for popup window configuration.\n\t * @returns {Promise<Record<string, string>>} A promise that resolves to the data returned from the popup window.\n\t */\n\tasync urlHandler(url: URL, options?: PopupWindowParams): Promise<Record<string, string>> {\n\t\treturn popupUrlHandler(url, options);\n\t}\n}\n"],"names":["PopupFlow","BaseFlow","options","isBrowser","state","State","url","data","popupCallbackHandler","popupUrlHandler"],"mappings":"4YASO,MAAMA,UAAkBC,CAAwC,CAMtE,MAAM,MAAMC,EAA6B,GAAmB,CAC3D,GAAI,CAACC,EACJ,OAGK,MAAAC,EAAQ,MAAMC,EAAM,SACpBC,EAAM,MAAM,KAAK,oBAAoBJ,CAAO,EAElDI,EAAI,aAAa,OAAO,QAASF,EAAM,EAAE,EACzCE,EAAI,aAAa,OAAO,iBAAkBF,EAAM,aAAa,EAC7DE,EAAI,aAAa,OAAO,QAASF,EAAM,KAAK,EACxCE,EAAA,aAAa,OAAO,UAAW,OAAO,EAErC,KAAA,QAAQ,IAAI,OAAOF,EAAM,EAAE,GAAI,KAAK,UAAUA,CAAK,CAAC,EAEpD,KAAA,cAAc,iBAAkB,CAAA,CAAE,EAEvC,MAAMG,EAAO,MAAM,KAAK,WAAWD,EAAKJ,CAAO,EAEzC,MAAA,KAAK,sBAAsBK,CAAI,EAEjC,KAAK,aAAe,KAAK,eAC5B,KAAK,cAAc,WAAY,CAAC,CAAE,YAAa,KAAK,YAAa,aAAc,KAAK,aAAc,OAAQ,KAAK,aAAA,CAAe,CAAC,CAEjI,CAOA,MAAM,SAASL,EAA6B,GAAmB,CACzDC,IAILD,EAAQ,OAAS,SAEX,MAAA,KAAK,MAAMA,CAAO,EACzB,CAMA,MAAM,gBAAgC,CAChBM,EAAA,KAAK,QAAQ,cAAgB,UAAU,CAC7D,CAQA,MAAM,WAAWF,EAAUJ,EAA8D,CACjF,OAAAO,EAAgBH,EAAKJ,CAAO,CACpC,CACD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../utils/handlers.cjs"),a=require("../utils/constants.cjs"),i=require("../State.cjs"),n=require("./BaseFlow.cjs");require("../utils/crypto.cjs");require("../utils/base64Url.cjs");require("../utils/date.cjs");require("../utils/jwt.cjs");require("../utils/fetch.cjs");require("../Metadata.cjs");require("../Session.cjs");class o extends n.BaseFlow{async login(e={}){if(!a.isBrowser)return;const r=await i.State.create(),s=await this.getAuthorizationUrl(e);s.searchParams.append("state",r.id),s.searchParams.append("code_challenge",r.codeChallenge),s.searchParams.append("nonce",r.nonce),this.storage.set(`sty.${r.id}`,JSON.stringify(r)),this.dispatchEvent("loginInitiated",[]),await this.urlHandler(s,e)}async register(e={}){a.isBrowser&&(e.prompt="create",await this.login(e))}async handleCallback(e){var r;e||(e=(r=globalThis.window)==null?void 0:r.location.href),await this.exchangeCodeForTokens(t.redirectCallbackHandler(e,this.options.responseMode||"fragment")),this.accessToken&&this.idTokenClaims&&this.dispatchEvent("loggedIn",[{accessToken:this.accessToken,refreshToken:this.refreshToken,claims:this.idTokenClaims}])}async urlHandler(e,r){return await t.redirectUrlHandler(e,r)}}exports.RedirectFlow=o;
|
|
2
|
+
//# sourceMappingURL=RedirectFlow.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedirectFlow.cjs","sources":["../../src/flows/RedirectFlow.ts"],"sourcesContent":["import type { SDKOptions, RedirectParams } from '../types';\nimport { redirectUrlHandler, redirectCallbackHandler } from '../utils/handlers';\nimport { isBrowser } from '../utils/constants';\nimport { State } from '../State';\nimport { BaseFlow } from './BaseFlow';\n\n/**\n * Implements the Redirect flow for authentication using a full-page redirect.\n */\nexport class RedirectFlow extends BaseFlow<SDKOptions, RedirectParams> {\n\t/**\n\t * Initiates the login process via a redirect.\n\t * @param {RedirectParams} [options={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the login process completes.\n\t */\n\tasync login(options: RedirectParams = {}): Promise<void> {\n\t\tif (!isBrowser) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst url = await this.getAuthorizationUrl(options);\n\n\t\turl.searchParams.append('state', state.id);\n\t\turl.searchParams.append('code_challenge', state.codeChallenge);\n\t\turl.searchParams.append('nonce', state.nonce);\n\n\t\tthis.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tthis.dispatchEvent('loginInitiated', []);\n\n\t\tawait this.urlHandler(url, options);\n\t}\n\n\t/**\n\t * Initiates the registration process via a redirect.\n\t * @param {RedirectParams} [options={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the registration process completes.\n\t */\n\tasync register(options: RedirectParams = {}): Promise<void> {\n\t\tif (!isBrowser) {\n\t\t\treturn;\n\t\t}\n\n\t\toptions.prompt = 'create';\n\n\t\tawait this.login(options);\n\t}\n\n\t/**\n\t * Handles the callback after login or registration via a redirect.\n\t * @param {string} [url] The URL to handle the callback from. Defaults to the current window location.\n\t * @returns {Promise<void>} A promise that resolves when the callback is handled.\n\t */\n\tasync handleCallback(url?: string): Promise<void> {\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tawait this.exchangeCodeForTokens(redirectCallbackHandler(url, this.options.responseMode || 'fragment'));\n\n\t\tif (this.accessToken && this.idTokenClaims) {\n\t\t\tthis.dispatchEvent('loggedIn', [{ accessToken: this.accessToken, refreshToken: this.refreshToken, claims: this.idTokenClaims }]);\n\t\t}\n\t}\n\n\t/**\n\t * Handles the URL redirection to the specified target.\n\t * @param {URL} url The URL to handle.\n\t * @param {RedirectParams} [options] Optional parameters for redirection.\n\t * @returns {Promise<void>} A promise that resolves when the redirection is handled.\n\t */\n\tasync urlHandler(url: URL, options?: RedirectParams): Promise<void> {\n\t\treturn await redirectUrlHandler(url, options);\n\t}\n}\n"],"names":["RedirectFlow","BaseFlow","options","isBrowser","state","State","url","_a","redirectCallbackHandler","redirectUrlHandler"],"mappings":"gaASO,MAAMA,UAAqBC,EAAAA,QAAqC,CAMtE,MAAM,MAAMC,EAA0B,GAAmB,CACxD,GAAI,CAACC,EAAAA,UACJ,OAGK,MAAAC,EAAQ,MAAMC,QAAM,SACpBC,EAAM,MAAM,KAAK,oBAAoBJ,CAAO,EAElDI,EAAI,aAAa,OAAO,QAASF,EAAM,EAAE,EACzCE,EAAI,aAAa,OAAO,iBAAkBF,EAAM,aAAa,EAC7DE,EAAI,aAAa,OAAO,QAASF,EAAM,KAAK,EAEvC,KAAA,QAAQ,IAAI,OAAOA,EAAM,EAAE,GAAI,KAAK,UAAUA,CAAK,CAAC,EAEpD,KAAA,cAAc,iBAAkB,CAAA,CAAE,EAEjC,MAAA,KAAK,WAAWE,EAAKJ,CAAO,CACnC,CAOA,MAAM,SAASA,EAA0B,GAAmB,CACtDC,EAAAA,YAILD,EAAQ,OAAS,SAEX,MAAA,KAAK,MAAMA,CAAO,EACzB,CAOA,MAAM,eAAeI,EAA6B,OAC5CA,IACEA,GAAAC,EAAA,WAAW,SAAX,YAAAA,EAAmB,SAAS,MAG7B,MAAA,KAAK,sBAAsBC,EAAAA,wBAAwBF,EAAK,KAAK,QAAQ,cAAgB,UAAU,CAAC,EAElG,KAAK,aAAe,KAAK,eAC5B,KAAK,cAAc,WAAY,CAAC,CAAE,YAAa,KAAK,YAAa,aAAc,KAAK,aAAc,OAAQ,KAAK,aAAA,CAAe,CAAC,CAEjI,CAQA,MAAM,WAAWA,EAAUJ,EAAyC,CAC5D,OAAA,MAAMO,EAAmB,mBAAAH,EAAKJ,CAAO,CAC7C,CACD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SDKOptions, RedirectParams } from '../types';
|
|
2
|
+
import { BaseFlow } from './BaseFlow';
|
|
3
|
+
/**
|
|
4
|
+
* Implements the Redirect flow for authentication using a full-page redirect.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RedirectFlow extends BaseFlow<SDKOptions, RedirectParams> {
|
|
7
|
+
/**
|
|
8
|
+
* Initiates the login process via a redirect.
|
|
9
|
+
* @param {RedirectParams} [options={}] Optional parameters for redirect configuration.
|
|
10
|
+
* @returns {Promise<void>} A promise that resolves when the login process completes.
|
|
11
|
+
*/
|
|
12
|
+
login(options?: RedirectParams): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Initiates the registration process via a redirect.
|
|
15
|
+
* @param {RedirectParams} [options={}] Optional parameters for redirect configuration.
|
|
16
|
+
* @returns {Promise<void>} A promise that resolves when the registration process completes.
|
|
17
|
+
*/
|
|
18
|
+
register(options?: RedirectParams): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Handles the callback after login or registration via a redirect.
|
|
21
|
+
* @param {string} [url] The URL to handle the callback from. Defaults to the current window location.
|
|
22
|
+
* @returns {Promise<void>} A promise that resolves when the callback is handled.
|
|
23
|
+
*/
|
|
24
|
+
handleCallback(url?: string): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Handles the URL redirection to the specified target.
|
|
27
|
+
* @param {URL} url The URL to handle.
|
|
28
|
+
* @param {RedirectParams} [options] Optional parameters for redirection.
|
|
29
|
+
* @returns {Promise<void>} A promise that resolves when the redirection is handled.
|
|
30
|
+
*/
|
|
31
|
+
urlHandler(url: URL, options?: RedirectParams): Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{redirectCallbackHandler as r,redirectUrlHandler as s}from"../utils/handlers.mjs";import{isBrowser as i}from"../utils/constants.mjs";import{State as o}from"../State.mjs";import{BaseFlow as n}from"./BaseFlow.mjs";import"../utils/crypto.mjs";import"../utils/base64Url.mjs";import"../utils/date.mjs";import"../utils/jwt.mjs";import"../utils/fetch.mjs";import"../Metadata.mjs";import"../Session.mjs";class C extends n{async login(e={}){if(!i)return;const t=await o.create(),a=await this.getAuthorizationUrl(e);a.searchParams.append("state",t.id),a.searchParams.append("code_challenge",t.codeChallenge),a.searchParams.append("nonce",t.nonce),this.storage.set(`sty.${t.id}`,JSON.stringify(t)),this.dispatchEvent("loginInitiated",[]),await this.urlHandler(a,e)}async register(e={}){i&&(e.prompt="create",await this.login(e))}async handleCallback(e){var t;e||(e=(t=globalThis.window)==null?void 0:t.location.href),await this.exchangeCodeForTokens(r(e,this.options.responseMode||"fragment")),this.accessToken&&this.idTokenClaims&&this.dispatchEvent("loggedIn",[{accessToken:this.accessToken,refreshToken:this.refreshToken,claims:this.idTokenClaims}])}async urlHandler(e,t){return await s(e,t)}}export{C as RedirectFlow};
|
|
2
|
+
//# sourceMappingURL=RedirectFlow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedirectFlow.mjs","sources":["../../src/flows/RedirectFlow.ts"],"sourcesContent":["import type { SDKOptions, RedirectParams } from '../types';\nimport { redirectUrlHandler, redirectCallbackHandler } from '../utils/handlers';\nimport { isBrowser } from '../utils/constants';\nimport { State } from '../State';\nimport { BaseFlow } from './BaseFlow';\n\n/**\n * Implements the Redirect flow for authentication using a full-page redirect.\n */\nexport class RedirectFlow extends BaseFlow<SDKOptions, RedirectParams> {\n\t/**\n\t * Initiates the login process via a redirect.\n\t * @param {RedirectParams} [options={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the login process completes.\n\t */\n\tasync login(options: RedirectParams = {}): Promise<void> {\n\t\tif (!isBrowser) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst url = await this.getAuthorizationUrl(options);\n\n\t\turl.searchParams.append('state', state.id);\n\t\turl.searchParams.append('code_challenge', state.codeChallenge);\n\t\turl.searchParams.append('nonce', state.nonce);\n\n\t\tthis.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tthis.dispatchEvent('loginInitiated', []);\n\n\t\tawait this.urlHandler(url, options);\n\t}\n\n\t/**\n\t * Initiates the registration process via a redirect.\n\t * @param {RedirectParams} [options={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the registration process completes.\n\t */\n\tasync register(options: RedirectParams = {}): Promise<void> {\n\t\tif (!isBrowser) {\n\t\t\treturn;\n\t\t}\n\n\t\toptions.prompt = 'create';\n\n\t\tawait this.login(options);\n\t}\n\n\t/**\n\t * Handles the callback after login or registration via a redirect.\n\t * @param {string} [url] The URL to handle the callback from. Defaults to the current window location.\n\t * @returns {Promise<void>} A promise that resolves when the callback is handled.\n\t */\n\tasync handleCallback(url?: string): Promise<void> {\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tawait this.exchangeCodeForTokens(redirectCallbackHandler(url, this.options.responseMode || 'fragment'));\n\n\t\tif (this.accessToken && this.idTokenClaims) {\n\t\t\tthis.dispatchEvent('loggedIn', [{ accessToken: this.accessToken, refreshToken: this.refreshToken, claims: this.idTokenClaims }]);\n\t\t}\n\t}\n\n\t/**\n\t * Handles the URL redirection to the specified target.\n\t * @param {URL} url The URL to handle.\n\t * @param {RedirectParams} [options] Optional parameters for redirection.\n\t * @returns {Promise<void>} A promise that resolves when the redirection is handled.\n\t */\n\tasync urlHandler(url: URL, options?: RedirectParams): Promise<void> {\n\t\treturn await redirectUrlHandler(url, options);\n\t}\n}\n"],"names":["RedirectFlow","BaseFlow","options","isBrowser","state","State","url","_a","redirectCallbackHandler","redirectUrlHandler"],"mappings":"kZASO,MAAMA,UAAqBC,CAAqC,CAMtE,MAAM,MAAMC,EAA0B,GAAmB,CACxD,GAAI,CAACC,EACJ,OAGK,MAAAC,EAAQ,MAAMC,EAAM,SACpBC,EAAM,MAAM,KAAK,oBAAoBJ,CAAO,EAElDI,EAAI,aAAa,OAAO,QAASF,EAAM,EAAE,EACzCE,EAAI,aAAa,OAAO,iBAAkBF,EAAM,aAAa,EAC7DE,EAAI,aAAa,OAAO,QAASF,EAAM,KAAK,EAEvC,KAAA,QAAQ,IAAI,OAAOA,EAAM,EAAE,GAAI,KAAK,UAAUA,CAAK,CAAC,EAEpD,KAAA,cAAc,iBAAkB,CAAA,CAAE,EAEjC,MAAA,KAAK,WAAWE,EAAKJ,CAAO,CACnC,CAOA,MAAM,SAASA,EAA0B,GAAmB,CACtDC,IAILD,EAAQ,OAAS,SAEX,MAAA,KAAK,MAAMA,CAAO,EACzB,CAOA,MAAM,eAAeI,EAA6B,OAC5CA,IACEA,GAAAC,EAAA,WAAW,SAAX,YAAAA,EAAmB,SAAS,MAG7B,MAAA,KAAK,sBAAsBC,EAAwBF,EAAK,KAAK,QAAQ,cAAgB,UAAU,CAAC,EAElG,KAAK,aAAe,KAAK,eAC5B,KAAK,cAAc,WAAY,CAAC,CAAE,YAAa,KAAK,YAAa,aAAc,KAAK,aAAc,OAAQ,KAAK,aAAA,CAAe,CAAC,CAEjI,CAQA,MAAM,WAAWA,EAAUJ,EAAyC,CAC5D,OAAA,MAAMO,EAAmBH,EAAKJ,CAAO,CAC7C,CACD"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./flows/RedirectFlow.cjs"),i=require("./flows/PopupFlow.cjs"),o=require("./storages/LocalStorage.cjs");require("./utils/handlers.cjs");require("./utils/constants.cjs");require("./State.cjs");require("./utils/crypto.cjs");require("./utils/base64Url.cjs");require("./utils/date.cjs");require("./flows/BaseFlow.cjs");require("./utils/jwt.cjs");require("./utils/fetch.cjs");require("./Metadata.cjs");require("./Session.cjs");function t(e){const r=e.storage||o.LocalStorage;return e.mode==="popup"?new i.PopupFlow(e,new r):new u.RedirectFlow(e,new r)}exports.initFlow=t;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import type { SDKOptions } from './types';\nimport { RedirectFlow } from './flows/RedirectFlow';\nimport { PopupFlow } from './flows/PopupFlow';\nimport { LocalStorage } from './storages/LocalStorage';\n\nexport type * from './types';\n\n/**\n * Initializes an authentication flow based on the specified mode.\n *\n * @param {SDKOptions & { mode?: 'popup' | 'redirect' }} options - The SDK options, including an optional mode. The default storage class is `LocalStorage`.\n * @returns {PopupFlow | RedirectFlow} A new instance of either PopupFlow or RedirectFlow based on the mode.\n */\nexport function initFlow(options: SDKOptions & { mode: 'popup' }): PopupFlow;\nexport function initFlow(options: SDKOptions & { mode: 'redirect' }): RedirectFlow;\nexport function initFlow(options: SDKOptions & { mode?: 'popup' | 'redirect' }): PopupFlow | RedirectFlow;\nexport function initFlow(options: SDKOptions & { mode?: 'popup' | 'redirect' }): PopupFlow | RedirectFlow {\n\tconst StorageClass = options.storage || LocalStorage;\n\n\tif (options.mode === 'popup') {\n\t\treturn new PopupFlow(options, new StorageClass());\n\t} else {\n\t\treturn new RedirectFlow(options, new StorageClass());\n\t}\n}\n"],"names":["initFlow","options","StorageClass","LocalStorage","PopupFlow","RedirectFlow"],"mappings":"sgBAgBO,SAASA,EAASC,EAAiF,CACnG,MAAAC,EAAeD,EAAQ,SAAWE,eAEpC,OAAAF,EAAQ,OAAS,QACb,IAAIG,EAAAA,UAAUH,EAAS,IAAIC,CAAc,EAEzC,IAAIG,EAAAA,aAAaJ,EAAS,IAAIC,CAAc,CAErD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SDKOptions } from './types';
|
|
2
|
+
import { RedirectFlow } from './flows/RedirectFlow';
|
|
3
|
+
import { PopupFlow } from './flows/PopupFlow';
|
|
4
|
+
export type * from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Initializes an authentication flow based on the specified mode.
|
|
7
|
+
*
|
|
8
|
+
* @param {SDKOptions & { mode?: 'popup' | 'redirect' }} options - The SDK options, including an optional mode. The default storage class is `LocalStorage`.
|
|
9
|
+
* @returns {PopupFlow | RedirectFlow} A new instance of either PopupFlow or RedirectFlow based on the mode.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initFlow(options: SDKOptions & {
|
|
12
|
+
mode: 'popup';
|
|
13
|
+
}): PopupFlow;
|
|
14
|
+
export declare function initFlow(options: SDKOptions & {
|
|
15
|
+
mode: 'redirect';
|
|
16
|
+
}): RedirectFlow;
|
|
17
|
+
export declare function initFlow(options: SDKOptions & {
|
|
18
|
+
mode?: 'popup' | 'redirect';
|
|
19
|
+
}): PopupFlow | RedirectFlow;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{RedirectFlow as t}from"./flows/RedirectFlow.mjs";import{PopupFlow as m}from"./flows/PopupFlow.mjs";import{LocalStorage as p}from"./storages/LocalStorage.mjs";import"./utils/handlers.mjs";import"./utils/constants.mjs";import"./State.mjs";import"./utils/crypto.mjs";import"./utils/base64Url.mjs";import"./utils/date.mjs";import"./flows/BaseFlow.mjs";import"./utils/jwt.mjs";import"./utils/fetch.mjs";import"./Metadata.mjs";import"./Session.mjs";function x(r){const o=r.storage||p;return r.mode==="popup"?new m(r,new o):new t(r,new o)}export{x as initFlow};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import type { SDKOptions } from './types';\nimport { RedirectFlow } from './flows/RedirectFlow';\nimport { PopupFlow } from './flows/PopupFlow';\nimport { LocalStorage } from './storages/LocalStorage';\n\nexport type * from './types';\n\n/**\n * Initializes an authentication flow based on the specified mode.\n *\n * @param {SDKOptions & { mode?: 'popup' | 'redirect' }} options - The SDK options, including an optional mode. The default storage class is `LocalStorage`.\n * @returns {PopupFlow | RedirectFlow} A new instance of either PopupFlow or RedirectFlow based on the mode.\n */\nexport function initFlow(options: SDKOptions & { mode: 'popup' }): PopupFlow;\nexport function initFlow(options: SDKOptions & { mode: 'redirect' }): RedirectFlow;\nexport function initFlow(options: SDKOptions & { mode?: 'popup' | 'redirect' }): PopupFlow | RedirectFlow;\nexport function initFlow(options: SDKOptions & { mode?: 'popup' | 'redirect' }): PopupFlow | RedirectFlow {\n\tconst StorageClass = options.storage || LocalStorage;\n\n\tif (options.mode === 'popup') {\n\t\treturn new PopupFlow(options, new StorageClass());\n\t} else {\n\t\treturn new RedirectFlow(options, new StorageClass());\n\t}\n}\n"],"names":["initFlow","options","StorageClass","LocalStorage","PopupFlow","RedirectFlow"],"mappings":"kcAgBO,SAASA,EAASC,EAAiF,CACnG,MAAAC,EAAeD,EAAQ,SAAWE,EAEpC,OAAAF,EAAQ,OAAS,QACb,IAAIG,EAAUH,EAAS,IAAIC,CAAc,EAEzC,IAAIG,EAAaJ,EAAS,IAAIC,CAAc,CAErD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class l{get(o){var e,t;return(t=(e=globalThis==null?void 0:globalThis.window)==null?void 0:e.localStorage)==null?void 0:t.getItem(o)}delete(o){var e;(e=globalThis==null?void 0:globalThis.window)==null||e.localStorage.removeItem(o)}set(o,e){var t;(t=globalThis==null?void 0:globalThis.window)==null||t.localStorage.setItem(o,e)}}exports.LocalStorage=l;
|
|
2
|
+
//# sourceMappingURL=LocalStorage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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\tget(key: string) {\n\t\treturn 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\tdelete(key: string) {\n\t\tglobalThis?.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\tset(key: string, value: string) {\n\t\tglobalThis?.window?.localStorage.setItem(key, value);\n\t}\n}\n"],"names":["LocalStorage","key","_b","_a","value"],"mappings":"gFAKO,MAAMA,CAAmC,CAM/C,IAAIC,EAAa,SAChB,OAAOC,GAAAC,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,eAApB,YAAAD,EAAkC,QAAQD,EAClD,CAMA,OAAOA,EAAa,QACPE,EAAA,mCAAA,SAAA,MAAAA,EAAQ,aAAa,WAAWF,EAC7C,CAOA,IAAIA,EAAaG,EAAe,QAC/BD,EAAA,mCAAY,SAAZ,MAAAA,EAAoB,aAAa,QAAQF,EAAKG,EAC/C,CACD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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): 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): 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): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
class a{get(o){var e,l;return(l=(e=globalThis==null?void 0:globalThis.window)==null?void 0:e.localStorage)==null?void 0:l.getItem(o)}delete(o){var e;(e=globalThis==null?void 0:globalThis.window)==null||e.localStorage.removeItem(o)}set(o,e){var l;(l=globalThis==null?void 0:globalThis.window)==null||l.localStorage.setItem(o,e)}}export{a as LocalStorage};
|
|
2
|
+
//# sourceMappingURL=LocalStorage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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\tget(key: string) {\n\t\treturn 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\tdelete(key: string) {\n\t\tglobalThis?.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\tset(key: string, value: string) {\n\t\tglobalThis?.window?.localStorage.setItem(key, value);\n\t}\n}\n"],"names":["LocalStorage","key","_a","_b","value"],"mappings":"AAKO,MAAMA,CAAmC,CAM/C,IAAIC,EAAa,CANX,IAAAC,EAAAC,EAOL,OAAOA,GAAAD,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,eAApB,YAAAC,EAAkC,QAAQF,EAClD,CAMA,OAAOA,EAAa,CAdd,IAAAC,GAeOA,EAAA,mCAAA,SAAA,MAAAA,EAAQ,aAAa,WAAWD,EAC7C,CAOA,IAAIA,EAAaG,EAAe,CAvB1B,IAAAF,GAwBLA,EAAA,mCAAY,SAAZ,MAAAA,EAAoB,aAAa,QAAQD,EAAKG,EAC/C,CACD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class t{get(s){var e,o;return(o=(e=globalThis==null?void 0:globalThis.window)==null?void 0:e.sessionStorage)==null?void 0:o.getItem(s)}delete(s){var e;(e=globalThis==null?void 0:globalThis.window)==null||e.sessionStorage.removeItem(s)}set(s,e){var o;(o=globalThis==null?void 0:globalThis.window)==null||o.sessionStorage.setItem(s,e)}}exports.SessionStorage=t;
|
|
2
|
+
//# sourceMappingURL=SessionStorage.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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\tget(key: string) {\n\t\treturn 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\tdelete(key: string) {\n\t\tglobalThis?.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\tset(key: string, value: string) {\n\t\tglobalThis?.window?.sessionStorage.setItem(key, value);\n\t}\n}\n"],"names":["SessionStorage","key","_b","_a","value"],"mappings":"gFAKO,MAAMA,CAAqC,CAMjD,IAAIC,EAAa,SAChB,OAAOC,GAAAC,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,iBAApB,YAAAD,EAAoC,QAAQD,EACpD,CAMA,OAAOA,EAAa,QACPE,EAAA,mCAAA,SAAA,MAAAA,EAAQ,eAAe,WAAWF,EAC/C,CAOA,IAAIA,EAAaG,EAAe,QAC/BD,EAAA,mCAAY,SAAZ,MAAAA,EAAoB,eAAe,QAAQF,EAAKG,EACjD,CACD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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): 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): 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): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
class i{get(s){var e,o;return(o=(e=globalThis==null?void 0:globalThis.window)==null?void 0:e.sessionStorage)==null?void 0:o.getItem(s)}delete(s){var e;(e=globalThis==null?void 0:globalThis.window)==null||e.sessionStorage.removeItem(s)}set(s,e){var o;(o=globalThis==null?void 0:globalThis.window)==null||o.sessionStorage.setItem(s,e)}}export{i as SessionStorage};
|
|
2
|
+
//# sourceMappingURL=SessionStorage.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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\tget(key: string) {\n\t\treturn 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\tdelete(key: string) {\n\t\tglobalThis?.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\tset(key: string, value: string) {\n\t\tglobalThis?.window?.sessionStorage.setItem(key, value);\n\t}\n}\n"],"names":["SessionStorage","key","_a","_b","value"],"mappings":"AAKO,MAAMA,CAAqC,CAMjD,IAAIC,EAAa,CANX,IAAAC,EAAAC,EAOL,OAAOA,GAAAD,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,iBAApB,YAAAC,EAAoC,QAAQF,EACpD,CAMA,OAAOA,EAAa,CAdd,IAAAC,GAeOA,EAAA,mCAAA,SAAA,MAAAA,EAAQ,eAAe,WAAWD,EAC/C,CAOA,IAAIA,EAAaG,EAAe,CAvB1B,IAAAF,GAwBLA,EAAA,mCAAY,SAAZ,MAAAA,EAAoB,eAAe,QAAQD,EAAKG,EACjD,CACD"}
|
package/dist/types.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=["code","id_token"],e=["query","fragment"],o=["none"],s=["authorization_code","refresh_token"],i=["RS256"],n=["public"],p=["none","login","create"],c=["redirect","popup"];class r{}const L=["item","group"];exports.AlgorithmTypeList=i;exports.FallbackModeTypeList=c;exports.GrantTypeList=s;exports.PromptTypeList=p;exports.ResponseModeList=e;exports.ResponseTypeList=t;exports.SDKStorage=r;exports.SelectOptionTypeList=L;exports.SubjectTypeList=n;exports.TokenEndpointAuthMethodList=o;
|
|
2
|
+
//# sourceMappingURL=types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.cjs","sources":["../src/types.ts"],"sourcesContent":["/**\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'}\n\t * @default 'redirect'\n\t */\n\tmode?: 'popup' | 'redirect';\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\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): 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): 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): void;\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 * 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\n/**\n * Options for configuring logout behavior.\n */\nexport type LogoutOptions = {\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 * List of select option types.\n */\nexport const SelectOptionTypeList = ['item', 'group'] as const;\n/**\n * Type representing valid select option types.\n */\nexport type SelectOptionType = (typeof SelectOptionTypeList)[number];\n\n/**\n * Data for branding purposes, such as logo and brand name.\n */\nexport type BrandingData = {\n\tlogoUrl: string | null;\n\tbrandName: string | null;\n\tcopyright: string | null;\n\tprivacyPolicyUrl: string | null;\n\tsiteTermsUrl: string | null;\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 PopupWindowParams = 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\n// endregion\n"],"names":["ResponseTypeList","ResponseModeList","TokenEndpointAuthMethodList","GrantTypeList","AlgorithmTypeList","SubjectTypeList","PromptTypeList","FallbackModeTypeList","SDKStorage","SelectOptionTypeList"],"mappings":"gFA6Ba,MAAAA,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,EA8ejD,MAAeC,CAAW,CAuBjC,CAiLa,MAAAC,EAAuB,CAAC,OAAQ,OAAO"}
|