@strivacity/sdk-core 2.1.0 → 2.1.2

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/flows/BaseFlow.cjs +1 -1
  3. package/dist/flows/BaseFlow.cjs.map +1 -1
  4. package/dist/flows/BaseFlow.mjs +1 -1
  5. package/dist/flows/BaseFlow.mjs.map +1 -1
  6. package/dist/flows/NativeFlow.cjs +1 -1
  7. package/dist/flows/NativeFlow.cjs.map +1 -1
  8. package/dist/flows/NativeFlow.mjs +1 -1
  9. package/dist/flows/NativeFlow.mjs.map +1 -1
  10. package/dist/flows/PopupFlow.cjs +1 -1
  11. package/dist/flows/PopupFlow.cjs.map +1 -1
  12. package/dist/flows/PopupFlow.mjs +1 -1
  13. package/dist/flows/PopupFlow.mjs.map +1 -1
  14. package/dist/flows/RedirectFlow.cjs +1 -1
  15. package/dist/flows/RedirectFlow.cjs.map +1 -1
  16. package/dist/flows/RedirectFlow.mjs +1 -1
  17. package/dist/flows/RedirectFlow.mjs.map +1 -1
  18. package/dist/storages/LocalStorage.cjs +1 -1
  19. package/dist/storages/LocalStorage.cjs.map +1 -1
  20. package/dist/storages/LocalStorage.mjs +1 -1
  21. package/dist/storages/LocalStorage.mjs.map +1 -1
  22. package/dist/storages/SessionStorage.cjs +1 -1
  23. package/dist/storages/SessionStorage.cjs.map +1 -1
  24. package/dist/storages/SessionStorage.mjs +1 -1
  25. package/dist/storages/SessionStorage.mjs.map +1 -1
  26. package/dist/utils/HttpClient.cjs.map +1 -1
  27. package/dist/utils/HttpClient.mjs.map +1 -1
  28. package/dist/utils/Metadata.cjs +1 -1
  29. package/dist/utils/Metadata.cjs.map +1 -1
  30. package/dist/utils/Metadata.mjs +1 -1
  31. package/dist/utils/Metadata.mjs.map +1 -1
  32. package/dist/utils/NativeFlowHandler.cjs +1 -1
  33. package/dist/utils/NativeFlowHandler.cjs.map +1 -1
  34. package/dist/utils/NativeFlowHandler.mjs +1 -1
  35. package/dist/utils/NativeFlowHandler.mjs.map +1 -1
  36. package/dist/utils/Session.cjs +1 -1
  37. package/dist/utils/Session.cjs.map +1 -1
  38. package/dist/utils/Session.mjs +1 -1
  39. package/dist/utils/Session.mjs.map +1 -1
  40. package/dist/utils/State.cjs +1 -1
  41. package/dist/utils/State.cjs.map +1 -1
  42. package/dist/utils/State.mjs +1 -1
  43. package/dist/utils/State.mjs.map +1 -1
  44. package/dist/utils/base64Url.cjs.map +1 -1
  45. package/dist/utils/base64Url.mjs.map +1 -1
  46. package/dist/utils/credentials.cjs +1 -1
  47. package/dist/utils/credentials.cjs.map +1 -1
  48. package/dist/utils/credentials.mjs +1 -1
  49. package/dist/utils/credentials.mjs.map +1 -1
  50. package/dist/utils/errors.cjs.map +1 -1
  51. package/dist/utils/errors.mjs.map +1 -1
  52. package/dist/utils/handlers.cjs +1 -1
  53. package/dist/utils/handlers.cjs.map +1 -1
  54. package/dist/utils/handlers.mjs +1 -1
  55. package/dist/utils/handlers.mjs.map +1 -1
  56. package/dist/utils/object.cjs.map +1 -1
  57. package/dist/utils/object.mjs.map +1 -1
  58. package/package.json +5 -2
