@thunderid/javascript 0.11.2 → 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 +0 -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 +1378 -1875
  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 +0 -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 +1378 -1875
  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 +0 -17
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +1378 -1875
  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 +0 -17
  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 +0 -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 +0 -17
  225. package/dist/utils/resolveResourceEndpoint.d.ts.map +1 -1
  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.
@@ -87,23 +70,6 @@ var TokenConstants_default = TokenConstants;
87
70
  //#endregion
88
71
  //#region src/errors/exception.ts
89
72
  /**
90
- * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
91
- *
92
- * WSO2 LLC. licenses this file to you under the Apache License,
93
- * Version 2.0 (the "License"); you may not use this file except
94
- * in compliance with the License.
95
- * You may obtain a copy of the License at
96
- *
97
- * http://www.apache.org/licenses/LICENSE-2.0
98
- *
99
- * Unless required by applicable law or agreed to in writing,
100
- * software distributed under the License is distributed on an
101
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
102
- * KIND, either express or implied. See the License for the
103
- * specific language governing permissions and limitations
104
- * under the License.
105
- */
106
- /**
107
73
  * @deprecated Use `ThunderIDRuntimeError` for runtime errors and `ThunderIDAPIError` for API errors.
108
74
  */
109
75
  var ThunderIDAuthException = class extends Error {
@@ -191,23 +157,6 @@ var IsomorphicCrypto = class {
191
157
  //#endregion
192
158
  //#region src/errors/ThunderIDError.ts
193
159
  /**
194
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
195
- *
196
- * WSO2 LLC. licenses this file to you under the Apache License,
197
- * Version 2.0 (the "License"); you may not use this file except
198
- * in compliance with the License.
199
- * You may obtain a copy of the License at
200
- *
201
- * http://www.apache.org/licenses/LICENSE-2.0
202
- *
203
- * Unless required by applicable law or agreed to in writing,
204
- * software distributed under the License is distributed on an
205
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
206
- * KIND, either express or implied. See the License for the
207
- * specific language governing permissions and limitations
208
- * under the License.
209
- */
210
- /**
211
160
  * Base class for all ThunderID errors. This class extends the native Error class
212
161
  * and adds support for error codes and proper stack traces. Each error is prefixed
213
162
  * with a lightning emoji and the SDK name for easy identification.
@@ -256,23 +205,6 @@ var ThunderIDError = class ThunderIDError extends Error {
256
205
  //#endregion
257
206
  //#region src/utils/parseApiErrorMessage.ts
258
207
  /**
259
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
260
- *
261
- * WSO2 LLC. licenses this file to you under the Apache License,
262
- * Version 2.0 (the "License"); you may not use this file except
263
- * in compliance with the License.
264
- * You may obtain a copy of the License at
265
- *
266
- * http://www.apache.org/licenses/LICENSE-2.0
267
- *
268
- * Unless required by applicable law or agreed to in writing,
269
- * software distributed under the License is distributed on an
270
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
271
- * KIND, either express or implied. See the License for the
272
- * specific language governing permissions and limitations
273
- * under the License.
274
- */
275
- /**
276
208
  * Attempts to extract a human-readable message from a structured API error response body.
277
209
  *
278
210
  * The backend returns errors in the following form:
@@ -435,23 +367,6 @@ let EmbeddedSignInFlowType = /* @__PURE__ */ function(EmbeddedSignInFlowType$1)
435
367
  //#endregion
436
368
  //#region src/utils/injectRequestedPermissions.ts
437
369
  /**
438
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
439
- *
440
- * WSO2 LLC. licenses this file to you under the Apache License,
441
- * Version 2.0 (the "License"); you may not use this file except
442
- * in compliance with the License.
443
- * You may obtain a copy of the License at
444
- *
445
- * http://www.apache.org/licenses/LICENSE-2.0
446
- *
447
- * Unless required by applicable law or agreed to in writing,
448
- * software distributed under the License is distributed on an
449
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
450
- * KIND, either express or implied. See the License for the
451
- * specific language governing permissions and limitations
452
- * under the License.
453
- */
454
- /**
455
370
  * Strips the top-level `scopes` field from a payload and injects it as
456
371
  * `inputs.requested_permissions` (space-separated string).
457
372
  *
@@ -473,1758 +388,1601 @@ const injectRequestedPermissions = (payload) => {
473
388
  var injectRequestedPermissions_default = injectRequestedPermissions;
474
389
 
475
390
  //#endregion
476
- //#region src/api/executeEmbeddedSignInFlow.ts
477
- const executeEmbeddedSignInFlow = async ({ url, baseUrl, payload, authId, flowSecret,...requestConfig }) => {
478
- 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.");
479
- const endpoint = url ?? `${baseUrl}/flow/execute`;
480
- const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
481
- const isNewFlowStart = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload;
482
- const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
483
- const basePayload = isNewFlowStart ? injectRequestedPermissions_default(cleanPayload) : cleanPayload;
484
- const requestPayload = isNewFlowStart || hasOnlyFlowId ? {
485
- ...basePayload,
486
- verbose: true
487
- } : basePayload;
488
- const response = await fetch(endpoint, {
489
- ...requestConfig,
490
- body: JSON.stringify(requestPayload),
491
- headers: {
492
- Accept: "application/json",
493
- "Content-Type": "application/json",
494
- ...isNewFlowStart && flowSecret ? { "Flow-Secret": flowSecret } : {},
495
- ...requestConfig.headers
496
- },
497
- method: requestConfig.method || "POST"
498
- });
499
- if (!response.ok) throw new ThunderIDAPIError(await response.text(), "executeEmbeddedSignInFlow-ResponseError-001", "javascript", response.status, response.statusText, "Authorization request failed");
500
- const flowResponse = await response.json();
501
- if (flowResponse.flowStatus === EmbeddedSignInFlowStatus.Complete && flowResponse.assertion && authId) try {
502
- const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
503
- body: JSON.stringify({
504
- assertion: flowResponse.assertion,
505
- authId
506
- }),
507
- credentials: "include",
508
- headers: {
509
- Accept: "application/json",
510
- "Content-Type": "application/json",
511
- ...requestConfig.headers
512
- },
513
- method: "POST"
514
- });
515
- if (!oauth2Response.ok) throw new ThunderIDAPIError(await oauth2Response.text(), "executeEmbeddedSignInFlow-OAuth2Error-002", "javascript", oauth2Response.status, oauth2Response.statusText, "OAuth2 authorization failed");
516
- const oauth2Result = await oauth2Response.json();
517
- return {
518
- flowStatus: flowResponse.flowStatus,
519
- redirectUrl: oauth2Result["redirect_uri"]
520
- };
521
- } catch (authError) {
522
- if (authError instanceof ThunderIDAPIError) throw authError;
523
- 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");
524
- }
525
- 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
526
401
  };
527
- var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
528
-
529
- //#endregion
530
- //#region src/models/embedded-signup-flow.ts
531
402
  /**
532
- * Status enumeration for ThunderID embedded sign-up flow operations.
533
- *
534
- * These statuses indicate the current state of the registration flow and determine
535
- * the next action required by the client application. Each status provides specific
536
- * guidance on how to proceed with the user registration process.
537
- *
538
- * @example
539
- * ```typescript
540
- * switch (response.flowStatus) {
541
- * case EmbeddedSignUpFlowStatus.Incomplete:
542
- * // More user input needed - render registration form components
543
- * break;
544
- * case EmbeddedSignUpFlowStatus.Complete:
545
- * // Registration successful - handle completion
546
- * break;
547
- * case EmbeddedSignUpFlowStatus.Error:
548
- * // Registration failed - show error details
549
- * const errorResponse = response as EmbeddedSignUpFlowErrorResponse;
550
- * showError(errorResponse.error.description.defaultValue);
551
- * break;
552
- * }
553
- * ```
554
- *
555
- * @experimental Part of the new ThunderID API
403
+ * Environment detection utilities
556
404
  */
557
- 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
+ }
558
451
  /**
559
- * Sign-up flow completed successfully.
560
- *
561
- * The user has successfully registered and the flow can proceed to
562
- * OAuth2 completion or redirection. Check for redirectUrl or assertion
563
- * data in the response for next steps.
452
+ * Update logger configuration
564
453
  */
565
- EmbeddedSignUpFlowStatus$1["Complete"] = "COMPLETE";
454
+ configure(config) {
455
+ this.config = {
456
+ ...this.config,
457
+ ...config
458
+ };
459
+ }
566
460
  /**
567
- * Sign-up flow encountered an error and cannot proceed.
568
- *
569
- * Registration failed due to validation errors, duplicate user,
570
- * system errors, or other issues. The response will be of type
571
- * `EmbeddedSignUpFlowErrorResponse` containing detailed failure
572
- * information that can be displayed to the user.
573
- *
574
- * @see {@link EmbeddedSignUpFlowErrorResponse} for error response structure
461
+ * Get current configuration
575
462
  */
576
- EmbeddedSignUpFlowStatus$1["Error"] = "ERROR";
463
+ getConfig() {
464
+ return { ...this.config };
465
+ }
577
466
  /**
578
- * Sign-up flow requires additional user input.
579
- *
580
- * More registration steps are needed. The response will contain
581
- * components in data.meta.components that should be rendered to
582
- * collect additional user information (e.g., profile data, verification).
467
+ * Check if a log level should be output
583
468
  */
584
- EmbeddedSignUpFlowStatus$1["Incomplete"] = "INCOMPLETE";
585
- return EmbeddedSignUpFlowStatus$1;
586
- }({});
587
- /**
588
- * Type enumeration for ThunderID embedded sign-up flow responses.
589
- *
590
- * Determines the nature of the registration flow response and how the client
591
- * should handle the returned data. This affects both UI rendering and flow
592
- * continuation logic during the user registration process.
593
- *
594
- * @experimental Part of the new ThunderID API
595
- */
596
- let EmbeddedSignUpFlowType = /* @__PURE__ */ function(EmbeddedSignUpFlowType$1) {
469
+ shouldLog(level) {
470
+ return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[this.config.level];
471
+ }
597
472
  /**
598
- * Response requires external redirection.
599
- *
600
- * Used for social registration providers, external identity providers,
601
- * or other flows that require navigating to an external URL during
602
- * the registration process. The response will contain redirection information.
473
+ * Get timestamp string
603
474
  */
604
- EmbeddedSignUpFlowType$1["Redirection"] = "REDIRECTION";
475
+ static getTimestamp() {
476
+ return (/* @__PURE__ */ new Date()).toISOString();
477
+ }
605
478
  /**
606
- * Response contains view components for rendering.
607
- *
608
- * Standard embedded registration flow response containing UI components
609
- * that should be rendered within the current application context.
610
- * Most common type for embedded user registration.
479
+ * Get log level string
611
480
  */
612
- EmbeddedSignUpFlowType$1["View"] = "VIEW";
613
- return EmbeddedSignUpFlowType$1;
614
- }({});
615
-
616
- //#endregion
617
- //#region src/api/executeEmbeddedSignUpFlow.ts
618
- const executeEmbeddedSignUpFlow = async ({ url, baseUrl, payload, authId,...requestConfig }) => {
619
- 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.");
620
- const endpoint = url ?? `${baseUrl}/flow/execute`;
621
- const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
622
- const isNewFlowStart = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload;
623
- const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
624
- const basePayload = isNewFlowStart ? injectRequestedPermissions_default(cleanPayload) : cleanPayload;
625
- const requestPayload = isNewFlowStart || hasOnlyFlowId ? {
626
- ...basePayload,
627
- verbose: true
628
- } : basePayload;
629
- const response = await fetch(endpoint, {
630
- ...requestConfig,
631
- body: JSON.stringify(requestPayload),
632
- headers: {
633
- Accept: "application/json",
634
- "Content-Type": "application/json",
635
- ...requestConfig.headers
636
- },
637
- method: requestConfig.method || "POST"
638
- });
639
- if (!response.ok) throw new ThunderIDAPIError(await response.text(), "executeEmbeddedSignUpFlow-ResponseError-001", "javascript", response.status, response.statusText, "Registration request failed");
640
- const flowResponse = await response.json();
641
- if (flowResponse.flowStatus === EmbeddedSignUpFlowStatus.Complete && flowResponse.assertion && authId) try {
642
- const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
643
- body: JSON.stringify({
644
- assertion: flowResponse.assertion,
645
- authId
646
- }),
647
- credentials: "include",
648
- headers: {
649
- Accept: "application/json",
650
- "Content-Type": "application/json",
651
- ...requestConfig.headers
652
- },
653
- method: "POST"
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
654
638
  });
655
- if (!oauth2Response.ok) throw new ThunderIDAPIError(await oauth2Response.text(), "executeEmbeddedSignUpFlow-OAuth2Error-002", "javascript", oauth2Response.status, oauth2Response.statusText, "OAuth2 authorization failed");
656
- const oauth2Result = await oauth2Response.json();
657
- return {
658
- flowStatus: flowResponse.flowStatus,
659
- redirectUrl: oauth2Result["redirect_uri"]
660
- };
661
- } catch (authError) {
662
- if (authError instanceof ThunderIDAPIError) throw authError;
663
- throw new ThunderIDAPIError(authError instanceof Error ? authError.message : "Unknown error", "executeEmbeddedSignUpFlow-OAuth2Error-001", "javascript", 500, "Failed to complete OAuth2 authorization after successful embedded sign-up flow.", "OAuth2 authorization failed");
664
639
  }
665
- return flowResponse;
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
+ }
666
652
  };
667
- var executeEmbeddedSignUpFlow_default = executeEmbeddedSignUpFlow;
668
-
669
- //#endregion
670
- //#region src/api/executeEmbeddedRecoveryFlow.ts
671
653
  /**
672
- * Executes an embedded recovery flow by sending a request to the flow execution endpoint.
673
- *
674
- * This function handles password-recovery and account-recovery flows driven by the
675
- * ThunderID server. The server returns UI components for each step (e.g. username
676
- * collection, OTP verification, password reset) and this function forwards the
677
- * user's responses back to the server.
678
- *
679
- * @param requestConfig - Request configuration containing URL, payload, and optional headers.
680
- * @returns A promise that resolves with the flow execution response.
681
- * @throws ThunderIDAPIError when the request fails or a payload is missing.
682
- *
683
- * @example
684
- * ```typescript
685
- * // Initiate recovery flow
686
- * const response = await executeEmbeddedRecoveryFlow({
687
- * baseUrl: 'https://localhost:8090',
688
- * payload: {
689
- * flowType: 'RECOVERY',
690
- * applicationId: 'my-app-id',
691
- * },
692
- * });
693
- *
694
- * // Continue recovery flow with user input
695
- * const nextResponse = await executeEmbeddedRecoveryFlow({
696
- * baseUrl: 'https://localhost:8090',
697
- * payload: {
698
- * executionId: response.executionId,
699
- * action: 'submit',
700
- * inputs: { username: 'user@example.com' },
701
- * challengeToken: response.challengeToken,
702
- * },
703
- * });
704
- * ```
654
+ * Default logger instance
705
655
  */
706
- const executeEmbeddedRecoveryFlow = async ({ url, baseUrl, payload,...requestConfig }) => {
707
- if (!payload) throw new ThunderIDAPIError("Recovery payload is required", "executeEmbeddedRecoveryFlow-ValidationError-002", "javascript", 400, "If a recovery payload is not provided, the request cannot be constructed correctly.");
708
- const endpoint = url ?? `${baseUrl}/flow/execute`;
709
- const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
710
- const hasOnlyAppIdAndFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 2;
711
- const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
712
- const requestPayload = hasOnlyAppIdAndFlowType || hasOnlyFlowId ? {
713
- ...cleanPayload,
714
- verbose: true
715
- } : cleanPayload;
716
- const response = await fetch(endpoint, {
717
- ...requestConfig,
718
- body: JSON.stringify(requestPayload),
719
- headers: {
720
- Accept: "application/json",
721
- "Content-Type": "application/json",
722
- ...requestConfig.headers
723
- },
724
- method: requestConfig.method || "POST"
725
- });
726
- if (!response.ok) throw new ThunderIDAPIError(await response.text(), "executeEmbeddedRecoveryFlow-ResponseError-001", "javascript", response.status, response.statusText, "Recovery request failed");
727
- return await response.json();
728
- };
729
- var executeEmbeddedRecoveryFlow_default = executeEmbeddedRecoveryFlow;
730
-
731
- //#endregion
732
- //#region src/models/embedded-flow.ts
656
+ const logger = new Logger();
733
657
  /**
734
- * Copyright (c) 2025-2026, WSO2 LLC. (https://www.wso2.com).
735
- *
736
- * WSO2 LLC. licenses this file to you under the Apache License,
737
- * Version 2.0 (the "License"); you may not use this file except
738
- * in compliance with the License.
739
- * You may obtain a copy of the License at
740
- *
741
- * http://www.apache.org/licenses/LICENSE-2.0
742
- *
743
- * Unless required by applicable law or agreed to in writing,
744
- * software distributed under the License is distributed on an
745
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
746
- * KIND, either express or implied. See the License for the
747
- * specific language governing permissions and limitations
748
- * under the License.
658
+ * Create a new logger instance with custom configuration
749
659
  */
