@thunderid/nextjs 0.10.2 → 0.10.4
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.
- package/dist/ThunderIDNextClient.d.ts +0 -17
- package/dist/ThunderIDNextClient.d.ts.map +1 -1
- package/dist/ThunderIDNextClient.js +13 -6
- package/dist/ThunderIDNextClient.js.map +1 -1
- package/dist/cjs/ThunderIDNextClient.cjs +12 -5
- package/dist/cjs/ThunderIDNextClient.cjs.map +1 -1
- package/dist/cjs/client/components/actions/SignInButton/SignInButton.cjs.map +1 -1
- package/dist/cjs/client/components/actions/SignOutButton/SignOutButton.cjs.map +1 -1
- package/dist/cjs/client/components/actions/SignUpButton/SignUpButton.cjs.map +1 -1
- package/dist/cjs/client/components/control/SignedIn/SignedIn.cjs.map +1 -1
- package/dist/cjs/client/components/control/SignedOut/SignedOut.cjs.map +1 -1
- package/dist/cjs/client/components/presentation/SignIn/SignIn.cjs.map +1 -1
- package/dist/cjs/client/components/presentation/SignUp/SignUp.cjs.map +1 -1
- package/dist/cjs/client/components/presentation/User/User.cjs.map +1 -1
- package/dist/cjs/client/components/presentation/UserAvatar/UserAvatar.cjs.map +1 -1
- package/dist/cjs/client/components/presentation/UserDropdown/UserDropdown.cjs.map +1 -1
- package/dist/cjs/client/components/presentation/UserProfile/UserProfile.cjs.map +1 -1
- package/dist/cjs/client/contexts/ThunderID/ThunderIDContext.cjs.map +1 -1
- package/dist/cjs/client/contexts/ThunderID/ThunderIDProvider.cjs.map +1 -1
- package/dist/cjs/client/contexts/ThunderID/useThunderID.cjs.map +1 -1
- package/dist/cjs/constants/sessionConstants.cjs +0 -17
- package/dist/cjs/constants/sessionConstants.cjs.map +1 -1
- package/dist/cjs/server/ThunderIDProvider.cjs +1 -0
- package/dist/cjs/server/ThunderIDProvider.cjs.map +1 -1
- package/dist/cjs/server/actions/clearSession.cjs.map +1 -1
- package/dist/cjs/server/actions/getAccessToken.cjs.map +1 -1
- package/dist/cjs/server/actions/getClientOrigin.cjs.map +1 -1
- package/dist/cjs/server/actions/getSessionId.cjs.map +1 -1
- package/dist/cjs/server/actions/getSessionPayload.cjs.map +1 -1
- package/dist/cjs/server/actions/getUserAction.cjs.map +1 -1
- package/dist/cjs/server/actions/getUserProfileAction.cjs.map +1 -1
- package/dist/cjs/server/actions/handleOAuthCallbackAction.cjs.map +1 -1
- package/dist/cjs/server/actions/isSignedIn.cjs.map +1 -1
- package/dist/cjs/server/actions/refreshToken.cjs.map +1 -1
- package/dist/cjs/server/actions/signInAction.cjs.map +1 -1
- package/dist/cjs/server/actions/signOutAction.cjs.map +1 -1
- package/dist/cjs/server/actions/signUpAction.cjs.map +1 -1
- package/dist/cjs/server/actions/updateUserProfileAction.cjs.map +1 -1
- package/dist/cjs/server/getClient.cjs.map +1 -1
- package/dist/cjs/server/proxy/createRouteMatcher.cjs.map +1 -1
- package/dist/cjs/server/proxy/thunderIDProxy.cjs.map +1 -1
- package/dist/cjs/server/thunderid.cjs.map +1 -1
- package/dist/cjs/utils/SessionManager.cjs.map +1 -1
- package/dist/cjs/utils/decorateConfigWithNextEnv.cjs.map +1 -1
- package/dist/cjs/utils/handleRefreshToken.cjs.map +1 -1
- package/dist/cjs/utils/logger.cjs.map +1 -1
- package/dist/cjs/utils/sessionUtils.cjs.map +1 -1
- package/dist/client/components/actions/SignInButton/SignInButton.d.ts +0 -17
- package/dist/client/components/actions/SignInButton/SignInButton.d.ts.map +1 -1
- package/dist/client/components/actions/SignInButton/SignInButton.js.map +1 -1
- package/dist/client/components/actions/SignOutButton/SignOutButton.d.ts +0 -17
- package/dist/client/components/actions/SignOutButton/SignOutButton.d.ts.map +1 -1
- package/dist/client/components/actions/SignOutButton/SignOutButton.js.map +1 -1
- package/dist/client/components/actions/SignUpButton/SignUpButton.d.ts +0 -17
- package/dist/client/components/actions/SignUpButton/SignUpButton.d.ts.map +1 -1
- package/dist/client/components/actions/SignUpButton/SignUpButton.js.map +1 -1
- package/dist/client/components/control/Loading/Loading.d.ts +0 -17
- package/dist/client/components/control/Loading/Loading.d.ts.map +1 -1
- package/dist/client/components/control/SignedIn/SignedIn.d.ts +0 -17
- package/dist/client/components/control/SignedIn/SignedIn.d.ts.map +1 -1
- package/dist/client/components/control/SignedIn/SignedIn.js.map +1 -1
- package/dist/client/components/control/SignedOut/SignedOut.d.ts +0 -17
- package/dist/client/components/control/SignedOut/SignedOut.d.ts.map +1 -1
- package/dist/client/components/control/SignedOut/SignedOut.js.map +1 -1
- package/dist/client/components/presentation/SignIn/SignIn.d.ts +0 -17
- package/dist/client/components/presentation/SignIn/SignIn.d.ts.map +1 -1
- package/dist/client/components/presentation/SignIn/SignIn.js.map +1 -1
- package/dist/client/components/presentation/SignUp/SignUp.d.ts +0 -17
- package/dist/client/components/presentation/SignUp/SignUp.d.ts.map +1 -1
- package/dist/client/components/presentation/SignUp/SignUp.js.map +1 -1
- package/dist/client/components/presentation/User/User.d.ts +0 -17
- package/dist/client/components/presentation/User/User.d.ts.map +1 -1
- package/dist/client/components/presentation/User/User.js.map +1 -1
- package/dist/client/components/presentation/UserAvatar/UserAvatar.d.ts +0 -17
- package/dist/client/components/presentation/UserAvatar/UserAvatar.d.ts.map +1 -1
- package/dist/client/components/presentation/UserAvatar/UserAvatar.js.map +1 -1
- package/dist/client/components/presentation/UserDropdown/UserDropdown.d.ts +0 -17
- package/dist/client/components/presentation/UserDropdown/UserDropdown.d.ts.map +1 -1
- package/dist/client/components/presentation/UserDropdown/UserDropdown.js.map +1 -1
- package/dist/client/components/presentation/UserProfile/UserProfile.d.ts +0 -17
- package/dist/client/components/presentation/UserProfile/UserProfile.d.ts.map +1 -1
- package/dist/client/components/presentation/UserProfile/UserProfile.js.map +1 -1
- package/dist/client/contexts/ThunderID/ThunderIDContext.d.ts +0 -17
- package/dist/client/contexts/ThunderID/ThunderIDContext.d.ts.map +1 -1
- package/dist/client/contexts/ThunderID/ThunderIDContext.js.map +1 -1
- package/dist/client/contexts/ThunderID/ThunderIDProvider.d.ts +0 -17
- package/dist/client/contexts/ThunderID/ThunderIDProvider.d.ts.map +1 -1
- package/dist/client/contexts/ThunderID/ThunderIDProvider.js.map +1 -1
- package/dist/client/contexts/ThunderID/useThunderID.d.ts +0 -17
- package/dist/client/contexts/ThunderID/useThunderID.d.ts.map +1 -1
- package/dist/client/contexts/ThunderID/useThunderID.js.map +1 -1
- package/dist/client/index.d.ts +0 -17
- package/dist/client/index.d.ts.map +1 -1
- package/dist/configs/InternalAuthAPIRoutesConfig.d.ts +0 -17
- package/dist/configs/InternalAuthAPIRoutesConfig.d.ts.map +1 -1
- package/dist/constants/sessionConstants.d.ts +0 -17
- package/dist/constants/sessionConstants.d.ts.map +1 -1
- package/dist/constants/sessionConstants.js +0 -17
- package/dist/constants/sessionConstants.js.map +1 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/models/api.d.ts +0 -17
- package/dist/models/api.d.ts.map +1 -1
- package/dist/models/config.d.ts +0 -17
- package/dist/models/config.d.ts.map +1 -1
- package/dist/server/ThunderIDProvider.d.ts +0 -17
- package/dist/server/ThunderIDProvider.d.ts.map +1 -1
- package/dist/server/ThunderIDProvider.js +2 -1
- package/dist/server/ThunderIDProvider.js.map +1 -1
- package/dist/server/actions/clearSession.d.ts +0 -17
- package/dist/server/actions/clearSession.d.ts.map +1 -1
- package/dist/server/actions/clearSession.js.map +1 -1
- package/dist/server/actions/getAccessToken.d.ts +0 -17
- package/dist/server/actions/getAccessToken.d.ts.map +1 -1
- package/dist/server/actions/getAccessToken.js.map +1 -1
- package/dist/server/actions/getClientOrigin.d.ts +0 -17
- package/dist/server/actions/getClientOrigin.d.ts.map +1 -1
- package/dist/server/actions/getClientOrigin.js.map +1 -1
- package/dist/server/actions/getSessionId.d.ts +0 -17
- package/dist/server/actions/getSessionId.d.ts.map +1 -1
- package/dist/server/actions/getSessionId.js.map +1 -1
- package/dist/server/actions/getSessionPayload.d.ts +0 -17
- package/dist/server/actions/getSessionPayload.d.ts.map +1 -1
- package/dist/server/actions/getSessionPayload.js.map +1 -1
- package/dist/server/actions/getUserAction.d.ts +0 -17
- package/dist/server/actions/getUserAction.d.ts.map +1 -1
- package/dist/server/actions/getUserAction.js.map +1 -1
- package/dist/server/actions/getUserProfileAction.d.ts +0 -17
- package/dist/server/actions/getUserProfileAction.d.ts.map +1 -1
- package/dist/server/actions/getUserProfileAction.js.map +1 -1
- package/dist/server/actions/handleOAuthCallbackAction.d.ts +0 -17
- package/dist/server/actions/handleOAuthCallbackAction.d.ts.map +1 -1
- package/dist/server/actions/handleOAuthCallbackAction.js.map +1 -1
- package/dist/server/actions/isSignedIn.d.ts +0 -17
- package/dist/server/actions/isSignedIn.d.ts.map +1 -1
- package/dist/server/actions/isSignedIn.js.map +1 -1
- package/dist/server/actions/refreshToken.d.ts +0 -17
- package/dist/server/actions/refreshToken.d.ts.map +1 -1
- package/dist/server/actions/refreshToken.js.map +1 -1
- package/dist/server/actions/signInAction.d.ts +0 -17
- package/dist/server/actions/signInAction.d.ts.map +1 -1
- package/dist/server/actions/signInAction.js.map +1 -1
- package/dist/server/actions/signOutAction.d.ts +0 -17
- package/dist/server/actions/signOutAction.d.ts.map +1 -1
- package/dist/server/actions/signOutAction.js.map +1 -1
- package/dist/server/actions/signUpAction.d.ts +0 -17
- package/dist/server/actions/signUpAction.d.ts.map +1 -1
- package/dist/server/actions/signUpAction.js.map +1 -1
- package/dist/server/actions/updateUserProfileAction.d.ts +0 -17
- package/dist/server/actions/updateUserProfileAction.d.ts.map +1 -1
- package/dist/server/actions/updateUserProfileAction.js.map +1 -1
- package/dist/server/getClient.d.ts +0 -17
- package/dist/server/getClient.d.ts.map +1 -1
- package/dist/server/getClient.js.map +1 -1
- package/dist/server/index.d.ts +0 -17
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/proxy/createRouteMatcher.d.ts +0 -17
- package/dist/server/proxy/createRouteMatcher.d.ts.map +1 -1
- package/dist/server/proxy/createRouteMatcher.js.map +1 -1
- package/dist/server/proxy/thunderIDProxy.d.ts +0 -17
- package/dist/server/proxy/thunderIDProxy.d.ts.map +1 -1
- package/dist/server/proxy/thunderIDProxy.js.map +1 -1
- package/dist/server/thunderid.d.ts +0 -17
- package/dist/server/thunderid.d.ts.map +1 -1
- package/dist/server/thunderid.js.map +1 -1
- package/dist/utils/SessionManager.d.ts +0 -17
- package/dist/utils/SessionManager.d.ts.map +1 -1
- package/dist/utils/SessionManager.js.map +1 -1
- package/dist/utils/createRouteMatcher.d.ts +0 -17
- package/dist/utils/createRouteMatcher.d.ts.map +1 -1
- package/dist/utils/decorateConfigWithNextEnv.d.ts +0 -17
- package/dist/utils/decorateConfigWithNextEnv.d.ts.map +1 -1
- package/dist/utils/decorateConfigWithNextEnv.js.map +1 -1
- package/dist/utils/handleRefreshToken.d.ts +0 -17
- package/dist/utils/handleRefreshToken.d.ts.map +1 -1
- package/dist/utils/handleRefreshToken.js.map +1 -1
- package/dist/utils/logger.d.ts +0 -17
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/sessionUtils.d.ts +0 -17
- package/dist/utils/sessionUtils.d.ts.map +1 -1
- package/dist/utils/sessionUtils.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
|
|
3
|
-
*
|
|
4
|
-
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
|
-
* Version 2.0 (the "License"); you may not use this file except
|
|
6
|
-
* in compliance with the License.
|
|
7
|
-
* You may obtain a copy of the License at
|
|
8
|
-
*
|
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing,
|
|
12
|
-
* software distributed under the License is distributed on an
|
|
13
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
* KIND, either express or implied. See the License for the
|
|
15
|
-
* specific language governing permissions and limitations
|
|
16
|
-
* under the License.
|
|
17
|
-
*/
|
|
18
1
|
import { ThunderIDNodeClient, ExtendedAuthorizeRequestUrlParams, IdToken, SignInOptions, SignUpOptions, Storage, TokenExchangeRequestConfig, TokenResponse, User, UserProfile } from '@thunderid/node';
|
|
19
2
|
import { ThunderIDNextConfig } from './models/config';
|
|
20
3
|
declare class ThunderIDNextClient<T extends ThunderIDNextConfig = ThunderIDNextConfig> extends ThunderIDNodeClient<T> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThunderIDNextClient.d.ts","sourceRoot":"","sources":["../src/ThunderIDNextClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ThunderIDNextClient.d.ts","sourceRoot":"","sources":["../src/ThunderIDNextClient.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,mBAAmB,EAInB,iCAAiC,EACjC,OAAO,EACP,aAAa,EACb,aAAa,EACb,OAAO,EACP,0BAA0B,EAC1B,aAAa,EACb,IAAI,EACJ,WAAW,EAOZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAC,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAKpD,cAAM,mBAAmB,CAAC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IACpG,aAAa,UAAS;;YAMf,iBAAiB;IAehB,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAwC1D,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAclD,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBvC,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IA2BrD,iBAAiB,CAAC,OAA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AmB,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import getClientOrigin_default from "./server/actions/getClientOrigin.js";
|
|
2
2
|
import getSessionId_default from "./server/actions/getSessionId.js";
|
|
3
3
|
import decorateConfigWithNextEnv_default from "./utils/decorateConfigWithNextEnv.js";
|
|
4
|
-
import { ThunderIDNodeClient, ThunderIDRuntimeError, executeEmbeddedSignInFlow, extractUserClaimsFromIdToken, generateFlattenedUserProfile, getUsersMe, updateMeProfile } from "@thunderid/node";
|
|
4
|
+
import { ThunderIDNodeClient, ThunderIDRuntimeError, executeEmbeddedSignInFlow, extractUserClaimsFromIdToken, generateFlattenedUserProfile, getUsersMe, resolveResourceEndpoint, updateMeProfile } from "@thunderid/node";
|
|
5
5
|
|
|
6
6
|
//#region src/ThunderIDNextClient.ts
|
|
7
7
|
var ThunderIDNextClient = class extends ThunderIDNodeClient {
|
|
@@ -44,9 +44,11 @@ var ThunderIDNextClient = class extends ThunderIDNodeClient {
|
|
|
44
44
|
await this.ensureInitialized();
|
|
45
45
|
const resolvedSessionId = userId || await getSessionId_default();
|
|
46
46
|
try {
|
|
47
|
-
const
|
|
47
|
+
const configData = await this.getStorageManager().getConfigData();
|
|
48
|
+
const baseUrl = configData?.baseUrl;
|
|
48
49
|
return await getUsersMe({
|
|
49
50
|
baseUrl,
|
|
51
|
+
url: resolveResourceEndpoint("usersMe", configData),
|
|
50
52
|
headers: { Authorization: `Bearer ${await this.getAccessToken(userId)}` }
|
|
51
53
|
});
|
|
52
54
|
} catch (error) {
|
|
@@ -56,9 +58,11 @@ var ThunderIDNextClient = class extends ThunderIDNodeClient {
|
|
|
56
58
|
async getUserProfile(userId) {
|
|
57
59
|
await this.ensureInitialized();
|
|
58
60
|
try {
|
|
59
|
-
const
|
|
61
|
+
const configData = await this.getStorageManager().getConfigData();
|
|
62
|
+
const baseUrl = configData?.baseUrl;
|
|
60
63
|
const profile = await getUsersMe({
|
|
61
64
|
baseUrl,
|
|
65
|
+
url: resolveResourceEndpoint("usersMe", configData),
|
|
62
66
|
headers: { Authorization: `Bearer ${await this.getAccessToken(userId)}` }
|
|
63
67
|
});
|
|
64
68
|
return {
|
|
@@ -75,9 +79,11 @@ var ThunderIDNextClient = class extends ThunderIDNodeClient {
|
|
|
75
79
|
async updateUserProfile(payload, userId) {
|
|
76
80
|
await this.ensureInitialized();
|
|
77
81
|
try {
|
|
78
|
-
const
|
|
82
|
+
const configData = await this.getStorageManager().getConfigData();
|
|
83
|
+
const baseUrl = configData?.baseUrl;
|
|
79
84
|
return updateMeProfile({
|
|
80
85
|
baseUrl,
|
|
86
|
+
url: resolveResourceEndpoint("usersMe", configData),
|
|
81
87
|
headers: { Authorization: `Bearer ${await this.getAccessToken(userId)}` },
|
|
82
88
|
payload: payload?.payload ?? payload
|
|
83
89
|
});
|
|
@@ -111,11 +117,12 @@ var ThunderIDNextClient = class extends ThunderIDNodeClient {
|
|
|
111
117
|
const arg4 = args[3];
|
|
112
118
|
if (typeof arg1 === "object" && arg1 !== null && ("executionId" in arg1 || "applicationId" in arg1)) {
|
|
113
119
|
await this.ensureInitialized();
|
|
120
|
+
const configData = await this.getStorageManager().getConfigData();
|
|
114
121
|
return executeEmbeddedSignInFlow({
|
|
115
|
-
baseUrl:
|
|
122
|
+
baseUrl: configData?.baseUrl,
|
|
116
123
|
flowSecret: arg2?.flowSecret,
|
|
117
124
|
payload: arg1,
|
|
118
|
-
url: arg2?.url
|
|
125
|
+
url: resolveResourceEndpoint("flowExecute", configData, arg2?.url)
|
|
119
126
|
});
|
|
120
127
|
}
|
|
121
128
|
return super.signIn(arg4, arg3, arg1?.code, arg1?.session_state, arg1?.state, arg1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThunderIDNextClient.js","names":["decorateConfigWithNextEnv","origin: string","getClientOrigin","initialized: boolean","resolvedSessionId: string","getSessionId","baseUrl: string | undefined","profile: User","token: string | undefined","arg1: any","arg2: any","arg3: any","arg4: any","afterSignOutUrl: string","message: string"],"sources":["../src/ThunderIDNextClient.ts"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {\n ThunderIDNodeClient,\n ThunderIDRuntimeError,\n AuthClientConfig,\n EmbeddedSignInFlowResponse,\n ExtendedAuthorizeRequestUrlParams,\n IdToken,\n SignInOptions,\n SignUpOptions,\n Storage,\n TokenExchangeRequestConfig,\n TokenResponse,\n User,\n UserProfile,\n executeEmbeddedSignInFlow,\n extractUserClaimsFromIdToken,\n generateFlattenedUserProfile,\n getUsersMe,\n updateMeProfile,\n} from '@thunderid/node';\nimport {ThunderIDNextConfig} from './models/config';\nimport getClientOrigin from './server/actions/getClientOrigin';\nimport getSessionId from './server/actions/getSessionId';\nimport decorateConfigWithNextEnv from './utils/decorateConfigWithNextEnv';\n\nclass ThunderIDNextClient<T extends ThunderIDNextConfig = ThunderIDNextConfig> extends ThunderIDNodeClient<T> {\n public isInitialized = false;\n\n public constructor() {\n super();\n }\n\n private async ensureInitialized(): Promise<void> {\n if (!this.isInitialized) {\n // Server actions may run in a module context that hasn't been through\n // ThunderIDServerProvider (e.g. a different worker). Try to initialize\n // from environment variables before giving up.\n await this.initialize({} as T);\n }\n\n if (!this.isInitialized) {\n throw new Error(\n '[ThunderIDNextClient] Client is not initialized. Make sure you have wrapped your app with ThunderIDProvider and provided the required configuration (baseUrl, clientId, etc.).',\n );\n }\n }\n\n override async initialize(config: T, storage?: Storage): Promise<boolean> {\n if (this.isInitialized) {\n return Promise.resolve(true);\n }\n\n const {\n baseUrl,\n organizationHandle,\n clientId,\n clientSecret,\n signInUrl,\n afterSignInUrl,\n afterSignOutUrl,\n signUpUrl,\n ...rest\n } = decorateConfigWithNextEnv(config);\n\n const origin: string = await getClientOrigin();\n\n const initialized: boolean = await super.initialize(\n {\n ...rest,\n afterSignInUrl: afterSignInUrl ?? origin,\n afterSignOutUrl: afterSignOutUrl ?? origin,\n baseUrl,\n clientId,\n clientSecret,\n enablePKCE: (rest as any).enablePKCE ?? true,\n organizationHandle,\n signInUrl,\n signUpUrl,\n } as any,\n storage,\n );\n\n this.isInitialized = initialized;\n\n return initialized;\n }\n\n override async reInitialize(config: Partial<T>): Promise<boolean> {\n try {\n await super.reInitialize(config);\n return true;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to re-initialize the client: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDNextClient-reInitialize-RuntimeError-001',\n 'nextjs',\n 'An error occurred while re-initializing the client. Please check your configuration and network connection.',\n );\n }\n }\n\n override async getUser(userId?: string): Promise<User> {\n await this.ensureInitialized();\n const resolvedSessionId: string = userId || (await getSessionId())!;\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n const profile: User = await getUsersMe({\n baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n });\n\n return profile;\n } catch (error) {\n return await super.getUser(resolvedSessionId);\n }\n }\n\n override async getUserProfile(userId?: string): Promise<UserProfile> {\n await this.ensureInitialized();\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n const profile: User = await getUsersMe({\n baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n });\n\n return {\n flattenedProfile: generateFlattenedUserProfile(profile),\n profile,\n };\n } catch (error) {\n return {\n flattenedProfile: extractUserClaimsFromIdToken(await super.getDecodedIdToken(userId)),\n profile: extractUserClaimsFromIdToken(await super.getDecodedIdToken(userId)),\n };\n }\n }\n\n override async updateUserProfile(payload: any, userId?: string): Promise<User> {\n await this.ensureInitialized();\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n return updateMeProfile({\n baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n payload: payload?.payload ?? payload,\n });\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to update user profile: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDNextClient-UpdateProfileError-001',\n 'react',\n 'An error occurred while updating the user profile. Please check your configuration and network connection.',\n );\n }\n }\n\n override isLoading(): boolean {\n return false;\n }\n\n override isSignedIn(sessionId?: string): Promise<boolean> {\n return super.isSignedIn(sessionId);\n }\n\n override exchangeToken(config: TokenExchangeRequestConfig, sessionId?: string): Promise<TokenResponse | Response> {\n return super.exchangeToken(config, sessionId) as unknown as Promise<TokenResponse | Response>;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override async getAccessToken(_sessionId?: string): Promise<string> {\n const {default: getAccessToken} = await import('./server/actions/getAccessToken');\n const token: string | undefined = await getAccessToken();\n\n if (typeof token !== 'string' || !token) {\n throw new ThunderIDRuntimeError(\n 'Failed to get access token.',\n 'ThunderIDNextClient-getAccessToken-RuntimeError-003',\n 'nextjs',\n 'An error occurred while obtaining the access token. Please check your configuration and network connection.',\n );\n }\n\n return token;\n }\n\n override async getDecodedIdToken(sessionId?: string, idToken?: string): Promise<IdToken> {\n await this.ensureInitialized();\n return await super.getDecodedIdToken(sessionId, idToken);\n }\n\n override async signIn(...args: any[]): Promise<any> {\n const arg1: any = args[0];\n const arg2: any = args[1];\n const arg3: any = args[2];\n const arg4: any = args[3];\n\n // An embedded sign-in flow payload initiates or continues a `POST /flow/execute` step\n // (identified by `applicationId` for a new flow or `executionId` to continue one). This is\n // distinct from the OAuth authorization_code exchange handled by `super.signIn` below, which\n // is used once the embedded flow completes and returns an authorization code.\n const isEmbeddedFlowPayload: boolean =\n typeof arg1 === 'object' && arg1 !== null && ('executionId' in arg1 || 'applicationId' in arg1);\n\n if (isEmbeddedFlowPayload) {\n await this.ensureInitialized();\n\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n\n return executeEmbeddedSignInFlow({\n baseUrl: configData?.baseUrl,\n flowSecret: arg2?.flowSecret,\n payload: arg1,\n url: arg2?.url,\n }) as unknown as Promise<EmbeddedSignInFlowResponse>;\n }\n\n return super.signIn(arg4, arg3, arg1?.code, arg1?.session_state, arg1?.state, arg1) as unknown as Promise<User>;\n }\n\n override async signOut(...args: any[]): Promise<string> {\n if (args[1] && typeof args[1] !== 'string') {\n throw new Error('The second argument must be a string.');\n }\n\n const config: T = this.getConfiguration();\n const afterSignOutUrl: string = config?.afterSignOutUrl || '/';\n\n const resolvedSessionId: string = args[1] || (await getSessionId())!;\n\n try {\n await (super.signOut as (...a: any[]) => Promise<string>)(resolvedSessionId);\n } catch (error) {\n const message: string = error instanceof Error ? error.message : String(error);\n\n if (\n !message.includes('end_session_endpoint') &&\n !message.includes('sign-out endpoint') &&\n !message.includes('Sign-out endpoint') &&\n !message.includes('Sign-out redirect URL')\n ) {\n throw error;\n }\n }\n\n return afterSignOutUrl;\n }\n\n override async signUp(_options?: SignUpOptions): Promise<void> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-ValidationError-002',\n 'nextjs',\n 'The signUp method is not implemented in the Next.js client.',\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override signInSilently(_options?: SignInOptions): Promise<User | boolean> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-signInSilently-NotImplementedError-001',\n 'nextjs',\n 'The signInSilently method is not implemented in the Next.js client.',\n );\n }\n\n public async getAuthorizeRequestUrl(\n customParams: ExtendedAuthorizeRequestUrlParams,\n userId?: string,\n ): Promise<string> {\n await this.ensureInitialized();\n return this.getSignInUrl(customParams, userId);\n }\n\n public override getStorageManager(): any {\n return super.getStorageManager();\n }\n\n public override async clearSession(): Promise<void> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-clearSession-NotImplementedError-001',\n 'nextjs',\n 'The clearSession method is not implemented in the Next.js client.',\n );\n }\n\n override async setSession(sessionData: Record<string, unknown>, sessionId?: string): Promise<void> {\n return this.getStorageManager().setSessionData(sessionData, sessionId);\n }\n\n override decodeJwtToken<R = Record<string, unknown>>(token: string): Promise<R> {\n return super.decodeJwtToken<R>(token);\n }\n}\n\nexport default ThunderIDNextClient;\n"],"mappings":";;;;;;AA2CA,IAAM,sBAAN,cAAuF,oBAAuB;CAC5G,AAAO,gBAAgB;CAEvB,AAAO,cAAc;AACnB,SAAO;;CAGT,MAAc,oBAAmC;AAC/C,MAAI,CAAC,KAAK,cAIR,OAAM,KAAK,WAAW,EAAE,CAAM;AAGhC,MAAI,CAAC,KAAK,cACR,OAAM,IAAI,MACR,iLACD;;CAIL,MAAe,WAAW,QAAW,SAAqC;AACxE,MAAI,KAAK,cACP,QAAO,QAAQ,QAAQ,KAAK;EAG9B,MAAM,EACJ,SACA,oBACA,UACA,cACA,WACA,gBACA,iBACA,UACA,GAAG,SACDA,kCAA0B,OAAO;EAErC,MAAMC,SAAiB,MAAMC,yBAAiB;EAE9C,MAAMC,cAAuB,MAAM,MAAM,WACvC;GACE,GAAG;GACH,gBAAgB,kBAAkB;GAClC,iBAAiB,mBAAmB;GACpC;GACA;GACA;GACA,YAAa,KAAa,cAAc;GACxC;GACA;GACA;GACD,EACD,QACD;AAED,OAAK,gBAAgB;AAErB,SAAO;;CAGT,MAAe,aAAa,QAAsC;AAChE,MAAI;AACF,SAAM,MAAM,aAAa,OAAO;AAChC,UAAO;WACA,OAAO;AACd,SAAM,IAAI,sBACR,uCAAuC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC7F,qDACA,UACA,8GACD;;;CA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AAC,QAAQ,SAAS,wBAAwB,CAE1C,OAAM;;AAIV,SAAO;;CAGT,MAAe,OAAO,UAAyC;AAC7D,QAAM,IAAI,sBACR,mBACA,2CACA,UACA,8DACD;;CAIH,AAAS,eAAe,UAAmD;AACzE,QAAM,IAAI,sBACR,mBACA,8DACA,UACA,sEACD;;CAGH,MAAa,uBACX,cACA,QACiB;AACjB,QAAM,KAAK,mBAAmB;AAC9B,SAAO,KAAK,aAAa,cAAc,OAAO;;CAGhD,AAAgB,oBAAyB;AACvC,SAAO,MAAM,mBAAmB;;CAGlC,MAAsB,eAA8B;AAClD,QAAM,IAAI,sBACR,mBACA,4DACA,UACA,oEACD;;CAGH,MAAe,WAAW,aAAsC,WAAmC;AACjG,SAAO,KAAK,mBAAmB,CAAC,eAAe,aAAa,UAAU;;CAGxE,AAAS,eAA4C,OAA2B;AAC9E,SAAO,MAAM,eAAkB,MAAM;;;AAIzC,kCAAe"}
|
|
1
|
+
{"version":3,"file":"ThunderIDNextClient.js","names":["decorateConfigWithNextEnv","origin: string","getClientOrigin","initialized: boolean","resolvedSessionId: string","getSessionId","configData: AuthClientConfig<T>","baseUrl: string | undefined","profile: User","token: string | undefined","arg1: any","arg2: any","arg3: any","arg4: any","afterSignOutUrl: string","message: string"],"sources":["../src/ThunderIDNextClient.ts"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ThunderIDNodeClient,\n ThunderIDRuntimeError,\n AuthClientConfig,\n EmbeddedSignInFlowResponse,\n ExtendedAuthorizeRequestUrlParams,\n IdToken,\n SignInOptions,\n SignUpOptions,\n Storage,\n TokenExchangeRequestConfig,\n TokenResponse,\n User,\n UserProfile,\n executeEmbeddedSignInFlow,\n extractUserClaimsFromIdToken,\n generateFlattenedUserProfile,\n getUsersMe,\n updateMeProfile,\n resolveResourceEndpoint,\n} from '@thunderid/node';\nimport {ThunderIDNextConfig} from './models/config';\nimport getClientOrigin from './server/actions/getClientOrigin';\nimport getSessionId from './server/actions/getSessionId';\nimport decorateConfigWithNextEnv from './utils/decorateConfigWithNextEnv';\n\nclass ThunderIDNextClient<T extends ThunderIDNextConfig = ThunderIDNextConfig> extends ThunderIDNodeClient<T> {\n public isInitialized = false;\n\n public constructor() {\n super();\n }\n\n private async ensureInitialized(): Promise<void> {\n if (!this.isInitialized) {\n // Server actions may run in a module context that hasn't been through\n // ThunderIDServerProvider (e.g. a different worker). Try to initialize\n // from environment variables before giving up.\n await this.initialize({} as T);\n }\n\n if (!this.isInitialized) {\n throw new Error(\n '[ThunderIDNextClient] Client is not initialized. Make sure you have wrapped your app with ThunderIDProvider and provided the required configuration (baseUrl, clientId, etc.).',\n );\n }\n }\n\n override async initialize(config: T, storage?: Storage): Promise<boolean> {\n if (this.isInitialized) {\n return Promise.resolve(true);\n }\n\n const {\n baseUrl,\n organizationHandle,\n clientId,\n clientSecret,\n signInUrl,\n afterSignInUrl,\n afterSignOutUrl,\n signUpUrl,\n ...rest\n } = decorateConfigWithNextEnv(config);\n\n const origin: string = await getClientOrigin();\n\n const initialized: boolean = await super.initialize(\n {\n ...rest,\n afterSignInUrl: afterSignInUrl ?? origin,\n afterSignOutUrl: afterSignOutUrl ?? origin,\n baseUrl,\n clientId,\n clientSecret,\n enablePKCE: (rest as any).enablePKCE ?? true,\n organizationHandle,\n signInUrl,\n signUpUrl,\n } as any,\n storage,\n );\n\n this.isInitialized = initialized;\n\n return initialized;\n }\n\n override async reInitialize(config: Partial<T>): Promise<boolean> {\n try {\n await super.reInitialize(config);\n return true;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to re-initialize the client: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDNextClient-reInitialize-RuntimeError-001',\n 'nextjs',\n 'An error occurred while re-initializing the client. Please check your configuration and network connection.',\n );\n }\n }\n\n override async getUser(userId?: string): Promise<User> {\n await this.ensureInitialized();\n const resolvedSessionId: string = userId || (await getSessionId())!;\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n const profile: User = await getUsersMe({\n baseUrl,\n url: resolveResourceEndpoint('usersMe', configData),\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n });\n\n return profile;\n } catch (error) {\n return await super.getUser(resolvedSessionId);\n }\n }\n\n override async getUserProfile(userId?: string): Promise<UserProfile> {\n await this.ensureInitialized();\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n const profile: User = await getUsersMe({\n baseUrl,\n url: resolveResourceEndpoint('usersMe', configData),\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n });\n\n return {\n flattenedProfile: generateFlattenedUserProfile(profile),\n profile,\n };\n } catch (error) {\n return {\n flattenedProfile: extractUserClaimsFromIdToken(await super.getDecodedIdToken(userId)),\n profile: extractUserClaimsFromIdToken(await super.getDecodedIdToken(userId)),\n };\n }\n }\n\n override async updateUserProfile(payload: any, userId?: string): Promise<User> {\n await this.ensureInitialized();\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n return updateMeProfile({\n baseUrl,\n url: resolveResourceEndpoint('usersMe', configData),\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n payload: payload?.payload ?? payload,\n });\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to update user profile: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDNextClient-UpdateProfileError-001',\n 'react',\n 'An error occurred while updating the user profile. Please check your configuration and network connection.',\n );\n }\n }\n\n override isLoading(): boolean {\n return false;\n }\n\n override isSignedIn(sessionId?: string): Promise<boolean> {\n return super.isSignedIn(sessionId);\n }\n\n override exchangeToken(config: TokenExchangeRequestConfig, sessionId?: string): Promise<TokenResponse | Response> {\n return super.exchangeToken(config, sessionId) as unknown as Promise<TokenResponse | Response>;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override async getAccessToken(_sessionId?: string): Promise<string> {\n const {default: getAccessToken} = await import('./server/actions/getAccessToken');\n const token: string | undefined = await getAccessToken();\n\n if (typeof token !== 'string' || !token) {\n throw new ThunderIDRuntimeError(\n 'Failed to get access token.',\n 'ThunderIDNextClient-getAccessToken-RuntimeError-003',\n 'nextjs',\n 'An error occurred while obtaining the access token. Please check your configuration and network connection.',\n );\n }\n\n return token;\n }\n\n override async getDecodedIdToken(sessionId?: string, idToken?: string): Promise<IdToken> {\n await this.ensureInitialized();\n return await super.getDecodedIdToken(sessionId, idToken);\n }\n\n override async signIn(...args: any[]): Promise<any> {\n const arg1: any = args[0];\n const arg2: any = args[1];\n const arg3: any = args[2];\n const arg4: any = args[3];\n\n // An embedded sign-in flow payload initiates or continues a `POST /flow/execute` step\n // (identified by `applicationId` for a new flow or `executionId` to continue one). This is\n // distinct from the OAuth authorization_code exchange handled by `super.signIn` below, which\n // is used once the embedded flow completes and returns an authorization code.\n const isEmbeddedFlowPayload: boolean =\n typeof arg1 === 'object' && arg1 !== null && ('executionId' in arg1 || 'applicationId' in arg1);\n\n if (isEmbeddedFlowPayload) {\n await this.ensureInitialized();\n\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n\n return executeEmbeddedSignInFlow({\n baseUrl: configData?.baseUrl,\n flowSecret: arg2?.flowSecret,\n payload: arg1,\n url: resolveResourceEndpoint('flowExecute', configData, arg2?.url),\n }) as unknown as Promise<EmbeddedSignInFlowResponse>;\n }\n\n return super.signIn(arg4, arg3, arg1?.code, arg1?.session_state, arg1?.state, arg1) as unknown as Promise<User>;\n }\n\n override async signOut(...args: any[]): Promise<string> {\n if (args[1] && typeof args[1] !== 'string') {\n throw new Error('The second argument must be a string.');\n }\n\n const config: T = this.getConfiguration();\n const afterSignOutUrl: string = config?.afterSignOutUrl || '/';\n\n const resolvedSessionId: string = args[1] || (await getSessionId())!;\n\n try {\n await (super.signOut as (...a: any[]) => Promise<string>)(resolvedSessionId);\n } catch (error) {\n const message: string = error instanceof Error ? error.message : String(error);\n\n if (\n !message.includes('end_session_endpoint') &&\n !message.includes('sign-out endpoint') &&\n !message.includes('Sign-out endpoint') &&\n !message.includes('Sign-out redirect URL')\n ) {\n throw error;\n }\n }\n\n return afterSignOutUrl;\n }\n\n override async signUp(_options?: SignUpOptions): Promise<void> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-ValidationError-002',\n 'nextjs',\n 'The signUp method is not implemented in the Next.js client.',\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override signInSilently(_options?: SignInOptions): Promise<User | boolean> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-signInSilently-NotImplementedError-001',\n 'nextjs',\n 'The signInSilently method is not implemented in the Next.js client.',\n );\n }\n\n public async getAuthorizeRequestUrl(\n customParams: ExtendedAuthorizeRequestUrlParams,\n userId?: string,\n ): Promise<string> {\n await this.ensureInitialized();\n return this.getSignInUrl(customParams, userId);\n }\n\n public override getStorageManager(): any {\n return super.getStorageManager();\n }\n\n public override async clearSession(): Promise<void> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-clearSession-NotImplementedError-001',\n 'nextjs',\n 'The clearSession method is not implemented in the Next.js client.',\n );\n }\n\n override async setSession(sessionData: Record<string, unknown>, sessionId?: string): Promise<void> {\n return this.getStorageManager().setSessionData(sessionData, sessionId);\n }\n\n override decodeJwtToken<R = Record<string, unknown>>(token: string): Promise<R> {\n return super.decodeJwtToken<R>(token);\n }\n}\n\nexport default ThunderIDNextClient;\n"],"mappings":";;;;;;AA6BA,IAAM,sBAAN,cAAuF,oBAAuB;CAC5G,AAAO,gBAAgB;CAEvB,AAAO,cAAc;AACnB,SAAO;;CAGT,MAAc,oBAAmC;AAC/C,MAAI,CAAC,KAAK,cAIR,OAAM,KAAK,WAAW,EAAE,CAAM;AAGhC,MAA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BACA,4DACA,UACA,oEACD;;CAGH,MAAe,WAAW,aAAsC,WAAmC;AACjG,SAAO,KAAK,mBAAmB,CAAC,eAAe,aAAa,UAAU;;CAGxE,AAAS,eAA4C,OAA2B;AAC9E,SAAO,MAAM,eAAkB,MAAM;;;AAIzC,kCAAe"}
|
|
@@ -46,9 +46,11 @@ var ThunderIDNextClient = class extends __thunderid_node.ThunderIDNodeClient {
|
|
|
46
46
|
await this.ensureInitialized();
|
|
47
47
|
const resolvedSessionId = userId || await require_getSessionId.default();
|
|
48
48
|
try {
|
|
49
|
-
const
|
|
49
|
+
const configData = await this.getStorageManager().getConfigData();
|
|
50
|
+
const baseUrl = configData?.baseUrl;
|
|
50
51
|
return await (0, __thunderid_node.getUsersMe)({
|
|
51
52
|
baseUrl,
|
|
53
|
+
url: (0, __thunderid_node.resolveResourceEndpoint)("usersMe", configData),
|
|
52
54
|
headers: { Authorization: `Bearer ${await this.getAccessToken(userId)}` }
|
|
53
55
|
});
|
|
54
56
|
} catch (error) {
|
|
@@ -58,9 +60,11 @@ var ThunderIDNextClient = class extends __thunderid_node.ThunderIDNodeClient {
|
|
|
58
60
|
async getUserProfile(userId) {
|
|
59
61
|
await this.ensureInitialized();
|
|
60
62
|
try {
|
|
61
|
-
const
|
|
63
|
+
const configData = await this.getStorageManager().getConfigData();
|
|
64
|
+
const baseUrl = configData?.baseUrl;
|
|
62
65
|
const profile = await (0, __thunderid_node.getUsersMe)({
|
|
63
66
|
baseUrl,
|
|
67
|
+
url: (0, __thunderid_node.resolveResourceEndpoint)("usersMe", configData),
|
|
64
68
|
headers: { Authorization: `Bearer ${await this.getAccessToken(userId)}` }
|
|
65
69
|
});
|
|
66
70
|
return {
|
|
@@ -77,9 +81,11 @@ var ThunderIDNextClient = class extends __thunderid_node.ThunderIDNodeClient {
|
|
|
77
81
|
async updateUserProfile(payload, userId) {
|
|
78
82
|
await this.ensureInitialized();
|
|
79
83
|
try {
|
|
80
|
-
const
|
|
84
|
+
const configData = await this.getStorageManager().getConfigData();
|
|
85
|
+
const baseUrl = configData?.baseUrl;
|
|
81
86
|
return (0, __thunderid_node.updateMeProfile)({
|
|
82
87
|
baseUrl,
|
|
88
|
+
url: (0, __thunderid_node.resolveResourceEndpoint)("usersMe", configData),
|
|
83
89
|
headers: { Authorization: `Bearer ${await this.getAccessToken(userId)}` },
|
|
84
90
|
payload: payload?.payload ?? payload
|
|
85
91
|
});
|
|
@@ -113,11 +119,12 @@ var ThunderIDNextClient = class extends __thunderid_node.ThunderIDNodeClient {
|
|
|
113
119
|
const arg4 = args[3];
|
|
114
120
|
if (typeof arg1 === "object" && arg1 !== null && ("executionId" in arg1 || "applicationId" in arg1)) {
|
|
115
121
|
await this.ensureInitialized();
|
|
122
|
+
const configData = await this.getStorageManager().getConfigData();
|
|
116
123
|
return (0, __thunderid_node.executeEmbeddedSignInFlow)({
|
|
117
|
-
baseUrl:
|
|
124
|
+
baseUrl: configData?.baseUrl,
|
|
118
125
|
flowSecret: arg2?.flowSecret,
|
|
119
126
|
payload: arg1,
|
|
120
|
-
url: arg2?.url
|
|
127
|
+
url: (0, __thunderid_node.resolveResourceEndpoint)("flowExecute", configData, arg2?.url)
|
|
121
128
|
});
|
|
122
129
|
}
|
|
123
130
|
return super.signIn(arg4, arg3, arg1?.code, arg1?.session_state, arg1?.state, arg1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThunderIDNextClient.cjs","names":["ThunderIDNodeClient","decorateConfigWithNextEnv","origin: string","getClientOrigin","initialized: boolean","ThunderIDRuntimeError","resolvedSessionId: string","getSessionId","baseUrl: string | undefined","profile: User","token: string | undefined","arg1: any","arg2: any","arg3: any","arg4: any","afterSignOutUrl: string","message: string"],"sources":["../../src/ThunderIDNextClient.ts"],"sourcesContent":["/**\n * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).\n *\n * WSO2 LLC. licenses this file to you under the Apache License,\n * Version 2.0 (the \"License\"); you may not use this file except\n * in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\n\nimport {\n ThunderIDNodeClient,\n ThunderIDRuntimeError,\n AuthClientConfig,\n EmbeddedSignInFlowResponse,\n ExtendedAuthorizeRequestUrlParams,\n IdToken,\n SignInOptions,\n SignUpOptions,\n Storage,\n TokenExchangeRequestConfig,\n TokenResponse,\n User,\n UserProfile,\n executeEmbeddedSignInFlow,\n extractUserClaimsFromIdToken,\n generateFlattenedUserProfile,\n getUsersMe,\n updateMeProfile,\n} from '@thunderid/node';\nimport {ThunderIDNextConfig} from './models/config';\nimport getClientOrigin from './server/actions/getClientOrigin';\nimport getSessionId from './server/actions/getSessionId';\nimport decorateConfigWithNextEnv from './utils/decorateConfigWithNextEnv';\n\nclass ThunderIDNextClient<T extends ThunderIDNextConfig = ThunderIDNextConfig> extends ThunderIDNodeClient<T> {\n public isInitialized = false;\n\n public constructor() {\n super();\n }\n\n private async ensureInitialized(): Promise<void> {\n if (!this.isInitialized) {\n // Server actions may run in a module context that hasn't been through\n // ThunderIDServerProvider (e.g. a different worker). Try to initialize\n // from environment variables before giving up.\n await this.initialize({} as T);\n }\n\n if (!this.isInitialized) {\n throw new Error(\n '[ThunderIDNextClient] Client is not initialized. Make sure you have wrapped your app with ThunderIDProvider and provided the required configuration (baseUrl, clientId, etc.).',\n );\n }\n }\n\n override async initialize(config: T, storage?: Storage): Promise<boolean> {\n if (this.isInitialized) {\n return Promise.resolve(true);\n }\n\n const {\n baseUrl,\n organizationHandle,\n clientId,\n clientSecret,\n signInUrl,\n afterSignInUrl,\n afterSignOutUrl,\n signUpUrl,\n ...rest\n } = decorateConfigWithNextEnv(config);\n\n const origin: string = await getClientOrigin();\n\n const initialized: boolean = await super.initialize(\n {\n ...rest,\n afterSignInUrl: afterSignInUrl ?? origin,\n afterSignOutUrl: afterSignOutUrl ?? origin,\n baseUrl,\n clientId,\n clientSecret,\n enablePKCE: (rest as any).enablePKCE ?? true,\n organizationHandle,\n signInUrl,\n signUpUrl,\n } as any,\n storage,\n );\n\n this.isInitialized = initialized;\n\n return initialized;\n }\n\n override async reInitialize(config: Partial<T>): Promise<boolean> {\n try {\n await super.reInitialize(config);\n return true;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to re-initialize the client: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDNextClient-reInitialize-RuntimeError-001',\n 'nextjs',\n 'An error occurred while re-initializing the client. Please check your configuration and network connection.',\n );\n }\n }\n\n override async getUser(userId?: string): Promise<User> {\n await this.ensureInitialized();\n const resolvedSessionId: string = userId || (await getSessionId())!;\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n const profile: User = await getUsersMe({\n baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n });\n\n return profile;\n } catch (error) {\n return await super.getUser(resolvedSessionId);\n }\n }\n\n override async getUserProfile(userId?: string): Promise<UserProfile> {\n await this.ensureInitialized();\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n const profile: User = await getUsersMe({\n baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n });\n\n return {\n flattenedProfile: generateFlattenedUserProfile(profile),\n profile,\n };\n } catch (error) {\n return {\n flattenedProfile: extractUserClaimsFromIdToken(await super.getDecodedIdToken(userId)),\n profile: extractUserClaimsFromIdToken(await super.getDecodedIdToken(userId)),\n };\n }\n }\n\n override async updateUserProfile(payload: any, userId?: string): Promise<User> {\n await this.ensureInitialized();\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n return updateMeProfile({\n baseUrl,\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n payload: payload?.payload ?? payload,\n });\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to update user profile: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDNextClient-UpdateProfileError-001',\n 'react',\n 'An error occurred while updating the user profile. Please check your configuration and network connection.',\n );\n }\n }\n\n override isLoading(): boolean {\n return false;\n }\n\n override isSignedIn(sessionId?: string): Promise<boolean> {\n return super.isSignedIn(sessionId);\n }\n\n override exchangeToken(config: TokenExchangeRequestConfig, sessionId?: string): Promise<TokenResponse | Response> {\n return super.exchangeToken(config, sessionId) as unknown as Promise<TokenResponse | Response>;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override async getAccessToken(_sessionId?: string): Promise<string> {\n const {default: getAccessToken} = await import('./server/actions/getAccessToken');\n const token: string | undefined = await getAccessToken();\n\n if (typeof token !== 'string' || !token) {\n throw new ThunderIDRuntimeError(\n 'Failed to get access token.',\n 'ThunderIDNextClient-getAccessToken-RuntimeError-003',\n 'nextjs',\n 'An error occurred while obtaining the access token. Please check your configuration and network connection.',\n );\n }\n\n return token;\n }\n\n override async getDecodedIdToken(sessionId?: string, idToken?: string): Promise<IdToken> {\n await this.ensureInitialized();\n return await super.getDecodedIdToken(sessionId, idToken);\n }\n\n override async signIn(...args: any[]): Promise<any> {\n const arg1: any = args[0];\n const arg2: any = args[1];\n const arg3: any = args[2];\n const arg4: any = args[3];\n\n // An embedded sign-in flow payload initiates or continues a `POST /flow/execute` step\n // (identified by `applicationId` for a new flow or `executionId` to continue one). This is\n // distinct from the OAuth authorization_code exchange handled by `super.signIn` below, which\n // is used once the embedded flow completes and returns an authorization code.\n const isEmbeddedFlowPayload: boolean =\n typeof arg1 === 'object' && arg1 !== null && ('executionId' in arg1 || 'applicationId' in arg1);\n\n if (isEmbeddedFlowPayload) {\n await this.ensureInitialized();\n\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n\n return executeEmbeddedSignInFlow({\n baseUrl: configData?.baseUrl,\n flowSecret: arg2?.flowSecret,\n payload: arg1,\n url: arg2?.url,\n }) as unknown as Promise<EmbeddedSignInFlowResponse>;\n }\n\n return super.signIn(arg4, arg3, arg1?.code, arg1?.session_state, arg1?.state, arg1) as unknown as Promise<User>;\n }\n\n override async signOut(...args: any[]): Promise<string> {\n if (args[1] && typeof args[1] !== 'string') {\n throw new Error('The second argument must be a string.');\n }\n\n const config: T = this.getConfiguration();\n const afterSignOutUrl: string = config?.afterSignOutUrl || '/';\n\n const resolvedSessionId: string = args[1] || (await getSessionId())!;\n\n try {\n await (super.signOut as (...a: any[]) => Promise<string>)(resolvedSessionId);\n } catch (error) {\n const message: string = error instanceof Error ? error.message : String(error);\n\n if (\n !message.includes('end_session_endpoint') &&\n !message.includes('sign-out endpoint') &&\n !message.includes('Sign-out endpoint') &&\n !message.includes('Sign-out redirect URL')\n ) {\n throw error;\n }\n }\n\n return afterSignOutUrl;\n }\n\n override async signUp(_options?: SignUpOptions): Promise<void> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-ValidationError-002',\n 'nextjs',\n 'The signUp method is not implemented in the Next.js client.',\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override signInSilently(_options?: SignInOptions): Promise<User | boolean> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-signInSilently-NotImplementedError-001',\n 'nextjs',\n 'The signInSilently method is not implemented in the Next.js client.',\n );\n }\n\n public async getAuthorizeRequestUrl(\n customParams: ExtendedAuthorizeRequestUrlParams,\n userId?: string,\n ): Promise<string> {\n await this.ensureInitialized();\n return this.getSignInUrl(customParams, userId);\n }\n\n public override getStorageManager(): any {\n return super.getStorageManager();\n }\n\n public override async clearSession(): Promise<void> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-clearSession-NotImplementedError-001',\n 'nextjs',\n 'The clearSession method is not implemented in the Next.js client.',\n );\n }\n\n override async setSession(sessionData: Record<string, unknown>, sessionId?: string): Promise<void> {\n return this.getStorageManager().setSessionData(sessionData, sessionId);\n }\n\n override decodeJwtToken<R = Record<string, unknown>>(token: string): Promise<R> {\n return super.decodeJwtToken<R>(token);\n }\n}\n\nexport default ThunderIDNextClient;\n"],"mappings":";;;;;;;;AA2CA,IAAM,sBAAN,cAAuFA,qCAAuB;CAC5G,AAAO,gBAAgB;CAEvB,AAAO,cAAc;AACnB,SAAO;;CAGT,MAAc,oBAAmC;AAC/C,MAAI,CAAC,KAAK,cAIR,OAAM,KAAK,WAAW,EAAE,CAAM;AAGhC,MAAI,CAAC,KAAK,cACR,OAAM,IAAI,MACR,iLACD;;CAIL,MAAe,WAAW,QAAW,SAAqC;AACxE,MAAI,KAAK,cACP,QAAO,QAAQ,QAAQ,KAAK;EAG9B,MAAM,EACJ,SACA,oBACA,UACA,cACA,WACA,gBACA,iBACA,UACA,GAAG,SACDC,0CAA0B,OAAO;EAErC,MAAMC,SAAiB,MAAMC,iCAAiB;EAE9C,MAAMC,cAAuB,MAAM,MAAM,WACvC;GACE,GAAG;GACH,gBAAgB,kBAAkB;GAClC,iBAAiB,mBAAmB;GACpC;GACA;GACA;GACA,YAAa,KAAa,cAAc;GACxC;GACA;GACA;GACD,EACD,QACD;AAED,OAAK,gBAAgB;AAErB,SAAO;;CAGT,MAAe,aAAa,QAAsC;AAChE,MAAI;AACF,SAAM,MAAM,aAAa,OAAO;AAChC,UAAO;WACA,OAAO;AACd,SAAM,IAAIC,uCACR,uCAAuC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IAC7F,qDACA,UACA,8GACD;;;CAIL,MAAe,QAAQ,QAAgC;AACrD,QAAM,KAAK,mBAAmB;EAC9B,MAAMC,oBAA4B,UAAW,MAAMC,8BAAc;AAEjE,MAAI;GAEF,MAAMC,WADkC,MAAM,KAAK,mBAAmB,CAAC,eAAe,GACtC;AASh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Aa,uBACX,cACA,QACiB;AACjB,QAAM,KAAK,mBAAmB;AAC9B,SAAO,KAAK,aAAa,cAAc,OAAO;;CAGhD,AAAgB,oBAAyB;AACvC,SAAO,MAAM,mBAAmB;;CAGlC,MAAsB,eAA8B;AAClD,QAAM,IAAIA,uCACR,mBACA,4DACA,UACA,oEACD;;CAGH,MAAe,WAAW,aAAsC,WAAmC;AACjG,SAAO,KAAK,mBAAmB,CAAC,eAAe,aAAa,UAAU;;CAGxE,AAAS,eAA4C,OAA2B;AAC9E,SAAO,MAAM,eAAkB,MAAM;;;AAIzC,kCAAe"}
|
|
1
|
+
{"version":3,"file":"ThunderIDNextClient.cjs","names":["ThunderIDNodeClient","decorateConfigWithNextEnv","origin: string","getClientOrigin","initialized: boolean","ThunderIDRuntimeError","resolvedSessionId: string","getSessionId","configData: AuthClientConfig<T>","baseUrl: string | undefined","profile: User","token: string | undefined","arg1: any","arg2: any","arg3: any","arg4: any","afterSignOutUrl: string","message: string"],"sources":["../../src/ThunderIDNextClient.ts"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n ThunderIDNodeClient,\n ThunderIDRuntimeError,\n AuthClientConfig,\n EmbeddedSignInFlowResponse,\n ExtendedAuthorizeRequestUrlParams,\n IdToken,\n SignInOptions,\n SignUpOptions,\n Storage,\n TokenExchangeRequestConfig,\n TokenResponse,\n User,\n UserProfile,\n executeEmbeddedSignInFlow,\n extractUserClaimsFromIdToken,\n generateFlattenedUserProfile,\n getUsersMe,\n updateMeProfile,\n resolveResourceEndpoint,\n} from '@thunderid/node';\nimport {ThunderIDNextConfig} from './models/config';\nimport getClientOrigin from './server/actions/getClientOrigin';\nimport getSessionId from './server/actions/getSessionId';\nimport decorateConfigWithNextEnv from './utils/decorateConfigWithNextEnv';\n\nclass ThunderIDNextClient<T extends ThunderIDNextConfig = ThunderIDNextConfig> extends ThunderIDNodeClient<T> {\n public isInitialized = false;\n\n public constructor() {\n super();\n }\n\n private async ensureInitialized(): Promise<void> {\n if (!this.isInitialized) {\n // Server actions may run in a module context that hasn't been through\n // ThunderIDServerProvider (e.g. a different worker). Try to initialize\n // from environment variables before giving up.\n await this.initialize({} as T);\n }\n\n if (!this.isInitialized) {\n throw new Error(\n '[ThunderIDNextClient] Client is not initialized. Make sure you have wrapped your app with ThunderIDProvider and provided the required configuration (baseUrl, clientId, etc.).',\n );\n }\n }\n\n override async initialize(config: T, storage?: Storage): Promise<boolean> {\n if (this.isInitialized) {\n return Promise.resolve(true);\n }\n\n const {\n baseUrl,\n organizationHandle,\n clientId,\n clientSecret,\n signInUrl,\n afterSignInUrl,\n afterSignOutUrl,\n signUpUrl,\n ...rest\n } = decorateConfigWithNextEnv(config);\n\n const origin: string = await getClientOrigin();\n\n const initialized: boolean = await super.initialize(\n {\n ...rest,\n afterSignInUrl: afterSignInUrl ?? origin,\n afterSignOutUrl: afterSignOutUrl ?? origin,\n baseUrl,\n clientId,\n clientSecret,\n enablePKCE: (rest as any).enablePKCE ?? true,\n organizationHandle,\n signInUrl,\n signUpUrl,\n } as any,\n storage,\n );\n\n this.isInitialized = initialized;\n\n return initialized;\n }\n\n override async reInitialize(config: Partial<T>): Promise<boolean> {\n try {\n await super.reInitialize(config);\n return true;\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to re-initialize the client: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDNextClient-reInitialize-RuntimeError-001',\n 'nextjs',\n 'An error occurred while re-initializing the client. Please check your configuration and network connection.',\n );\n }\n }\n\n override async getUser(userId?: string): Promise<User> {\n await this.ensureInitialized();\n const resolvedSessionId: string = userId || (await getSessionId())!;\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n const profile: User = await getUsersMe({\n baseUrl,\n url: resolveResourceEndpoint('usersMe', configData),\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n });\n\n return profile;\n } catch (error) {\n return await super.getUser(resolvedSessionId);\n }\n }\n\n override async getUserProfile(userId?: string): Promise<UserProfile> {\n await this.ensureInitialized();\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n const profile: User = await getUsersMe({\n baseUrl,\n url: resolveResourceEndpoint('usersMe', configData),\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n });\n\n return {\n flattenedProfile: generateFlattenedUserProfile(profile),\n profile,\n };\n } catch (error) {\n return {\n flattenedProfile: extractUserClaimsFromIdToken(await super.getDecodedIdToken(userId)),\n profile: extractUserClaimsFromIdToken(await super.getDecodedIdToken(userId)),\n };\n }\n }\n\n override async updateUserProfile(payload: any, userId?: string): Promise<User> {\n await this.ensureInitialized();\n\n try {\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n const baseUrl: string | undefined = configData?.baseUrl;\n\n return updateMeProfile({\n baseUrl,\n url: resolveResourceEndpoint('usersMe', configData),\n headers: {\n Authorization: `Bearer ${await this.getAccessToken(userId)}`,\n },\n payload: payload?.payload ?? payload,\n });\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Failed to update user profile: ${error instanceof Error ? error.message : String(error)}`,\n 'ThunderIDNextClient-UpdateProfileError-001',\n 'react',\n 'An error occurred while updating the user profile. Please check your configuration and network connection.',\n );\n }\n }\n\n override isLoading(): boolean {\n return false;\n }\n\n override isSignedIn(sessionId?: string): Promise<boolean> {\n return super.isSignedIn(sessionId);\n }\n\n override exchangeToken(config: TokenExchangeRequestConfig, sessionId?: string): Promise<TokenResponse | Response> {\n return super.exchangeToken(config, sessionId) as unknown as Promise<TokenResponse | Response>;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override async getAccessToken(_sessionId?: string): Promise<string> {\n const {default: getAccessToken} = await import('./server/actions/getAccessToken');\n const token: string | undefined = await getAccessToken();\n\n if (typeof token !== 'string' || !token) {\n throw new ThunderIDRuntimeError(\n 'Failed to get access token.',\n 'ThunderIDNextClient-getAccessToken-RuntimeError-003',\n 'nextjs',\n 'An error occurred while obtaining the access token. Please check your configuration and network connection.',\n );\n }\n\n return token;\n }\n\n override async getDecodedIdToken(sessionId?: string, idToken?: string): Promise<IdToken> {\n await this.ensureInitialized();\n return await super.getDecodedIdToken(sessionId, idToken);\n }\n\n override async signIn(...args: any[]): Promise<any> {\n const arg1: any = args[0];\n const arg2: any = args[1];\n const arg3: any = args[2];\n const arg4: any = args[3];\n\n // An embedded sign-in flow payload initiates or continues a `POST /flow/execute` step\n // (identified by `applicationId` for a new flow or `executionId` to continue one). This is\n // distinct from the OAuth authorization_code exchange handled by `super.signIn` below, which\n // is used once the embedded flow completes and returns an authorization code.\n const isEmbeddedFlowPayload: boolean =\n typeof arg1 === 'object' && arg1 !== null && ('executionId' in arg1 || 'applicationId' in arg1);\n\n if (isEmbeddedFlowPayload) {\n await this.ensureInitialized();\n\n const configData: AuthClientConfig<T> = await this.getStorageManager().getConfigData();\n\n return executeEmbeddedSignInFlow({\n baseUrl: configData?.baseUrl,\n flowSecret: arg2?.flowSecret,\n payload: arg1,\n url: resolveResourceEndpoint('flowExecute', configData, arg2?.url),\n }) as unknown as Promise<EmbeddedSignInFlowResponse>;\n }\n\n return super.signIn(arg4, arg3, arg1?.code, arg1?.session_state, arg1?.state, arg1) as unknown as Promise<User>;\n }\n\n override async signOut(...args: any[]): Promise<string> {\n if (args[1] && typeof args[1] !== 'string') {\n throw new Error('The second argument must be a string.');\n }\n\n const config: T = this.getConfiguration();\n const afterSignOutUrl: string = config?.afterSignOutUrl || '/';\n\n const resolvedSessionId: string = args[1] || (await getSessionId())!;\n\n try {\n await (super.signOut as (...a: any[]) => Promise<string>)(resolvedSessionId);\n } catch (error) {\n const message: string = error instanceof Error ? error.message : String(error);\n\n if (\n !message.includes('end_session_endpoint') &&\n !message.includes('sign-out endpoint') &&\n !message.includes('Sign-out endpoint') &&\n !message.includes('Sign-out redirect URL')\n ) {\n throw error;\n }\n }\n\n return afterSignOutUrl;\n }\n\n override async signUp(_options?: SignUpOptions): Promise<void> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-ValidationError-002',\n 'nextjs',\n 'The signUp method is not implemented in the Next.js client.',\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n override signInSilently(_options?: SignInOptions): Promise<User | boolean> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-signInSilently-NotImplementedError-001',\n 'nextjs',\n 'The signInSilently method is not implemented in the Next.js client.',\n );\n }\n\n public async getAuthorizeRequestUrl(\n customParams: ExtendedAuthorizeRequestUrlParams,\n userId?: string,\n ): Promise<string> {\n await this.ensureInitialized();\n return this.getSignInUrl(customParams, userId);\n }\n\n public override getStorageManager(): any {\n return super.getStorageManager();\n }\n\n public override async clearSession(): Promise<void> {\n throw new ThunderIDRuntimeError(\n 'Not implemented',\n 'ThunderIDNextClient-clearSession-NotImplementedError-001',\n 'nextjs',\n 'The clearSession method is not implemented in the Next.js client.',\n );\n }\n\n override async setSession(sessionData: Record<string, unknown>, sessionId?: string): Promise<void> {\n return this.getStorageManager().setSessionData(sessionData, sessionId);\n }\n\n override decodeJwtToken<R = Record<string, unknown>>(token: string): Promise<R> {\n return super.decodeJwtToken<R>(token);\n }\n}\n\nexport default ThunderIDNextClient;\n"],"mappings":";;;;;;;;AA6BA,IAAM,sBAAN,cAAuFA,qCAAuB;CAC5G,AAAO,gBAAgB;CAEvB,AAAO,cAAc;AACnB,SAAO;;CAGT,MAAc,oBAAmC;AAC/C,MAAI,CAAC,KAAK,cAIR,OAAM,KAAK,WAAW,EAAE,CAAM;AAGhC,MAAI,CAAC,KAAK,cACR,OAAM,IAAI,MACR,iLACD;;CAIL,MAAe,WAAW,QAAW,SAAqC;AACxE,MAAI,KAAK,cACP,QAAO,QAAQ,QAAQ,KAAK;EAG9B,MAAM,EACJ,SACA,oBACA,UACA,cACA,WACA,gBAC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ignInButton.cjs","names":["SignInButton: ForwardRefExoticComponent<SignInButtonProps & RefAttributes<HTMLButtonElement>>","useThunderID","router: AppRouterInstance","ThunderIDRuntimeError","BaseSignInButton"],"sources":["../../../../../../src/client/components/actions/SignInButton/SignInButton.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"SignInButton.cjs","names":["SignInButton: ForwardRefExoticComponent<SignInButtonProps & RefAttributes<HTMLButtonElement>>","useThunderID","router: AppRouterInstance","ThunderIDRuntimeError","BaseSignInButton"],"sources":["../../../../../../src/client/components/actions/SignInButton/SignInButton.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {ThunderIDRuntimeError} from '@thunderid/node';\nimport {BaseSignInButton, BaseSignInButtonProps, useTranslation} from '@thunderid/react';\nimport {AppRouterInstance} from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport {useRouter} from 'next/navigation';\nimport {forwardRef, ForwardRefExoticComponent, ReactElement, Ref, RefAttributes, MouseEvent, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Props interface of {@link SignInButton}\n */\nexport type SignInButtonProps = BaseSignInButtonProps & {\n /**\n * Additional parameters to pass to the `authorize` request.\n */\n signInOptions?: Record<string, any>;\n};\n\n/**\n * SignInButton component that uses server actions for authentication in Next.js.\n *\n * @example Using render props\n * ```tsx\n * <SignInButton>\n * {({isLoading}) => (\n * <button type=\"submit\" disabled={isLoading}>\n * {isLoading ? 'Signing in...' : 'Sign In'}\n * </button>\n * )}\n * </SignInButton>\n * ```\n *\n * @example Using traditional props\n * ```tsx\n * <SignInButton className=\"custom-button\">Sign In</SignInButton>\n * ```\n *\n * @remarks\n * In Next.js with server actions, the sign-in is handled via the server action.\n * When using render props, the custom button should use `type=\"submit\"` instead of `onClick={signIn}`.\n * The `signIn` function in render props is provided for API consistency but should not be used directly.\n */\nconst SignInButton: ForwardRefExoticComponent<SignInButtonProps & RefAttributes<HTMLButtonElement>> = forwardRef<\n HTMLButtonElement,\n SignInButtonProps\n>(\n (\n {className, style, children, preferences, onClick, signInOptions = {}, ...rest}: SignInButtonProps,\n ref: Ref<HTMLButtonElement>,\n ): ReactElement => {\n const {signIn, signInUrl} = useThunderID();\n const router: AppRouterInstance = useRouter();\n const {t} = useTranslation(preferences?.i18n);\n\n const [isLoading, setIsLoading] = useState(false);\n\n const handleSignIn = async (): Promise<void> => {\n try {\n setIsLoading(true);\n\n // If a custom `signInUrl` is provided, use it for navigation.\n if (signInUrl) {\n router.push(signInUrl);\n } else if (signIn) {\n await signIn(signInOptions);\n }\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Sign in failed: ${error instanceof Error ? error.message : String(error)}`,\n 'SignInButton-handleSignIn-RuntimeError-001',\n 'nextjs',\n 'Something went wrong while trying to sign in. Please try again later.',\n );\n } finally {\n setIsLoading(false);\n }\n };\n\n const handleOnClick = async (e: MouseEvent<HTMLButtonElement>): Promise<void> => {\n await handleSignIn();\n if (onClick) {\n onClick(e);\n }\n };\n\n return (\n <BaseSignInButton\n className={className}\n style={style}\n ref={ref}\n preferences={preferences}\n isLoading={isLoading}\n signIn={handleSignIn}\n onClick={handleOnClick}\n {...rest}\n >\n {children ?? t('elements.buttons.signin.text')}\n </BaseSignInButton>\n );\n },\n);\n\nSignInButton.displayName = 'SignInButton';\n\nexport default SignInButton;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAMA,sCAKF,EAAC,WAAW,OAAO,UAAU,aAAa,SAAS,gBAAgB,EAAE,CAAE,GAAG,QAC1E,QACiB;CACjB,MAAM,EAAC,QAAQ,cAAaC,8BAAc;CAC1C,MAAMC,yCAAuC;CAC7C,MAAM,EAAC,4CAAoB,aAAa,KAAK;CAE7C,MAAM,CAAC,WAAW,oCAAyB,MAAM;CAEjD,MAAM,eAAe,YAA2B;AAC9C,MAAI;AACF,gBAAa,KAAK;AAGlB,OAAI,UACF,QAAO,KAAK,UAAU;YACb,OACT,OAAM,OAAO,cAAc;WAEtB,OAAO;AACd,SAAM,IAAIC,uCACR,mBAAmB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IACzE,8CACA,UACA,wEACD;YACO;AACR,gBAAa,MAAM;;;CAIvB,MAAM,gBAAgB,OAAO,MAAoD;AAC/E,QAAM,cAAc;AACpB,MAAI,QACF,SAAQ,EAAE;;AAId,QACE,2CAACC;EACY;EACJ;EACF;EACQ;EACF;EACX,QAAQ;EACR,SAAS;EACT,GAAI;YAEH,YAAY,EAAE,+BAA+B;GAC7B;EAGxB;AAED,aAAa,cAAc;AAE3B,2BAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignOutButton.cjs","names":["SignOutButton: ForwardRefExoticComponent<SignOutButtonProps & RefAttributes<HTMLButtonElement>>","useThunderID","BaseSignOutButton"],"sources":["../../../../../../src/client/components/actions/SignOutButton/SignOutButton.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"SignOutButton.cjs","names":["SignOutButton: ForwardRefExoticComponent<SignOutButtonProps & RefAttributes<HTMLButtonElement>>","useThunderID","BaseSignOutButton"],"sources":["../../../../../../src/client/components/actions/SignOutButton/SignOutButton.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {BaseSignOutButton, BaseSignOutButtonProps, useTranslation} from '@thunderid/react';\nimport {forwardRef, ForwardRefExoticComponent, ReactElement, Ref, RefAttributes, useState, MouseEvent} from 'react';\nimport logger from '../../../../utils/logger';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Interface for SignInButton component props.\n */\nexport type SignOutButtonProps = BaseSignOutButtonProps;\n\n/**\n * SignInButton component. This button initiates the sign-in process when clicked.\n *\n * @example\n * ```tsx\n * import { SignInButton } from '@thunderid/auth-react';\n *\n * const App = () => {\n * const buttonRef = useRef<HTMLButtonElement>(null);\n * return (\n * <SignInButton ref={buttonRef} className=\"custom-class\" style={{ backgroundColor: 'blue' }}>\n * Sign In\n * </SignInButton>\n * );\n * }\n * ```\n */\nconst SignOutButton: ForwardRefExoticComponent<SignOutButtonProps & RefAttributes<HTMLButtonElement>> = forwardRef<\n HTMLButtonElement,\n SignOutButtonProps\n>(\n (\n {className, style, preferences, onClick, children, ...rest}: SignOutButtonProps,\n ref: Ref<HTMLButtonElement>,\n ): ReactElement => {\n const {signOut} = useThunderID();\n const {t} = useTranslation(preferences?.i18n);\n\n const [isLoading, setIsLoading] = useState(false);\n\n const handleOnClick = async (e: MouseEvent<HTMLButtonElement>): Promise<void> => {\n try {\n setIsLoading(true);\n\n logger.debug('[SignOutButton] Initiating a sign-out from a button click');\n\n await signOut();\n\n if (onClick) {\n onClick(e);\n }\n } catch (error) {\n logger.error('[SignOutButton] Error occurred initiating sign-out from a button click:', error);\n } finally {\n setIsLoading(false);\n }\n };\n\n return (\n <BaseSignOutButton ref={ref} onClick={handleOnClick} isLoading={isLoading} preferences={preferences} {...rest}>\n {children ?? t('elements.buttons.signout.text')}\n </BaseSignOutButton>\n );\n },\n);\n\nexport default SignOutButton;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAMA,uCAKF,EAAC,WAAW,OAAO,aAAa,SAAS,SAAU,GAAG,QACtD,QACiB;CACjB,MAAM,EAAC,YAAWC,8BAAc;CAChC,MAAM,EAAC,4CAAoB,aAAa,KAAK;CAE7C,MAAM,CAAC,WAAW,oCAAyB,MAAM;CAEjD,MAAM,gBAAgB,OAAO,MAAoD;AAC/E,MAAI;AACF,gBAAa,KAAK;AAElB,0BAAO,MAAM,4DAA4D;AAEzE,SAAM,SAAS;AAEf,OAAI,QACF,SAAQ,EAAE;WAEL,OAAO;AACd,0BAAO,MAAM,2EAA2E,MAAM;YACtF;AACR,gBAAa,MAAM;;;AAIvB,QACE,2CAACC;EAAuB;EAAK,SAAS;EAA0B;EAAwB;EAAa,GAAI;YACtG,YAAY,EAAE,gCAAgC;GAC7B;EAGzB;AAED,4BAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUpButton.cjs","names":["SignUpButton: ForwardRefExoticComponent<SignUpButtonProps & RefAttributes<HTMLButtonElement>>","useThunderID","router: AppRouterInstance","ThunderIDRuntimeError","BaseSignUpButton"],"sources":["../../../../../../src/client/components/actions/SignUpButton/SignUpButton.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"SignUpButton.cjs","names":["SignUpButton: ForwardRefExoticComponent<SignUpButtonProps & RefAttributes<HTMLButtonElement>>","useThunderID","router: AppRouterInstance","ThunderIDRuntimeError","BaseSignUpButton"],"sources":["../../../../../../src/client/components/actions/SignUpButton/SignUpButton.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {ThunderIDRuntimeError} from '@thunderid/node';\nimport {BaseSignUpButton, BaseSignUpButtonProps, useTranslation} from '@thunderid/react';\nimport {AppRouterInstance} from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport {useRouter} from 'next/navigation';\nimport {forwardRef, ForwardRefExoticComponent, MouseEvent, ReactElement, Ref, RefAttributes, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Props interface of {@link SignUpButton}\n */\nexport type SignUpButtonProps = BaseSignUpButtonProps;\n\n/**\n * SignUpButton component that supports both render props and traditional props patterns.\n * It redirects the user to the ThunderID sign-up page configured for the application.\n *\n * @remarks This component is only supported in browser based React applications (CSR).\n *\n * @example Using render props pattern\n * ```tsx\n * <SignUpButton>\n * {({ signUp, isLoading }) => (\n * <button onClick={signUp} disabled={isLoading}>\n * {isLoading ? 'Creating Account...' : 'Create Account'}\n * </button>\n * )}\n * </SignUpButton>\n * ```\n *\n * @example Using traditional props pattern\n * ```tsx\n * <SignUpButton className=\"custom-button\">Create Account</SignUpButton>\n * ```\n *\n * @example Using component-level preferences\n * ```tsx\n * <SignUpButton\n * preferences={{\n * i18n: {\n * bundles: {\n * 'en-US': {\n * translations: {\n * 'buttons.signUp': 'Custom Sign Up Text'\n * }\n * }\n * }\n * }\n * }}\n * >\n * Custom Sign Up\n * </SignUpButton>\n * ```\n */\nconst SignUpButton: ForwardRefExoticComponent<SignUpButtonProps & RefAttributes<HTMLButtonElement>> = forwardRef<\n HTMLButtonElement,\n SignUpButtonProps\n>(({children, onClick, preferences, ...rest}: SignUpButtonProps, ref: Ref<HTMLButtonElement>): ReactElement => {\n const {signUp, signUpUrl} = useThunderID();\n const router: AppRouterInstance = useRouter();\n const {t} = useTranslation(preferences?.i18n);\n\n const [isLoading, setIsLoading] = useState(false);\n\n const handleSignUp = async (e?: MouseEvent<HTMLButtonElement>): Promise<void> => {\n try {\n setIsLoading(true);\n\n // If a custom `signUpUrl` is provided, use it for navigation.\n if (signUpUrl) {\n router.push(signUpUrl);\n } else if (signUp) {\n await signUp();\n }\n\n if (onClick) {\n onClick(e!);\n }\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Sign up failed: ${error instanceof Error ? error.message : String(error)}`,\n 'SignUpButton-handleSignUp-RuntimeError-001',\n 'nextjs',\n 'Something went wrong while trying to sign up. Please try again later.',\n );\n } finally {\n setIsLoading(false);\n }\n };\n\n return (\n <BaseSignUpButton\n ref={ref}\n onClick={handleSignUp}\n isLoading={isLoading}\n signUp={handleSignUp}\n preferences={preferences}\n {...rest}\n >\n {children ?? t('elements.buttons.signup.text')}\n </BaseSignUpButton>\n );\n});\n\nSignUpButton.displayName = 'SignUpButton';\n\nexport default SignUpButton;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAMA,sCAGH,EAAC,UAAU,SAAS,YAAa,GAAG,QAA0B,QAA8C;CAC7G,MAAM,EAAC,QAAQ,cAAaC,8BAAc;CAC1C,MAAMC,yCAAuC;CAC7C,MAAM,EAAC,4CAAoB,aAAa,KAAK;CAE7C,MAAM,CAAC,WAAW,oCAAyB,MAAM;CAEjD,MAAM,eAAe,OAAO,MAAqD;AAC/E,MAAI;AACF,gBAAa,KAAK;AAGlB,OAAI,UACF,QAAO,KAAK,UAAU;YACb,OACT,OAAM,QAAQ;AAGhB,OAAI,QACF,SAAQ,EAAG;WAEN,OAAO;AACd,SAAM,IAAIC,uCACR,mBAAmB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,IACzE,8CACA,UACA,wEACD;YACO;AACR,gBAAa,MAAM;;;AAIvB,QACE,2CAACC;EACM;EACL,SAAS;EACE;EACX,QAAQ;EACK;EACb,GAAI;YAEH,YAAY,EAAE,+BAA+B;GAC7B;EAErB;AAEF,aAAa,cAAc;AAE3B,2BAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignedIn.cjs","names":["SignedIn: FC<PropsWithChildren<SignedInProps>>","useThunderID"],"sources":["../../../../../../src/client/components/control/SignedIn/SignedIn.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"SignedIn.cjs","names":["SignedIn: FC<PropsWithChildren<SignedInProps>>","useThunderID"],"sources":["../../../../../../src/client/components/control/SignedIn/SignedIn.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {FC, PropsWithChildren, ReactNode} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Props interface of {@link SignedIn}\n */\nexport interface SignedInProps {\n /**\n * Content to show when the user is not signed in.\n */\n fallback?: ReactNode;\n}\n\n/**\n * A component that only renders its children when the user is signed in.\n *\n * @example\n * ```tsx\n * import { SignedIn } from '@thunderid/auth-next';\n *\n * const App = () => {\n * return (\n * <SignedIn fallback={<p>Please sign in to continue</p>}>\n * <p>Welcome! You are signed in.</p>\n * </SignedIn>\n * );\n * }\n * ```\n */\nconst SignedIn: FC<PropsWithChildren<SignedInProps>> = ({\n children,\n fallback = null,\n}: PropsWithChildren<SignedInProps>) => {\n const {isSignedIn} = useThunderID();\n\n return <>{isSignedIn ? children : fallback}</>;\n};\n\nexport default SignedIn;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAMA,YAAkD,EACtD,UACA,WAAW,WAC2B;CACtC,MAAM,EAAC,eAAcC,8BAAc;AAEnC,QAAO,mFAAG,aAAa,WAAW,WAAY;;AAGhD,uBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignedOut.cjs","names":["SignedOut: FC<PropsWithChildren<SignedOutProps>>","useThunderID"],"sources":["../../../../../../src/client/components/control/SignedOut/SignedOut.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"SignedOut.cjs","names":["SignedOut: FC<PropsWithChildren<SignedOutProps>>","useThunderID"],"sources":["../../../../../../src/client/components/control/SignedOut/SignedOut.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {FC, PropsWithChildren, ReactNode} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Props interface of {@link SignedOut}\n */\nexport interface SignedOutProps {\n /**\n * Content to show when the user is not signed-out.\n */\n fallback?: ReactNode;\n}\n\n/**\n * A component that only renders its children when the user is signed out.\n *\n * @example\n * ```tsx\n * import { SignedOut } from '@thunderid/auth-next';\n *\n * const App = () => {\n * return (\n * <SignedOut fallback={<p>Please sign out to continue</p>}>\n * <p>Welcome! You are signed out.</p>\n * </SignedOut>\n * );\n * }\n * ```\n */\nconst SignedOut: FC<PropsWithChildren<SignedOutProps>> = ({\n children,\n fallback = null,\n}: PropsWithChildren<SignedOutProps>) => {\n const {isSignedIn} = useThunderID();\n\n return <>{!isSignedIn ? children : fallback}</>;\n};\n\nexport default SignedOut;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAMA,aAAoD,EACxD,UACA,WAAW,WAC4B;CACvC,MAAM,EAAC,eAAcC,8BAAc;AAEnC,QAAO,mFAAG,CAAC,aAAa,WAAW,WAAY;;AAGjD,wBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignIn.cjs","names":["SignIn: FC<SignInProps>","useThunderID","normalizedError: Error","response: any","EmbeddedFlowType","ThunderIDRuntimeError","BaseSignIn"],"sources":["../../../../../../src/client/components/presentation/SignIn/SignIn.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"SignIn.cjs","names":["SignIn: FC<SignInProps>","useThunderID","normalizedError: Error","response: any","EmbeddedFlowType","ThunderIDRuntimeError","BaseSignIn"],"sources":["../../../../../../src/client/components/presentation/SignIn/SignIn.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {EmbeddedFlowComponent, EmbeddedFlowType, ThunderIDRuntimeError} from '@thunderid/node';\nimport {BaseSignIn, BaseSignInProps, normalizeFlowResponse, useTranslation} from '@thunderid/react';\nimport {FC, useEffect, useRef, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Props for the SignIn component.\n * Extends BaseSignInProps for full compatibility with the React BaseSignIn component\n */\nexport type SignInProps = Pick<BaseSignInProps, 'className' | 'id' | 'onSuccess' | 'onError' | 'variant' | 'size'>;\n\n/**\n * A SignIn component for Next.js that provides native authentication flow.\n * This component delegates to the BaseSignIn from @thunderid/react. Unlike BaseSignUp,\n * BaseSignIn does not manage its own flow state, so this component initiates the flow\n * (using the server-action-backed `signIn`) and tracks `components`/`executionId` itself.\n */\nconst SignIn: FC<SignInProps> = ({size = 'medium', variant = 'outlined', onError, ...rest}: SignInProps) => {\n const {signIn, applicationId, scopes} = useThunderID();\n const {t} = useTranslation();\n\n const [components, setComponents] = useState<EmbeddedFlowComponent[]>([]);\n const [additionalData, setAdditionalData] = useState<Record<string, any>>({});\n const [executionId, setExecutionId] = useState<string | undefined>(undefined);\n const [isFlowInitialized, setIsFlowInitialized] = useState(false);\n const [flowError, setFlowError] = useState<Error | null>(null);\n const initializationAttemptedRef = useRef(false);\n // A fresh challenge token is required on every step to prevent replay attacks; the server\n // rotates it on each response, so it's tracked in a ref (not state) to avoid a stale value\n // from a closure captured before the previous response's state update committed.\n const challengeTokenRef = useRef<string | undefined>(undefined);\n\n const applyFlowResponse = (response: any): void => {\n const normalized = normalizeFlowResponse(response, t, {resolveTranslations: false});\n\n challengeTokenRef.current = response?.challengeToken ?? undefined;\n setExecutionId(normalized.executionId ?? undefined);\n setComponents(normalized.components);\n setAdditionalData(normalized.additionalData);\n };\n\n const handleFlowError = (error: unknown): void => {\n const normalizedError: Error = error instanceof Error ? error : new Error(String(error));\n\n setFlowError(normalizedError);\n onError?.(normalizedError);\n };\n\n useEffect(() => {\n if (initializationAttemptedRef.current || !signIn) {\n return;\n }\n\n initializationAttemptedRef.current = true;\n\n (async (): Promise<void> => {\n try {\n const response: any = await signIn(\n {\n applicationId,\n flowType: EmbeddedFlowType.Authentication,\n ...(scopes && {scopes}),\n },\n {},\n );\n\n // `response` is undefined when the provider already redirected\n // (OAuth-redirect or completed flows are handled there directly).\n if (response) {\n applyFlowResponse(response);\n }\n } catch (error) {\n handleFlowError(error);\n } finally {\n setIsFlowInitialized(true);\n }\n })();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [signIn]);\n\n const handleOnSubmit = async (payload: any): Promise<void> => {\n if (!signIn) {\n throw new ThunderIDRuntimeError(\n '`signIn` function is not available.',\n 'SignIn-handleOnSubmit-RuntimeError-001',\n 'nextjs',\n );\n }\n\n const response: any = await signIn(\n {\n ...payload,\n executionId,\n ...(challengeTokenRef.current ? {challengeToken: challengeTokenRef.current} : {}),\n },\n {},\n );\n\n if (response) {\n applyFlowResponse(response);\n }\n };\n\n return (\n <BaseSignIn\n additionalData={additionalData}\n components={components}\n error={flowError}\n isLoading={!isFlowInitialized}\n onError={onError}\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;CAEZ,MAAM,iBAAiB,OAAO,YAAgC;AAC5D,MAAI,CAAC,OACH,OAAM,IAAIC,uCACR,uCACA,0CACA,SACD;EAGH,MAAMF,WAAgB,MAAM,OAC1B;GACE,GAAG;GACH;GACA,GAAI,kBAAkB,UAAU,EAAC,gBAAgB,kBAAkB,SAAQ,GAAG,EAAE;GACjF,EACD,EAAE,CACH;AAED,MAAI,SACF,mBAAkB,SAAS;;AAI/B,QACE,2CAACG;EACiB;EACJ;EACZ,OAAO;EACP,WAAW,CAAC;EACH;EACT,UAAU;EACJ;EACG;EACT,GAAI;GACJ;;AAIN,OAAO,cAAc;AAErB,qBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUp.cjs","names":["SignUp: FC<SignUpProps>","useThunderID","ThunderIDRuntimeError","EmbeddedFlowType","BaseSignUp"],"sources":["../../../../../../src/client/components/presentation/SignUp/SignUp.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"SignUp.cjs","names":["SignUp: FC<SignUpProps>","useThunderID","ThunderIDRuntimeError","EmbeddedFlowType","BaseSignUp"],"sources":["../../../../../../src/client/components/presentation/SignUp/SignUp.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {ThunderIDRuntimeError, EmbeddedFlowType} from '@thunderid/node';\nimport {BaseSignUp, BaseSignUpProps} from '@thunderid/react';\nimport {FC} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Props for the SignUp component.\n */\nexport type SignUpProps = BaseSignUpProps;\n\n/**\n * A styled SignUp component that provides embedded sign-up flow with pre-built styling.\n * This component handles the API calls for sign-up and delegates UI logic to BaseSignUp.\n *\n * @example\n * ```tsx\n * import { SignUp } from '@thunderid/react';\n *\n * const App = () => {\n * return (\n * <SignUp\n * onSuccess={(response) => {\n * console.log('Sign-up successful:', response);\n * // Handle successful sign-up (e.g., redirect, show confirmation)\n * }}\n * onError={(error) => {\n * console.error('Sign-up failed:', error);\n * }}\n * onComplete={(redirectUrl) => {\n * // Platform-specific redirect handling (e.g., Next.js router.push)\n * router.push(redirectUrl); // or window.location.href = redirectUrl\n * }}\n * size=\"medium\"\n * variant=\"outlined\"\n * afterSignUpUrl=\"/welcome\"\n * />\n * );\n * };\n * ```\n */\nconst SignUp: FC<SignUpProps> = ({\n className,\n size = 'medium',\n variant = 'outlined',\n afterSignUpUrl,\n onError,\n}: SignUpProps) => {\n const {signUp, applicationId: contextApplicationId, scopes} = useThunderID();\n\n /**\n * Initialize the sign-up flow.\n */\n const handleInitialize = async (payload?: any): Promise<any> => {\n if (!signUp) {\n throw new ThunderIDRuntimeError(\n '`signUp` function is not available.',\n 'SignUp-handleInitialize-RuntimeError-001',\n 'nextjs',\n );\n }\n\n return (await signUp({\n flowType: EmbeddedFlowType.Registration,\n ...(contextApplicationId && {applicationId: contextApplicationId}),\n ...(scopes && {scopes}),\n ...payload,\n })) as unknown as Promise<any>;\n };\n\n /**\n * Handle sign-up steps.\n */\n const handleOnSubmit = async (payload: any): Promise<any> => {\n if (!signUp) {\n throw new ThunderIDRuntimeError(\n '`signUp` function is not available.',\n 'SignUp-handleOnSubmit-RuntimeError-001',\n 'nextjs',\n );\n }\n\n return (await signUp(payload)) as unknown as Promise<any>;\n };\n\n return (\n <BaseSignUp\n afterSignUpUrl={afterSignUpUrl}\n onInitialize={handleInitialize}\n onSubmit={handleOnSubmit}\n onError={onError}\n className={className}\n size={size}\n variant={variant}\n isInitialized={true}\n />\n );\n};\n\nexport default SignUp;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAMA,UAA2B,EAC/B,WACA,OAAO,UACP,UAAU,YACV,gBACA,cACiB;CACjB,MAAM,EAAC,QAAQ,eAAe,sBAAsB,WAAUC,8BAAc;;;;CAK5E,MAAM,mBAAmB,OAAO,YAAgC;AAC9D,MAAI,CAAC,OACH,OAAM,IAAIC,uCACR,uCACA,4CACA,SACD;AAGH,SAAQ,MAAM,OAAO;GACnB,UAAUC,kCAAiB;GAC3B,GAAI,wBAAwB,EAAC,eAAe,sBAAqB;GACjE,GAAI,UAAU,EAAC,QAAO;GACtB,GAAG;GACJ,CAAC;;;;;CAMJ,MAAM,iBAAiB,OAAO,YAA+B;AAC3D,MAAI,CAAC,OACH,OAAM,IAAID,uCACR,uCACA,0CACA,SACD;AAGH,SAAQ,MAAM,OAAO,QAAQ;;AAG/B,QACE,2CAACE;EACiB;EAChB,cAAc;EACd,UAAU;EACD;EACE;EACL;EACG;EACT,eAAe;GACf;;AAIN,qBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"User.cjs","names":["User: FC<UserProps>","useThunderID","BaseUser"],"sources":["../../../../../../src/client/components/presentation/User/User.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"User.cjs","names":["User: FC<UserProps>","useThunderID","BaseUser"],"sources":["../../../../../../src/client/components/presentation/User/User.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {BaseUser, BaseUserProps} from '@thunderid/react';\nimport {FC, ReactElement, ReactNode} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\n/**\n * Props for the User component.\n * Extends BaseUserProps but makes the user prop optional since it will be obtained from useThunderID\n */\nexport interface UserProps extends Omit<BaseUserProps, 'user'> {\n /**\n * Render prop that takes the user object and returns a ReactNode.\n * @param user - The authenticated user object from ThunderID.\n * @returns A ReactNode to render.\n */\n children: (user: any | null) => ReactNode;\n\n /**\n * Optional element to render when no user is signed in.\n */\n fallback?: ReactNode;\n}\n\n/**\n * A component that uses render props to expose the authenticated user object.\n * This component automatically retrieves the user from ThunderID context.\n *\n * @remarks This component is only supported in browser based React applications (CSR).\n *\n * @example\n * ```tsx\n * import { User } from '@thunderid/auth-react';\n *\n * const App = () => {\n * return (\n * <User fallback={<p>Please sign in</p>}>\n * {(user) => (\n * <div>\n * <h1>Welcome, {user.displayName}!</h1>\n * <p>Email: {user.email}</p>\n * </div>\n * )}\n * </User>\n * );\n * }\n * ```\n */\nconst User: FC<UserProps> = ({children, fallback = null}: UserProps): ReactElement => {\n const {user} = useThunderID();\n\n return (\n <BaseUser user={user} fallback={fallback}>\n {children}\n </BaseUser>\n );\n};\n\nUser.displayName = 'User';\n\nexport default User;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAMA,QAAuB,EAAC,UAAU,WAAW,WAAmC;CACpF,MAAM,EAAC,SAAQC,8BAAc;AAE7B,QACE,2CAACC;EAAe;EAAgB;EAC7B;GACQ;;AAIf,KAAK,cAAc;AAEnB,mBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAvatar.cjs","names":["UserAvatar: FC<UserAvatarProps>","useThunderID","BaseUserAvatar"],"sources":["../../../../../../src/client/components/presentation/UserAvatar/UserAvatar.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"UserAvatar.cjs","names":["UserAvatar: FC<UserAvatarProps>","useThunderID","BaseUserAvatar"],"sources":["../../../../../../src/client/components/presentation/UserAvatar/UserAvatar.tsx"],"sourcesContent":["// Copyright 2026 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {BaseUserAvatar, BaseUserAvatarProps} from '@thunderid/react';\nimport {FC, ReactElement} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\n\nexport type UserAvatarProps = Omit<BaseUserAvatarProps, 'user'>;\n\n/**\n * UserAvatar component renders an avatar for the currently signed-in user.\n * This component is the Next.js-specific implementation that uses BaseUserAvatar\n * and automatically retrieves the user data from ThunderID context.\n *\n * @example\n * ```tsx\n * <UserAvatar size={48} />\n * ```\n */\nconst UserAvatar: FC<UserAvatarProps> = (props: UserAvatarProps): ReactElement => {\n const {user} = useThunderID();\n\n return <BaseUserAvatar user={user} {...props} />;\n};\n\nexport default UserAvatar;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqBA,MAAMA,cAAmC,UAAyC;CAChF,MAAM,EAAC,SAAQC,8BAAc;AAE7B,QAAO,2CAACC;EAAqB;EAAM,GAAI;GAAS;;AAGlD,yBAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserDropdown.cjs","names":["UserDropdown: FC<UserDropdownProps>","useThunderID","renderProps: UserDropdownRenderProps","UserProfile","BaseUserDropdown"],"sources":["../../../../../../src/client/components/presentation/UserDropdown/UserDropdown.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"UserDropdown.cjs","names":["UserDropdown: FC<UserDropdownProps>","useThunderID","renderProps: UserDropdownRenderProps","UserProfile","BaseUserDropdown"],"sources":["../../../../../../src/client/components/presentation/UserDropdown/UserDropdown.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {BaseUserDropdown, BaseUserDropdownProps} from '@thunderid/react';\nimport {FC, ReactElement, ReactNode, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\nimport UserProfile from '../UserProfile/UserProfile.js';\n\n/**\n * Render props data passed to the children function\n */\nexport interface UserDropdownRenderProps {\n /** Function to close the profile dialog */\n closeProfile: () => void;\n /** Whether user data is currently loading */\n isLoading: boolean;\n /** Whether the profile dialog is currently open */\n isProfileOpen: boolean;\n /** Function to open the user profile dialog */\n openProfile: () => void;\n /** Function to sign out the user */\n signOut: () => void;\n /** The authenticated user object */\n user: any;\n}\n\n/**\n * Props for the UserDropdown component.\n * Extends BaseUserDropdownProps but excludes user, onManageProfile, and onSignOut since they're handled internally\n */\nexport type UserDropdownProps = Omit<BaseUserDropdownProps, 'user' | 'onManageProfile'> & {\n /**\n * Render prop function that receives user state and actions.\n * When provided, this completely replaces the default dropdown rendering.\n */\n children?: (props: UserDropdownRenderProps) => ReactNode;\n /**\n * Custom render function for the dropdown content.\n * When provided, this replaces just the dropdown content while keeping the trigger.\n */\n renderDropdown?: (props: UserDropdownRenderProps) => ReactNode;\n /**\n * Custom render function for the trigger button.\n * When provided, this replaces just the trigger button while keeping the dropdown.\n */\n renderTrigger?: (props: UserDropdownRenderProps) => ReactNode;\n};\n\n/**\n * UserDropdown component displays a user avatar with a dropdown menu.\n * When clicked, it shows a popover with customizable menu items.\n * This component is the React-specific implementation that uses the BaseUserDropdown\n * and automatically retrieves the user data from ThunderID context.\n *\n * Supports render props for complete customization of the dropdown appearance and behavior.\n *\n * @example\n * ```tsx\n * // Basic usage - will use user from ThunderID context\n * <UserDropdown menuItems={[\n * { label: 'Profile', onClick: () => {} },\n * { label: 'Settings', href: '/settings' },\n * { label: 'Sign Out', onClick: () => {} }\n * ]} />\n *\n * // With custom configuration\n * <UserDropdown\n * showTriggerLabel={true}\n * avatarSize={40}\n * fallback={<div>Please sign in</div>}\n * />\n *\n * // Using render props for complete customization\n * <UserDropdown>\n * {({ user, isLoading, openProfile, signOut }) => (\n * <div>\n * <button onClick={openProfile}>\n * {user?.name || 'Loading...'}\n * </button>\n * <button onClick={signOut}>Logout</button>\n * </div>\n * )}\n * </UserDropdown>\n *\n * // Using partial render props\n * <UserDropdown\n * renderTrigger={({ user, openProfile }) => (\n * <button onClick={openProfile} className=\"custom-trigger\">\n * Welcome, {user?.name}!\n * </button>\n * )}\n * />\n * ```\n */\nconst UserDropdown: FC<UserDropdownProps> = ({\n children,\n renderTrigger,\n renderDropdown,\n onSignOut,\n ...rest\n}: UserDropdownProps): ReactElement => {\n const {user, isLoading, signOut} = useThunderID();\n const [isProfileOpen, setIsProfileOpen] = useState(false);\n\n const handleManageProfile = (): void => {\n setIsProfileOpen(true);\n };\n\n const handleSignOut = (): void => {\n signOut();\n if (onSignOut) {\n onSignOut();\n }\n };\n\n const closeProfile = (): void => {\n setIsProfileOpen(false);\n };\n\n // Prepare render props data\n const renderProps: UserDropdownRenderProps = {\n closeProfile,\n isLoading: isLoading!,\n isProfileOpen,\n openProfile: handleManageProfile,\n signOut: handleSignOut,\n user,\n };\n\n // If children render prop is provided, use it for complete customization\n if (children) {\n return (\n <>\n {children(renderProps)}\n <UserProfile mode=\"popup\" open={isProfileOpen} onOpenChange={setIsProfileOpen} />\n </>\n );\n }\n\n // If partial render props are provided, customize specific parts\n if (renderTrigger || renderDropdown) {\n // This would require significant changes to BaseUserDropdown to support partial customization\n // For now, we'll provide a simple implementation that shows how it could work\n return (\n <>\n {renderTrigger ? (\n renderTrigger(renderProps)\n ) : (\n <BaseUserDropdown\n user={user}\n isLoading={isLoading}\n onManageProfile={handleManageProfile}\n onSignOut={handleSignOut}\n {...rest}\n />\n )}\n {/* Note: renderDropdown would need BaseUserDropdown modifications to implement properly */}\n <UserProfile mode=\"popup\" open={isProfileOpen} onOpenChange={setIsProfileOpen} />\n </>\n );\n }\n\n // Default behavior - use BaseUserDropdown as before\n return (\n <>\n <BaseUserDropdown\n user={user}\n isLoading={isLoading}\n onManageProfile={handleManageProfile}\n onSignOut={handleSignOut}\n {...rest}\n />\n {isProfileOpen && <UserProfile mode=\"popup\" open={isProfileOpen} onOpenChange={setIsProfileOpen} />}\n </>\n );\n};\n\nexport default UserDropdown;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,MAAMA,gBAAuC,EAC3C,UACA,eACA,gBACA,UACA,GAAG,WACkC;CACrC,MAAM,EAAC,MAAM,WAAW,YAAWC,8BAAc;CACjD,MAAM,CAAC,eAAe,wCAA6B,MAAM;CAEzD,MAAM,4BAAkC;AACtC,mBAAiB,KAAK;;CAGxB,MAAM,sBAA4B;AAChC,WAAS;AACT,MAAI,UACF,YAAW;;CAIf,MAAM,qBAA2B;AAC/B,mBAAiB,MAAM;;CAIzB,MAAMC,cAAuC;EAC3C;EACW;EACX;EACA,aAAa;EACb,SAAS;EACT;EACD;AAGD,KAAI,SACF,QACE,qFACG,SAAS,YAAY,EACtB,2CAACC;EAAY,MAAK;EAAQ,MAAM;EAAe,cAAc;GAAoB,IAChF;AAKP,KAAI,iBAAiB,eAGnB,QACE,qFACG,gBACC,cAAc,YAAY,GAE1B,2CAACC;EACO;EACK;EACX,iBAAiB;EACjB,WAAW;EACX,GAAI;GACJ,EAGJ,2CAACD;EAAY,MAAK;EAAQ,MAAM;EAAe,cAAc;GAAoB,IAChF;AAKP,QACE,qFACE,2CAACC;EACO;EACK;EACX,iBAAiB;EACjB,WAAW;EACX,GAAI;GACJ,EACD,iBAAiB,2CAACD;EAAY,MAAK;EAAQ,MAAM;EAAe,cAAc;GAAoB,IAClG;;AAIP,2BAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProfile.cjs","names":["UserProfile: FC<UserProfileProps>","useThunderID","isEditableProfile: boolean","result: {data: {user: User}; error: string; success: boolean}","getSessionId","BaseUserProfile"],"sources":["../../../../../../src/client/components/presentation/UserProfile/UserProfile.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"UserProfile.cjs","names":["UserProfile: FC<UserProfileProps>","useThunderID","isEditableProfile: boolean","result: {data: {user: User}; error: string; success: boolean}","getSessionId","BaseUserProfile"],"sources":["../../../../../../src/client/components/presentation/UserProfile/UserProfile.tsx"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {deepMerge, User} from '@thunderid/node';\nimport {BaseUserProfile, BaseUserProfileProps, useUser, useTranslation} from '@thunderid/react';\nimport {FC, ReactElement, useState} from 'react';\nimport useThunderID from '../../../contexts/ThunderID/useThunderID';\nimport getSessionId from '../../../../server/actions/getSessionId';\n\n/**\n * Props for the UserProfile component.\n * Extends BaseUserProfileProps but makes the user prop optional since it will be obtained from useThunderID\n */\nexport type UserProfileProps = Omit<BaseUserProfileProps, 'user' | 'profile' | 'flattenedProfile'>;\n\n/**\n * UserProfile component displays the authenticated user's profile information in a\n * structured and styled format. It shows user details such as display name, email,\n * username, and other available profile information from ThunderID.\n *\n * This component is the React-specific implementation that uses the BaseUserProfile\n * and automatically retrieves the user data from ThunderID context if not provided.\n *\n * @example\n * ```tsx\n * // Basic usage - will use user from ThunderID context\n * <UserProfile />\n *\n * // With explicit user data\n * <UserProfile user={specificUser} />\n *\n * // With card layout and custom fallback\n * <UserProfile\n * cardLayout={true}\n * fallback={<div>Please sign in to view your profile</div>}\n * />\n * ```\n */\nconst UserProfile: FC<UserProfileProps> = ({preferences, editable = true, ...rest}: UserProfileProps): ReactElement => {\n const {preferences: contextPreferences} = useThunderID();\n const {profile, flattenedProfile, onUpdateProfile, updateProfile} = useUser();\n const resolvedPreferences = {\n ...contextPreferences,\n ...preferences,\n user: {\n ...contextPreferences?.user,\n ...preferences?.user,\n },\n };\n const {t} = useTranslation(resolvedPreferences?.i18n);\n const isEditableProfile: boolean = resolvedPreferences?.user?.fetchUserProfile === false ? false : editable;\n\n const [error, setError] = useState<string | null>(null);\n\n const handleProfileUpdate = async (payload: any): Promise<void> => {\n setError(null);\n\n const updatedAttributes = deepMerge((profile?.['attributes'] as Record<string, unknown>) ?? {}, payload);\n\n Object.keys(updatedAttributes).forEach((key) => {\n if (updatedAttributes[key] === undefined || updatedAttributes[key] === null) {\n delete updatedAttributes[key];\n }\n });\n\n const result: {data: {user: User}; error: string; success: boolean} = await updateProfile(\n {payload: updatedAttributes},\n await getSessionId(),\n );\n\n if (result.success) {\n onUpdateProfile(result.data.user);\n } else {\n setError(result.error || t('user.profile.update.generic.error'));\n }\n };\n\n return (\n <BaseUserProfile\n profile={profile!}\n flattenedProfile={flattenedProfile!}\n editable={isEditableProfile}\n onUpdate={isEditableProfile ? handleProfileUpdate : undefined}\n error={error}\n preferences={resolvedPreferences}\n {...rest}\n />\n );\n};\n\nexport default UserProfile;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAMA,eAAqC,EAAC,aAAa,WAAW,KAAM,GAAG,WAA0C;CACrH,MAAM,EAAC,aAAa,uBAAsBC,8BAAc;CACxD,MAAM,EAAC,SAAS,kBAAkB,iBAAiB,kDAA0B;CAC7E,MAAM,sBAAsB;EAC1B,GAAG;EACH,GAAG;EACH,MAAM;GACJ,GAAG,oBAAoB;GACvB,GAAG,aAAa;GACjB;EACF;CACD,MAAM,EAAC,4CAAoB,qBAAqB,KAAK;CACrD,MAAMC,oBAA6B,qBAAqB,MAAM,qBAAqB,QAAQ,QAAQ;CAEnG,MAAM,CAAC,OAAO,gCAAoC,KAAK;CAEvD,MAAM,sBAAsB,OAAO,YAAgC;AACjE,WAAS,KAAK;EAEd,MAAM,oDAA+B,UAAU,iBAA6C,EAAE,EAAE,QAAQ;AAExG,SAAO,KAAK,kBAAkB,CAAC,SAAS,QAAQ;AAC9C,OAAI,kBAAkB,SAAS,UAAa,kBAAkB,SAAS,KACrE,QAAO,kBAAkB;IAE3B;EAEF,MAAMC,SAAgE,MAAM,cAC1E,EAAC,SAAS,mBAAkB,EAC5B,MAAMC,8BAAc,CACrB;AAED,MAAI,OAAO,QACT,iBAAgB,OAAO,KAAK,KAAK;MAEjC,UAAS,OAAO,SAAS,EAAE,oCAAoC,CAAC;;AAIpE,QACE,2CAACC;EACU;EACS;EAClB,UAAU;EACV,UAAU,oBAAoB,sBAAsB;EAC7C;EACP,aAAa;EACb,GAAI;GACJ;;AAIN,0BAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThunderIDContext.cjs","names":["ThunderIDContext: Context<ThunderIDContextProps | null>"],"sources":["../../../../../src/client/contexts/ThunderID/ThunderIDContext.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"ThunderIDContext.cjs","names":["ThunderIDContext: Context<ThunderIDContextProps | null>"],"sources":["../../../../../src/client/contexts/ThunderID/ThunderIDContext.ts"],"sourcesContent":["// Copyright 2025 The ThunderID Authors\n// SPDX-License-Identifier: Apache-2.0\n\n'use client';\n\nimport {ThunderIDContextProps as ReactContextProps} from '@thunderid/react';\nimport {Context, createContext} from 'react';\nimport {RefreshResult} from '../../../server/actions/refreshToken';\n\n/**\n * Props interface of {@link ThunderIDContext}\n */\nexport type ThunderIDContextProps = Partial<ReactContextProps> & {\n clearSession?: () => Promise<void>;\n refreshToken?: () => Promise<RefreshResult>;\n};\n\n/**\n * Context object for managing the Authentication flow builder core context.\n */\nconst ThunderIDContext: Context<ThunderIDContextProps | null> = createContext<null | ThunderIDContextProps>({\n afterSignInUrl: undefined,\n applicationId: undefined,\n baseUrl: undefined,\n clearSession: () => Promise.resolve(),\n isInitialized: false,\n isLoading: true,\n isSignedIn: false,\n organizationHandle: undefined,\n refreshToken: () => Promise.resolve({expiresAt: 0}),\n signIn: () => Promise.resolve({} as any),\n signInUrl: undefined,\n signOut: () => Promise.resolve({} as any),\n signUp: () => Promise.resolve({} as any),\n signUpUrl: undefined,\n user: null,\n});\n\nThunderIDContext.displayName = 'ThunderIDContext';\n\nexport default ThunderIDContext;\n"],"mappings":";;;;;;;;;;;AAoBA,MAAMA,4CAAsG;CAC1G,gBAAgB;CAChB,eAAe;CACf,SAAS;CACT,oBAAoB,QAAQ,SAAS;CACrC,eAAe;CACf,WAAW;CACX,YAAY;CACZ,oBAAoB;CACpB,oBAAoB,QAAQ,QAAQ,EAAC,WAAW,GAAE,CAAC;CACnD,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,WAAW;CACX,eAAe,QAAQ,QAAQ,EAAE,CAAQ;CACzC,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,WAAW;CACX,MAAM;CACP,CAAC;AAEF,iBAAiB,cAAc;AAE/B,+BAAe"}
|