@thunderid/react 1.3.1 → 1.3.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.
@@ -6,6 +6,15 @@ declare class ThunderIDReactClient<T extends ThunderIDReactConfig = ThunderIDRea
6
6
  constructor(instanceId?: number);
7
7
  private setLoading;
8
8
  private withLoading;
9
+ /**
10
+ * Returns the stored config, re-running initialization first when it has gone missing.
11
+ *
12
+ * NOTE: With React 19 strict mode, the initialization logic runs twice, and there's an intermittent
13
+ * issue where the config object is not getting stored in the storage layer with Vite scaffolding.
14
+ * An operation that resolves endpoints from a lost config fails (for example "required endpoints
15
+ * are missing"), so recover it from the config this client was initialized with.
16
+ */
17
+ private ensureConfigData;
9
18
  initialize(config: ThunderIDReactConfig): Promise<boolean>;
10
19
  reInitialize(config: Partial<ThunderIDReactConfig>): Promise<boolean>;
11
20
  updateUserProfile(): Promise<User>;
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDReactClient.d.ts","sourceRoot":"","sources":["../src/ThunderIDReactClient.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EACtB,WAAW,EACX,aAAa,EACb,IAAI,EACJ,aAAa,EAGb,OAAO,EAEP,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,0BAA0B,EAE1B,0BAA0B,EAM3B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,oBAAoB,EAAC,MAAM,iBAAiB,CAAC;AAErD,cAAM,oBAAoB,CAAC,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,sBAAsB,CAAC,CAAC,CAAC;IACjH,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,iBAAiB,CAAmC;gBAEhD,UAAU,SAAI;IAI1B,OAAO,CAAC,UAAU;YAIJ,WAAW;IAUhB,UAAU,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC;IAY1D,YAAY,CAAC,MAAM,EAAE,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EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAC9C,MAAM,CAAC,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAoDlC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAUnC,iBAAiB,IAAI,GAAG;IAIlC,OAAO,CAAC,aAAa,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAItE,UAAU,CAAC,cAAc,CAAC,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC;CAGrF;AAED,eAAe,oBAAoB,CAAC"}
@@ -18,6 +18,20 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
18
18
  this.setLoading(false);
19
19
  }
20
20
  }