750
- let EmbeddedFlowType = /* @__PURE__ */ function(EmbeddedFlowType$1) {
751
- EmbeddedFlowType$1["Authentication"] = "AUTHENTICATION";
752
- EmbeddedFlowType$1["Recovery"] = "RECOVERY";
753
- EmbeddedFlowType$1["Registration"] = "REGISTRATION";
754
- EmbeddedFlowType$1["UserOnboarding"] = "USER_ONBOARDING";
755
- return EmbeddedFlowType$1;
756
- }({});
757
- let EmbeddedFlowResponseType = /* @__PURE__ */ function(EmbeddedFlowResponseType$1) {
758
- EmbeddedFlowResponseType$1["Redirection"] = "REDIRECTION";
759
- EmbeddedFlowResponseType$1["View"] = "VIEW";
760
- return EmbeddedFlowResponseType$1;
761
- }({});
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);
762
672
  /**
763
- * Component types supported by the ThunderID embedded flow API.
764
- *
765
- * These types define the different UI components that can be rendered
766
- * as part of the embedded authentication flows. Each type corresponds
767
- * to a specific UI element with its own behavior and properties.
768
- *
769
- * @example
770
- * ```typescript
771
- * // Check component type to render appropriate UI
772
- * if (component.type === EmbeddedFlowComponentType.TextInput) {
773
- * // Render text input field
774
- * } else if (component.type === EmbeddedFlowComponentType.Action) {
775
- * // Render button/action
776
- * }
777
- * ```
778
- *
779
- * @experimental This API may change in future versions
673
+ * Configure the default logger
780
674
  */
781
- let EmbeddedFlowComponentType = /* @__PURE__ */ function(EmbeddedFlowComponentType$1) {
782
- /** Interactive action component (buttons, links) for user interactions */
783
- EmbeddedFlowComponentType$1["Action"] = "ACTION";
784
- /** Container block component that groups other components */
785
- EmbeddedFlowComponentType$1["Block"] = "BLOCK";
786
- /** Consent component for displaying consent purposes and attributes */
787
- EmbeddedFlowComponentType$1["Consent"] = "CONSENT";
788
- /** Copyable text display component that shows text with a copy-to-clipboard action */
789
- EmbeddedFlowComponentType$1["CopyableText"] = "COPYABLE_TEXT";
790
- /** Date input field for selecting a calendar date */
791
- EmbeddedFlowComponentType$1["DateInput"] = "DATE_INPUT";
792
- /** Divider component for visual separation of content */
793
- EmbeddedFlowComponentType$1["Divider"] = "DIVIDER";
794
- /** Email input field with validation for email addresses. */
795
- EmbeddedFlowComponentType$1["EmailInput"] = "EMAIL_INPUT";
796
- /** Icon display component for rendering named vector icons */
797
- EmbeddedFlowComponentType$1["Icon"] = "ICON";
798
- /** Image display component for logos and illustrations */
799
- EmbeddedFlowComponentType$1["Image"] = "IMAGE";
800
- /** One-time password input field for multi-factor authentication */
801
- EmbeddedFlowComponentType$1["OtpInput"] = "OTP_INPUT";
802
- /** Organization unit tree picker for selecting an OU */
803
- EmbeddedFlowComponentType$1["OuSelect"] = "OU_SELECT";
804
- /** Password input field with masking for sensitive data */
805
- EmbeddedFlowComponentType$1["PasswordInput"] = "PASSWORD_INPUT";
806
- /** Phone number input field with country code support */
807
- EmbeddedFlowComponentType$1["PhoneInput"] = "PHONE_INPUT";
808
- /** Rich text display component that renders formatted HTML content */
809
- EmbeddedFlowComponentType$1["RichText"] = "RICH_TEXT";
810
- /** Select/dropdown input component for single choice selection */
811
- EmbeddedFlowComponentType$1["Select"] = "SELECT";
812
- /** Stack layout component for arranging children in a row or column */
813
- EmbeddedFlowComponentType$1["Stack"] = "STACK";
814
- /** Text display component for labels, headings, and messages */
815
- EmbeddedFlowComponentType$1["Text"] = "TEXT";
816
- /** Standard text input field for user data entry */
817
- EmbeddedFlowComponentType$1["TextInput"] = "TEXT_INPUT";
818
- /** Timer component for displaying a countdown */
819
- EmbeddedFlowComponentType$1["Timer"] = "TIMER";
820
- /** QR code display component for wallet-based flows (e.g. OpenID4VP) */
821
- EmbeddedFlowComponentType$1["QrCode"] = "QR_CODE";
822
- return EmbeddedFlowComponentType$1;
823
- }({});
675
+ const configure = (config) => logger.configure(config);
824
676
  /**
825
- * Action variant types for buttons and interactive elements.
826
- *
827
- * @experimental This API may change in future versions
677
+ * Create component-specific loggers
828
678
  */
829
- let EmbeddedFlowActionVariant = /* @__PURE__ */ function(EmbeddedFlowActionVariant$1) {
830
- /** Danger action button for destructive operations */
831
- EmbeddedFlowActionVariant$1["Danger"] = "DANGER";
832
- /** Info action button for informational purposes */
833
- EmbeddedFlowActionVariant$1["Info"] = "INFO";
834
- /** Link-styled action button */
835
- EmbeddedFlowActionVariant$1["Link"] = "LINK";
836
- /** Outlined action button for secondary emphasis */
837
- EmbeddedFlowActionVariant$1["Outlined"] = "OUTLINED";
838
- /** Primary action button with highest visual emphasis */
839
- EmbeddedFlowActionVariant$1["Primary"] = "PRIMARY";
840
- /** Secondary action button with moderate visual emphasis */
841
- EmbeddedFlowActionVariant$1["Secondary"] = "SECONDARY";
842
- /** Success action button for positive confirmations */
843
- EmbeddedFlowActionVariant$1["Success"] = "SUCCESS";
844
- /** Tertiary action button with minimal visual emphasis */
845
- EmbeddedFlowActionVariant$1["Tertiary"] = "TERTIARY";
846
- /** Warning action button for cautionary actions */
847
- EmbeddedFlowActionVariant$1["Warning"] = "WARNING";
848
- return EmbeddedFlowActionVariant$1;
849
- }({});
679
+ const createComponentLogger = (component) => logger.child(component);
850
680
  /**
851
- * Text variant types for typography components.
852
- *
853
- * @experimental This API may change in future versions
681
+ * Create package-specific logger
854
682
  */
855
- let EmbeddedFlowTextVariant = /* @__PURE__ */ function(EmbeddedFlowTextVariant$1) {
856
- /** Primary body text for main content */
857
- EmbeddedFlowTextVariant$1["Body1"] = "BODY_1";
858
- /** Secondary body text for supplementary content */
859
- EmbeddedFlowTextVariant$1["Body2"] = "BODY_2";
860
- /** Text styled for button labels */
861
- EmbeddedFlowTextVariant$1["ButtonText"] = "BUTTON_TEXT";
862
- /** Small caption text for annotations and descriptions */
863
- EmbeddedFlowTextVariant$1["Caption"] = "CAPTION";
864
- /** Largest heading level for main titles */
865
- EmbeddedFlowTextVariant$1["Heading1"] = "HEADING_1";
866
- /** Second level heading for major sections */
867
- EmbeddedFlowTextVariant$1["Heading2"] = "HEADING_2";
868
- /** Third level heading for subsections */
869
- EmbeddedFlowTextVariant$1["Heading3"] = "HEADING_3";
870
- /** Fourth level heading for minor sections */
871
- EmbeddedFlowTextVariant$1["Heading4"] = "HEADING_4";
872
- /** Fifth level heading for detailed sections */
873
- EmbeddedFlowTextVariant$1["Heading5"] = "HEADING_5";
874
- /** Smallest heading level for fine-grained sections */
875
- EmbeddedFlowTextVariant$1["Heading6"] = "HEADING_6";
876
- /** Overline text for labels and categories */
877
- EmbeddedFlowTextVariant$1["Overline"] = "OVERLINE";
878
- /** Primary subtitle text with larger emphasis */
879
- EmbeddedFlowTextVariant$1["Subtitle1"] = "SUBTITLE_1";
880
- /** Secondary subtitle text with moderate emphasis */
881
- EmbeddedFlowTextVariant$1["Subtitle2"] = "SUBTITLE_2";
882
- return EmbeddedFlowTextVariant$1;
883
- }({});
683
+ const createPackageLogger = (packageName) => createLogger({
684
+ level: "info",
685
+ prefix: `${PREFIX} - ${packageName}`,
686
+ showLevel: true,
687
+ timestamps: true
688
+ });
884
689
  /**
885
- * Event types for action components.
886
- *
887
- * @experimental This API may change in future versions
690
+ * Create package component logger (package + component)
888
691
  */
889
- let EmbeddedFlowEventType = /* @__PURE__ */ function(EmbeddedFlowEventType$1) {
890
- /** Navigate back to the previous step */
891
- EmbeddedFlowEventType$1["Back"] = "BACK";
892
- /** Cancel the current operation */
893
- EmbeddedFlowEventType$1["Cancel"] = "CANCEL";
894
- /** Navigate to a different flow step or page */
895
- EmbeddedFlowEventType$1["Navigate"] = "NAVIGATE";
896
- /** Reset form fields to initial state */
897
- EmbeddedFlowEventType$1["Reset"] = "RESET";
898
- /** Submit form data to the server */
899
- EmbeddedFlowEventType$1["Submit"] = "SUBMIT";
900
- /** Trigger an action or event */
901
- EmbeddedFlowEventType$1["Trigger"] = "TRIGGER";
902
- return EmbeddedFlowEventType$1;
903
- }({});
692
+ const createPackageComponentLogger = (packageName, component) => {
693
+ return createPackageLogger(packageName).child(component);
694
+ };
904
695
 
905
696
  //#endregion
906
- //#region src/api/executeEmbeddedUserOnboardingFlow.ts
907
- /**
908
- * Executes an embedded user onboarding flow by sending a request to the flow execution endpoint.
909
- *
910
- * This function handles both:
911
- * - Admin flow: Initiates onboarding, collects user details, generates invite link
912
- * - End-user flow: Validates invite token and allows password setting
913
- *
914
- * @param requestConfig - Request configuration object containing URL, payload, and optional auth token.
915
- * @returns A promise that resolves with the flow execution response.
916
- * @throws ThunderIDAPIError when the request fails or URL is invalid.
917
- *
918
- * @example
919
- * ```typescript
920
- * // Admin initiating user onboarding (requires auth token)
921
- * const response = await executeEmbeddedUserOnboardingFlow({
922
- * baseUrl: "https://api.thunder.io",
923
- * payload: {
924
- * flowType: "USER_ONBOARDING"
925
- * },
926
- * headers: {
927
- * Authorization: `Bearer ${accessToken}`
928
- * }
929
- * });
930
- *
931
- * // End-user accepting invite (no auth required)
932
- * const response = await executeEmbeddedUserOnboardingFlow({
933
- * baseUrl: "https://api.thunder.io",
934
- * payload: {
935
- * executionId: "flow-id-from-url",
936
- * inputs: { inviteToken: "token-from-url" }
937
- * }
938
- * });
939
- * ```
940
- */
941
- const executeEmbeddedUserOnboardingFlow = async ({ url, baseUrl, payload,...requestConfig }) => {
942
- if (!payload) throw new ThunderIDAPIError("User onboarding payload is required", "executeEmbeddedUserOnboardingFlow-ValidationError-002", "javascript", 400, "If a user onboarding payload is not provided, the request cannot be constructed correctly.");
943
- const endpoint = url ?? `${baseUrl}/flow/execute`;
944
- const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
945
- const hasOnlyFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 1;
946
- const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
947
- const hasFlowIdWithInputs = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && "inputs" in cleanPayload;
948
- const requestPayload = hasOnlyFlowType || hasOnlyFlowId || hasFlowIdWithInputs ? {
949
- ...cleanPayload,
950
- verbose: true
951
- } : cleanPayload;
952
- if ("flowType" in requestPayload && requestPayload["flowType"] !== EmbeddedFlowType.UserOnboarding) requestPayload["flowType"] = EmbeddedFlowType.UserOnboarding;
953
- const response = await fetch(endpoint, {
954
- ...requestConfig,
955
- body: JSON.stringify(requestPayload),
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",
956
709
  headers: {
957
710
  Accept: "application/json",
958
711
  "Content-Type": "application/json",
959
- ...requestConfig.headers
712
+ ...headers
960
713
  },
961
- method: requestConfig.method || "POST"
714
+ method: "POST"
962
715
  });
963
- if (!response.ok) throw new ThunderIDAPIError(await response.text(), "executeEmbeddedUserOnboardingFlow-ResponseError-001", "javascript", response.status, response.statusText, "User onboarding request failed");
964
- return await response.json();
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();
965
722
  };
966
- var executeEmbeddedUserOnboardingFlow_default = executeEmbeddedUserOnboardingFlow;
967
-
968
- //#endregion
969
- //#region src/api/getFlowMeta.ts
970
- /**
971
- * Fetches aggregated flow metadata from the `GET /flow/meta` endpoint.
972
- *
973
- * The response includes:
974
- * - Application or OU details depending on the `type` parameter
975
- * - Resolved design configuration (theme and layout)
976
- * - i18n translations filtered by `language` and `namespace`
977
- * - Registration flow enablement status
978
- *
979
- * @param config - Request configuration including `baseUrl`/`url`, and optional
980
- * `type`, `id`, `language`, and `namespace` filters. When `type`
981
- * and `id` are omitted the server returns i18n-only metadata.
982
- * @returns A promise that resolves to the {@link FlowMetadataResponse}.
983
- *
984
- * @throws {ThunderIDAPIError} When the server returns a non-OK response.
985
- *
986
- * @example
987
- * ```typescript
988
- * import getFlowMeta from './api/getFlowMeta';
989
- * import { FlowMetaType } from './models/flow-meta';
990
- *
991
- * const meta = await getFlowMeta({
992
- * baseUrl: 'https://localhost:8090',
993
- * type: FlowMetaType.App,
994
- * id: '60a9b38b-6eba-9f9e-55f9-267067de4680',
995
- * language: 'en',
996
- * namespace: 'auth',
997
- * });
998
- *
999
- * console.log(meta.application?.name);
1000
- * console.log(meta.i18n.translations);
1001
- * ```
1002
- *
1003
- * @experimental This function targets the ThunderID V2 platform API
1004
- */
1005
- const getFlowMeta = async ({ url, baseUrl, type, id, language, namespace,...requestConfig }) => {
1006
- const queryParams = new URLSearchParams({
1007
- ...id ? { id } : {},
1008
- ...type ? { type } : {},
1009
- ...language ? { language } : {},
1010
- ...namespace ? { namespace } : {}
1011
- });
1012
- const endpoint = `${url ?? `${baseUrl}/flow/meta`}?${queryParams.toString()}`;
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;
1013
745
  const response = await fetch(endpoint, {
1014
746
  ...requestConfig,
747
+ body: JSON.stringify(requestPayload),
1015
748
  headers: {
1016
749
  Accept: "application/json",
750
+ "Content-Type": "application/json",
751
+ ...isNewFlowStart && flowSecret ? { "Flow-Secret": flowSecret } : {},
1017
752
  ...requestConfig.headers
1018
753
  },
1019
- method: "GET"
754
+ method: requestConfig.method || "POST"
1020
755
  });
1021
- if (!response.ok) throw new ThunderIDAPIError(await response.text(), "getFlowMeta-ResponseError-001", "javascript", response.status, response.statusText, "Flow metadata request failed");
1022
- return await response.json();
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;
1023
778
  };
1024
- var getFlowMeta_default = getFlowMeta;
779
+ var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
1025
780
 
1026
781
  //#endregion
1027
- //#region src/api/getOrganizationUnitChildren.ts
782
+ //#region src/models/embedded-signup-flow.ts
1028
783
  /**
1029
- * Retrieves the child organization units of a given organization unit.
784
+ * Status enumeration for ThunderID embedded sign-up flow operations.
1030
785
  *
1031
- * @param config - Request configuration object.
1032
- * @returns A promise that resolves with the list of child organization units.
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
1033
808
  */
