@thunderid/javascript 0.11.1 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/dist/DefaultCacheStore.d.ts +0 -17
  2. package/dist/DefaultCacheStore.d.ts.map +1 -1
  3. package/dist/DefaultCrypto.d.ts +0 -17
  4. package/dist/DefaultCrypto.d.ts.map +1 -1
  5. package/dist/HttpClient.d.ts +0 -17
  6. package/dist/HttpClient.d.ts.map +1 -1
  7. package/dist/IsomorphicCrypto.d.ts +0 -17
  8. package/dist/IsomorphicCrypto.d.ts.map +1 -1
  9. package/dist/StorageManager.d.ts +0 -17
  10. package/dist/StorageManager.d.ts.map +1 -1
  11. package/dist/ThunderIDJavaScriptClient.d.ts +7 -17
  12. package/dist/ThunderIDJavaScriptClient.d.ts.map +1 -1
  13. package/dist/api/executeEmbeddedRecoveryFlow.d.ts +0 -17
  14. package/dist/api/executeEmbeddedRecoveryFlow.d.ts.map +1 -1
  15. package/dist/api/executeEmbeddedSignInFlow.d.ts +0 -17
  16. package/dist/api/executeEmbeddedSignInFlow.d.ts.map +1 -1
  17. package/dist/api/executeEmbeddedSignUpFlow.d.ts +0 -17
  18. package/dist/api/executeEmbeddedSignUpFlow.d.ts.map +1 -1
  19. package/dist/api/executeEmbeddedUserOnboardingFlow.d.ts +0 -17
  20. package/dist/api/executeEmbeddedUserOnboardingFlow.d.ts.map +1 -1
  21. package/dist/api/getFlowMeta.d.ts +0 -17
  22. package/dist/api/getFlowMeta.d.ts.map +1 -1
  23. package/dist/api/getOrganizationUnitChildren.d.ts +0 -17
  24. package/dist/api/getOrganizationUnitChildren.d.ts.map +1 -1
  25. package/dist/api/getUserInfo.d.ts +0 -17
  26. package/dist/api/getUserInfo.d.ts.map +1 -1
  27. package/dist/api/getUsersMe.d.ts +0 -17
  28. package/dist/api/getUsersMe.d.ts.map +1 -1
  29. package/dist/api/updateMeProfile.d.ts +0 -17
  30. package/dist/api/updateMeProfile.d.ts.map +1 -1
  31. package/dist/cjs/index.cjs +750 -1144
  32. package/dist/constants/ApplicationNativeAuthenticationConstants.d.ts +0 -17
  33. package/dist/constants/ApplicationNativeAuthenticationConstants.d.ts.map +1 -1
  34. package/dist/constants/OIDCDiscoveryConstants.d.ts +0 -17
  35. package/dist/constants/OIDCDiscoveryConstants.d.ts.map +1 -1
  36. package/dist/constants/OIDCRequestConstants.d.ts +0 -17
  37. package/dist/constants/OIDCRequestConstants.d.ts.map +1 -1
  38. package/dist/constants/PKCEConstants.d.ts +0 -17
  39. package/dist/constants/PKCEConstants.d.ts.map +1 -1
  40. package/dist/constants/ScopeConstants.d.ts +0 -17
  41. package/dist/constants/ScopeConstants.d.ts.map +1 -1
  42. package/dist/constants/TokenConstants.d.ts +3 -17
  43. package/dist/constants/TokenConstants.d.ts.map +1 -1
  44. package/dist/constants/TokenExchangeConstants.d.ts +0 -17
  45. package/dist/constants/TokenExchangeConstants.d.ts.map +1 -1
  46. package/dist/constants/VendorConstants.d.ts +0 -17
  47. package/dist/constants/VendorConstants.d.ts.map +1 -1
  48. package/dist/edge/index.js +750 -1145
  49. package/dist/errors/ThunderIDAPIError.d.ts +0 -17
  50. package/dist/errors/ThunderIDAPIError.d.ts.map +1 -1
  51. package/dist/errors/ThunderIDError.d.ts +0 -17
  52. package/dist/errors/ThunderIDError.d.ts.map +1 -1
  53. package/dist/errors/ThunderIDRuntimeError.d.ts +0 -17
  54. package/dist/errors/ThunderIDRuntimeError.d.ts.map +1 -1
  55. package/dist/errors/exception.d.ts +0 -17
  56. package/dist/errors/exception.d.ts.map +1 -1
  57. package/dist/i18n/constants/TranslationBundleConstants.d.ts +0 -17
  58. package/dist/i18n/constants/TranslationBundleConstants.d.ts.map +1 -1
  59. package/dist/i18n/models/i18n.d.ts +0 -17
  60. package/dist/i18n/models/i18n.d.ts.map +1 -1
  61. package/dist/i18n/translations/en-US.d.ts +0 -17
  62. package/dist/i18n/translations/en-US.d.ts.map +1 -1
  63. package/dist/i18n/translations/fr-FR.d.ts +0 -17
  64. package/dist/i18n/translations/fr-FR.d.ts.map +1 -1
  65. package/dist/i18n/translations/hi-IN.d.ts +0 -17
  66. package/dist/i18n/translations/hi-IN.d.ts.map +1 -1
  67. package/dist/i18n/translations/index.d.ts +0 -17
  68. package/dist/i18n/translations/index.d.ts.map +1 -1
  69. package/dist/i18n/translations/ja-JP.d.ts +0 -17
  70. package/dist/i18n/translations/ja-JP.d.ts.map +1 -1
  71. package/dist/i18n/translations/pt-BR.d.ts +0 -17
  72. package/dist/i18n/translations/pt-BR.d.ts.map +1 -1
  73. package/dist/i18n/translations/pt-PT.d.ts +0 -17
  74. package/dist/i18n/translations/pt-PT.d.ts.map +1 -1
  75. package/dist/i18n/translations/si-LK.d.ts +0 -17
  76. package/dist/i18n/translations/si-LK.d.ts.map +1 -1
  77. package/dist/i18n/translations/ta-IN.d.ts +0 -17
  78. package/dist/i18n/translations/ta-IN.d.ts.map +1 -1
  79. package/dist/i18n/translations/te-IN.d.ts +0 -17
  80. package/dist/i18n/translations/te-IN.d.ts.map +1 -1
  81. package/dist/i18n/utils/getDefaultI18nBundles.d.ts +0 -17
  82. package/dist/i18n/utils/getDefaultI18nBundles.d.ts.map +1 -1
  83. package/dist/i18n/utils/normalizeTranslations.d.ts +0 -17
  84. package/dist/i18n/utils/normalizeTranslations.d.ts.map +1 -1
  85. package/dist/index.d.ts +2 -17
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +750 -1145
  88. package/dist/models/agent.d.ts +0 -17
  89. package/dist/models/agent.d.ts.map +1 -1
  90. package/dist/models/auth-code-response.d.ts +0 -17
  91. package/dist/models/auth-code-response.d.ts.map +1 -1
  92. package/dist/models/ciba.d.ts +0 -17
  93. package/dist/models/ciba.d.ts.map +1 -1
  94. package/dist/models/client.d.ts +0 -17
  95. package/dist/models/client.d.ts.map +1 -1
  96. package/dist/models/config.d.ts +53 -23
  97. package/dist/models/config.d.ts.map +1 -1
  98. package/dist/models/crypto.d.ts +0 -17
  99. package/dist/models/crypto.d.ts.map +1 -1
  100. package/dist/models/embedded-flow.d.ts +0 -17
  101. package/dist/models/embedded-flow.d.ts.map +1 -1
  102. package/dist/models/embedded-recovery-flow.d.ts +0 -17
  103. package/dist/models/embedded-recovery-flow.d.ts.map +1 -1
  104. package/dist/models/embedded-signin-flow.d.ts +5 -17
  105. package/dist/models/embedded-signin-flow.d.ts.map +1 -1
  106. package/dist/models/embedded-signup-flow.d.ts +0 -17
  107. package/dist/models/embedded-signup-flow.d.ts.map +1 -1
  108. package/dist/models/extensions/components.d.ts +0 -17
  109. package/dist/models/extensions/components.d.ts.map +1 -1
  110. package/dist/models/field.d.ts +0 -17
  111. package/dist/models/field.d.ts.map +1 -1
  112. package/dist/models/flow-meta.d.ts +0 -17
  113. package/dist/models/flow-meta.d.ts.map +1 -1
  114. package/dist/models/flow.d.ts +1 -19
  115. package/dist/models/flow.d.ts.map +1 -1
  116. package/dist/models/http.d.ts +0 -17
  117. package/dist/models/http.d.ts.map +1 -1
  118. package/dist/models/oauth-request.d.ts +0 -17
  119. package/dist/models/oauth-request.d.ts.map +1 -1
  120. package/dist/models/oauth-response.d.ts +0 -17
  121. package/dist/models/oauth-response.d.ts.map +1 -1
  122. package/dist/models/oidc-discovery.d.ts +0 -17
  123. package/dist/models/oidc-discovery.d.ts.map +1 -1
  124. package/dist/models/oidc-endpoints.d.ts +0 -17
  125. package/dist/models/oidc-endpoints.d.ts.map +1 -1
  126. package/dist/models/session.d.ts +0 -17
  127. package/dist/models/session.d.ts.map +1 -1
  128. package/dist/models/store.d.ts +0 -17
  129. package/dist/models/store.d.ts.map +1 -1
  130. package/dist/models/token-endpoint-auth.d.ts +0 -17
  131. package/dist/models/token-endpoint-auth.d.ts.map +1 -1
  132. package/dist/models/token.d.ts +0 -17
  133. package/dist/models/token.d.ts.map +1 -1
  134. package/dist/models/translation.d.ts +0 -17
  135. package/dist/models/translation.d.ts.map +1 -1
  136. package/dist/models/user.d.ts +0 -17
  137. package/dist/models/user.d.ts.map +1 -1
  138. package/dist/models/utility-types.d.ts +0 -17
  139. package/dist/models/utility-types.d.ts.map +1 -1
  140. package/dist/models/vars.d.ts +0 -17
  141. package/dist/models/vars.d.ts.map +1 -1
  142. package/dist/theme/createTheme.d.ts +0 -17
  143. package/dist/theme/createTheme.d.ts.map +1 -1
  144. package/dist/theme/types.d.ts +0 -17
  145. package/dist/theme/types.d.ts.map +1 -1
  146. package/dist/utils/AuthenticationHelper.d.ts +11 -17
  147. package/dist/utils/AuthenticationHelper.d.ts.map +1 -1
  148. package/dist/utils/arrayBufferToBase64url.d.ts +0 -17
  149. package/dist/utils/arrayBufferToBase64url.d.ts.map +1 -1
  150. package/dist/utils/base64Encode.d.ts +0 -17
  151. package/dist/utils/base64Encode.d.ts.map +1 -1
  152. package/dist/utils/base64urlToArrayBuffer.d.ts +0 -17
  153. package/dist/utils/base64urlToArrayBuffer.d.ts.map +1 -1
  154. package/dist/utils/bem.d.ts +0 -17
  155. package/dist/utils/bem.d.ts.map +1 -1
  156. package/dist/utils/buildValidatorFromRules.d.ts +0 -17
  157. package/dist/utils/buildValidatorFromRules.d.ts.map +1 -1
  158. package/dist/utils/containsMetaFlowTemplateLiteral.d.ts +0 -17
  159. package/dist/utils/containsMetaFlowTemplateLiteral.d.ts.map +1 -1
  160. package/dist/utils/countryCodeToFlagEmoji.d.ts +0 -17
  161. package/dist/utils/countryCodeToFlagEmoji.d.ts.map +1 -1
  162. package/dist/utils/deepMerge.d.ts +0 -17
  163. package/dist/utils/deepMerge.d.ts.map +1 -1
  164. package/dist/utils/evaluateValidationRule.d.ts +0 -17
  165. package/dist/utils/evaluateValidationRule.d.ts.map +1 -1
  166. package/dist/utils/extractEmojiFromUri.d.ts +0 -17
  167. package/dist/utils/extractEmojiFromUri.d.ts.map +1 -1
  168. package/dist/utils/extractPkceStorageKeyFromState.d.ts +0 -17
  169. package/dist/utils/extractPkceStorageKeyFromState.d.ts.map +1 -1
  170. package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +0 -17
  171. package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts.map +1 -1
  172. package/dist/utils/extractUserClaimsFromIdToken.d.ts +0 -17
  173. package/dist/utils/extractUserClaimsFromIdToken.d.ts.map +1 -1
  174. package/dist/utils/formatDate.d.ts +0 -17
  175. package/dist/utils/formatDate.d.ts.map +1 -1
  176. package/dist/utils/generatePkceStorageKey.d.ts +0 -17
  177. package/dist/utils/generatePkceStorageKey.d.ts.map +1 -1
  178. package/dist/utils/generateStateParamForRequestCorrelation.d.ts +0 -17
  179. package/dist/utils/generateStateParamForRequestCorrelation.d.ts.map +1 -1
  180. package/dist/utils/get.d.ts +0 -17
  181. package/dist/utils/get.d.ts.map +1 -1
  182. package/dist/utils/getAuthorizeRequestUrlParams.d.ts +0 -17
  183. package/dist/utils/getAuthorizeRequestUrlParams.d.ts.map +1 -1
  184. package/dist/utils/getLatestStateParam.d.ts +0 -17
  185. package/dist/utils/getLatestStateParam.d.ts.map +1 -1
  186. package/dist/utils/getRedirectBasedSignUpUrl.d.ts +0 -17
  187. package/dist/utils/getRedirectBasedSignUpUrl.d.ts.map +1 -1
  188. package/dist/utils/getVendorPrefix.d.ts +0 -17
  189. package/dist/utils/getVendorPrefix.d.ts.map +1 -1
  190. package/dist/utils/injectRequestedPermissions.d.ts +0 -17
  191. package/dist/utils/injectRequestedPermissions.d.ts.map +1 -1
  192. package/dist/utils/isEmojiUri.d.ts +0 -17
  193. package/dist/utils/isEmojiUri.d.ts.map +1 -1
  194. package/dist/utils/isEmpty.d.ts +0 -17
  195. package/dist/utils/isEmpty.d.ts.map +1 -1
  196. package/dist/utils/isMetaFlowTemplateLiteral.d.ts +0 -17
  197. package/dist/utils/isMetaFlowTemplateLiteral.d.ts.map +1 -1
  198. package/dist/utils/isRecognizedBaseUrlPattern.d.ts +0 -17
  199. package/dist/utils/isRecognizedBaseUrlPattern.d.ts.map +1 -1
  200. package/dist/utils/isTranslationFlowTemplateLiteral.d.ts +0 -17
  201. package/dist/utils/isTranslationFlowTemplateLiteral.d.ts.map +1 -1
  202. package/dist/utils/logger.d.ts +0 -17
  203. package/dist/utils/logger.d.ts.map +1 -1
  204. package/dist/utils/parseApiErrorMessage.d.ts +0 -17
  205. package/dist/utils/parseApiErrorMessage.d.ts.map +1 -1
  206. package/dist/utils/parseFlowTemplateLiteral.d.ts +0 -17
  207. package/dist/utils/parseFlowTemplateLiteral.d.ts.map +1 -1
  208. package/dist/utils/processOpenIDScopes.d.ts +0 -17
  209. package/dist/utils/processOpenIDScopes.d.ts.map +1 -1
  210. package/dist/utils/processUsername.d.ts +0 -17
  211. package/dist/utils/processUsername.d.ts.map +1 -1
  212. package/dist/utils/removeTrailingSlash.d.ts +0 -17
  213. package/dist/utils/removeTrailingSlash.d.ts.map +1 -1
  214. package/dist/utils/resolveFieldName.d.ts +0 -17
  215. package/dist/utils/resolveFieldName.d.ts.map +1 -1
  216. package/dist/utils/resolveFlowTemplateLiterals.d.ts +0 -17
  217. package/dist/utils/resolveFlowTemplateLiterals.d.ts.map +1 -1
  218. package/dist/utils/resolveLocaleDisplayName.d.ts +0 -17
  219. package/dist/utils/resolveLocaleDisplayName.d.ts.map +1 -1
  220. package/dist/utils/resolveLocaleEmoji.d.ts +0 -17
  221. package/dist/utils/resolveLocaleEmoji.d.ts.map +1 -1
  222. package/dist/utils/resolveMeta.d.ts +0 -17
  223. package/dist/utils/resolveMeta.d.ts.map +1 -1
  224. package/dist/utils/resolveResourceEndpoint.d.ts +48 -0
  225. package/dist/utils/resolveResourceEndpoint.d.ts.map +1 -0
  226. package/dist/utils/set.d.ts +0 -17
  227. package/dist/utils/set.d.ts.map +1 -1
  228. package/dist/utils/startCase.d.ts +0 -17
  229. package/dist/utils/startCase.d.ts.map +1 -1
  230. package/dist/utils/withVendorCSSClassPrefix.d.ts +1 -18
  231. package/dist/utils/withVendorCSSClassPrefix.d.ts.map +1 -1
  232. package/package.json +2 -2