21
+ /**
22
+ * Returns the stored config, re-running initialization first when it has gone missing.
23
+ *
24
+ * NOTE: With React 19 strict mode, the initialization logic runs twice, and there's an intermittent
25
+ * issue where the config object is not getting stored in the storage layer with Vite scaffolding.
26
+ * An operation that resolves endpoints from a lost config fails (for example "required endpoints
27
+ * are missing"), so recover it from the config this client was initialized with.
28
+ */
29
+ async ensureConfigData() {
30
+ const config = await this.getStorageManager().getConfigData();
31
+ if (!(!config || Object.keys(config).length === 0 || Boolean(this._initializeConfig?.baseUrl) && !config.baseUrl) || !this._initializeConfig) return config;
32
+ await this.initialize(this._initializeConfig);
33
+ return await this.getStorageManager().getConfigData();
34
+ }
21
35
  initialize(config) {
22
36
  return this.withLoading(async () => {
23
37
  this._initializeConfig = {
@@ -74,11 +88,7 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
74
88
  return this.withLoading(async () => {
75
89
  const arg1 = args[0];
76
90
  const arg2 = args[1];
77
- let config = await this.getStorageManager().getConfigData();
78
- if (!config || Object.keys(config).length === 0) {
79
- await this.initialize(this._initializeConfig);
80
- config = await this.getStorageManager().getConfigData();
81
- }
91
+ const config = await this.ensureConfigData();
82
92
  if (typeof arg1 === "object" && arg1 !== null && arg1.callOnlyOnRedirect === true) return;
83
93
  if (typeof arg1 === "object" && arg1 !== null && !isEmpty(arg1) && ("executionId" in arg1 || "applicationId" in arg1)) {
84
94
  const authIdFromUrl = new URL(window.location.href).searchParams.get("authId") ?? "";
@@ -109,6 +119,7 @@ var ThunderIDReactClient = class extends ThunderIDBrowserClient {
109
119
  });
110
120
  }
111
121
  async signInSilently(options) {
122
+ await this.ensureConfigData();
112
123
  return super.signInSilently(options);
113
124
  }
114
125
  async signUp(...args) {
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDReactClient.js","names":["isInitialized: boolean","claims: User","arg1: any","arg2: any","config: ThunderIDReactConfig | undefined","authIdFromUrl: string","authIdFromStorage: string","response: EmbeddedSignInFlowResponse","decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }","createdAt: number","expiresIn: number","config: ThunderIDReactConfig","firstArg: any","baseUrl: string","response: any","decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }"],"sources":["../src/ThunderIDReactClient.ts"],"sourcesContent":["// Copyright 2025-2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ThunderIDBrowserClient,\n UserProfile,\n SignInOptions,\n User,\n SignUpOptions,\n ThunderIDRuntimeError,\n executeEmbeddedSignInFlow,\n IdToken,\n extractUserClaimsFromIdToken,\n TokenResponse,\n HttpRequestConfig,\n HttpResponse,\n TokenExchangeRequestConfig,\n isEmpty,\n EmbeddedSignInFlowResponse,\n executeEmbeddedSignUpFlow,\n executeEmbeddedRecoveryFlow,\n EmbeddedSignInFlowStatus,\n EmbeddedSignUpFlowStatus,\n resolveResourceEndpoint,\n} from '@thunderid/browser';\nimport {ThunderIDReactConfig} from './models/config';\n\nclass ThunderIDReactClient<T extends ThunderIDReactConfig = ThunderIDReactConfig> extends ThunderIDBrowserClient<T> {\n private loadingState = false;\n\n private _initializeConfig: ThunderIDReactConfig | undefined;\n\n constructor(instanceId = 0) {\n super(instanceId);\n }\n\n private setLoading(loading: boolean): void {\n this.loadingState = loading;\n }\n\n private async withLoading<TResult>(operation: () => Promise<TResult>): Promise<TResult> {\n this.setLoading(true);\n try {\n const result: TResult = await operation();\n return result;\n } finally {\n this.setLoading(false);\n }\n }\n\n override initialize(config: ThunderIDReactConfig): Promise<boolean> {\n return this.withLoading(async () => {\n this._initializeConfig = {\n ...config,\n periodicTokenRefresh:\n config?.tokenLifecycle?.refreshToken?.autoRefresh ?? (config as any)?.periodicTokenRefresh,\n } as any;\n\n return super.initialize(this._initializeConfig as unknown as T);\n });\n }\n\n override reInitialize(config: Partial<ThunderIDReactConfig>): Promise<boolean> {\n return this.withLoading(async () => {\n let isInitialized: boolean;\n\n try {\n await super.reInitialize(config as Partial<T>);\n isInitialized = true;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to check if the client is initialized: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDReactClient-reInitialize-RuntimeError-001',\n 'react',\n 'An error occurred while checking the initialization status of the client.',\n );\n }\n\n return isInitialized;\n });\n }\n\n override async updateUserProfile(): Promise<User> {\n throw new Error('Not implemented');\n }\n\n override async getUser(): Promise<User> {\n return extractUserClaimsFromIdToken(await this.getDecodedIdToken());\n }\n\n override async getDecodedIdToken(sessionId?: string): Promise<IdToken> {\n return super.getDecodedIdToken(sessionId);\n }\n\n override async getIdToken(): Promise<string> {\n return this.withLoading(async () => super.getIdToken());\n }\n\n override async getUserProfile(): Promise<UserProfile> {\n return this.withLoading(async () => {\n const claims: User = extractUserClaimsFromIdToken(await this.getDecodedIdToken());\n return {\n flattenedProfile: claims,\n profile: claims,\n schemas: [],\n };\n });\n }\n\n override isLoading(): boolean {\n return this.loadingState;\n }\n\n override async isSignedIn(): Promise<boolean> {\n return super.isSignedIn();\n }\n\n override async exchangeToken(config: TokenExchangeRequestConfig): Promise<TokenResponse | Response> {\n return this.withLoading(async () => super.exchangeToken(config) as unknown as TokenResponse | Response);\n }\n\n override async signIn(...args: any[]): Promise<User | EmbeddedSignInFlowResponse> {\n return this.withLoading(async () => {\n const arg1: any = args[0];\n const arg2: any = args[1];\n\n let config: ThunderIDReactConfig | undefined = (await this.getStorageManager().getConfigData()) as\n | ThunderIDReactConfig\n | undefined;\n\n // NOTE: With React 19 strict mode, the initialization logic runs twice, and there's an intermittent\n // issue where the config object is not getting stored in the storage layer with Vite scaffolding.\n // Hence, we need to check if the client is initialized but the config object is empty, and reinitialize.\n if (!config || Object.keys(config).length === 0) {\n await this.initialize(this._initializeConfig!);\n // Reload the config persisted by initialization so downstream endpoint resolution\n // (baseUrl and the flowExecute override) uses the recovered values, not the stale empty config.\n config = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig | undefined;\n }\n\n if (typeof arg1 === 'object' && arg1 !== null && arg1.callOnlyOnRedirect === true) {\n return undefined as any;\n }\n\n if (\n typeof arg1 === 'object' &&\n arg1 !== null &&\n !isEmpty(arg1) &&\n ('executionId' in arg1 || 'applicationId' in arg1)\n ) {\n const authIdFromUrl: string = new URL(window.location.href).searchParams.get('authId') ?? '';\n const authIdFromStorage: string =\n ((await this.getStorageManager().getHybridDataParameter('authId')) as string) ?? '';\n const authId: string = authIdFromUrl || authIdFromStorage;\n const baseUrl: string = config?.baseUrl ?? '';\n\n const response: EmbeddedSignInFlowResponse = await executeEmbeddedSignInFlow({\n authId,\n baseUrl,\n payload: arg1,\n url: resolveResourceEndpoint('flowExecute', config, arg2?.url),\n });\n\n if (\n response &&\n typeof response === 'object' &&\n response.flowStatus === EmbeddedSignInFlowStatus.Complete &&\n response.assertion\n ) {\n const decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n } = await this.decodeJwtToken<{\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }>(response.assertion);\n\n const createdAt: number = decodedAssertion.iat ? decodedAssertion.iat * 1000 : Date.now();\n const expiresIn: number =\n decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;\n\n await this.setSession({\n access_token: response.assertion,\n created_at: createdAt,\n expires_in: expiresIn,\n id_token: response.assertion,\n scope: decodedAssertion.scope,\n token_type: 'Bearer',\n });\n\n this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion as IdToken) as User);\n }\n\n return response;\n }\n\n return (await super.signIn(...args)) as unknown as User;\n });\n }\n\n override async signInSilently(options?: SignInOptions): Promise<User | boolean> {\n return super.signInSilently(options as Record<string, string | boolean>) as Promise<User | boolean>;\n }\n\n override async signUp(options?: SignUpOptions): Promise<void>;\n override async signUp(payload: any): Promise<any>;\n override async signUp(...args: any[]): Promise<void | any> {\n const config: ThunderIDReactConfig = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig;\n const firstArg: any = args[0];\n const baseUrl: string = config?.baseUrl ?? '';\n\n const authId: string = new URL(window.location.href).searchParams.get('authId') ?? '';\n\n const response: any = await executeEmbeddedSignUpFlow({\n authId,\n baseUrl,\n payload: typeof firstArg === 'object' && 'flowType' in firstArg ? {...firstArg, verbose: true} : firstArg,\n url: resolveResourceEndpoint('flowExecute', config),\n });\n\n if (\n response &&\n typeof response === 'object' &&\n response.flowStatus === EmbeddedSignUpFlowStatus.Complete &&\n response.assertion\n ) {\n const decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n } = await this.decodeJwtToken<{\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }>(response.assertion);\n\n const createdAt: number = decodedAssertion.iat ? decodedAssertion.iat * 1000 : Date.now();\n const expiresIn: number =\n decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;\n\n await this.setSession({\n access_token: response.assertion,\n created_at: createdAt,\n expires_in: expiresIn,\n id_token: response.assertion,\n scope: decodedAssertion.scope,\n token_type: 'Bearer',\n });\n\n this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion as IdToken) as User);\n }\n\n return response;\n }\n\n override async recover(payload?: any): Promise<any> {\n const config: ThunderIDReactConfig = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig;\n\n return executeEmbeddedRecoveryFlow({\n baseUrl: config?.baseUrl,\n payload: {...payload, verbose: true},\n url: resolveResourceEndpoint('flowExecute', config),\n }) as any;\n }\n\n public override getStorageManager(): any {\n return super.getStorageManager();\n }\n\n async request(requestConfig?: HttpRequestConfig): Promise<HttpResponse<any>> {\n return super.httpRequest(requestConfig!) as Promise<HttpResponse<any>>;\n }\n\n async requestAll(requestConfigs?: HttpRequestConfig[]): Promise<HttpResponse<any>[]> {\n return super.httpRequestAll(requestConfigs!) as Promise<HttpResponse<any>[]>;\n }\n}\n\nexport default ThunderIDReactClient;\n"],"mappings":";;;AA2BA,IAAM,uBAAN,cAA0F,uBAA0B;CAClH,AAAQ,eAAe;CAEvB,AAAQ;CAER,YAAY,aAAa,GAAG;AAC1B,QAAM,WAAW;;CAGnB,AAAQ,WAAW,SAAwB;AACzC,OAAK,eAAe;;CAGtB,MAAc,YAAqB,WAAqD;AACtF,OAAK,WAAW,KAAK;AACrB,MAAI;AAEF,UADwB,MAAM,WAAW;YAEjC;AACR,QAAK,WAAW,MAAM;;;CAI1B,AAAS,WAAW,QAAgD;AAClE,SAAO,KAAK,YAAY,YAAY;AAClC,QAAK,oBAAoB;IACvB,GAAG;IACH,sBACE,QAAQ,gBAAgB,cAAc,eAAgB,QAAgB;IACzE;AAED,UAAO,MAAM,WAAW,KAAK,kBAAkC;IAC/D;;CAGJ,AAAS,aAAa,QAAyD;AAC7E,SAAO,KAAK,YAAY,YAAY;GAClC,IAAIA;AAEJ,OAAI;AACF,UAAM,MAAM,aAAa,OAAqB;AAC9C,oBAAgB;YACT,OAAO;AACd,UAAM,IAAI,sBACR,iDAAiD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IACvG,sDACA,SACA,4EACD;;AAGH,UAAO;IACP;;CAGJ,MA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BAAiB,MAAM,iBAAiB,MAAM,MAAO,KAAK,KAAK;GACzF,MAAMC,YACJ,iBAAiB,OAAO,iBAAiB,MAAM,iBAAiB,MAAM,iBAAiB,MAAM;AAE/F,SAAM,KAAK,WAAW;IACpB,cAAc,SAAS;IACvB,YAAY;IACZ,YAAY;IACZ,UAAU,SAAS;IACnB,OAAO,iBAAiB;IACxB,YAAY;IACb,CAAC;AAEF,QAAK,aAAa,6BAA6B,iBAA4B,CAAS;;AAGtF,SAAO;;CAGT,MAAe,QAAQ,SAA6B;EAClD,MAAMC,SAAgC,MAAM,KAAK,mBAAmB,CAAC,eAAe;AAEpF,SAAO,4BAA4B;GACjC,SAAS,QAAQ;GACjB,SAAS;IAAC,GAAG;IAAS,SAAS;IAAK;GACpC,KAAK,wBAAwB,eAAe,OAAO;GACpD,CAAC;;CAGJ,AAAgB,oBAAyB;AACvC,SAAO,MAAM,mBAAmB;;CAGlC,MAAM,QAAQ,eAA+D;AAC3E,SAAO,MAAM,YAAY,cAAe;;CAG1C,MAAM,WAAW,gBAAoE;AACnF,SAAO,MAAM,eAAe,eAAgB;;;AAIhD,mCAAe"}
1
+ {"version":3,"file":"ThunderIDReactClient.js","names":["config: ThunderIDReactConfig | undefined","isInitialized: boolean","claims: User","arg1: any","arg2: any","authIdFromUrl: string","authIdFromStorage: string","response: EmbeddedSignInFlowResponse","decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }","createdAt: number","expiresIn: number","config: ThunderIDReactConfig","firstArg: any","baseUrl: string","response: any","decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }"],"sources":["../src/ThunderIDReactClient.ts"],"sourcesContent":["// Copyright 2025-2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ThunderIDBrowserClient,\n UserProfile,\n SignInOptions,\n User,\n SignUpOptions,\n ThunderIDRuntimeError,\n executeEmbeddedSignInFlow,\n IdToken,\n extractUserClaimsFromIdToken,\n TokenResponse,\n HttpRequestConfig,\n HttpResponse,\n TokenExchangeRequestConfig,\n isEmpty,\n EmbeddedSignInFlowResponse,\n executeEmbeddedSignUpFlow,\n executeEmbeddedRecoveryFlow,\n EmbeddedSignInFlowStatus,\n EmbeddedSignUpFlowStatus,\n resolveResourceEndpoint,\n} from '@thunderid/browser';\nimport {ThunderIDReactConfig} from './models/config';\n\nclass ThunderIDReactClient<T extends ThunderIDReactConfig = ThunderIDReactConfig> extends ThunderIDBrowserClient<T> {\n private loadingState = false;\n\n private _initializeConfig: ThunderIDReactConfig | undefined;\n\n constructor(instanceId = 0) {\n super(instanceId);\n }\n\n private setLoading(loading: boolean): void {\n this.loadingState = loading;\n }\n\n private async withLoading<TResult>(operation: () => Promise<TResult>): Promise<TResult> {\n this.setLoading(true);\n try {\n const result: TResult = await operation();\n return result;\n } finally {\n this.setLoading(false);\n }\n }\n\n /**\n * Returns the stored config, re-running initialization first when it has gone missing.\n *\n * NOTE: With React 19 strict mode, the initialization logic runs twice, and there's an intermittent\n * issue where the config object is not getting stored in the storage layer with Vite scaffolding.\n * An operation that resolves endpoints from a lost config fails (for example \"required endpoints\n * are missing\"), so recover it from the config this client was initialized with.\n */\n private async ensureConfigData(): Promise<ThunderIDReactConfig | undefined> {\n const config: ThunderIDReactConfig | undefined = (await this.getStorageManager().getConfigData()) as\n | ThunderIDReactConfig\n | undefined;\n const isConfigLost: boolean =\n !config || Object.keys(config).length === 0 || (Boolean(this._initializeConfig?.baseUrl) && !config.baseUrl);\n\n if (!isConfigLost || !this._initializeConfig) {\n return config;\n }\n\n await this.initialize(this._initializeConfig);\n\n // Reload the config persisted by initialization so downstream endpoint resolution\n // (baseUrl and the flowExecute override) uses the recovered values, not the stale empty config.\n return (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig | undefined;\n }\n\n override initialize(config: ThunderIDReactConfig): Promise<boolean> {\n return this.withLoading(async () => {\n this._initializeConfig = {\n ...config,\n periodicTokenRefresh:\n config?.tokenLifecycle?.refreshToken?.autoRefresh ?? (config as any)?.periodicTokenRefresh,\n } as any;\n\n return super.initialize(this._initializeConfig as unknown as T);\n });\n }\n\n override reInitialize(config: Partial<ThunderIDReactConfig>): Promise<boolean> {\n return this.withLoading(async () => {\n let isInitialized: boolean;\n\n try {\n await super.reInitialize(config as Partial<T>);\n isInitialized = true;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to check if the client is initialized: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDReactClient-reInitialize-RuntimeError-001',\n 'react',\n 'An error occurred while checking the initialization status of the client.',\n );\n }\n\n return isInitialized;\n });\n }\n\n override async updateUserProfile(): Promise<User> {\n throw new Error('Not implemented');\n }\n\n override async getUser(): Promise<User> {\n return extractUserClaimsFromIdToken(await this.getDecodedIdToken());\n }\n\n override async getDecodedIdToken(sessionId?: string): Promise<IdToken> {\n return super.getDecodedIdToken(sessionId);\n }\n\n override async getIdToken(): Promise<string> {\n return this.withLoading(async () => super.getIdToken());\n }\n\n override async getUserProfile(): Promise<UserProfile> {\n return this.withLoading(async () => {\n const claims: User = extractUserClaimsFromIdToken(await this.getDecodedIdToken());\n return {\n flattenedProfile: claims,\n profile: claims,\n schemas: [],\n };\n });\n }\n\n override isLoading(): boolean {\n return this.loadingState;\n }\n\n override async isSignedIn(): Promise<boolean> {\n return super.isSignedIn();\n }\n\n override async exchangeToken(config: TokenExchangeRequestConfig): Promise<TokenResponse | Response> {\n return this.withLoading(async () => super.exchangeToken(config) as unknown as TokenResponse | Response);\n }\n\n override async signIn(...args: any[]): Promise<User | EmbeddedSignInFlowResponse> {\n return this.withLoading(async () => {\n const arg1: any = args[0];\n const arg2: any = args[1];\n\n const config: ThunderIDReactConfig | undefined = await this.ensureConfigData();\n\n if (typeof arg1 === 'object' && arg1 !== null && arg1.callOnlyOnRedirect === true) {\n return undefined as any;\n }\n\n if (\n typeof arg1 === 'object' &&\n arg1 !== null &&\n !isEmpty(arg1) &&\n ('executionId' in arg1 || 'applicationId' in arg1)\n ) {\n const authIdFromUrl: string = new URL(window.location.href).searchParams.get('authId') ?? '';\n const authIdFromStorage: string =\n ((await this.getStorageManager().getHybridDataParameter('authId')) as string) ?? '';\n const authId: string = authIdFromUrl || authIdFromStorage;\n const baseUrl: string = config?.baseUrl ?? '';\n\n const response: EmbeddedSignInFlowResponse = await executeEmbeddedSignInFlow({\n authId,\n baseUrl,\n payload: arg1,\n url: resolveResourceEndpoint('flowExecute', config, arg2?.url),\n });\n\n if (\n response &&\n typeof response === 'object' &&\n response.flowStatus === EmbeddedSignInFlowStatus.Complete &&\n response.assertion\n ) {\n const decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n } = await this.decodeJwtToken<{\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }>(response.assertion);\n\n const createdAt: number = decodedAssertion.iat ? decodedAssertion.iat * 1000 : Date.now();\n const expiresIn: number =\n decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;\n\n await this.setSession({\n access_token: response.assertion,\n created_at: createdAt,\n expires_in: expiresIn,\n id_token: response.assertion,\n scope: decodedAssertion.scope,\n token_type: 'Bearer',\n });\n\n this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion as IdToken) as User);\n }\n\n return response;\n }\n\n return (await super.signIn(...args)) as unknown as User;\n });\n }\n\n override async signInSilently(options?: SignInOptions): Promise<User | boolean> {\n await this.ensureConfigData();\n\n return super.signInSilently(options as Record<string, string | boolean>) as Promise<User | boolean>;\n }\n\n override async signUp(options?: SignUpOptions): Promise<void>;\n override async signUp(payload: any): Promise<any>;\n override async signUp(...args: any[]): Promise<void | any> {\n const config: ThunderIDReactConfig = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig;\n const firstArg: any = args[0];\n const baseUrl: string = config?.baseUrl ?? '';\n\n const authId: string = new URL(window.location.href).searchParams.get('authId') ?? '';\n\n const response: any = await executeEmbeddedSignUpFlow({\n authId,\n baseUrl,\n payload: typeof firstArg === 'object' && 'flowType' in firstArg ? {...firstArg, verbose: true} : firstArg,\n url: resolveResourceEndpoint('flowExecute', config),\n });\n\n if (\n response &&\n typeof response === 'object' &&\n response.flowStatus === EmbeddedSignUpFlowStatus.Complete &&\n response.assertion\n ) {\n const decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n } = await this.decodeJwtToken<{\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }>(response.assertion);\n\n const createdAt: number = decodedAssertion.iat ? decodedAssertion.iat * 1000 : Date.now();\n const expiresIn: number =\n decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;\n\n await this.setSession({\n access_token: response.assertion,\n created_at: createdAt,\n expires_in: expiresIn,\n id_token: response.assertion,\n scope: decodedAssertion.scope,\n token_type: 'Bearer',\n });\n\n this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion as IdToken) as User);\n }\n\n return response;\n }\n\n override async recover(payload?: any): Promise<any> {\n const config: ThunderIDReactConfig = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig;\n\n return executeEmbeddedRecoveryFlow({\n baseUrl: config?.baseUrl,\n payload: {...payload, verbose: true},\n url: resolveResourceEndpoint('flowExecute', config),\n }) as any;\n }\n\n public override getStorageManager(): any {\n return super.getStorageManager();\n }\n\n async request(requestConfig?: HttpRequestConfig): Promise<HttpResponse<any>> {\n return super.httpRequest(requestConfig!) as Promise<HttpResponse<any>>;\n }\n\n async requestAll(requestConfigs?: HttpRequestConfig[]): Promise<HttpResponse<any>[]> {\n return super.httpRequestAll(requestConfigs!) as Promise<HttpResponse<any>[]>;\n }\n}\n\nexport default ThunderIDReactClient;\n"],"mappings":";;;AA2BA,IAAM,uBAAN,cAA0F,uBAA0B;CAClH,AAAQ,eAAe;CAEvB,AAAQ;CAER,YAAY,aAAa,GAAG;AAC1B,QAAM,WAAW;;CAGnB,AAAQ,WAAW,SA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AG;IAAS,SAAS;IAAK;GACpC,KAAK,wBAAwB,eAAe,OAAO;GACpD,CAAC;;CAGJ,AAAgB,oBAAyB;AACvC,SAAO,MAAM,mBAAmB;;CAGlC,MAAM,QAAQ,eAA+D;AAC3E,SAAO,MAAM,YAAY,cAAe;;CAG1C,MAAM,WAAW,gBAAoE;AACnF,SAAO,MAAM,eAAe,eAAgB;;;AAIhD,mCAAe"}
@@ -20,6 +20,20 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
20
20
  this.setLoading(false);
21
21
  }
22
22
  }
23
+ /**
24
+ * Returns the stored config, re-running initialization first when it has gone missing.
25
+ *
26
+ * NOTE: With React 19 strict mode, the initialization logic runs twice, and there's an intermittent
27
+ * issue where the config object is not getting stored in the storage layer with Vite scaffolding.
28
+ * An operation that resolves endpoints from a lost config fails (for example "required endpoints
29
+ * are missing"), so recover it from the config this client was initialized with.
30
+ */
31
+ async ensureConfigData() {
32
+ const config = await this.getStorageManager().getConfigData();
33
+ if (!(!config || Object.keys(config).length === 0 || Boolean(this._initializeConfig?.baseUrl) && !config.baseUrl) || !this._initializeConfig) return config;
34
+ await this.initialize(this._initializeConfig);
35
+ return await this.getStorageManager().getConfigData();
36
+ }
23
37
  initialize(config) {
24
38
  return this.withLoading(async () => {
25
39
  this._initializeConfig = {
@@ -76,11 +90,7 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
76
90
  return this.withLoading(async () => {
77
91
  const arg1 = args[0];
78
92
  const arg2 = args[1];
79
- let config = await this.getStorageManager().getConfigData();
80
- if (!config || Object.keys(config).length === 0) {
81
- await this.initialize(this._initializeConfig);
82
- config = await this.getStorageManager().getConfigData();
83
- }
93
+ const config = await this.ensureConfigData();
84
94
  if (typeof arg1 === "object" && arg1 !== null && arg1.callOnlyOnRedirect === true) return;
85
95
  if (typeof arg1 === "object" && arg1 !== null && !(0, __thunderid_browser.isEmpty)(arg1) && ("executionId" in arg1 || "applicationId" in arg1)) {
86
96
  const authIdFromUrl = new URL(window.location.href).searchParams.get("authId") ?? "";
@@ -111,6 +121,7 @@ var ThunderIDReactClient = class extends __thunderid_browser.ThunderIDBrowserCli
111
121
  });
112
122
  }
113
123
  async signInSilently(options) {
124
+ await this.ensureConfigData();
114
125
  return super.signInSilently(options);
115
126
  }
116
127
  async signUp(...args) {
@@ -1 +1 @@
1
- {"version":3,"file":"ThunderIDReactClient.cjs","names":["ThunderIDBrowserClient","isInitialized: boolean","ThunderIDRuntimeError","claims: User","arg1: any","arg2: any","config: ThunderIDReactConfig | undefined","authIdFromUrl: string","authIdFromStorage: string","response: EmbeddedSignInFlowResponse","EmbeddedSignInFlowStatus","decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }","createdAt: number","expiresIn: number","config: ThunderIDReactConfig","firstArg: any","baseUrl: string","response: any","EmbeddedSignUpFlowStatus","decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }"],"sources":["../../src/ThunderIDReactClient.ts"],"sourcesContent":["// Copyright 2025-2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ThunderIDBrowserClient,\n UserProfile,\n SignInOptions,\n User,\n SignUpOptions,\n ThunderIDRuntimeError,\n executeEmbeddedSignInFlow,\n IdToken,\n extractUserClaimsFromIdToken,\n TokenResponse,\n HttpRequestConfig,\n HttpResponse,\n TokenExchangeRequestConfig,\n isEmpty,\n EmbeddedSignInFlowResponse,\n executeEmbeddedSignUpFlow,\n executeEmbeddedRecoveryFlow,\n EmbeddedSignInFlowStatus,\n EmbeddedSignUpFlowStatus,\n resolveResourceEndpoint,\n} from '@thunderid/browser';\nimport {ThunderIDReactConfig} from './models/config';\n\nclass ThunderIDReactClient<T extends ThunderIDReactConfig = ThunderIDReactConfig> extends ThunderIDBrowserClient<T> {\n private loadingState = false;\n\n private _initializeConfig: ThunderIDReactConfig | undefined;\n\n constructor(instanceId = 0) {\n super(instanceId);\n }\n\n private setLoading(loading: boolean): void {\n this.loadingState = loading;\n }\n\n private async withLoading<TResult>(operation: () => Promise<TResult>): Promise<TResult> {\n this.setLoading(true);\n try {\n const result: TResult = await operation();\n return result;\n } finally {\n this.setLoading(false);\n }\n }\n\n override initialize(config: ThunderIDReactConfig): Promise<boolean> {\n return this.withLoading(async () => {\n this._initializeConfig = {\n ...config,\n periodicTokenRefresh:\n config?.tokenLifecycle?.refreshToken?.autoRefresh ?? (config as any)?.periodicTokenRefresh,\n } as any;\n\n return super.initialize(this._initializeConfig as unknown as T);\n });\n }\n\n override reInitialize(config: Partial<ThunderIDReactConfig>): Promise<boolean> {\n return this.withLoading(async () => {\n let isInitialized: boolean;\n\n try {\n await super.reInitialize(config as Partial<T>);\n isInitialized = true;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to check if the client is initialized: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDReactClient-reInitialize-RuntimeError-001',\n 'react',\n 'An error occurred while checking the initialization status of the client.',\n );\n }\n\n return isInitialized;\n });\n }\n\n override async updateUserProfile(): Promise<User> {\n throw new Error('Not implemented');\n }\n\n override async getUser(): Promise<User> {\n return extractUserClaimsFromIdToken(await this.getDecodedIdToken());\n }\n\n override async getDecodedIdToken(sessionId?: string): Promise<IdToken> {\n return super.getDecodedIdToken(sessionId);\n }\n\n override async getIdToken(): Promise<string> {\n return this.withLoading(async () => super.getIdToken());\n }\n\n override async getUserProfile(): Promise<UserProfile> {\n return this.withLoading(async () => {\n const claims: User = extractUserClaimsFromIdToken(await this.getDecodedIdToken());\n return {\n flattenedProfile: claims,\n profile: claims,\n schemas: [],\n };\n });\n }\n\n override isLoading(): boolean {\n return this.loadingState;\n }\n\n override async isSignedIn(): Promise<boolean> {\n return super.isSignedIn();\n }\n\n override async exchangeToken(config: TokenExchangeRequestConfig): Promise<TokenResponse | Response> {\n return this.withLoading(async () => super.exchangeToken(config) as unknown as TokenResponse | Response);\n }\n\n override async signIn(...args: any[]): Promise<User | EmbeddedSignInFlowResponse> {\n return this.withLoading(async () => {\n const arg1: any = args[0];\n const arg2: any = args[1];\n\n let config: ThunderIDReactConfig | undefined = (await this.getStorageManager().getConfigData()) as\n | ThunderIDReactConfig\n | undefined;\n\n // NOTE: With React 19 strict mode, the initialization logic runs twice, and there's an intermittent\n // issue where the config object is not getting stored in the storage layer with Vite scaffolding.\n // Hence, we need to check if the client is initialized but the config object is empty, and reinitialize.\n if (!config || Object.keys(config).length === 0) {\n await this.initialize(this._initializeConfig!);\n // Reload the config persisted by initialization so downstream endpoint resolution\n // (baseUrl and the flowExecute override) uses the recovered values, not the stale empty config.\n config = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig | undefined;\n }\n\n if (typeof arg1 === 'object' && arg1 !== null && arg1.callOnlyOnRedirect === true) {\n return undefined as any;\n }\n\n if (\n typeof arg1 === 'object' &&\n arg1 !== null &&\n !isEmpty(arg1) &&\n ('executionId' in arg1 || 'applicationId' in arg1)\n ) {\n const authIdFromUrl: string = new URL(window.location.href).searchParams.get('authId') ?? '';\n const authIdFromStorage: string =\n ((await this.getStorageManager().getHybridDataParameter('authId')) as string) ?? '';\n const authId: string = authIdFromUrl || authIdFromStorage;\n const baseUrl: string = config?.baseUrl ?? '';\n\n const response: EmbeddedSignInFlowResponse = await executeEmbeddedSignInFlow({\n authId,\n baseUrl,\n payload: arg1,\n url: resolveResourceEndpoint('flowExecute', config, arg2?.url),\n });\n\n if (\n response &&\n typeof response === 'object' &&\n response.flowStatus === EmbeddedSignInFlowStatus.Complete &&\n response.assertion\n ) {\n const decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n } = await this.decodeJwtToken<{\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }>(response.assertion);\n\n const createdAt: number = decodedAssertion.iat ? decodedAssertion.iat * 1000 : Date.now();\n const expiresIn: number =\n decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;\n\n await this.setSession({\n access_token: response.assertion,\n created_at: createdAt,\n expires_in: expiresIn,\n id_token: response.assertion,\n scope: decodedAssertion.scope,\n token_type: 'Bearer',\n });\n\n this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion as IdToken) as User);\n }\n\n return response;\n }\n\n return (await super.signIn(...args)) as unknown as User;\n });\n }\n\n override async signInSilently(options?: SignInOptions): Promise<User | boolean> {\n return super.signInSilently(options as Record<string, string | boolean>) as Promise<User | boolean>;\n }\n\n override async signUp(options?: SignUpOptions): Promise<void>;\n override async signUp(payload: any): Promise<any>;\n override async signUp(...args: any[]): Promise<void | any> {\n const config: ThunderIDReactConfig = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig;\n const firstArg: any = args[0];\n const baseUrl: string = config?.baseUrl ?? '';\n\n const authId: string = new URL(window.location.href).searchParams.get('authId') ?? '';\n\n const response: any = await executeEmbeddedSignUpFlow({\n authId,\n baseUrl,\n payload: typeof firstArg === 'object' && 'flowType' in firstArg ? {...firstArg, verbose: true} : firstArg,\n url: resolveResourceEndpoint('flowExecute', config),\n });\n\n if (\n response &&\n typeof response === 'object' &&\n response.flowStatus === EmbeddedSignUpFlowStatus.Complete &&\n response.assertion\n ) {\n const decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n } = await this.decodeJwtToken<{\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }>(response.assertion);\n\n const createdAt: number = decodedAssertion.iat ? decodedAssertion.iat * 1000 : Date.now();\n const expiresIn: number =\n decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;\n\n await this.setSession({\n access_token: response.assertion,\n created_at: createdAt,\n expires_in: expiresIn,\n id_token: response.assertion,\n scope: decodedAssertion.scope,\n token_type: 'Bearer',\n });\n\n this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion as IdToken) as User);\n }\n\n return response;\n }\n\n override async recover(payload?: any): Promise<any> {\n const config: ThunderIDReactConfig = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig;\n\n return executeEmbeddedRecoveryFlow({\n baseUrl: config?.baseUrl,\n payload: {...payload, verbose: true},\n url: resolveResourceEndpoint('flowExecute', config),\n }) as any;\n }\n\n public override getStorageManager(): any {\n return super.getStorageManager();\n }\n\n async request(requestConfig?: HttpRequestConfig): Promise<HttpResponse<any>> {\n return super.httpRequest(requestConfig!) as Promise<HttpResponse<any>>;\n }\n\n async requestAll(requestConfigs?: HttpRequestConfig[]): Promise<HttpResponse<any>[]> {\n return super.httpRequestAll(requestConfigs!) as Promise<HttpResponse<any>[]>;\n }\n}\n\nexport default ThunderIDReactClient;\n"],"mappings":";;;;;AA2BA,IAAM,uBAAN,cAA0FA,2CAA0B;CAClH,AAAQ,eAAe;CAEvB,AAAQ;CAER,YAAY,aAAa,GAAG;AAC1B,QAAM,WAAW;;CAGnB,AAAQ,WAAW,SAAwB;AACzC,OAAK,eAAe;;CAGtB,MAAc,YAAqB,WAAqD;AACtF,OAAK,WAAW,KAAK;AACrB,MAAI;AAEF,UADwB,MAAM,WAAW;YAEjC;AACR,QAAK,WAAW,MAAM;;;CAI1B,AAAS,WAAW,QAAgD;AAClE,SAAO,KAAK,YAAY,YAAY;AAClC,QAAK,oBAAoB;IACvB,GAAG;IACH,sBACE,QAAQ,gBAAgB,cAAc,eAAgB,QAAgB;IACzE;AAED,UAAO,MAAM,WAAW,KAAK,kBAAkC;IAC/D;;CAGJ,AAAS,aAAa,QAAyD;AAC7E,SAAO,KAAK,YAAY,YAAY;GAClC,IAAIC;AAEJ,OAAI;AACF,UAAM,MAAM,aAAa,OAAqB;AAC9C,oBAAgB;YACT,OAAO;AACd,UAAM,IAAIC,0CACR,iDAAiD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IACvG,sDACA,SACA,4EACD;;AAGH,UAAO;IACP;;CAGJ,MAAe,oBAAmC;AAChD,QAAM,IAAI,MAAM,kBAAkB;;CAGpC,MAAe,UAAyB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AAiB,MAAM;AAE/F,SAAM,KAAK,WAAW;IACpB,cAAc,SAAS;IACvB,YAAY;IACZ,YAAY;IACZ,UAAU,SAAS;IACnB,OAAO,iBAAiB;IACxB,YAAY;IACb,CAAC;AAEF,QAAK,mEAA0C,iBAA4B,CAAS;;AAGtF,SAAO;;CAGT,MAAe,QAAQ,SAA6B;EAClD,MAAMC,SAAgC,MAAM,KAAK,mBAAmB,CAAC,eAAe;AAEpF,8DAAmC;GACjC,SAAS,QAAQ;GACjB,SAAS;IAAC,GAAG;IAAS,SAAS;IAAK;GACpC,sDAA6B,eAAe,OAAO;GACpD,CAAC;;CAGJ,AAAgB,oBAAyB;AACvC,SAAO,MAAM,mBAAmB;;CAGlC,MAAM,QAAQ,eAA+D;AAC3E,SAAO,MAAM,YAAY,cAAe;;CAG1C,MAAM,WAAW,gBAAoE;AACnF,SAAO,MAAM,eAAe,eAAgB;;;AAIhD,mCAAe"}
1
+ {"version":3,"file":"ThunderIDReactClient.cjs","names":["ThunderIDBrowserClient","config: ThunderIDReactConfig | undefined","isInitialized: boolean","ThunderIDRuntimeError","claims: User","arg1: any","arg2: any","authIdFromUrl: string","authIdFromStorage: string","response: EmbeddedSignInFlowResponse","EmbeddedSignInFlowStatus","decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }","createdAt: number","expiresIn: number","config: ThunderIDReactConfig","firstArg: any","baseUrl: string","response: any","EmbeddedSignUpFlowStatus","decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }"],"sources":["../../src/ThunderIDReactClient.ts"],"sourcesContent":["// Copyright 2025-2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ThunderIDBrowserClient,\n UserProfile,\n SignInOptions,\n User,\n SignUpOptions,\n ThunderIDRuntimeError,\n executeEmbeddedSignInFlow,\n IdToken,\n extractUserClaimsFromIdToken,\n TokenResponse,\n HttpRequestConfig,\n HttpResponse,\n TokenExchangeRequestConfig,\n isEmpty,\n EmbeddedSignInFlowResponse,\n executeEmbeddedSignUpFlow,\n executeEmbeddedRecoveryFlow,\n EmbeddedSignInFlowStatus,\n EmbeddedSignUpFlowStatus,\n resolveResourceEndpoint,\n} from '@thunderid/browser';\nimport {ThunderIDReactConfig} from './models/config';\n\nclass ThunderIDReactClient<T extends ThunderIDReactConfig = ThunderIDReactConfig> extends ThunderIDBrowserClient<T> {\n private loadingState = false;\n\n private _initializeConfig: ThunderIDReactConfig | undefined;\n\n constructor(instanceId = 0) {\n super(instanceId);\n }\n\n private setLoading(loading: boolean): void {\n this.loadingState = loading;\n }\n\n private async withLoading<TResult>(operation: () => Promise<TResult>): Promise<TResult> {\n this.setLoading(true);\n try {\n const result: TResult = await operation();\n return result;\n } finally {\n this.setLoading(false);\n }\n }\n\n /**\n * Returns the stored config, re-running initialization first when it has gone missing.\n *\n * NOTE: With React 19 strict mode, the initialization logic runs twice, and there's an intermittent\n * issue where the config object is not getting stored in the storage layer with Vite scaffolding.\n * An operation that resolves endpoints from a lost config fails (for example \"required endpoints\n * are missing\"), so recover it from the config this client was initialized with.\n */\n private async ensureConfigData(): Promise<ThunderIDReactConfig | undefined> {\n const config: ThunderIDReactConfig | undefined = (await this.getStorageManager().getConfigData()) as\n | ThunderIDReactConfig\n | undefined;\n const isConfigLost: boolean =\n !config || Object.keys(config).length === 0 || (Boolean(this._initializeConfig?.baseUrl) && !config.baseUrl);\n\n if (!isConfigLost || !this._initializeConfig) {\n return config;\n }\n\n await this.initialize(this._initializeConfig);\n\n // Reload the config persisted by initialization so downstream endpoint resolution\n // (baseUrl and the flowExecute override) uses the recovered values, not the stale empty config.\n return (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig | undefined;\n }\n\n override initialize(config: ThunderIDReactConfig): Promise<boolean> {\n return this.withLoading(async () => {\n this._initializeConfig = {\n ...config,\n periodicTokenRefresh:\n config?.tokenLifecycle?.refreshToken?.autoRefresh ?? (config as any)?.periodicTokenRefresh,\n } as any;\n\n return super.initialize(this._initializeConfig as unknown as T);\n });\n }\n\n override reInitialize(config: Partial<ThunderIDReactConfig>): Promise<boolean> {\n return this.withLoading(async () => {\n let isInitialized: boolean;\n\n try {\n await super.reInitialize(config as Partial<T>);\n isInitialized = true;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to check if the client is initialized: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDReactClient-reInitialize-RuntimeError-001',\n 'react',\n 'An error occurred while checking the initialization status of the client.',\n );\n }\n\n return isInitialized;\n });\n }\n\n override async updateUserProfile(): Promise<User> {\n throw new Error('Not implemented');\n }\n\n override async getUser(): Promise<User> {\n return extractUserClaimsFromIdToken(await this.getDecodedIdToken());\n }\n\n override async getDecodedIdToken(sessionId?: string): Promise<IdToken> {\n return super.getDecodedIdToken(sessionId);\n }\n\n override async getIdToken(): Promise<string> {\n return this.withLoading(async () => super.getIdToken());\n }\n\n override async getUserProfile(): Promise<UserProfile> {\n return this.withLoading(async () => {\n const claims: User = extractUserClaimsFromIdToken(await this.getDecodedIdToken());\n return {\n flattenedProfile: claims,\n profile: claims,\n schemas: [],\n };\n });\n }\n\n override isLoading(): boolean {\n return this.loadingState;\n }\n\n override async isSignedIn(): Promise<boolean> {\n return super.isSignedIn();\n }\n\n override async exchangeToken(config: TokenExchangeRequestConfig): Promise<TokenResponse | Response> {\n return this.withLoading(async () => super.exchangeToken(config) as unknown as TokenResponse | Response);\n }\n\n override async signIn(...args: any[]): Promise<User | EmbeddedSignInFlowResponse> {\n return this.withLoading(async () => {\n const arg1: any = args[0];\n const arg2: any = args[1];\n\n const config: ThunderIDReactConfig | undefined = await this.ensureConfigData();\n\n if (typeof arg1 === 'object' && arg1 !== null && arg1.callOnlyOnRedirect === true) {\n return undefined as any;\n }\n\n if (\n typeof arg1 === 'object' &&\n arg1 !== null &&\n !isEmpty(arg1) &&\n ('executionId' in arg1 || 'applicationId' in arg1)\n ) {\n const authIdFromUrl: string = new URL(window.location.href).searchParams.get('authId') ?? '';\n const authIdFromStorage: string =\n ((await this.getStorageManager().getHybridDataParameter('authId')) as string) ?? '';\n const authId: string = authIdFromUrl || authIdFromStorage;\n const baseUrl: string = config?.baseUrl ?? '';\n\n const response: EmbeddedSignInFlowResponse = await executeEmbeddedSignInFlow({\n authId,\n baseUrl,\n payload: arg1,\n url: resolveResourceEndpoint('flowExecute', config, arg2?.url),\n });\n\n if (\n response &&\n typeof response === 'object' &&\n response.flowStatus === EmbeddedSignInFlowStatus.Complete &&\n response.assertion\n ) {\n const decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n } = await this.decodeJwtToken<{\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }>(response.assertion);\n\n const createdAt: number = decodedAssertion.iat ? decodedAssertion.iat * 1000 : Date.now();\n const expiresIn: number =\n decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;\n\n await this.setSession({\n access_token: response.assertion,\n created_at: createdAt,\n expires_in: expiresIn,\n id_token: response.assertion,\n scope: decodedAssertion.scope,\n token_type: 'Bearer',\n });\n\n this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion as IdToken) as User);\n }\n\n return response;\n }\n\n return (await super.signIn(...args)) as unknown as User;\n });\n }\n\n override async signInSilently(options?: SignInOptions): Promise<User | boolean> {\n await this.ensureConfigData();\n\n return super.signInSilently(options as Record<string, string | boolean>) as Promise<User | boolean>;\n }\n\n override async signUp(options?: SignUpOptions): Promise<void>;\n override async signUp(payload: any): Promise<any>;\n override async signUp(...args: any[]): Promise<void | any> {\n const config: ThunderIDReactConfig = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig;\n const firstArg: any = args[0];\n const baseUrl: string = config?.baseUrl ?? '';\n\n const authId: string = new URL(window.location.href).searchParams.get('authId') ?? '';\n\n const response: any = await executeEmbeddedSignUpFlow({\n authId,\n baseUrl,\n payload: typeof firstArg === 'object' && 'flowType' in firstArg ? {...firstArg, verbose: true} : firstArg,\n url: resolveResourceEndpoint('flowExecute', config),\n });\n\n if (\n response &&\n typeof response === 'object' &&\n response.flowStatus === EmbeddedSignUpFlowStatus.Complete &&\n response.assertion\n ) {\n const decodedAssertion: {\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n } = await this.decodeJwtToken<{\n [key: string]: unknown;\n exp?: number;\n iat?: number;\n scope?: string;\n }>(response.assertion);\n\n const createdAt: number = decodedAssertion.iat ? decodedAssertion.iat * 1000 : Date.now();\n const expiresIn: number =\n decodedAssertion.exp && decodedAssertion.iat ? decodedAssertion.exp - decodedAssertion.iat : 3600;\n\n await this.setSession({\n access_token: response.assertion,\n created_at: createdAt,\n expires_in: expiresIn,\n id_token: response.assertion,\n scope: decodedAssertion.scope,\n token_type: 'Bearer',\n });\n\n this.notifySignIn(extractUserClaimsFromIdToken(decodedAssertion as IdToken) as User);\n }\n\n return response;\n }\n\n override async recover(payload?: any): Promise<any> {\n const config: ThunderIDReactConfig = (await this.getStorageManager().getConfigData()) as ThunderIDReactConfig;\n\n return executeEmbeddedRecoveryFlow({\n baseUrl: config?.baseUrl,\n payload: {...payload, verbose: true},\n url: resolveResourceEndpoint('flowExecute', config),\n }) as any;\n }\n\n public override getStorageManager(): any {\n return super.getStorageManager();\n }\n\n async request(requestConfig?: HttpRequestConfig): Promise<HttpResponse<any>> {\n return super.httpRequest(requestConfig!) as Promise<HttpResponse<any>>;\n }\n\n async requestAll(requestConfigs?: HttpRequestConfig[]): Promise<HttpResponse<any>[]> {\n return super.httpRequestAll(requestConfigs!) as Promise<HttpResponse<any>[]>;\n }\n}\n\nexport default ThunderIDReactClient;\n"],"mappings":";;;;;AA2BA,IAAM,uBAAN,cAA0FA,2CAA0B;CAClH,AAAQ,eAAe;CAEvB,AAAQ;CAER,YAAY,aAAa,GAAG;AAC1B,QAAM,WAAW;;CAGnB,AAAQ,WAAW,SAAwB;AACzC,OAAK,eAAe;;CAGtB,MAAc,YAAqB,WAAqD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;;CAGlC,MAAM,QAAQ,eAA+D;AAC3E,SAAO,MAAM,YAAY,cAAe;;CAG1C,MAAM,WAAW,gBAAoE;AACnF,SAAO,MAAM,eAAe,eAAgB;;;AAIhD,mCAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thunderid/react",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "React SDK for ThunderID",
5
5
  "keywords": [
6
6
  "thunderid",
@@ -60,7 +60,7 @@
60
60
  "dependencies": {
61
61
  "@emotion/css": "11.13.5",
62
62
  "@floating-ui/react": "0.27.12",
63
- "@thunderid/browser": "^1.2.1",
63
+ "@thunderid/browser": "^1.2.2",
64
64
  "dompurify": "3.4.13",
65
65
  "tslib": "2.8.1"
66
66
  },