1034
- const getOrganizationUnitChildren = async ({ url, baseUrl, organizationUnitId, limit, offset, fetcher,...requestConfig }) => {
1035
- try {
1036
- new URL(url ?? baseUrl);
1037
- } catch (error$1) {
1038
- throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "getOrganizationUnitChildren-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1039
- }
1040
- const fetchFn = fetcher || fetch;
1041
- const queryParams = new URLSearchParams();
1042
- if (limit !== void 0) queryParams.set("limit", String(limit));
1043
- if (offset !== void 0) queryParams.set("offset", String(offset));
1044
- const query = queryParams.toString();
1045
- const resolvedBase = url ?? `${baseUrl}/api/server/v1/organization-units/${organizationUnitId}/children`;
1046
- const resolvedUrl = query ? `${resolvedBase}?${query}` : resolvedBase;
1047
- const requestInit = {
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, {
1048
882
  ...requestConfig,
883
+ body: JSON.stringify(requestPayload),
1049
884
  headers: {
1050
885
  Accept: "application/json",
1051
886
  "Content-Type": "application/json",
1052
887
  ...requestConfig.headers
1053
888
  },
1054
- method: "GET"
1055
- };
1056
- try {
1057
- const response = await fetchFn(resolvedUrl, requestInit);
1058
- if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getOrganizationUnitChildren-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch organization unit children");
1059
- return await response.json();
1060
- } catch (error$1) {
1061
- if (error$1 instanceof ThunderIDAPIError) throw error$1;
1062
- throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getOrganizationUnitChildren-NetworkError-001", "javascript", 0, "Network Error");
1063
- }
1064
- };
1065
- var getOrganizationUnitChildren_default = getOrganizationUnitChildren;
1066
-
1067
- //#endregion
1068
- //#region src/api/getUserInfo.ts
1069
- /**
1070
- * Retrieves the user information from the specified OIDC userinfo endpoint.
1071
- *
1072
- * @param requestConfig - Request configuration object.
1073
- * @returns A promise that resolves with the user information.
1074
- * @throw
1075
- * const userInfo = await getUserInfo({
1076
- * url: "https://localhost:8090/oauth2/userinfo",
1077
- * });
1078
- * console.log(userInfo);
1079
- * } catch (error) {
1080
- * if (error instanceof ThunderIDAPIError) {
1081
- * console.error('Failed to get user info:', error.message);
1082
- * }
1083
- * }
1084
- * ```
1085
- */
1086
- const getUserInfo = async ({ url,...requestConfig }) => {
1087
- try {
1088
- new URL(url);
1089
- } catch (error$1) {
1090
- throw new ThunderIDAPIError("Invalid endpoint URL provided", "getUserInfo-ValidationError-001", "javascript", 400, "Invalid Request");
1091
- }
1092
- try {
1093
- const response = await fetch(url, {
1094
- ...requestConfig,
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,
897
+ authId
898
+ }),
899
+ credentials: "include",
1095
900
  headers: {
1096
901
  Accept: "application/json",
1097
902
  "Content-Type": "application/json",
1098
903
  ...requestConfig.headers
1099
904
  },
1100
- method: "GET"
905
+ method: "POST"
1101
906
  });
1102
- if (!response.ok) throw new ThunderIDAPIError(await response.text(), "getUserInfo-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch user info");
1103
- return await response.json();
1104
- } catch (error$1) {
1105
- if (error$1 instanceof ThunderIDAPIError) throw error$1;
1106
- throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getUserInfo-NetworkError-001", "javascript", 0, "Network Error");
1107
- }
1108
- };
1109
- var getUserInfo_default = getUserInfo;
1110
-
1111
- //#endregion
1112
- //#region src/utils/processUsername.ts
1113
- /**
1114
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1115
- *
1116
- * WSO2 LLC. licenses this file to you under the Apache License,
1117
- * Version 2.0 (the "License"); you may not use this file except
1118
- * in compliance with the License.
1119
- * You may obtain a copy of the License at
1120
- *
1121
- * http://www.apache.org/licenses/LICENSE-2.0
1122
- *
1123
- * Unless required by applicable law or agreed to in writing,
1124
- * software distributed under the License is distributed on an
1125
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1126
- * KIND, either express or implied. See the License for the
1127
- * specific language governing permissions and limitations
1128
- * under the License.
1129
- */
1130
- /**
1131
- * Regular expression to match userstore prefixes in usernames.
1132
- * Matches patterns like "DEFAULT/", "ASGARDEO_USER/", "PRIMARY/", etc.
1133
- * The pattern matches any uppercase letters, numbers, and underscores followed by a forward slash.
1134
- */
1135
- const USERSTORE_PREFIX_REGEX = /^[A-Z_][A-Z0-9_]*\//;
1136
- /**
1137
- * Removes userstore prefixes from a username if they exist.
1138
- * This is commonly used to clean usernames returned from profile endpoints
1139
- * that include userstore prefixes like "DEFAULT/", "ASGARDEO_USER/", "PRIMARY/", etc.
1140
- *
1141
- * @param username - The username string to process
1142
- * @returns The username without the userstore prefix, or the original username if no prefix exists
1143
- *
1144
- * @example
1145
- * ```typescript
1146
- * const cleanUsername = removeUserstorePrefix("DEFAULT/john.doe");
1147
- * console.log(cleanUsername); // "john.doe"
1148
- *
1149
- * const thunderidUser = removeUserstorePrefix("ASGARDEO_USER/jane.doe");
1150
- * console.log(thunderidUser); // "jane.doe"
1151
- *
1152
- * const primaryUser = removeUserstorePrefix("PRIMARY/admin");
1153
- * console.log(primaryUser); // "admin"
1154
- *
1155
- * const alreadyClean = removeUserstorePrefix("user.name");
1156
- * console.log(alreadyClean); // "user.name"
1157
- *
1158
- * const emptyInput = removeUserstorePrefix("");
1159
- * console.log(emptyInput); // ""
1160
- * ```
1161
- */
1162
- const removeUserstorePrefix = (username) => {
1163
- if (!username) return "";
1164
- return username.replace(USERSTORE_PREFIX_REGEX, "");
907
+ if (!oauth2Response.ok) throw new ThunderIDAPIError(await oauth2Response.text(), "executeEmbeddedSignUpFlow-OAuth2Error-002", "javascript", oauth2Response.status, oauth2Response.statusText, "OAuth2 authorization failed");
908
+ const oauth2Result = await oauth2Response.json();
909
+ return {
910
+ flowStatus: flowResponse.flowStatus,
911
+ redirectUrl: oauth2Result["redirect_uri"]
912
+ };
913
+ } catch (authError) {
914
+ if (authError instanceof ThunderIDAPIError) throw authError;
915
+ throw new ThunderIDAPIError(authError instanceof Error ? authError.message : "Unknown error", "executeEmbeddedSignUpFlow-OAuth2Error-001", "javascript", 500, "Failed to complete OAuth2 authorization after successful embedded sign-up flow.", "OAuth2 authorization failed");
916
+ }
917
+ return flowResponse;
1165
918
  };
919
+ var executeEmbeddedSignUpFlow_default = executeEmbeddedSignUpFlow;
920
+
921
+ //#endregion
922
+ //#region src/api/executeEmbeddedRecoveryFlow.ts
1166
923
  /**
1167
- * Processes a user object to remove userstore prefixes from username fields.
1168
- * This is a helper function for processing user objects returned from profile endpoints.
1169
- * Handles various username field variations: username, userName, and user_name.
924
+ * Executes an embedded recovery flow by sending a request to the flow execution endpoint.
1170
925
  *
1171
- * @param user - The user object to process
1172
- * @returns The user object with processed username fields
926
+ * This function handles password-recovery and account-recovery flows driven by the
927
+ * ThunderID server. The server returns UI components for each step (e.g. username
928
+ * collection, OTP verification, password reset) and this function forwards the
929
+ * user's responses back to the server.
930
+ *
931
+ * @param requestConfig - Request configuration containing URL, payload, and optional headers.
932
+ * @returns A promise that resolves with the flow execution response.
933
+ * @throws ThunderIDAPIError when the request fails or a payload is missing.
1173
934
  *
1174
935
  * @example
1175
936
  * ```typescript
1176
- * const user = { username: "DEFAULT/john.doe", email: "john@example.com" };
1177
- * const processedUser = processUserUsername(user);
1178
- * console.log(processedUser.username); // "john.doe"
1179
- *
1180
- * const camelCaseUser = { userName: "ASGARDEO_USER/jane.doe", email: "jane@example.com" };
1181
- * const processedCamelCaseUser = processUserUsername(camelCaseUser);
1182
- * console.log(processedCamelCaseUser.userName); // "jane.doe"
937
+ * // Initiate recovery flow
938
+ * const response = await executeEmbeddedRecoveryFlow({
939
+ * baseUrl: 'https://localhost:8090',
940
+ * payload: {
941
+ * flowType: 'RECOVERY',
942
+ * applicationId: 'my-app-id',
943
+ * },
944
+ * });
1183
945
  *
1184
- * const snakeCaseUser = { user_name: "PRIMARY/admin", email: "admin@example.com" };
1185
- * const processedSnakeCaseUser = processUserUsername(snakeCaseUser);
1186
- * console.log(processedSnakeCaseUser.user_name); // "admin"
946
+ * // Continue recovery flow with user input
947
+ * const nextResponse = await executeEmbeddedRecoveryFlow({
948
+ * baseUrl: 'https://localhost:8090',
949
+ * payload: {
950
+ * executionId: response.executionId,
951
+ * action: 'submit',
952
+ * inputs: { username: 'user@example.com' },
953
+ * challengeToken: response.challengeToken,
954
+ * },
955
+ * });
1187
956
  * ```
1188
957
  */
1189
- const processUsername = (user) => {
1190
- if (!user) return user;
1191
- const processedUser = { ...user };
1192
- if (processedUser.username) processedUser.username = removeUserstorePrefix(processedUser.username);
1193
- if (processedUser.userName) processedUser.userName = removeUserstorePrefix(processedUser.userName);
1194
- if (processedUser.user_name) processedUser.user_name = removeUserstorePrefix(processedUser.user_name);
1195
- return processedUser;
958
+ const executeEmbeddedRecoveryFlow = async ({ url, baseUrl, payload,...requestConfig }) => {
959
+ if (!payload) throw new ThunderIDAPIError("Recovery payload is required", "executeEmbeddedRecoveryFlow-ValidationError-002", "javascript", 400, "If a recovery payload is not provided, the request cannot be constructed correctly.");
960
+ const endpoint = url ?? `${baseUrl}/flow/execute`;
961
+ const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
962
+ const hasOnlyAppIdAndFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 2;
963
+ const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
964
+ const requestPayload = hasOnlyAppIdAndFlowType || hasOnlyFlowId ? {
965
+ ...cleanPayload,
966
+ verbose: true
967
+ } : cleanPayload;
968
+ const response = await fetch(endpoint, {
969
+ ...requestConfig,
970
+ body: JSON.stringify(requestPayload),
971
+ headers: {
972
+ Accept: "application/json",
973
+ "Content-Type": "application/json",
974
+ ...requestConfig.headers
975
+ },
976
+ method: requestConfig.method || "POST"
977
+ });
978
+ if (!response.ok) throw new ThunderIDAPIError(await response.text(), "executeEmbeddedRecoveryFlow-ResponseError-001", "javascript", response.status, response.statusText, "Recovery request failed");
979
+ return await response.json();
1196
980
  };
1197
- var processUsername_default = processUsername;
981
+ var executeEmbeddedRecoveryFlow_default = executeEmbeddedRecoveryFlow;
1198
982
 
1199
983
  //#endregion
1200
- //#region src/api/getUsersMe.ts
984
+ //#region src/models/embedded-flow.ts
985
+ let EmbeddedFlowType = /* @__PURE__ */ function(EmbeddedFlowType$1) {
986
+ EmbeddedFlowType$1["Authentication"] = "AUTHENTICATION";
987
+ EmbeddedFlowType$1["Recovery"] = "RECOVERY";
988
+ EmbeddedFlowType$1["Registration"] = "REGISTRATION";
989
+ EmbeddedFlowType$1["UserOnboarding"] = "USER_ONBOARDING";
990
+ return EmbeddedFlowType$1;
991
+ }({});
992
+ let EmbeddedFlowResponseType = /* @__PURE__ */ function(EmbeddedFlowResponseType$1) {
993
+ EmbeddedFlowResponseType$1["Redirection"] = "REDIRECTION";
994
+ EmbeddedFlowResponseType$1["View"] = "VIEW";
995
+ return EmbeddedFlowResponseType$1;
996
+ }({});
1201
997
  /**
1202
- * Retrieves the user profile information from the specified /users/me endpoint.
998
+ * Component types supported by the ThunderID embedded flow API.
1203
999
  *
1204
- * @param config - Request configuration object.
1205
- * @returns A promise that resolves with the user profile information.
1206
- * @example
1207
- * ```typescript
1208
- * // Using default fetch
1209
- * try {
1210
- * const userProfile = await getUsersMe({
1211
- * url: "https://localhost:8090/users/me",
1212
- * });
1213
- * console.log(userProfile);
1214
- * } catch (error) {
1215
- * if (error instanceof ThunderIDAPIError) {
1216
- * console.error('Failed to get user profile:', error.message);
1217
- * }
1218
- * }
1219
- * ```
1000
+ * These types define the different UI components that can be rendered
1001
+ * as part of the embedded authentication flows. Each type corresponds
1002
+ * to a specific UI element with its own behavior and properties.
1220
1003
  *
1221
1004
  * @example
1222
1005
  * ```typescript
1223
- * // Using custom fetcher (e.g., axios-based httpClient)
1224
- * try {
1225
- * const userProfile = await getUsersMe({
1226
- * url: "https://localhost:8090/users/me",
1227
- * fetcher: async (url, config) => {
1228
- * const response = await httpClient({
1229
- * url,
1230
- * method: config.method,
1231
- * headers: config.headers,
1232
- * ...config
1233
- * });
1234
- * // Convert axios-like response to fetch-like Response
1235
- * return {
1236
- * ok: response.status >= 200 && response.status < 300,
1237
- * status: response.status,
1238
- * statusText: response.statusText,
1239
- * json: () => Promise.resolve(response.data),
1240
- * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
1241
- * } as Response;
1242
- * }
1243
- * });
1244
- * console.log(userProfile);
1245
- * } catch (error) {
1246
- * if (error instanceof ThunderIDAPIError) {
1247
- * console.error('Failed to get user profile:', error.message);
1248
- * }
1006
+ * // Check component type to render appropriate UI
1007
+ * if (component.type === EmbeddedFlowComponentType.TextInput) {
1008
+ * // Render text input field
1009
+ * } else if (component.type === EmbeddedFlowComponentType.Action) {
1010
+ * // Render button/action
1249
1011
  * }
1250
1012
  * ```
1013
+ *
1014
+ * @experimental This API may change in future versions
1015
+ */
1016
+ let EmbeddedFlowComponentType = /* @__PURE__ */ function(EmbeddedFlowComponentType$1) {
1017
+ /** Interactive action component (buttons, links) for user interactions */
1018
+ EmbeddedFlowComponentType$1["Action"] = "ACTION";
1019
+ /** Container block component that groups other components */
1020
+ EmbeddedFlowComponentType$1["Block"] = "BLOCK";
1021
+ /** Consent component for displaying consent purposes and attributes */
1022
+ EmbeddedFlowComponentType$1["Consent"] = "CONSENT";
1023
+ /** Copyable text display component that shows text with a copy-to-clipboard action */
1024
+ EmbeddedFlowComponentType$1["CopyableText"] = "COPYABLE_TEXT";
1025
+ /** Date input field for selecting a calendar date */
1026
+ EmbeddedFlowComponentType$1["DateInput"] = "DATE_INPUT";
1027
+ /** Divider component for visual separation of content */
1028
+ EmbeddedFlowComponentType$1["Divider"] = "DIVIDER";
1029
+ /** Email input field with validation for email addresses. */
1030
+ EmbeddedFlowComponentType$1["EmailInput"] = "EMAIL_INPUT";
1031
+ /** Icon display component for rendering named vector icons */
1032
+ EmbeddedFlowComponentType$1["Icon"] = "ICON";
1033
+ /** Image display component for logos and illustrations */
1034
+ EmbeddedFlowComponentType$1["Image"] = "IMAGE";
1035
+ /** One-time password input field for multi-factor authentication */
1036
+ EmbeddedFlowComponentType$1["OtpInput"] = "OTP_INPUT";
1037
+ /** Organization unit tree picker for selecting an OU */
1038
+ EmbeddedFlowComponentType$1["OuSelect"] = "OU_SELECT";
1039
+ /** Password input field with masking for sensitive data */
1040
+ EmbeddedFlowComponentType$1["PasswordInput"] = "PASSWORD_INPUT";
1041
+ /** Phone number input field with country code support */
1042
+ EmbeddedFlowComponentType$1["PhoneInput"] = "PHONE_INPUT";
1043
+ /** Rich text display component that renders formatted HTML content */
1044
+ EmbeddedFlowComponentType$1["RichText"] = "RICH_TEXT";
1045
+ /** Select/dropdown input component for single choice selection */
1046
+ EmbeddedFlowComponentType$1["Select"] = "SELECT";
1047
+ /** Stack layout component for arranging children in a row or column */
1048
+ EmbeddedFlowComponentType$1["Stack"] = "STACK";
1049
+ /** Text display component for labels, headings, and messages */
1050
+ EmbeddedFlowComponentType$1["Text"] = "TEXT";
1051
+ /** Standard text input field for user data entry */
1052
+ EmbeddedFlowComponentType$1["TextInput"] = "TEXT_INPUT";
1053
+ /** Timer component for displaying a countdown */
1054
+ EmbeddedFlowComponentType$1["Timer"] = "TIMER";
1055
+ /** QR code display component for wallet-based flows (e.g. OpenID4VP) */
1056
+ EmbeddedFlowComponentType$1["QrCode"] = "QR_CODE";
1057
+ return EmbeddedFlowComponentType$1;
1058
+ }({});
1059
+ /**
1060
+ * Action variant types for buttons and interactive elements.
1061
+ *
1062
+ * @experimental This API may change in future versions
1063
+ */
1064
+ let EmbeddedFlowActionVariant = /* @__PURE__ */ function(EmbeddedFlowActionVariant$1) {
1065
+ /** Danger action button for destructive operations */
1066
+ EmbeddedFlowActionVariant$1["Danger"] = "DANGER";
1067
+ /** Info action button for informational purposes */
1068
+ EmbeddedFlowActionVariant$1["Info"] = "INFO";
1069
+ /** Link-styled action button */
1070
+ EmbeddedFlowActionVariant$1["Link"] = "LINK";
1071
+ /** Outlined action button for secondary emphasis */
1072
+ EmbeddedFlowActionVariant$1["Outlined"] = "OUTLINED";
1073
+ /** Primary action button with highest visual emphasis */
1074
+ EmbeddedFlowActionVariant$1["Primary"] = "PRIMARY";
1075
+ /** Secondary action button with moderate visual emphasis */
1076
+ EmbeddedFlowActionVariant$1["Secondary"] = "SECONDARY";
1077
+ /** Success action button for positive confirmations */
1078
+ EmbeddedFlowActionVariant$1["Success"] = "SUCCESS";
1079
+ /** Tertiary action button with minimal visual emphasis */
1080
+ EmbeddedFlowActionVariant$1["Tertiary"] = "TERTIARY";
1081
+ /** Warning action button for cautionary actions */
1082
+ EmbeddedFlowActionVariant$1["Warning"] = "WARNING";
1083
+ return EmbeddedFlowActionVariant$1;
1084
+ }({});
1085
+ /**
1086
+ * Text variant types for typography components.
1087
+ *
1088
+ * @experimental This API may change in future versions
1089
+ */
1090
+ let EmbeddedFlowTextVariant = /* @__PURE__ */ function(EmbeddedFlowTextVariant$1) {
1091
+ /** Primary body text for main content */
1092
+ EmbeddedFlowTextVariant$1["Body1"] = "BODY_1";
1093
+ /** Secondary body text for supplementary content */
1094
+ EmbeddedFlowTextVariant$1["Body2"] = "BODY_2";
1095
+ /** Text styled for button labels */
1096
+ EmbeddedFlowTextVariant$1["ButtonText"] = "BUTTON_TEXT";
1097
+ /** Small caption text for annotations and descriptions */
1098
+ EmbeddedFlowTextVariant$1["Caption"] = "CAPTION";
1099
+ /** Largest heading level for main titles */
1100
+ EmbeddedFlowTextVariant$1["Heading1"] = "HEADING_1";
1101
+ /** Second level heading for major sections */
1102
+ EmbeddedFlowTextVariant$1["Heading2"] = "HEADING_2";
1103
+ /** Third level heading for subsections */
1104
+ EmbeddedFlowTextVariant$1["Heading3"] = "HEADING_3";
1105
+ /** Fourth level heading for minor sections */
1106
+ EmbeddedFlowTextVariant$1["Heading4"] = "HEADING_4";
1107
+ /** Fifth level heading for detailed sections */
1108
+ EmbeddedFlowTextVariant$1["Heading5"] = "HEADING_5";
1109
+ /** Smallest heading level for fine-grained sections */
1110
+ EmbeddedFlowTextVariant$1["Heading6"] = "HEADING_6";
1111
+ /** Overline text for labels and categories */
1112
+ EmbeddedFlowTextVariant$1["Overline"] = "OVERLINE";
1113
+ /** Primary subtitle text with larger emphasis */
1114
+ EmbeddedFlowTextVariant$1["Subtitle1"] = "SUBTITLE_1";
1115
+ /** Secondary subtitle text with moderate emphasis */
1116
+ EmbeddedFlowTextVariant$1["Subtitle2"] = "SUBTITLE_2";
1117
+ return EmbeddedFlowTextVariant$1;
1118
+ }({});
1119
+ /**
1120
+ * Event types for action components.
1121
+ *
1122
+ * @experimental This API may change in future versions
1251
1123
  */
1252
- const getUsersMe = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1253
- try {
1254
- new URL(url ?? baseUrl);
1255
- } catch (error$1) {
1256
- throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "getUsersMe-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1257
- }
1258
- const fetchFn = fetcher || fetch;
1259
- const resolvedUrl = url ?? `${baseUrl}/users/me`;
1260
- const requestInit = {
1261
- ...requestConfig,
1262
- headers: {
1263
- Accept: "application/json",
1264
- "Content-Type": "application/json",
1265
- ...requestConfig.headers
1266
- },
1267
- method: "GET"
1268
- };
1269
- try {
1270
- const response = await fetchFn(resolvedUrl, requestInit);
1271
- if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getUsersMe-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch user profile");
1272
- const user = await response.json();
1273
- const attributes = user["attributes"] ?? {};
1274
- return processUsername_default({
1275
- ...user,
1276
- ...attributes
1277
- });
1278
- } catch (error$1) {
1279
- if (error$1 instanceof ThunderIDAPIError) throw error$1;
1280
- throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getUsersMe-NetworkError-001", "javascript", 0, "Network Error");
1281
- }
1282
- };
1283
- var getUsersMe_default = getUsersMe;
1124
+ let EmbeddedFlowEventType = /* @__PURE__ */ function(EmbeddedFlowEventType$1) {
1125
+ /** Navigate back to the previous step */
1126
+ EmbeddedFlowEventType$1["Back"] = "BACK";
1127
+ /** Cancel the current operation */
1128
+ EmbeddedFlowEventType$1["Cancel"] = "CANCEL";
1129
+ /** Navigate to a different flow step or page */
1130
+ EmbeddedFlowEventType$1["Navigate"] = "NAVIGATE";
1131
+ /** Reset form fields to initial state */
1132
+ EmbeddedFlowEventType$1["Reset"] = "RESET";
1133
+ /** Submit form data to the server */
1134
+ EmbeddedFlowEventType$1["Submit"] = "SUBMIT";
1135
+ /** Trigger an action or event */
1136
+ EmbeddedFlowEventType$1["Trigger"] = "TRIGGER";
1137
+ return EmbeddedFlowEventType$1;
1138
+ }({});
1284
1139
 