@@ -34,23 +34,6 @@ jose = __toESM(jose);
34
34
 
35
35
  //#region src/constants/TokenConstants.ts
36
36
  /**
37
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
38
- *
39
- * WSO2 LLC. licenses this file to you under the Apache License,
40
- * Version 2.0 (the "License"); you may not use this file except
41
- * in compliance with the License.
42
- * You may obtain a copy of the License at
43
- *
44
- * http://www.apache.org/licenses/LICENSE-2.0
45
- *
46
- * Unless required by applicable law or agreed to in writing,
47
- * software distributed under the License is distributed on an
48
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
49
- * KIND, either express or implied. See the License for the
50
- * specific language governing permissions and limitations
51
- * under the License.
52
- */
53
- /**
54
37
  * Constants related to OIDC token management and storage.
55
38
  * This object contains configuration values and storage keys
56
39
  * used in token validation and management processes.
@@ -79,30 +62,14 @@ const TokenConstants = {
79
62
  "ML-DSA-65",
80
63
  "ML-DSA-87"
81
64
  ] },
82
- Storage: { StorageKeys: { REFRESH_TOKEN_TIMER: "refresh_token_timer" } }
65
+ Storage: { StorageKeys: { REFRESH_TOKEN_TIMER: "refresh_token_timer" } },
66
+ Lifecycle: { CLIENT_CREDENTIALS_REFRESH_MARGIN_MS: 3e4 }
83
67
  };
84
68
  var TokenConstants_default = TokenConstants;
85
69
 
86
70
  //#endregion
87
71
  //#region src/errors/exception.ts
88
72
  /**
89
- * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
90
- *
91
- * WSO2 LLC. licenses this file to you under the Apache License,
92
- * Version 2.0 (the "License"); you may not use this file except
93
- * in compliance with the License.
94
- * You may obtain a copy of the License at
95
- *
96
- * http://www.apache.org/licenses/LICENSE-2.0
97
- *
98
- * Unless required by applicable law or agreed to in writing,
99
- * software distributed under the License is distributed on an
100
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
101
- * KIND, either express or implied. See the License for the
102
- * specific language governing permissions and limitations
103
- * under the License.
104
- */
105
- /**
106
73
  * @deprecated Use `ThunderIDRuntimeError` for runtime errors and `ThunderIDAPIError` for API errors.
107
74
  */
