@strivacity/sdk-core 1.0.1 → 2.0.0-beta

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 (115) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +9 -7
  3. package/dist/flows/BaseFlow.cjs +1 -1
  4. package/dist/flows/BaseFlow.cjs.map +1 -1
  5. package/dist/flows/BaseFlow.d.ts +42 -55
  6. package/dist/flows/BaseFlow.mjs +1 -1
  7. package/dist/flows/BaseFlow.mjs.map +1 -1
  8. package/dist/flows/NativeFlow.cjs +2 -0
  9. package/dist/flows/NativeFlow.cjs.map +1 -0
  10. package/dist/flows/NativeFlow.d.ts +24 -0
  11. package/dist/flows/NativeFlow.mjs +2 -0
  12. package/dist/flows/NativeFlow.mjs.map +1 -0
  13. package/dist/flows/PopupFlow.cjs +1 -1
  14. package/dist/flows/PopupFlow.cjs.map +1 -1
  15. package/dist/flows/PopupFlow.d.ts +7 -14
  16. package/dist/flows/PopupFlow.mjs +1 -1
  17. package/dist/flows/PopupFlow.mjs.map +1 -1
  18. package/dist/flows/RedirectFlow.cjs +1 -1
  19. package/dist/flows/RedirectFlow.cjs.map +1 -1
  20. package/dist/flows/RedirectFlow.d.ts +6 -12
  21. package/dist/flows/RedirectFlow.mjs +1 -1
  22. package/dist/flows/RedirectFlow.mjs.map +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.ts +10 -4
  26. package/dist/index.mjs +1 -1
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/storages/LocalStorage.cjs +1 -1
  29. package/dist/storages/LocalStorage.cjs.map +1 -1
  30. package/dist/storages/LocalStorage.d.ts +3 -3
  31. package/dist/storages/LocalStorage.mjs +1 -1
  32. package/dist/storages/LocalStorage.mjs.map +1 -1
  33. package/dist/storages/SessionStorage.cjs +1 -1
  34. package/dist/storages/SessionStorage.cjs.map +1 -1
  35. package/dist/storages/SessionStorage.d.ts +3 -3
  36. package/dist/storages/SessionStorage.mjs +1 -1
  37. package/dist/storages/SessionStorage.mjs.map +1 -1
  38. package/dist/types.cjs +1 -1
  39. package/dist/types.cjs.map +1 -1
  40. package/dist/types.d.ts +257 -25
  41. package/dist/types.mjs +1 -1
  42. package/dist/types.mjs.map +1 -1
  43. package/dist/utils/HttpClient.cjs +2 -0
  44. package/dist/utils/HttpClient.cjs.map +1 -0
  45. package/dist/utils/HttpClient.d.ts +4 -0
  46. package/dist/utils/HttpClient.mjs +2 -0
  47. package/dist/utils/HttpClient.mjs.map +1 -0
  48. package/dist/utils/Metadata.cjs +2 -0
  49. package/dist/utils/Metadata.cjs.map +1 -0
  50. package/dist/{Metadata.d.ts → utils/Metadata.d.ts} +26 -2
  51. package/dist/utils/Metadata.mjs +2 -0
  52. package/dist/utils/Metadata.mjs.map +1 -0
  53. package/dist/utils/NativeFlowHandler.cjs +2 -0
  54. package/dist/utils/NativeFlowHandler.cjs.map +1 -0
  55. package/dist/utils/NativeFlowHandler.d.ts +54 -0
  56. package/dist/utils/NativeFlowHandler.mjs +2 -0
  57. package/dist/utils/NativeFlowHandler.mjs.map +1 -0
  58. package/dist/utils/Session.cjs +2 -0
  59. package/dist/utils/Session.cjs.map +1 -0
  60. package/dist/{Session.d.ts → utils/Session.d.ts} +1 -1
  61. package/dist/utils/Session.mjs +2 -0
  62. package/dist/utils/Session.mjs.map +1 -0
  63. package/dist/utils/State.cjs +2 -0
  64. package/dist/utils/State.cjs.map +1 -0
  65. package/dist/utils/State.mjs +2 -0
  66. package/dist/utils/State.mjs.map +1 -0
  67. package/dist/utils/base64Url.cjs.map +1 -1
  68. package/dist/utils/base64Url.mjs.map +1 -1
  69. package/dist/utils/crypto.cjs.map +1 -1
  70. package/dist/utils/crypto.mjs.map +1 -1
  71. package/dist/utils/date.cjs.map +1 -1
  72. package/dist/utils/date.mjs.map +1 -1
  73. package/dist/utils/errors.cjs +2 -0
  74. package/dist/utils/errors.cjs.map +1 -0
  75. package/dist/utils/errors.d.ts +4 -0
  76. package/dist/utils/errors.mjs +2 -0
  77. package/dist/utils/errors.mjs.map +1 -0
  78. package/dist/utils/handlers.cjs +1 -1
  79. package/dist/utils/handlers.cjs.map +1 -1
  80. package/dist/utils/handlers.d.ts +11 -11
  81. package/dist/utils/handlers.mjs +1 -1
  82. package/dist/utils/handlers.mjs.map +1 -1
  83. package/dist/utils/jwt.cjs +1 -1
  84. package/dist/utils/jwt.cjs.map +1 -1
  85. package/dist/utils/jwt.mjs +1 -1
  86. package/dist/utils/jwt.mjs.map +1 -1
  87. package/dist/utils/object.cjs +2 -0
  88. package/dist/utils/object.cjs.map +1 -0
  89. package/dist/utils/object.d.ts +1 -0
  90. package/dist/utils/object.mjs +2 -0
  91. package/dist/utils/object.mjs.map +1 -0
  92. package/package.json +1 -1
  93. package/dist/Metadata.cjs +0 -2
  94. package/dist/Metadata.cjs.map +0 -1
  95. package/dist/Metadata.mjs +0 -2
  96. package/dist/Metadata.mjs.map +0 -1
  97. package/dist/Session.cjs +0 -2
  98. package/dist/Session.cjs.map +0 -1
  99. package/dist/Session.mjs +0 -2
  100. package/dist/Session.mjs.map +0 -1
  101. package/dist/State.cjs +0 -2
  102. package/dist/State.cjs.map +0 -1
  103. package/dist/State.mjs +0 -2
  104. package/dist/State.mjs.map +0 -1
  105. package/dist/utils/constants.cjs +0 -2
  106. package/dist/utils/constants.cjs.map +0 -1
  107. package/dist/utils/constants.d.ts +0 -6
  108. package/dist/utils/constants.mjs +0 -2
  109. package/dist/utils/constants.mjs.map +0 -1
  110. package/dist/utils/fetch.cjs +0 -2
  111. package/dist/utils/fetch.cjs.map +0 -1
  112. package/dist/utils/fetch.d.ts +0 -2
  113. package/dist/utils/fetch.mjs +0 -2
  114. package/dist/utils/fetch.mjs.map +0 -1
  115. /package/dist/{State.d.ts → utils/State.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sources":["../src/types.ts"],"sourcesContent":["/**\n * Makes properties of `T` required based on the keys provided in `K`.\n *\n * @template T - The type from which properties will be made required.\n * @template K - The keys of `T` that should be required.\n * @example\n * type MyType = { a?: string; b?: number; c?: boolean };\n * type RequiredAB = Mandatory<MyType, 'a' | 'b'>; // { a: string; b: number; c?: boolean }\n */\nexport type Mandatory<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;\n\n/**\n * A type representing a partial record of key-value pairs where keys are of type `K` and values are of type `T`.\n *\n * @template K - The type of the keys in the record.\n * @template T - The type of the values in the record.\n * @example\n * type StringMap = PartialRecord<string, string>; // { [key: string]: string | undefined }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PartialRecord<K extends keyof any, T> = {\n\t[P in K]?: T;\n};\n\n// region SDK\n\n/**\n * List of supported response types.\n */\nexport const ResponseTypeList = ['code', 'id_token'] as const;\n/**\n * Type representing valid response types.\n */\nexport type ResponseType = (typeof ResponseTypeList)[number];\n\n/**\n * List of supported response modes.\n */\nexport const ResponseModeList = ['query', 'fragment'] as const;\n/**\n * Type representing valid response modes.\n */\nexport type ResponseMode = (typeof ResponseModeList)[number];\n\n/**\n * List of supported token endpoint authentication methods.\n */\nexport const TokenEndpointAuthMethodList = ['none'] as const;\n/**\n * Type representing valid token endpoint authentication methods.\n */\nexport type TokenEndpointAuthMethod = (typeof TokenEndpointAuthMethodList)[number];\n\n/**\n * List of supported grant types.\n */\nexport const GrantTypeList = ['authorization_code', 'refresh_token'] as const;\n/**\n * Type representing valid grant types.\n */\nexport type GrantType = (typeof GrantTypeList)[number];\n\n/**\n * List of supported algorithm types.\n */\nexport const AlgorithmTypeList = ['RS256'] as const;\n/**\n * Type representing valid algorithm types.\n */\nexport type AlgorithmType = (typeof AlgorithmTypeList)[number];\n\n/**\n * List of supported subject types.\n */\nexport const SubjectTypeList = ['public'] as const;\n/**\n * Type representing valid subject types.\n */\nexport type SubjectType = (typeof SubjectTypeList)[number];\n\n/**\n * List of supported prompt types.\n */\nexport const PromptTypeList = ['none', 'login', 'create'] as const;\n/**\n * Type representing valid prompt types.\n */\nexport type PromptType = (typeof PromptTypeList)[number];\n\n/**\n * List of supported fallback modes.\n */\nexport const FallbackModeTypeList = ['redirect', 'popup'] as const;\n/**\n * Type representing valid fallback modes.\n */\nexport type FallbackMode = (typeof FallbackModeTypeList)[number];\n\n/**\n * Represents a signing key used in cryptographic operations, such as signing JSON Web Tokens (JWTs).\n *\n * This type defines the key's properties, including its usage, type, identifier, algorithm, and key material.\n */\nexport type SigningKey = {\n\t/**\n\t * The intended use of the key. Common values include \"sig\" for signature and \"enc\" for encryption.\n\t *\n\t * @type {string}\n\t * @example 'sig'\n\t */\n\tuse: string;\n\n\t/**\n\t * The key type. For example, \"RSA\" for RSA keys or \"EC\" for Elliptic Curve keys.\n\t *\n\t * @type {string}\n\t * @example 'RSA'\n\t */\n\tkty: string;\n\n\t/**\n\t * A unique identifier for the key. This is used to distinguish the key from others.\n\t *\n\t * @type {string}\n\t * @example 'key-id-1234'\n\t */\n\tkid: string;\n\n\t/**\n\t * The algorithm used with the key. For example, \"RS256\" for RSA SHA-256.\n\t *\n\t * @type {AlgorithmType}\n\t * @example 'RS256'\n\t */\n\talg: AlgorithmType;\n\n\t/**\n\t * The modulus of the RSA key, encoded in base64url format. For RSA keys, this is a required property.\n\t *\n\t * @type {string}\n\t * @example 'base64url-encoded-modulus'\n\t */\n\tn: string;\n\n\t/**\n\t * The exponent of the RSA key, encoded in base64url format. For RSA keys, this is a required property.\n\t *\n\t * @type {string}\n\t * @example 'base64url-encoded-exponent'\n\t */\n\te: string;\n};\n\n/**\n * Represents the metadata options provided by an authorization server.\n *\n * This metadata includes information about the server's endpoints, supported features, and supported claims.\n */\nexport type MetadataOptions = {\n\t/**\n\t * The issuer of the tokens. This is the authorization server or entity that issues the tokens.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tissuer: string;\n\n\t/**\n\t * The URL of the authorization endpoint where authentication requests are sent.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/authorize'\n\t */\n\tauthorization_endpoint: string;\n\n\t/**\n\t * The URL of the token endpoint where tokens are exchanged.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/token'\n\t */\n\ttoken_endpoint: string;\n\n\t/**\n\t * The URL of the JSON Web Key Set (JWKS) endpoint where public keys are available.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/jwks'\n\t */\n\tjwks_uri: string;\n\n\t/**\n\t * The types of subjects that are supported by the authorization server.\n\t *\n\t * @type {Array<SubjectType>}\n\t * @example ['public']\n\t */\n\tsubject_types_supported: Array<SubjectType>;\n\n\t/**\n\t * The types of responses supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['code', 'id_token']\n\t */\n\tresponse_types_supported: Array<string>;\n\n\t/**\n\t * The claims supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['sub', 'name', 'email']\n\t */\n\tclaims_supported: Array<string>;\n\n\t/**\n\t * The grant types supported by the authorization server.\n\t *\n\t * @type {Array<GrantType>}\n\t * @example ['authorization_code', 'refresh_token']\n\t */\n\tgrant_types_supported: Array<GrantType>;\n\n\t/**\n\t * The response modes supported by the authorization server.\n\t *\n\t * @type {Array<ResponseMode>}\n\t * @example ['query', 'fragment']\n\t */\n\tresponse_modes_supported: Array<ResponseMode>;\n\n\t/**\n\t * The URL of the user info endpoint where user information can be retrieved.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/userinfo'\n\t */\n\tuserinfo_endpoint: string;\n\n\t/**\n\t * The scopes supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['openid', 'profile', 'email']\n\t */\n\tscopes_supported: Array<string>;\n\n\t/**\n\t * The authentication methods supported for token endpoint authentication.\n\t *\n\t * @type {Array<TokenEndpointAuthMethod>}\n\t * @example ['none']\n\t */\n\ttoken_endpoint_auth_methods_supported: Array<TokenEndpointAuthMethod>;\n\n\t/**\n\t * The algorithms supported for signing tokens used in the user info endpoint.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tuserinfo_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms supported for signing ID tokens.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tid_token_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms used to sign ID tokens in response.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tid_token_signed_response_alg: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms used to sign responses from the user info endpoint.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tuserinfo_signed_response_alg: Array<AlgorithmType>;\n\n\t/**\n\t * Indicates whether the request parameter is supported in requests.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequest_parameter_supported: boolean;\n\n\t/**\n\t * Indicates whether the request URI parameter is supported in requests.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequest_uri_parameter_supported: boolean;\n\n\t/**\n\t * Indicates whether request URI registration is required.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequire_request_uri_registration: boolean;\n\n\t/**\n\t * Indicates whether the claims parameter is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tclaims_parameter_supported: boolean;\n\n\t/**\n\t * The URL of the revocation endpoint for revoking tokens.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/revoke'\n\t */\n\trevocation_endpoint: string;\n\n\t/**\n\t * Indicates whether backchannel logout is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tbackchannel_logout_supported: boolean;\n\n\t/**\n\t * Indicates whether backchannel logout session support is provided.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tbackchannel_logout_session_supported: boolean;\n\n\t/**\n\t * Indicates whether frontchannel logout is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tfrontchannel_logout_supported: boolean;\n\n\t/**\n\t * Indicates whether frontchannel logout session support is provided.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tfrontchannel_logout_session_supported: boolean;\n\n\t/**\n\t * The URL of the endpoint where end-session requests can be sent.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/logout'\n\t */\n\tend_session_endpoint: string;\n\n\t/**\n\t * The algorithms supported for signing request objects.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\trequest_object_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The code challenge methods supported by the authorization server.\n\t *\n\t * @type {Array<'S256'>}\n\t * @example ['S256']\n\t */\n\tcode_challenge_methods_supported: Array<'S256'>;\n};\n\n/**\n * Represents the standard claims in a JSON Web Token (JWT).\n *\n * These claims are part of the payload in a JWT and convey information about the token, such as its issuer, subject, and expiration.\n */\nexport type JwtClaims = {\n\t/**\n\t * The issuer of the token. This typically represents the authorization server or entity that issued the JWT.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tiss?: string;\n\n\t/**\n\t * The subject of the token. This is the identifier for the entity the token represents, such as a user ID.\n\t *\n\t * @type {string}\n\t * @example 'user123'\n\t */\n\tsub?: string;\n\n\t/**\n\t * The audience for which the token is intended. This can be a single identifier or an array of identifiers.\n\t *\n\t * @type {string | Array<string>}\n\t * @example 'your-client-id' | ['client1', 'client2']\n\t */\n\taud?: string | Array<string>;\n\n\t/**\n\t * The expiration time of the token, expressed as a Unix timestamp (number of seconds since January 1, 1970).\n\t *\n\t * @type {number}\n\t * @example 1633024800\n\t */\n\texp?: number;\n\n\t/**\n\t * The not-before time of the token, expressed as a Unix timestamp. The token must not be accepted before this time.\n\t *\n\t * @type {number}\n\t * @example 1633021200\n\t */\n\tnbf?: number;\n\n\t/**\n\t * The issued-at time of the token, expressed as a Unix timestamp (number of seconds since January 1, 1970).\n\t *\n\t * @type {number}\n\t * @example 1633022400\n\t */\n\tiat?: number;\n\n\t/**\n\t * A unique identifier for the token. This can be used to prevent token replay attacks.\n\t *\n\t * @type {string}\n\t * @example 'unique-jwt-id-1234'\n\t */\n\tjti?: string;\n};\n\n/**\n * Represents the claims included in an ID token, extending standard JWT claims with additional properties specific to identity tokens.\n *\n * ID tokens are used to authenticate and provide identity information about the user.\n */\nexport type IdTokenClaims = Mandatory<JwtClaims, 'iss' | 'sub' | 'aud' | 'exp' | 'iat'> & {\n\t/**\n\t * The authentication time, indicating when the user was authenticated.\n\t *\n\t * @type {number}\n\t * @example 1633022400\n\t */\n\tauth_time?: number;\n\n\t/**\n\t * A nonce value used to associate a client session with an ID token, preventing replay attacks.\n\t *\n\t * @type {string}\n\t * @example 'nonce-value-1234'\n\t */\n\tnonce?: string;\n\n\t/**\n\t * The Authentication Context Class Reference, indicating the authentication methods used.\n\t *\n\t * @type {string}\n\t * @example '2'\n\t */\n\tacr?: string;\n\n\t/**\n\t * The Authentication Methods References, providing information about the authentication methods used.\n\t *\n\t * @type {unknown}\n\t */\n\tamr?: unknown;\n\n\t/**\n\t * Authorized party, the client that the ID token is intended for.\n\t *\n\t * @type {string}\n\t * @example 'client-id'\n\t */\n\tazp?: string;\n\n\t/**\n\t * Session ID for the user, which can be used to manage user sessions.\n\t *\n\t * @type {string}\n\t * @example 'session-id-1234'\n\t */\n\tsid?: string;\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t[key: string]: any;\n};\n\n/**\n * Options for configuring the SDK.\n */\nexport type SDKOptions = {\n\t/**\n\t * Specifies the mode of the SDK operation, either 'popup' or 'redirect'.\n\t *\n\t * @type {'popup' | 'redirect'}\n\t * @default 'redirect'\n\t */\n\tmode?: 'popup' | 'redirect';\n\n\t/**\n\t * The issuer of the tokens, typically the URL of the authorization server.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tissuer: string;\n\n\t/**\n\t * The client ID issued by the authorization server, used to identify the application.\n\t *\n\t * @type {string}\n\t * @example 'your-client-id'\n\t */\n\tclientId: string;\n\n\t/**\n\t * The URI to which the user will be redirected after authentication or authorization.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/callback'\n\t */\n\tredirectUri: string;\n\n\t/**\n\t * A list of scopes requested by the application, defining the access levels for the tokens.\n\t *\n\t * @type {Array<string>}\n\t * @default ['openid']\n\t * @example ['openid', 'profile']\n\t */\n\tscopes?: Array<string>;\n\n\t/**\n\t * The type of response expected from the authorization server.\n\t *\n\t * @type {ResponseType}\n\t * @default 'code'\n\t */\n\tresponseType?: ResponseType;\n\n\t/**\n\t * The mode in which the response is returned from the authorization server.\n\t *\n\t * @type {ResponseMode}\n\t * @default 'query'\n\t */\n\tresponseMode?: ResponseMode;\n\n\t/**\n\t * The name of the token in storage used to persist authentication information.\n\t *\n\t * @type {string}\n\t * @default 'sty.session'\n\t * @example 'accessToken'\n\t */\n\tstorageTokenName?: string;\n\n\t/**\n\t * The storage mechanism used to save and retrieve authentication information.\n\t *\n\t * @type {SDKStorageType}\n\t * @default LocalStorage\n\t */\n\tstorage?: SDKStorageType;\n};\n\n/**\n * Abstract class for SDK storage mechanisms.\n */\nexport abstract class SDKStorage {\n\t/**\n\t * Retrieves an item from the storage by key.\n\t *\n\t * @param {string} key - The key of the item to retrieve.\n\t * @returns {string | null} The value associated with the key, or `null` if not found.\n\t */\n\tabstract get(key: string): string | null;\n\n\t/**\n\t * Deletes an item from the storage by key.\n\t *\n\t * @param {string} key - The key of the item to delete.\n\t */\n\tabstract delete(key: string): void;\n\n\t/**\n\t * Sets an item in the storage with the specified key and value.\n\t *\n\t * @param {string} key - The key to associate with the value.\n\t * @param {string} value - The value to store.\n\t */\n\tabstract set(key: string, value: string): void;\n}\n\n/**\n * Type representing a constructor function for SDKStorage.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SDKStorageType = new (...args: Array<any>) => SDKStorage;\n\n/**\n * A collection of functions used to handle various events that occur within the SDK.\n */\nexport type EventFunctions = {\n\t/**\n\t * Handler called when an access token has expired.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The expired access token.\n\t * @param {string | null} [params.refreshToken] - The refresh token associated with the access token, if available.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\taccessTokenExpired: (params: { accessToken: string; refreshToken?: string | null }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when the SDK is initialized.\n\t *\n\t * @returns {Promise<void> | void} A promise that resolves when the initialization is complete, or void if no asynchronous operation is needed.\n\t */\n\tinit: () => Promise<void> | void;\n\n\t/**\n\t * Handler called when a user has successfully logged in.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The access token obtained after login.\n\t * @param {string | null} [params.refreshToken] - The refresh token obtained after login, if available.\n\t * @param {IdTokenClaims} params.claims - The claims extracted from the ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\tloggedIn: (params: { accessToken: string; refreshToken?: string | null; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when login has been initiated.\n\t *\n\t * @returns {Promise<void> | void} A promise that resolves when the login initiation process is complete, or void if no asynchronous operation is needed.\n\t */\n\tloginInitiated: () => Promise<void> | void;\n\n\t/**\n\t * Handler called when a logout request has been initiated.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.idToken - The ID token associated with the logout request.\n\t * @param {IdTokenClaims} params.claims - The claims associated with the ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the logout initiation process is complete, or void if no asynchronous operation is needed.\n\t */\n\tlogoutInitiated: (params: { idToken: string; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a user session has been successfully loaded.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The access token associated with the loaded session.\n\t * @param {string | null} [params.refreshToken] - The refresh token associated with the session, if available.\n\t * @param {IdTokenClaims} params.claims - The claims associated with the ID token in the session.\n\t * @returns {Promise<void> | void} A promise that resolves when the session loading is complete, or void if no asynchronous operation is needed.\n\t */\n\tsessionLoaded: (params: { accessToken: string; refreshToken?: string | null; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when an access token has been successfully refreshed.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The new access token obtained after the refresh.\n\t * @param {string} params.refreshToken - The refresh token used to obtain the new access token.\n\t * @param {IdTokenClaims} params.claims - The claims extracted from the new ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the token refresh is complete, or void if no asynchronous operation is needed.\n\t */\n\ttokenRefreshed: (params: { accessToken: string; refreshToken: string; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token refresh operation fails.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.refreshToken - The refresh token that was used in the failed refresh operation.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRefreshFailed: (params: { refreshToken: string }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token has been successfully revoked.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.token - The token that was revoked.\n\t * @param {'refresh_token' | 'access_token'} params.tokenTypeHint - The type of token that was revoked.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRevoked: (params: { token: string; tokenTypeHint: 'refresh_token' | 'access_token' }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token revocation operation fails.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.token - The token that was attempted to be revoked.\n\t * @param {'refresh_token' | 'access_token'} params.tokenTypeHint - The type of token that was attempted to be revoked.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRevokeFailed: (params: { token: string; tokenTypeHint: 'refresh_token' | 'access_token' }) => Promise<void> | void;\n};\n\n// endregion\n\n// region Flows\n\n/**\n * Extra parameters that can be used in requests.\n */\n/**\n * Additional parameters that can be included in authentication or authorization requests.\n */\nexport type ExtraRequestArgs = {\n\t/**\n\t * Specifies the type of prompt to display to the user during authentication or authorization.\n\t *\n\t * @type {PromptType}\n\t * @example 'none' | 'login' | 'create'\n\t */\n\tprompt?: PromptType;\n\n\t/**\n\t * Provides a hint to the authorization server about the user's email or username.\n\t *\n\t * @type {string}\n\t * @example 'user@example.com'\n\t */\n\tloginHint?: string;\n\n\t/**\n\t * A list of values used to request specific authentication contexts or levels of assurance.\n\t *\n\t * This parameter allows requesting specific authentication contexts (e.g., multi-factor authentication)\n\t * or other criteria that the authorization server should consider when authenticating the user.\n\t *\n\t * @type {Array<string>}\n\t * @example ['urn:mace:incommon:iap:bronze', 'urn:mace:incommon:iap:silver']\n\t */\n\tacrValues?: Array<string>;\n\n\t/**\n\t * A list of locale codes to request specific language and regional preferences for the user interface.\n\t *\n\t * This parameter allows requesting the user interface to be presented in specific languages or regional formats.\n\t *\n\t * @type {Array<string>}\n\t * @example ['en-US', 'fr-CA']\n\t */\n\tuiLocales?: Array<string>;\n};\n\n/**\n * Options for configuring logout behavior.\n */\nexport type LogoutOptions = {\n\t/**\n\t * The URI to redirect to after a successful logout.\n\t *\n\t * If specified, the user will be redirected to this URI upon completing the logout process.\n\t * This is often used to send users back to the main application or a custom post-logout page.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/home'\n\t */\n\tpostLogoutRedirectUri?: string;\n};\n\n/**\n * List of select option types.\n */\nexport const SelectOptionTypeList = ['item', 'group'] as const;\n/**\n * Type representing valid select option types.\n */\nexport type SelectOptionType = (typeof SelectOptionTypeList)[number];\n\n/**\n * Data for branding purposes, such as logo and brand name.\n */\nexport type BrandingData = {\n\tlogoUrl: string | null;\n\tbrandName: string | null;\n\tcopyright: string | null;\n\tprivacyPolicyUrl: string | null;\n\tsiteTermsUrl: string | null;\n};\n\n/**\n * Parameters for redirect authentication flow.\n */\nexport type RedirectParams = ExtraRequestArgs & {\n\t/**\n\t * The method used to update the browser's location after authentication or authorization.\n\t *\n\t * Determines whether the new URL should replace the current URL in the history or be added to it.\n\t *\n\t * @type {'replace' | 'assign'}\n\t * @default 'assign'\n\t */\n\tlocationMethod?: 'replace' | 'assign';\n\n\t/**\n\t * The window in which the redirect should occur.\n\t *\n\t * Specifies whether the redirect should happen in the top-level window or the current window.\n\t *\n\t * @type {'top' | 'self'}\n\t * @default 'self'\n\t */\n\ttargetWindow?: 'top' | 'self';\n};\n\n/**\n * Features for customizing the popup window.\n */\nexport type PopupWindowFeatures = {\n\t/**\n\t * The horizontal position of the popup window relative to the left edge of the screen.\n\t *\n\t * @type {number}\n\t * @example 100\n\t */\n\tleft?: number;\n\n\t/**\n\t * The vertical position of the popup window relative to the top edge of the screen.\n\t *\n\t * @type {number}\n\t * @example 100\n\t */\n\ttop?: number;\n\n\t/**\n\t * The width of the popup window.\n\t *\n\t * @type {number}\n\t * @example 600\n\t */\n\twidth?: number;\n\n\t/**\n\t * The height of the popup window.\n\t *\n\t * @type {number}\n\t * @example 400\n\t */\n\theight?: number;\n\n\t/**\n\t * Whether the popup window should display a menubar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tmenubar?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display a toolbar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\ttoolbar?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display the address/location bar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tlocation?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display a status bar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tstatus?: boolean | string;\n\n\t/**\n\t * Whether the popup window should be resizable.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example false\n\t */\n\tresizable?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display scrollbars.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example false\n\t */\n\tscrollbars?: boolean | string;\n\n\t[key: string]: boolean | string | number | undefined;\n};\n\n/**\n * Parameters for popup authentication flow.\n */\nexport type PopupWindowParams = ExtraRequestArgs & {\n\t/**\n\t * Configuration options for the popup window, including size, position, and other features.\n\t *\n\t * @type {PopupWindowFeatures}\n\t */\n\tpopupWindowFeatures?: PopupWindowFeatures;\n\n\t/**\n\t * The target of the popup window, which specifies where the popup should be opened.\n\t *\n\t * @type {string}\n\t * @example '_blank' | '_self' | '_parent' | '_top'\n\t */\n\tpopupWindowTarget?: string;\n};\n\n// endregion\n"],"names":["ResponseTypeList","ResponseModeList","TokenEndpointAuthMethodList","GrantTypeList","AlgorithmTypeList","SubjectTypeList","PromptTypeList","FallbackModeTypeList","SDKStorage","SelectOptionTypeList"],"mappings":"gFA6Ba,MAAAA,EAAmB,CAAC,OAAQ,UAAU,EAStCC,EAAmB,CAAC,QAAS,UAAU,EASvCC,EAA8B,CAAC,MAAM,EASrCC,EAAgB,CAAC,qBAAsB,eAAe,EAStDC,EAAoB,CAAC,OAAO,EAS5BC,EAAkB,CAAC,QAAQ,EAS3BC,EAAiB,CAAC,OAAQ,QAAS,QAAQ,EAS3CC,EAAuB,CAAC,WAAY,OAAO,EA8ejD,MAAeC,CAAW,CAuBjC,CAiLa,MAAAC,EAAuB,CAAC,OAAQ,OAAO"}
1
+ {"version":3,"file":"types.cjs","sources":["../src/types.ts"],"sourcesContent":["/**\n * Makes properties of `T` required based on the keys provided in `K`.\n *\n * @template T - The type from which properties will be made required.\n * @template K - The keys of `T` that should be required.\n * @example\n * type MyType = { a?: string; b?: number; c?: boolean };\n * type RequiredAB = Mandatory<MyType, 'a' | 'b'>; // { a: string; b: number; c?: boolean }\n */\nexport type Mandatory<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;\n\n/**\n * A type representing a partial record of key-value pairs where keys are of type `K` and values are of type `T`.\n *\n * @template K - The type of the keys in the record.\n * @template T - The type of the values in the record.\n * @example\n * type StringMap = PartialRecord<string, string>; // { [key: string]: string | undefined }\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PartialRecord<K extends keyof any, T> = {\n\t[P in K]?: T;\n};\n\n// region SDK\n\n/**\n * List of supported response types.\n */\nexport const ResponseTypeList = ['code', 'id_token'] as const;\n/**\n * Type representing valid response types.\n */\nexport type ResponseType = (typeof ResponseTypeList)[number];\n\n/**\n * List of supported response modes.\n */\nexport const ResponseModeList = ['query', 'fragment'] as const;\n/**\n * Type representing valid response modes.\n */\nexport type ResponseMode = (typeof ResponseModeList)[number];\n\n/**\n * List of supported token endpoint authentication methods.\n */\nexport const TokenEndpointAuthMethodList = ['none'] as const;\n/**\n * Type representing valid token endpoint authentication methods.\n */\nexport type TokenEndpointAuthMethod = (typeof TokenEndpointAuthMethodList)[number];\n\n/**\n * List of supported grant types.\n */\nexport const GrantTypeList = ['authorization_code', 'refresh_token'] as const;\n/**\n * Type representing valid grant types.\n */\nexport type GrantType = (typeof GrantTypeList)[number];\n\n/**\n * List of supported algorithm types.\n */\nexport const AlgorithmTypeList = ['RS256'] as const;\n/**\n * Type representing valid algorithm types.\n */\nexport type AlgorithmType = (typeof AlgorithmTypeList)[number];\n\n/**\n * List of supported subject types.\n */\nexport const SubjectTypeList = ['public'] as const;\n/**\n * Type representing valid subject types.\n */\nexport type SubjectType = (typeof SubjectTypeList)[number];\n\n/**\n * List of supported prompt types.\n */\nexport const PromptTypeList = ['none', 'login', 'create'] as const;\n/**\n * Type representing valid prompt types.\n */\nexport type PromptType = (typeof PromptTypeList)[number];\n\n/**\n * List of supported fallback modes.\n */\nexport const FallbackModeTypeList = ['redirect', 'popup'] as const;\n/**\n * Type representing valid fallback modes.\n */\nexport type FallbackMode = (typeof FallbackModeTypeList)[number];\n\n/**\n * Represents a signing key used in cryptographic operations, such as signing JSON Web Tokens (JWTs).\n *\n * This type defines the key's properties, including its usage, type, identifier, algorithm, and key material.\n */\nexport type SigningKey = {\n\t/**\n\t * The intended use of the key. Common values include \"sig\" for signature and \"enc\" for encryption.\n\t *\n\t * @type {string}\n\t * @example 'sig'\n\t */\n\tuse: string;\n\n\t/**\n\t * The key type. For example, \"RSA\" for RSA keys or \"EC\" for Elliptic Curve keys.\n\t *\n\t * @type {string}\n\t * @example 'RSA'\n\t */\n\tkty: string;\n\n\t/**\n\t * A unique identifier for the key. This is used to distinguish the key from others.\n\t *\n\t * @type {string}\n\t * @example 'key-id-1234'\n\t */\n\tkid: string;\n\n\t/**\n\t * The algorithm used with the key. For example, \"RS256\" for RSA SHA-256.\n\t *\n\t * @type {AlgorithmType}\n\t * @example 'RS256'\n\t */\n\talg: AlgorithmType;\n\n\t/**\n\t * The modulus of the RSA key, encoded in base64url format. For RSA keys, this is a required property.\n\t *\n\t * @type {string}\n\t * @example 'base64url-encoded-modulus'\n\t */\n\tn: string;\n\n\t/**\n\t * The exponent of the RSA key, encoded in base64url format. For RSA keys, this is a required property.\n\t *\n\t * @type {string}\n\t * @example 'base64url-encoded-exponent'\n\t */\n\te: string;\n};\n\n/**\n * Represents the metadata options provided by an authorization server.\n *\n * This metadata includes information about the server's endpoints, supported features, and supported claims.\n */\nexport type MetadataOptions = {\n\t/**\n\t * The issuer of the tokens. This is the authorization server or entity that issues the tokens.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tissuer: string;\n\n\t/**\n\t * The URL of the authorization endpoint where authentication requests are sent.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/authorize'\n\t */\n\tauthorization_endpoint: string;\n\n\t/**\n\t * The URL of the token endpoint where tokens are exchanged.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/token'\n\t */\n\ttoken_endpoint: string;\n\n\t/**\n\t * The URL of the JSON Web Key Set (JWKS) endpoint where public keys are available.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/jwks'\n\t */\n\tjwks_uri: string;\n\n\t/**\n\t * The types of subjects that are supported by the authorization server.\n\t *\n\t * @type {Array<SubjectType>}\n\t * @example ['public']\n\t */\n\tsubject_types_supported: Array<SubjectType>;\n\n\t/**\n\t * The types of responses supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['code', 'id_token']\n\t */\n\tresponse_types_supported: Array<string>;\n\n\t/**\n\t * The claims supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['sub', 'name', 'email']\n\t */\n\tclaims_supported: Array<string>;\n\n\t/**\n\t * The grant types supported by the authorization server.\n\t *\n\t * @type {Array<GrantType>}\n\t * @example ['authorization_code', 'refresh_token']\n\t */\n\tgrant_types_supported: Array<GrantType>;\n\n\t/**\n\t * The response modes supported by the authorization server.\n\t *\n\t * @type {Array<ResponseMode>}\n\t * @example ['query', 'fragment']\n\t */\n\tresponse_modes_supported: Array<ResponseMode>;\n\n\t/**\n\t * The URL of the user info endpoint where user information can be retrieved.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/userinfo'\n\t */\n\tuserinfo_endpoint: string;\n\n\t/**\n\t * The scopes supported by the authorization server.\n\t *\n\t * @type {Array<string>}\n\t * @example ['openid', 'profile', 'email']\n\t */\n\tscopes_supported: Array<string>;\n\n\t/**\n\t * The authentication methods supported for token endpoint authentication.\n\t *\n\t * @type {Array<TokenEndpointAuthMethod>}\n\t * @example ['none']\n\t */\n\ttoken_endpoint_auth_methods_supported: Array<TokenEndpointAuthMethod>;\n\n\t/**\n\t * The algorithms supported for signing tokens used in the user info endpoint.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tuserinfo_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms supported for signing ID tokens.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tid_token_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms used to sign ID tokens in response.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tid_token_signed_response_alg: Array<AlgorithmType>;\n\n\t/**\n\t * The algorithms used to sign responses from the user info endpoint.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\tuserinfo_signed_response_alg: Array<AlgorithmType>;\n\n\t/**\n\t * Indicates whether the request parameter is supported in requests.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequest_parameter_supported: boolean;\n\n\t/**\n\t * Indicates whether the request URI parameter is supported in requests.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequest_uri_parameter_supported: boolean;\n\n\t/**\n\t * Indicates whether request URI registration is required.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\trequire_request_uri_registration: boolean;\n\n\t/**\n\t * Indicates whether the claims parameter is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tclaims_parameter_supported: boolean;\n\n\t/**\n\t * The URL of the revocation endpoint for revoking tokens.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/oauth/revoke'\n\t */\n\trevocation_endpoint: string;\n\n\t/**\n\t * Indicates whether backchannel logout is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tbackchannel_logout_supported: boolean;\n\n\t/**\n\t * Indicates whether backchannel logout session support is provided.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tbackchannel_logout_session_supported: boolean;\n\n\t/**\n\t * Indicates whether frontchannel logout is supported.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tfrontchannel_logout_supported: boolean;\n\n\t/**\n\t * Indicates whether frontchannel logout session support is provided.\n\t *\n\t * @type {boolean}\n\t * @example true\n\t */\n\tfrontchannel_logout_session_supported: boolean;\n\n\t/**\n\t * The URL of the endpoint where end-session requests can be sent.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/logout'\n\t */\n\tend_session_endpoint: string;\n\n\t/**\n\t * The algorithms supported for signing request objects.\n\t *\n\t * @type {Array<AlgorithmType>}\n\t * @example ['RS256']\n\t */\n\trequest_object_signing_alg_values_supported: Array<AlgorithmType>;\n\n\t/**\n\t * The code challenge methods supported by the authorization server.\n\t *\n\t * @type {Array<'S256'>}\n\t * @example ['S256']\n\t */\n\tcode_challenge_methods_supported: Array<'S256'>;\n};\n\n/**\n * Represents the standard claims in a JSON Web Token (JWT).\n *\n * These claims are part of the payload in a JWT and convey information about the token, such as its issuer, subject, and expiration.\n */\nexport type JwtClaims = {\n\t/**\n\t * The issuer of the token. This typically represents the authorization server or entity that issued the JWT.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tiss?: string;\n\n\t/**\n\t * The subject of the token. This is the identifier for the entity the token represents, such as a user ID.\n\t *\n\t * @type {string}\n\t * @example 'user123'\n\t */\n\tsub?: string;\n\n\t/**\n\t * The audience for which the token is intended. This can be a single identifier or an array of identifiers.\n\t *\n\t * @type {string | Array<string>}\n\t * @example 'your-client-id' | ['client1', 'client2']\n\t */\n\taud?: string | Array<string>;\n\n\t/**\n\t * The expiration time of the token, expressed as a Unix timestamp (number of seconds since January 1, 1970).\n\t *\n\t * @type {number}\n\t * @example 1633024800\n\t */\n\texp?: number;\n\n\t/**\n\t * The not-before time of the token, expressed as a Unix timestamp. The token must not be accepted before this time.\n\t *\n\t * @type {number}\n\t * @example 1633021200\n\t */\n\tnbf?: number;\n\n\t/**\n\t * The issued-at time of the token, expressed as a Unix timestamp (number of seconds since January 1, 1970).\n\t *\n\t * @type {number}\n\t * @example 1633022400\n\t */\n\tiat?: number;\n\n\t/**\n\t * A unique identifier for the token. This can be used to prevent token replay attacks.\n\t *\n\t * @type {string}\n\t * @example 'unique-jwt-id-1234'\n\t */\n\tjti?: string;\n};\n\n/**\n * Represents the claims included in an ID token, extending standard JWT claims with additional properties specific to identity tokens.\n *\n * ID tokens are used to authenticate and provide identity information about the user.\n */\nexport type IdTokenClaims = Mandatory<JwtClaims, 'iss' | 'sub' | 'aud' | 'exp' | 'iat'> & {\n\t/**\n\t * The authentication time, indicating when the user was authenticated.\n\t *\n\t * @type {number}\n\t * @example 1633022400\n\t */\n\tauth_time?: number;\n\n\t/**\n\t * A nonce value used to associate a client session with an ID token, preventing replay attacks.\n\t *\n\t * @type {string}\n\t * @example 'nonce-value-1234'\n\t */\n\tnonce?: string;\n\n\t/**\n\t * The Authentication Context Class Reference, indicating the authentication methods used.\n\t *\n\t * @type {string}\n\t * @example '2'\n\t */\n\tacr?: string;\n\n\t/**\n\t * The Authentication Methods References, providing information about the authentication methods used.\n\t *\n\t * @type {unknown}\n\t */\n\tamr?: unknown;\n\n\t/**\n\t * Authorized party, the client that the ID token is intended for.\n\t *\n\t * @type {string}\n\t * @example 'client-id'\n\t */\n\tazp?: string;\n\n\t/**\n\t * Session ID for the user, which can be used to manage user sessions.\n\t *\n\t * @type {string}\n\t * @example 'session-id-1234'\n\t */\n\tsid?: string;\n\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t[key: string]: any;\n};\n\n/**\n * Options for configuring the SDK.\n */\nexport type SDKOptions = {\n\t/**\n\t * Specifies the mode of the SDK operation, either 'popup' or 'redirect'.\n\t *\n\t * @type {'popup' | 'redirect'}\n\t * @default 'redirect'\n\t */\n\tmode?: 'popup' | 'redirect' | 'native';\n\n\t/**\n\t * The issuer of the tokens, typically the URL of the authorization server.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com'\n\t */\n\tissuer: string;\n\n\t/**\n\t * The client ID issued by the authorization server, used to identify the application.\n\t *\n\t * @type {string}\n\t * @example 'your-client-id'\n\t */\n\tclientId: string;\n\n\t/**\n\t * The URI to which the user will be redirected after authentication or authorization.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/callback'\n\t */\n\tredirectUri: string;\n\n\t/**\n\t * A list of scopes requested by the application, defining the access levels for the tokens.\n\t *\n\t * @type {Array<string>}\n\t * @default ['openid']\n\t * @example ['openid', 'profile']\n\t */\n\tscopes?: Array<string>;\n\n\t/**\n\t * The type of response expected from the authorization server.\n\t *\n\t * @type {ResponseType}\n\t * @default 'code'\n\t */\n\tresponseType?: ResponseType;\n\n\t/**\n\t * The mode in which the response is returned from the authorization server.\n\t *\n\t * @type {ResponseMode}\n\t * @default 'query'\n\t */\n\tresponseMode?: ResponseMode;\n\n\t/**\n\t * The name of the token in storage used to persist authentication information.\n\t *\n\t * @type {string}\n\t * @default 'sty.session'\n\t * @example 'accessToken'\n\t */\n\tstorageTokenName?: string;\n\n\t/**\n\t * The storage mechanism used to save and retrieve authentication information.\n\t *\n\t * @type {SDKStorageType}\n\t * @default LocalStorage\n\t */\n\tstorage?: SDKStorageType;\n\n\t/**\n\t * The HTTP client used for making requests to the authorization server.\n\t *\n\t * @type {SDKHttpClient}\n\t * @default HttpClient\n\t */\n\thttpClient?: SDKHttpClientType;\n\n\t/**\n\t * Handles the URL redirection to the specified target.\n\t * You can use this method to implement custom URL handling logic, such as opening a new window or navigating to a different page.\n\t *\n\t * @param {string} url - The URL to handle.\n\t * @param {Record<string, unknown>} params - Optional parameters for redirection.\n\t * @returns - A promise that resolves when the redirection is handled.\n\t */\n\turlHandler?: (url: string, params?: Record<string, unknown>) => Promise<unknown>;\n\n\t/**\n\t * Handles the callback from the authorization server after a successful authentication or authorization.\n\t * You can use this method to implement custom logic for processing the response from the authorization server.\n\t *\n\t * @param url - The URL containing the response from the authorization server.\n\t * @param responseMode - The mode in which the response is returned (e.g., 'query', 'fragment').\n\t * @returns - A promise that resolves when the callback is handled.\n\t */\n\tcallbackHandler?: (url: string, responseMode?: ResponseMode) => Promise<unknown>;\n};\n\n/**\n * Abstract class for SDK storage mechanisms.\n */\nexport abstract class SDKStorage {\n\t/**\n\t * Retrieves an item from the storage by key.\n\t *\n\t * @param {string} key - The key of the item to retrieve.\n\t * @returns {string | null} The value associated with the key, or `null` if not found.\n\t */\n\tabstract get(key: string): Promise<string | null>;\n\n\t/**\n\t * Deletes an item from the storage by key.\n\t *\n\t * @param {string} key - The key of the item to delete.\n\t */\n\tabstract delete(key: string): Promise<void>;\n\n\t/**\n\t * Sets an item in the storage with the specified key and value.\n\t *\n\t * @param {string} key - The key to associate with the value.\n\t * @param {string} value - The value to store.\n\t */\n\tabstract set(key: string, value: string): Promise<void>;\n}\n\n/**\n * Abstract class for HTTP client used in the SDK.\n */\nexport abstract class SDKHttpClient {\n\t/**\n\t * Makes an HTTP request to the specified URL with optional options.\n\t * @param {string} url - The URL to which the request is sent.\n\t * @param {RequestInit} options - Optional request options, such as method, headers, body, etc.\n\t */\n\tabstract request<T>(url: string, options?: RequestInit): Promise<HttpClientResponse<T>>;\n}\n\n/**\n * Type representing a constructor function for SDKStorage.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SDKStorageType = new (...args: Array<any>) => SDKStorage;\n\n/**\n * Type representing a constructor function for SDKHttpClient.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SDKHttpClientType = new (...args: Array<any>) => SDKHttpClient;\n\n/**\n * Http client response type.\n */\nexport type HttpClientResponse<T> = {\n\treadonly headers: Headers;\n\treadonly ok: boolean;\n\treadonly status: number;\n\treadonly statusText: string;\n\treadonly url: string;\n\tjson(): Promise<T>;\n\ttext(): Promise<string>;\n};\n\n/**\n * A collection of functions used to handle various events that occur within the SDK.\n */\nexport type EventFunctions = {\n\t/**\n\t * Handler called when an access token has expired.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The expired access token.\n\t * @param {string | null} [params.refreshToken] - The refresh token associated with the access token, if available.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\taccessTokenExpired: (params: { accessToken: string; refreshToken?: string | null }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when the SDK is initialized.\n\t *\n\t * @returns {Promise<void> | void} A promise that resolves when the initialization is complete, or void if no asynchronous operation is needed.\n\t */\n\tinit: () => Promise<void> | void;\n\n\t/**\n\t * Handler called when a user has successfully logged in.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The access token obtained after login.\n\t * @param {string | null} [params.refreshToken] - The refresh token obtained after login, if available.\n\t * @param {IdTokenClaims} params.claims - The claims extracted from the ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\tloggedIn: (params: { accessToken: string; refreshToken?: string | null; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when login has been initiated.\n\t *\n\t * @returns {Promise<void> | void} A promise that resolves when the login initiation process is complete, or void if no asynchronous operation is needed.\n\t */\n\tloginInitiated: () => Promise<void> | void;\n\n\t/**\n\t * Handler called when a logout request has been initiated.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.idToken - The ID token associated with the logout request.\n\t * @param {IdTokenClaims} params.claims - The claims associated with the ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the logout initiation process is complete, or void if no asynchronous operation is needed.\n\t */\n\tlogoutInitiated: (params: { idToken: string; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a user session has been successfully loaded.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The access token associated with the loaded session.\n\t * @param {string | null} [params.refreshToken] - The refresh token associated with the session, if available.\n\t * @param {IdTokenClaims} params.claims - The claims associated with the ID token in the session.\n\t * @returns {Promise<void> | void} A promise that resolves when the session loading is complete, or void if no asynchronous operation is needed.\n\t */\n\tsessionLoaded: (params: { accessToken: string; refreshToken?: string | null; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when an access token has been successfully refreshed.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.accessToken - The new access token obtained after the refresh.\n\t * @param {string} params.refreshToken - The refresh token used to obtain the new access token.\n\t * @param {IdTokenClaims} params.claims - The claims extracted from the new ID token.\n\t * @returns {Promise<void> | void} A promise that resolves when the token refresh is complete, or void if no asynchronous operation is needed.\n\t */\n\ttokenRefreshed: (params: { accessToken: string; refreshToken: string; claims: IdTokenClaims }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token refresh operation fails.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.refreshToken - The refresh token that was used in the failed refresh operation.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRefreshFailed: (params: { refreshToken: string }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token has been successfully revoked.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.token - The token that was revoked.\n\t * @param {'refresh_token' | 'access_token'} params.tokenTypeHint - The type of token that was revoked.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRevoked: (params: { token: string; tokenTypeHint: 'refresh_token' | 'access_token' }) => Promise<void> | void;\n\n\t/**\n\t * Handler called when a token revocation operation fails.\n\t *\n\t * @param {Object} params - The parameters for the event.\n\t * @param {string} params.token - The token that was attempted to be revoked.\n\t * @param {'refresh_token' | 'access_token'} params.tokenTypeHint - The type of token that was attempted to be revoked.\n\t * @returns {Promise<void> | void} A promise that resolves when the handler completes, or void if no asynchronous operation is needed.\n\t */\n\ttokenRevokeFailed: (params: { token: string; tokenTypeHint: 'refresh_token' | 'access_token' }) => Promise<void> | void;\n};\n\n// endregion\n\n// region Flows\n\n/**\n * Extra parameters that can be used in requests.\n */\n/**\n * Additional parameters that can be included in authentication or authorization requests.\n */\nexport type ExtraRequestArgs = {\n\t/**\n\t * Specifies the type of prompt to display to the user during authentication or authorization.\n\t *\n\t * @type {PromptType}\n\t * @example 'none' | 'login' | 'create'\n\t */\n\tprompt?: PromptType;\n\n\t/**\n\t * Provides a hint to the authorization server about the user's email or username.\n\t *\n\t * @type {string}\n\t * @example 'user@example.com'\n\t */\n\tloginHint?: string;\n\n\t/**\n\t * A list of values used to request specific authentication contexts or levels of assurance.\n\t *\n\t * This parameter allows requesting specific authentication contexts (e.g., multi-factor authentication)\n\t * or other criteria that the authorization server should consider when authenticating the user.\n\t *\n\t * @type {Array<string>}\n\t * @example ['urn:mace:incommon:iap:bronze', 'urn:mace:incommon:iap:silver']\n\t */\n\tacrValues?: Array<string>;\n\n\t/**\n\t * A list of locale codes to request specific language and regional preferences for the user interface.\n\t *\n\t * This parameter allows requesting the user interface to be presented in specific languages or regional formats.\n\t *\n\t * @type {Array<string>}\n\t * @example ['en-US', 'fr-CA']\n\t */\n\tuiLocales?: Array<string>;\n};\n\n/**\n * Params for configuring logout behavior.\n */\nexport type LogoutParams = {\n\t/**\n\t * The URI to redirect to after a successful logout.\n\t *\n\t * If specified, the user will be redirected to this URI upon completing the logout process.\n\t * This is often used to send users back to the main application or a custom post-logout page.\n\t *\n\t * @type {string}\n\t * @example 'https://example.com/home'\n\t */\n\tpostLogoutRedirectUri?: string;\n};\n\n/**\n * Parameters for redirect authentication flow.\n */\nexport type RedirectParams = ExtraRequestArgs & {\n\t/**\n\t * The method used to update the browser's location after authentication or authorization.\n\t *\n\t * Determines whether the new URL should replace the current URL in the history or be added to it.\n\t *\n\t * @type {'replace' | 'assign'}\n\t * @default 'assign'\n\t */\n\tlocationMethod?: 'replace' | 'assign';\n\n\t/**\n\t * The window in which the redirect should occur.\n\t *\n\t * Specifies whether the redirect should happen in the top-level window or the current window.\n\t *\n\t * @type {'top' | 'self'}\n\t * @default 'self'\n\t */\n\ttargetWindow?: 'top' | 'self';\n};\n\n/**\n * Features for customizing the popup window.\n */\nexport type PopupWindowFeatures = {\n\t/**\n\t * The horizontal position of the popup window relative to the left edge of the screen.\n\t *\n\t * @type {number}\n\t * @example 100\n\t */\n\tleft?: number;\n\n\t/**\n\t * The vertical position of the popup window relative to the top edge of the screen.\n\t *\n\t * @type {number}\n\t * @example 100\n\t */\n\ttop?: number;\n\n\t/**\n\t * The width of the popup window.\n\t *\n\t * @type {number}\n\t * @example 600\n\t */\n\twidth?: number;\n\n\t/**\n\t * The height of the popup window.\n\t *\n\t * @type {number}\n\t * @example 400\n\t */\n\theight?: number;\n\n\t/**\n\t * Whether the popup window should display a menubar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tmenubar?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display a toolbar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\ttoolbar?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display the address/location bar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tlocation?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display a status bar.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example true\n\t */\n\tstatus?: boolean | string;\n\n\t/**\n\t * Whether the popup window should be resizable.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example false\n\t */\n\tresizable?: boolean | string;\n\n\t/**\n\t * Whether the popup window should display scrollbars.\n\t *\n\t * Can be a boolean value or a string ('yes' or 'no').\n\t *\n\t * @type {boolean | string}\n\t * @example false\n\t */\n\tscrollbars?: boolean | string;\n\n\t[key: string]: boolean | string | number | undefined;\n};\n\n/**\n * Parameters for popup authentication flow.\n */\nexport type PopupParams = ExtraRequestArgs & {\n\t/**\n\t * Configuration options for the popup window, including size, position, and other features.\n\t *\n\t * @type {PopupWindowFeatures}\n\t */\n\tpopupWindowFeatures?: PopupWindowFeatures;\n\n\t/**\n\t * The target of the popup window, which specifies where the popup should be opened.\n\t *\n\t * @type {string}\n\t * @example '_blank' | '_self' | '_parent' | '_top'\n\t */\n\tpopupWindowTarget?: string;\n};\n\n/**\n * Parameters for native authentication flow.\n */\nexport type NativeParams = RedirectParams;\n\nexport declare const WidgetTypeList: readonly [\n\t'layout',\n\t'submit',\n\t'static',\n\t'input',\n\t'checkbox',\n\t'password',\n\t'select',\n\t'multiSelect',\n\t'passcode',\n\t'date',\n\t'phone',\n\t'loading',\n];\nexport type WidgetType = (typeof WidgetTypeList)[number];\nexport declare const SelectOptionTypeList: readonly ['item', 'group'];\nexport type SelectOptionType = (typeof SelectOptionTypeList)[number];\nexport type BrandingData = {\n\tlogoUrl: string | null;\n\tbrandName: string | null;\n\tcopyright: string | null;\n\tprivacyPolicyUrl: string | null;\n\tsiteTermsUrl: string | null;\n};\nexport type CheckboxWidget = {\n\tid: string;\n\ttype: 'checkbox';\n\tlabel?: string;\n\treadonly?: boolean;\n\tvalue?: boolean;\n\trender: {\n\t\ttype: 'checkboxHidden' | 'checkboxShown';\n\t\tlabelType: 'text' | 'html';\n\t};\n\tvalidator?: {\n\t\trequired?: boolean;\n\t};\n};\nexport type DateWidget = {\n\tid: string;\n\ttype: 'date';\n\tlabel?: string;\n\tplaceholder?: string;\n\treadonly?: boolean;\n\tvalue?: string;\n\trender: {\n\t\ttype: 'native' | 'fieldSet';\n\t};\n\tvalidator?: {\n\t\tnotBefore?: string;\n\t\tnotAfter?: string;\n\t\trequired?: boolean;\n\t};\n};\nexport type InputWidget = {\n\tid: string;\n\ttype: 'input';\n\tlabel?: string;\n\tvalue?: string;\n\tplaceholder?: string;\n\treadonly?: boolean;\n\tautocomplete?: string;\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tinputmode: any;\n\tvalidator?: {\n\t\trequired?: boolean;\n\t\tminLength?: number;\n\t\tmaxLength?: number;\n\t\tregex?: string;\n\t};\n};\nexport type PasscodeWidget = {\n\tid: string;\n\ttype: 'passcode';\n\tlabel?: string;\n\tvalidator?: {\n\t\tlength?: number;\n\t};\n};\nexport type PasswordWidget = {\n\tid: string;\n\ttype: 'password';\n\tlabel?: string;\n\tqualityIndicator?: boolean;\n\tvalidator?: {\n\t\tminLength?: number;\n\t\tmaxLength?: number;\n\t\tmaxNumericCharacterSequences?: number;\n\t\tmaxRepeatedCharacters?: number;\n\t\tmustContain?: Array<'UPPERCASE' | 'LOWERCASE' | 'NUMERIC' | 'SPECIAL'>;\n\t\trestrictedCharacters?: string;\n\t};\n};\nexport type PhoneWidget = {\n\tid: string;\n\ttype: 'phone';\n\tlabel?: string;\n\treadonly?: boolean;\n\tvalue?: string;\n\tvalidator?: {\n\t\trequired?: boolean;\n\t};\n};\nexport type SelectWidgetOption = {\n\ttype: 'item';\n\tlabel?: string;\n\tvalue: string;\n};\nexport type SelectWidgetOptionGroup = {\n\ttype: 'group';\n\tlabel?: string;\n\toptions: Array<SelectWidgetOption>;\n};\nexport type SelectWidget = {\n\tid: string;\n\ttype: 'select';\n\tlabel?: string;\n\treadonly?: boolean;\n\tvalues?: Array<string>;\n\tplaceholder?: string;\n\trender: {\n\t\ttype: 'dropdown' | 'radio';\n\t};\n\toptions: Array<SelectWidgetOptionGroup | SelectWidgetOption>;\n\tvalidator?: {\n\t\trequired?: boolean;\n\t};\n};\nexport type MultiSelectWidget = {\n\tid: string;\n\ttype: 'multiSelect';\n\tlabel?: string;\n\treadonly?: boolean;\n\tvalues?: Array<string>;\n\tplaceholder?: string;\n\trender: {\n\t\ttype: 'dropdown' | 'checkbox';\n\t};\n\toptions: Array<SelectWidgetOptionGroup | SelectWidgetOption>;\n\tvalidator?: {\n\t\tminSelectable?: number;\n\t\tmaxSelectable?: number;\n\t};\n};\nexport type StaticWidget = {\n\tid: string;\n\ttype: 'static';\n\tvalue: string;\n\trender: {\n\t\ttype: 'html' | 'text';\n\t};\n};\nexport type SubmitWidget = {\n\tid: string;\n\ttype: 'submit';\n\tlabel?: string;\n\trender: {\n\t\ttype: 'button' | 'link';\n\t\ttextColor?: string;\n\t\tbgColor?: string;\n\t\thint?: {\n\t\t\ticon?: string;\n\t\t\tvariant?: string;\n\t\t};\n\t};\n};\nexport type FormWidget = {\n\tid: string;\n\ttype: 'form';\n\twidgets: Array<\n\t\tCheckboxWidget | DateWidget | InputWidget | PasscodeWidget | PasswordWidget | PhoneWidget | SelectWidget | MultiSelectWidget | StaticWidget | SubmitWidget\n\t>;\n};\nexport type Widget = {\n\ttype: 'widget';\n\tformId: string;\n\twidgetId: string;\n};\nexport type LayoutWidget = {\n\ttype: 'vertical' | 'horizontal';\n\titems: Array<Widget | LayoutWidget>;\n};\nexport type LoginFlowMessage = {\n\ttype: string;\n\ttext: string;\n};\nexport type LoginFlowState = {\n\thostedUrl?: string;\n\tfinalizeUrl?: string;\n\tscreen?: string;\n\tbranding?: BrandingData;\n\tforms?: Array<FormWidget>;\n\tlayout?: LayoutWidget;\n\tmessages?: Record<string, Record<string, LoginFlowMessage>> & {\n\t\tglobal?: LoginFlowMessage;\n\t};\n};\n\n// endregion\n"],"names":["ResponseTypeList","ResponseModeList","TokenEndpointAuthMethodList","GrantTypeList","AlgorithmTypeList","SubjectTypeList","PromptTypeList","FallbackModeTypeList","SDKStorage","SDKHttpClient"],"mappings":"gFA6BO,MAAMA,EAAmB,CAAC,OAAQ,UAAU,EAStCC,EAAmB,CAAC,QAAS,UAAU,EASvCC,EAA8B,CAAC,MAAM,EASrCC,EAAgB,CAAC,qBAAsB,eAAe,EAStDC,EAAoB,CAAC,OAAO,EAS5BC,EAAkB,CAAC,QAAQ,EAS3BC,EAAiB,CAAC,OAAQ,QAAS,QAAQ,EAS3CC,EAAuB,CAAC,WAAY,OAAO,EA0gBjD,MAAeC,CAAW,CAuBjC,CAKO,MAAeC,CAAc,CAOpC"}
package/dist/types.d.ts CHANGED
@@ -450,7 +450,7 @@ export type SDKOptions = {
450
450
  * @type {'popup' | 'redirect'}
451
451
  * @default 'redirect'
452
452
  */
453
- mode?: 'popup' | 'redirect';
453
+ mode?: 'popup' | 'redirect' | 'native';
454
454
  /**
455
455
  * The issuer of the tokens, typically the URL of the authorization server.
456
456
  *
@@ -509,6 +509,31 @@ export type SDKOptions = {
509
509
  * @default LocalStorage
510
510
  */
511
511
  storage?: SDKStorageType;
512
+ /**
513
+ * The HTTP client used for making requests to the authorization server.
514
+ *
515
+ * @type {SDKHttpClient}
516
+ * @default HttpClient
517
+ */
518
+ httpClient?: SDKHttpClientType;
519
+ /**
520
+ * Handles the URL redirection to the specified target.
521
+ * You can use this method to implement custom URL handling logic, such as opening a new window or navigating to a different page.
522
+ *
523
+ * @param {string} url - The URL to handle.
524
+ * @param {Record<string, unknown>} params - Optional parameters for redirection.
525
+ * @returns - A promise that resolves when the redirection is handled.
526
+ */
527
+ urlHandler?: (url: string, params?: Record<string, unknown>) => Promise<unknown>;
528
+ /**
529
+ * Handles the callback from the authorization server after a successful authentication or authorization.
530
+ * You can use this method to implement custom logic for processing the response from the authorization server.
531
+ *
532
+ * @param url - The URL containing the response from the authorization server.
533
+ * @param responseMode - The mode in which the response is returned (e.g., 'query', 'fragment').
534
+ * @returns - A promise that resolves when the callback is handled.
535
+ */
536
+ callbackHandler?: (url: string, responseMode?: ResponseMode) => Promise<unknown>;
512
537
  };
513
538
  /**
514
539
  * Abstract class for SDK storage mechanisms.
@@ -520,25 +545,52 @@ export declare abstract class SDKStorage {
520
545
  * @param {string} key - The key of the item to retrieve.
521
546
  * @returns {string | null} The value associated with the key, or `null` if not found.
522
547
  */
523
- abstract get(key: string): string | null;
548
+ abstract get(key: string): Promise<string | null>;
524
549
  /**
525
550
  * Deletes an item from the storage by key.
526
551
  *
527
552
  * @param {string} key - The key of the item to delete.
528
553
  */
529
- abstract delete(key: string): void;
554
+ abstract delete(key: string): Promise<void>;
530
555
  /**
531
556
  * Sets an item in the storage with the specified key and value.
532
557
  *
533
558
  * @param {string} key - The key to associate with the value.
534
559
  * @param {string} value - The value to store.
535
560
  */
536
- abstract set(key: string, value: string): void;
561
+ abstract set(key: string, value: string): Promise<void>;
562
+ }
563
+ /**
564
+ * Abstract class for HTTP client used in the SDK.
565
+ */
566
+ export declare abstract class SDKHttpClient {
567
+ /**
568
+ * Makes an HTTP request to the specified URL with optional options.
569
+ * @param {string} url - The URL to which the request is sent.
570
+ * @param {RequestInit} options - Optional request options, such as method, headers, body, etc.
571
+ */
572
+ abstract request<T>(url: string, options?: RequestInit): Promise<HttpClientResponse<T>>;
537
573
  }
538
574
  /**
539
575
  * Type representing a constructor function for SDKStorage.
540
576
  */
541
577
  export type SDKStorageType = new (...args: Array<any>) => SDKStorage;
578
+ /**
579
+ * Type representing a constructor function for SDKHttpClient.
580
+ */
581
+ export type SDKHttpClientType = new (...args: Array<any>) => SDKHttpClient;
582
+ /**
583
+ * Http client response type.
584
+ */
585
+ export type HttpClientResponse<T> = {
586
+ readonly headers: Headers;
587
+ readonly ok: boolean;
588
+ readonly status: number;
589
+ readonly statusText: string;
590
+ readonly url: string;
591
+ json(): Promise<T>;
592
+ text(): Promise<string>;
593
+ };
542
594
  /**
543
595
  * A collection of functions used to handle various events that occur within the SDK.
544
596
  */
@@ -698,9 +750,9 @@ export type ExtraRequestArgs = {
698
750
  uiLocales?: Array<string>;
699
751
  };
700
752
  /**
701
- * Options for configuring logout behavior.
753
+ * Params for configuring logout behavior.
702
754
  */
703
- export type LogoutOptions = {
755
+ export type LogoutParams = {
704
756
  /**
705
757
  * The URI to redirect to after a successful logout.
706
758
  *
@@ -712,24 +764,6 @@ export type LogoutOptions = {
712
764
  */
713
765
  postLogoutRedirectUri?: string;
714
766
  };
715
- /**
716
- * List of select option types.
717
- */
718
- export declare const SelectOptionTypeList: readonly ["item", "group"];
719
- /**
720
- * Type representing valid select option types.
721
- */
722
- export type SelectOptionType = (typeof SelectOptionTypeList)[number];
723
- /**
724
- * Data for branding purposes, such as logo and brand name.
725
- */
726
- export type BrandingData = {
727
- logoUrl: string | null;
728
- brandName: string | null;
729
- copyright: string | null;
730
- privacyPolicyUrl: string | null;
731
- siteTermsUrl: string | null;
732
- };
733
767
  /**
734
768
  * Parameters for redirect authentication flow.
735
769
  */
@@ -844,7 +878,7 @@ export type PopupWindowFeatures = {
844
878
  /**
845
879
  * Parameters for popup authentication flow.
846
880
  */
847
- export type PopupWindowParams = ExtraRequestArgs & {
881
+ export type PopupParams = ExtraRequestArgs & {
848
882
  /**
849
883
  * Configuration options for the popup window, including size, position, and other features.
850
884
  *
@@ -859,3 +893,201 @@ export type PopupWindowParams = ExtraRequestArgs & {
859
893
  */
860
894
  popupWindowTarget?: string;
861
895
  };
896
+ /**
897
+ * Parameters for native authentication flow.
898
+ */
899
+ export type NativeParams = RedirectParams;
900
+ export declare const WidgetTypeList: readonly [
901
+ 'layout',
902
+ 'submit',
903
+ 'static',
904
+ 'input',
905
+ 'checkbox',
906
+ 'password',
907
+ 'select',
908
+ 'multiSelect',
909
+ 'passcode',
910
+ 'date',
911
+ 'phone',
912
+ 'loading'
913
+ ];
914
+ export type WidgetType = (typeof WidgetTypeList)[number];
915
+ export declare const SelectOptionTypeList: readonly ['item', 'group'];
916
+ export type SelectOptionType = (typeof SelectOptionTypeList)[number];
917
+ export type BrandingData = {
918
+ logoUrl: string | null;
919
+ brandName: string | null;
920
+ copyright: string | null;
921
+ privacyPolicyUrl: string | null;
922
+ siteTermsUrl: string | null;
923
+ };
924
+ export type CheckboxWidget = {
925
+ id: string;
926
+ type: 'checkbox';
927
+ label?: string;
928
+ readonly?: boolean;
929
+ value?: boolean;
930
+ render: {
931
+ type: 'checkboxHidden' | 'checkboxShown';
932
+ labelType: 'text' | 'html';
933
+ };
934
+ validator?: {
935
+ required?: boolean;
936
+ };
937
+ };
938
+ export type DateWidget = {
939
+ id: string;
940
+ type: 'date';
941
+ label?: string;
942
+ placeholder?: string;
943
+ readonly?: boolean;
944
+ value?: string;
945
+ render: {
946
+ type: 'native' | 'fieldSet';
947
+ };
948
+ validator?: {
949
+ notBefore?: string;
950
+ notAfter?: string;
951
+ required?: boolean;
952
+ };
953
+ };
954
+ export type InputWidget = {
955
+ id: string;
956
+ type: 'input';
957
+ label?: string;
958
+ value?: string;
959
+ placeholder?: string;
960
+ readonly?: boolean;
961
+ autocomplete?: string;
962
+ inputmode: any;
963
+ validator?: {
964
+ required?: boolean;
965
+ minLength?: number;
966
+ maxLength?: number;
967
+ regex?: string;
968
+ };
969
+ };
970
+ export type PasscodeWidget = {
971
+ id: string;
972
+ type: 'passcode';
973
+ label?: string;
974
+ validator?: {
975
+ length?: number;
976
+ };
977
+ };
978
+ export type PasswordWidget = {
979
+ id: string;
980
+ type: 'password';
981
+ label?: string;
982
+ qualityIndicator?: boolean;
983
+ validator?: {
984
+ minLength?: number;
985
+ maxLength?: number;
986
+ maxNumericCharacterSequences?: number;
987
+ maxRepeatedCharacters?: number;
988
+ mustContain?: Array<'UPPERCASE' | 'LOWERCASE' | 'NUMERIC' | 'SPECIAL'>;
989
+ restrictedCharacters?: string;
990
+ };
991
+ };
992
+ export type PhoneWidget = {
993
+ id: string;
994
+ type: 'phone';
995
+ label?: string;
996
+ readonly?: boolean;
997
+ value?: string;
998
+ validator?: {
999
+ required?: boolean;
1000
+ };
1001
+ };
1002
+ export type SelectWidgetOption = {
1003
+ type: 'item';
1004
+ label?: string;
1005
+ value: string;
1006
+ };
1007
+ export type SelectWidgetOptionGroup = {
1008
+ type: 'group';
1009
+ label?: string;
1010
+ options: Array<SelectWidgetOption>;
1011
+ };
1012
+ export type SelectWidget = {
1013
+ id: string;
1014
+ type: 'select';
1015
+ label?: string;
1016
+ readonly?: boolean;
1017
+ values?: Array<string>;
1018
+ placeholder?: string;
1019
+ render: {
1020
+ type: 'dropdown' | 'radio';
1021
+ };
1022
+ options: Array<SelectWidgetOptionGroup | SelectWidgetOption>;
1023
+ validator?: {
1024
+ required?: boolean;
1025
+ };
1026
+ };
1027
+ export type MultiSelectWidget = {
1028
+ id: string;
1029
+ type: 'multiSelect';
1030
+ label?: string;
1031
+ readonly?: boolean;
1032
+ values?: Array<string>;
1033
+ placeholder?: string;
1034
+ render: {
1035
+ type: 'dropdown' | 'checkbox';
1036
+ };
1037
+ options: Array<SelectWidgetOptionGroup | SelectWidgetOption>;
1038
+ validator?: {
1039
+ minSelectable?: number;
1040
+ maxSelectable?: number;
1041
+ };
1042
+ };
1043
+ export type StaticWidget = {
1044
+ id: string;
1045
+ type: 'static';
1046
+ value: string;
1047
+ render: {
1048
+ type: 'html' | 'text';
1049
+ };
1050
+ };
1051
+ export type SubmitWidget = {
1052
+ id: string;
1053
+ type: 'submit';
1054
+ label?: string;
1055
+ render: {
1056
+ type: 'button' | 'link';
1057
+ textColor?: string;
1058
+ bgColor?: string;
1059
+ hint?: {
1060
+ icon?: string;
1061
+ variant?: string;
1062
+ };
1063
+ };
1064
+ };
1065
+ export type FormWidget = {
1066
+ id: string;
1067
+ type: 'form';
1068
+ widgets: Array<CheckboxWidget | DateWidget | InputWidget | PasscodeWidget | PasswordWidget | PhoneWidget | SelectWidget | MultiSelectWidget | StaticWidget | SubmitWidget>;
1069
+ };
1070
+ export type Widget = {
1071
+ type: 'widget';
1072
+ formId: string;
1073
+ widgetId: string;
1074
+ };
1075
+ export type LayoutWidget = {
1076
+ type: 'vertical' | 'horizontal';
1077
+ items: Array<Widget | LayoutWidget>;
1078
+ };
1079
+ export type LoginFlowMessage = {
1080
+ type: string;
1081
+ text: string;
1082
+ };
1083
+ export type LoginFlowState = {
1084
+ hostedUrl?: string;
1085
+ finalizeUrl?: string;
1086
+ screen?: string;
1087
+ branding?: BrandingData;
1088
+ forms?: Array<FormWidget>;
1089
+ layout?: LayoutWidget;
1090
+ messages?: Record<string, Record<string, LoginFlowMessage>> & {
1091
+ global?: LoginFlowMessage;
1092
+ };
1093
+ };
package/dist/types.mjs CHANGED
@@ -1,2 +1,2 @@
1
- const e=["code","id_token"],o=["query","fragment"],n=["none"],s=["authorization_code","refresh_token"],i=["RS256"],c=["public"],p=["none","login","create"],r=["redirect","popup"];class a{}const L=["item","group"];export{i as AlgorithmTypeList,r as FallbackModeTypeList,s as GrantTypeList,p as PromptTypeList,o as ResponseModeList,e as ResponseTypeList,a as SDKStorage,L as SelectOptionTypeList,c as SubjectTypeList,n as TokenEndpointAuthMethodList};
1
+ const e=["code","id_token"],o=["query","fragment"],s=["none"],n=["authorization_code","refresh_token"],c=["RS256"],i=["public"],p=["none","login","create"],r=["redirect","popup"];class a{}class d{}export{c as AlgorithmTypeList,r as FallbackModeTypeList,n as GrantTypeList,p as PromptTypeList,o as ResponseModeList,e as ResponseTypeList,d as SDKHttpClient,a as SDKStorage,i as SubjectTypeList,s as TokenEndpointAuthMethodList};
2
2
  //# sourceMappingURL=types.mjs.map