1285
1140
  //#endregion
1286
- //#region src/api/updateMeProfile.ts
1141
+ //#region src/api/executeEmbeddedUserOnboardingFlow.ts
1287
1142
  /**
1288
- * Updates the user profile information at the specified /users/me endpoint.
1143
+ * Executes an embedded user onboarding flow by sending a request to the flow execution endpoint.
1144
+ *
1145
+ * This function handles both:
1146
+ * - Admin flow: Initiates onboarding, collects user details, generates invite link
1147
+ * - End-user flow: Validates invite token and allows password setting
1148
+ *
1149
+ * @param requestConfig - Request configuration object containing URL, payload, and optional auth token.
1150
+ * @returns A promise that resolves with the flow execution response.
1151
+ * @throws ThunderIDAPIError when the request fails or URL is invalid.
1289
1152
  *
1290
- * @param config - Configuration object with URL, payload and optional request config.
1291
- * @returns A promise that resolves with the updated user profile information.
1292
1153
  * @example
1293
1154
  * ```typescript
1294
- * // Using default fetch
1295
- * await updateMeProfile({
1296
- * url: "https://localhost:8090/users/me",
1297
- * payload: { mobileNumbers: ["0777933830"] }
1155
+ * // Admin initiating user onboarding (requires auth token)
1156
+ * const response = await executeEmbeddedUserOnboardingFlow({
1157
+ * baseUrl: "https://api.thunder.io",
1158
+ * payload: {
1159
+ * flowType: "USER_ONBOARDING"
1160
+ * },
1161
+ * headers: {
1162
+ * Authorization: `Bearer ${accessToken}`
1163
+ * }
1298
1164
  * });
1299
- * ```
1300
1165
  *
1301
- * @example
1302
- * ```typescript
1303
- * // Using custom fetcher (e.g., axios-based httpClient)
1304
- * await updateMeProfile({
1305
- * url: "https://localhost:8090/users/me",
1306
- * payload: { mobileNumbers: ["0777933830"] },
1307
- * fetcher: async (url, config) => {
1308
- * const response = await httpClient({
1309
- * url,
1310
- * method: config.method,
1311
- * headers: config.headers,
1312
- * data: config.body,
1313
- * ...config
1314
- * });
1315
- * // Convert axios-like response to fetch-like Response
1316
- * return {
1317
- * ok: response.status >= 200 && response.status < 300,
1318
- * status: response.status,
1319
- * statusText: response.statusText,
1320
- * json: () => Promise.resolve(response.data),
1321
- * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
1322
- * } as Response;
1166
+ * // End-user accepting invite (no auth required)
1167
+ * const response = await executeEmbeddedUserOnboardingFlow({
1168
+ * baseUrl: "https://api.thunder.io",
1169
+ * payload: {
1170
+ * executionId: "flow-id-from-url",
1171
+ * inputs: { inviteToken: "token-from-url" }
1323
1172
  * }
1324
1173
  * });
1325
1174
  * ```
1326
1175
  */
1327
- const updateMeProfile = async ({ url, baseUrl, payload, fetcher,...requestConfig }) => {
1328
- try {
1329
- new URL(url ?? baseUrl);
1330
- } catch (error$1) {
1331
- throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "updateMeProfile-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1332
- }
1333
- const data = { attributes: payload };
1334
- const fetchFn = fetcher || fetch;
1335
- const resolvedUrl = url ?? `${baseUrl}/users/me`;
1336
- const requestInit = {
1176
+ const executeEmbeddedUserOnboardingFlow = async ({ url, baseUrl, payload,...requestConfig }) => {
1177
+ if (!payload) throw new ThunderIDAPIError("User onboarding payload is required", "executeEmbeddedUserOnboardingFlow-ValidationError-002", "javascript", 400, "If a user onboarding payload is not provided, the request cannot be constructed correctly.");
1178
+ const endpoint = url ?? `${baseUrl}/flow/execute`;
1179
+ const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
1180
+ const hasOnlyFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 1;
1181
+ const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && Object.keys(cleanPayload).length === 1;
1182
+ const hasFlowIdWithInputs = typeof cleanPayload === "object" && cleanPayload !== null && "executionId" in cleanPayload && "inputs" in cleanPayload;
1183
+ const requestPayload = hasOnlyFlowType || hasOnlyFlowId || hasFlowIdWithInputs ? {
1184
+ ...cleanPayload,
1185
+ verbose: true
1186
+ } : cleanPayload;
1187
+ if ("flowType" in requestPayload && requestPayload["flowType"] !== EmbeddedFlowType.UserOnboarding) requestPayload["flowType"] = EmbeddedFlowType.UserOnboarding;
1188
+ const response = await fetch(endpoint, {
1337
1189
  ...requestConfig,
1338
- method: "PUT",
1339
- body: JSON.stringify(data),
1190
+ body: JSON.stringify(requestPayload),
1340
1191
  headers: {
1341
- ...requestConfig.headers,
1342
1192
  Accept: "application/json",
1343
- "Content-Type": "application/json"
1344
- }
1345
- };
1346
- try {
1347
- const response = await fetchFn(resolvedUrl, requestInit);
1348
- if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "updateMeProfile-ResponseError-001", "javascript", response.status, response.statusText, "Failed to update user profile");
1349
- const user = await response.json();
1350
- const attributes = user["attributes"] ?? {};
1351
- return processUsername_default({
1352
- ...user,
1353
- ...attributes
1354
- });
1355
- } catch (error$1) {
1356
- if (error$1 instanceof ThunderIDAPIError) throw error$1;
1357
- throw new ThunderIDAPIError(error$1?.response?.data?.detail || "An error occurred while updating the user profile. Please try again.", "updateMeProfile-NetworkError-001", "javascript", error$1?.data?.status, "Network Error");
1358
- }
1193
+ "Content-Type": "application/json",
1194
+ ...requestConfig.headers
1195
+ },
1196
+ method: requestConfig.method || "POST"
1197
+ });
1198
+ if (!response.ok) throw new ThunderIDAPIError(await response.text(), "executeEmbeddedUserOnboardingFlow-ResponseError-001", "javascript", response.status, response.statusText, "User onboarding request failed");
1199
+ return await response.json();
1359
1200
  };
1360
- var updateMeProfile_default = updateMeProfile;
1361
-
1362
- //#endregion
1363
- //#region src/constants/ApplicationNativeAuthenticationConstants.ts
1364
- /**
1365
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1366
- *
1367
- * WSO2 LLC. licenses this file to you under the Apache License,
1368
- * Version 2.0 (the "License"); you may not use this file except
1369
- * in compliance with the License.
1370
- * You may obtain a copy of the License at
1371
- *
1372
- * http://www.apache.org/licenses/LICENSE-2.0
1373
- *
1374
- * Unless required by applicable law or agreed to in writing,
1375
- * software distributed under the License is distributed on an
1376
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1377
- * KIND, either express or implied. See the License for the
1378
- * specific language governing permissions and limitations
1379
- * under the License.
1380
- */
1381
- /**
1382
- * Constants representing Application Native Authentication related configurations and constants.
1383
- */
1384
- const ApplicationNativeAuthenticationConstants = { SupportedAuthenticators: {
1385
- EmailOtp: "ZW1haWwtb3RwLWF1dGhlbnRpY2F0b3I6TE9DQUw",
1386
- Facebook: "RmFjZWJvb2tBdXRoZW50aWNhdG9yOkZhY2Vib29r",
1387
- GitHub: "R2l0aHViQXV0aGVudGljYXRvcjpHaXRIdWI",
1388
- Google: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I6R29vZ2xl",
1389
- IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
1390
- LinkedIn: "TGlua2VkSW5PSURDOkxpbmtlZElu",
1391
- MagicLink: "TWFnaWNMaW5rQXV0aGVudGljYXRvcjpMT0NBTA",
1392
- Microsoft: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6TWljcm9zb2Z0",
1393
- Passkey: "RklET0F1dGhlbnRpY2F0b3I6TE9DQUw",
1394
- PushNotification: "cHVzaC1ub3RpZmljYXRpb24tYXV0aGVudGljYXRvcjpMT0NBTA",
1395
- SignInWithEthereum: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6U2lnbiBJbiBXaXRoIEV0aGVyZXVt",
1396
- SmsOtp: "c21zLW90cC1hdXRoZW50aWNhdG9yOkxPQ0FM",
1397
- Totp: "dG90cDpMT0NBTA",
1398
- UsernamePassword: "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM"
1399
- } };
1400
- var ApplicationNativeAuthenticationConstants_default = ApplicationNativeAuthenticationConstants;
1201
+ var executeEmbeddedUserOnboardingFlow_default = executeEmbeddedUserOnboardingFlow;
1401
1202
 
1402
1203
  //#endregion
1403
- //#region src/constants/ScopeConstants.ts
1204
+ //#region src/api/getFlowMeta.ts
1404
1205
  /**
1405
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1406
- *
1407
- * WSO2 LLC. licenses this file to you under the Apache License,
1408
- * Version 2.0 (the "License"); you may not use this file except
1409
- * in compliance with the License.
1410
- * You may obtain a copy of the License at
1206
+ * Fetches aggregated flow metadata from the `GET /flow/meta` endpoint.
1411
1207
  *
1412
- * http://www.apache.org/licenses/LICENSE-2.0
1208
+ * The response includes:
1209
+ * - Application or OU details depending on the `type` parameter
1210
+ * - Resolved design configuration (theme and layout)
1211
+ * - i18n translations filtered by `language` and `namespace`
1212
+ * - Registration flow enablement status
1413
1213
  *
1414
- * Unless required by applicable law or agreed to in writing,
1415
- * software distributed under the License is distributed on an
1416
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1417
- * KIND, either express or implied. See the License for the
1418
- * specific language governing permissions and limitations
1419
- * under the License.
1420
- */
1421
- /**
1422
- * Constants for OAuth 2.0 and OpenID Connect scopes.
1423
- * These scopes define the level of access that the client application
1424
- * is requesting from the authorization server.
1214
+ * @param config - Request configuration including `baseUrl`/`url`, and optional
1215
+ * `type`, `id`, `language`, and `namespace` filters. When `type`
1216
+ * and `id` are omitted the server returns i18n-only metadata.
1217
+ * @returns A promise that resolves to the {@link FlowMetadataResponse}.
1425
1218
  *
1426
- * @remarks
1427
- * Scopes are space-separated strings that represent different permissions.
1428
- * The 'openid' scope is required for OpenID Connect flows, while other
1429
- * scopes provide access to different resources or user information.
1219
+ * @throws {ThunderIDAPIError} When the server returns a non-OK response.
1430
1220
  *
1431
1221
  * @example
1432
1222
  * ```typescript
1433
- * // Requesting OpenID Connect authentication
1434
- * const scope = [ScopeConstants.OPENID];
1435
- *
1436
- * // Requesting profile information
1437
- * const scopes = [ScopeConstants.OPENID, ScopeConstants.PROFILE];
1438
- * ```
1439
- */
1440
- const ScopeConstants = {
1441
- OPENID: "openid",
1442
- PROFILE: "profile"
1443
- };
1444
- var ScopeConstants_default = ScopeConstants;
1445
-
1446
- //#endregion
1447
- //#region src/constants/OIDCRequestConstants.ts
1448
- /**
1449
- * Constants representing standard OpenID Connect (OIDC) request and response parameters.
1450
- * These parameters are commonly used during authorization, token exchange, and logout flows.
1451
- */
1452
- const OIDCRequestConstants = {
1453
- Params: {
1454
- AUTHORIZATION_CODE: "code",
1455
- SESSION_STATE: "session_state",
1456
- SIGN_OUT_SUCCESS: "sign_out_success",
1457
- STATE: "state"
1458
- },
1459
- SignIn: { Payload: { DEFAULT_SCOPES: [ScopeConstants_default.OPENID, ScopeConstants_default.PROFILE] } },
1460
- SignOut: { Storage: { StorageKeys: { SIGN_OUT_URL: "sign_out_url" } } }
1461
- };
1462
- var OIDCRequestConstants_default = OIDCRequestConstants;
1463
-
1464
- //#endregion
1465
- //#region src/constants/VendorConstants.ts
1466
- /**
1467
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1468
- *
1469
- * WSO2 LLC. licenses this file to you under the Apache License,
1470
- * Version 2.0 (the "License"); you may not use this file except
1471
- * in compliance with the License.
1472
- * You may obtain a copy of the License at
1473
- *
1474
- * http://www.apache.org/licenses/LICENSE-2.0
1223
+ * import getFlowMeta from './api/getFlowMeta';
1224
+ * import { FlowMetaType } from './models/flow-meta';
1475
1225
  *
1476
- * Unless required by applicable law or agreed to in writing,
1477
- * software distributed under the License is distributed on an
1478
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1479
- * KIND, either express or implied. See the License for the
1480
- * specific language governing permissions and limitations
1481
- * under the License.
1482
- */
1483
- /**
1484
- * Constants for vendor-specific configurations.
1485
- * By default, the vendor is inferred as ThunderID.
1226
+ * const meta = await getFlowMeta({
1227
+ * baseUrl: 'https://localhost:8090',
1228
+ * type: FlowMetaType.App,
1229
+ * id: '60a9b38b-6eba-9f9e-55f9-267067de4680',
1230
+ * language: 'en',
1231
+ * namespace: 'auth',
1232
+ * });
1486
1233
  *
1487
- * @example
1488
- * ```typescript
1489
- * // Using the vendor prefix in a URL
1490
- * const apiUrl = `${VendorConstants.VENDOR_PREFIX}/api/v1/resource`;
1234
+ * console.log(meta.application?.name);
1235
+ * console.log(meta.i18n.translations);
1491
1236
  * ```
1237
+ *
1238
+ * @experimental This function targets the ThunderID V2 platform API
1492
1239
  */