108
75
  var ThunderIDAuthException = class extends Error {
@@ -190,23 +157,6 @@ var IsomorphicCrypto = class {
190
157
  //#endregion
191
158
  //#region src/errors/ThunderIDError.ts
192
159
  /**
193
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
194
- *
195
- * WSO2 LLC. licenses this file to you under the Apache License,
196
- * Version 2.0 (the "License"); you may not use this file except
197
- * in compliance with the License.
198
- * You may obtain a copy of the License at
199
- *
200
- * http://www.apache.org/licenses/LICENSE-2.0
201
- *
202
- * Unless required by applicable law or agreed to in writing,
203
- * software distributed under the License is distributed on an
204
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
205
- * KIND, either express or implied. See the License for the
206
- * specific language governing permissions and limitations
207
- * under the License.
208
- */
209
- /**
210
160
  * Base class for all ThunderID errors. This class extends the native Error class
211
161
  * and adds support for error codes and proper stack traces. Each error is prefixed
212
162
  * with a lightning emoji and the SDK name for easy identification.
@@ -255,23 +205,6 @@ var ThunderIDError = class ThunderIDError extends Error {
255
205
  //#endregion
256
206
  //#region src/utils/parseApiErrorMessage.ts
257
207
  /**
258
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
259
- *
260
- * WSO2 LLC. licenses this file to you under the Apache License,
261
- * Version 2.0 (the "License"); you may not use this file except
262
- * in compliance with the License.
263
- * You may obtain a copy of the License at
264
- *
265
- * http://www.apache.org/licenses/LICENSE-2.0
266
- *
267
- * Unless required by applicable law or agreed to in writing,
268
- * software distributed under the License is distributed on an
269
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
270
- * KIND, either express or implied. See the License for the
271
- * specific language governing permissions and limitations
272
- * under the License.
273
- */
274
- /**
275
208
  * Attempts to extract a human-readable message from a structured API error response body.
276
209
  *
277
210
  * The backend returns errors in the following form:
@@ -434,23 +367,6 @@ let EmbeddedSignInFlowType = /* @__PURE__ */ function(EmbeddedSignInFlowType$1)
434
367
  //#endregion
435
368
  //#region src/utils/injectRequestedPermissions.ts
436
369
  /**
437
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
438
- *
439
- * WSO2 LLC. licenses this file to you under the Apache License,
440
- * Version 2.0 (the "License"); you may not use this file except
441
- * in compliance with the License.
442
- * You may obtain a copy of the License at
443
- *
444
- * http://www.apache.org/licenses/LICENSE-2.0
445
- *
446
- * Unless required by applicable law or agreed to in writing,
447
- * software distributed under the License is distributed on an
448
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
449
- * KIND, either express or implied. See the License for the
450
- * specific language governing permissions and limitations
451
- * under the License.
452
- */
453
- /**
454
370
  * Strips the top-level `scopes` field from a payload and injects it as
455
371
  * `inputs.requested_permissions` (space-separated string).
456
372
  *
@@ -472,175 +388,512 @@ const injectRequestedPermissions = (payload) => {
472
388
  var injectRequestedPermissions_default = injectRequestedPermissions;
473
389
 
474
390
  //#endregion
475
- //#region src/api/executeEmbeddedSignInFlow.ts
476
- const executeEmbeddedSignInFlow = async ({ url, baseUrl, payload, authId, flowSecret,...requestConfig }) => {
477
- if (!payload) throw new ThunderIDAPIError("Authorization payload is required", "executeEmbeddedSignInFlow-ValidationError-002", "javascript", 400, "If an authorization payload is not provided, the request cannot be constructed correctly.");
478
- const endpoint = url ?? `${baseUrl}/flow/execute`;
479
- const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
480
- const isNewFlowStart = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload;
481
- const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
482
- const basePayload = isNewFlowStart ? injectRequestedPermissions_default(cleanPayload) : cleanPayload;
483
- const requestPayload = isNewFlowStart || hasOnlyFlowId ? {
484
- ...basePayload,
485
- verbose: true
486
- } : basePayload;
487
- const response = await fetch(endpoint, {
488
- ...requestConfig,
489
- body: JSON.stringify(requestPayload),
490
- headers: {
491
- Accept: "application/json",
492
- "Content-Type": "application/json",
493
- ...isNewFlowStart && flowSecret ? { "Flow-Secret": flowSecret } : {},
494
- ...requestConfig.headers
495
- },
496
- method: requestConfig.method || "POST"
497
- });
498
- if (!response.ok) throw new ThunderIDAPIError(await response.text(), "executeEmbeddedSignInFlow-ResponseError-001", "javascript", response.status, response.statusText, "Authorization request failed");
499
- const flowResponse = await response.json();
500
- if (flowResponse.flowStatus === EmbeddedSignInFlowStatus.Complete && flowResponse.assertion && authId) try {
501
- const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
502
- body: JSON.stringify({
503
- assertion: flowResponse.assertion,
504
- authId
505
- }),
506
- credentials: "include",
507
- headers: {
508
- Accept: "application/json",
509
- "Content-Type": "application/json",
510
- ...requestConfig.headers
511
- },
512
- method: "POST"
513
- });
514
- if (!oauth2Response.ok) throw new ThunderIDAPIError(await oauth2Response.text(), "executeEmbeddedSignInFlow-OAuth2Error-002", "javascript", oauth2Response.status, oauth2Response.statusText, "OAuth2 authorization failed");
515
- const oauth2Result = await oauth2Response.json();
516
- return {
517
- flowStatus: flowResponse.flowStatus,
518
- redirectUrl: oauth2Result["redirect_uri"]
519
- };
520
- } catch (authError) {
521
- if (authError instanceof ThunderIDAPIError) throw authError;
522
- throw new ThunderIDAPIError(authError instanceof Error ? authError.message : "Unknown error", "executeEmbeddedSignInFlow-OAuth2Error-001", "javascript", 500, "Failed to complete OAuth2 authorization after successful embedded sign-in flow.", "OAuth2 authorization failed");
523
- }
524
- return flowResponse;
391
+ //#region src/utils/logger.ts
392
+ const PREFIX = "⚡ ThunderID";
393
+ /**
394
+ * Default logger configuration
395
+ */
396
+ const DEFAULT_CONFIG$1 = {
397
+ level: "info",
398
+ prefix: `${PREFIX}`,
399
+ showLevel: true,
400
+ timestamps: true
525
401
  };
526
- var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
527
-
528
- //#endregion
529
- //#region src/models/embedded-signup-flow.ts
530
402
  /**
531
- * Status enumeration for ThunderID embedded sign-up flow operations.
532
- *
533
- * These statuses indicate the current state of the registration flow and determine
534
- * the next action required by the client application. Each status provides specific
535
- * guidance on how to proceed with the user registration process.
536
- *
537
- * @example
538
- * ```typescript
539
- * switch (response.flowStatus) {
540
- * case EmbeddedSignUpFlowStatus.Incomplete:
541
- * // More user input needed - render registration form components
542
- * break;
543
- * case EmbeddedSignUpFlowStatus.Complete:
544
- * // Registration successful - handle completion
545
- * break;
546
- * case EmbeddedSignUpFlowStatus.Error:
547
- * // Registration failed - show error details
548
- * const errorResponse = response as EmbeddedSignUpFlowErrorResponse;
549
- * showError(errorResponse.error.description.defaultValue);
550
- * break;
551
- * }
552
- * ```
553
- *
554
- * @experimental Part of the new ThunderID API
403
+ * Environment detection utilities
555
404
  */
556
- let EmbeddedSignUpFlowStatus = /* @__PURE__ */ function(EmbeddedSignUpFlowStatus$1) {
405
+ const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
406
+ const isNode = () => typeof process !== "undefined" && process.versions && process.versions.node;
407
+ /**
408
+ * Color codes for terminal output (Node.js)
409
+ */
410
+ const COLORS = {
411
+ blue: "\x1B[34m",
412
+ bright: "\x1B[1m",
413
+ cyan: "\x1B[36m",
414
+ dim: "\x1B[2m",
415
+ gray: "\x1B[90m",
416
+ green: "\x1B[32m",
417
+ magenta: "\x1B[35m",
418
+ red: "\x1B[31m",
419
+ reset: "\x1B[0m",
420
+ white: "\x1B[37m",
421
+ yellow: "\x1B[33m"
422
+ };
423
+ /**
424
+ * Browser console styling
425
+ */
426
+ const BROWSER_STYLES = {
427
+ debug: "color: #6b7280; font-weight: normal;",
428
+ error: "color: #dc2626; font-weight: bold;",
429
+ info: "color: #2563eb; font-weight: bold;",
430
+ prefix: "color: #7c3aed; font-weight: bold;",
431
+ timestamp: "color: #6b7280; font-size: 0.9em;",
432
+ warn: "color: #d97706; font-weight: bold;"
433
+ };
434
+ const LOG_LEVEL_ORDER = {
435
+ debug: 0,
436
+ error: 3,
437
+ info: 1,
438
+ warn: 2
439
+ };
440
+ /**
441
+ * Universal logger class that works in both browser and Node.js environments
442
+ */
443
+ var Logger = class Logger {
444
+ config;
445
+ constructor(config = {}) {
446
+ this.config = {
447
+ ...DEFAULT_CONFIG$1,
448
+ ...config
449
+ };
450
+ }
557
451
  /**
558
- * Sign-up flow completed successfully.
559
- *
560
- * The user has successfully registered and the flow can proceed to
561
- * OAuth2 completion or redirection. Check for redirectUrl or assertion
562
- * data in the response for next steps.
452
+ * Update logger configuration
563
453
  */
564
- EmbeddedSignUpFlowStatus$1["Complete"] = "COMPLETE";
454
+ configure(config) {
455
+ this.config = {
456
+ ...this.config,
457
+ ...config
458
+ };
459
+ }
565
460
  /**
566
- * Sign-up flow encountered an error and cannot proceed.
567
- *
568
- * Registration failed due to validation errors, duplicate user,
569
- * system errors, or other issues. The response will be of type
570
- * `EmbeddedSignUpFlowErrorResponse` containing detailed failure
571
- * information that can be displayed to the user.
572
- *
573
- * @see {@link EmbeddedSignUpFlowErrorResponse} for error response structure
461
+ * Get current configuration
574
462
  */
575
- EmbeddedSignUpFlowStatus$1["Error"] = "ERROR";
463
+ getConfig() {
464
+ return { ...this.config };
465
+ }
576
466
  /**
577
- * Sign-up flow requires additional user input.
578
- *
579
- * More registration steps are needed. The response will contain
580
- * components in data.meta.components that should be rendered to
581
- * collect additional user information (e.g., profile data, verification).
467
+ * Check if a log level should be output
582
468
  */
583
- EmbeddedSignUpFlowStatus$1["Incomplete"] = "INCOMPLETE";
584
- return EmbeddedSignUpFlowStatus$1;
585
- }({});
586
- /**
587
- * Type enumeration for ThunderID embedded sign-up flow responses.
588
- *
589
- * Determines the nature of the registration flow response and how the client
590
- * should handle the returned data. This affects both UI rendering and flow
591
- * continuation logic during the user registration process.
592
- *
593
- * @experimental Part of the new ThunderID API
594
- */
595
- let EmbeddedSignUpFlowType = /* @__PURE__ */ function(EmbeddedSignUpFlowType$1) {
469
+ shouldLog(level) {
470
+ return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[this.config.level];
471
+ }
596
472
  /**
597
- * Response requires external redirection.
598
- *
599
- * Used for social registration providers, external identity providers,
600
- * or other flows that require navigating to an external URL during
601
- * the registration process. The response will contain redirection information.
473
+ * Get timestamp string
602
474
  */
603
- EmbeddedSignUpFlowType$1["Redirection"] = "REDIRECTION";
475
+ static getTimestamp() {
476
+ return (/* @__PURE__ */ new Date()).toISOString();
477
+ }
604
478
  /**
605
- * Response contains view components for rendering.
606
- *
607
- * Standard embedded registration flow response containing UI components
608
- * that should be rendered within the current application context.
609
- * Most common type for embedded user registration.
479
+ * Get log level string
610
480
  */
611
- EmbeddedSignUpFlowType$1["View"] = "VIEW";
612
- return EmbeddedSignUpFlowType$1;
613
- }({});
614
-
615
- //#endregion
616
- //#region src/api/executeEmbeddedSignUpFlow.ts
617
- const executeEmbeddedSignUpFlow = async ({ url, baseUrl, payload, authId,...requestConfig }) => {
618
- if (!payload) throw new ThunderIDAPIError("Registration payload is required", "executeEmbeddedSignUpFlow-ValidationError-002", "javascript", 400, "If a registration payload is not provided, the request cannot be constructed correctly.");
619
- const endpoint = url ?? `${baseUrl}/flow/execute`;
620
- const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
621
- const isNewFlowStart = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload;
622
- const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
623
- const basePayload = isNewFlowStart ? injectRequestedPermissions_default(cleanPayload) : cleanPayload;
624
- const requestPayload = isNewFlowStart || hasOnlyFlowId ? {
625
- ...basePayload,
626
- verbose: true
627
- } : basePayload;
628
- const response = await fetch(endpoint, {
629
- ...requestConfig,
630
- body: JSON.stringify(requestPayload),
631
- headers: {
632
- Accept: "application/json",
633
- "Content-Type": "application/json",
634
- ...requestConfig.headers
635
- },
636
- method: requestConfig.method || "POST"
637
- });
638
- if (!response.ok) throw new ThunderIDAPIError(await response.text(), "executeEmbeddedSignUpFlow-ResponseError-001", "javascript", response.status, response.statusText, "Registration request failed");
639
- const flowResponse = await response.json();
640
- if (flowResponse.flowStatus === EmbeddedSignUpFlowStatus.Complete && flowResponse.assertion && authId) try {
641
- const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
642
- body: JSON.stringify({
643
- assertion: flowResponse.assertion,
481
+ static getLevelString(level) {
482
+ switch (level) {
483
+ case "debug": return "DEBUG";
484
+ case "info": return "INFO";
485
+ case "warn": return "WARN";
486
+ case "error": return "ERROR";
487
+ default: return "UNKNOWN";
488
+ }
489
+ }
490
+ /**
491
+ * Format message for Node.js terminal
492
+ */
493
+ formatForNode(level, message) {
494
+ const parts = [];
495
+ if (this.config.timestamps) parts.push(`${COLORS.gray}[${Logger.getTimestamp()}]${COLORS.reset}`);
496
+ if (this.config.prefix) parts.push(`${COLORS.magenta}${this.config.prefix}${COLORS.reset}`);
497
+ if (this.config.showLevel) {
498
+ const levelStr = Logger.getLevelString(level);
499
+ let coloredLevel;
500
+ switch (level) {
501
+ case "debug":
502
+ coloredLevel = `${COLORS.gray}[${levelStr}]${COLORS.reset}`;
503
+ break;
504
+ case "info":
505
+ coloredLevel = `${COLORS.blue}[${levelStr}]${COLORS.reset}`;
506
+ break;
507
+ case "warn":
508
+ coloredLevel = `${COLORS.yellow}[${levelStr}]${COLORS.reset}`;
509
+ break;
510
+ case "error":
511
+ coloredLevel = `${COLORS.red}[${levelStr}]${COLORS.reset}`;
512
+ break;
513
+ default: coloredLevel = `[${levelStr}]`;
514
+ }
515
+ parts.push(coloredLevel);
516
+ }
517
+ parts.push(message);
518
+ return parts.join(" ");
519
+ }
520
+ /**
521
+ * Log message using appropriate method
522
+ */
523
+ logMessage(level, message, ...args) {
524
+ if (!this.shouldLog(level)) return;
525
+ if (this.config.formatter) {
526
+ this.config.formatter(level, message, ...args);
527
+ return;
528
+ }
529
+ if (isBrowser()) this.logToBrowser(level, message, ...args);
530
+ else if (isNode()) this.logToNode(level, message, ...args);
531
+ else console.log(message, ...args);
532
+ }
533
+ /**
534
+ * Log to browser console with styling
535
+ */
536
+ logToBrowser(level, message, ...args) {
537
+ const parts = [];
538
+ const styles = [];
539
+ if (this.config.timestamps) {
540
+ parts.push(`%c[${Logger.getTimestamp()}]`);
541
+ styles.push(BROWSER_STYLES.timestamp);
542
+ }
543
+ if (this.config.prefix) {
544
+ parts.push(`%c${this.config.prefix}`);
545
+ styles.push(BROWSER_STYLES.prefix);
546
+ }
547
+ if (this.config.showLevel) {
548
+ const levelStr = Logger.getLevelString(level);
549
+ parts.push(`%c[${levelStr}]`);
550
+ switch (level) {
551
+ case "debug":
552
+ styles.push(BROWSER_STYLES.debug);
553
+ break;
554
+ case "info":
555
+ styles.push(BROWSER_STYLES.info);
556
+ break;
557
+ case "warn":
558
+ styles.push(BROWSER_STYLES.warn);
559
+ break;
560
+ case "error":
561
+ styles.push(BROWSER_STYLES.error);
562
+ break;
563
+ default: styles.push("");
564
+ }
565
+ }
566
+ parts.push(`%c${message}`);
567
+ styles.push("color: inherit; font-weight: normal;");
568
+ const formattedMessage = parts.join(" ");
569
+ switch (level) {
570
+ case "debug":
571
+ console.debug(formattedMessage, ...styles, ...args);
572
+ break;
573
+ case "info":
574
+ console.info(formattedMessage, ...styles, ...args);
575
+ break;
576
+ case "warn":
577
+ console.warn(formattedMessage, ...styles, ...args);
578
+ break;
579
+ case "error":
580
+ console.error(formattedMessage, ...styles, ...args);
581
+ break;
582
+ default: console.log(formattedMessage, ...styles, ...args);
583
+ }
584
+ }
585
+ /**
586
+ * Log to Node.js console
587
+ */
588
+ logToNode(level, message, ...args) {
589
+ const formattedMessage = this.formatForNode(level, message);
590
+ switch (level) {
591
+ case "debug":
592
+ console.debug(formattedMessage, ...args);
593
+ break;
594
+ case "info":
595
+ console.info(formattedMessage, ...args);
596
+ break;
597
+ case "warn":
598
+ console.warn(formattedMessage, ...args);
599
+ break;
600
+ case "error":
601
+ console.error(formattedMessage, ...args);
602
+ break;
603
+ default: console.log(formattedMessage, ...args);
604
+ }
605
+ }
606
+ /**
607
+ * Log debug message
608
+ */
609
+ debug(message, ...args) {
610
+ this.logMessage("debug", message, ...args);
611
+ }
612
+ /**
613
+ * Log info message
614
+ */
615
+ info(message, ...args) {
616
+ this.logMessage("info", message, ...args);
617
+ }
618
+ /**
619
+ * Log warning message
620
+ */
621
+ warn(message, ...args) {
622
+ this.logMessage("warn", message, ...args);
623
+ }
624
+ /**
625
+ * Log error message
626
+ */
627
+ error(message, ...args) {
628
+ this.logMessage("error", message, ...args);
629
+ }
630
+ /**
631
+ * Create a child logger with additional prefix
632
+ */
633
+ child(prefix) {
634
+ const childPrefix = this.config.prefix ? `${this.config.prefix} - ${prefix}` : prefix;
635
+ return new Logger({
636
+ ...this.config,
637
+ prefix: childPrefix
638
+ });
639
+ }
640
+ /**
641
+ * Set log level
642
+ */
643
+ setLevel(level) {
644
+ this.config.level = level;
645
+ }
646
+ /**
647
+ * Get current log level
648
+ */
649
+ getLevel() {
650
+ return this.config.level;
651
+ }
652
+ };
653
+ /**
654
+ * Default logger instance
655
+ */
656
+ const logger = new Logger();
657
+ /**
658
+ * Create a new logger instance with custom configuration
659
+ */
660
+ const createLogger = (config) => new Logger(config);
661
+ /**
662
+ * Default export - global logger instance
663
+ */
664
+ var logger_default = logger;
665
+ /**
666
+ * Named exports for convenience
667
+ */
668
+ const debug = (message, ...args) => logger.debug(message, ...args);
669
+ const info = (message, ...args) => logger.info(message, ...args);
670
+ const warn = (message, ...args) => logger.warn(message, ...args);
671
+ const error = (message, ...args) => logger.error(message, ...args);
672
+ /**
673
+ * Configure the default logger
674
+ */
675
+ const configure = (config) => logger.configure(config);
676
+ /**
677
+ * Create component-specific loggers
678
+ */
679
+ const createComponentLogger = (component) => logger.child(component);
680
+ /**
681
+ * Create package-specific logger
682
+ */
683
+ const createPackageLogger = (packageName) => createLogger({
684
+ level: "info",
685
+ prefix: `${PREFIX} - ${packageName}`,
686
+ showLevel: true,
687
+ timestamps: true
688
+ });
689
+ /**
690
+ * Create package component logger (package + component)
691
+ */
692
+ const createPackageComponentLogger = (packageName, component) => {
693
+ return createPackageLogger(packageName).child(component);
694
+ };
695
+
696
+ //#endregion
697
+ //#region src/api/executeEmbeddedSignInFlow.ts
698
+ const readErrorAssertion = (body) => {
699
+ try {
700
+ return JSON.parse(body).errorAssertion;
701
+ } catch {
702
+ return;
703
+ }
704
+ };
705
+ const postAuthCallback = async (baseUrl, body, headers) => {
706
+ const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
707
+ body: JSON.stringify(body),
708
+ credentials: "include",
709
+ headers: {
710
+ Accept: "application/json",
711
+ "Content-Type": "application/json",
712
+ ...headers
713
+ },
714
+ method: "POST"
715
+ });
716
+ if (!oauth2Response.ok) {
717
+ const oauth2ErrorText = await oauth2Response.text();
718
+ logger_default.error(`OAuth2 authorization failed. The callback responded ${oauth2Response.status} ${oauth2Response.statusText}:`, oauth2ErrorText);
719
+ throw new ThunderIDAPIError("OAuth2 authorization failed", "executeEmbeddedSignInFlow-OAuth2Error-002", "javascript", oauth2Response.status, oauth2Response.statusText);
720
+ }
721
+ return oauth2Response.json();
722
+ };
723
+ const relayFailure = async (baseUrl, authId, errorAssertion, headers, flowResponse) => {
724
+ const oauth2Result = await postAuthCallback(baseUrl, {
725
+ assertion: errorAssertion,
726
+ authId
727
+ }, headers);
728
+ return {
729
+ ...flowResponse,
730
+ flowStatus: EmbeddedSignInFlowStatus.Error,
731
+ redirectUrl: oauth2Result["redirect_uri"]
732
+ };
733
+ };
734
+ const executeEmbeddedSignInFlow = async ({ url, baseUrl, payload, authId, flowSecret,...requestConfig }) => {
735
+ if (!payload) throw new ThunderIDAPIError("Authorization payload is required", "executeEmbeddedSignInFlow-ValidationError-002", "javascript", 400, "If an authorization payload is not provided, the request cannot be constructed correctly.");
736
+ const endpoint = url ?? `${baseUrl}/flow/execute`;
737
+ const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
738
+ const isNewFlowStart = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload;
739
+ const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
740
+ const basePayload = isNewFlowStart ? injectRequestedPermissions_default(cleanPayload) : cleanPayload;
741
+ const requestPayload = isNewFlowStart || hasOnlyFlowId ? {
742
+ ...basePayload,
743
+ verbose: true
744
+ } : basePayload;
745
+ const response = await fetch(endpoint, {
746
+ ...requestConfig,
747
+ body: JSON.stringify(requestPayload),
748
+ headers: {
749
+ Accept: "application/json",
750
+ "Content-Type": "application/json",
751
+ ...isNewFlowStart && flowSecret ? { "Flow-Secret": flowSecret } : {},
752
+ ...requestConfig.headers
753
+ },
754
+ method: requestConfig.method || "POST"
755
+ });
756
+ if (!response.ok) {
757
+ const errorText = await response.text();
758
+ const errorAssertion = readErrorAssertion(errorText);
759
+ if (authId && errorAssertion) return await relayFailure(baseUrl, authId, errorAssertion, requestConfig.headers);
760
+ throw new ThunderIDAPIError(errorText, "executeEmbeddedSignInFlow-ResponseError-001", "javascript", response.status, response.statusText, "Authorization request failed");
761
+ }
762
+ const flowResponse = await response.json();
763
+ if (flowResponse.flowStatus === EmbeddedSignInFlowStatus.Complete && flowResponse.assertion && authId) try {
764
+ const oauth2Result = await postAuthCallback(baseUrl, {
765
+ assertion: flowResponse.assertion,
766
+ authId
767
+ }, requestConfig.headers);
768
+ return {
769
+ flowStatus: flowResponse.flowStatus,
770
+ redirectUrl: oauth2Result["redirect_uri"]
771
+ };
772
+ } catch (authError) {
773
+ if (authError instanceof ThunderIDAPIError) throw authError;
774
+ throw new ThunderIDAPIError(authError instanceof Error ? authError.message : "Unknown error", "executeEmbeddedSignInFlow-OAuth2Error-001", "javascript", 500, "Failed to complete OAuth2 authorization after successful embedded sign-in flow.", "OAuth2 authorization failed");
775
+ }
776
+ if (flowResponse.flowStatus === EmbeddedSignInFlowStatus.Error && flowResponse.errorAssertion && authId) return relayFailure(baseUrl, authId, flowResponse.errorAssertion, requestConfig.headers, flowResponse);
777
+ return flowResponse;
778
+ };
779
+ var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
780
+
781
+ //#endregion
782
+ //#region src/models/embedded-signup-flow.ts
783
+ /**
784
+ * Status enumeration for ThunderID embedded sign-up flow operations.
785
+ *
786
+ * These statuses indicate the current state of the registration flow and determine
787
+ * the next action required by the client application. Each status provides specific
788
+ * guidance on how to proceed with the user registration process.
789
+ *
790
+ * @example
791
+ * ```typescript
792
+ * switch (response.flowStatus) {
793
+ * case EmbeddedSignUpFlowStatus.Incomplete:
794
+ * // More user input needed - render registration form components
795
+ * break;
796
+ * case EmbeddedSignUpFlowStatus.Complete:
797
+ * // Registration successful - handle completion
798
+ * break;
799
+ * case EmbeddedSignUpFlowStatus.Error:
800
+ * // Registration failed - show error details
801
+ * const errorResponse = response as EmbeddedSignUpFlowErrorResponse;
802
+ * showError(errorResponse.error.description.defaultValue);
803
+ * break;
804
+ * }
805
+ * ```
806
+ *
807
+ * @experimental Part of the new ThunderID API
808
+ */
809
+ let EmbeddedSignUpFlowStatus = /* @__PURE__ */ function(EmbeddedSignUpFlowStatus$1) {
810
+ /**
811
+ * Sign-up flow completed successfully.
812
+ *
813
+ * The user has successfully registered and the flow can proceed to
814
+ * OAuth2 completion or redirection. Check for redirectUrl or assertion
815
+ * data in the response for next steps.
816
+ */
817
+ EmbeddedSignUpFlowStatus$1["Complete"] = "COMPLETE";
818
+ /**
819
+ * Sign-up flow encountered an error and cannot proceed.
820
+ *
821
+ * Registration failed due to validation errors, duplicate user,
822
+ * system errors, or other issues. The response will be of type
823
+ * `EmbeddedSignUpFlowErrorResponse` containing detailed failure
824
+ * information that can be displayed to the user.
825
+ *
826
+ * @see {@link EmbeddedSignUpFlowErrorResponse} for error response structure
827
+ */
828
+ EmbeddedSignUpFlowStatus$1["Error"] = "ERROR";
829
+ /**
830
+ * Sign-up flow requires additional user input.
831
+ *
832
+ * More registration steps are needed. The response will contain
833
+ * components in data.meta.components that should be rendered to
834
+ * collect additional user information (e.g., profile data, verification).
835
+ */
836
+ EmbeddedSignUpFlowStatus$1["Incomplete"] = "INCOMPLETE";
837
+ return EmbeddedSignUpFlowStatus$1;
838
+ }({});
839
+ /**
840
+ * Type enumeration for ThunderID embedded sign-up flow responses.
841
+ *
842
+ * Determines the nature of the registration flow response and how the client
843
+ * should handle the returned data. This affects both UI rendering and flow
844
+ * continuation logic during the user registration process.
845
+ *
846
+ * @experimental Part of the new ThunderID API
847
+ */
848
+ let EmbeddedSignUpFlowType = /* @__PURE__ */ function(EmbeddedSignUpFlowType$1) {
849
+ /**
850
+ * Response requires external redirection.
851
+ *
852
+ * Used for social registration providers, external identity providers,
853
+ * or other flows that require navigating to an external URL during
854
+ * the registration process. The response will contain redirection information.
855
+ */
856
+ EmbeddedSignUpFlowType$1["Redirection"] = "REDIRECTION";
857
+ /**
858
+ * Response contains view components for rendering.
859
+ *
860
+ * Standard embedded registration flow response containing UI components
861
+ * that should be rendered within the current application context.
862
+ * Most common type for embedded user registration.
863
+ */
864
+ EmbeddedSignUpFlowType$1["View"] = "VIEW";
865
+ return EmbeddedSignUpFlowType$1;
866
+ }({});
867
+
868
+ //#endregion
869
+ //#region src/api/executeEmbeddedSignUpFlow.ts
870
+ const executeEmbeddedSignUpFlow = async ({ url, baseUrl, payload, authId,...requestConfig }) => {
871
+ if (!payload) throw new ThunderIDAPIError("Registration payload is required", "executeEmbeddedSignUpFlow-ValidationError-002", "javascript", 400, "If a registration payload is not provided, the request cannot be constructed correctly.");
872
+ const endpoint = url ?? `${baseUrl}/flow/execute`;
873
+ const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
874
+ const isNewFlowStart = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload;
875
+ const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
876
+ const basePayload = isNewFlowStart ? injectRequestedPermissions_default(cleanPayload) : cleanPayload;
877
+ const requestPayload = isNewFlowStart || hasOnlyFlowId ? {
878
+ ...basePayload,
879
+ verbose: true
880
+ } : basePayload;
881
+ const response = await fetch(endpoint, {
882
+ ...requestConfig,
883
+ body: JSON.stringify(requestPayload),
884
+ headers: {
885
+ Accept: "application/json",
886
+ "Content-Type": "application/json",
887
+ ...requestConfig.headers
888
+ },
889
+ method: requestConfig.method || "POST"
890
+ });
891
+ if (!response.ok) throw new ThunderIDAPIError(await response.text(), "executeEmbeddedSignUpFlow-ResponseError-001", "javascript", response.status, response.statusText, "Registration request failed");
892
+ const flowResponse = await response.json();
893
+ if (flowResponse.flowStatus === EmbeddedSignUpFlowStatus.Complete && flowResponse.assertion && authId) try {
894
+ const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
895
+ body: JSON.stringify({
896
+ assertion: flowResponse.assertion,
644
897
  authId
645
898
  }),
646
899
  credentials: "include",
@@ -729,23 +982,6 @@ var executeEmbeddedRecoveryFlow_default = executeEmbeddedRecoveryFlow;
729
982
 
730
983
  //#endregion
731
984
  //#region src/models/embedded-flow.ts
732
- /**
733
- * Copyright (c) 2025-2026, WSO2 LLC. (https://www.wso2.com).
734
- *
735
- * WSO2 LLC. licenses this file to you under the Apache License,
736
- * Version 2.0 (the "License"); you may not use this file except
737
- * in compliance with the License.
738
- * You may obtain a copy of the License at
739
- *
740
- * http://www.apache.org/licenses/LICENSE-2.0
741
- *
742
- * Unless required by applicable law or agreed to in writing,
743
- * software distributed under the License is distributed on an
744
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
745
- * KIND, either express or implied. See the License for the
746
- * specific language governing permissions and limitations
747
- * under the License.
748
- */
749
985
  let EmbeddedFlowType = /* @__PURE__ */ function(EmbeddedFlowType$1) {
750
986
  EmbeddedFlowType$1["Authentication"] = "AUTHENTICATION";
751
987
  EmbeddedFlowType$1["Recovery"] = "RECOVERY";
@@ -1110,23 +1346,6 @@ var getUserInfo_default = getUserInfo;
1110
1346
  //#endregion
1111
1347
  //#region src/utils/processUsername.ts
1112
1348
  /**
1113
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1114
- *
1115
- * WSO2 LLC. licenses this file to you under the Apache License,
1116
- * Version 2.0 (the "License"); you may not use this file except
1117
- * in compliance with the License.
1118
- * You may obtain a copy of the License at
1119
- *
1120
- * http://www.apache.org/licenses/LICENSE-2.0
1121
- *
1122
- * Unless required by applicable law or agreed to in writing,
1123
- * software distributed under the License is distributed on an
1124
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1125
- * KIND, either express or implied. See the License for the
1126
- * specific language governing permissions and limitations
1127
- * under the License.
1128
- */
1129
- /**
1130
1349
  * Regular expression to match userstore prefixes in usernames.
1131
1350
  * Matches patterns like "DEFAULT/", "ASGARDEO_USER/", "PRIMARY/", etc.
1132
1351
  * The pattern matches any uppercase letters, numbers, and underscores followed by a forward slash.
@@ -1361,23 +1580,6 @@ var updateMeProfile_default = updateMeProfile;
1361
1580
  //#endregion
1362
1581
  //#region src/constants/ApplicationNativeAuthenticationConstants.ts
1363
1582
  /**
1364
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1365
- *
1366
- * WSO2 LLC. licenses this file to you under the Apache License,
1367
- * Version 2.0 (the "License"); you may not use this file except
1368
- * in compliance with the License.
1369
- * You may obtain a copy of the License at
1370
- *
1371
- * http://www.apache.org/licenses/LICENSE-2.0
1372
- *
1373
- * Unless required by applicable law or agreed to in writing,
1374
- * software distributed under the License is distributed on an
1375
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1376
- * KIND, either express or implied. See the License for the
1377
- * specific language governing permissions and limitations
1378
- * under the License.
1379
- */
1380
- /**
1381
1583
  * Constants representing Application Native Authentication related configurations and constants.
1382
1584
  */
1383
1585
  const ApplicationNativeAuthenticationConstants = { SupportedAuthenticators: {
@@ -1401,23 +1603,6 @@ var ApplicationNativeAuthenticationConstants_default = ApplicationNativeAuthenti
1401
1603
  //#endregion
1402
1604
  //#region src/constants/ScopeConstants.ts
1403
1605
  /**
1404
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1405
- *
1406
- * WSO2 LLC. licenses this file to you under the Apache License,
1407
- * Version 2.0 (the "License"); you may not use this file except
1408
- * in compliance with the License.
1409
- * You may obtain a copy of the License at
1410
- *
1411
- * http://www.apache.org/licenses/LICENSE-2.0
1412
- *
1413
- * Unless required by applicable law or agreed to in writing,
1414
- * software distributed under the License is distributed on an
1415
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1416
- * KIND, either express or implied. See the License for the
1417
- * specific language governing permissions and limitations
1418
- * under the License.
1419
- */
1420
- /**
1421
1606
  * Constants for OAuth 2.0 and OpenID Connect scopes.
1422
1607
  * These scopes define the level of access that the client application
1423
1608
  * is requesting from the authorization server.
@@ -1463,23 +1648,6 @@ var OIDCRequestConstants_default = OIDCRequestConstants;
1463
1648
  //#endregion
1464
1649
  //#region src/constants/VendorConstants.ts
1465
1650
  /**
1466
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1467
- *
1468
- * WSO2 LLC. licenses this file to you under the Apache License,
1469
- * Version 2.0 (the "License"); you may not use this file except
1470
- * in compliance with the License.
1471
- * You may obtain a copy of the License at
1472
- *
1473
- * http://www.apache.org/licenses/LICENSE-2.0
1474
- *
1475
- * Unless required by applicable law or agreed to in writing,
1476
- * software distributed under the License is distributed on an
1477
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1478
- * KIND, either express or implied. See the License for the
1479
- * specific language governing permissions and limitations
1480
- * under the License.
1481
- */
1482
- /**
1483
1651
  * Constants for vendor-specific configurations.
1484
1652
  * By default, the vendor is inferred as ThunderID.
1485
1653
  *
@@ -1581,23 +1749,6 @@ let EmbeddedRecoveryFlowType = /* @__PURE__ */ function(EmbeddedRecoveryFlowType
1581
1749
  //#endregion
1582
1750
  //#region src/models/flow-meta.ts
1583
1751
  /**
1584
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
1585
- *
1586
- * WSO2 LLC. licenses this file to you under the Apache License,
1587
- * Version 2.0 (the "License"); you may not use this file except
1588
- * in compliance with the License.
1589
- * You may obtain a copy of the License at
1590
- *
1591
- * http://www.apache.org/licenses/LICENSE-2.0
1592
- *
1593
- * Unless required by applicable law or agreed to in writing,
1594
- * software distributed under the License is distributed on an
1595
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1596
- * KIND, either express or implied. See the License for the
1597
- * specific language governing permissions and limitations
1598
- * under the License.
1599
- */
1600
- /**
1601
1752
  * The type of entity to retrieve flow metadata for.
1602
1753
  *
1603
1754
  * @example
@@ -1621,33 +1772,15 @@ let FlowMetaType = /* @__PURE__ */ function(FlowMetaType$1) {
1621
1772
 
1622
1773
  //#endregion
1623
1774
  //#region src/models/flow.ts
1624
- /**
1625
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1626
- *
1627
- * WSO2 LLC. licenses this file to you under the Apache License,
1628
- * Version 2.0 (the "License"); you may not use this file except
1629
- * in compliance with the License.
1630
- * You may obtain a copy of the License at
1631
- *
1632
- * http://www.apache.org/licenses/LICENSE-2.0
1633
- *
1634
- * Unless required by applicable law or agreed to in writing,
1635
- * software distributed under the License is distributed on an
1636
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1637
- * KIND, either express or implied. See the License for the
1638
- * specific language governing permissions and limitations
1639
- * under the License.
1640
- */
1641
1775
  let FlowMode = /* @__PURE__ */ function(FlowMode$1) {
1642
1776
  /**
1643
1777
  * This mode is suitable for embedded sign-in, sign-up, etc. flows where the authentication
1644
1778
  * UIs are rendered within the application.
1645
- * @see {@link https://is.docs.wso2.com/en/7.1.0/references/app-native-authentication/}
1646
1779
  */
1647
1780
  FlowMode$1["Embedded"] = "DIRECT";
1648
1781
  /**
1649
1782
  * Traditional redirect based sign-in, sign-up, etc. flows where the authentication
1650
- * UIs are from a external Identity Provider (ex: WSO2 Identity Server or ThunderID).
1783
+ * UIs are from a external Identity Provider (ex: ThunderID).
1651
1784
  */
1652
1785
  FlowMode$1["Redirect"] = "REDIRECTION";
1653
1786
  return FlowMode$1;
@@ -1655,23 +1788,6 @@ let FlowMode = /* @__PURE__ */ function(FlowMode$1) {
1655
1788
 
1656
1789
  //#endregion
1657
1790
  //#region src/models/field.ts
1658
- /**
1659
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1660
- *
1661
- * WSO2 LLC. licenses this file to you under the Apache License,
1662
- * Version 2.0 (the "License"); you may not use this file except
1663
- * in compliance with the License.
1664
- * You may obtain a copy of the License at
1665
- *
1666
- * http://www.apache.org/licenses/LICENSE-2.0
1667
- *
1668
- * Unless required by applicable law or agreed to in writing,
1669
- * software distributed under the License is distributed on an
1670
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1671
- * KIND, either express or implied. See the License for the
1672
- * specific language governing permissions and limitations
1673
- * under the License.
1674
- */
1675
1791
  let FieldType = /* @__PURE__ */ function(FieldType$1) {
1676
1792
  FieldType$1["Checkbox"] = "CHECKBOX";
1677
1793
  FieldType$1["Date"] = "DATE";
@@ -1691,23 +1807,6 @@ let FieldType = /* @__PURE__ */ function(FieldType$1) {
1691
1807
  //#endregion
1692
1808
  //#region src/constants/OIDCDiscoveryConstants.ts
1693
1809
  /**
1694
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1695
- *
1696
- * WSO2 LLC. licenses this file to you under the Apache License,
1697
- * Version 2.0 (the "License"); you may not use this file except
1698
- * in compliance with the License.
1699
- * You may obtain a copy of the License at
1700
- *
1701
- * http://www.apache.org/licenses/LICENSE-2.0
1702
- *
1703
- * Unless required by applicable law or agreed to in writing,
1704
- * software distributed under the License is distributed on an
1705
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1706
- * KIND, either express or implied. See the License for the
1707
- * specific language governing permissions and limitations
1708
- * under the License.
1709
- */
1710
- /**
1711
1810
  * Constants related to OpenID Connect (OIDC) metadata and endpoints.
1712
1811
  * This object contains all the standard OIDC endpoints and storage keys
1713
1812
  * used throughout the application for authentication and authorization.
@@ -1719,511 +1818,171 @@ let FieldType = /* @__PURE__ */ function(FieldType$1) {
1719
1818
  *
1720
1819
  * @example
1721
1820
  * ```typescript
1722
- * // Using an endpoint
1723
- * const authEndpoint = OIDCDiscoveryConstants.Endpoints.AUTHORIZATION;
1724
- *
1725
- * // Using a storage key
1726
- * const tokenKey = OIDCDiscoveryConstants.Storage.StorageKeys.Endpoints.TOKEN;
1727
- * ```
1728
- */
1729
- const OIDCDiscoveryConstants = {
1730
- Endpoints: {
1731
- AUTHORIZATION: "/oauth2/authorize",
1732
- END_SESSION: "/oauth2/logout",
1733
- ISSUER: "/oauth2/token",
1734
- JWKS: "/oauth2/jwks",
1735
- REVOCATION: "/oauth2/revoke",
1736
- SESSION_IFRAME: "/oidc/checksession",
1737
- TOKEN: "/oauth2/token",
1738
- USERINFO: "/oauth2/userinfo"
1739
- },
1740
- Storage: { StorageKeys: {
1741
- Endpoints: {
1742
- AUTHORIZATION: "authorization_endpoint",
1743
- END_SESSION: "end_session_endpoint",
1744
- ISSUER: "issuer",
1745
- JWKS: "jwks_uri",
1746
- REVOCATION: "revocation_endpoint",
1747
- SESSION_IFRAME: "check_session_iframe",
1748
- TOKEN: "token_endpoint",
1749
- USERINFO: "userinfo_endpoint"
1750
- },
1751
- OPENID_PROVIDER_CONFIG_INITIATED: "op_config_initiated"
1752
- } }
1753
- };
1754
- var OIDCDiscoveryConstants_default = OIDCDiscoveryConstants;
1755
-
1756
- //#endregion
1757
- //#region src/constants/PKCEConstants.ts
1758
- /**
1759
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1760
- *
1761
- * WSO2 LLC. licenses this file to you under the Apache License,
1762
- * Version 2.0 (the "License"); you may not use this file except
1763
- * in compliance with the License.
1764
- * You may obtain a copy of the License at
1765
- *
1766
- * http://www.apache.org/licenses/LICENSE-2.0
1767
- *
1768
- * Unless required by applicable law or agreed to in writing,
1769
- * software distributed under the License is distributed on an
1770
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1771
- * KIND, either express or implied. See the License for the
1772
- * specific language governing permissions and limitations
1773
- * under the License.
1774
- */
1775
- /**
1776
- * Constants related to Proof Key for Code Exchange (PKCE) implementation.
1777
- * This object contains all the necessary constants for implementing PKCE
1778
- * flow in the OAuth 2.0 authorization code grant.
1779
- *
1780
- * @remarks
1781
- * PKCE is an extension to the authorization code flow to prevent CSRF and
1782
- * authorization code injection attacks. The constants are organized into
1783
- * storage-related sections for managing PKCE state.
1784
- *
1785
- * @example
1786
- * ```typescript
1787
- * // Using storage keys
1788
- * const codeVerifierKey = PKCEConstants.Storage.StorageKeys.CODE_VERIFIER;
1789
- * const separator = PKCEConstants.Storage.StorageKeys.SEPARATOR;
1790
- * ```
1791
- */
1792
- const PKCEConstants = {
1793
- DEFAULT_CODE_CHALLENGE_METHOD: "S256",
1794
- Storage: { StorageKeys: {
1795
- CODE_VERIFIER: "pkce_code_verifier",
1796
- SEPARATOR: "#"
1797
- } }
1798
- };
1799
- var PKCEConstants_default = PKCEConstants;
1800
-
1801
- //#endregion
1802
- //#region src/DefaultCacheStore.ts
1803
- /**
1804
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
1805
- *
1806
- * WSO2 LLC. licenses this file to you under the Apache License,
1807
- * Version 2.0 (the "License"); you may not use this file except
1808
- * in compliance with the License.
1809
- * You may obtain a copy of the License at
1810
- *
1811
- * http://www.apache.org/licenses/LICENSE-2.0
1812
- *
1813
- * Unless required by applicable law or agreed to in writing,
1814
- * software distributed under the License is distributed on an
1815
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1816
- * KIND, either express or implied. See the License for the
1817
- * specific language governing permissions and limitations
1818
- * under the License.
1819
- */
1820
- var DefaultCacheStore = class {
1821
- cache;
1822
- constructor() {
1823
- this.cache = /* @__PURE__ */ new Map();
1824
- }
1825
- get length() {
1826
- return this.cache.size;
1827
- }
1828
- getItem(key) {
1829
- return this.cache.get(key) ?? null;
1830
- }
1831
- setItem(key, value) {
1832
- this.cache.set(key, value);
1833
- }
1834
- removeItem(key) {
1835
- this.cache.delete(key);
1836
- }
1837
- clear() {
1838
- this.cache.clear();
1839
- }
1840
- key(index) {
1841
- return Array.from(this.cache.keys())[index] ?? null;
1842
- }
1843
- async setData(key, value) {
1844
- this.cache.set(key, value);
1845
- }
1846
- async getData(key) {
1847
- return this.cache.get(key) ?? "{}";
1848
- }
1849
- async removeData(key) {
1850
- this.cache.delete(key);
1851
- }
1852
- };
1853
-
1854
- //#endregion
1855
- //#region src/DefaultCrypto.ts
1856
- /**
1857
- * Default implementation of the Crypto interface using the 'jose' library
1858
- * and the native Web Crypto API.
1859
- */
1860
- var DefaultCrypto = class {
1861
- base64URLDecode(value) {
1862
- const decodedArray = jose.base64url.decode(value);
1863
- return new TextDecoder().decode(decodedArray);
1864
- }
1865
- base64URLEncode(value) {
1866
- return jose.base64url.encode(value);
1867
- }
1868
- generateRandomBytes(length) {
1869
- return crypto.getRandomValues(new Uint8Array(length));
1870
- }
1871
- async hashSha256(data) {
1872
- const dataBuffer = new TextEncoder().encode(data);
1873
- const hashBuffer = await crypto.subtle.digest("SHA-256", dataBuffer);
1874
- return new Uint8Array(hashBuffer);
1875
- }
1876
- async verifyJwt(idToken, jwk, algorithms, clientId, issuer, subject, clockTolerance, validateJwtIssuer = true) {
1877
- const key = await jose.importJWK(jwk);
1878
- await jose.jwtVerify(idToken, key, {
1879
- algorithms,
1880
- audience: [clientId],
1881
- clockTolerance,
1882
- issuer: validateJwtIssuer ? issuer : void 0,
1883
- subject
1884
- });
1885
- return true;
1886
- }
1887
- };
1888
-
1889
- //#endregion
1890
- //#region src/models/store.ts
1891
- /**
1892
- * Enum representing different types of data stores used in the application.
1893
- */
1894
- let Stores = /* @__PURE__ */ function(Stores$1) {
1895
- /**
1896
- * Store for configuration data that defines the application's behavior and settings.
1897
- */
1898
- Stores$1["ConfigData"] = "config_data";
1899
- /**
1900
- * Store for OpenID Connect provider metadata, including endpoints and configuration.
1901
- */
1902
- Stores$1["OIDCProviderMetaData"] = "oidc_provider_meta_data";
1903
- /**
1904
- * Store for persisted data that needs to be retained across sessions and application restarts.
1905
- */
1906
- Stores$1["PersistedData"] = "persisted_data";
1907
- /**
1908
- * Store for user session-related data like tokens and authentication state.
1909
- */
1910
- Stores$1["SessionData"] = "session_data";
1911
- /**
1912
- * Store for temporary data that needs to persist only for a short duration.
1913
- */
1914
- Stores$1["TemporaryData"] = "temporary_data";
1915
- /**
1916
- * Store for data that leverages local storage if available, falling back to the configured storage.
1917
- */
1918
- Stores$1["HybridData"] = "hybrid_data";
1919
- return Stores$1;
1920
- }({});
1921
-
1922
- //#endregion
1923
- //#region src/utils/logger.ts
1924
- const PREFIX = "⚡ ThunderID";
1925
- /**
1926
- * Default logger configuration
1927
- */
1928
- const DEFAULT_CONFIG$1 = {
1929
- level: "info",
1930
- prefix: `${PREFIX}`,
1931
- showLevel: true,
1932
- timestamps: true
1933
- };
1934
- /**
1935
- * Environment detection utilities
1936
- */
1937
- const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
1938
- const isNode = () => typeof process !== "undefined" && process.versions && process.versions.node;
1939
- /**
1940
- * Color codes for terminal output (Node.js)
1941
- */
1942
- const COLORS = {
1943
- blue: "\x1B[34m",
1944
- bright: "\x1B[1m",
1945
- cyan: "\x1B[36m",
1946
- dim: "\x1B[2m",
1947
- gray: "\x1B[90m",
1948
- green: "\x1B[32m",
1949
- magenta: "\x1B[35m",
1950
- red: "\x1B[31m",
1951
- reset: "\x1B[0m",
1952
- white: "\x1B[37m",
1953
- yellow: "\x1B[33m"
1954
- };
1955
- /**
1956
- * Browser console styling
1821
+ * // Using an endpoint
1822
+ * const authEndpoint = OIDCDiscoveryConstants.Endpoints.AUTHORIZATION;
1823
+ *
1824
+ * // Using a storage key
1825
+ * const tokenKey = OIDCDiscoveryConstants.Storage.StorageKeys.Endpoints.TOKEN;
1826
+ * ```
1957
1827
  */
1958
- const BROWSER_STYLES = {
1959
- debug: "color: #6b7280; font-weight: normal;",
1960
- error: "color: #dc2626; font-weight: bold;",
1961
- info: "color: #2563eb; font-weight: bold;",
1962
- prefix: "color: #7c3aed; font-weight: bold;",
1963
- timestamp: "color: #6b7280; font-size: 0.9em;",
1964
- warn: "color: #d97706; font-weight: bold;"
1965
- };
1966
- const LOG_LEVEL_ORDER = {
1967
- debug: 0,
1968
- error: 3,
1969
- info: 1,
1970
- warn: 2
1828
+ const OIDCDiscoveryConstants = {
1829
+ Endpoints: {
1830
+ AUTHORIZATION: "/oauth2/authorize",
1831
+ END_SESSION: "/oauth2/logout",
1832
+ ISSUER: "/oauth2/token",
1833
+ JWKS: "/oauth2/jwks",
1834
+ REVOCATION: "/oauth2/revoke",
1835
+ SESSION_IFRAME: "/oidc/checksession",
1836
+ TOKEN: "/oauth2/token",
1837
+ USERINFO: "/oauth2/userinfo"
1838
+ },
1839
+ Storage: { StorageKeys: {
1840
+ Endpoints: {
1841
+ AUTHORIZATION: "authorization_endpoint",
1842
+ END_SESSION: "end_session_endpoint",
1843
+ ISSUER: "issuer",
1844
+ JWKS: "jwks_uri",
1845
+ REVOCATION: "revocation_endpoint",
1846
+ SESSION_IFRAME: "check_session_iframe",
1847
+ TOKEN: "token_endpoint",
1848
+ USERINFO: "userinfo_endpoint"
1849
+ },
1850
+ OPENID_PROVIDER_CONFIG_INITIATED: "op_config_initiated"
1851
+ } }
1971
1852
  };
1853
+ var OIDCDiscoveryConstants_default = OIDCDiscoveryConstants;
1854
+
1855
+ //#endregion
1856
+ //#region src/constants/PKCEConstants.ts
1972
1857
  /**
1973
- * Universal logger class that works in both browser and Node.js environments
1858
+ * Constants related to Proof Key for Code Exchange (PKCE) implementation.
1859
+ * This object contains all the necessary constants for implementing PKCE
1860
+ * flow in the OAuth 2.0 authorization code grant.
1861
+ *
1862
+ * @remarks
1863
+ * PKCE is an extension to the authorization code flow to prevent CSRF and
1864
+ * authorization code injection attacks. The constants are organized into
1865
+ * storage-related sections for managing PKCE state.
1866
+ *
1867
+ * @example
1868
+ * ```typescript
1869
+ * // Using storage keys
1870
+ * const codeVerifierKey = PKCEConstants.Storage.StorageKeys.CODE_VERIFIER;
1871
+ * const separator = PKCEConstants.Storage.StorageKeys.SEPARATOR;
1872
+ * ```
1974
1873
  */
1975
- var Logger = class Logger {
1976
- config;
1977
- constructor(config = {}) {
1978
- this.config = {
1979
- ...DEFAULT_CONFIG$1,
1980
- ...config
1981
- };
1874
+ const PKCEConstants = {
1875
+ DEFAULT_CODE_CHALLENGE_METHOD: "S256",
1876
+ Storage: { StorageKeys: {
1877
+ CODE_VERIFIER: "pkce_code_verifier",
1878
+ SEPARATOR: "#"
1879
+ } }
1880
+ };
1881
+ var PKCEConstants_default = PKCEConstants;
1882
+
1883
+ //#endregion
1884
+ //#region src/DefaultCacheStore.ts
1885
+ var DefaultCacheStore = class {
1886
+ cache;
1887
+ constructor() {
1888
+ this.cache = /* @__PURE__ */ new Map();
1982
1889
  }
1983
- /**
1984
- * Update logger configuration
1985
- */
1986
- configure(config) {
1987
- this.config = {
1988
- ...this.config,
1989
- ...config
1990
- };
1890
+ get length() {
1891
+ return this.cache.size;
1991
1892
  }
1992
- /**
1993
- * Get current configuration
1994
- */
1995
- getConfig() {
1996
- return { ...this.config };
1893
+ getItem(key) {
1894
+ return this.cache.get(key) ?? null;
1997
1895
  }
1998
- /**
1999
- * Check if a log level should be output
2000
- */
2001
- shouldLog(level) {
2002
- return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[this.config.level];
1896
+ setItem(key, value) {
1897
+ this.cache.set(key, value);
2003
1898
  }
2004
- /**
2005
- * Get timestamp string
2006
- */
2007
- static getTimestamp() {
2008
- return (/* @__PURE__ */ new Date()).toISOString();
1899
+ removeItem(key) {
1900
+ this.cache.delete(key);
2009
1901
  }
2010
- /**
2011
- * Get log level string
2012
- */
2013
- static getLevelString(level) {
2014
- switch (level) {
2015
- case "debug": return "DEBUG";
2016
- case "info": return "INFO";
2017
- case "warn": return "WARN";
2018
- case "error": return "ERROR";
2019
- default: return "UNKNOWN";
2020
- }
1902
+ clear() {
1903
+ this.cache.clear();
2021
1904
  }
2022
- /**
2023
- * Format message for Node.js terminal
2024
- */
2025
- formatForNode(level, message) {
2026
- const parts = [];
2027
- if (this.config.timestamps) parts.push(`${COLORS.gray}[${Logger.getTimestamp()}]${COLORS.reset}`);
2028
- if (this.config.prefix) parts.push(`${COLORS.magenta}${this.config.prefix}${COLORS.reset}`);
2029
- if (this.config.showLevel) {
2030
- const levelStr = Logger.getLevelString(level);
2031
- let coloredLevel;
2032
- switch (level) {
2033
- case "debug":
2034
- coloredLevel = `${COLORS.gray}[${levelStr}]${COLORS.reset}`;
2035
- break;
2036
- case "info":
2037
- coloredLevel = `${COLORS.blue}[${levelStr}]${COLORS.reset}`;
2038
- break;
2039
- case "warn":
2040
- coloredLevel = `${COLORS.yellow}[${levelStr}]${COLORS.reset}`;
2041
- break;
2042
- case "error":
2043
- coloredLevel = `${COLORS.red}[${levelStr}]${COLORS.reset}`;
2044
- break;
2045
- default: coloredLevel = `[${levelStr}]`;
2046
- }
2047
- parts.push(coloredLevel);
2048
- }
2049
- parts.push(message);
2050
- return parts.join(" ");
1905
+ key(index) {
1906
+ return Array.from(this.cache.keys())[index] ?? null;
2051
1907
  }
2052
- /**
2053
- * Log message using appropriate method
2054
- */
2055
- logMessage(level, message, ...args) {
2056
- if (!this.shouldLog(level)) return;
2057
- if (this.config.formatter) {
2058
- this.config.formatter(level, message, ...args);
2059
- return;
2060
- }
2061
- if (isBrowser()) this.logToBrowser(level, message, ...args);
2062
- else if (isNode()) this.logToNode(level, message, ...args);
2063
- else console.log(message, ...args);
1908
+ async setData(key, value) {
1909
+ this.cache.set(key, value);
2064
1910
  }
2065
- /**
2066
- * Log to browser console with styling
2067
- */
2068
- logToBrowser(level, message, ...args) {
2069
- const parts = [];
2070
- const styles = [];
2071
- if (this.config.timestamps) {
2072
- parts.push(`%c[${Logger.getTimestamp()}]`);
2073
- styles.push(BROWSER_STYLES.timestamp);
2074
- }
2075
- if (this.config.prefix) {
2076
- parts.push(`%c${this.config.prefix}`);
2077
- styles.push(BROWSER_STYLES.prefix);
2078
- }
2079
- if (this.config.showLevel) {
2080
- const levelStr = Logger.getLevelString(level);
2081
- parts.push(`%c[${levelStr}]`);
2082
- switch (level) {
2083
- case "debug":
2084
- styles.push(BROWSER_STYLES.debug);
2085
- break;
2086
- case "info":
2087
- styles.push(BROWSER_STYLES.info);
2088
- break;
2089
- case "warn":
2090
- styles.push(BROWSER_STYLES.warn);
2091
- break;
2092
- case "error":
2093
- styles.push(BROWSER_STYLES.error);
2094
- break;
2095
- default: styles.push("");
2096
- }
2097
- }
2098
- parts.push(`%c${message}`);
2099
- styles.push("color: inherit; font-weight: normal;");
2100
- const formattedMessage = parts.join(" ");
2101
- switch (level) {
2102
- case "debug":
2103
- console.debug(formattedMessage, ...styles, ...args);
2104
- break;
2105
- case "info":
2106
- console.info(formattedMessage, ...styles, ...args);
2107
- break;
2108
- case "warn":
2109
- console.warn(formattedMessage, ...styles, ...args);
2110
- break;
2111
- case "error":
2112
- console.error(formattedMessage, ...styles, ...args);
2113
- break;
2114
- default: console.log(formattedMessage, ...styles, ...args);
2115
- }
1911
+ async getData(key) {
1912
+ return this.cache.get(key) ?? "{}";
2116
1913
  }
2117
- /**
2118
- * Log to Node.js console
2119
- */
2120
- logToNode(level, message, ...args) {
2121
- const formattedMessage = this.formatForNode(level, message);
2122
- switch (level) {
2123
- case "debug":
2124
- console.debug(formattedMessage, ...args);
2125
- break;
2126
- case "info":
2127
- console.info(formattedMessage, ...args);
2128
- break;
2129
- case "warn":
2130
- console.warn(formattedMessage, ...args);
2131
- break;
2132
- case "error":
2133
- console.error(formattedMessage, ...args);
2134
- break;
2135
- default: console.log(formattedMessage, ...args);
2136
- }
1914
+ async removeData(key) {
1915
+ this.cache.delete(key);
1916
+ }
1917
+ };
1918
+
1919
+ //#endregion
1920
+ //#region src/DefaultCrypto.ts
1921
+ /**
1922
+ * Default implementation of the Crypto interface using the 'jose' library
1923
+ * and the native Web Crypto API.
1924
+ */
1925
+ var DefaultCrypto = class {
1926
+ base64URLDecode(value) {
1927
+ const decodedArray = jose.base64url.decode(value);
1928
+ return new TextDecoder().decode(decodedArray);
2137
1929
  }
2138
- /**
2139
- * Log debug message
2140
- */
2141
- debug(message, ...args) {
2142
- this.logMessage("debug", message, ...args);
1930
+ base64URLEncode(value) {
1931
+ return jose.base64url.encode(value);
1932
+ }
1933
+ generateRandomBytes(length) {
1934
+ return crypto.getRandomValues(new Uint8Array(length));
1935
+ }
1936
+ async hashSha256(data) {
1937
+ const dataBuffer = new TextEncoder().encode(data);
1938
+ const hashBuffer = await crypto.subtle.digest("SHA-256", dataBuffer);
1939
+ return new Uint8Array(hashBuffer);
1940
+ }
1941
+ async verifyJwt(idToken, jwk, algorithms, clientId, issuer, subject, clockTolerance, validateJwtIssuer = true) {
1942
+ const key = await jose.importJWK(jwk);
1943
+ await jose.jwtVerify(idToken, key, {
1944
+ algorithms,
1945
+ audience: [clientId],
1946
+ clockTolerance,
1947
+ issuer: validateJwtIssuer ? issuer : void 0,
1948
+ subject
1949
+ });
1950
+ return true;
2143
1951
  }
1952
+ };
1953
+
1954
+ //#endregion
1955
+ //#region src/models/store.ts
1956
+ /**
1957
+ * Enum representing different types of data stores used in the application.
1958
+ */
1959
+ let Stores = /* @__PURE__ */ function(Stores$1) {
2144
1960
  /**
2145
- * Log info message
1961
+ * Store for configuration data that defines the application's behavior and settings.
2146
1962
  */
2147
- info(message, ...args) {
2148
- this.logMessage("info", message, ...args);
2149
- }
1963
+ Stores$1["ConfigData"] = "config_data";
2150
1964
  /**
2151
- * Log warning message
1965
+ * Store for OpenID Connect provider metadata, including endpoints and configuration.
2152
1966
  */
2153
- warn(message, ...args) {
2154
- this.logMessage("warn", message, ...args);
2155
- }
1967
+ Stores$1["OIDCProviderMetaData"] = "oidc_provider_meta_data";
2156
1968
  /**
2157
- * Log error message
1969
+ * Store for persisted data that needs to be retained across sessions and application restarts.
2158
1970
  */
2159
- error(message, ...args) {
2160
- this.logMessage("error", message, ...args);
2161
- }
1971
+ Stores$1["PersistedData"] = "persisted_data";
2162
1972
  /**
2163
- * Create a child logger with additional prefix
1973
+ * Store for user session-related data like tokens and authentication state.
2164
1974
  */
2165
- child(prefix) {
2166
- const childPrefix = this.config.prefix ? `${this.config.prefix} - ${prefix}` : prefix;
2167
- return new Logger({
2168
- ...this.config,
2169
- prefix: childPrefix
2170
- });
2171
- }
1975
+ Stores$1["SessionData"] = "session_data";
2172
1976
  /**
2173
- * Set log level
1977
+ * Store for temporary data that needs to persist only for a short duration.
2174
1978
  */
2175
- setLevel(level) {
2176
- this.config.level = level;
2177
- }
1979
+ Stores$1["TemporaryData"] = "temporary_data";
2178
1980
  /**
2179
- * Get current log level
1981
+ * Store for data that leverages local storage if available, falling back to the configured storage.
2180
1982
  */
2181
- getLevel() {
2182
- return this.config.level;
2183
- }
2184
- };
2185
- /**
2186
- * Default logger instance
2187
- */
2188
- const logger = new Logger();
2189
- /**
2190
- * Create a new logger instance with custom configuration
2191
- */
2192
- const createLogger = (config) => new Logger(config);
2193
- /**
2194
- * Default export - global logger instance
2195
- */
2196
- var logger_default = logger;
2197
- /**
2198
- * Named exports for convenience
2199
- */
2200
- const debug = (message, ...args) => logger.debug(message, ...args);
2201
- const info = (message, ...args) => logger.info(message, ...args);
2202
- const warn = (message, ...args) => logger.warn(message, ...args);
2203
- const error = (message, ...args) => logger.error(message, ...args);
2204
- /**
2205
- * Configure the default logger
2206
- */
2207
- const configure = (config) => logger.configure(config);
2208
- /**
2209
- * Create component-specific loggers
2210
- */
2211
- const createComponentLogger = (component) => logger.child(component);
2212
- /**
2213
- * Create package-specific logger
2214
- */
2215
- const createPackageLogger = (packageName) => createLogger({
2216
- level: "info",
2217
- prefix: `${PREFIX} - ${packageName}`,
2218
- showLevel: true,
2219
- timestamps: true
2220
- });
2221
- /**
2222
- * Create package component logger (package + component)
2223
- */
2224
- const createPackageComponentLogger = (packageName, component) => {
2225
- return createPackageLogger(packageName).child(component);
2226
- };
1983
+ Stores$1["HybridData"] = "hybrid_data";
1984
+ return Stores$1;
1985
+ }({});
2227
1986
 
2228
1987
  //#endregion
2229
1988
  //#region src/StorageManager.ts
@@ -2546,24 +2305,43 @@ const processOpenIDScopes = (scopes) => {
2546
2305
  var processOpenIDScopes_default = processOpenIDScopes;
2547
2306
 
2548
2307
  //#endregion
2549
- //#region src/constants/TokenExchangeConstants.ts
2308
+ //#region src/utils/resolveResourceEndpoint.ts
2309
+ /**
2310
+ * The `config.endpoints` keys that address resource-server endpoints rather than OIDC/OAuth
2311
+ * endpoints. Used to keep these overrides out of the resolved OIDC provider metadata.
2312
+ */
2313
+ const RESOURCE_ENDPOINT_KEYS = [
2314
+ "flowExecute",
2315
+ "flowMeta",
2316
+ "usersMe"
2317
+ ];
2550
2318
  /**
2551
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
2319
+ * Resolves the absolute `url` to use for a resource-server endpoint, honoring (in order of
2320
+ * precedence) an explicit per-call URL, then a `config.endpoints` override.
2552
2321
  *
2553
- * WSO2 LLC. licenses this file to you under the Apache License,
2554
- * Version 2.0 (the "License"); you may not use this file except
2555
- * in compliance with the License.
2556
- * You may obtain a copy of the License at
2322
+ * Returns `undefined` when neither is set, so the calling API function falls back to deriving the
2323
+ * endpoint from `baseUrl` (i.e. `${baseUrl}/flow/execute`) exactly as before. Callers should keep
2324
+ * passing `baseUrl` alongside the resolved `url` to preserve that fallback.
2557
2325
  *
2558
- * http://www.apache.org/licenses/LICENSE-2.0
2326
+ * @param key - The resource endpoint to resolve.
2327
+ * @param config - The client config carrying optional `endpoints` overrides.
2328
+ * @param explicitUrl - An explicit URL provided by the immediate caller; takes highest precedence.
2329
+ * @returns The resolved override URL, or `undefined` to defer to `baseUrl`-based resolution.
2559
2330
  *
2560
- * Unless required by applicable law or agreed to in writing,
2561
- * software distributed under the License is distributed on an
2562
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2563
- * KIND, either express or implied. See the License for the
2564
- * specific language governing permissions and limitations
2565
- * under the License.
2331
+ * @example
2332
+ * ```typescript
2333
+ * const response = await executeEmbeddedUserOnboardingFlow({
2334
+ * baseUrl: config.baseUrl,
2335
+ * url: resolveResourceEndpoint('flowExecute', config),
2336
+ * payload,
2337
+ * });
2338
+ * ```
2566
2339
  */
2340
+ const resolveResourceEndpoint = (key, config, explicitUrl) => explicitUrl ?? config?.endpoints?.[key] ?? void 0;
2341
+ var resolveResourceEndpoint_default = resolveResourceEndpoint;
2342
+
2343
+ //#endregion
2344
+ //#region src/constants/TokenExchangeConstants.ts
2567
2345
  /**
2568
2346
  * Constants for OAuth 2.0 Token Exchange operations.
2569
2347
  * This object contains placeholders used in token exchange requests
@@ -2615,6 +2393,25 @@ var AuthenticationHelper = class {
2615
2393
  this.cryptoHelper = cryptoHelperInstance;
2616
2394
  }
2617
2395
  /**
2396
+ * Maps the config-defined OIDC endpoint overrides to their discovery-metadata form.
2397
+ *
2398
+ * Endpoint names are converted from camelCase to snake_case, and resource-server endpoints
2399
+ * (`RESOURCE_ENDPOINT_KEYS`) are excluded — those are resolved separately via
2400
+ * `resolveResourceEndpoint` and must not leak into the OIDC provider metadata.
2401
+ *
2402
+ * @param configData - The resolved auth client config.
2403
+ * @returns A snake_cased map of the OIDC endpoint overrides (empty when none are configured).
2404
+ */
2405
+ mapConfiguredOidcEndpoints(configData) {
2406
+ const endpoints = {};
2407
+ if (!configData.endpoints) return endpoints;
2408
+ Object.keys(configData.endpoints).filter((endpointName) => !RESOURCE_ENDPOINT_KEYS.includes(endpointName)).forEach((endpointName) => {
2409
+ const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
2410
+ endpoints[snakeCasedName] = configData.endpoints ? configData.endpoints[endpointName] : "";
2411
+ });
2412
+ return endpoints;
2413
+ }
2414
+ /**
2618
2415
  * Merges explicit endpoint overrides from config into the discovery response.
2619
2416
  * Config-defined endpoint names (camelCase) are converted to snake_case before merging.
2620
2417
  *
@@ -2622,15 +2419,10 @@ var AuthenticationHelper = class {
2622
2419
  * @returns The discovery response with any config-specified endpoint overrides applied.
2623
2420
  */
2624
2421
  async resolveEndpoints(response) {
2625
- const oidcProviderMetaData = {};
2626
2422
  const configData = await this.config();
2627
- if (configData.endpoints) Object.keys(configData.endpoints).forEach((endpointName) => {
2628
- const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
2629
- oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
2630
- });
2631
2423
  return {
2632
2424
  ...response,
2633
- ...oidcProviderMetaData
2425
+ ...this.mapConfiguredOidcEndpoints(configData)
2634
2426
  };
2635
2427
  }
2636
2428
  /**
@@ -2641,7 +2433,6 @@ var AuthenticationHelper = class {
2641
2433
  * @throws {ThunderIDAuthException} When required endpoints are absent from the config.
2642
2434
  */
2643
2435
  async resolveEndpointsExplicitly() {
2644
- const oidcProviderMetaData = {};
2645
2436
  const configData = await this.config();
2646
2437
  const requiredEndpoints = [
2647
2438
  OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION,
@@ -2656,11 +2447,7 @@ var AuthenticationHelper = class {
2656
2447
  if (!(configData.endpoints ? requiredEndpoints.every((reqEndpointName) => configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
2657
2448
  return endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`) === reqEndpointName;
2658
2449
  }) : false) : false)) throw new ThunderIDAuthException("JS-AUTH_HELPER-REE-NF01", "Required endpoints missing", "Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object.");
2659
- if (configData.endpoints) Object.keys(configData.endpoints).forEach((endpointName) => {
2660
- const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
2661
- oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
2662
- });
2663
- return { ...oidcProviderMetaData };
2450
+ return { ...this.mapConfiguredOidcEndpoints(configData) };
2664
2451
  }
2665
2452
  /**
2666
2453
  * Derives OIDC endpoint URLs from the configured `baseUrl`.
@@ -2671,14 +2458,10 @@ var AuthenticationHelper = class {
2671
2458
  * @throws {ThunderIDAuthException} When `baseUrl` is not defined in the config.
2672
2459
  */
2673
2460
  async resolveEndpointsByBaseURL() {
2674
- const oidcProviderMetaData = {};
2675
2461
  const configData = await this.config();
2676
2462
  const { baseUrl } = configData;
2677
2463
  if (!baseUrl) throw new ThunderIDAuthException("JS-AUTH_HELPER_REBO-NF01", "Base URL not defined.", "Base URL is not defined in AuthClient config.");
2678
- if (configData.endpoints) Object.keys(configData.endpoints).forEach((endpointName) => {
2679
- const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
2680
- oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
2681
- });
2464
+ const oidcProviderMetaData = this.mapConfiguredOidcEndpoints(configData);
2682
2465
  const endpointKeys = OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints;
2683
2466
  const endpointPaths = OIDCDiscoveryConstants_default.Endpoints;
2684
2467
  return {
@@ -2834,23 +2617,6 @@ var base64Encode_default = base64Encode;
2834
2617
  //#endregion
2835
2618
  //#region src/utils/deepMerge.ts
2836
2619
  /**
2837
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
2838
- *
2839
- * WSO2 LLC. licenses this file to you under the Apache License,
2840
- * Version 2.0 (the "License"); you may not use this file except
2841
- * in compliance with the License.
2842
- * You may obtain a copy of the License at
2843
- *
2844
- * http://www.apache.org/licenses/LICENSE-2.0
2845
- *
2846
- * Unless required by applicable law or agreed to in writing,
2847
- * software distributed under the License is distributed on an
2848
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2849
- * KIND, either express or implied. See the License for the
2850
- * specific language governing permissions and limitations
2851
- * under the License.
2852
- */
2853
- /**
2854
2620
  * Checks if a value is a plain object (not an array, function, date, etc.)
2855
2621
  *
2856
2622
  * @param value - The value to check
@@ -3106,8 +2872,18 @@ var ThunderIDJavaScriptClient = class {
3106
2872
  return createdAt + parseInt(expiresInString, 10) * 1e3 > (/* @__PURE__ */ new Date()).getTime();
3107
2873
  }
3108
2874
  async getAccessToken(sessionId) {
2875
+ if ((await this.configProvider()).grantType === "client_credentials") {
2876
+ const sessionData = await this.storageManager.getSessionData(sessionId);
2877
+ if (sessionData?.access_token && this.isCachedTokenStillValid(sessionData)) return sessionData.access_token;
2878
+ return (await this.requestClientCredentialsToken(sessionId)).accessToken;
2879
+ }
3109
2880
  return (await this.storageManager.getSessionData(sessionId))?.access_token;
3110
2881
  }
2882
+ isCachedTokenStillValid(sessionData) {
2883
+ if (!sessionData.created_at || !sessionData.expires_in) return false;
2884
+ const expiresInMs = parseInt(sessionData.expires_in, 10) * 1e3;
2885
+ return sessionData.created_at + expiresInMs - TokenConstants_default.Lifecycle.CLIENT_CREDENTIALS_REFRESH_MARGIN_MS > Date.now();
2886
+ }
3111
2887
  clearSession(sessionId) {
3112
2888
  this.authHelper.clearSession(sessionId);
3113
2889
  }
@@ -3380,6 +3156,56 @@ var ThunderIDJavaScriptClient = class {
3380
3156
  if (!tokenResponse.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RAT2-HE04", `Refreshing access token failed with ${tokenResponse.statusText}`, await tokenResponse.json());
3381
3157
  return this.authHelper.handleTokenResponse(tokenResponse, userId);
3382
3158
  }
3159
+ /**
3160
+ * Requests a machine-to-machine access token via the `client_credentials` grant
3161
+ * (RFC 6749 §4.4) and caches it under the given session key. Unlike the user-facing
3162
+ * flows, there's no id_token or refresh_token: the service authenticates as itself.
3163
+ */
3164
+ async requestClientCredentialsToken(sessionId) {
3165
+ if (!await this.storageManager.getTemporaryDataParameter(OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED)) await this.loadOpenIDProviderConfiguration(false);
3166
+ const tokenEndpoint = (await this.oidcProviderMetaDataProvider()).token_endpoint;
3167
+ const configData = await this.configProvider();
3168
+ if (!tokenEndpoint || tokenEndpoint.trim().length === 0) throw new ThunderIDAuthException("JS-AUTH_CORE-RCCT-NF01", "Token endpoint not found.", "No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty.");
3169
+ const body = new URLSearchParams();
3170
+ body.set("grant_type", "client_credentials");
3171
+ body.set("client_id", configData.clientId ?? "");
3172
+ const hasSecret = Boolean(configData.clientSecret && configData.clientSecret.trim().length > 0);
3173
+ const tokenEndpointAuthMethod = configData.tokenRequest?.authMethod ?? "client_secret_basic";
3174
+ if (hasSecret && tokenEndpointAuthMethod === "client_secret_post") body.set("client_secret", configData.clientSecret);
3175
+ const scope = Array.isArray(configData.scopes) ? configData.scopes.join(" ") : configData.scopes;
3176
+ if (scope) body.set("scope", scope);
3177
+ if (configData.tokenRequest?.params) Object.entries(configData.tokenRequest.params).forEach(([key, value]) => {
3178
+ body.set(key, value);
3179
+ });
3180
+ const tokenRequestHeaders = {
3181
+ Accept: "application/json",
3182
+ "Content-Type": "application/x-www-form-urlencoded"
3183
+ };
3184
+ if (hasSecret && tokenEndpointAuthMethod === "client_secret_basic") tokenRequestHeaders["Authorization"] = `Basic ${base64Encode_default(`${encodeURIComponent(configData.clientId)}:${encodeURIComponent(configData.clientSecret)}`)}`;
3185
+ let tokenResponse;
3186
+ try {
3187
+ tokenResponse = await fetch(tokenEndpoint, {
3188
+ body,
3189
+ headers: tokenRequestHeaders,
3190
+ method: "POST"
3191
+ });
3192
+ } catch (error$1) {
3193
+ throw new ThunderIDAuthException("JS-AUTH_CORE-RCCT-NE02", "Requesting client credentials token failed.", error$1 ?? "The request to get the client credentials access token failed.");
3194
+ }
3195
+ if (!tokenResponse.ok) throw new ThunderIDAuthException("JS-AUTH_CORE-RCCT-HE03", `Requesting client credentials token failed with ${tokenResponse.statusText}`, await tokenResponse.json());
3196
+ const parsedResponse = await tokenResponse.json();
3197
+ parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
3198
+ await this.storageManager.setSessionData(parsedResponse, sessionId);
3199
+ return {
3200
+ accessToken: parsedResponse.access_token,
3201
+ createdAt: parsedResponse.created_at,
3202
+ expiresIn: parsedResponse.expires_in,
3203
+ idToken: parsedResponse.id_token ?? "",
3204
+ refreshToken: parsedResponse.refresh_token ?? "",
3205
+ scope: parsedResponse.scope,
3206
+ tokenType: parsedResponse.token_type
3207
+ };
3208
+ }
3383
3209
  async revokeAccessToken(userId) {
3384
3210
  const revokeTokenEndpoint = (await this.oidcProviderMetaDataProvider()).revocation_endpoint;
3385
3211
  const configData = await this.configProvider();
@@ -4014,23 +3840,6 @@ var createTheme_default = createTheme;
4014
3840
  //#endregion
4015
3841
  //#region src/utils/arrayBufferToBase64url.ts
4016
3842
  /**
4017
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4018
- *
4019
- * WSO2 LLC. licenses this file to you under the Apache License,
4020
- * Version 2.0 (the "License"); you may not use this file except
4021
- * in compliance with the License.
4022
- * You may obtain a copy of the License at
4023
- *
4024
- * http://www.apache.org/licenses/LICENSE-2.0
4025
- *
4026
- * Unless required by applicable law or agreed to in writing,
4027
- * software distributed under the License is distributed on an
4028
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4029
- * KIND, either express or implied. See the License for the
4030
- * specific language governing permissions and limitations
4031
- * under the License.
4032
- */
4033
- /**
4034
3843
  * Converts an ArrayBuffer to a base64url encoded string.
4035
3844
  *
4036
3845
  * Base64url encoding is a URL-safe variant of base64 encoding that:
@@ -4070,23 +3879,6 @@ var arrayBufferToBase64url_default = arrayBufferToBase64url;
4070
3879
  //#endregion
4071
3880
  //#region src/utils/base64urlToArrayBuffer.ts
4072
3881
  /**
4073
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4074
- *
4075
- * WSO2 LLC. licenses this file to you under the Apache License,
4076
- * Version 2.0 (the "License"); you may not use this file except
4077
- * in compliance with the License.
4078
- * You may obtain a copy of the License at
4079
- *
4080
- * http://www.apache.org/licenses/LICENSE-2.0
4081
- *
4082
- * Unless required by applicable law or agreed to in writing,
4083
- * software distributed under the License is distributed on an
4084
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4085
- * KIND, either express or implied. See the License for the
4086
- * specific language governing permissions and limitations
4087
- * under the License.
4088
- */
4089
- /**
4090
3882
  * Converts a base64url encoded string back to an ArrayBuffer.
4091
3883
  *
4092
3884
  * This function performs the inverse operation of base64url encoding by:
@@ -4135,23 +3927,6 @@ var base64urlToArrayBuffer_default = base64urlToArrayBuffer;
4135
3927
  //#endregion
4136
3928
  //#region src/utils/bem.ts
4137
3929
  /**
4138
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4139
- *
4140
- * WSO2 LLC. licenses this file to you under the Apache License,
4141
- * Version 2.0 (the "License"); you may not use this file except
4142
- * in compliance with the License.
4143
- * You may obtain a copy of the License at
4144
- *
4145
- * http://www.apache.org/licenses/LICENSE-2.0
4146
- *
4147
- * Unless required by applicable law or agreed to in writing,
4148
- * software distributed under the License is distributed on an
4149
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4150
- * KIND, either express or implied. See the License for the
4151
- * specific language governing permissions and limitations
4152
- * under the License.
4153
- */
4154
- /**
4155
3930
  * Creates a BEM-style class name by combining a base class with element and/or modifier
4156
3931
  *
4157
3932
  * @param baseClass - The base CSS class string (usually from emotion's css function)
@@ -4189,23 +3964,6 @@ var bem_default = bem;
4189
3964
  //#endregion
4190
3965
  //#region src/utils/formatDate.ts
4191
3966
  /**
4192
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4193
- *
4194
- * WSO2 LLC. licenses this file to you under the Apache License,
4195
- * Version 2.0 (the "License"); you may not use this file except
4196
- * in compliance with the License.
4197
- * You may obtain a copy of the License at
4198
- *
4199
- * http://www.apache.org/licenses/LICENSE-2.0
4200
- *
4201
- * Unless required by applicable law or agreed to in writing,
4202
- * software distributed under the License is distributed on an
4203
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4204
- * KIND, either express or implied. See the License for the
4205
- * specific language governing permissions and limitations
4206
- * under the License.
4207
- */
4208
- /**
4209
3967
  * Formats a date string to a human-readable format.
4210
3968
  *
4211
3969
  * @param dateString - The date string to format (optional)
@@ -4356,23 +4114,6 @@ var getRedirectBasedSignUpUrl_default = getRedirectBasedSignUpUrl;
4356
4114
  //#endregion
4357
4115
  //#region src/utils/isEmpty.ts
4358
4116
  /**
4359
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4360
- *
4361
- * WSO2 LLC. licenses this file to you under the Apache License,
4362
- * Version 2.0 (the "License"); you may not use this file except
4363
- * in compliance with the License.
4364
- * You may obtain a copy of the License at
4365
- *
4366
- * http://www.apache.org/licenses/LICENSE-2.0
4367
- *
4368
- * Unless required by applicable law or agreed to in writing,
4369
- * software distributed under the License is distributed on an
4370
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4371
- * KIND, either express or implied. See the License for the
4372
- * specific language governing permissions and limitations
4373
- * under the License.
4374
- */
4375
- /**
4376
4117
  * Checks if a value is considered empty.
4377
4118
  *
4378
4119
  * A value is considered empty if it is:
@@ -4412,23 +4153,6 @@ var isEmpty_default = isEmpty;
4412
4153
 
4413
4154
  //#endregion
4414
4155
  //#region src/utils/isEmojiUri.ts
4415
- /**
4416
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
4417
- *
4418
- * WSO2 LLC. licenses this file to you under the Apache License,
4419
- * Version 2.0 (the "License"); you may not use this file except
4420
- * in compliance with the License.
4421
- * You may obtain a copy of the License at
4422
- *
4423
- * http://www.apache.org/licenses/LICENSE-2.0
4424
- *
4425
- * Unless required by applicable law or agreed to in writing,
4426
- * software distributed under the License is distributed on an
4427
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4428
- * KIND, either express or implied. See the License for the
4429
- * specific language governing permissions and limitations
4430
- * under the License.
4431
- */
4432
4156
  const EMOJI_URI_SCHEME = "emoji:";
4433
4157
  /**
4434
4158
  * Checks whether a given URI uses the `emoji:` scheme (e.g. `"emoji:🐯"`).
@@ -4469,23 +4193,6 @@ var extractEmojiFromUri_default = extractEmojiFromUri;
4469
4193
  //#endregion
4470
4194
  //#region src/utils/set.ts
4471
4195
  /**
4472
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4473
- *
4474
- * WSO2 LLC. licenses this file to you under the Apache License,
4475
- * Version 2.0 (the "License"); you may not use this file except
4476
- * in compliance with the License.
4477
- * You may obtain a copy of the License at
4478
- *
4479
- * http://www.apache.org/licenses/LICENSE-2.0
4480
- *
4481
- * Unless required by applicable law or agreed to in writing,
4482
- * software distributed under the License is distributed on an
4483
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4484
- * KIND, either express or implied. See the License for the
4485
- * specific language governing permissions and limitations
4486
- * under the License.
4487
- */
4488
- /**
4489
4196
  * Sets the value at path of object. If a portion of path doesn't exist,
4490
4197
  * it's created. Arrays are created for missing index properties while
4491
4198
  * objects are created for all other missing properties.
@@ -4515,23 +4222,6 @@ var set_default = set;
4515
4222
  //#endregion
4516
4223
  //#region src/utils/get.ts
4517
4224
  /**
4518
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4519
- *
4520
- * WSO2 LLC. licenses this file to you under the Apache License,
4521
- * Version 2.0 (the "License"); you may not use this file except
4522
- * in compliance with the License.
4523
- * You may obtain a copy of the License at
4524
- *
4525
- * http://www.apache.org/licenses/LICENSE-2.0
4526
- *
4527
- * Unless required by applicable law or agreed to in writing,
4528
- * software distributed under the License is distributed on an
4529
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4530
- * KIND, either express or implied. See the License for the
4531
- * specific language governing permissions and limitations
4532
- * under the License.
4533
- */
4534
- /**
4535
4225
  * Gets the value at path of object. If the resolved value is undefined,
4536
4226
  * the defaultValue is returned in its place.
4537
4227
  * Similar to Lodash's get() function
@@ -4551,23 +4241,6 @@ var get_default = get;
4551
4241
  //#endregion
4552
4242
  //#region src/utils/startCase.ts
4553
4243
  /**
4554
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
4555
- *
4556
- * WSO2 LLC. licenses this file to you under the Apache License,
4557
- * Version 2.0 (the "License"); you may not use this file except
4558
- * in compliance with the License.
4559
- * You may obtain a copy of the License at
4560
- *
4561
- * http://www.apache.org/licenses/LICENSE-2.0
4562
- *
4563
- * Unless required by applicable law or agreed to in writing,
4564
- * software distributed under the License is distributed on an
4565
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4566
- * KIND, either express or implied. See the License for the
4567
- * specific language governing permissions and limitations
4568
- * under the License.
4569
- */
4570
- /**
4571
4244
  * Converts the first character of `string` to upper case.
4572
4245
  *
4573
4246
  * @param string - The string to convert.
@@ -4592,23 +4265,6 @@ var startCase_default = startCase;
4592
4265
  //#endregion
4593
4266
  //#region src/utils/removeTrailingSlash.ts
4594
4267
  /**
4595
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4596
- *
4597
- * WSO2 LLC. licenses this file to you under the Apache License,
4598
- * Version 2.0 (the "License"); you may not use this file except
4599
- * in compliance with the License.
4600
- * You may obtain a copy of the License at
4601
- *
4602
- * http://www.apache.org/licenses/LICENSE-2.0
4603
- *
4604
- * Unless required by applicable law or agreed to in writing,
4605
- * software distributed under the License is distributed on an
4606
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4607
- * KIND, either express or implied. See the License for the
4608
- * specific language governing permissions and limitations
4609
- * under the License.
4610
- */
4611
- /**
4612
4268
  * Removes a trailing slash from a path string if it exists.
4613
4269
  *
4614
4270
  * @param path - The string path to process
@@ -4661,23 +4317,6 @@ function resolveMeta(path, meta) {
4661
4317
  //#endregion
4662
4318
  //#region src/utils/parseFlowTemplateLiteral.ts
4663
4319
  /**
4664
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
4665
- *
4666
- * WSO2 LLC. licenses this file to you under the Apache License,
4667
- * Version 2.0 (the "License"); you may not use this file except
4668
- * in compliance with the License.
4669
- * You may obtain a copy of the License at
4670
- *
4671
- * http://www.apache.org/licenses/LICENSE-2.0
4672
- *
4673
- * Unless required by applicable law or agreed to in writing,
4674
- * software distributed under the License is distributed on an
4675
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4676
- * KIND, either express or implied. See the License for the
4677
- * specific language governing permissions and limitations
4678
- * under the License.
4679
- */
4680
- /**
4681
4320
  * Regular expression to detect a flow template literal wrapped in double braces.
4682
4321
  * Matches patterns like `{{ t(key) }}`, `{{ meta(key) }}`, etc.
4683
4322
  *
@@ -4794,23 +4433,6 @@ function resolveFlowTemplateLiterals(text, { t, meta }) {
4794
4433
  //#endregion
4795
4434
  //#region src/utils/countryCodeToFlagEmoji.ts
4796
4435
  /**
4797
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
4798
- *
4799
- * WSO2 LLC. licenses this file to you under the Apache License,
4800
- * Version 2.0 (the "License"); you may not use this file except
4801
- * in compliance with the License.
4802
- * You may obtain a copy of the License at
4803
- *
4804
- * http://www.apache.org/licenses/LICENSE-2.0
4805
- *
4806
- * Unless required by applicable law or agreed to in writing,
4807
- * software distributed under the License is distributed on an
4808
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4809
- * KIND, either express or implied. See the License for the
4810
- * specific language governing permissions and limitations
4811
- * under the License.
4812
- */
4813
- /**
4814
4436
  * Converts a two-letter ISO 3166-1 alpha-2 country code to a flag emoji using
4815
4437
  * Unicode Regional Indicator Symbols (U+1F1E6–U+1F1FF).
4816
4438
  *
@@ -4824,23 +4446,6 @@ function countryCodeToFlagEmoji(countryCode) {
4824
4446
  //#endregion
4825
4447
  //#region src/utils/resolveLocaleDisplayName.ts
4826
4448
  /**
4827
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
4828
- *
4829
- * WSO2 LLC. licenses this file to you under the Apache License,
4830
- * Version 2.0 (the "License"); you may not use this file except
4831
- * in compliance with the License.
4832
- * You may obtain a copy of the License at
4833
- *
4834
- * http://www.apache.org/licenses/LICENSE-2.0
4835
- *
4836
- * Unless required by applicable law or agreed to in writing,
4837
- * software distributed under the License is distributed on an
4838
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4839
- * KIND, either express or implied. See the License for the
4840
- * specific language governing permissions and limitations
4841
- * under the License.
4842
- */
4843
- /**
4844
4449
  * Resolves a BCP 47 locale tag to a human-readable display name using the
4845
4450
  * `Intl.DisplayNames` API.
4846
4451
  *
@@ -5012,7 +4617,7 @@ var buildValidatorFromRules_default = buildValidatorFromRules;
5012
4617
  * ```typescript
5013
4618
  * // Usage with clsx
5014
4619
  * clsx(withVendorCSSClassPrefix('sign-in-button'), className)
5015
- * // Result: "wso2-sign-in-button"
4620
+ * // Result: "thunderid-sign-in-button"
5016
4621
  * ```
5017
4622
  */
5018
4623
  const withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_PREFIX}-${className}`;
@@ -6199,6 +5804,7 @@ exports.resolveFlowTemplateLiterals = resolveFlowTemplateLiterals;
6199
5804
  exports.resolveLocaleDisplayName = resolveLocaleDisplayName;
6200
5805
  exports.resolveLocaleEmoji = resolveLocaleEmoji_default;
6201
5806
  exports.resolveMeta = resolveMeta;
5807
+ exports.resolveResourceEndpoint = resolveResourceEndpoint_default;
6202
5808
  exports.set = set_default;
6203
5809
  exports.startCase = startCase_default;
6204
5810
  exports.updateMeProfile = updateMeProfile_default;