@@ -1 +1 @@
1
- {"version":3,"file":"RedirectFlow.cjs","sources":["../../src/flows/RedirectFlow.ts"],"sourcesContent":["import type { SDKOptions, RedirectParams, SDKStorage, SDKHttpClient } from '../types';\nimport { redirectUrlHandler, redirectCallbackHandler } from '../utils/handlers';\nimport { State } from '../utils/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\tconstructor(options: SDKOptions, storage: SDKStorage, httpClient: SDKHttpClient) {\n\t\tif (!options.urlHandler) {\n\t\t\toptions.urlHandler = redirectUrlHandler;\n\t\t}\n\t\tif (!options.callbackHandler) {\n\t\t\toptions.callbackHandler = redirectCallbackHandler;\n\t\t}\n\n\t\tsuper(options, storage, httpClient);\n\t}\n\n\t/**\n\t * Initiates the login process via a redirect.\n\t * @param {RedirectParams} [params={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the login process completes.\n\t */\n\tasync login(params: RedirectParams = {}): Promise<void> {\n\t\tif (typeof this.options.urlHandler !== 'function') {\n\t\t\tthrow new Error('URL handler is not defined. Please provide a valid URL handler function in the SDK options.');\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst url = await this.getAuthorizationUrl(params);\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\tawait this.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tthis.dispatchEvent('loginInitiated', []);\n\n\t\tawait this.options.urlHandler(url.toString(), params);\n\t}\n\n\t/**\n\t * Initiates the registration process via a redirect.\n\t * @param {RedirectParams} [params={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the registration process completes.\n\t */\n\tasync register(params: RedirectParams = {}): Promise<void> {\n\t\tparams.prompt = 'create';\n\n\t\tawait this.login(params);\n\t}\n\n\t/**\n\t * Initiates the entry process via a redirect.\n\t * @param {string} url Optional URL to use for the entry process. If not provided, the current window location will be used.\n\t * @returns {Promise<void>} A promise that resolves when the entry process completes.\n\t */\n\tasync entry(url?: string): Promise<void> {\n\t\tif (typeof this.options.urlHandler !== 'function') {\n\t\t\tthrow new Error('URL handler is not defined. Please provide a valid URL handler function in the SDK options.');\n\t\t}\n\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tconst entryUrl = new URL(url);\n\n\t\tawait this.options.urlHandler(`${this.options.issuer}/provider/entry?${entryUrl.searchParams.toString()}`);\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 (typeof this.options.callbackHandler !== 'function') {\n\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t}\n\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tawait this.tokenExchange((await this.options.callbackHandler(url, this.options.responseMode || 'fragment')) as Record<string, string>);\n\t}\n}\n"],"names":["RedirectFlow","BaseFlow","options","storage","httpClient","redirectUrlHandler","redirectCallbackHandler","params","state","State","url","_a","entryUrl"],"mappings":"gXAQO,MAAMA,UAAqBC,EAAAA,QAAqC,CACtE,YAAYC,EAAqBC,EAAqBC,EAA2B,CAC3EF,EAAQ,aACZA,EAAQ,WAAaG,EAAAA,oBAEjBH,EAAQ,kBACZA,EAAQ,gBAAkBI,EAAAA,yBAG3B,MAAMJ,EAASC,EAASC,CAAU,CAAA,CAQnC,MAAM,MAAMG,EAAyB,GAAmB,CACvD,GAAI,OAAO,KAAK,QAAQ,YAAe,WACtC,MAAM,IAAI,MAAM,6FAA6F,EAG9G,MAAMC,EAAQ,MAAMC,EAAAA,MAAM,OAAA,EACpBC,EAAM,MAAM,KAAK,oBAAoBH,CAAM,EAEjDG,EAAI,aAAa,OAAO,QAASF,EAAM,EAAE,EACzCE,EAAI,aAAa,OAAO,iBAAkBF,EAAM,aAAa,EAC7DE,EAAI,aAAa,OAAO,QAASF,EAAM,KAAK,EAE5C,MAAM,KAAK,QAAQ,IAAI,OAAOA,EAAM,EAAE,GAAI,KAAK,UAAUA,CAAK,CAAC,EAE/D,KAAK,cAAc,iBAAkB,EAAE,EAEvC,MAAM,KAAK,QAAQ,WAAWE,EAAI,SAAA,EAAYH,CAAM,CAAA,CAQrD,MAAM,SAASA,EAAyB,GAAmB,CAC1DA,EAAO,OAAS,SAEhB,MAAM,KAAK,MAAMA,CAAM,CAAA,CAQxB,MAAM,MAAMG,EAA6B,OACxC,GAAI,OAAO,KAAK,QAAQ,YAAe,WACtC,MAAM,IAAI,MAAM,6FAA6F,EAGzGA,IACJA,GAAMC,EAAA,WAAW,SAAX,YAAAA,EAAmB,SAAS,MAGnC,MAAMC,EAAW,IAAI,IAAIF,CAAG,EAE5B,MAAM,KAAK,QAAQ,WAAW,GAAG,KAAK,QAAQ,MAAM,mBAAmBE,EAAS,aAAa,SAAA,CAAU,EAAE,CAAA,CAQ1G,MAAM,eAAeF,EAA6B,OACjD,GAAI,OAAO,KAAK,QAAQ,iBAAoB,WAC3C,MAAM,IAAI,MAAM,uGAAuG,EAGnHA,IACJA,GAAMC,EAAA,WAAW,SAAX,YAAAA,EAAmB,SAAS,MAGnC,MAAM,KAAK,cAAe,MAAM,KAAK,QAAQ,gBAAgBD,EAAK,KAAK,QAAQ,cAAgB,UAAU,CAA4B,CAAA,CAEvI"}
1
+ {"version":3,"file":"RedirectFlow.cjs","sources":["../../src/flows/RedirectFlow.ts"],"sourcesContent":["import type { SDKOptions, RedirectParams, SDKStorage, SDKHttpClient } from '../types';\nimport { redirectUrlHandler, redirectCallbackHandler } from '../utils/handlers';\nimport { State } from '../utils/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\tconstructor(options: SDKOptions, storage: SDKStorage, httpClient: SDKHttpClient) {\n\t\tif (!options.urlHandler) {\n\t\t\toptions.urlHandler = redirectUrlHandler;\n\t\t}\n\t\tif (!options.callbackHandler) {\n\t\t\toptions.callbackHandler = redirectCallbackHandler;\n\t\t}\n\n\t\tsuper(options, storage, httpClient);\n\t}\n\n\t/**\n\t * Initiates the login process via a redirect.\n\t * @param {RedirectParams} [params={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the login process completes.\n\t */\n\tasync login(params: RedirectParams = {}): Promise<void> {\n\t\tif (typeof this.options.urlHandler !== 'function') {\n\t\t\tthrow new Error('URL handler is not defined. Please provide a valid URL handler function in the SDK options.');\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst url = await this.getAuthorizationUrl(params);\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\tawait this.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tthis.dispatchEvent('loginInitiated', []);\n\n\t\tawait this.options.urlHandler(url.toString(), params);\n\t}\n\n\t/**\n\t * Initiates the registration process via a redirect.\n\t * @param {RedirectParams} [params={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the registration process completes.\n\t */\n\tasync register(params: RedirectParams = {}): Promise<void> {\n\t\tparams.prompt = 'create';\n\n\t\tawait this.login(params);\n\t}\n\n\t/**\n\t * Initiates the entry process via a redirect.\n\t * @param {string} url Optional URL to use for the entry process. If not provided, the current window location will be used.\n\t * @returns {Promise<void>} A promise that resolves when the entry process completes.\n\t */\n\tasync entry(url?: string): Promise<void> {\n\t\tif (typeof this.options.urlHandler !== 'function') {\n\t\t\tthrow new Error('URL handler is not defined. Please provide a valid URL handler function in the SDK options.');\n\t\t}\n\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tconst entryUrl = new URL(url);\n\n\t\tawait this.options.urlHandler(`${this.options.issuer}/provider/entry?${entryUrl.searchParams.toString()}`);\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 (typeof this.options.callbackHandler !== 'function') {\n\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t}\n\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tawait this.tokenExchange((await this.options.callbackHandler(url, this.options.responseMode || 'fragment')) as Record<string, string>);\n\t}\n}\n"],"names":["RedirectFlow","BaseFlow","options","storage","httpClient","redirectUrlHandler","redirectCallbackHandler","params","state","State","url","entryUrl"],"mappings":"gXAQO,MAAMA,UAAqBC,EAAAA,QAAqC,CACtE,YAAYC,EAAqBC,EAAqBC,EAA2B,CAC3EF,EAAQ,aACZA,EAAQ,WAAaG,EAAAA,oBAEjBH,EAAQ,kBACZA,EAAQ,gBAAkBI,EAAAA,yBAG3B,MAAMJ,EAASC,EAASC,CAAU,CACnC,CAOA,MAAM,MAAMG,EAAyB,GAAmB,CACvD,GAAI,OAAO,KAAK,QAAQ,YAAe,WACtC,MAAM,IAAI,MAAM,6FAA6F,EAG9G,MAAMC,EAAQ,MAAMC,EAAAA,MAAM,OAAA,EACpBC,EAAM,MAAM,KAAK,oBAAoBH,CAAM,EAEjDG,EAAI,aAAa,OAAO,QAASF,EAAM,EAAE,EACzCE,EAAI,aAAa,OAAO,iBAAkBF,EAAM,aAAa,EAC7DE,EAAI,aAAa,OAAO,QAASF,EAAM,KAAK,EAE5C,MAAM,KAAK,QAAQ,IAAI,OAAOA,EAAM,EAAE,GAAI,KAAK,UAAUA,CAAK,CAAC,EAE/D,KAAK,cAAc,iBAAkB,EAAE,EAEvC,MAAM,KAAK,QAAQ,WAAWE,EAAI,SAAA,EAAYH,CAAM,CACrD,CAOA,MAAM,SAASA,EAAyB,GAAmB,CAC1DA,EAAO,OAAS,SAEhB,MAAM,KAAK,MAAMA,CAAM,CACxB,CAOA,MAAM,MAAMG,EAA6B,CACxC,GAAI,OAAO,KAAK,QAAQ,YAAe,WACtC,MAAM,IAAI,MAAM,6FAA6F,EAGzGA,IACJA,EAAM,WAAW,QAAQ,SAAS,MAGnC,MAAMC,EAAW,IAAI,IAAID,CAAG,EAE5B,MAAM,KAAK,QAAQ,WAAW,GAAG,KAAK,QAAQ,MAAM,mBAAmBC,EAAS,aAAa,SAAA,CAAU,EAAE,CAC1G,CAOA,MAAM,eAAeD,EAA6B,CACjD,GAAI,OAAO,KAAK,QAAQ,iBAAoB,WAC3C,MAAM,IAAI,MAAM,uGAAuG,EAGnHA,IACJA,EAAM,WAAW,QAAQ,SAAS,MAGnC,MAAM,KAAK,cAAe,MAAM,KAAK,QAAQ,gBAAgBA,EAAK,KAAK,QAAQ,cAAgB,UAAU,CAA4B,CACtI,CACD"}
@@ -1,2 +1,2 @@
1
- import{redirectUrlHandler as i,redirectCallbackHandler as n}from"../utils/handlers.mjs";import{State as r}from"../utils/State.mjs";import{BaseFlow as o}from"./BaseFlow.mjs";import"../utils/crypto.mjs";import"../utils/base64Url.mjs";import"../utils/date.mjs";import"../utils/jwt.mjs";import"../utils/Metadata.mjs";import"../utils/Session.mjs";class u extends o{constructor(e,t,a){e.urlHandler||(e.urlHandler=i),e.callbackHandler||(e.callbackHandler=n),super(e,t,a)}async login(e={}){if(typeof this.options.urlHandler!="function")throw new Error("URL handler is not defined. Please provide a valid URL handler function in the SDK options.");const t=await r.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),await this.storage.set(`sty.${t.id}`,JSON.stringify(t)),this.dispatchEvent("loginInitiated",[]),await this.options.urlHandler(a.toString(),e)}async register(e={}){e.prompt="create",await this.login(e)}async entry(e){var a;if(typeof this.options.urlHandler!="function")throw new Error("URL handler is not defined. Please provide a valid URL handler function in the SDK options.");e||(e=(a=globalThis.window)==null?void 0:a.location.href);const t=new URL(e);await this.options.urlHandler(`${this.options.issuer}/provider/entry?${t.searchParams.toString()}`)}async handleCallback(e){var t;if(typeof this.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");e||(e=(t=globalThis.window)==null?void 0:t.location.href),await this.tokenExchange(await this.options.callbackHandler(e,this.options.responseMode||"fragment"))}}export{u as RedirectFlow};
1
+ import{redirectUrlHandler as i,redirectCallbackHandler as n}from"../utils/handlers.mjs";import{State as r}from"../utils/State.mjs";import{BaseFlow as o}from"./BaseFlow.mjs";import"../utils/crypto.mjs";import"../utils/base64Url.mjs";import"../utils/date.mjs";import"../utils/jwt.mjs";import"../utils/Metadata.mjs";import"../utils/Session.mjs";class u extends o{constructor(e,t,a){e.urlHandler||(e.urlHandler=i),e.callbackHandler||(e.callbackHandler=n),super(e,t,a)}async login(e={}){if(typeof this.options.urlHandler!="function")throw new Error("URL handler is not defined. Please provide a valid URL handler function in the SDK options.");const t=await r.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),await this.storage.set(`sty.${t.id}`,JSON.stringify(t)),this.dispatchEvent("loginInitiated",[]),await this.options.urlHandler(a.toString(),e)}async register(e={}){e.prompt="create",await this.login(e)}async entry(e){if(typeof this.options.urlHandler!="function")throw new Error("URL handler is not defined. Please provide a valid URL handler function in the SDK options.");e||(e=globalThis.window?.location.href);const t=new URL(e);await this.options.urlHandler(`${this.options.issuer}/provider/entry?${t.searchParams.toString()}`)}async handleCallback(e){if(typeof this.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");e||(e=globalThis.window?.location.href),await this.tokenExchange(await this.options.callbackHandler(e,this.options.responseMode||"fragment"))}}export{u as RedirectFlow};
2
2
  //# sourceMappingURL=RedirectFlow.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"RedirectFlow.mjs","sources":["../../src/flows/RedirectFlow.ts"],"sourcesContent":["import type { SDKOptions, RedirectParams, SDKStorage, SDKHttpClient } from '../types';\nimport { redirectUrlHandler, redirectCallbackHandler } from '../utils/handlers';\nimport { State } from '../utils/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\tconstructor(options: SDKOptions, storage: SDKStorage, httpClient: SDKHttpClient) {\n\t\tif (!options.urlHandler) {\n\t\t\toptions.urlHandler = redirectUrlHandler;\n\t\t}\n\t\tif (!options.callbackHandler) {\n\t\t\toptions.callbackHandler = redirectCallbackHandler;\n\t\t}\n\n\t\tsuper(options, storage, httpClient);\n\t}\n\n\t/**\n\t * Initiates the login process via a redirect.\n\t * @param {RedirectParams} [params={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the login process completes.\n\t */\n\tasync login(params: RedirectParams = {}): Promise<void> {\n\t\tif (typeof this.options.urlHandler !== 'function') {\n\t\t\tthrow new Error('URL handler is not defined. Please provide a valid URL handler function in the SDK options.');\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst url = await this.getAuthorizationUrl(params);\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\tawait this.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tthis.dispatchEvent('loginInitiated', []);\n\n\t\tawait this.options.urlHandler(url.toString(), params);\n\t}\n\n\t/**\n\t * Initiates the registration process via a redirect.\n\t * @param {RedirectParams} [params={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the registration process completes.\n\t */\n\tasync register(params: RedirectParams = {}): Promise<void> {\n\t\tparams.prompt = 'create';\n\n\t\tawait this.login(params);\n\t}\n\n\t/**\n\t * Initiates the entry process via a redirect.\n\t * @param {string} url Optional URL to use for the entry process. If not provided, the current window location will be used.\n\t * @returns {Promise<void>} A promise that resolves when the entry process completes.\n\t */\n\tasync entry(url?: string): Promise<void> {\n\t\tif (typeof this.options.urlHandler !== 'function') {\n\t\t\tthrow new Error('URL handler is not defined. Please provide a valid URL handler function in the SDK options.');\n\t\t}\n\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tconst entryUrl = new URL(url);\n\n\t\tawait this.options.urlHandler(`${this.options.issuer}/provider/entry?${entryUrl.searchParams.toString()}`);\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 (typeof this.options.callbackHandler !== 'function') {\n\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t}\n\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tawait this.tokenExchange((await this.options.callbackHandler(url, this.options.responseMode || 'fragment')) as Record<string, string>);\n\t}\n}\n"],"names":["RedirectFlow","BaseFlow","options","storage","httpClient","redirectUrlHandler","redirectCallbackHandler","params","state","State","url","_a","entryUrl"],"mappings":"sVAQO,MAAMA,UAAqBC,CAAqC,CACtE,YAAYC,EAAqBC,EAAqBC,EAA2B,CAC3EF,EAAQ,aACZA,EAAQ,WAAaG,GAEjBH,EAAQ,kBACZA,EAAQ,gBAAkBI,GAG3B,MAAMJ,EAASC,EAASC,CAAU,CAAA,CAQnC,MAAM,MAAMG,EAAyB,GAAmB,CACvD,GAAI,OAAO,KAAK,QAAQ,YAAe,WACtC,MAAM,IAAI,MAAM,6FAA6F,EAG9G,MAAMC,EAAQ,MAAMC,EAAM,OAAA,EACpBC,EAAM,MAAM,KAAK,oBAAoBH,CAAM,EAEjDG,EAAI,aAAa,OAAO,QAASF,EAAM,EAAE,EACzCE,EAAI,aAAa,OAAO,iBAAkBF,EAAM,aAAa,EAC7DE,EAAI,aAAa,OAAO,QAASF,EAAM,KAAK,EAE5C,MAAM,KAAK,QAAQ,IAAI,OAAOA,EAAM,EAAE,GAAI,KAAK,UAAUA,CAAK,CAAC,EAE/D,KAAK,cAAc,iBAAkB,EAAE,EAEvC,MAAM,KAAK,QAAQ,WAAWE,EAAI,SAAA,EAAYH,CAAM,CAAA,CAQrD,MAAM,SAASA,EAAyB,GAAmB,CAC1DA,EAAO,OAAS,SAEhB,MAAM,KAAK,MAAMA,CAAM,CAAA,CAQxB,MAAM,MAAMG,EAA6B,OACxC,GAAI,OAAO,KAAK,QAAQ,YAAe,WACtC,MAAM,IAAI,MAAM,6FAA6F,EAGzGA,IACJA,GAAMC,EAAA,WAAW,SAAX,YAAAA,EAAmB,SAAS,MAGnC,MAAMC,EAAW,IAAI,IAAIF,CAAG,EAE5B,MAAM,KAAK,QAAQ,WAAW,GAAG,KAAK,QAAQ,MAAM,mBAAmBE,EAAS,aAAa,SAAA,CAAU,EAAE,CAAA,CAQ1G,MAAM,eAAeF,EAA6B,OACjD,GAAI,OAAO,KAAK,QAAQ,iBAAoB,WAC3C,MAAM,IAAI,MAAM,uGAAuG,EAGnHA,IACJA,GAAMC,EAAA,WAAW,SAAX,YAAAA,EAAmB,SAAS,MAGnC,MAAM,KAAK,cAAe,MAAM,KAAK,QAAQ,gBAAgBD,EAAK,KAAK,QAAQ,cAAgB,UAAU,CAA4B,CAAA,CAEvI"}
1
+ {"version":3,"file":"RedirectFlow.mjs","sources":["../../src/flows/RedirectFlow.ts"],"sourcesContent":["import type { SDKOptions, RedirectParams, SDKStorage, SDKHttpClient } from '../types';\nimport { redirectUrlHandler, redirectCallbackHandler } from '../utils/handlers';\nimport { State } from '../utils/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\tconstructor(options: SDKOptions, storage: SDKStorage, httpClient: SDKHttpClient) {\n\t\tif (!options.urlHandler) {\n\t\t\toptions.urlHandler = redirectUrlHandler;\n\t\t}\n\t\tif (!options.callbackHandler) {\n\t\t\toptions.callbackHandler = redirectCallbackHandler;\n\t\t}\n\n\t\tsuper(options, storage, httpClient);\n\t}\n\n\t/**\n\t * Initiates the login process via a redirect.\n\t * @param {RedirectParams} [params={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the login process completes.\n\t */\n\tasync login(params: RedirectParams = {}): Promise<void> {\n\t\tif (typeof this.options.urlHandler !== 'function') {\n\t\t\tthrow new Error('URL handler is not defined. Please provide a valid URL handler function in the SDK options.');\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst url = await this.getAuthorizationUrl(params);\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\tawait this.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tthis.dispatchEvent('loginInitiated', []);\n\n\t\tawait this.options.urlHandler(url.toString(), params);\n\t}\n\n\t/**\n\t * Initiates the registration process via a redirect.\n\t * @param {RedirectParams} [params={}] Optional parameters for redirect configuration.\n\t * @returns {Promise<void>} A promise that resolves when the registration process completes.\n\t */\n\tasync register(params: RedirectParams = {}): Promise<void> {\n\t\tparams.prompt = 'create';\n\n\t\tawait this.login(params);\n\t}\n\n\t/**\n\t * Initiates the entry process via a redirect.\n\t * @param {string} url Optional URL to use for the entry process. If not provided, the current window location will be used.\n\t * @returns {Promise<void>} A promise that resolves when the entry process completes.\n\t */\n\tasync entry(url?: string): Promise<void> {\n\t\tif (typeof this.options.urlHandler !== 'function') {\n\t\t\tthrow new Error('URL handler is not defined. Please provide a valid URL handler function in the SDK options.');\n\t\t}\n\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tconst entryUrl = new URL(url);\n\n\t\tawait this.options.urlHandler(`${this.options.issuer}/provider/entry?${entryUrl.searchParams.toString()}`);\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 (typeof this.options.callbackHandler !== 'function') {\n\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t}\n\n\t\tif (!url) {\n\t\t\turl = globalThis.window?.location.href;\n\t\t}\n\n\t\tawait this.tokenExchange((await this.options.callbackHandler(url, this.options.responseMode || 'fragment')) as Record<string, string>);\n\t}\n}\n"],"names":["RedirectFlow","BaseFlow","options","storage","httpClient","redirectUrlHandler","redirectCallbackHandler","params","state","State","url","entryUrl"],"mappings":"sVAQO,MAAMA,UAAqBC,CAAqC,CACtE,YAAYC,EAAqBC,EAAqBC,EAA2B,CAC3EF,EAAQ,aACZA,EAAQ,WAAaG,GAEjBH,EAAQ,kBACZA,EAAQ,gBAAkBI,GAG3B,MAAMJ,EAASC,EAASC,CAAU,CACnC,CAOA,MAAM,MAAMG,EAAyB,GAAmB,CACvD,GAAI,OAAO,KAAK,QAAQ,YAAe,WACtC,MAAM,IAAI,MAAM,6FAA6F,EAG9G,MAAMC,EAAQ,MAAMC,EAAM,OAAA,EACpBC,EAAM,MAAM,KAAK,oBAAoBH,CAAM,EAEjDG,EAAI,aAAa,OAAO,QAASF,EAAM,EAAE,EACzCE,EAAI,aAAa,OAAO,iBAAkBF,EAAM,aAAa,EAC7DE,EAAI,aAAa,OAAO,QAASF,EAAM,KAAK,EAE5C,MAAM,KAAK,QAAQ,IAAI,OAAOA,EAAM,EAAE,GAAI,KAAK,UAAUA,CAAK,CAAC,EAE/D,KAAK,cAAc,iBAAkB,EAAE,EAEvC,MAAM,KAAK,QAAQ,WAAWE,EAAI,SAAA,EAAYH,CAAM,CACrD,CAOA,MAAM,SAASA,EAAyB,GAAmB,CAC1DA,EAAO,OAAS,SAEhB,MAAM,KAAK,MAAMA,CAAM,CACxB,CAOA,MAAM,MAAMG,EAA6B,CACxC,GAAI,OAAO,KAAK,QAAQ,YAAe,WACtC,MAAM,IAAI,MAAM,6FAA6F,EAGzGA,IACJA,EAAM,WAAW,QAAQ,SAAS,MAGnC,MAAMC,EAAW,IAAI,IAAID,CAAG,EAE5B,MAAM,KAAK,QAAQ,WAAW,GAAG,KAAK,QAAQ,MAAM,mBAAmBC,EAAS,aAAa,SAAA,CAAU,EAAE,CAC1G,CAOA,MAAM,eAAeD,EAA6B,CACjD,GAAI,OAAO,KAAK,QAAQ,iBAAoB,WAC3C,MAAM,IAAI,MAAM,uGAAuG,EAGnHA,IACJA,EAAM,WAAW,QAAQ,SAAS,MAGnC,MAAM,KAAK,cAAe,MAAM,KAAK,QAAQ,gBAAgBA,EAAK,KAAK,QAAQ,cAAgB,UAAU,CAA4B,CACtI,CACD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class t{async get(o){var e,a;return await Promise.resolve((a=(e=globalThis==null?void 0:globalThis.window)==null?void 0:e.localStorage)==null?void 0:a.getItem(o))}async delete(o){var e;await Promise.resolve((e=globalThis==null?void 0:globalThis.window)==null?void 0:e.localStorage.removeItem(o))}async set(o,e){var a;await Promise.resolve((a=globalThis==null?void 0:globalThis.window)==null?void 0:a.localStorage.setItem(o,e))}}exports.LocalStorage=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class a{async get(e){return await Promise.resolve(globalThis?.window?.localStorage?.getItem(e))}async delete(e){await Promise.resolve(globalThis?.window?.localStorage.removeItem(e))}async set(e,o){await Promise.resolve(globalThis?.window?.localStorage.setItem(e,o))}}exports.LocalStorage=a;
2
2
  //# sourceMappingURL=LocalStorage.cjs.map
@@ -1 +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\tasync get(key: string): Promise<string | null> {\n\t\treturn await Promise.resolve(globalThis?.window?.localStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from local storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in local storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.setItem(key, value));\n\t}\n}\n"],"names":["LocalStorage","key","_b","_a","value"],"mappings":"gFAKO,MAAMA,CAAmC,CAM/C,MAAM,IAAIC,EAAqC,SAC9C,OAAO,MAAM,QAAQ,SAAQC,GAAAC,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,eAApB,YAAAD,EAAkC,QAAQD,EAAI,CAAA,CAO5E,MAAM,OAAOA,EAA4B,OACxC,MAAM,QAAQ,SAAQE,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,aAAa,WAAWF,EAAI,CAAA,CAQvE,MAAM,IAAIA,EAAaG,EAA8B,OACpD,MAAM,QAAQ,SAAQD,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,aAAa,QAAQF,EAAKG,EAAM,CAAA,CAE5E"}
1
+ {"version":3,"file":"LocalStorage.cjs","sources":["../../src/storages/LocalStorage.ts"],"sourcesContent":["import type { SDKStorage } from '../types';\n\n/**\n * Implements local storage operations using the browser's `localStorage`.\n */\nexport class LocalStorage implements SDKStorage {\n\t/**\n\t * Retrieves a value from local storage by key.\n\t * @param {string} key The key to retrieve the value for.\n\t * @returns {string | null} The value associated with the key, or null if not found.\n\t */\n\tasync get(key: string): Promise<string | null> {\n\t\treturn await Promise.resolve(globalThis?.window?.localStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from local storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in local storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.setItem(key, value));\n\t}\n}\n"],"names":["LocalStorage","key","value"],"mappings":"gFAKO,MAAMA,CAAmC,CAM/C,MAAM,IAAIC,EAAqC,CAC9C,OAAO,MAAM,QAAQ,QAAQ,YAAY,QAAQ,cAAc,QAAQA,CAAG,CAAC,CAC5E,CAMA,MAAM,OAAOA,EAA4B,CACxC,MAAM,QAAQ,QAAQ,YAAY,QAAQ,aAAa,WAAWA,CAAG,CAAC,CACvE,CAOA,MAAM,IAAIA,EAAaC,EAA8B,CACpD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,aAAa,QAAQD,EAAKC,CAAK,CAAC,CAC3E,CACD"}
@@ -1,2 +1,2 @@
1
- class t{async get(o){var e,a;return await Promise.resolve((a=(e=globalThis==null?void 0:globalThis.window)==null?void 0:e.localStorage)==null?void 0:a.getItem(o))}async delete(o){var e;await Promise.resolve((e=globalThis==null?void 0:globalThis.window)==null?void 0:e.localStorage.removeItem(o))}async set(o,e){var a;await Promise.resolve((a=globalThis==null?void 0:globalThis.window)==null?void 0:a.localStorage.setItem(o,e))}}export{t as LocalStorage};
1
+ class l{async get(e){return await Promise.resolve(globalThis?.window?.localStorage?.getItem(e))}async delete(e){await Promise.resolve(globalThis?.window?.localStorage.removeItem(e))}async set(e,o){await Promise.resolve(globalThis?.window?.localStorage.setItem(e,o))}}export{l as LocalStorage};
2
2
  //# sourceMappingURL=LocalStorage.mjs.map
@@ -1 +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\tasync get(key: string): Promise<string | null> {\n\t\treturn await Promise.resolve(globalThis?.window?.localStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from local storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in local storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.setItem(key, value));\n\t}\n}\n"],"names":["LocalStorage","key","_a","_b","value"],"mappings":"AAKO,MAAMA,CAAmC,CAM/C,MAAM,IAAIC,EAAqC,CANzC,IAAAC,EAAAC,EAOL,OAAO,MAAM,QAAQ,SAAQA,GAAAD,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,eAApB,YAAAC,EAAkC,QAAQF,EAAI,CAAA,CAO5E,MAAM,OAAOA,EAA4B,CAdnC,IAAAC,EAeL,MAAM,QAAQ,SAAQA,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,aAAa,WAAWD,EAAI,CAAA,CAQvE,MAAM,IAAIA,EAAaG,EAA8B,CAvB/C,IAAAF,EAwBL,MAAM,QAAQ,SAAQA,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,aAAa,QAAQD,EAAKG,EAAM,CAAA,CAE5E"}
1
+ {"version":3,"file":"LocalStorage.mjs","sources":["../../src/storages/LocalStorage.ts"],"sourcesContent":["import type { SDKStorage } from '../types';\n\n/**\n * Implements local storage operations using the browser's `localStorage`.\n */\nexport class LocalStorage implements SDKStorage {\n\t/**\n\t * Retrieves a value from local storage by key.\n\t * @param {string} key The key to retrieve the value for.\n\t * @returns {string | null} The value associated with the key, or null if not found.\n\t */\n\tasync get(key: string): Promise<string | null> {\n\t\treturn await Promise.resolve(globalThis?.window?.localStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from local storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in local storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.localStorage.setItem(key, value));\n\t}\n}\n"],"names":["LocalStorage","key","value"],"mappings":"AAKO,MAAMA,CAAmC,CAM/C,MAAM,IAAIC,EAAqC,CAC9C,OAAO,MAAM,QAAQ,QAAQ,YAAY,QAAQ,cAAc,QAAQA,CAAG,CAAC,CAC5E,CAMA,MAAM,OAAOA,EAA4B,CACxC,MAAM,QAAQ,QAAQ,YAAY,QAAQ,aAAa,WAAWA,CAAG,CAAC,CACvE,CAOA,MAAM,IAAIA,EAAaC,EAA8B,CACpD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,aAAa,QAAQD,EAAKC,CAAK,CAAC,CAC3E,CACD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class t{async get(s){var e,o;return Promise.resolve((o=(e=globalThis==null?void 0:globalThis.window)==null?void 0:e.sessionStorage)==null?void 0:o.getItem(s))}async delete(s){var e;await Promise.resolve((e=globalThis==null?void 0:globalThis.window)==null?void 0:e.sessionStorage.removeItem(s))}async set(s,e){var o;await Promise.resolve((o=globalThis==null?void 0:globalThis.window)==null?void 0:o.sessionStorage.setItem(s,e))}}exports.SessionStorage=t;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class o{async get(e){return Promise.resolve(globalThis?.window?.sessionStorage?.getItem(e))}async delete(e){await Promise.resolve(globalThis?.window?.sessionStorage.removeItem(e))}async set(e,s){await Promise.resolve(globalThis?.window?.sessionStorage.setItem(e,s))}}exports.SessionStorage=o;
2
2
  //# sourceMappingURL=SessionStorage.cjs.map
@@ -1 +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\tasync get(key: string): Promise<string | null> {\n\t\treturn Promise.resolve(globalThis?.window?.sessionStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from session storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in session storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.setItem(key, value));\n\t}\n}\n"],"names":["SessionStorage","key","_b","_a","value"],"mappings":"gFAKO,MAAMA,CAAqC,CAMjD,MAAM,IAAIC,EAAqC,SAC9C,OAAO,QAAQ,SAAQC,GAAAC,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,iBAApB,YAAAD,EAAoC,QAAQD,EAAI,CAAA,CAOxE,MAAM,OAAOA,EAA4B,OACxC,MAAM,QAAQ,SAAQE,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,eAAe,WAAWF,EAAI,CAAA,CAQzE,MAAM,IAAIA,EAAaG,EAA8B,OACpD,MAAM,QAAQ,SAAQD,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,eAAe,QAAQF,EAAKG,EAAM,CAAA,CAE9E"}
1
+ {"version":3,"file":"SessionStorage.cjs","sources":["../../src/storages/SessionStorage.ts"],"sourcesContent":["import type { SDKStorage } from '../types';\n\n/**\n * Implements session storage operations using the browser's `sessionStorage`.\n */\nexport class SessionStorage implements SDKStorage {\n\t/**\n\t * Retrieves a value from session storage by key.\n\t * @param {string} key The key to retrieve the value for.\n\t * @returns {string | null} The value associated with the key, or null if not found.\n\t */\n\tasync get(key: string): Promise<string | null> {\n\t\treturn Promise.resolve(globalThis?.window?.sessionStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from session storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in session storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.setItem(key, value));\n\t}\n}\n"],"names":["SessionStorage","key","value"],"mappings":"gFAKO,MAAMA,CAAqC,CAMjD,MAAM,IAAIC,EAAqC,CAC9C,OAAO,QAAQ,QAAQ,YAAY,QAAQ,gBAAgB,QAAQA,CAAG,CAAC,CACxE,CAMA,MAAM,OAAOA,EAA4B,CACxC,MAAM,QAAQ,QAAQ,YAAY,QAAQ,eAAe,WAAWA,CAAG,CAAC,CACzE,CAOA,MAAM,IAAIA,EAAaC,EAA8B,CACpD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,eAAe,QAAQD,EAAKC,CAAK,CAAC,CAC7E,CACD"}
@@ -1,2 +1,2 @@
1
- class a{async get(s){var e,o;return Promise.resolve((o=(e=globalThis==null?void 0:globalThis.window)==null?void 0:e.sessionStorage)==null?void 0:o.getItem(s))}async delete(s){var e;await Promise.resolve((e=globalThis==null?void 0:globalThis.window)==null?void 0:e.sessionStorage.removeItem(s))}async set(s,e){var o;await Promise.resolve((o=globalThis==null?void 0:globalThis.window)==null?void 0:o.sessionStorage.setItem(s,e))}}export{a as SessionStorage};
1
+ class t{async get(e){return Promise.resolve(globalThis?.window?.sessionStorage?.getItem(e))}async delete(e){await Promise.resolve(globalThis?.window?.sessionStorage.removeItem(e))}async set(e,s){await Promise.resolve(globalThis?.window?.sessionStorage.setItem(e,s))}}export{t as SessionStorage};
2
2
  //# sourceMappingURL=SessionStorage.mjs.map
@@ -1 +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\tasync get(key: string): Promise<string | null> {\n\t\treturn Promise.resolve(globalThis?.window?.sessionStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from session storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in session storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.setItem(key, value));\n\t}\n}\n"],"names":["SessionStorage","key","_a","_b","value"],"mappings":"AAKO,MAAMA,CAAqC,CAMjD,MAAM,IAAIC,EAAqC,CANzC,IAAAC,EAAAC,EAOL,OAAO,QAAQ,SAAQA,GAAAD,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,iBAApB,YAAAC,EAAoC,QAAQF,EAAI,CAAA,CAOxE,MAAM,OAAOA,EAA4B,CAdnC,IAAAC,EAeL,MAAM,QAAQ,SAAQA,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,eAAe,WAAWD,EAAI,CAAA,CAQzE,MAAM,IAAIA,EAAaG,EAA8B,CAvB/C,IAAAF,EAwBL,MAAM,QAAQ,SAAQA,EAAA,mCAAY,SAAZ,YAAAA,EAAoB,eAAe,QAAQD,EAAKG,EAAM,CAAA,CAE9E"}
1
+ {"version":3,"file":"SessionStorage.mjs","sources":["../../src/storages/SessionStorage.ts"],"sourcesContent":["import type { SDKStorage } from '../types';\n\n/**\n * Implements session storage operations using the browser's `sessionStorage`.\n */\nexport class SessionStorage implements SDKStorage {\n\t/**\n\t * Retrieves a value from session storage by key.\n\t * @param {string} key The key to retrieve the value for.\n\t * @returns {string | null} The value associated with the key, or null if not found.\n\t */\n\tasync get(key: string): Promise<string | null> {\n\t\treturn Promise.resolve(globalThis?.window?.sessionStorage?.getItem(key));\n\t}\n\n\t/**\n\t * Deletes a key-value pair from session storage.\n\t * @param {string} key The key to delete.\n\t */\n\tasync delete(key: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.removeItem(key));\n\t}\n\n\t/**\n\t * Sets a key-value pair in session storage.\n\t * @param {string} key The key to set.\n\t * @param {string} value The value to associate with the key.\n\t */\n\tasync set(key: string, value: string): Promise<void> {\n\t\tawait Promise.resolve(globalThis?.window?.sessionStorage.setItem(key, value));\n\t}\n}\n"],"names":["SessionStorage","key","value"],"mappings":"AAKO,MAAMA,CAAqC,CAMjD,MAAM,IAAIC,EAAqC,CAC9C,OAAO,QAAQ,QAAQ,YAAY,QAAQ,gBAAgB,QAAQA,CAAG,CAAC,CACxE,CAMA,MAAM,OAAOA,EAA4B,CACxC,MAAM,QAAQ,QAAQ,YAAY,QAAQ,eAAe,WAAWA,CAAG,CAAC,CACzE,CAOA,MAAM,IAAIA,EAAaC,EAA8B,CACpD,MAAM,QAAQ,QAAQ,YAAY,QAAQ,eAAe,QAAQD,EAAKC,CAAK,CAAC,CAC7E,CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"HttpClient.cjs","sources":["../../src/utils/HttpClient.ts"],"sourcesContent":["import { SDKHttpClient, type HttpClientResponse } from '../types';\n\nexport class HttpClient extends SDKHttpClient {\n\tasync request<T>(url: string, options?: RequestInit): Promise<HttpClientResponse<T>> {\n\t\tconst response = await fetch(url, options);\n\n\t\treturn {\n\t\t\theaders: response.headers,\n\t\t\tok: response.ok,\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t\turl: response.url,\n\t\t\tjson: async () => (await response.json()) as T,\n\t\t\ttext: async () => await response.text(),\n\t\t\t// NOTE: Only json and text methods are supported in native platforms.\n\t\t};\n\t}\n}\n"],"names":["HttpClient","SDKHttpClient","url","options","response"],"mappings":"gHAEO,MAAMA,UAAmBC,EAAAA,aAAc,CAC7C,MAAM,QAAWC,EAAaC,EAAuD,CACpF,MAAMC,EAAW,MAAM,MAAMF,EAAKC,CAAO,EAEzC,MAAO,CACN,QAASC,EAAS,QAClB,GAAIA,EAAS,GACb,OAAQA,EAAS,OACjB,WAAYA,EAAS,WACrB,IAAKA,EAAS,IACd,KAAM,SAAa,MAAMA,EAAS,KAAA,EAClC,KAAM,SAAY,MAAMA,EAAS,KAAA,CAAK,CAEvC,CAEF"}
1
+ {"version":3,"file":"HttpClient.cjs","sources":["../../src/utils/HttpClient.ts"],"sourcesContent":["import { SDKHttpClient, type HttpClientResponse } from '../types';\n\nexport class HttpClient extends SDKHttpClient {\n\tasync request<T>(url: string, options?: RequestInit): Promise<HttpClientResponse<T>> {\n\t\tconst response = await fetch(url, options);\n\n\t\treturn {\n\t\t\theaders: response.headers,\n\t\t\tok: response.ok,\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t\turl: response.url,\n\t\t\tjson: async () => (await response.json()) as T,\n\t\t\ttext: async () => await response.text(),\n\t\t\t// NOTE: Only json and text methods are supported in native platforms.\n\t\t};\n\t}\n}\n"],"names":["HttpClient","SDKHttpClient","url","options","response"],"mappings":"gHAEO,MAAMA,UAAmBC,EAAAA,aAAc,CAC7C,MAAM,QAAWC,EAAaC,EAAuD,CACpF,MAAMC,EAAW,MAAM,MAAMF,EAAKC,CAAO,EAEzC,MAAO,CACN,QAASC,EAAS,QAClB,GAAIA,EAAS,GACb,OAAQA,EAAS,OACjB,WAAYA,EAAS,WACrB,IAAKA,EAAS,IACd,KAAM,SAAa,MAAMA,EAAS,KAAA,EAClC,KAAM,SAAY,MAAMA,EAAS,KAAA,CAAK,CAGxC,CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"HttpClient.mjs","sources":["../../src/utils/HttpClient.ts"],"sourcesContent":["import { SDKHttpClient, type HttpClientResponse } from '../types';\n\nexport class HttpClient extends SDKHttpClient {\n\tasync request<T>(url: string, options?: RequestInit): Promise<HttpClientResponse<T>> {\n\t\tconst response = await fetch(url, options);\n\n\t\treturn {\n\t\t\theaders: response.headers,\n\t\t\tok: response.ok,\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t\turl: response.url,\n\t\t\tjson: async () => (await response.json()) as T,\n\t\t\ttext: async () => await response.text(),\n\t\t\t// NOTE: Only json and text methods are supported in native platforms.\n\t\t};\n\t}\n}\n"],"names":["HttpClient","SDKHttpClient","url","options","response"],"mappings":"6CAEO,MAAMA,UAAmBC,CAAc,CAC7C,MAAM,QAAWC,EAAaC,EAAuD,CACpF,MAAMC,EAAW,MAAM,MAAMF,EAAKC,CAAO,EAEzC,MAAO,CACN,QAASC,EAAS,QAClB,GAAIA,EAAS,GACb,OAAQA,EAAS,OACjB,WAAYA,EAAS,WACrB,IAAKA,EAAS,IACd,KAAM,SAAa,MAAMA,EAAS,KAAA,EAClC,KAAM,SAAY,MAAMA,EAAS,KAAA,CAAK,CAEvC,CAEF"}
1
+ {"version":3,"file":"HttpClient.mjs","sources":["../../src/utils/HttpClient.ts"],"sourcesContent":["import { SDKHttpClient, type HttpClientResponse } from '../types';\n\nexport class HttpClient extends SDKHttpClient {\n\tasync request<T>(url: string, options?: RequestInit): Promise<HttpClientResponse<T>> {\n\t\tconst response = await fetch(url, options);\n\n\t\treturn {\n\t\t\theaders: response.headers,\n\t\t\tok: response.ok,\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t\turl: response.url,\n\t\t\tjson: async () => (await response.json()) as T,\n\t\t\ttext: async () => await response.text(),\n\t\t\t// NOTE: Only json and text methods are supported in native platforms.\n\t\t};\n\t}\n}\n"],"names":["HttpClient","SDKHttpClient","url","options","response"],"mappings":"6CAEO,MAAMA,UAAmBC,CAAc,CAC7C,MAAM,QAAWC,EAAaC,EAAuD,CACpF,MAAMC,EAAW,MAAM,MAAMF,EAAKC,CAAO,EAEzC,MAAO,CACN,QAASC,EAAS,QAClB,GAAIA,EAAS,GACb,OAAQA,EAAS,OACjB,WAAYA,EAAS,WACrB,IAAKA,EAAS,IACd,KAAM,SAAa,MAAMA,EAAS,KAAA,EAClC,KAAM,SAAY,MAAMA,EAAS,KAAA,CAAK,CAGxC,CACD"}
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.defineProperty;var i=(a,t,e)=>t in a?n(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var r=(a,t,e)=>i(a,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class s{constructor(t,e){r(this,"data",null);this.sdk=t,this.metadataUrl=e}get issuer(){return this.getMetadataProperty("issuer")}get authorizationEndpoint(){return this.getMetadataProperty("authorization_endpoint")}get tokenEndpoint(){return this.getMetadataProperty("token_endpoint")}get userinfoEndpoint(){return this.getMetadataProperty("userinfo_endpoint")}get endSessionEndpoint(){return this.getMetadataProperty("end_session_endpoint")}get revocationEndpoint(){return this.getMetadataProperty("revocation_endpoint")}get jwksUri(){return this.getMetadataProperty("jwks_uri")}async fetchMetadata(){const t=await this.sdk.httpClient.request(this.metadataUrl,{method:"GET"});this.data=await t.json()}async getMetadataProperty(t){var e;return(e=this.data)!=null&&e[t]?Promise.resolve(this.data[t]):(await this.fetchMetadata(),Promise.resolve(this.data[t]))}}exports.Metadata=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class a{constructor(t,e){this.sdk=t,this.metadataUrl=e}data=null;get issuer(){return this.getMetadataProperty("issuer")}get authorizationEndpoint(){return this.getMetadataProperty("authorization_endpoint")}get tokenEndpoint(){return this.getMetadataProperty("token_endpoint")}get userinfoEndpoint(){return this.getMetadataProperty("userinfo_endpoint")}get endSessionEndpoint(){return this.getMetadataProperty("end_session_endpoint")}get revocationEndpoint(){return this.getMetadataProperty("revocation_endpoint")}get jwksUri(){return this.getMetadataProperty("jwks_uri")}async fetchMetadata(){const t=await this.sdk.httpClient.request(this.metadataUrl,{method:"GET"});this.data=await t.json()}async getMetadataProperty(t){return this.data?.[t]?Promise.resolve(this.data[t]):(await this.fetchMetadata(),Promise.resolve(this.data[t]))}}exports.Metadata=a;
2
2
  //# sourceMappingURL=Metadata.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Metadata.cjs","sources":["../../src/utils/Metadata.ts"],"sourcesContent":["import type { BaseFlow } from '../flows/BaseFlow';\nimport type { MetadataOptions } from '../types';\n\n/**\n * Class responsible for fetching and handling metadata for authentication endpoints.\n */\nexport class Metadata {\n\t/**\n\t * Holds the metadata options once fetched, or null if not yet fetched.\n\t * @protected\n\t */\n\tprotected data: MetadataOptions | null = null;\n\n\t/**\n\t * Retrieves the issuer metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the issuer string.\n\t */\n\tget issuer(): Promise<string> {\n\t\treturn this.getMetadataProperty('issuer');\n\t}\n\n\t/**\n\t * Retrieves the authorization endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the authorization endpoint URL.\n\t */\n\tget authorizationEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('authorization_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the token endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the token endpoint URL.\n\t */\n\tget tokenEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('token_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the user info endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the user info endpoint URL.\n\t */\n\tget userinfoEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('userinfo_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the end session endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the end session endpoint URL.\n\t */\n\tget endSessionEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('end_session_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the revocation endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the revocation endpoint URL.\n\t */\n\tget revocationEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('revocation_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the JWKS URI metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the JWKS URI.\n\t */\n\tget jwksUri(): Promise<string> {\n\t\treturn this.getMetadataProperty('jwks_uri');\n\t}\n\n\t/**\n\t * Creates an instance of the Metadata class.\n\t *\n\t * @param {string} metadataUrl The URL to fetch metadata from.\n\t */\n\tconstructor(\n\t\t/**\n\t\t * The SDK instance.\n\t\t *\n\t\t * @type {SDKStorage}\n\t\t */\n\t\tprotected sdk: BaseFlow,\n\n\t\t/**\n\t\t * The URL to fetch metadata from.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tprotected metadataUrl: string,\n\t) {}\n\n\t/**\n\t * Fetches and updates the metadata from the specified URL.\n\t *\n\t * @returns {Promise<void>} A promise that resolves once the metadata is fetched.\n\t */\n\tasync fetchMetadata(): Promise<void> {\n\t\tconst response = await this.sdk.httpClient.request<MetadataOptions>(this.metadataUrl, { method: 'GET' });\n\t\tthis.data = await response.json();\n\t}\n\n\t/**\n\t * Retrieves a specific metadata property.\n\t *\n\t * @template K The key of the metadata property.\n\t * @param {K} key The metadata property key to retrieve.\n\t * @returns {Promise<MetadataOptions[K]>} A promise that resolves to the value of the specified metadata property.\n\t */\n\tasync getMetadataProperty<K extends keyof MetadataOptions>(key: K): Promise<MetadataOptions[K]> {\n\t\tif (this.data?.[key]) {\n\t\t\treturn Promise.resolve(this.data[key]);\n\t\t}\n\n\t\tawait this.fetchMetadata();\n\n\t\treturn Promise.resolve((this.data as MetadataOptions)[key]);\n\t}\n}\n"],"names":["Metadata","sdk","metadataUrl","__publicField","response","key","_a"],"mappings":"oPAMO,MAAMA,CAAS,CA2ErB,YAMWC,EAOAC,EACT,CApFQC,EAAA,YAA+B,MA4E9B,KAAA,IAAAF,EAOA,KAAA,YAAAC,CAAA,CA5EX,IAAI,QAA0B,CAC7B,OAAO,KAAK,oBAAoB,QAAQ,CAAA,CAQzC,IAAI,uBAAyC,CAC5C,OAAO,KAAK,oBAAoB,wBAAwB,CAAA,CAQzD,IAAI,eAAiC,CACpC,OAAO,KAAK,oBAAoB,gBAAgB,CAAA,CAQjD,IAAI,kBAAoC,CACvC,OAAO,KAAK,oBAAoB,mBAAmB,CAAA,CAQpD,IAAI,oBAAsC,CACzC,OAAO,KAAK,oBAAoB,sBAAsB,CAAA,CAQvD,IAAI,oBAAsC,CACzC,OAAO,KAAK,oBAAoB,qBAAqB,CAAA,CAQtD,IAAI,SAA2B,CAC9B,OAAO,KAAK,oBAAoB,UAAU,CAAA,CA6B3C,MAAM,eAA+B,CACpC,MAAME,EAAW,MAAM,KAAK,IAAI,WAAW,QAAyB,KAAK,YAAa,CAAE,OAAQ,KAAA,CAAO,EACvG,KAAK,KAAO,MAAMA,EAAS,KAAA,CAAK,CAUjC,MAAM,oBAAqDC,EAAqC,OAC/F,OAAIC,EAAA,KAAK,OAAL,MAAAA,EAAYD,GACR,QAAQ,QAAQ,KAAK,KAAKA,CAAG,CAAC,GAGtC,MAAM,KAAK,cAAA,EAEJ,QAAQ,QAAS,KAAK,KAAyBA,CAAG,CAAC,EAAA,CAE5D"}
1
+ {"version":3,"file":"Metadata.cjs","sources":["../../src/utils/Metadata.ts"],"sourcesContent":["import type { BaseFlow } from '../flows/BaseFlow';\nimport type { MetadataOptions } from '../types';\n\n/**\n * Class responsible for fetching and handling metadata for authentication endpoints.\n */\nexport class Metadata {\n\t/**\n\t * Holds the metadata options once fetched, or null if not yet fetched.\n\t * @protected\n\t */\n\tprotected data: MetadataOptions | null = null;\n\n\t/**\n\t * Retrieves the issuer metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the issuer string.\n\t */\n\tget issuer(): Promise<string> {\n\t\treturn this.getMetadataProperty('issuer');\n\t}\n\n\t/**\n\t * Retrieves the authorization endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the authorization endpoint URL.\n\t */\n\tget authorizationEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('authorization_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the token endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the token endpoint URL.\n\t */\n\tget tokenEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('token_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the user info endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the user info endpoint URL.\n\t */\n\tget userinfoEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('userinfo_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the end session endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the end session endpoint URL.\n\t */\n\tget endSessionEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('end_session_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the revocation endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the revocation endpoint URL.\n\t */\n\tget revocationEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('revocation_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the JWKS URI metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the JWKS URI.\n\t */\n\tget jwksUri(): Promise<string> {\n\t\treturn this.getMetadataProperty('jwks_uri');\n\t}\n\n\t/**\n\t * Creates an instance of the Metadata class.\n\t *\n\t * @param {string} metadataUrl The URL to fetch metadata from.\n\t */\n\tconstructor(\n\t\t/**\n\t\t * The SDK instance.\n\t\t *\n\t\t * @type {SDKStorage}\n\t\t */\n\t\tprotected sdk: BaseFlow,\n\n\t\t/**\n\t\t * The URL to fetch metadata from.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tprotected metadataUrl: string,\n\t) {}\n\n\t/**\n\t * Fetches and updates the metadata from the specified URL.\n\t *\n\t * @returns {Promise<void>} A promise that resolves once the metadata is fetched.\n\t */\n\tasync fetchMetadata(): Promise<void> {\n\t\tconst response = await this.sdk.httpClient.request<MetadataOptions>(this.metadataUrl, { method: 'GET' });\n\t\tthis.data = await response.json();\n\t}\n\n\t/**\n\t * Retrieves a specific metadata property.\n\t *\n\t * @template K The key of the metadata property.\n\t * @param {K} key The metadata property key to retrieve.\n\t * @returns {Promise<MetadataOptions[K]>} A promise that resolves to the value of the specified metadata property.\n\t */\n\tasync getMetadataProperty<K extends keyof MetadataOptions>(key: K): Promise<MetadataOptions[K]> {\n\t\tif (this.data?.[key]) {\n\t\t\treturn Promise.resolve(this.data[key]);\n\t\t}\n\n\t\tawait this.fetchMetadata();\n\n\t\treturn Promise.resolve((this.data as MetadataOptions)[key]);\n\t}\n}\n"],"names":["Metadata","sdk","metadataUrl","response","key"],"mappings":"gFAMO,MAAMA,CAAS,CA2ErB,YAMWC,EAOAC,EACT,CARS,KAAA,IAAAD,EAOA,KAAA,YAAAC,CACR,CApFO,KAA+B,KAOzC,IAAI,QAA0B,CAC7B,OAAO,KAAK,oBAAoB,QAAQ,CACzC,CAOA,IAAI,uBAAyC,CAC5C,OAAO,KAAK,oBAAoB,wBAAwB,CACzD,CAOA,IAAI,eAAiC,CACpC,OAAO,KAAK,oBAAoB,gBAAgB,CACjD,CAOA,IAAI,kBAAoC,CACvC,OAAO,KAAK,oBAAoB,mBAAmB,CACpD,CAOA,IAAI,oBAAsC,CACzC,OAAO,KAAK,oBAAoB,sBAAsB,CACvD,CAOA,IAAI,oBAAsC,CACzC,OAAO,KAAK,oBAAoB,qBAAqB,CACtD,CAOA,IAAI,SAA2B,CAC9B,OAAO,KAAK,oBAAoB,UAAU,CAC3C,CA4BA,MAAM,eAA+B,CACpC,MAAMC,EAAW,MAAM,KAAK,IAAI,WAAW,QAAyB,KAAK,YAAa,CAAE,OAAQ,KAAA,CAAO,EACvG,KAAK,KAAO,MAAMA,EAAS,KAAA,CAC5B,CASA,MAAM,oBAAqDC,EAAqC,CAC/F,OAAI,KAAK,OAAOA,CAAG,EACX,QAAQ,QAAQ,KAAK,KAAKA,CAAG,CAAC,GAGtC,MAAM,KAAK,cAAA,EAEJ,QAAQ,QAAS,KAAK,KAAyBA,CAAG,CAAC,EAC3D,CACD"}
@@ -1,2 +1,2 @@
1
- var n=Object.defineProperty;var i=(a,t,e)=>t in a?n(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e;var r=(a,t,e)=>i(a,typeof t!="symbol"?t+"":t,e);class o{constructor(t,e){r(this,"data",null);this.sdk=t,this.metadataUrl=e}get issuer(){return this.getMetadataProperty("issuer")}get authorizationEndpoint(){return this.getMetadataProperty("authorization_endpoint")}get tokenEndpoint(){return this.getMetadataProperty("token_endpoint")}get userinfoEndpoint(){return this.getMetadataProperty("userinfo_endpoint")}get endSessionEndpoint(){return this.getMetadataProperty("end_session_endpoint")}get revocationEndpoint(){return this.getMetadataProperty("revocation_endpoint")}get jwksUri(){return this.getMetadataProperty("jwks_uri")}async fetchMetadata(){const t=await this.sdk.httpClient.request(this.metadataUrl,{method:"GET"});this.data=await t.json()}async getMetadataProperty(t){var e;return(e=this.data)!=null&&e[t]?Promise.resolve(this.data[t]):(await this.fetchMetadata(),Promise.resolve(this.data[t]))}}export{o as Metadata};
1
+ class r{constructor(t,e){this.sdk=t,this.metadataUrl=e}data=null;get issuer(){return this.getMetadataProperty("issuer")}get authorizationEndpoint(){return this.getMetadataProperty("authorization_endpoint")}get tokenEndpoint(){return this.getMetadataProperty("token_endpoint")}get userinfoEndpoint(){return this.getMetadataProperty("userinfo_endpoint")}get endSessionEndpoint(){return this.getMetadataProperty("end_session_endpoint")}get revocationEndpoint(){return this.getMetadataProperty("revocation_endpoint")}get jwksUri(){return this.getMetadataProperty("jwks_uri")}async fetchMetadata(){const t=await this.sdk.httpClient.request(this.metadataUrl,{method:"GET"});this.data=await t.json()}async getMetadataProperty(t){return this.data?.[t]?Promise.resolve(this.data[t]):(await this.fetchMetadata(),Promise.resolve(this.data[t]))}}export{r as Metadata};
2
2
  //# sourceMappingURL=Metadata.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Metadata.mjs","sources":["../../src/utils/Metadata.ts"],"sourcesContent":["import type { BaseFlow } from '../flows/BaseFlow';\nimport type { MetadataOptions } from '../types';\n\n/**\n * Class responsible for fetching and handling metadata for authentication endpoints.\n */\nexport class Metadata {\n\t/**\n\t * Holds the metadata options once fetched, or null if not yet fetched.\n\t * @protected\n\t */\n\tprotected data: MetadataOptions | null = null;\n\n\t/**\n\t * Retrieves the issuer metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the issuer string.\n\t */\n\tget issuer(): Promise<string> {\n\t\treturn this.getMetadataProperty('issuer');\n\t}\n\n\t/**\n\t * Retrieves the authorization endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the authorization endpoint URL.\n\t */\n\tget authorizationEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('authorization_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the token endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the token endpoint URL.\n\t */\n\tget tokenEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('token_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the user info endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the user info endpoint URL.\n\t */\n\tget userinfoEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('userinfo_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the end session endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the end session endpoint URL.\n\t */\n\tget endSessionEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('end_session_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the revocation endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the revocation endpoint URL.\n\t */\n\tget revocationEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('revocation_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the JWKS URI metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the JWKS URI.\n\t */\n\tget jwksUri(): Promise<string> {\n\t\treturn this.getMetadataProperty('jwks_uri');\n\t}\n\n\t/**\n\t * Creates an instance of the Metadata class.\n\t *\n\t * @param {string} metadataUrl The URL to fetch metadata from.\n\t */\n\tconstructor(\n\t\t/**\n\t\t * The SDK instance.\n\t\t *\n\t\t * @type {SDKStorage}\n\t\t */\n\t\tprotected sdk: BaseFlow,\n\n\t\t/**\n\t\t * The URL to fetch metadata from.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tprotected metadataUrl: string,\n\t) {}\n\n\t/**\n\t * Fetches and updates the metadata from the specified URL.\n\t *\n\t * @returns {Promise<void>} A promise that resolves once the metadata is fetched.\n\t */\n\tasync fetchMetadata(): Promise<void> {\n\t\tconst response = await this.sdk.httpClient.request<MetadataOptions>(this.metadataUrl, { method: 'GET' });\n\t\tthis.data = await response.json();\n\t}\n\n\t/**\n\t * Retrieves a specific metadata property.\n\t *\n\t * @template K The key of the metadata property.\n\t * @param {K} key The metadata property key to retrieve.\n\t * @returns {Promise<MetadataOptions[K]>} A promise that resolves to the value of the specified metadata property.\n\t */\n\tasync getMetadataProperty<K extends keyof MetadataOptions>(key: K): Promise<MetadataOptions[K]> {\n\t\tif (this.data?.[key]) {\n\t\t\treturn Promise.resolve(this.data[key]);\n\t\t}\n\n\t\tawait this.fetchMetadata();\n\n\t\treturn Promise.resolve((this.data as MetadataOptions)[key]);\n\t}\n}\n"],"names":["Metadata","sdk","metadataUrl","__publicField","response","key","_a"],"mappings":"oKAMO,MAAMA,CAAS,CA2ErB,YAMWC,EAOAC,EACT,CApFQC,EAAA,YAA+B,MA4E9B,KAAA,IAAAF,EAOA,KAAA,YAAAC,CAAA,CA5EX,IAAI,QAA0B,CAC7B,OAAO,KAAK,oBAAoB,QAAQ,CAAA,CAQzC,IAAI,uBAAyC,CAC5C,OAAO,KAAK,oBAAoB,wBAAwB,CAAA,CAQzD,IAAI,eAAiC,CACpC,OAAO,KAAK,oBAAoB,gBAAgB,CAAA,CAQjD,IAAI,kBAAoC,CACvC,OAAO,KAAK,oBAAoB,mBAAmB,CAAA,CAQpD,IAAI,oBAAsC,CACzC,OAAO,KAAK,oBAAoB,sBAAsB,CAAA,CAQvD,IAAI,oBAAsC,CACzC,OAAO,KAAK,oBAAoB,qBAAqB,CAAA,CAQtD,IAAI,SAA2B,CAC9B,OAAO,KAAK,oBAAoB,UAAU,CAAA,CA6B3C,MAAM,eAA+B,CACpC,MAAME,EAAW,MAAM,KAAK,IAAI,WAAW,QAAyB,KAAK,YAAa,CAAE,OAAQ,KAAA,CAAO,EACvG,KAAK,KAAO,MAAMA,EAAS,KAAA,CAAK,CAUjC,MAAM,oBAAqDC,EAAqC,CA5G1F,IAAAC,EA6GL,OAAIA,EAAA,KAAK,OAAL,MAAAA,EAAYD,GACR,QAAQ,QAAQ,KAAK,KAAKA,CAAG,CAAC,GAGtC,MAAM,KAAK,cAAA,EAEJ,QAAQ,QAAS,KAAK,KAAyBA,CAAG,CAAC,EAAA,CAE5D"}
1
+ {"version":3,"file":"Metadata.mjs","sources":["../../src/utils/Metadata.ts"],"sourcesContent":["import type { BaseFlow } from '../flows/BaseFlow';\nimport type { MetadataOptions } from '../types';\n\n/**\n * Class responsible for fetching and handling metadata for authentication endpoints.\n */\nexport class Metadata {\n\t/**\n\t * Holds the metadata options once fetched, or null if not yet fetched.\n\t * @protected\n\t */\n\tprotected data: MetadataOptions | null = null;\n\n\t/**\n\t * Retrieves the issuer metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the issuer string.\n\t */\n\tget issuer(): Promise<string> {\n\t\treturn this.getMetadataProperty('issuer');\n\t}\n\n\t/**\n\t * Retrieves the authorization endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the authorization endpoint URL.\n\t */\n\tget authorizationEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('authorization_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the token endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the token endpoint URL.\n\t */\n\tget tokenEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('token_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the user info endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the user info endpoint URL.\n\t */\n\tget userinfoEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('userinfo_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the end session endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the end session endpoint URL.\n\t */\n\tget endSessionEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('end_session_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the revocation endpoint metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the revocation endpoint URL.\n\t */\n\tget revocationEndpoint(): Promise<string> {\n\t\treturn this.getMetadataProperty('revocation_endpoint');\n\t}\n\n\t/**\n\t * Retrieves the JWKS URI metadata.\n\t *\n\t * @returns {Promise<string>} A promise that resolves to the JWKS URI.\n\t */\n\tget jwksUri(): Promise<string> {\n\t\treturn this.getMetadataProperty('jwks_uri');\n\t}\n\n\t/**\n\t * Creates an instance of the Metadata class.\n\t *\n\t * @param {string} metadataUrl The URL to fetch metadata from.\n\t */\n\tconstructor(\n\t\t/**\n\t\t * The SDK instance.\n\t\t *\n\t\t * @type {SDKStorage}\n\t\t */\n\t\tprotected sdk: BaseFlow,\n\n\t\t/**\n\t\t * The URL to fetch metadata from.\n\t\t *\n\t\t * @type {string}\n\t\t */\n\t\tprotected metadataUrl: string,\n\t) {}\n\n\t/**\n\t * Fetches and updates the metadata from the specified URL.\n\t *\n\t * @returns {Promise<void>} A promise that resolves once the metadata is fetched.\n\t */\n\tasync fetchMetadata(): Promise<void> {\n\t\tconst response = await this.sdk.httpClient.request<MetadataOptions>(this.metadataUrl, { method: 'GET' });\n\t\tthis.data = await response.json();\n\t}\n\n\t/**\n\t * Retrieves a specific metadata property.\n\t *\n\t * @template K The key of the metadata property.\n\t * @param {K} key The metadata property key to retrieve.\n\t * @returns {Promise<MetadataOptions[K]>} A promise that resolves to the value of the specified metadata property.\n\t */\n\tasync getMetadataProperty<K extends keyof MetadataOptions>(key: K): Promise<MetadataOptions[K]> {\n\t\tif (this.data?.[key]) {\n\t\t\treturn Promise.resolve(this.data[key]);\n\t\t}\n\n\t\tawait this.fetchMetadata();\n\n\t\treturn Promise.resolve((this.data as MetadataOptions)[key]);\n\t}\n}\n"],"names":["Metadata","sdk","metadataUrl","response","key"],"mappings":"AAMO,MAAMA,CAAS,CA2ErB,YAMWC,EAOAC,EACT,CARS,KAAA,IAAAD,EAOA,KAAA,YAAAC,CACR,CApFO,KAA+B,KAOzC,IAAI,QAA0B,CAC7B,OAAO,KAAK,oBAAoB,QAAQ,CACzC,CAOA,IAAI,uBAAyC,CAC5C,OAAO,KAAK,oBAAoB,wBAAwB,CACzD,CAOA,IAAI,eAAiC,CACpC,OAAO,KAAK,oBAAoB,gBAAgB,CACjD,CAOA,IAAI,kBAAoC,CACvC,OAAO,KAAK,oBAAoB,mBAAmB,CACpD,CAOA,IAAI,oBAAsC,CACzC,OAAO,KAAK,oBAAoB,sBAAsB,CACvD,CAOA,IAAI,oBAAsC,CACzC,OAAO,KAAK,oBAAoB,qBAAqB,CACtD,CAOA,IAAI,SAA2B,CAC9B,OAAO,KAAK,oBAAoB,UAAU,CAC3C,CA4BA,MAAM,eAA+B,CACpC,MAAMC,EAAW,MAAM,KAAK,IAAI,WAAW,QAAyB,KAAK,YAAa,CAAE,OAAQ,KAAA,CAAO,EACvG,KAAK,KAAO,MAAMA,EAAS,KAAA,CAC5B,CASA,MAAM,oBAAqDC,EAAqC,CAC/F,OAAI,KAAK,OAAOA,CAAG,EACX,QAAQ,QAAQ,KAAK,KAAKA,CAAG,CAAC,GAGtC,MAAM,KAAK,cAAA,EAEJ,QAAQ,QAAS,KAAK,KAAyBA,CAAG,CAAC,EAC3D,CACD"}
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.defineProperty;var l=(a,s,e)=>s in a?d(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e;var n=(a,s,e)=>l(a,typeof s!="symbol"?s+"":s,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./State.cjs"),o=require("./errors.cjs");require("./crypto.cjs");require("./base64Url.cjs");require("./date.cjs");class c{constructor(s,e={}){n(this,"sessionId",null);this.sdk=s,this.params=e}async startSession(s){if(s)return this.sessionId=s,this.submitForm();const e=await h.State.create(),t=await this.sdk.getAuthorizationUrl(this.params);t.searchParams.append("sdk",this.params.sdk||"web"),t.searchParams.append("state",e.id),t.searchParams.append("code_challenge",e.codeChallenge),t.searchParams.append("nonce",e.nonce),await this.sdk.storage.set(`sty.${e.id}`,JSON.stringify(e));const r=await this.sdk.httpClient.request(t.toString(),{method:"GET",credentials:"include"}),i=new URL(await r.text());if(i.searchParams.has("code")){if(typeof this.sdk.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");if(!i.toString().startsWith(this.sdk.options.redirectUri))throw new Error("Invalid redirect URI");return await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(i.toString(),this.sdk.options.responseMode||"fragment"))}if(i.searchParams.has("error"))throw new Error(`${i.searchParams.get("error")}: ${i.searchParams.get("error_description")}`);if(!i.searchParams.has("session_id"))throw new Error('Failed to start a session: "session_id" is missing');return this.sessionId=i.searchParams.get("session_id"),this.submitForm()}async finalizeSession(s){const e=await this.sdk.httpClient.request(s,{method:"GET",credentials:"include"}),t=new URL(await e.text());if(typeof this.sdk.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");if(!t.toString().startsWith(this.sdk.options.redirectUri))throw new Error("Invalid redirect URI");await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(t.toString(),this.sdk.options.responseMode||"fragment"))}async submitForm(s,e={}){const t=await this.sdk.httpClient.request(new URL(`/flow/api/v1/${s?`form/${s}`:"init"}`,this.sdk.options.issuer).toString(),{method:"POST",headers:{Authorization:`Bearer ${this.sessionId}`,"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"}),r=await t.json();if(!t.ok&&t.status>=400&&t.status<500){if(t.status!==403&&(r!=null&&r.hostedUrl)&&!r.messages)throw new o.FallbackError(new URL(r.hostedUrl));if(t.status!==400)throw new Error(`HTTP ${t.status}: ${t.statusText}`)}if(r.finalizeUrl)await this.finalizeSession(r.finalizeUrl);else if(r.hostedUrl&&!r.forms&&!r.messages)throw new o.FallbackError(new URL(r.hostedUrl));return r}}exports.NativeFlowHandler=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./State.cjs"),a=require("./errors.cjs");require("./crypto.cjs");require("./base64Url.cjs");require("./date.cjs");class o{constructor(r,e={}){this.sdk=r,this.params=e}sessionId=null;async startSession(r){if(r)return this.sessionId=r,this.submitForm();const e=await n.State.create(),s=await this.sdk.getAuthorizationUrl(this.params);s.searchParams.append("sdk",this.params.sdk||"web"),s.searchParams.append("state",e.id),s.searchParams.append("code_challenge",e.codeChallenge),s.searchParams.append("nonce",e.nonce),await this.sdk.storage.set(`sty.${e.id}`,JSON.stringify(e));const t=await this.sdk.httpClient.request(s.toString(),{method:"GET",credentials:"include"}),i=new URL(await t.text());if(i.searchParams.has("code")){if(typeof this.sdk.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");if(!i.toString().startsWith(this.sdk.options.redirectUri))throw new Error("Invalid redirect URI");return await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(i.toString(),this.sdk.options.responseMode||"fragment"))}if(i.searchParams.has("error"))throw new Error(`${i.searchParams.get("error")}: ${i.searchParams.get("error_description")}`);if(!i.searchParams.has("session_id"))throw new Error('Failed to start a session: "session_id" is missing');return this.sessionId=i.searchParams.get("session_id"),this.submitForm()}async finalizeSession(r){const e=await this.sdk.httpClient.request(r,{method:"GET",headers:{Authorization:`Bearer ${this.sessionId}`},credentials:"include"}),s=new URL(await e.text());if(typeof this.sdk.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");if(!s.toString().startsWith(this.sdk.options.redirectUri))throw new Error("Invalid redirect URI");await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(s.toString(),this.sdk.options.responseMode||"fragment"))}async submitForm(r,e={}){const s=await this.sdk.httpClient.request(new URL(`/flow/api/v1/${r?`form/${r}`:"init"}`,this.sdk.options.issuer).toString(),{method:"POST",headers:{Authorization:`Bearer ${this.sessionId}`,"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"}),t=await s.json();if(!s.ok&&s.status>=400&&s.status<500){if(s.status!==403&&t?.hostedUrl&&!t.messages)throw new a.FallbackError(new URL(t.hostedUrl));if(s.status!==400)throw new Error(`HTTP ${s.status}: ${s.statusText}`)}if(t.finalizeUrl)await this.finalizeSession(t.finalizeUrl);else if(t.hostedUrl&&!t.forms&&!t.messages)throw new a.FallbackError(new URL(t.hostedUrl));return t}}exports.NativeFlowHandler=o;
2
2
  //# sourceMappingURL=NativeFlowHandler.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"NativeFlowHandler.cjs","sources":["../../src/utils/NativeFlowHandler.ts"],"sourcesContent":["import type { NativeParams, LoginFlowState } from '../types';\nimport type { BaseFlow } from '../flows/BaseFlow';\nimport { State } from './State';\nimport { FallbackError } from './errors';\n\nexport class NativeFlowHandler {\n\t/**\n\t * The session ID.\n\t *\n\t * @type {string | null}\n\t */\n\tprotected sessionId: string | null = null;\n\n\tconstructor(\n\t\t/**\n\t\t * The SDK instance.\n\t\t *\n\t\t * @type {SDKStorage}\n\t\t */\n\t\tprotected sdk: BaseFlow,\n\t\t/**\n\t\t * Optional parameters for native configuration.\n\t\t *\n\t\t * @type {NativeParams} [options={}]\n\t\t */\n\t\tprotected params: NativeParams = {},\n\t) {}\n\n\t/**\n\t * Starts a new session.\n\t *\n\t * @param {string} [sessionId] - The session ID to start the session with. If not provided, a new session will be created.\n\t * @returns {Promise<LoginFlowState | void>}\n\t */\n\tasync startSession(sessionId?: string | null): Promise<LoginFlowState | void> {\n\t\tif (sessionId) {\n\t\t\tthis.sessionId = sessionId;\n\t\t\treturn this.submitForm();\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst authorizationUrl = await this.sdk.getAuthorizationUrl(this.params);\n\n\t\tauthorizationUrl.searchParams.append('sdk', this.params.sdk || 'web');\n\t\tauthorizationUrl.searchParams.append('state', state.id);\n\t\tauthorizationUrl.searchParams.append('code_challenge', state.codeChallenge);\n\t\tauthorizationUrl.searchParams.append('nonce', state.nonce);\n\n\t\tawait this.sdk.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tconst response = await this.sdk.httpClient.request(authorizationUrl.toString(), { method: 'GET', credentials: 'include' });\n\t\tconst redirectUri = new URL(await response.text());\n\n\t\tif (redirectUri.searchParams.has('code')) {\n\t\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t\t}\n\t\t\tif (!redirectUri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\t\tthrow new Error('Invalid redirect URI');\n\t\t\t}\n\n\t\t\treturn await this.sdk.tokenExchange(\n\t\t\t\t(await this.sdk.options.callbackHandler(redirectUri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t\t);\n\t\t}\n\n\t\tif (redirectUri.searchParams.has('error')) {\n\t\t\tthrow new Error(`${redirectUri.searchParams.get('error')}: ${redirectUri.searchParams.get('error_description')}`);\n\t\t}\n\n\t\tif (!redirectUri.searchParams.has('session_id')) {\n\t\t\tthrow new Error('Failed to start a session: \"session_id\" is missing');\n\t\t}\n\n\t\tthis.sessionId = redirectUri.searchParams.get('session_id');\n\n\t\treturn this.submitForm();\n\t}\n\n\t/**\n\t * Finalizes the session using the provided [finalizeUrl].\n\t *\n\t * @param {string} finalizeUrl The URL to finalize the session.\n\t */\n\tasync finalizeSession(finalizeUrl: string): Promise<void> {\n\t\tconst response = await this.sdk.httpClient.request(finalizeUrl, { method: 'GET', credentials: 'include' });\n\t\tconst redirectUri = new URL(await response.text());\n\n\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t}\n\n\t\tif (!redirectUri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\tthrow new Error('Invalid redirect URI');\n\t\t}\n\n\t\tawait this.sdk.tokenExchange(\n\t\t\t(await this.sdk.options.callbackHandler(redirectUri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t);\n\t}\n\n\t/**\n\t * Submits a form with the provided [formId] and [data].\n\t *\n\t * @returns {Promise<LoginFlowState>}\n\t */\n\tasync submitForm(formId?: string, body: Record<string, unknown> = {}): Promise<LoginFlowState> {\n\t\tconst response = await this.sdk.httpClient.request<LoginFlowState>(\n\t\t\tnew URL(`/flow/api/v1/${formId ? `form/${formId}` : 'init'}`, this.sdk.options.issuer).toString(),\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: { Authorization: `Bearer ${this.sessionId}`, 'Content-Type': 'application/json' },\n\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\tcredentials: 'include',\n\t\t\t},\n\t\t);\n\t\tconst data = await response.json();\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status >= 400 && response.status < 500) {\n\t\t\t\tif (response.status !== 403 && data?.hostedUrl && !data.messages) {\n\t\t\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t\t\t}\n\n\t\t\t\tif (response.status !== 400) {\n\t\t\t\t\tthrow new Error(`HTTP ${response.status}: ${response.statusText}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (data.finalizeUrl) {\n\t\t\tawait this.finalizeSession(data.finalizeUrl);\n\t\t} else if (data.hostedUrl && !data.forms && !data.messages) {\n\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t}\n\n\t\treturn data;\n\t}\n}\n"],"names":["NativeFlowHandler","sdk","params","__publicField","sessionId","state","State","authorizationUrl","response","redirectUri","finalizeUrl","formId","body","data","FallbackError"],"mappings":"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"}
1
+ {"version":3,"file":"NativeFlowHandler.cjs","sources":["../../src/utils/NativeFlowHandler.ts"],"sourcesContent":["import type { NativeParams, LoginFlowState } from '../types';\nimport type { BaseFlow } from '../flows/BaseFlow';\nimport { State } from './State';\nimport { FallbackError } from './errors';\n\nexport class NativeFlowHandler {\n\t/**\n\t * The session ID.\n\t *\n\t * @type {string | null}\n\t */\n\tprotected sessionId: string | null = null;\n\n\tconstructor(\n\t\t/**\n\t\t * The SDK instance.\n\t\t *\n\t\t * @type {SDKStorage}\n\t\t */\n\t\tprotected sdk: BaseFlow,\n\t\t/**\n\t\t * Optional parameters for native configuration.\n\t\t *\n\t\t * @type {NativeParams} [options={}]\n\t\t */\n\t\tprotected params: NativeParams = {},\n\t) {}\n\n\t/**\n\t * Starts a new session.\n\t *\n\t * @param {string} [sessionId] - The session ID to start the session with. If not provided, a new session will be created.\n\t * @returns {Promise<LoginFlowState | void>}\n\t */\n\tasync startSession(sessionId?: string | null): Promise<LoginFlowState | void> {\n\t\tif (sessionId) {\n\t\t\tthis.sessionId = sessionId;\n\t\t\treturn this.submitForm();\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst authorizationUrl = await this.sdk.getAuthorizationUrl(this.params);\n\n\t\tauthorizationUrl.searchParams.append('sdk', this.params.sdk || 'web');\n\t\tauthorizationUrl.searchParams.append('state', state.id);\n\t\tauthorizationUrl.searchParams.append('code_challenge', state.codeChallenge);\n\t\tauthorizationUrl.searchParams.append('nonce', state.nonce);\n\n\t\tawait this.sdk.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tconst response = await this.sdk.httpClient.request(authorizationUrl.toString(), { method: 'GET', credentials: 'include' });\n\t\tconst redirectUri = new URL(await response.text());\n\n\t\tif (redirectUri.searchParams.has('code')) {\n\t\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t\t}\n\t\t\tif (!redirectUri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\t\tthrow new Error('Invalid redirect URI');\n\t\t\t}\n\n\t\t\treturn await this.sdk.tokenExchange(\n\t\t\t\t(await this.sdk.options.callbackHandler(redirectUri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t\t);\n\t\t}\n\n\t\tif (redirectUri.searchParams.has('error')) {\n\t\t\tthrow new Error(`${redirectUri.searchParams.get('error')}: ${redirectUri.searchParams.get('error_description')}`);\n\t\t}\n\n\t\tif (!redirectUri.searchParams.has('session_id')) {\n\t\t\tthrow new Error('Failed to start a session: \"session_id\" is missing');\n\t\t}\n\n\t\tthis.sessionId = redirectUri.searchParams.get('session_id');\n\n\t\treturn this.submitForm();\n\t}\n\n\t/**\n\t * Finalizes the session using the provided [finalizeUrl].\n\t *\n\t * @param {string} finalizeUrl The URL to finalize the session.\n\t */\n\tasync finalizeSession(finalizeUrl: string): Promise<void> {\n\t\tconst response = await this.sdk.httpClient.request(finalizeUrl, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: { Authorization: `Bearer ${this.sessionId}` },\n\t\t\tcredentials: 'include',\n\t\t});\n\t\tconst redirectUri = new URL(await response.text());\n\n\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t}\n\n\t\tif (!redirectUri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\tthrow new Error('Invalid redirect URI');\n\t\t}\n\n\t\tawait this.sdk.tokenExchange(\n\t\t\t(await this.sdk.options.callbackHandler(redirectUri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t);\n\t}\n\n\t/**\n\t * Submits a form with the provided [formId] and [data].\n\t *\n\t * @returns {Promise<LoginFlowState>}\n\t */\n\tasync submitForm(formId?: string, body: Record<string, unknown> = {}): Promise<LoginFlowState> {\n\t\tconst response = await this.sdk.httpClient.request<LoginFlowState>(\n\t\t\tnew URL(`/flow/api/v1/${formId ? `form/${formId}` : 'init'}`, this.sdk.options.issuer).toString(),\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: { Authorization: `Bearer ${this.sessionId}`, 'Content-Type': 'application/json' },\n\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\tcredentials: 'include',\n\t\t\t},\n\t\t);\n\t\tconst data = await response.json();\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status >= 400 && response.status < 500) {\n\t\t\t\tif (response.status !== 403 && data?.hostedUrl && !data.messages) {\n\t\t\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t\t\t}\n\n\t\t\t\tif (response.status !== 400) {\n\t\t\t\t\tthrow new Error(`HTTP ${response.status}: ${response.statusText}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (data.finalizeUrl) {\n\t\t\tawait this.finalizeSession(data.finalizeUrl);\n\t\t} else if (data.hostedUrl && !data.forms && !data.messages) {\n\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t}\n\n\t\treturn data;\n\t}\n}\n"],"names":["NativeFlowHandler","sdk","params","sessionId","state","State","authorizationUrl","response","redirectUri","finalizeUrl","formId","body","data","FallbackError"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- var d=Object.defineProperty;var h=(a,s,e)=>s in a?d(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e;var n=(a,s,e)=>h(a,typeof s!="symbol"?s+"":s,e);import{State as c}from"./State.mjs";import{FallbackError as o}from"./errors.mjs";import"./crypto.mjs";import"./base64Url.mjs";import"./date.mjs";class u{constructor(s,e={}){n(this,"sessionId",null);this.sdk=s,this.params=e}async startSession(s){if(s)return this.sessionId=s,this.submitForm();const e=await c.create(),t=await this.sdk.getAuthorizationUrl(this.params);t.searchParams.append("sdk",this.params.sdk||"web"),t.searchParams.append("state",e.id),t.searchParams.append("code_challenge",e.codeChallenge),t.searchParams.append("nonce",e.nonce),await this.sdk.storage.set(`sty.${e.id}`,JSON.stringify(e));const i=await this.sdk.httpClient.request(t.toString(),{method:"GET",credentials:"include"}),r=new URL(await i.text());if(r.searchParams.has("code")){if(typeof this.sdk.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");if(!r.toString().startsWith(this.sdk.options.redirectUri))throw new Error("Invalid redirect URI");return await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(r.toString(),this.sdk.options.responseMode||"fragment"))}if(r.searchParams.has("error"))throw new Error(`${r.searchParams.get("error")}: ${r.searchParams.get("error_description")}`);if(!r.searchParams.has("session_id"))throw new Error('Failed to start a session: "session_id" is missing');return this.sessionId=r.searchParams.get("session_id"),this.submitForm()}async finalizeSession(s){const e=await this.sdk.httpClient.request(s,{method:"GET",credentials:"include"}),t=new URL(await e.text());if(typeof this.sdk.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");if(!t.toString().startsWith(this.sdk.options.redirectUri))throw new Error("Invalid redirect URI");await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(t.toString(),this.sdk.options.responseMode||"fragment"))}async submitForm(s,e={}){const t=await this.sdk.httpClient.request(new URL(`/flow/api/v1/${s?`form/${s}`:"init"}`,this.sdk.options.issuer).toString(),{method:"POST",headers:{Authorization:`Bearer ${this.sessionId}`,"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"}),i=await t.json();if(!t.ok&&t.status>=400&&t.status<500){if(t.status!==403&&(i!=null&&i.hostedUrl)&&!i.messages)throw new o(new URL(i.hostedUrl));if(t.status!==400)throw new Error(`HTTP ${t.status}: ${t.statusText}`)}if(i.finalizeUrl)await this.finalizeSession(i.finalizeUrl);else if(i.hostedUrl&&!i.forms&&!i.messages)throw new o(new URL(i.hostedUrl));return i}}export{u as NativeFlowHandler};
1
+ import{State as n}from"./State.mjs";import{FallbackError as a}from"./errors.mjs";import"./crypto.mjs";import"./base64Url.mjs";import"./date.mjs";class w{constructor(i,e={}){this.sdk=i,this.params=e}sessionId=null;async startSession(i){if(i)return this.sessionId=i,this.submitForm();const e=await n.create(),s=await this.sdk.getAuthorizationUrl(this.params);s.searchParams.append("sdk",this.params.sdk||"web"),s.searchParams.append("state",e.id),s.searchParams.append("code_challenge",e.codeChallenge),s.searchParams.append("nonce",e.nonce),await this.sdk.storage.set(`sty.${e.id}`,JSON.stringify(e));const t=await this.sdk.httpClient.request(s.toString(),{method:"GET",credentials:"include"}),r=new URL(await t.text());if(r.searchParams.has("code")){if(typeof this.sdk.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");if(!r.toString().startsWith(this.sdk.options.redirectUri))throw new Error("Invalid redirect URI");return await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(r.toString(),this.sdk.options.responseMode||"fragment"))}if(r.searchParams.has("error"))throw new Error(`${r.searchParams.get("error")}: ${r.searchParams.get("error_description")}`);if(!r.searchParams.has("session_id"))throw new Error('Failed to start a session: "session_id" is missing');return this.sessionId=r.searchParams.get("session_id"),this.submitForm()}async finalizeSession(i){const e=await this.sdk.httpClient.request(i,{method:"GET",headers:{Authorization:`Bearer ${this.sessionId}`},credentials:"include"}),s=new URL(await e.text());if(typeof this.sdk.options.callbackHandler!="function")throw new Error("Callback handler is not defined. Please provide a valid callback handler function in the SDK options.");if(!s.toString().startsWith(this.sdk.options.redirectUri))throw new Error("Invalid redirect URI");await this.sdk.tokenExchange(await this.sdk.options.callbackHandler(s.toString(),this.sdk.options.responseMode||"fragment"))}async submitForm(i,e={}){const s=await this.sdk.httpClient.request(new URL(`/flow/api/v1/${i?`form/${i}`:"init"}`,this.sdk.options.issuer).toString(),{method:"POST",headers:{Authorization:`Bearer ${this.sessionId}`,"Content-Type":"application/json"},body:JSON.stringify(e),credentials:"include"}),t=await s.json();if(!s.ok&&s.status>=400&&s.status<500){if(s.status!==403&&t?.hostedUrl&&!t.messages)throw new a(new URL(t.hostedUrl));if(s.status!==400)throw new Error(`HTTP ${s.status}: ${s.statusText}`)}if(t.finalizeUrl)await this.finalizeSession(t.finalizeUrl);else if(t.hostedUrl&&!t.forms&&!t.messages)throw new a(new URL(t.hostedUrl));return t}}export{w as NativeFlowHandler};
2
2
  //# sourceMappingURL=NativeFlowHandler.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"NativeFlowHandler.mjs","sources":["../../src/utils/NativeFlowHandler.ts"],"sourcesContent":["import type { NativeParams, LoginFlowState } from '../types';\nimport type { BaseFlow } from '../flows/BaseFlow';\nimport { State } from './State';\nimport { FallbackError } from './errors';\n\nexport class NativeFlowHandler {\n\t/**\n\t * The session ID.\n\t *\n\t * @type {string | null}\n\t */\n\tprotected sessionId: string | null = null;\n\n\tconstructor(\n\t\t/**\n\t\t * The SDK instance.\n\t\t *\n\t\t * @type {SDKStorage}\n\t\t */\n\t\tprotected sdk: BaseFlow,\n\t\t/**\n\t\t * Optional parameters for native configuration.\n\t\t *\n\t\t * @type {NativeParams} [options={}]\n\t\t */\n\t\tprotected params: NativeParams = {},\n\t) {}\n\n\t/**\n\t * Starts a new session.\n\t *\n\t * @param {string} [sessionId] - The session ID to start the session with. If not provided, a new session will be created.\n\t * @returns {Promise<LoginFlowState | void>}\n\t */\n\tasync startSession(sessionId?: string | null): Promise<LoginFlowState | void> {\n\t\tif (sessionId) {\n\t\t\tthis.sessionId = sessionId;\n\t\t\treturn this.submitForm();\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst authorizationUrl = await this.sdk.getAuthorizationUrl(this.params);\n\n\t\tauthorizationUrl.searchParams.append('sdk', this.params.sdk || 'web');\n\t\tauthorizationUrl.searchParams.append('state', state.id);\n\t\tauthorizationUrl.searchParams.append('code_challenge', state.codeChallenge);\n\t\tauthorizationUrl.searchParams.append('nonce', state.nonce);\n\n\t\tawait this.sdk.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tconst response = await this.sdk.httpClient.request(authorizationUrl.toString(), { method: 'GET', credentials: 'include' });\n\t\tconst redirectUri = new URL(await response.text());\n\n\t\tif (redirectUri.searchParams.has('code')) {\n\t\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t\t}\n\t\t\tif (!redirectUri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\t\tthrow new Error('Invalid redirect URI');\n\t\t\t}\n\n\t\t\treturn await this.sdk.tokenExchange(\n\t\t\t\t(await this.sdk.options.callbackHandler(redirectUri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t\t);\n\t\t}\n\n\t\tif (redirectUri.searchParams.has('error')) {\n\t\t\tthrow new Error(`${redirectUri.searchParams.get('error')}: ${redirectUri.searchParams.get('error_description')}`);\n\t\t}\n\n\t\tif (!redirectUri.searchParams.has('session_id')) {\n\t\t\tthrow new Error('Failed to start a session: \"session_id\" is missing');\n\t\t}\n\n\t\tthis.sessionId = redirectUri.searchParams.get('session_id');\n\n\t\treturn this.submitForm();\n\t}\n\n\t/**\n\t * Finalizes the session using the provided [finalizeUrl].\n\t *\n\t * @param {string} finalizeUrl The URL to finalize the session.\n\t */\n\tasync finalizeSession(finalizeUrl: string): Promise<void> {\n\t\tconst response = await this.sdk.httpClient.request(finalizeUrl, { method: 'GET', credentials: 'include' });\n\t\tconst redirectUri = new URL(await response.text());\n\n\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t}\n\n\t\tif (!redirectUri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\tthrow new Error('Invalid redirect URI');\n\t\t}\n\n\t\tawait this.sdk.tokenExchange(\n\t\t\t(await this.sdk.options.callbackHandler(redirectUri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t);\n\t}\n\n\t/**\n\t * Submits a form with the provided [formId] and [data].\n\t *\n\t * @returns {Promise<LoginFlowState>}\n\t */\n\tasync submitForm(formId?: string, body: Record<string, unknown> = {}): Promise<LoginFlowState> {\n\t\tconst response = await this.sdk.httpClient.request<LoginFlowState>(\n\t\t\tnew URL(`/flow/api/v1/${formId ? `form/${formId}` : 'init'}`, this.sdk.options.issuer).toString(),\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: { Authorization: `Bearer ${this.sessionId}`, 'Content-Type': 'application/json' },\n\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\tcredentials: 'include',\n\t\t\t},\n\t\t);\n\t\tconst data = await response.json();\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status >= 400 && response.status < 500) {\n\t\t\t\tif (response.status !== 403 && data?.hostedUrl && !data.messages) {\n\t\t\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t\t\t}\n\n\t\t\t\tif (response.status !== 400) {\n\t\t\t\t\tthrow new Error(`HTTP ${response.status}: ${response.statusText}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (data.finalizeUrl) {\n\t\t\tawait this.finalizeSession(data.finalizeUrl);\n\t\t} else if (data.hostedUrl && !data.forms && !data.messages) {\n\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t}\n\n\t\treturn data;\n\t}\n}\n"],"names":["NativeFlowHandler","sdk","params","__publicField","sessionId","state","State","authorizationUrl","response","redirectUri","finalizeUrl","formId","body","data","FallbackError"],"mappings":"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"}
1
+ {"version":3,"file":"NativeFlowHandler.mjs","sources":["../../src/utils/NativeFlowHandler.ts"],"sourcesContent":["import type { NativeParams, LoginFlowState } from '../types';\nimport type { BaseFlow } from '../flows/BaseFlow';\nimport { State } from './State';\nimport { FallbackError } from './errors';\n\nexport class NativeFlowHandler {\n\t/**\n\t * The session ID.\n\t *\n\t * @type {string | null}\n\t */\n\tprotected sessionId: string | null = null;\n\n\tconstructor(\n\t\t/**\n\t\t * The SDK instance.\n\t\t *\n\t\t * @type {SDKStorage}\n\t\t */\n\t\tprotected sdk: BaseFlow,\n\t\t/**\n\t\t * Optional parameters for native configuration.\n\t\t *\n\t\t * @type {NativeParams} [options={}]\n\t\t */\n\t\tprotected params: NativeParams = {},\n\t) {}\n\n\t/**\n\t * Starts a new session.\n\t *\n\t * @param {string} [sessionId] - The session ID to start the session with. If not provided, a new session will be created.\n\t * @returns {Promise<LoginFlowState | void>}\n\t */\n\tasync startSession(sessionId?: string | null): Promise<LoginFlowState | void> {\n\t\tif (sessionId) {\n\t\t\tthis.sessionId = sessionId;\n\t\t\treturn this.submitForm();\n\t\t}\n\n\t\tconst state = await State.create();\n\t\tconst authorizationUrl = await this.sdk.getAuthorizationUrl(this.params);\n\n\t\tauthorizationUrl.searchParams.append('sdk', this.params.sdk || 'web');\n\t\tauthorizationUrl.searchParams.append('state', state.id);\n\t\tauthorizationUrl.searchParams.append('code_challenge', state.codeChallenge);\n\t\tauthorizationUrl.searchParams.append('nonce', state.nonce);\n\n\t\tawait this.sdk.storage.set(`sty.${state.id}`, JSON.stringify(state));\n\n\t\tconst response = await this.sdk.httpClient.request(authorizationUrl.toString(), { method: 'GET', credentials: 'include' });\n\t\tconst redirectUri = new URL(await response.text());\n\n\t\tif (redirectUri.searchParams.has('code')) {\n\t\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t\t}\n\t\t\tif (!redirectUri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\t\tthrow new Error('Invalid redirect URI');\n\t\t\t}\n\n\t\t\treturn await this.sdk.tokenExchange(\n\t\t\t\t(await this.sdk.options.callbackHandler(redirectUri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t\t);\n\t\t}\n\n\t\tif (redirectUri.searchParams.has('error')) {\n\t\t\tthrow new Error(`${redirectUri.searchParams.get('error')}: ${redirectUri.searchParams.get('error_description')}`);\n\t\t}\n\n\t\tif (!redirectUri.searchParams.has('session_id')) {\n\t\t\tthrow new Error('Failed to start a session: \"session_id\" is missing');\n\t\t}\n\n\t\tthis.sessionId = redirectUri.searchParams.get('session_id');\n\n\t\treturn this.submitForm();\n\t}\n\n\t/**\n\t * Finalizes the session using the provided [finalizeUrl].\n\t *\n\t * @param {string} finalizeUrl The URL to finalize the session.\n\t */\n\tasync finalizeSession(finalizeUrl: string): Promise<void> {\n\t\tconst response = await this.sdk.httpClient.request(finalizeUrl, {\n\t\t\tmethod: 'GET',\n\t\t\theaders: { Authorization: `Bearer ${this.sessionId}` },\n\t\t\tcredentials: 'include',\n\t\t});\n\t\tconst redirectUri = new URL(await response.text());\n\n\t\tif (typeof this.sdk.options.callbackHandler !== 'function') {\n\t\t\tthrow new Error('Callback handler is not defined. Please provide a valid callback handler function in the SDK options.');\n\t\t}\n\n\t\tif (!redirectUri.toString().startsWith(this.sdk.options.redirectUri)) {\n\t\t\tthrow new Error('Invalid redirect URI');\n\t\t}\n\n\t\tawait this.sdk.tokenExchange(\n\t\t\t(await this.sdk.options.callbackHandler(redirectUri.toString(), this.sdk.options.responseMode || 'fragment')) as Record<string, string>,\n\t\t);\n\t}\n\n\t/**\n\t * Submits a form with the provided [formId] and [data].\n\t *\n\t * @returns {Promise<LoginFlowState>}\n\t */\n\tasync submitForm(formId?: string, body: Record<string, unknown> = {}): Promise<LoginFlowState> {\n\t\tconst response = await this.sdk.httpClient.request<LoginFlowState>(\n\t\t\tnew URL(`/flow/api/v1/${formId ? `form/${formId}` : 'init'}`, this.sdk.options.issuer).toString(),\n\t\t\t{\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: { Authorization: `Bearer ${this.sessionId}`, 'Content-Type': 'application/json' },\n\t\t\t\tbody: JSON.stringify(body),\n\t\t\t\tcredentials: 'include',\n\t\t\t},\n\t\t);\n\t\tconst data = await response.json();\n\n\t\tif (!response.ok) {\n\t\t\tif (response.status >= 400 && response.status < 500) {\n\t\t\t\tif (response.status !== 403 && data?.hostedUrl && !data.messages) {\n\t\t\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t\t\t}\n\n\t\t\t\tif (response.status !== 400) {\n\t\t\t\t\tthrow new Error(`HTTP ${response.status}: ${response.statusText}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (data.finalizeUrl) {\n\t\t\tawait this.finalizeSession(data.finalizeUrl);\n\t\t} else if (data.hostedUrl && !data.forms && !data.messages) {\n\t\t\tthrow new FallbackError(new URL(data.hostedUrl));\n\t\t}\n\n\t\treturn data;\n\t}\n}\n"],"names":["NativeFlowHandler","sdk","params","sessionId","state","State","authorizationUrl","response","redirectUri","finalizeUrl","formId","body","data","FallbackError"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- "use strict";var i=Object.defineProperty;var u=(l,e,r)=>e in l?i(l,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[e]=r;var t=(l,e,r)=>u(l,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./date.cjs");class s{constructor(){t(this,"state",null);t(this,"code",null);t(this,"error",null);t(this,"error_description",null);t(this,"id_token",null);t(this,"access_token",null);t(this,"refresh_token",null);t(this,"token_type","bearer");t(this,"scope",null);t(this,"expires_at",null);t(this,"claims",null)}get expires_in(){return this.expires_at?this.expires_at-n.timestamp():0}set expires_in(e){e!==null&&!isNaN(e)&&(this.expires_at=Math.floor(e)+n.timestamp())}static load(e){if(!e)return null;let r=new s;try{Object.assign(r,JSON.parse(e))}catch{r=null}return r}}exports.Session=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./date.cjs");class r{state=null;code=null;error=null;error_description=null;id_token=null;access_token=null;refresh_token=null;token_type="bearer";scope=null;expires_at=null;claims=null;get expires_in(){return this.expires_at?this.expires_at-l.timestamp():0}set expires_in(e){e!==null&&!isNaN(e)&&(this.expires_at=Math.floor(e)+l.timestamp())}static load(e){if(!e)return null;let t=new r;try{Object.assign(t,JSON.parse(e))}catch{t=null}return t}}exports.Session=r;
2
2
  //# sourceMappingURL=Session.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Session.cjs","sources":["../../src/utils/Session.ts"],"sourcesContent":["import type { IdTokenClaims } from '../types';\nimport { timestamp } from './date';\n\n/**\n * Class representing a user's authentication session, storing tokens and related information.\n */\nexport class Session {\n\t/**\n\t * The state parameter used in the authentication request.\n\t * @type {string | null}\n\t */\n\tstate: string | null = null;\n\n\t/**\n\t * The authorization code returned by the authorization server.\n\t * @type {string | null}\n\t */\n\tcode: string | null = null;\n\n\t/**\n\t * The error returned during the authentication process, if any.\n\t * @type {string | null}\n\t */\n\terror: string | null = null;\n\n\t/**\n\t * A description of the error returned during authentication.\n\t * @type {string | null}\n\t */\n\terror_description: string | null = null;\n\n\t/**\n\t * The ID token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\tid_token: string | null = null;\n\n\t/**\n\t * The access token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\taccess_token: string | null = null;\n\n\t/**\n\t * The refresh token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\trefresh_token: string | null = null;\n\n\t/**\n\t * The type of token issued, defaulting to 'bearer'.\n\t * @type {string}\n\t */\n\ttoken_type = 'bearer';\n\n\t/**\n\t * The scope of the issued token.\n\t * @type {string | null}\n\t */\n\tscope: string | null = null;\n\n\t/**\n\t * The expiration timestamp of the access token, represented in seconds since the epoch.\n\t * @type {number | null}\n\t */\n\texpires_at: number | null = null;\n\n\t/**\n\t * The claims associated with the ID token.\n\t * @type {IdTokenClaims | null}\n\t */\n\tclaims: IdTokenClaims | null = null;\n\n\t/**\n\t * Returns the number of seconds until the access token expires.\n\t * If `expires_at` is not set, returns 0.\n\t *\n\t * @returns {number} The number of seconds until the token expires.\n\t */\n\tget expires_in(): number {\n\t\tif (!this.expires_at) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn this.expires_at - timestamp();\n\t}\n\n\t/**\n\t * Sets the expiration time based on a duration in seconds.\n\t * This also updates the `expires_at` timestamp.\n\t *\n\t * @param {number | null} value The number of seconds until the token expires.\n\t */\n\tset expires_in(value: number | null) {\n\t\tif (value !== null && !isNaN(value)) {\n\t\t\tthis.expires_at = Math.floor(value) + timestamp();\n\t\t}\n\t}\n\n\t/**\n\t * Loads a serialized session from a JSON string.\n\t *\n\t * @param {string | null} serializedSession The JSON string representing a session.\n\t * @returns {Session | null} A new session instance populated with the data from the string, or null if parsing fails.\n\t */\n\tstatic load(serializedSession: string | null): Session | null {\n\t\tif (!serializedSession) {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet session: Session | null = new Session();\n\n\t\ttry {\n\t\t\tObject.assign(session, JSON.parse(serializedSession));\n\t\t} catch {\n\t\t\tsession = null;\n\t\t}\n\n\t\treturn session;\n\t}\n}\n"],"names":["Session","__publicField","timestamp","value","serializedSession","session"],"mappings":"kRAMO,MAAMA,CAAQ,CAAd,cAKNC,EAAA,aAAuB,MAMvBA,EAAA,YAAsB,MAMtBA,EAAA,aAAuB,MAMvBA,EAAA,yBAAmC,MAMnCA,EAAA,gBAA0B,MAM1BA,EAAA,oBAA8B,MAM9BA,EAAA,qBAA+B,MAM/BA,EAAA,kBAAa,UAMbA,EAAA,aAAuB,MAMvBA,EAAA,kBAA4B,MAM5BA,EAAA,cAA+B,MAQ/B,IAAI,YAAqB,CACxB,OAAK,KAAK,WAIH,KAAK,WAAaC,YAAA,EAHjB,CAG2B,CASpC,IAAI,WAAWC,EAAsB,CAChCA,IAAU,MAAQ,CAAC,MAAMA,CAAK,IACjC,KAAK,WAAa,KAAK,MAAMA,CAAK,EAAID,EAAAA,UAAA,EACvC,CASD,OAAO,KAAKE,EAAkD,CAC7D,GAAI,CAACA,EACJ,OAAO,KAGR,IAAIC,EAA0B,IAAIL,EAElC,GAAI,CACH,OAAO,OAAOK,EAAS,KAAK,MAAMD,CAAiB,CAAC,CAAA,MAC7C,CACPC,EAAU,IAAA,CAGX,OAAOA,CAAA,CAET"}
1
+ {"version":3,"file":"Session.cjs","sources":["../../src/utils/Session.ts"],"sourcesContent":["import type { IdTokenClaims } from '../types';\nimport { timestamp } from './date';\n\n/**\n * Class representing a user's authentication session, storing tokens and related information.\n */\nexport class Session {\n\t/**\n\t * The state parameter used in the authentication request.\n\t * @type {string | null}\n\t */\n\tstate: string | null = null;\n\n\t/**\n\t * The authorization code returned by the authorization server.\n\t * @type {string | null}\n\t */\n\tcode: string | null = null;\n\n\t/**\n\t * The error returned during the authentication process, if any.\n\t * @type {string | null}\n\t */\n\terror: string | null = null;\n\n\t/**\n\t * A description of the error returned during authentication.\n\t * @type {string | null}\n\t */\n\terror_description: string | null = null;\n\n\t/**\n\t * The ID token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\tid_token: string | null = null;\n\n\t/**\n\t * The access token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\taccess_token: string | null = null;\n\n\t/**\n\t * The refresh token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\trefresh_token: string | null = null;\n\n\t/**\n\t * The type of token issued, defaulting to 'bearer'.\n\t * @type {string}\n\t */\n\ttoken_type = 'bearer';\n\n\t/**\n\t * The scope of the issued token.\n\t * @type {string | null}\n\t */\n\tscope: string | null = null;\n\n\t/**\n\t * The expiration timestamp of the access token, represented in seconds since the epoch.\n\t * @type {number | null}\n\t */\n\texpires_at: number | null = null;\n\n\t/**\n\t * The claims associated with the ID token.\n\t * @type {IdTokenClaims | null}\n\t */\n\tclaims: IdTokenClaims | null = null;\n\n\t/**\n\t * Returns the number of seconds until the access token expires.\n\t * If `expires_at` is not set, returns 0.\n\t *\n\t * @returns {number} The number of seconds until the token expires.\n\t */\n\tget expires_in(): number {\n\t\tif (!this.expires_at) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn this.expires_at - timestamp();\n\t}\n\n\t/**\n\t * Sets the expiration time based on a duration in seconds.\n\t * This also updates the `expires_at` timestamp.\n\t *\n\t * @param {number | null} value The number of seconds until the token expires.\n\t */\n\tset expires_in(value: number | null) {\n\t\tif (value !== null && !isNaN(value)) {\n\t\t\tthis.expires_at = Math.floor(value) + timestamp();\n\t\t}\n\t}\n\n\t/**\n\t * Loads a serialized session from a JSON string.\n\t *\n\t * @param {string | null} serializedSession The JSON string representing a session.\n\t * @returns {Session | null} A new session instance populated with the data from the string, or null if parsing fails.\n\t */\n\tstatic load(serializedSession: string | null): Session | null {\n\t\tif (!serializedSession) {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet session: Session | null = new Session();\n\n\t\ttry {\n\t\t\tObject.assign(session, JSON.parse(serializedSession));\n\t\t} catch {\n\t\t\tsession = null;\n\t\t}\n\n\t\treturn session;\n\t}\n}\n"],"names":["Session","timestamp","value","serializedSession","session"],"mappings":"8GAMO,MAAMA,CAAQ,CAKpB,MAAuB,KAMvB,KAAsB,KAMtB,MAAuB,KAMvB,kBAAmC,KAMnC,SAA0B,KAM1B,aAA8B,KAM9B,cAA+B,KAM/B,WAAa,SAMb,MAAuB,KAMvB,WAA4B,KAM5B,OAA+B,KAQ/B,IAAI,YAAqB,CACxB,OAAK,KAAK,WAIH,KAAK,WAAaC,YAAA,EAHjB,CAIT,CAQA,IAAI,WAAWC,EAAsB,CAChCA,IAAU,MAAQ,CAAC,MAAMA,CAAK,IACjC,KAAK,WAAa,KAAK,MAAMA,CAAK,EAAID,EAAAA,UAAA,EAExC,CAQA,OAAO,KAAKE,EAAkD,CAC7D,GAAI,CAACA,EACJ,OAAO,KAGR,IAAIC,EAA0B,IAAIJ,EAElC,GAAI,CACH,OAAO,OAAOI,EAAS,KAAK,MAAMD,CAAiB,CAAC,CACrD,MAAQ,CACPC,EAAU,IACX,CAEA,OAAOA,CACR,CACD"}
@@ -1,2 +1,2 @@
1
- var i=Object.defineProperty;var o=(l,e,r)=>e in l?i(l,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):l[e]=r;var t=(l,e,r)=>o(l,typeof e!="symbol"?e+"":e,r);import{timestamp as n}from"./date.mjs";class s{constructor(){t(this,"state",null);t(this,"code",null);t(this,"error",null);t(this,"error_description",null);t(this,"id_token",null);t(this,"access_token",null);t(this,"refresh_token",null);t(this,"token_type","bearer");t(this,"scope",null);t(this,"expires_at",null);t(this,"claims",null)}get expires_in(){return this.expires_at?this.expires_at-n():0}set expires_in(e){e!==null&&!isNaN(e)&&(this.expires_at=Math.floor(e)+n())}static load(e){if(!e)return null;let r=new s;try{Object.assign(r,JSON.parse(e))}catch{r=null}return r}}export{s as Session};
1
+ import{timestamp as r}from"./date.mjs";class l{state=null;code=null;error=null;error_description=null;id_token=null;access_token=null;refresh_token=null;token_type="bearer";scope=null;expires_at=null;claims=null;get expires_in(){return this.expires_at?this.expires_at-r():0}set expires_in(e){e!==null&&!isNaN(e)&&(this.expires_at=Math.floor(e)+r())}static load(e){if(!e)return null;let t=new l;try{Object.assign(t,JSON.parse(e))}catch{t=null}return t}}export{l as Session};
2
2
  //# sourceMappingURL=Session.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Session.mjs","sources":["../../src/utils/Session.ts"],"sourcesContent":["import type { IdTokenClaims } from '../types';\nimport { timestamp } from './date';\n\n/**\n * Class representing a user's authentication session, storing tokens and related information.\n */\nexport class Session {\n\t/**\n\t * The state parameter used in the authentication request.\n\t * @type {string | null}\n\t */\n\tstate: string | null = null;\n\n\t/**\n\t * The authorization code returned by the authorization server.\n\t * @type {string | null}\n\t */\n\tcode: string | null = null;\n\n\t/**\n\t * The error returned during the authentication process, if any.\n\t * @type {string | null}\n\t */\n\terror: string | null = null;\n\n\t/**\n\t * A description of the error returned during authentication.\n\t * @type {string | null}\n\t */\n\terror_description: string | null = null;\n\n\t/**\n\t * The ID token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\tid_token: string | null = null;\n\n\t/**\n\t * The access token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\taccess_token: string | null = null;\n\n\t/**\n\t * The refresh token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\trefresh_token: string | null = null;\n\n\t/**\n\t * The type of token issued, defaulting to 'bearer'.\n\t * @type {string}\n\t */\n\ttoken_type = 'bearer';\n\n\t/**\n\t * The scope of the issued token.\n\t * @type {string | null}\n\t */\n\tscope: string | null = null;\n\n\t/**\n\t * The expiration timestamp of the access token, represented in seconds since the epoch.\n\t * @type {number | null}\n\t */\n\texpires_at: number | null = null;\n\n\t/**\n\t * The claims associated with the ID token.\n\t * @type {IdTokenClaims | null}\n\t */\n\tclaims: IdTokenClaims | null = null;\n\n\t/**\n\t * Returns the number of seconds until the access token expires.\n\t * If `expires_at` is not set, returns 0.\n\t *\n\t * @returns {number} The number of seconds until the token expires.\n\t */\n\tget expires_in(): number {\n\t\tif (!this.expires_at) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn this.expires_at - timestamp();\n\t}\n\n\t/**\n\t * Sets the expiration time based on a duration in seconds.\n\t * This also updates the `expires_at` timestamp.\n\t *\n\t * @param {number | null} value The number of seconds until the token expires.\n\t */\n\tset expires_in(value: number | null) {\n\t\tif (value !== null && !isNaN(value)) {\n\t\t\tthis.expires_at = Math.floor(value) + timestamp();\n\t\t}\n\t}\n\n\t/**\n\t * Loads a serialized session from a JSON string.\n\t *\n\t * @param {string | null} serializedSession The JSON string representing a session.\n\t * @returns {Session | null} A new session instance populated with the data from the string, or null if parsing fails.\n\t */\n\tstatic load(serializedSession: string | null): Session | null {\n\t\tif (!serializedSession) {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet session: Session | null = new Session();\n\n\t\ttry {\n\t\t\tObject.assign(session, JSON.parse(serializedSession));\n\t\t} catch {\n\t\t\tsession = null;\n\t\t}\n\n\t\treturn session;\n\t}\n}\n"],"names":["Session","__publicField","timestamp","value","serializedSession","session"],"mappings":"2MAMO,MAAMA,CAAQ,CAAd,cAKNC,EAAA,aAAuB,MAMvBA,EAAA,YAAsB,MAMtBA,EAAA,aAAuB,MAMvBA,EAAA,yBAAmC,MAMnCA,EAAA,gBAA0B,MAM1BA,EAAA,oBAA8B,MAM9BA,EAAA,qBAA+B,MAM/BA,EAAA,kBAAa,UAMbA,EAAA,aAAuB,MAMvBA,EAAA,kBAA4B,MAM5BA,EAAA,cAA+B,MAQ/B,IAAI,YAAqB,CACxB,OAAK,KAAK,WAIH,KAAK,WAAaC,EAAA,EAHjB,CAG2B,CASpC,IAAI,WAAWC,EAAsB,CAChCA,IAAU,MAAQ,CAAC,MAAMA,CAAK,IACjC,KAAK,WAAa,KAAK,MAAMA,CAAK,EAAID,EAAA,EACvC,CASD,OAAO,KAAKE,EAAkD,CAC7D,GAAI,CAACA,EACJ,OAAO,KAGR,IAAIC,EAA0B,IAAIL,EAElC,GAAI,CACH,OAAO,OAAOK,EAAS,KAAK,MAAMD,CAAiB,CAAC,CAAA,MAC7C,CACPC,EAAU,IAAA,CAGX,OAAOA,CAAA,CAET"}
1
+ {"version":3,"file":"Session.mjs","sources":["../../src/utils/Session.ts"],"sourcesContent":["import type { IdTokenClaims } from '../types';\nimport { timestamp } from './date';\n\n/**\n * Class representing a user's authentication session, storing tokens and related information.\n */\nexport class Session {\n\t/**\n\t * The state parameter used in the authentication request.\n\t * @type {string | null}\n\t */\n\tstate: string | null = null;\n\n\t/**\n\t * The authorization code returned by the authorization server.\n\t * @type {string | null}\n\t */\n\tcode: string | null = null;\n\n\t/**\n\t * The error returned during the authentication process, if any.\n\t * @type {string | null}\n\t */\n\terror: string | null = null;\n\n\t/**\n\t * A description of the error returned during authentication.\n\t * @type {string | null}\n\t */\n\terror_description: string | null = null;\n\n\t/**\n\t * The ID token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\tid_token: string | null = null;\n\n\t/**\n\t * The access token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\taccess_token: string | null = null;\n\n\t/**\n\t * The refresh token issued by the authorization server.\n\t * @type {string | null}\n\t */\n\trefresh_token: string | null = null;\n\n\t/**\n\t * The type of token issued, defaulting to 'bearer'.\n\t * @type {string}\n\t */\n\ttoken_type = 'bearer';\n\n\t/**\n\t * The scope of the issued token.\n\t * @type {string | null}\n\t */\n\tscope: string | null = null;\n\n\t/**\n\t * The expiration timestamp of the access token, represented in seconds since the epoch.\n\t * @type {number | null}\n\t */\n\texpires_at: number | null = null;\n\n\t/**\n\t * The claims associated with the ID token.\n\t * @type {IdTokenClaims | null}\n\t */\n\tclaims: IdTokenClaims | null = null;\n\n\t/**\n\t * Returns the number of seconds until the access token expires.\n\t * If `expires_at` is not set, returns 0.\n\t *\n\t * @returns {number} The number of seconds until the token expires.\n\t */\n\tget expires_in(): number {\n\t\tif (!this.expires_at) {\n\t\t\treturn 0;\n\t\t}\n\n\t\treturn this.expires_at - timestamp();\n\t}\n\n\t/**\n\t * Sets the expiration time based on a duration in seconds.\n\t * This also updates the `expires_at` timestamp.\n\t *\n\t * @param {number | null} value The number of seconds until the token expires.\n\t */\n\tset expires_in(value: number | null) {\n\t\tif (value !== null && !isNaN(value)) {\n\t\t\tthis.expires_at = Math.floor(value) + timestamp();\n\t\t}\n\t}\n\n\t/**\n\t * Loads a serialized session from a JSON string.\n\t *\n\t * @param {string | null} serializedSession The JSON string representing a session.\n\t * @returns {Session | null} A new session instance populated with the data from the string, or null if parsing fails.\n\t */\n\tstatic load(serializedSession: string | null): Session | null {\n\t\tif (!serializedSession) {\n\t\t\treturn null;\n\t\t}\n\n\t\tlet session: Session | null = new Session();\n\n\t\ttry {\n\t\t\tObject.assign(session, JSON.parse(serializedSession));\n\t\t} catch {\n\t\t\tsession = null;\n\t\t}\n\n\t\treturn session;\n\t}\n}\n"],"names":["Session","timestamp","value","serializedSession","session"],"mappings":"uCAMO,MAAMA,CAAQ,CAKpB,MAAuB,KAMvB,KAAsB,KAMtB,MAAuB,KAMvB,kBAAmC,KAMnC,SAA0B,KAM1B,aAA8B,KAM9B,cAA+B,KAM/B,WAAa,SAMb,MAAuB,KAMvB,WAA4B,KAM5B,OAA+B,KAQ/B,IAAI,YAAqB,CACxB,OAAK,KAAK,WAIH,KAAK,WAAaC,EAAA,EAHjB,CAIT,CAQA,IAAI,WAAWC,EAAsB,CAChCA,IAAU,MAAQ,CAAC,MAAMA,CAAK,IACjC,KAAK,WAAa,KAAK,MAAMA,CAAK,EAAID,EAAA,EAExC,CAQA,OAAO,KAAKE,EAAkD,CAC7D,GAAI,CAACA,EACJ,OAAO,KAGR,IAAIC,EAA0B,IAAIJ,EAElC,GAAI,CACH,OAAO,OAAOI,EAAS,KAAK,MAAMD,CAAiB,CAAC,CACrD,MAAQ,CACPC,EAAU,IACX,CAEA,OAAOA,CACR,CACD"}
@@ -1,2 +1,2 @@
1
- "use strict";var o=Object.defineProperty;var d=(n,e,t)=>e in n?o(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var r=(n,e,t)=>d(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./crypto.cjs"),s=require("./date.cjs");require("./base64Url.cjs");class i{constructor(){r(this,"id");r(this,"createdAt");r(this,"codeVerifier");r(this,"codeChallenge");r(this,"nonce")}static async create(){const e=new i;return e.id=c.Crypto.generateState(),e.createdAt=s.timestamp(),e.codeVerifier=c.Crypto.generateCodeVerifier(),e.codeChallenge=await c.Crypto.generateCodeChallenge(e.codeVerifier),e.nonce=c.Crypto.generateNonce(),e}static fromSerializedData(e){const t=new i,a=JSON.parse(e);return t.id=a.id,t.createdAt=a.createdAt,t.codeVerifier=a.codeVerifier,t.codeChallenge=a.codeChallenge,t.nonce=a.nonce,t}}exports.State=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./crypto.cjs"),c=require("./date.cjs");require("./base64Url.cjs");class a{id;createdAt;codeVerifier;codeChallenge;nonce;static async create(){const e=new a;return e.id=n.Crypto.generateState(),e.createdAt=c.timestamp(),e.codeVerifier=n.Crypto.generateCodeVerifier(),e.codeChallenge=await n.Crypto.generateCodeChallenge(e.codeVerifier),e.nonce=n.Crypto.generateNonce(),e}static fromSerializedData(e){const t=new a,r=JSON.parse(e);return t.id=r.id,t.createdAt=r.createdAt,t.codeVerifier=r.codeVerifier,t.codeChallenge=r.codeChallenge,t.nonce=r.nonce,t}}exports.State=a;
2
2
  //# sourceMappingURL=State.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"State.cjs","sources":["../../src/utils/State.ts"],"sourcesContent":["import { Crypto } from './crypto';\nimport { timestamp } from './date';\n\n/**\n * Class representing an OAuth state, including code verifier and nonce for PKCE flows.\n */\nexport class State {\n\t/**\n\t * The unique identifier for the state.\n\t * @type {string}\n\t */\n\tid!: string;\n\n\t/**\n\t * The timestamp when the state was created, represented in seconds since the epoch.\n\t * @type {number}\n\t */\n\tcreatedAt!: number;\n\n\t/**\n\t * The code verifier used in the PKCE (Proof Key for Code Exchange) flow.\n\t * @type {string}\n\t */\n\tcodeVerifier!: string;\n\n\t/**\n\t * The code challenge derived from the code verifier for the PKCE flow.\n\t * @type {string}\n\t */\n\tcodeChallenge!: string;\n\n\t/**\n\t * The nonce value used to associate a client session with an ID token for replay protection.\n\t * @type {string}\n\t */\n\tnonce!: string;\n\n\t/**\n\t * Creates a new instance of `State` with generated values for PKCE and nonce.\n\t *\n\t * @returns {Promise<State>} A promise that resolves to a new `State` instance.\n\t */\n\tstatic async create(): Promise<State> {\n\t\tconst instance = new State();\n\n\t\tinstance.id = Crypto.generateState();\n\t\tinstance.createdAt = timestamp();\n\t\tinstance.codeVerifier = Crypto.generateCodeVerifier();\n\t\tinstance.codeChallenge = await Crypto.generateCodeChallenge(instance.codeVerifier);\n\t\tinstance.nonce = Crypto.generateNonce();\n\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Deserializes a `State` instance from a JSON string.\n\t *\n\t * @param {string} serializedData The serialized state data as a JSON string.\n\t * @returns {State} A new `State` instance populated with the deserialized data.\n\t */\n\tstatic fromSerializedData(serializedData: string): State {\n\t\tconst instance = new State();\n\t\tconst data = JSON.parse(serializedData);\n\n\t\tinstance.id = data.id;\n\t\tinstance.createdAt = data.createdAt;\n\t\tinstance.codeVerifier = data.codeVerifier;\n\t\tinstance.codeChallenge = data.codeChallenge;\n\t\tinstance.nonce = data.nonce;\n\n\t\treturn instance;\n\t}\n}\n"],"names":["State","__publicField","instance","Crypto","timestamp","serializedData","data"],"mappings":"uUAMO,MAAMA,CAAM,CAAZ,cAKNC,EAAA,WAMAA,EAAA,kBAMAA,EAAA,qBAMAA,EAAA,sBAMAA,EAAA,cAOA,aAAa,QAAyB,CACrC,MAAMC,EAAW,IAAIF,EAErB,OAAAE,EAAS,GAAKC,EAAAA,OAAO,cAAA,EACrBD,EAAS,UAAYE,YAAA,EACrBF,EAAS,aAAeC,EAAAA,OAAO,qBAAA,EAC/BD,EAAS,cAAgB,MAAMC,EAAAA,OAAO,sBAAsBD,EAAS,YAAY,EACjFA,EAAS,MAAQC,EAAAA,OAAO,cAAA,EAEjBD,CAAA,CASR,OAAO,mBAAmBG,EAA+B,CACxD,MAAMH,EAAW,IAAIF,EACfM,EAAO,KAAK,MAAMD,CAAc,EAEtC,OAAAH,EAAS,GAAKI,EAAK,GACnBJ,EAAS,UAAYI,EAAK,UAC1BJ,EAAS,aAAeI,EAAK,aAC7BJ,EAAS,cAAgBI,EAAK,cAC9BJ,EAAS,MAAQI,EAAK,MAEfJ,CAAA,CAET"}
1
+ {"version":3,"file":"State.cjs","sources":["../../src/utils/State.ts"],"sourcesContent":["import { Crypto } from './crypto';\nimport { timestamp } from './date';\n\n/**\n * Class representing an OAuth state, including code verifier and nonce for PKCE flows.\n */\nexport class State {\n\t/**\n\t * The unique identifier for the state.\n\t * @type {string}\n\t */\n\tid!: string;\n\n\t/**\n\t * The timestamp when the state was created, represented in seconds since the epoch.\n\t * @type {number}\n\t */\n\tcreatedAt!: number;\n\n\t/**\n\t * The code verifier used in the PKCE (Proof Key for Code Exchange) flow.\n\t * @type {string}\n\t */\n\tcodeVerifier!: string;\n\n\t/**\n\t * The code challenge derived from the code verifier for the PKCE flow.\n\t * @type {string}\n\t */\n\tcodeChallenge!: string;\n\n\t/**\n\t * The nonce value used to associate a client session with an ID token for replay protection.\n\t * @type {string}\n\t */\n\tnonce!: string;\n\n\t/**\n\t * Creates a new instance of `State` with generated values for PKCE and nonce.\n\t *\n\t * @returns {Promise<State>} A promise that resolves to a new `State` instance.\n\t */\n\tstatic async create(): Promise<State> {\n\t\tconst instance = new State();\n\n\t\tinstance.id = Crypto.generateState();\n\t\tinstance.createdAt = timestamp();\n\t\tinstance.codeVerifier = Crypto.generateCodeVerifier();\n\t\tinstance.codeChallenge = await Crypto.generateCodeChallenge(instance.codeVerifier);\n\t\tinstance.nonce = Crypto.generateNonce();\n\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Deserializes a `State` instance from a JSON string.\n\t *\n\t * @param {string} serializedData The serialized state data as a JSON string.\n\t * @returns {State} A new `State` instance populated with the deserialized data.\n\t */\n\tstatic fromSerializedData(serializedData: string): State {\n\t\tconst instance = new State();\n\t\tconst data = JSON.parse(serializedData);\n\n\t\tinstance.id = data.id;\n\t\tinstance.createdAt = data.createdAt;\n\t\tinstance.codeVerifier = data.codeVerifier;\n\t\tinstance.codeChallenge = data.codeChallenge;\n\t\tinstance.nonce = data.nonce;\n\n\t\treturn instance;\n\t}\n}\n"],"names":["State","instance","Crypto","timestamp","serializedData","data"],"mappings":"mKAMO,MAAMA,CAAM,CAKlB,GAMA,UAMA,aAMA,cAMA,MAOA,aAAa,QAAyB,CACrC,MAAMC,EAAW,IAAID,EAErB,OAAAC,EAAS,GAAKC,EAAAA,OAAO,cAAA,EACrBD,EAAS,UAAYE,YAAA,EACrBF,EAAS,aAAeC,EAAAA,OAAO,qBAAA,EAC/BD,EAAS,cAAgB,MAAMC,EAAAA,OAAO,sBAAsBD,EAAS,YAAY,EACjFA,EAAS,MAAQC,EAAAA,OAAO,cAAA,EAEjBD,CACR,CAQA,OAAO,mBAAmBG,EAA+B,CACxD,MAAMH,EAAW,IAAID,EACfK,EAAO,KAAK,MAAMD,CAAc,EAEtC,OAAAH,EAAS,GAAKI,EAAK,GACnBJ,EAAS,UAAYI,EAAK,UAC1BJ,EAAS,aAAeI,EAAK,aAC7BJ,EAAS,cAAgBI,EAAK,cAC9BJ,EAAS,MAAQI,EAAK,MAEfJ,CACR,CACD"}
@@ -1,2 +1,2 @@
1
- var o=Object.defineProperty;var d=(n,e,r)=>e in n?o(n,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[e]=r;var t=(n,e,r)=>d(n,typeof e!="symbol"?e+"":e,r);import{Crypto as c}from"./crypto.mjs";import{timestamp as l}from"./date.mjs";import"./base64Url.mjs";class i{constructor(){t(this,"id");t(this,"createdAt");t(this,"codeVerifier");t(this,"codeChallenge");t(this,"nonce")}static async create(){const e=new i;return e.id=c.generateState(),e.createdAt=l(),e.codeVerifier=c.generateCodeVerifier(),e.codeChallenge=await c.generateCodeChallenge(e.codeVerifier),e.nonce=c.generateNonce(),e}static fromSerializedData(e){const r=new i,a=JSON.parse(e);return r.id=a.id,r.createdAt=a.createdAt,r.codeVerifier=a.codeVerifier,r.codeChallenge=a.codeChallenge,r.nonce=a.nonce,r}}export{i as State};
1
+ import{Crypto as n}from"./crypto.mjs";import{timestamp as c}from"./date.mjs";import"./base64Url.mjs";class a{id;createdAt;codeVerifier;codeChallenge;nonce;static async create(){const e=new a;return e.id=n.generateState(),e.createdAt=c(),e.codeVerifier=n.generateCodeVerifier(),e.codeChallenge=await n.generateCodeChallenge(e.codeVerifier),e.nonce=n.generateNonce(),e}static fromSerializedData(e){const r=new a,t=JSON.parse(e);return r.id=t.id,r.createdAt=t.createdAt,r.codeVerifier=t.codeVerifier,r.codeChallenge=t.codeChallenge,r.nonce=t.nonce,r}}export{a as State};
2
2
  //# sourceMappingURL=State.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"State.mjs","sources":["../../src/utils/State.ts"],"sourcesContent":["import { Crypto } from './crypto';\nimport { timestamp } from './date';\n\n/**\n * Class representing an OAuth state, including code verifier and nonce for PKCE flows.\n */\nexport class State {\n\t/**\n\t * The unique identifier for the state.\n\t * @type {string}\n\t */\n\tid!: string;\n\n\t/**\n\t * The timestamp when the state was created, represented in seconds since the epoch.\n\t * @type {number}\n\t */\n\tcreatedAt!: number;\n\n\t/**\n\t * The code verifier used in the PKCE (Proof Key for Code Exchange) flow.\n\t * @type {string}\n\t */\n\tcodeVerifier!: string;\n\n\t/**\n\t * The code challenge derived from the code verifier for the PKCE flow.\n\t * @type {string}\n\t */\n\tcodeChallenge!: string;\n\n\t/**\n\t * The nonce value used to associate a client session with an ID token for replay protection.\n\t * @type {string}\n\t */\n\tnonce!: string;\n\n\t/**\n\t * Creates a new instance of `State` with generated values for PKCE and nonce.\n\t *\n\t * @returns {Promise<State>} A promise that resolves to a new `State` instance.\n\t */\n\tstatic async create(): Promise<State> {\n\t\tconst instance = new State();\n\n\t\tinstance.id = Crypto.generateState();\n\t\tinstance.createdAt = timestamp();\n\t\tinstance.codeVerifier = Crypto.generateCodeVerifier();\n\t\tinstance.codeChallenge = await Crypto.generateCodeChallenge(instance.codeVerifier);\n\t\tinstance.nonce = Crypto.generateNonce();\n\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Deserializes a `State` instance from a JSON string.\n\t *\n\t * @param {string} serializedData The serialized state data as a JSON string.\n\t * @returns {State} A new `State` instance populated with the deserialized data.\n\t */\n\tstatic fromSerializedData(serializedData: string): State {\n\t\tconst instance = new State();\n\t\tconst data = JSON.parse(serializedData);\n\n\t\tinstance.id = data.id;\n\t\tinstance.createdAt = data.createdAt;\n\t\tinstance.codeVerifier = data.codeVerifier;\n\t\tinstance.codeChallenge = data.codeChallenge;\n\t\tinstance.nonce = data.nonce;\n\n\t\treturn instance;\n\t}\n}\n"],"names":["State","__publicField","instance","Crypto","timestamp","serializedData","data"],"mappings":"yQAMO,MAAMA,CAAM,CAAZ,cAKNC,EAAA,WAMAA,EAAA,kBAMAA,EAAA,qBAMAA,EAAA,sBAMAA,EAAA,cAOA,aAAa,QAAyB,CACrC,MAAMC,EAAW,IAAIF,EAErB,OAAAE,EAAS,GAAKC,EAAO,cAAA,EACrBD,EAAS,UAAYE,EAAA,EACrBF,EAAS,aAAeC,EAAO,qBAAA,EAC/BD,EAAS,cAAgB,MAAMC,EAAO,sBAAsBD,EAAS,YAAY,EACjFA,EAAS,MAAQC,EAAO,cAAA,EAEjBD,CAAA,CASR,OAAO,mBAAmBG,EAA+B,CACxD,MAAMH,EAAW,IAAIF,EACfM,EAAO,KAAK,MAAMD,CAAc,EAEtC,OAAAH,EAAS,GAAKI,EAAK,GACnBJ,EAAS,UAAYI,EAAK,UAC1BJ,EAAS,aAAeI,EAAK,aAC7BJ,EAAS,cAAgBI,EAAK,cAC9BJ,EAAS,MAAQI,EAAK,MAEfJ,CAAA,CAET"}
1
+ {"version":3,"file":"State.mjs","sources":["../../src/utils/State.ts"],"sourcesContent":["import { Crypto } from './crypto';\nimport { timestamp } from './date';\n\n/**\n * Class representing an OAuth state, including code verifier and nonce for PKCE flows.\n */\nexport class State {\n\t/**\n\t * The unique identifier for the state.\n\t * @type {string}\n\t */\n\tid!: string;\n\n\t/**\n\t * The timestamp when the state was created, represented in seconds since the epoch.\n\t * @type {number}\n\t */\n\tcreatedAt!: number;\n\n\t/**\n\t * The code verifier used in the PKCE (Proof Key for Code Exchange) flow.\n\t * @type {string}\n\t */\n\tcodeVerifier!: string;\n\n\t/**\n\t * The code challenge derived from the code verifier for the PKCE flow.\n\t * @type {string}\n\t */\n\tcodeChallenge!: string;\n\n\t/**\n\t * The nonce value used to associate a client session with an ID token for replay protection.\n\t * @type {string}\n\t */\n\tnonce!: string;\n\n\t/**\n\t * Creates a new instance of `State` with generated values for PKCE and nonce.\n\t *\n\t * @returns {Promise<State>} A promise that resolves to a new `State` instance.\n\t */\n\tstatic async create(): Promise<State> {\n\t\tconst instance = new State();\n\n\t\tinstance.id = Crypto.generateState();\n\t\tinstance.createdAt = timestamp();\n\t\tinstance.codeVerifier = Crypto.generateCodeVerifier();\n\t\tinstance.codeChallenge = await Crypto.generateCodeChallenge(instance.codeVerifier);\n\t\tinstance.nonce = Crypto.generateNonce();\n\n\t\treturn instance;\n\t}\n\n\t/**\n\t * Deserializes a `State` instance from a JSON string.\n\t *\n\t * @param {string} serializedData The serialized state data as a JSON string.\n\t * @returns {State} A new `State` instance populated with the deserialized data.\n\t */\n\tstatic fromSerializedData(serializedData: string): State {\n\t\tconst instance = new State();\n\t\tconst data = JSON.parse(serializedData);\n\n\t\tinstance.id = data.id;\n\t\tinstance.createdAt = data.createdAt;\n\t\tinstance.codeVerifier = data.codeVerifier;\n\t\tinstance.codeChallenge = data.codeChallenge;\n\t\tinstance.nonce = data.nonce;\n\n\t\treturn instance;\n\t}\n}\n"],"names":["State","instance","Crypto","timestamp","serializedData","data"],"mappings":"qGAMO,MAAMA,CAAM,CAKlB,GAMA,UAMA,aAMA,cAMA,MAOA,aAAa,QAAyB,CACrC,MAAMC,EAAW,IAAID,EAErB,OAAAC,EAAS,GAAKC,EAAO,cAAA,EACrBD,EAAS,UAAYE,EAAA,EACrBF,EAAS,aAAeC,EAAO,qBAAA,EAC/BD,EAAS,cAAgB,MAAMC,EAAO,sBAAsBD,EAAS,YAAY,EACjFA,EAAS,MAAQC,EAAO,cAAA,EAEjBD,CACR,CAQA,OAAO,mBAAmBG,EAA+B,CACxD,MAAMH,EAAW,IAAID,EACfK,EAAO,KAAK,MAAMD,CAAc,EAEtC,OAAAH,EAAS,GAAKI,EAAK,GACnBJ,EAAS,UAAYI,EAAK,UAC1BJ,EAAS,aAAeI,EAAK,aAC7BJ,EAAS,cAAgBI,EAAK,cAC9BJ,EAAS,MAAQI,EAAK,MAEfJ,CACR,CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"base64Url.cjs","sources":["../../src/utils/base64Url.ts"],"sourcesContent":["/**\n * Encodes a buffer or string into a Base64 URL-safe string.\n *\n * @param {string | null | BufferSource | ArrayBuffer} buffer The buffer or string to encode.\n * @returns {string} The Base64 URL-encoded string.\n */\nfunction encode(buffer: string | null | BufferSource | ArrayBuffer): string {\n\tif (typeof buffer === 'string') {\n\t\treturn buffer;\n\t}\n\n\tconst str = String.fromCharCode.apply(null, [...new Uint8Array(buffer as ArrayBuffer)]);\n\n\treturn btoa(str).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n\n/**\n * Decodes a Base64 URL-safe string into an ArrayBuffer.\n *\n * @param {string | BufferSource} base64Url The Base64 URL-safe string or BufferSource to decode.\n * @returns {ArrayBuffer} The decoded ArrayBuffer.\n */\nfunction decode(base64Url: string | BufferSource): ArrayBuffer {\n\tif (typeof base64Url !== 'string') {\n\t\treturn base64Url as ArrayBuffer;\n\t}\n\n\tconst base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n\tconst binStr = atob(base64);\n\tconst binary = new Uint8Array(binStr.length);\n\n\tfor (let i = 0; i < binStr.length; i++) {\n\t\tbinary[i] = binStr.charCodeAt(i);\n\t}\n\n\treturn binary.buffer;\n}\n\n/**\n * Decodes a Base64 URL-safe string into a UTF-8 string.\n *\n * @param {string} base64Url The Base64 URL-safe string to decode.\n * @returns {string} The decoded Unicode string.\n */\nfunction decodeUnicode(base64Url: string): string {\n\treturn decodeURIComponent(\n\t\tatob(base64Url).replace(/(.)/g, (m, p) => {\n\t\t\tlet code = (p as string).charCodeAt(0).toString(16).toUpperCase();\n\t\t\tif (code.length < 2) {\n\t\t\t\tcode = '0' + code;\n\t\t\t}\n\t\t\treturn '%' + code;\n\t\t}),\n\t);\n}\n\nexport const Base64Url = {\n\tencode,\n\tdecode,\n\tdecodeUnicode,\n};\n"],"names":["encode","buffer","str","decode","base64Url","base64","binStr","binary","i","decodeUnicode","m","p","code","Base64Url"],"mappings":"gFAMA,SAASA,EAAOC,EAA4D,CAC3E,GAAI,OAAOA,GAAW,SACrB,OAAOA,EAGR,MAAMC,EAAM,OAAO,aAAa,MAAM,KAAM,CAAC,GAAG,IAAI,WAAWD,CAAqB,CAAC,CAAC,EAEtF,OAAO,KAAKC,CAAG,EAAE,QAAQ,KAAM,EAAE,EAAE,QAAQ,MAAO,GAAG,EAAE,QAAQ,MAAO,GAAG,CAC1E,CAQA,SAASC,EAAOC,EAA+C,CAC9D,GAAI,OAAOA,GAAc,SACxB,OAAOA,EAGR,MAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAAE,QAAQ,MAAO,EAAE,EAC1EE,EAAS,KAAKD,CAAM,EACpBE,EAAS,IAAI,WAAWD,EAAO,MAAM,EAE3C,QAASE,EAAI,EAAGA,EAAIF,EAAO,OAAQE,IAClCD,EAAOC,CAAC,EAAIF,EAAO,WAAWE,CAAC,EAGhC,OAAOD,EAAO,MACf,CAQA,SAASE,EAAcL,EAA2B,CACjD,OAAO,mBACN,KAAKA,CAAS,EAAE,QAAQ,OAAQ,CAACM,EAAGC,IAAM,CACzC,IAAIC,EAAQD,EAAa,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,YAAA,EACpD,OAAIC,EAAK,OAAS,IACjBA,EAAO,IAAMA,GAEP,IAAMA,CAAA,CACb,CAAA,CAEH,CAEO,MAAMC,EAAY,CACxB,OAAAb,EACA,OAAAG,EACA,cAAAM,CACD"}
1
+ {"version":3,"file":"base64Url.cjs","sources":["../../src/utils/base64Url.ts"],"sourcesContent":["/**\n * Encodes a buffer or string into a Base64 URL-safe string.\n *\n * @param {string | null | BufferSource | ArrayBuffer} buffer The buffer or string to encode.\n * @returns {string} The Base64 URL-encoded string.\n */\nfunction encode(buffer: string | null | BufferSource | ArrayBuffer): string {\n\tif (typeof buffer === 'string') {\n\t\treturn buffer;\n\t}\n\n\tconst str = String.fromCharCode.apply(null, [...new Uint8Array(buffer as ArrayBuffer)]);\n\n\treturn btoa(str).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n\n/**\n * Decodes a Base64 URL-safe string into an ArrayBuffer.\n *\n * @param {string | BufferSource} base64Url The Base64 URL-safe string or BufferSource to decode.\n * @returns {ArrayBuffer} The decoded ArrayBuffer.\n */\nfunction decode(base64Url: string | BufferSource): ArrayBuffer {\n\tif (typeof base64Url !== 'string') {\n\t\treturn base64Url as ArrayBuffer;\n\t}\n\n\tconst base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n\tconst binStr = atob(base64);\n\tconst binary = new Uint8Array(binStr.length);\n\n\tfor (let i = 0; i < binStr.length; i++) {\n\t\tbinary[i] = binStr.charCodeAt(i);\n\t}\n\n\treturn binary.buffer;\n}\n\n/**\n * Decodes a Base64 URL-safe string into a UTF-8 string.\n *\n * @param {string} base64Url The Base64 URL-safe string to decode.\n * @returns {string} The decoded Unicode string.\n */\nfunction decodeUnicode(base64Url: string): string {\n\treturn decodeURIComponent(\n\t\tatob(base64Url).replace(/(.)/g, (m, p) => {\n\t\t\tlet code = (p as string).charCodeAt(0).toString(16).toUpperCase();\n\t\t\tif (code.length < 2) {\n\t\t\t\tcode = '0' + code;\n\t\t\t}\n\t\t\treturn '%' + code;\n\t\t}),\n\t);\n}\n\nexport const Base64Url = {\n\tencode,\n\tdecode,\n\tdecodeUnicode,\n};\n"],"names":["encode","buffer","str","decode","base64Url","base64","binStr","binary","i","decodeUnicode","m","p","code","Base64Url"],"mappings":"gFAMA,SAASA,EAAOC,EAA4D,CAC3E,GAAI,OAAOA,GAAW,SACrB,OAAOA,EAGR,MAAMC,EAAM,OAAO,aAAa,MAAM,KAAM,CAAC,GAAG,IAAI,WAAWD,CAAqB,CAAC,CAAC,EAEtF,OAAO,KAAKC,CAAG,EAAE,QAAQ,KAAM,EAAE,EAAE,QAAQ,MAAO,GAAG,EAAE,QAAQ,MAAO,GAAG,CAC1E,CAQA,SAASC,EAAOC,EAA+C,CAC9D,GAAI,OAAOA,GAAc,SACxB,OAAOA,EAGR,MAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAAE,QAAQ,MAAO,EAAE,EAC1EE,EAAS,KAAKD,CAAM,EACpBE,EAAS,IAAI,WAAWD,EAAO,MAAM,EAE3C,QAASE,EAAI,EAAGA,EAAIF,EAAO,OAAQE,IAClCD,EAAOC,CAAC,EAAIF,EAAO,WAAWE,CAAC,EAGhC,OAAOD,EAAO,MACf,CAQA,SAASE,EAAcL,EAA2B,CACjD,OAAO,mBACN,KAAKA,CAAS,EAAE,QAAQ,OAAQ,CAACM,EAAGC,IAAM,CACzC,IAAIC,EAAQD,EAAa,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,YAAA,EACpD,OAAIC,EAAK,OAAS,IACjBA,EAAO,IAAMA,GAEP,IAAMA,CACd,CAAC,CAAA,CAEH,CAEO,MAAMC,EAAY,CACxB,OAAAb,EACA,OAAAG,EACA,cAAAM,CACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"base64Url.mjs","sources":["../../src/utils/base64Url.ts"],"sourcesContent":["/**\n * Encodes a buffer or string into a Base64 URL-safe string.\n *\n * @param {string | null | BufferSource | ArrayBuffer} buffer The buffer or string to encode.\n * @returns {string} The Base64 URL-encoded string.\n */\nfunction encode(buffer: string | null | BufferSource | ArrayBuffer): string {\n\tif (typeof buffer === 'string') {\n\t\treturn buffer;\n\t}\n\n\tconst str = String.fromCharCode.apply(null, [...new Uint8Array(buffer as ArrayBuffer)]);\n\n\treturn btoa(str).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n\n/**\n * Decodes a Base64 URL-safe string into an ArrayBuffer.\n *\n * @param {string | BufferSource} base64Url The Base64 URL-safe string or BufferSource to decode.\n * @returns {ArrayBuffer} The decoded ArrayBuffer.\n */\nfunction decode(base64Url: string | BufferSource): ArrayBuffer {\n\tif (typeof base64Url !== 'string') {\n\t\treturn base64Url as ArrayBuffer;\n\t}\n\n\tconst base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n\tconst binStr = atob(base64);\n\tconst binary = new Uint8Array(binStr.length);\n\n\tfor (let i = 0; i < binStr.length; i++) {\n\t\tbinary[i] = binStr.charCodeAt(i);\n\t}\n\n\treturn binary.buffer;\n}\n\n/**\n * Decodes a Base64 URL-safe string into a UTF-8 string.\n *\n * @param {string} base64Url The Base64 URL-safe string to decode.\n * @returns {string} The decoded Unicode string.\n */\nfunction decodeUnicode(base64Url: string): string {\n\treturn decodeURIComponent(\n\t\tatob(base64Url).replace(/(.)/g, (m, p) => {\n\t\t\tlet code = (p as string).charCodeAt(0).toString(16).toUpperCase();\n\t\t\tif (code.length < 2) {\n\t\t\t\tcode = '0' + code;\n\t\t\t}\n\t\t\treturn '%' + code;\n\t\t}),\n\t);\n}\n\nexport const Base64Url = {\n\tencode,\n\tdecode,\n\tdecodeUnicode,\n};\n"],"names":["encode","buffer","str","decode","base64Url","base64","binStr","binary","i","decodeUnicode","m","p","code","Base64Url"],"mappings":"AAMA,SAASA,EAAOC,EAA4D,CAC3E,GAAI,OAAOA,GAAW,SACrB,OAAOA,EAGR,MAAMC,EAAM,OAAO,aAAa,MAAM,KAAM,CAAC,GAAG,IAAI,WAAWD,CAAqB,CAAC,CAAC,EAEtF,OAAO,KAAKC,CAAG,EAAE,QAAQ,KAAM,EAAE,EAAE,QAAQ,MAAO,GAAG,EAAE,QAAQ,MAAO,GAAG,CAC1E,CAQA,SAASC,EAAOC,EAA+C,CAC9D,GAAI,OAAOA,GAAc,SACxB,OAAOA,EAGR,MAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAAE,QAAQ,MAAO,EAAE,EAC1EE,EAAS,KAAKD,CAAM,EACpBE,EAAS,IAAI,WAAWD,EAAO,MAAM,EAE3C,QAASE,EAAI,EAAGA,EAAIF,EAAO,OAAQE,IAClCD,EAAOC,CAAC,EAAIF,EAAO,WAAWE,CAAC,EAGhC,OAAOD,EAAO,MACf,CAQA,SAASE,EAAcL,EAA2B,CACjD,OAAO,mBACN,KAAKA,CAAS,EAAE,QAAQ,OAAQ,CAACM,EAAGC,IAAM,CACzC,IAAIC,EAAQD,EAAa,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,YAAA,EACpD,OAAIC,EAAK,OAAS,IACjBA,EAAO,IAAMA,GAEP,IAAMA,CAAA,CACb,CAAA,CAEH,CAEO,MAAMC,EAAY,CACxB,OAAAb,EACA,OAAAG,EACA,cAAAM,CACD"}
1
+ {"version":3,"file":"base64Url.mjs","sources":["../../src/utils/base64Url.ts"],"sourcesContent":["/**\n * Encodes a buffer or string into a Base64 URL-safe string.\n *\n * @param {string | null | BufferSource | ArrayBuffer} buffer The buffer or string to encode.\n * @returns {string} The Base64 URL-encoded string.\n */\nfunction encode(buffer: string | null | BufferSource | ArrayBuffer): string {\n\tif (typeof buffer === 'string') {\n\t\treturn buffer;\n\t}\n\n\tconst str = String.fromCharCode.apply(null, [...new Uint8Array(buffer as ArrayBuffer)]);\n\n\treturn btoa(str).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n\n/**\n * Decodes a Base64 URL-safe string into an ArrayBuffer.\n *\n * @param {string | BufferSource} base64Url The Base64 URL-safe string or BufferSource to decode.\n * @returns {ArrayBuffer} The decoded ArrayBuffer.\n */\nfunction decode(base64Url: string | BufferSource): ArrayBuffer {\n\tif (typeof base64Url !== 'string') {\n\t\treturn base64Url as ArrayBuffer;\n\t}\n\n\tconst base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/').replace(/\\s/g, '');\n\tconst binStr = atob(base64);\n\tconst binary = new Uint8Array(binStr.length);\n\n\tfor (let i = 0; i < binStr.length; i++) {\n\t\tbinary[i] = binStr.charCodeAt(i);\n\t}\n\n\treturn binary.buffer;\n}\n\n/**\n * Decodes a Base64 URL-safe string into a UTF-8 string.\n *\n * @param {string} base64Url The Base64 URL-safe string to decode.\n * @returns {string} The decoded Unicode string.\n */\nfunction decodeUnicode(base64Url: string): string {\n\treturn decodeURIComponent(\n\t\tatob(base64Url).replace(/(.)/g, (m, p) => {\n\t\t\tlet code = (p as string).charCodeAt(0).toString(16).toUpperCase();\n\t\t\tif (code.length < 2) {\n\t\t\t\tcode = '0' + code;\n\t\t\t}\n\t\t\treturn '%' + code;\n\t\t}),\n\t);\n}\n\nexport const Base64Url = {\n\tencode,\n\tdecode,\n\tdecodeUnicode,\n};\n"],"names":["encode","buffer","str","decode","base64Url","base64","binStr","binary","i","decodeUnicode","m","p","code","Base64Url"],"mappings":"AAMA,SAASA,EAAOC,EAA4D,CAC3E,GAAI,OAAOA,GAAW,SACrB,OAAOA,EAGR,MAAMC,EAAM,OAAO,aAAa,MAAM,KAAM,CAAC,GAAG,IAAI,WAAWD,CAAqB,CAAC,CAAC,EAEtF,OAAO,KAAKC,CAAG,EAAE,QAAQ,KAAM,EAAE,EAAE,QAAQ,MAAO,GAAG,EAAE,QAAQ,MAAO,GAAG,CAC1E,CAQA,SAASC,EAAOC,EAA+C,CAC9D,GAAI,OAAOA,GAAc,SACxB,OAAOA,EAGR,MAAMC,EAASD,EAAU,QAAQ,KAAM,GAAG,EAAE,QAAQ,KAAM,GAAG,EAAE,QAAQ,MAAO,EAAE,EAC1EE,EAAS,KAAKD,CAAM,EACpBE,EAAS,IAAI,WAAWD,EAAO,MAAM,EAE3C,QAASE,EAAI,EAAGA,EAAIF,EAAO,OAAQE,IAClCD,EAAOC,CAAC,EAAIF,EAAO,WAAWE,CAAC,EAGhC,OAAOD,EAAO,MACf,CAQA,SAASE,EAAcL,EAA2B,CACjD,OAAO,mBACN,KAAKA,CAAS,EAAE,QAAQ,OAAQ,CAACM,EAAGC,IAAM,CACzC,IAAIC,EAAQD,EAAa,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,YAAA,EACpD,OAAIC,EAAK,OAAS,IACjBA,EAAO,IAAMA,GAEP,IAAMA,CACd,CAAC,CAAA,CAEH,CAEO,MAAMC,EAAY,CACxB,OAAAb,EACA,OAAAG,EACA,cAAAM,CACD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./base64Url.cjs");async function o(e){e.challenge=r.Base64Url.decode(e.challenge),e.user.id=r.Base64Url.decode(e.user.id),e.excludeCredentials&&(e.excludeCredentials=e.excludeCredentials.map(a=>(a.id=r.Base64Url.decode(a.id),a)));const n=new AbortController,t=await navigator.credentials.create({publicKey:e,signal:n.signal});return t.type!=="public-key"?Promise.reject(new Error("Not a public key")):{id:t.id,rawId:r.Base64Url.encode(t.rawId),type:t.type,authenticatorAttachment:t.authenticatorAttachment,response:{clientDataJSON:r.Base64Url.encode(t.response.clientDataJSON),attestationObject:r.Base64Url.encode(t.response.attestationObject),transports:t.response.getTransports?t.response.getTransports():[]}}}async function c(e,n=!1){var l;e.challenge=r.Base64Url.decode(e.challenge),e.allowCredentials&&(e.allowCredentials=(l=e.allowCredentials)==null?void 0:l.map(s=>(s.id=r.Base64Url.decode(s.id),s)));const t=new AbortController,a=await navigator.credentials.get({publicKey:e,signal:t.signal,mediation:n?"conditional":"optional"});return a.type!=="public-key"?Promise.reject(new Error("Not a public key")):{id:a.id,rawId:r.Base64Url.encode(a.rawId),type:a.type,response:{clientDataJSON:r.Base64Url.encode(a.response.clientDataJSON),authenticatorData:r.Base64Url.encode(a.response.authenticatorData),signature:r.Base64Url.encode(a.response.signature),userHandle:r.Base64Url.encode(a.response.userHandle)}}}exports.createCredential=o;exports.getCredential=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./base64Url.cjs");async function l(e){e.challenge=r.Base64Url.decode(e.challenge),e.user.id=r.Base64Url.decode(e.user.id),e.excludeCredentials&&(e.excludeCredentials=e.excludeCredentials.map(a=>(a.id=r.Base64Url.decode(a.id),a)));const n=new AbortController,t=await navigator.credentials.create({publicKey:e,signal:n.signal});return t.type!=="public-key"?Promise.reject(new Error("Not a public key")):{id:t.id,rawId:r.Base64Url.encode(t.rawId),type:t.type,authenticatorAttachment:t.authenticatorAttachment,response:{clientDataJSON:r.Base64Url.encode(t.response.clientDataJSON),attestationObject:r.Base64Url.encode(t.response.attestationObject),transports:t.response.getTransports?t.response.getTransports():[]}}}async function o(e,n=!1){e.challenge=r.Base64Url.decode(e.challenge),e.allowCredentials&&(e.allowCredentials=e.allowCredentials?.map(s=>(s.id=r.Base64Url.decode(s.id),s)));const t=new AbortController,a=await navigator.credentials.get({publicKey:e,signal:t.signal,mediation:n?"conditional":"optional"});return a.type!=="public-key"?Promise.reject(new Error("Not a public key")):{id:a.id,rawId:r.Base64Url.encode(a.rawId),type:a.type,response:{clientDataJSON:r.Base64Url.encode(a.response.clientDataJSON),authenticatorData:r.Base64Url.encode(a.response.authenticatorData),signature:r.Base64Url.encode(a.response.signature),userHandle:r.Base64Url.encode(a.response.userHandle)}}}exports.createCredential=l;exports.getCredential=o;
2
2
  //# sourceMappingURL=credentials.cjs.map