1493
- const VendorConstants = { VENDOR_PREFIX: "thunderid" };
1494
- var VendorConstants_default = VendorConstants;
1240
+ const getFlowMeta = async ({ url, baseUrl, type, id, language, namespace,...requestConfig }) => {
1241
+ const queryParams = new URLSearchParams({
1242
+ ...id ? { id } : {},
1243
+ ...type ? { type } : {},
1244
+ ...language ? { language } : {},
1245
+ ...namespace ? { namespace } : {}
1246
+ });
1247
+ const endpoint = `${url ?? `${baseUrl}/flow/meta`}?${queryParams.toString()}`;
1248
+ const response = await fetch(endpoint, {
1249
+ ...requestConfig,
1250
+ headers: {
1251
+ Accept: "application/json",
1252
+ ...requestConfig.headers
1253
+ },
1254
+ method: "GET"
1255
+ });
1256
+ if (!response.ok) throw new ThunderIDAPIError(await response.text(), "getFlowMeta-ResponseError-001", "javascript", response.status, response.statusText, "Flow metadata request failed");
1257
+ return await response.json();
1258
+ };
1259
+ var getFlowMeta_default = getFlowMeta;
1495
1260
 
1496
1261
  //#endregion
1497
- //#region src/errors/ThunderIDRuntimeError.ts
1262
+ //#region src/api/getOrganizationUnitChildren.ts
1498
1263
  /**
1499
- * Base class for all runtime errors in ThunderID. This class extends ThunderIDError
1500
- * and adds support for additional error details. Use this class for errors that occur
1501
- * during runtime execution that are not related to API calls.
1264
+ * Retrieves the child organization units of a given organization unit.
1502
1265
  *
1503
- * @example
1504
- * ```typescript
1505
- * throw new ThunderIDRuntimeError(
1506
- * "Failed to parse configuration",
1507
- * "CONFIG_PARSE_ERROR",
1508
- * { invalidField: "redirectUri" }
1509
- * );
1510
- * ```
1266
+ * @param config - Request configuration object.
1267
+ * @returns A promise that resolves with the list of child organization units.
1511
1268
  */
1512
- var ThunderIDRuntimeError = class extends ThunderIDError {
1513
- /**
1514
- * Creates an instance of ThunderIDRuntimeError.
1515
- *
1516
- * @param message - Human-readable description of the error
1517
- * @param code - A unique error code that identifies the error type
1518
- * @param details - Additional details about the error that might be helpful for debugging
1519
- * @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'ThunderID'
1520
- * @constructor
1521
- */
1522
- constructor(message, code, origin, details) {
1523
- super(message, code, origin);
1524
- this.details = details;
1525
- Object.defineProperty(this, "name", {
1526
- configurable: true,
1527
- value: "ThunderIDRuntimeError",
1528
- writable: true
1529
- });
1269
+ const getOrganizationUnitChildren = async ({ url, baseUrl, organizationUnitId, limit, offset, fetcher,...requestConfig }) => {
1270
+ try {
1271
+ new URL(url ?? baseUrl);
1272
+ } catch (error$1) {
1273
+ throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "getOrganizationUnitChildren-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1530
1274
  }
1531
- /**
1532
- * Returns a string representation of the runtime error
1533
- * @returns Formatted error string with name, code, details, and message
1534
- */
1535
- toString() {
1536
- const details = this.details ? `\nDetails: ${JSON.stringify(this.details, null, 2)}` : "";
1537
- return `[${this.name}] (code="${this.code}")${details}\nMessage: ${this.message}`;
1275
+ const fetchFn = fetcher || fetch;
1276
+ const queryParams = new URLSearchParams();
1277
+ if (limit !== void 0) queryParams.set("limit", String(limit));
1278
+ if (offset !== void 0) queryParams.set("offset", String(offset));
1279
+ const query = queryParams.toString();
1280
+ const resolvedBase = url ?? `${baseUrl}/api/server/v1/organization-units/${organizationUnitId}/children`;
1281
+ const resolvedUrl = query ? `${resolvedBase}?${query}` : resolvedBase;
1282
+ const requestInit = {
1283
+ ...requestConfig,
1284
+ headers: {
1285
+ Accept: "application/json",
1286
+ "Content-Type": "application/json",
1287
+ ...requestConfig.headers
1288
+ },
1289
+ method: "GET"
1290
+ };
1291
+ try {
1292
+ const response = await fetchFn(resolvedUrl, requestInit);
1293
+ if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getOrganizationUnitChildren-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch organization unit children");
1294
+ return await response.json();
1295
+ } catch (error$1) {
1296
+ if (error$1 instanceof ThunderIDAPIError) throw error$1;
1297
+ throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getOrganizationUnitChildren-NetworkError-001", "javascript", 0, "Network Error");
1538
1298
  }
1539
1299
  };
1300
+ var getOrganizationUnitChildren_default = getOrganizationUnitChildren;
1540
1301
 
1541
1302
  //#endregion
1542
- //#region src/models/embedded-recovery-flow.ts
1543
- /**
1544
- * Status enumeration for the embedded recovery flow operations.
1545
- *
1546
- * @experimental Part of the new ThunderID API
1547
- */
1548
- let EmbeddedRecoveryFlowStatus = /* @__PURE__ */ function(EmbeddedRecoveryFlowStatus$1) {
1549
- /**
1550
- * Recovery flow completed successfully.
1551
- */
1552
- EmbeddedRecoveryFlowStatus$1["Complete"] = "COMPLETE";
1553
- /**
1554
- * Recovery flow encountered an error and cannot proceed.
1555
- *
1556
- * @see {@link EmbeddedRecoveryFlowErrorResponse} for error response structure
1557
- */
1558
- EmbeddedRecoveryFlowStatus$1["Error"] = "ERROR";
1559
- /**
1560
- * Recovery flow requires additional user input.
1561
- */
1562
- EmbeddedRecoveryFlowStatus$1["Incomplete"] = "INCOMPLETE";
1563
- return EmbeddedRecoveryFlowStatus$1;
1564
- }({});
1303
+ //#region src/api/getUserInfo.ts
1565
1304
  /**
1566
- * Type enumeration for embedded recovery flow responses.
1305
+ * Retrieves the user information from the specified OIDC userinfo endpoint.
1567
1306
  *
1568
- * @experimental Part of the new ThunderID API
1307
+ * @param requestConfig - Request configuration object.
1308
+ * @returns A promise that resolves with the user information.
1309
+ * @throw
1310
+ * const userInfo = await getUserInfo({
1311
+ * url: "https://localhost:8090/oauth2/userinfo",
1312
+ * });
1313
+ * console.log(userInfo);
1314
+ * } catch (error) {
1315
+ * if (error instanceof ThunderIDAPIError) {
1316
+ * console.error('Failed to get user info:', error.message);
1317
+ * }
1318
+ * }
1319
+ * ```
1569
1320
  */
1570
- let EmbeddedRecoveryFlowType = /* @__PURE__ */ function(EmbeddedRecoveryFlowType$1) {
1571
- /**
1572
- * Response requires external redirection.
1573
- */
1574
- EmbeddedRecoveryFlowType$1["Redirection"] = "REDIRECTION";
1575
- /**
1576
- * Response contains view components for rendering.
1577
- */
1578
- EmbeddedRecoveryFlowType$1["View"] = "VIEW";
1579
- return EmbeddedRecoveryFlowType$1;
1580
- }({});
1321
+ const getUserInfo = async ({ url,...requestConfig }) => {
1322
+ try {
1323
+ new URL(url);
1324
+ } catch (error$1) {
1325
+ throw new ThunderIDAPIError("Invalid endpoint URL provided", "getUserInfo-ValidationError-001", "javascript", 400, "Invalid Request");
1326
+ }
1327
+ try {
1328
+ const response = await fetch(url, {
1329
+ ...requestConfig,
1330
+ headers: {
1331
+ Accept: "application/json",
1332
+ "Content-Type": "application/json",
1333
+ ...requestConfig.headers
1334
+ },
1335
+ method: "GET"
1336
+ });
1337
+ if (!response.ok) throw new ThunderIDAPIError(await response.text(), "getUserInfo-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch user info");
1338
+ return await response.json();
1339
+ } catch (error$1) {
1340
+ if (error$1 instanceof ThunderIDAPIError) throw error$1;
1341
+ throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getUserInfo-NetworkError-001", "javascript", 0, "Network Error");
1342
+ }
1343
+ };
1344
+ var getUserInfo_default = getUserInfo;
1581
1345
 
1582
1346
  //#endregion
1583
- //#region src/models/flow-meta.ts
1347
+ //#region src/utils/processUsername.ts
1584
1348
  /**
1585
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
1586
- *
1587
- * WSO2 LLC. licenses this file to you under the Apache License,
1588
- * Version 2.0 (the "License"); you may not use this file except
1589
- * in compliance with the License.
1590
- * You may obtain a copy of the License at
1591
- *
1592
- * http://www.apache.org/licenses/LICENSE-2.0
1593
- *
1594
- * Unless required by applicable law or agreed to in writing,
1595
- * software distributed under the License is distributed on an
1596
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1597
- * KIND, either express or implied. See the License for the
1598
- * specific language governing permissions and limitations
1599
- * under the License.
1349
+ * Regular expression to match userstore prefixes in usernames.
1350
+ * Matches patterns like "DEFAULT/", "ASGARDEO_USER/", "PRIMARY/", etc.
1351
+ * The pattern matches any uppercase letters, numbers, and underscores followed by a forward slash.
1600
1352
  */
1353
+ const USERSTORE_PREFIX_REGEX = /^[A-Z_][A-Z0-9_]*\//;
1601
1354
  /**
1602
- * The type of entity to retrieve flow metadata for.
1355
+ * Removes userstore prefixes from a username if they exist.
1356
+ * This is commonly used to clean usernames returned from profile endpoints
1357
+ * that include userstore prefixes like "DEFAULT/", "ASGARDEO_USER/", "PRIMARY/", etc.
1358
+ *
1359
+ * @param username - The username string to process
1360
+ * @returns The username without the userstore prefix, or the original username if no prefix exists
1603
1361
  *
1604
1362
  * @example
1605
1363
  * ```typescript
1606
- * const config: GetFlowMetaRequestConfig = {
1607
- * baseUrl: 'https://localhost:8090',
1608
- * type: FlowMetaType.App,
1609
- * id: '60a9b38b-6eba-9f9e-55f9-267067de4680',
1610
- * };
1611
- * ```
1364
+ * const cleanUsername = removeUserstorePrefix("DEFAULT/john.doe");
1365
+ * console.log(cleanUsername); // "john.doe"
1612
1366
  *
1613
- * @experimental This API may change in future versions
1614
- */
1615
- let FlowMetaType = /* @__PURE__ */ function(FlowMetaType$1) {
1616
- /** Retrieve metadata scoped to a specific application */
1617
- FlowMetaType$1["App"] = "APP";
1618
- /** Retrieve metadata scoped to a specific organization unit */
1619
- FlowMetaType$1["Ou"] = "OU";
1620
- return FlowMetaType$1;
1621
- }({});
1622
-
1623
- //#endregion
1624
- //#region src/models/flow.ts
1625
- /**
1626
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1367
+ * const thunderidUser = removeUserstorePrefix("ASGARDEO_USER/jane.doe");
1368
+ * console.log(thunderidUser); // "jane.doe"
1627
1369
  *
1628
- * WSO2 LLC. licenses this file to you under the Apache License,
1629
- * Version 2.0 (the "License"); you may not use this file except
1630
- * in compliance with the License.
1631
- * You may obtain a copy of the License at
1370
+ * const primaryUser = removeUserstorePrefix("PRIMARY/admin");
1371
+ * console.log(primaryUser); // "admin"
1632
1372
  *
1633
- * http://www.apache.org/licenses/LICENSE-2.0
1373
+ * const alreadyClean = removeUserstorePrefix("user.name");
1374
+ * console.log(alreadyClean); // "user.name"
1634
1375
  *
1635
- * Unless required by applicable law or agreed to in writing,
1636
- * software distributed under the License is distributed on an
1637
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1638
- * KIND, either express or implied. See the License for the
1639
- * specific language governing permissions and limitations
1640
- * under the License.
1376
+ * const emptyInput = removeUserstorePrefix("");
1377
+ * console.log(emptyInput); // ""
1378
+ * ```
1641
1379
  */
1642
- let FlowMode = /* @__PURE__ */ function(FlowMode$1) {
1643
- /**
1644
- * This mode is suitable for embedded sign-in, sign-up, etc. flows where the authentication
1645
- * UIs are rendered within the application.
1646
- * @see {@link https://is.docs.wso2.com/en/7.1.0/references/app-native-authentication/}
1647
- */
1648
- FlowMode$1["Embedded"] = "DIRECT";
1649
- /**
1650
- * Traditional redirect based sign-in, sign-up, etc. flows where the authentication
1651
- * UIs are from a external Identity Provider (ex: WSO2 Identity Server or ThunderID).
1652
- */
1653
- FlowMode$1["Redirect"] = "REDIRECTION";
1654
- return FlowMode$1;
1655
- }({});
1656
-
1657
- //#endregion
1658
- //#region src/models/field.ts
1380
+ const removeUserstorePrefix = (username) => {
1381
+ if (!username) return "";
1382
+ return username.replace(USERSTORE_PREFIX_REGEX, "");
1383
+ };
1659
1384
  /**
1660
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1385
+ * Processes a user object to remove userstore prefixes from username fields.
1386
+ * This is a helper function for processing user objects returned from profile endpoints.
1387
+ * Handles various username field variations: username, userName, and user_name.
1388
+ *
1389
+ * @param user - The user object to process
1390
+ * @returns The user object with processed username fields
1661
1391
  *
1662
- * WSO2 LLC. licenses this file to you under the Apache License,
1663
- * Version 2.0 (the "License"); you may not use this file except
1664
- * in compliance with the License.
1665
- * You may obtain a copy of the License at
1392
+ * @example
1393
+ * ```typescript
1394
+ * const user = { username: "DEFAULT/john.doe", email: "john@example.com" };
1395
+ * const processedUser = processUserUsername(user);
1396
+ * console.log(processedUser.username); // "john.doe"
1666
1397
  *
1667
- * http://www.apache.org/licenses/LICENSE-2.0
1398
+ * const camelCaseUser = { userName: "ASGARDEO_USER/jane.doe", email: "jane@example.com" };
1399
+ * const processedCamelCaseUser = processUserUsername(camelCaseUser);
1400
+ * console.log(processedCamelCaseUser.userName); // "jane.doe"
1668
1401
  *
1669
- * Unless required by applicable law or agreed to in writing,
1670
- * software distributed under the License is distributed on an
1671
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1672
- * KIND, either express or implied. See the License for the
1673
- * specific language governing permissions and limitations
1674
- * under the License.
1402
+ * const snakeCaseUser = { user_name: "PRIMARY/admin", email: "admin@example.com" };
1403
+ * const processedSnakeCaseUser = processUserUsername(snakeCaseUser);
1404
+ * console.log(processedSnakeCaseUser.user_name); // "admin"
1405
+ * ```
1675
1406
  */
1676
- let FieldType = /* @__PURE__ */ function(FieldType$1) {
1677
- FieldType$1["Checkbox"] = "CHECKBOX";
1678
- FieldType$1["Date"] = "DATE";
1679
- FieldType$1["Email"] = "EMAIL";
1680
- FieldType$1["Number"] = "NUMBER";
1681
- FieldType$1["Otp"] = "OTP";
1682
- FieldType$1["Password"] = "PASSWORD";
1683
- FieldType$1["Radio"] = "RADIO";
1684
- FieldType$1["Select"] = "SELECT";
1685
- FieldType$1["Tel"] = "TEL";
1686
- FieldType$1["Text"] = "TEXT";
1687
- FieldType$1["Textarea"] = "TEXTAREA";
1688
- FieldType$1["Time"] = "TIME";
1689
- return FieldType$1;
1690
- }({});
1407
+ const processUsername = (user) => {
1408
+ if (!user) return user;
1409
+ const processedUser = { ...user };
1410
+ if (processedUser.username) processedUser.username = removeUserstorePrefix(processedUser.username);
1411
+ if (processedUser.userName) processedUser.userName = removeUserstorePrefix(processedUser.userName);
1412
+ if (processedUser.user_name) processedUser.user_name = removeUserstorePrefix(processedUser.user_name);
1413
+ return processedUser;
1414
+ };
1415
+ var processUsername_default = processUsername;
1691
1416
 
1692
1417
  //#endregion
1693
- //#region src/constants/OIDCDiscoveryConstants.ts
1418
+ //#region src/api/getUsersMe.ts
1694
1419
  /**
1695
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1696
- *
1697
- * WSO2 LLC. licenses this file to you under the Apache License,
1698
- * Version 2.0 (the "License"); you may not use this file except
1699
- * in compliance with the License.
1700
- * You may obtain a copy of the License at
1420
+ * Retrieves the user profile information from the specified /users/me endpoint.
1701
1421
  *
1702
- * http://www.apache.org/licenses/LICENSE-2.0
1422
+ * @param config - Request configuration object.
1423
+ * @returns A promise that resolves with the user profile information.
1424
+ * @example
1425
+ * ```typescript
1426
+ * // Using default fetch
1427
+ * try {
1428
+ * const userProfile = await getUsersMe({
1429
+ * url: "https://localhost:8090/users/me",
1430
+ * });
1431
+ * console.log(userProfile);
1432
+ * } catch (error) {
1433
+ * if (error instanceof ThunderIDAPIError) {
1434
+ * console.error('Failed to get user profile:', error.message);
1435
+ * }
1436
+ * }
1437
+ * ```
1703
1438
  *
1704
- * Unless required by applicable law or agreed to in writing,
1705
- * software distributed under the License is distributed on an
1706
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1707
- * KIND, either express or implied. See the License for the
1708
- * specific language governing permissions and limitations
1709
- * under the License.
1439
+ * @example
1440
+ * ```typescript
1441
+ * // Using custom fetcher (e.g., axios-based httpClient)
1442
+ * try {
1443
+ * const userProfile = await getUsersMe({
1444
+ * url: "https://localhost:8090/users/me",
1445
+ * fetcher: async (url, config) => {
1446
+ * const response = await httpClient({
1447
+ * url,
1448
+ * method: config.method,
1449
+ * headers: config.headers,
1450
+ * ...config
1451
+ * });
1452
+ * // Convert axios-like response to fetch-like Response
1453
+ * return {
1454
+ * ok: response.status >= 200 && response.status < 300,
1455
+ * status: response.status,
1456
+ * statusText: response.statusText,
1457
+ * json: () => Promise.resolve(response.data),
1458
+ * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
1459
+ * } as Response;
1460
+ * }
1461
+ * });
1462
+ * console.log(userProfile);
1463
+ * } catch (error) {
1464
+ * if (error instanceof ThunderIDAPIError) {
1465
+ * console.error('Failed to get user profile:', error.message);
1466
+ * }
1467
+ * }
1468
+ * ```
1710
1469
  */
1470
+ const getUsersMe = async ({ url, baseUrl, fetcher,...requestConfig }) => {
1471
+ try {
1472
+ new URL(url ?? baseUrl);
1473
+ } catch (error$1) {
1474
+ throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "getUsersMe-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1475
+ }
1476
+ const fetchFn = fetcher || fetch;
1477
+ const resolvedUrl = url ?? `${baseUrl}/users/me`;
1478
+ const requestInit = {
1479
+ ...requestConfig,
1480
+ headers: {
1481
+ Accept: "application/json",
1482
+ "Content-Type": "application/json",
1483
+ ...requestConfig.headers
1484
+ },
1485
+ method: "GET"
1486
+ };
1487
+ try {
1488
+ const response = await fetchFn(resolvedUrl, requestInit);
1489
+ if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "getUsersMe-ResponseError-001", "javascript", response.status, response.statusText, "Failed to fetch user profile");
1490
+ const user = await response.json();
1491
+ const attributes = user["attributes"] ?? {};
1492
+ return processUsername_default({
1493
+ ...user,
1494
+ ...attributes
1495
+ });
1496
+ } catch (error$1) {
1497
+ if (error$1 instanceof ThunderIDAPIError) throw error$1;
1498
+ throw new ThunderIDAPIError(`Network or parsing error: ${error$1 instanceof Error ? error$1.message : "Unknown error"}`, "getUsersMe-NetworkError-001", "javascript", 0, "Network Error");
1499
+ }
1500
+ };
1501
+ var getUsersMe_default = getUsersMe;
1502
+
1503
+ //#endregion
1504
+ //#region src/api/updateMeProfile.ts
1711
1505
  /**
1712
- * Constants related to OpenID Connect (OIDC) metadata and endpoints.
1713
- * This object contains all the standard OIDC endpoints and storage keys
1714
- * used throughout the application for authentication and authorization.
1715
- *
1716
- * @remarks
1717
- * The constants are organized into two main sections:
1718
- * 1. Endpoints - Contains all OIDC standard endpoint paths
1719
- * 2. Storage - Contains keys used for storing OIDC-related data
1506
+ * Updates the user profile information at the specified /users/me endpoint.
1720
1507
  *
1508
+ * @param config - Configuration object with URL, payload and optional request config.
1509
+ * @returns A promise that resolves with the updated user profile information.
1721
1510
  * @example
1722
1511
  * ```typescript
1723
- * // Using an endpoint
1724
- * const authEndpoint = OIDCDiscoveryConstants.Endpoints.AUTHORIZATION;
1512
+ * // Using default fetch
1513
+ * await updateMeProfile({
1514
+ * url: "https://localhost:8090/users/me",
1515
+ * payload: { mobileNumbers: ["0777933830"] }
1516
+ * });
1517
+ * ```
1725
1518
  *
1726
- * // Using a storage key
1727
- * const tokenKey = OIDCDiscoveryConstants.Storage.StorageKeys.Endpoints.TOKEN;
1519
+ * @example
1520
+ * ```typescript
1521
+ * // Using custom fetcher (e.g., axios-based httpClient)
1522
+ * await updateMeProfile({
1523
+ * url: "https://localhost:8090/users/me",
1524
+ * payload: { mobileNumbers: ["0777933830"] },
1525
+ * fetcher: async (url, config) => {
1526
+ * const response = await httpClient({
1527
+ * url,
1528
+ * method: config.method,
1529
+ * headers: config.headers,
1530
+ * data: config.body,
1531
+ * ...config
1532
+ * });
1533
+ * // Convert axios-like response to fetch-like Response
1534
+ * return {
1535
+ * ok: response.status >= 200 && response.status < 300,
1536
+ * status: response.status,
1537
+ * statusText: response.statusText,
1538
+ * json: () => Promise.resolve(response.data),
1539
+ * text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
1540
+ * } as Response;
1541
+ * }
1542
+ * });
1728
1543
  * ```
1729
1544
  */
1730
- const OIDCDiscoveryConstants = {
1731
- Endpoints: {
1732
- AUTHORIZATION: "/oauth2/authorize",
1733
- END_SESSION: "/oauth2/logout",
1734
- ISSUER: "/oauth2/token",
1735
- JWKS: "/oauth2/jwks",
1736
- REVOCATION: "/oauth2/revoke",
1737
- SESSION_IFRAME: "/oidc/checksession",
1738
- TOKEN: "/oauth2/token",
1739
- USERINFO: "/oauth2/userinfo"
1740
- },
1741
- Storage: { StorageKeys: {
1742
- Endpoints: {
1743
- AUTHORIZATION: "authorization_endpoint",
1744
- END_SESSION: "end_session_endpoint",
1745
- ISSUER: "issuer",
1746
- JWKS: "jwks_uri",
1747
- REVOCATION: "revocation_endpoint",
1748
- SESSION_IFRAME: "check_session_iframe",
1749
- TOKEN: "token_endpoint",
1750
- USERINFO: "userinfo_endpoint"
1751
- },
1752
- OPENID_PROVIDER_CONFIG_INITIATED: "op_config_initiated"
1753
- } }
1545
+ const updateMeProfile = async ({ url, baseUrl, payload, fetcher,...requestConfig }) => {
1546
+ try {
1547
+ new URL(url ?? baseUrl);
1548
+ } catch (error$1) {
1549
+ throw new ThunderIDAPIError(`Invalid URL provided. ${error$1?.toString()}`, "updateMeProfile-ValidationError-001", "javascript", 400, "The provided `url` or `baseUrl` path does not adhere to the URL schema.");
1550
+ }
1551
+ const data = { attributes: payload };
1552
+ const fetchFn = fetcher || fetch;
1553
+ const resolvedUrl = url ?? `${baseUrl}/users/me`;
1554
+ const requestInit = {
1555
+ ...requestConfig,
1556
+ method: "PUT",
1557
+ body: JSON.stringify(data),
1558
+ headers: {
1559
+ ...requestConfig.headers,
1560
+ Accept: "application/json",
1561
+ "Content-Type": "application/json"
1562
+ }
1563
+ };
1564
+ try {
1565
+ const response = await fetchFn(resolvedUrl, requestInit);
1566
+ if (!response?.ok) throw new ThunderIDAPIError(await response.text(), "updateMeProfile-ResponseError-001", "javascript", response.status, response.statusText, "Failed to update user profile");
1567
+ const user = await response.json();
1568
+ const attributes = user["attributes"] ?? {};
1569
+ return processUsername_default({
1570
+ ...user,
1571
+ ...attributes
1572
+ });
1573
+ } catch (error$1) {
1574
+ if (error$1 instanceof ThunderIDAPIError) throw error$1;
1575
+ throw new ThunderIDAPIError(error$1?.response?.data?.detail || "An error occurred while updating the user profile. Please try again.", "updateMeProfile-NetworkError-001", "javascript", error$1?.data?.status, "Network Error");
1576
+ }
1754
1577
  };
1755
- var OIDCDiscoveryConstants_default = OIDCDiscoveryConstants;
1578
+ var updateMeProfile_default = updateMeProfile;
1756
1579
 
1757
1580
  //#endregion
1758
- //#region src/constants/PKCEConstants.ts
1581
+ //#region src/constants/ApplicationNativeAuthenticationConstants.ts
1759
1582
  /**
1760
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
1761
- *
1762
- * WSO2 LLC. licenses this file to you under the Apache License,
1763
- * Version 2.0 (the "License"); you may not use this file except
1764
- * in compliance with the License.
1765
- * You may obtain a copy of the License at
1766
- *
1767
- * http://www.apache.org/licenses/LICENSE-2.0
1768
- *
1769
- * Unless required by applicable law or agreed to in writing,
1770
- * software distributed under the License is distributed on an
1771
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1772
- * KIND, either express or implied. See the License for the
1773
- * specific language governing permissions and limitations
1774
- * under the License.
1583
+ * Constants representing Application Native Authentication related configurations and constants.
1775
1584
  */
1585
+ const ApplicationNativeAuthenticationConstants = { SupportedAuthenticators: {
1586
+ EmailOtp: "ZW1haWwtb3RwLWF1dGhlbnRpY2F0b3I6TE9DQUw",
1587
+ Facebook: "RmFjZWJvb2tBdXRoZW50aWNhdG9yOkZhY2Vib29r",
1588
+ GitHub: "R2l0aHViQXV0aGVudGljYXRvcjpHaXRIdWI",
1589
+ Google: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I6R29vZ2xl",
1590
+ IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
1591
+ LinkedIn: "TGlua2VkSW5PSURDOkxpbmtlZElu",
1592
+ MagicLink: "TWFnaWNMaW5rQXV0aGVudGljYXRvcjpMT0NBTA",
1593
+ Microsoft: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6TWljcm9zb2Z0",
1594
+ Passkey: "RklET0F1dGhlbnRpY2F0b3I6TE9DQUw",
1595
+ PushNotification: "cHVzaC1ub3RpZmljYXRpb24tYXV0aGVudGljYXRvcjpMT0NBTA",
1596
+ SignInWithEthereum: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6U2lnbiBJbiBXaXRoIEV0aGVyZXVt",
1597
+ SmsOtp: "c21zLW90cC1hdXRoZW50aWNhdG9yOkxPQ0FM",
1598
+ Totp: "dG90cDpMT0NBTA",
1599
+ UsernamePassword: "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM"
1600
+ } };
1601
+ var ApplicationNativeAuthenticationConstants_default = ApplicationNativeAuthenticationConstants;
1602
+
1603
+ //#endregion
1604
+ //#region src/constants/ScopeConstants.ts
1776
1605
  /**
1777
- * Constants related to Proof Key for Code Exchange (PKCE) implementation.
1778
- * This object contains all the necessary constants for implementing PKCE
1779
- * flow in the OAuth 2.0 authorization code grant.
1606
+ * Constants for OAuth 2.0 and OpenID Connect scopes.
1607
+ * These scopes define the level of access that the client application
1608
+ * is requesting from the authorization server.
1780
1609
  *
1781
1610
  * @remarks
1782
- * PKCE is an extension to the authorization code flow to prevent CSRF and
1783
- * authorization code injection attacks. The constants are organized into
1784
- * storage-related sections for managing PKCE state.
1611
+ * Scopes are space-separated strings that represent different permissions.
1612
+ * The 'openid' scope is required for OpenID Connect flows, while other
1613
+ * scopes provide access to different resources or user information.
1785
1614
  *
1786
1615
  * @example
1787
1616
  * ```typescript
1788
- * // Using storage keys
1789
- * const codeVerifierKey = PKCEConstants.Storage.StorageKeys.CODE_VERIFIER;
1790
- * const separator = PKCEConstants.Storage.StorageKeys.SEPARATOR;
1617
+ * // Requesting OpenID Connect authentication
1618
+ * const scope = [ScopeConstants.OPENID];
1619
+ *
1620
+ * // Requesting profile information
1621
+ * const scopes = [ScopeConstants.OPENID, ScopeConstants.PROFILE];
1791
1622
  * ```
1792
1623
  */
1793
- const PKCEConstants = {
1794
- DEFAULT_CODE_CHALLENGE_METHOD: "S256",
1795
- Storage: { StorageKeys: {
1796
- CODE_VERIFIER: "pkce_code_verifier",
1797
- SEPARATOR: "#"
1798
- } }
1624
+ const ScopeConstants = {
1625
+ OPENID: "openid",
1626
+ PROFILE: "profile"
1799
1627
  };
1800
- var PKCEConstants_default = PKCEConstants;
1628
+ var ScopeConstants_default = ScopeConstants;
1801
1629
 
1802
1630
  //#endregion
1803
- //#region src/DefaultCacheStore.ts
1631
+ //#region src/constants/OIDCRequestConstants.ts
1804
1632
  /**
1805
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
1806
- *
1807
- * WSO2 LLC. licenses this file to you under the Apache License,
1808
- * Version 2.0 (the "License"); you may not use this file except
1809
- * in compliance with the License.
1810
- * You may obtain a copy of the License at
1811
- *
1812
- * http://www.apache.org/licenses/LICENSE-2.0
1813
- *
1814
- * Unless required by applicable law or agreed to in writing,
1815
- * software distributed under the License is distributed on an
1816
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1817
- * KIND, either express or implied. See the License for the
1818
- * specific language governing permissions and limitations
1819
- * under the License.
1633
+ * Constants representing standard OpenID Connect (OIDC) request and response parameters.
1634
+ * These parameters are commonly used during authorization, token exchange, and logout flows.
1820
1635
  */
1821
- var DefaultCacheStore = class {
1822
- cache;
1823
- constructor() {
1824
- this.cache = /* @__PURE__ */ new Map();
1825
- }
1826
- get length() {
1827
- return this.cache.size;
1828
- }
1829
- getItem(key) {
1830
- return this.cache.get(key) ?? null;
1831
- }
1832
- setItem(key, value) {
1833
- this.cache.set(key, value);
1834
- }
1835
- removeItem(key) {
1836
- this.cache.delete(key);
1837
- }
1838
- clear() {
1839
- this.cache.clear();
1840
- }
1841
- key(index) {
1842
- return Array.from(this.cache.keys())[index] ?? null;
1843
- }
1844
- async setData(key, value) {
1845
- this.cache.set(key, value);
1846
- }
1847
- async getData(key) {
1848
- return this.cache.get(key) ?? "{}";
1849
- }
1850
- async removeData(key) {
1851
- this.cache.delete(key);
1852
- }
1636
+ const OIDCRequestConstants = {
1637
+ Params: {
1638
+ AUTHORIZATION_CODE: "code",
1639
+ SESSION_STATE: "session_state",
1640
+ SIGN_OUT_SUCCESS: "sign_out_success",
1641
+ STATE: "state"
1642
+ },
1643
+ SignIn: { Payload: { DEFAULT_SCOPES: [ScopeConstants_default.OPENID, ScopeConstants_default.PROFILE] } },
1644
+ SignOut: { Storage: { StorageKeys: { SIGN_OUT_URL: "sign_out_url" } } }
1853
1645
  };
1646
+ var OIDCRequestConstants_default = OIDCRequestConstants;
1854
1647
 
1855
1648
  //#endregion
1856
- //#region src/DefaultCrypto.ts
1649
+ //#region src/constants/VendorConstants.ts
1857
1650
  /**
1858
- * Default implementation of the Crypto interface using the 'jose' library
1859
- * and the native Web Crypto API.
1651
+ * Constants for vendor-specific configurations.
1652
+ * By default, the vendor is inferred as ThunderID.
1653
+ *
1654
+ * @example
1655
+ * ```typescript
1656
+ * // Using the vendor prefix in a URL
1657
+ * const apiUrl = `${VendorConstants.VENDOR_PREFIX}/api/v1/resource`;
1658
+ * ```
1860
1659
  */
1861
- var DefaultCrypto = class {
1862
- base64URLDecode(value) {
1863
- const decodedArray = jose.base64url.decode(value);
1864
- return new TextDecoder().decode(decodedArray);
1865
- }
1866
- base64URLEncode(value) {
1867
- return jose.base64url.encode(value);
1868
- }
1869
- generateRandomBytes(length) {
1870
- return crypto.getRandomValues(new Uint8Array(length));
1871
- }
1872
- async hashSha256(data) {
1873
- const dataBuffer = new TextEncoder().encode(data);
1874
- const hashBuffer = await crypto.subtle.digest("SHA-256", dataBuffer);
1875
- return new Uint8Array(hashBuffer);
1876
- }
1877
- async verifyJwt(idToken, jwk, algorithms, clientId, issuer, subject, clockTolerance, validateJwtIssuer = true) {
1878
- const key = await jose.importJWK(jwk);
1879
- await jose.jwtVerify(idToken, key, {
1880
- algorithms,
1881
- audience: [clientId],
1882
- clockTolerance,
1883
- issuer: validateJwtIssuer ? issuer : void 0,
1884
- subject
1885
- });
1886
- return true;
1887
- }
1888
- };
1660
+ const VendorConstants = { VENDOR_PREFIX: "thunderid" };
1661
+ var VendorConstants_default = VendorConstants;
1889
1662
 
1890
1663
  //#endregion
1891
- //#region src/models/store.ts
1664
+ //#region src/errors/ThunderIDRuntimeError.ts
1892
1665
  /**
1893
- * Enum representing different types of data stores used in the application.
1666
+ * Base class for all runtime errors in ThunderID. This class extends ThunderIDError
1667
+ * and adds support for additional error details. Use this class for errors that occur
1668
+ * during runtime execution that are not related to API calls.
1669
+ *
1670
+ * @example
1671
+ * ```typescript
1672
+ * throw new ThunderIDRuntimeError(
1673
+ * "Failed to parse configuration",
1674
+ * "CONFIG_PARSE_ERROR",
1675
+ * { invalidField: "redirectUri" }
1676
+ * );
1677
+ * ```
1894
1678
  */
1895
- let Stores = /* @__PURE__ */ function(Stores$1) {
1896
- /**
1897
- * Store for configuration data that defines the application's behavior and settings.
1898
- */
1899
- Stores$1["ConfigData"] = "config_data";
1900
- /**
1901
- * Store for OpenID Connect provider metadata, including endpoints and configuration.
1902
- */
1903
- Stores$1["OIDCProviderMetaData"] = "oidc_provider_meta_data";
1904
- /**
1905
- * Store for persisted data that needs to be retained across sessions and application restarts.
1906
- */
1907
- Stores$1["PersistedData"] = "persisted_data";
1908
- /**
1909
- * Store for user session-related data like tokens and authentication state.
1910
- */
1911
- Stores$1["SessionData"] = "session_data";
1679
+ var ThunderIDRuntimeError = class extends ThunderIDError {
1912
1680
  /**
1913
- * Store for temporary data that needs to persist only for a short duration.
1681
+ * Creates an instance of ThunderIDRuntimeError.
1682
+ *
1683
+ * @param message - Human-readable description of the error
1684
+ * @param code - A unique error code that identifies the error type
1685
+ * @param details - Additional details about the error that might be helpful for debugging
1686
+ * @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'ThunderID'
1687
+ * @constructor
1914
1688
  */
1915
- Stores$1["TemporaryData"] = "temporary_data";
1689
+ constructor(message, code, origin, details) {
1690
+ super(message, code, origin);
1691
+ this.details = details;
1692
+ Object.defineProperty(this, "name", {
1693
+ configurable: true,
1694
+ value: "ThunderIDRuntimeError",
1695
+ writable: true
1696
+ });
1697
+ }
1916
1698
  /**
1917
- * Store for data that leverages local storage if available, falling back to the configured storage.
1699
+ * Returns a string representation of the runtime error
1700
+ * @returns Formatted error string with name, code, details, and message
1918
1701
  */
1919
- Stores$1["HybridData"] = "hybrid_data";
1920
- return Stores$1;
1921
- }({});
1702
+ toString() {
1703
+ const details = this.details ? `\nDetails: ${JSON.stringify(this.details, null, 2)}` : "";
1704
+ return `[${this.name}] (code="${this.code}")${details}\nMessage: ${this.message}`;
1705
+ }
1706
+ };
1922
1707
 
1923
1708
  //#endregion
1924
- //#region src/utils/logger.ts
1925
- const PREFIX = "⚡ ThunderID";
1926
- /**
1927
- * Default logger configuration
1928
- */
1929
- const DEFAULT_CONFIG$1 = {
1930
- level: "info",
1931
- prefix: `${PREFIX}`,
1932
- showLevel: true,
1933
- timestamps: true
1934
- };
1935
- /**
1936
- * Environment detection utilities
1937
- */
1938
- const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
1939
- const isNode = () => typeof process !== "undefined" && process.versions && process.versions.node;
1940
- /**
1941
- * Color codes for terminal output (Node.js)
1942
- */
1943
- const COLORS = {
1944
- blue: "\x1B[34m",
1945
- bright: "\x1B[1m",
1946
- cyan: "\x1B[36m",
1947
- dim: "\x1B[2m",
1948
- gray: "\x1B[90m",
1949
- green: "\x1B[32m",
1950
- magenta: "\x1B[35m",
1951
- red: "\x1B[31m",
1952
- reset: "\x1B[0m",
1953
- white: "\x1B[37m",
1954
- yellow: "\x1B[33m"
1955
- };
1956
- /**
1957
- * Browser console styling
1958
- */
1959
- const BROWSER_STYLES = {
1960
- debug: "color: #6b7280; font-weight: normal;",
1961
- error: "color: #dc2626; font-weight: bold;",
1962
- info: "color: #2563eb; font-weight: bold;",
1963
- prefix: "color: #7c3aed; font-weight: bold;",
1964
- timestamp: "color: #6b7280; font-size: 0.9em;",
1965
- warn: "color: #d97706; font-weight: bold;"
1966
- };
1967
- const LOG_LEVEL_ORDER = {
1968
- debug: 0,
1969
- error: 3,
1970
- info: 1,
1971
- warn: 2
1972
- };
1709
+ //#region src/models/embedded-recovery-flow.ts
1973
1710
  /**
1974
- * Universal logger class that works in both browser and Node.js environments
1711
+ * Status enumeration for the embedded recovery flow operations.
1712
+ *
1713
+ * @experimental Part of the new ThunderID API
1975
1714
  */
1976
- var Logger = class Logger {
1977
- config;
1978
- constructor(config = {}) {
1979
- this.config = {
1980
- ...DEFAULT_CONFIG$1,
1981
- ...config
1982
- };
1983
- }
1984
- /**
1985
- * Update logger configuration
1986
- */
1987
- configure(config) {
1988
- this.config = {
1989
- ...this.config,
1990
- ...config
1991
- };
1992
- }
1715
+ let EmbeddedRecoveryFlowStatus = /* @__PURE__ */ function(EmbeddedRecoveryFlowStatus$1) {
1993
1716
  /**
1994
- * Get current configuration
1717
+ * Recovery flow completed successfully.
1995
1718
  */
1996
- getConfig() {
1997
- return { ...this.config };
1998
- }
1719
+ EmbeddedRecoveryFlowStatus$1["Complete"] = "COMPLETE";
1999
1720
  /**
2000
- * Check if a log level should be output
1721
+ * Recovery flow encountered an error and cannot proceed.
1722
+ *
1723
+ * @see {@link EmbeddedRecoveryFlowErrorResponse} for error response structure
2001
1724
  */
2002
- shouldLog(level) {
2003
- return LOG_LEVEL_ORDER[level] >= LOG_LEVEL_ORDER[this.config.level];
2004
- }
1725
+ EmbeddedRecoveryFlowStatus$1["Error"] = "ERROR";
2005
1726
  /**
2006
- * Get timestamp string
1727
+ * Recovery flow requires additional user input.
2007
1728
  */
2008
- static getTimestamp() {
2009
- return (/* @__PURE__ */ new Date()).toISOString();
2010
- }
1729
+ EmbeddedRecoveryFlowStatus$1["Incomplete"] = "INCOMPLETE";
1730
+ return EmbeddedRecoveryFlowStatus$1;
1731
+ }({});
1732
+ /**
1733
+ * Type enumeration for embedded recovery flow responses.
1734
+ *
1735
+ * @experimental Part of the new ThunderID API
1736
+ */
1737
+ let EmbeddedRecoveryFlowType = /* @__PURE__ */ function(EmbeddedRecoveryFlowType$1) {
2011
1738
  /**
2012
- * Get log level string
1739
+ * Response requires external redirection.
2013
1740
  */
2014
- static getLevelString(level) {
2015
- switch (level) {
2016
- case "debug": return "DEBUG";
2017
- case "info": return "INFO";
2018
- case "warn": return "WARN";
2019
- case "error": return "ERROR";
2020
- default: return "UNKNOWN";
2021
- }
2022
- }
1741
+ EmbeddedRecoveryFlowType$1["Redirection"] = "REDIRECTION";
2023
1742
  /**
2024
- * Format message for Node.js terminal
1743
+ * Response contains view components for rendering.
2025
1744
  */
2026
- formatForNode(level, message) {
2027
- const parts = [];
2028
- if (this.config.timestamps) parts.push(`${COLORS.gray}[${Logger.getTimestamp()}]${COLORS.reset}`);
2029
- if (this.config.prefix) parts.push(`${COLORS.magenta}${this.config.prefix}${COLORS.reset}`);
2030
- if (this.config.showLevel) {
2031
- const levelStr = Logger.getLevelString(level);
2032
- let coloredLevel;
2033
- switch (level) {
2034
- case "debug":
2035
- coloredLevel = `${COLORS.gray}[${levelStr}]${COLORS.reset}`;
2036
- break;
2037
- case "info":
2038
- coloredLevel = `${COLORS.blue}[${levelStr}]${COLORS.reset}`;
2039
- break;
2040
- case "warn":
2041
- coloredLevel = `${COLORS.yellow}[${levelStr}]${COLORS.reset}`;
2042
- break;
2043
- case "error":
2044
- coloredLevel = `${COLORS.red}[${levelStr}]${COLORS.reset}`;
2045
- break;
2046
- default: coloredLevel = `[${levelStr}]`;
2047
- }
2048
- parts.push(coloredLevel);
2049
- }
2050
- parts.push(message);
2051
- return parts.join(" ");
2052
- }
1745
+ EmbeddedRecoveryFlowType$1["View"] = "VIEW";
1746
+ return EmbeddedRecoveryFlowType$1;
1747
+ }({});
1748
+
1749
+ //#endregion
1750
+ //#region src/models/flow-meta.ts
1751
+ /**
1752
+ * The type of entity to retrieve flow metadata for.
1753
+ *
1754
+ * @example
1755
+ * ```typescript
1756
+ * const config: GetFlowMetaRequestConfig = {
1757
+ * baseUrl: 'https://localhost:8090',
1758
+ * type: FlowMetaType.App,
1759
+ * id: '60a9b38b-6eba-9f9e-55f9-267067de4680',
1760
+ * };
1761
+ * ```
1762
+ *
1763
+ * @experimental This API may change in future versions
1764
+ */
1765
+ let FlowMetaType = /* @__PURE__ */ function(FlowMetaType$1) {
1766
+ /** Retrieve metadata scoped to a specific application */
1767
+ FlowMetaType$1["App"] = "APP";
1768
+ /** Retrieve metadata scoped to a specific organization unit */
1769
+ FlowMetaType$1["Ou"] = "OU";
1770
+ return FlowMetaType$1;
1771
+ }({});
1772
+
1773
+ //#endregion
1774
+ //#region src/models/flow.ts
1775
+ let FlowMode = /* @__PURE__ */ function(FlowMode$1) {
2053
1776
  /**
2054
- * Log message using appropriate method
1777
+ * This mode is suitable for embedded sign-in, sign-up, etc. flows where the authentication
1778
+ * UIs are rendered within the application.
2055
1779
  */
2056
- logMessage(level, message, ...args) {
2057
- if (!this.shouldLog(level)) return;
2058
- if (this.config.formatter) {
2059
- this.config.formatter(level, message, ...args);
2060
- return;
2061
- }
2062
- if (isBrowser()) this.logToBrowser(level, message, ...args);
2063
- else if (isNode()) this.logToNode(level, message, ...args);
2064
- else console.log(message, ...args);
2065
- }
1780
+ FlowMode$1["Embedded"] = "DIRECT";
2066
1781
  /**
2067
- * Log to browser console with styling
1782
+ * Traditional redirect based sign-in, sign-up, etc. flows where the authentication
1783
+ * UIs are from a external Identity Provider (ex: ThunderID).
2068
1784
  */
2069
- logToBrowser(level, message, ...args) {
2070
- const parts = [];
2071
- const styles = [];
2072
- if (this.config.timestamps) {
2073
- parts.push(`%c[${Logger.getTimestamp()}]`);
2074
- styles.push(BROWSER_STYLES.timestamp);
2075
- }
2076
- if (this.config.prefix) {
2077
- parts.push(`%c${this.config.prefix}`);
2078
- styles.push(BROWSER_STYLES.prefix);
2079
- }
2080
- if (this.config.showLevel) {
2081
- const levelStr = Logger.getLevelString(level);
2082
- parts.push(`%c[${levelStr}]`);
2083
- switch (level) {
2084
- case "debug":
2085
- styles.push(BROWSER_STYLES.debug);
2086
- break;
2087
- case "info":
2088
- styles.push(BROWSER_STYLES.info);
2089
- break;
2090
- case "warn":
2091
- styles.push(BROWSER_STYLES.warn);
2092
- break;
2093
- case "error":
2094
- styles.push(BROWSER_STYLES.error);
2095
- break;
2096
- default: styles.push("");
2097
- }
2098
- }
2099
- parts.push(`%c${message}`);
2100
- styles.push("color: inherit; font-weight: normal;");
2101
- const formattedMessage = parts.join(" ");
2102
- switch (level) {
2103
- case "debug":
2104
- console.debug(formattedMessage, ...styles, ...args);
2105
- break;
2106
- case "info":
2107
- console.info(formattedMessage, ...styles, ...args);
2108
- break;
2109
- case "warn":
2110
- console.warn(formattedMessage, ...styles, ...args);
2111
- break;
2112
- case "error":
2113
- console.error(formattedMessage, ...styles, ...args);
2114
- break;
2115
- default: console.log(formattedMessage, ...styles, ...args);
2116
- }
1785
+ FlowMode$1["Redirect"] = "REDIRECTION";
1786
+ return FlowMode$1;
1787
+ }({});
1788
+
1789
+ //#endregion
1790
+ //#region src/models/field.ts
1791
+ let FieldType = /* @__PURE__ */ function(FieldType$1) {
1792
+ FieldType$1["Checkbox"] = "CHECKBOX";
1793
+ FieldType$1["Date"] = "DATE";
1794
+ FieldType$1["Email"] = "EMAIL";
1795
+ FieldType$1["Number"] = "NUMBER";
1796
+ FieldType$1["Otp"] = "OTP";
1797
+ FieldType$1["Password"] = "PASSWORD";
1798
+ FieldType$1["Radio"] = "RADIO";
1799
+ FieldType$1["Select"] = "SELECT";
1800
+ FieldType$1["Tel"] = "TEL";
1801
+ FieldType$1["Text"] = "TEXT";
1802
+ FieldType$1["Textarea"] = "TEXTAREA";
1803
+ FieldType$1["Time"] = "TIME";
1804
+ return FieldType$1;
1805
+ }({});
1806
+
1807
+ //#endregion
1808
+ //#region src/constants/OIDCDiscoveryConstants.ts
1809
+ /**
1810
+ * Constants related to OpenID Connect (OIDC) metadata and endpoints.
1811
+ * This object contains all the standard OIDC endpoints and storage keys
1812
+ * used throughout the application for authentication and authorization.
1813
+ *
1814
+ * @remarks
1815
+ * The constants are organized into two main sections:
1816
+ * 1. Endpoints - Contains all OIDC standard endpoint paths
1817
+ * 2. Storage - Contains keys used for storing OIDC-related data
1818
+ *
1819
+ * @example
1820
+ * ```typescript
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
+ * ```
1827
+ */
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
+ } }
1852
+ };
1853
+ var OIDCDiscoveryConstants_default = OIDCDiscoveryConstants;
1854
+
1855
+ //#endregion
1856
+ //#region src/constants/PKCEConstants.ts
1857
+ /**
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
+ * ```
1873
+ */
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();
2117
1889
  }
2118
- /**
2119
- * Log to Node.js console
2120
- */
2121
- logToNode(level, message, ...args) {
2122
- const formattedMessage = this.formatForNode(level, message);
2123
- switch (level) {
2124
- case "debug":
2125
- console.debug(formattedMessage, ...args);
2126
- break;
2127
- case "info":
2128
- console.info(formattedMessage, ...args);
2129
- break;
2130
- case "warn":
2131
- console.warn(formattedMessage, ...args);
2132
- break;
2133
- case "error":
2134
- console.error(formattedMessage, ...args);
2135
- break;
2136
- default: console.log(formattedMessage, ...args);
2137
- }
1890
+ get length() {
1891
+ return this.cache.size;
2138
1892
  }
2139
- /**
2140
- * Log debug message
2141
- */
2142
- debug(message, ...args) {
2143
- this.logMessage("debug", message, ...args);
1893
+ getItem(key) {
1894
+ return this.cache.get(key) ?? null;
1895
+ }
1896
+ setItem(key, value) {
1897
+ this.cache.set(key, value);
1898
+ }
1899
+ removeItem(key) {
1900
+ this.cache.delete(key);
1901
+ }
1902
+ clear() {
1903
+ this.cache.clear();
1904
+ }
1905
+ key(index) {
1906
+ return Array.from(this.cache.keys())[index] ?? null;
1907
+ }
1908
+ async setData(key, value) {
1909
+ this.cache.set(key, value);
1910
+ }
1911
+ async getData(key) {
1912
+ return this.cache.get(key) ?? "{}";
1913
+ }
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);
1929
+ }
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;
2144
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) {
2145
1960
  /**
2146
- * Log info message
1961
+ * Store for configuration data that defines the application's behavior and settings.
2147
1962
  */
2148
- info(message, ...args) {
2149
- this.logMessage("info", message, ...args);
2150
- }
1963
+ Stores$1["ConfigData"] = "config_data";
2151
1964
  /**
2152
- * Log warning message
1965
+ * Store for OpenID Connect provider metadata, including endpoints and configuration.
2153
1966
  */
2154
- warn(message, ...args) {
2155
- this.logMessage("warn", message, ...args);
2156
- }
1967
+ Stores$1["OIDCProviderMetaData"] = "oidc_provider_meta_data";
2157
1968
  /**
2158
- * Log error message
1969
+ * Store for persisted data that needs to be retained across sessions and application restarts.
2159
1970
  */
2160
- error(message, ...args) {
2161
- this.logMessage("error", message, ...args);
2162
- }
1971
+ Stores$1["PersistedData"] = "persisted_data";
2163
1972
  /**
2164
- * Create a child logger with additional prefix
1973
+ * Store for user session-related data like tokens and authentication state.
2165
1974
  */
2166
- child(prefix) {
2167
- const childPrefix = this.config.prefix ? `${this.config.prefix} - ${prefix}` : prefix;
2168
- return new Logger({
2169
- ...this.config,
2170
- prefix: childPrefix
2171
- });
2172
- }
1975
+ Stores$1["SessionData"] = "session_data";
2173
1976
  /**
2174
- * Set log level
1977
+ * Store for temporary data that needs to persist only for a short duration.
2175
1978
  */
2176
- setLevel(level) {
2177
- this.config.level = level;
2178
- }
1979
+ Stores$1["TemporaryData"] = "temporary_data";
2179
1980
  /**
2180
- * Get current log level
1981
+ * Store for data that leverages local storage if available, falling back to the configured storage.
2181
1982
  */
2182
- getLevel() {
2183
- return this.config.level;
2184
- }
2185
- };
2186
- /**
2187
- * Default logger instance
2188
- */
2189
- const logger = new Logger();
2190
- /**
2191
- * Create a new logger instance with custom configuration
2192
- */
2193
- const createLogger = (config) => new Logger(config);
2194
- /**
2195
- * Default export - global logger instance
2196
- */
2197
- var logger_default = logger;
2198
- /**
2199
- * Named exports for convenience
2200
- */
2201
- const debug = (message, ...args) => logger.debug(message, ...args);
2202
- const info = (message, ...args) => logger.info(message, ...args);
2203
- const warn = (message, ...args) => logger.warn(message, ...args);
2204
- const error = (message, ...args) => logger.error(message, ...args);
2205
- /**
2206
- * Configure the default logger
2207
- */
2208
- const configure = (config) => logger.configure(config);
2209
- /**
2210
- * Create component-specific loggers
2211
- */
2212
- const createComponentLogger = (component) => logger.child(component);
2213
- /**
2214
- * Create package-specific logger
2215
- */
2216
- const createPackageLogger = (packageName) => createLogger({
2217
- level: "info",
2218
- prefix: `${PREFIX} - ${packageName}`,
2219
- showLevel: true,
2220
- timestamps: true
2221
- });
2222
- /**
2223
- * Create package component logger (package + component)
2224
- */
2225
- const createPackageComponentLogger = (packageName, component) => {
2226
- return createPackageLogger(packageName).child(component);
2227
- };
1983
+ Stores$1["HybridData"] = "hybrid_data";
1984
+ return Stores$1;
1985
+ }({});
2228
1986
 
2229
1987
  //#endregion
2230
1988
  //#region src/StorageManager.ts
@@ -2585,23 +2343,6 @@ var resolveResourceEndpoint_default = resolveResourceEndpoint;
2585
2343
  //#endregion
2586
2344
  //#region src/constants/TokenExchangeConstants.ts
2587
2345
  /**
2588
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
2589
- *
2590
- * WSO2 LLC. licenses this file to you under the Apache License,
2591
- * Version 2.0 (the "License"); you may not use this file except
2592
- * in compliance with the License.
2593
- * You may obtain a copy of the License at
2594
- *
2595
- * http://www.apache.org/licenses/LICENSE-2.0
2596
- *
2597
- * Unless required by applicable law or agreed to in writing,
2598
- * software distributed under the License is distributed on an
2599
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2600
- * KIND, either express or implied. See the License for the
2601
- * specific language governing permissions and limitations
2602
- * under the License.
2603
- */
2604
- /**
2605
2346
  * Constants for OAuth 2.0 Token Exchange operations.
2606
2347
  * This object contains placeholders used in token exchange requests
2607
2348
  * and responses for dynamic value substitution.
@@ -2876,23 +2617,6 @@ var base64Encode_default = base64Encode;
2876
2617
  //#endregion
2877
2618
  //#region src/utils/deepMerge.ts
2878
2619
  /**
2879
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
2880
- *
2881
- * WSO2 LLC. licenses this file to you under the Apache License,
2882
- * Version 2.0 (the "License"); you may not use this file except
2883
- * in compliance with the License.
2884
- * You may obtain a copy of the License at
2885
- *
2886
- * http://www.apache.org/licenses/LICENSE-2.0
2887
- *
2888
- * Unless required by applicable law or agreed to in writing,
2889
- * software distributed under the License is distributed on an
2890
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2891
- * KIND, either express or implied. See the License for the
2892
- * specific language governing permissions and limitations
2893
- * under the License.
2894
- */
2895
- /**
2896
2620
  * Checks if a value is a plain object (not an array, function, date, etc.)
2897
2621
  *
2898
2622
  * @param value - The value to check
@@ -4116,23 +3840,6 @@ var createTheme_default = createTheme;
4116
3840
  //#endregion
4117
3841
  //#region src/utils/arrayBufferToBase64url.ts
4118
3842
  /**
4119
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4120
- *
4121
- * WSO2 LLC. licenses this file to you under the Apache License,
4122
- * Version 2.0 (the "License"); you may not use this file except
4123
- * in compliance with the License.
4124
- * You may obtain a copy of the License at
4125
- *
4126
- * http://www.apache.org/licenses/LICENSE-2.0
4127
- *
4128
- * Unless required by applicable law or agreed to in writing,
4129
- * software distributed under the License is distributed on an
4130
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4131
- * KIND, either express or implied. See the License for the
4132
- * specific language governing permissions and limitations
4133
- * under the License.
4134
- */
4135
- /**
4136
3843
  * Converts an ArrayBuffer to a base64url encoded string.
4137
3844
  *
4138
3845
  * Base64url encoding is a URL-safe variant of base64 encoding that:
@@ -4172,23 +3879,6 @@ var arrayBufferToBase64url_default = arrayBufferToBase64url;
4172
3879
  //#endregion
4173
3880
  //#region src/utils/base64urlToArrayBuffer.ts
4174
3881
  /**
4175
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4176
- *
4177
- * WSO2 LLC. licenses this file to you under the Apache License,
4178
- * Version 2.0 (the "License"); you may not use this file except
4179
- * in compliance with the License.
4180
- * You may obtain a copy of the License at
4181
- *
4182
- * http://www.apache.org/licenses/LICENSE-2.0
4183
- *
4184
- * Unless required by applicable law or agreed to in writing,
4185
- * software distributed under the License is distributed on an
4186
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4187
- * KIND, either express or implied. See the License for the
4188
- * specific language governing permissions and limitations
4189
- * under the License.
4190
- */
4191
- /**
4192
3882
  * Converts a base64url encoded string back to an ArrayBuffer.
4193
3883
  *
4194
3884
  * This function performs the inverse operation of base64url encoding by:
@@ -4237,23 +3927,6 @@ var base64urlToArrayBuffer_default = base64urlToArrayBuffer;
4237
3927
  //#endregion
4238
3928
  //#region src/utils/bem.ts
4239
3929
  /**
4240
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4241
- *
4242
- * WSO2 LLC. licenses this file to you under the Apache License,
4243
- * Version 2.0 (the "License"); you may not use this file except
4244
- * in compliance with the License.
4245
- * You may obtain a copy of the License at
4246
- *
4247
- * http://www.apache.org/licenses/LICENSE-2.0
4248
- *
4249
- * Unless required by applicable law or agreed to in writing,
4250
- * software distributed under the License is distributed on an
4251
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4252
- * KIND, either express or implied. See the License for the
4253
- * specific language governing permissions and limitations
4254
- * under the License.
4255
- */
4256
- /**
4257
3930
  * Creates a BEM-style class name by combining a base class with element and/or modifier
4258
3931
  *
4259
3932
  * @param baseClass - The base CSS class string (usually from emotion's css function)
@@ -4291,23 +3964,6 @@ var bem_default = bem;
4291
3964
  //#endregion
4292
3965
  //#region src/utils/formatDate.ts
4293
3966
  /**
4294
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4295
- *
4296
- * WSO2 LLC. licenses this file to you under the Apache License,
4297
- * Version 2.0 (the "License"); you may not use this file except
4298
- * in compliance with the License.
4299
- * You may obtain a copy of the License at
4300
- *
4301
- * http://www.apache.org/licenses/LICENSE-2.0
4302
- *
4303
- * Unless required by applicable law or agreed to in writing,
4304
- * software distributed under the License is distributed on an
4305
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4306
- * KIND, either express or implied. See the License for the
4307
- * specific language governing permissions and limitations
4308
- * under the License.
4309
- */
4310
- /**
4311
3967
  * Formats a date string to a human-readable format.
4312
3968
  *
4313
3969
  * @param dateString - The date string to format (optional)
@@ -4458,23 +4114,6 @@ var getRedirectBasedSignUpUrl_default = getRedirectBasedSignUpUrl;
4458
4114
  //#endregion
4459
4115
  //#region src/utils/isEmpty.ts
4460
4116
  /**
4461
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4462
- *
4463
- * WSO2 LLC. licenses this file to you under the Apache License,
4464
- * Version 2.0 (the "License"); you may not use this file except
4465
- * in compliance with the License.
4466
- * You may obtain a copy of the License at
4467
- *
4468
- * http://www.apache.org/licenses/LICENSE-2.0
4469
- *
4470
- * Unless required by applicable law or agreed to in writing,
4471
- * software distributed under the License is distributed on an
4472
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4473
- * KIND, either express or implied. See the License for the
4474
- * specific language governing permissions and limitations
4475
- * under the License.
4476
- */
4477
- /**
4478
4117
  * Checks if a value is considered empty.
4479
4118
  *
4480
4119
  * A value is considered empty if it is:
@@ -4514,23 +4153,6 @@ var isEmpty_default = isEmpty;
4514
4153
 
4515
4154
  //#endregion
4516
4155
  //#region src/utils/isEmojiUri.ts
4517
- /**
4518
- * Copyright (c) 2026, 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
4156
  const EMOJI_URI_SCHEME = "emoji:";
4535
4157
  /**
4536
4158
  * Checks whether a given URI uses the `emoji:` scheme (e.g. `"emoji:🐯"`).
@@ -4571,23 +4193,6 @@ var extractEmojiFromUri_default = extractEmojiFromUri;
4571
4193
  //#endregion
4572
4194
  //#region src/utils/set.ts
4573
4195
  /**
4574
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4575
- *
4576
- * WSO2 LLC. licenses this file to you under the Apache License,
4577
- * Version 2.0 (the "License"); you may not use this file except
4578
- * in compliance with the License.
4579
- * You may obtain a copy of the License at
4580
- *
4581
- * http://www.apache.org/licenses/LICENSE-2.0
4582
- *
4583
- * Unless required by applicable law or agreed to in writing,
4584
- * software distributed under the License is distributed on an
4585
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4586
- * KIND, either express or implied. See the License for the
4587
- * specific language governing permissions and limitations
4588
- * under the License.
4589
- */
4590
- /**
4591
4196
  * Sets the value at path of object. If a portion of path doesn't exist,
4592
4197
  * it's created. Arrays are created for missing index properties while
4593
4198
  * objects are created for all other missing properties.
@@ -4617,23 +4222,6 @@ var set_default = set;
4617
4222
  //#endregion
4618
4223
  //#region src/utils/get.ts
4619
4224
  /**
4620
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4621
- *
4622
- * WSO2 LLC. licenses this file to you under the Apache License,
4623
- * Version 2.0 (the "License"); you may not use this file except
4624
- * in compliance with the License.
4625
- * You may obtain a copy of the License at
4626
- *
4627
- * http://www.apache.org/licenses/LICENSE-2.0
4628
- *
4629
- * Unless required by applicable law or agreed to in writing,
4630
- * software distributed under the License is distributed on an
4631
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4632
- * KIND, either express or implied. See the License for the
4633
- * specific language governing permissions and limitations
4634
- * under the License.
4635
- */
4636
- /**
4637
4225
  * Gets the value at path of object. If the resolved value is undefined,
4638
4226
  * the defaultValue is returned in its place.
4639
4227
  * Similar to Lodash's get() function
@@ -4653,23 +4241,6 @@ var get_default = get;
4653
4241
  //#endregion
4654
4242
  //#region src/utils/startCase.ts
4655
4243
  /**
4656
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
4657
- *
4658
- * WSO2 LLC. licenses this file to you under the Apache License,
4659
- * Version 2.0 (the "License"); you may not use this file except
4660
- * in compliance with the License.
4661
- * You may obtain a copy of the License at
4662
- *
4663
- * http://www.apache.org/licenses/LICENSE-2.0
4664
- *
4665
- * Unless required by applicable law or agreed to in writing,
4666
- * software distributed under the License is distributed on an
4667
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4668
- * KIND, either express or implied. See the License for the
4669
- * specific language governing permissions and limitations
4670
- * under the License.
4671
- */
4672
- /**
4673
4244
  * Converts the first character of `string` to upper case.
4674
4245
  *
4675
4246
  * @param string - The string to convert.
@@ -4694,23 +4265,6 @@ var startCase_default = startCase;
4694
4265
  //#endregion
4695
4266
  //#region src/utils/removeTrailingSlash.ts
4696
4267
  /**
4697
- * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
4698
- *
4699
- * WSO2 LLC. licenses this file to you under the Apache License,
4700
- * Version 2.0 (the "License"); you may not use this file except
4701
- * in compliance with the License.
4702
- * You may obtain a copy of the License at
4703
- *
4704
- * http://www.apache.org/licenses/LICENSE-2.0
4705
- *
4706
- * Unless required by applicable law or agreed to in writing,
4707
- * software distributed under the License is distributed on an
4708
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4709
- * KIND, either express or implied. See the License for the
4710
- * specific language governing permissions and limitations
4711
- * under the License.
4712
- */
4713
- /**
4714
4268
  * Removes a trailing slash from a path string if it exists.
4715
4269
  *
4716
4270
  * @param path - The string path to process
@@ -4763,23 +4317,6 @@ function resolveMeta(path, meta) {
4763
4317
  //#endregion
4764
4318
  //#region src/utils/parseFlowTemplateLiteral.ts
4765
4319
  /**
4766
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
4767
- *
4768
- * WSO2 LLC. licenses this file to you under the Apache License,
4769
- * Version 2.0 (the "License"); you may not use this file except
4770
- * in compliance with the License.
4771
- * You may obtain a copy of the License at
4772
- *
4773
- * http://www.apache.org/licenses/LICENSE-2.0
4774
- *
4775
- * Unless required by applicable law or agreed to in writing,
4776
- * software distributed under the License is distributed on an
4777
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4778
- * KIND, either express or implied. See the License for the
4779
- * specific language governing permissions and limitations
4780
- * under the License.
4781
- */
4782
- /**
4783
4320
  * Regular expression to detect a flow template literal wrapped in double braces.
4784
4321
  * Matches patterns like `{{ t(key) }}`, `{{ meta(key) }}`, etc.
4785
4322
  *
@@ -4896,23 +4433,6 @@ function resolveFlowTemplateLiterals(text, { t, meta }) {
4896
4433
  //#endregion
4897
4434
  //#region src/utils/countryCodeToFlagEmoji.ts
4898
4435
  /**
4899
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
4900
- *
4901
- * WSO2 LLC. licenses this file to you under the Apache License,
4902
- * Version 2.0 (the "License"); you may not use this file except
4903
- * in compliance with the License.
4904
- * You may obtain a copy of the License at
4905
- *
4906
- * http://www.apache.org/licenses/LICENSE-2.0
4907
- *
4908
- * Unless required by applicable law or agreed to in writing,
4909
- * software distributed under the License is distributed on an
4910
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4911
- * KIND, either express or implied. See the License for the
4912
- * specific language governing permissions and limitations
4913
- * under the License.
4914
- */
4915
- /**
4916
4436
  * Converts a two-letter ISO 3166-1 alpha-2 country code to a flag emoji using
4917
4437
  * Unicode Regional Indicator Symbols (U+1F1E6–U+1F1FF).
4918
4438
  *
@@ -4926,23 +4446,6 @@ function countryCodeToFlagEmoji(countryCode) {
4926
4446
  //#endregion
4927
4447
  //#region src/utils/resolveLocaleDisplayName.ts
4928
4448
  /**
4929
- * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
4930
- *
4931
- * WSO2 LLC. licenses this file to you under the Apache License,
4932
- * Version 2.0 (the "License"); you may not use this file except
4933
- * in compliance with the License.
4934
- * You may obtain a copy of the License at
4935
- *
4936
- * http://www.apache.org/licenses/LICENSE-2.0
4937
- *
4938
- * Unless required by applicable law or agreed to in writing,
4939
- * software distributed under the License is distributed on an
4940
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4941
- * KIND, either express or implied. See the License for the
4942
- * specific language governing permissions and limitations
4943
- * under the License.
4944
- */
4945
- /**
4946
4449
  * Resolves a BCP 47 locale tag to a human-readable display name using the
4947
4450
  * `Intl.DisplayNames` API.
4948
4451
  *
@@ -5114,7 +4617,7 @@ var buildValidatorFromRules_default = buildValidatorFromRules;
5114
4617
  * ```typescript
5115
4618
  * // Usage with clsx
5116
4619
  * clsx(withVendorCSSClassPrefix('sign-in-button'), className)
5117
- * // Result: "wso2-sign-in-button"
4620
+ * // Result: "thunderid-sign-in-button"
5118
4621
  * ```
5119
4622
  */
5120
4623
  const withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_PREFIX}-${className}`;