@thunderid/react 0.6.0 → 0.7.0
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/api/{getScim2Me.d.ts → getUsersMe.d.ts} +11 -11
- package/dist/api/{getScim2Me.d.ts.map → getUsersMe.d.ts.map} +1 -1
- package/dist/api/{getScim2Me.js → getUsersMe.js} +12 -12
- package/dist/api/{getScim2Me.js.map → getUsersMe.js.map} +1 -1
- package/dist/api/updateMeProfile.d.ts +5 -5
- package/dist/api/updateMeProfile.js +6 -6
- package/dist/api/updateMeProfile.js.map +1 -1
- package/dist/cjs/api/{getScim2Me.cjs → getUsersMe.cjs} +11 -11
- package/dist/cjs/api/{getScim2Me.cjs.map → getUsersMe.cjs.map} +1 -1
- package/dist/cjs/api/updateMeProfile.cjs +6 -6
- package/dist/cjs/api/updateMeProfile.cjs.map +1 -1
- package/dist/cjs/components/presentation/UserProfile/BaseUserProfile.cjs +48 -58
- package/dist/cjs/components/presentation/UserProfile/BaseUserProfile.cjs.map +1 -1
- package/dist/cjs/components/presentation/UserProfile/UserProfile.cjs +21 -8
- package/dist/cjs/components/presentation/UserProfile/UserProfile.cjs.map +1 -1
- package/dist/cjs/components/presentation/auth/SignUp/BaseSignUp.cjs +2 -0
- package/dist/cjs/components/presentation/auth/SignUp/BaseSignUp.cjs.map +1 -1
- package/dist/cjs/contexts/ThunderID/ThunderIDContext.cjs +1 -0
- package/dist/cjs/contexts/ThunderID/ThunderIDContext.cjs.map +1 -1
- package/dist/cjs/contexts/ThunderID/ThunderIDProvider.cjs +23 -7
- package/dist/cjs/contexts/ThunderID/ThunderIDProvider.cjs.map +1 -1
- package/dist/cjs/contexts/User/UserContext.cjs +0 -1
- package/dist/cjs/contexts/User/UserContext.cjs.map +1 -1
- package/dist/cjs/contexts/User/UserProvider.cjs +0 -2
- package/dist/cjs/contexts/User/UserProvider.cjs.map +1 -1
- package/dist/cjs/contexts/User/useUser.cjs +0 -1
- package/dist/cjs/contexts/User/useUser.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts +0 -20
- package/dist/components/presentation/UserProfile/BaseUserProfile.d.ts.map +1 -1
- package/dist/components/presentation/UserProfile/BaseUserProfile.js +50 -60
- package/dist/components/presentation/UserProfile/BaseUserProfile.js.map +1 -1
- package/dist/components/presentation/UserProfile/UserProfile.d.ts +1 -1
- package/dist/components/presentation/UserProfile/UserProfile.d.ts.map +1 -1
- package/dist/components/presentation/UserProfile/UserProfile.js +22 -9
- package/dist/components/presentation/UserProfile/UserProfile.js.map +1 -1
- package/dist/components/presentation/auth/SignUp/BaseSignUp.d.ts.map +1 -1
- package/dist/components/presentation/auth/SignUp/BaseSignUp.js +2 -0
- package/dist/components/presentation/auth/SignUp/BaseSignUp.js.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDContext.d.ts +1 -0
- package/dist/contexts/ThunderID/ThunderIDContext.d.ts.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDContext.js +1 -0
- package/dist/contexts/ThunderID/ThunderIDContext.js.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDProvider.d.ts.map +1 -1
- package/dist/contexts/ThunderID/ThunderIDProvider.js +23 -7
- package/dist/contexts/ThunderID/ThunderIDProvider.js.map +1 -1
- package/dist/contexts/User/UserContext.d.ts +1 -2
- package/dist/contexts/User/UserContext.d.ts.map +1 -1
- package/dist/contexts/User/UserContext.js +0 -1
- package/dist/contexts/User/UserContext.js.map +1 -1
- package/dist/contexts/User/UserProvider.d.ts +0 -1
- package/dist/contexts/User/UserProvider.d.ts.map +1 -1
- package/dist/contexts/User/UserProvider.js +0 -2
- package/dist/contexts/User/UserProvider.js.map +1 -1
- package/dist/contexts/User/useUser.d.ts +0 -1
- package/dist/contexts/User/useUser.d.ts.map +1 -1
- package/dist/contexts/User/useUser.js +0 -1
- package/dist/contexts/User/useUser.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +3 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThunderIDContext.cjs","names":["ThunderIDContext: Context<ThunderIDContextProps | null>","VendorConstants"],"sources":["../../../../src/contexts/ThunderID/ThunderIDContext.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 FlowMetadataResponse,\n HttpRequestConfig,\n HttpResponse,\n IdToken,\n OIDCDiscoveryApiResponse,\n SignInOptions,\n TokenExchangeRequestConfig,\n TokenResponse,\n VendorConstants,\n} from '@thunderid/browser';\nimport {Context, createContext} from 'react';\nimport {ThunderIDReactConfig} from '../../models/config';\nimport ThunderIDReactClient from '../../ThunderIDReactClient';\n\n/**\n * Props interface of {@link ThunderIDContext}\n */\nexport type ThunderIDContextProps = {\n afterSignInUrl: string | undefined;\n applicationId: string | undefined;\n baseUrl: string | undefined;\n clientId: string | undefined;\n scopes: string | string[] | undefined;\n /**\n * OIDC discovery data.\n */\n discovery: {\n /**\n * The response from the `.well-known/openid-configuration` endpoint.\n * Contains server capabilities, supported endpoints, and metadata.\n * `null` while loading or when discovery has not been fetched.\n */\n wellKnown: OIDCDiscoveryApiResponse | null;\n };\n /**\n * Swaps the current access token with a new one based on the provided configuration (with a grant type).\n * @param config - Configuration for the token exchange request.\n * @returns A promise that resolves to the token response or the raw response.\n */\n exchangeToken: (config: TokenExchangeRequestConfig) => Promise<TokenResponse | Response>;\n /**\n * Retrieves the access token stored in the storage.\n * This function retrieves the access token and returns it.\n * @remarks This does not work in the `webWorker` or any other worker environment.\n * @returns A promise that resolves to the access token.\n */\n getAccessToken: () => Promise<string>;\n /**\n * Function to retrieve the decoded ID token.\n * This function decodes the ID token and returns its payload.\n * It can be used to access user claims and other information contained in the ID token.\n *\n * @returns A promise that resolves to the decoded ID token payload.\n */\n getDecodedIdToken: () => Promise<IdToken>;\n /**\n * Function to retrieve the ID token.\n * This function retrieves the ID token and returns it.\n *\n * @returns A promise that resolves to the ID token.\n */\n getIdToken: () => Promise<string>;\n /**\n * Returns the underlying StorageManager instance for reading and writing SDK-managed storage.\n */\n getStorageManager: () => Promise<any>;\n /**\n * HTTP request function to make API calls.\n * @param requestConfig - Configuration for the HTTP request.\n * @returns A promise that resolves to the HTTP response.\n */\n http: {\n /**\n * Makes an HTTP request using the provided configuration.\n * @param requestConfig - Configuration for the HTTP request.\n * @returns A promise that resolves to the HTTP response.\n */\n request: (requestConfig?: HttpRequestConfig) => Promise<HttpResponse<any>>;\n /**\n * Makes multiple HTTP requests based on the provided configuration.\n * @param requestConfigs - Set of configurations for the HTTP requests.\n * @returns A promise that resolves to an array of HTTP responses.\n */\n requestAll: (requestConfigs?: HttpRequestConfig[]) => Promise<HttpResponse<any>[]>;\n };\n /**\n * Instance ID for multi-instance support.\n */\n instanceId: number;\n isInitialized: boolean;\n /**\n * Flag indicating whether the SDK is working in the background.\n */\n isLoading: boolean;\n /**\n * Flag indicating whether flow metadata is currently being fetched.\n */\n isMetaLoading: boolean;\n /**\n * Flag indicating whether the user is signed in or not.\n */\n isSignedIn: boolean;\n\n /**\n * Flow metadata returned by `GET /flow/meta` (v2 platform only).\n * `null` while loading or when `resolveFromMeta` is disabled.\n */\n meta: FlowMetadataResponse | null;\n\n organizationHandle: string | undefined;\n\n /**\n * Re-initializes the client with a new configuration.\n *\n * @remarks\n * This can be partial configuration to update only specific fields.\n *\n * @param config - New configuration to re-initialize the client with.\n * @returns Promise resolving to boolean indicating success.\n */\n reInitialize: (config: Partial<ThunderIDReactConfig>) => Promise<boolean>;\n\n /**\n * Recovery function to initiate the account/password recovery flow.\n */\n recover: (...args: any[]) => Promise<any>;\n\n /**\n * Resolves `{{ t(key) }}` and `{{ meta(path) }}` template expressions in a string,\n * using the current i18n translation function and flow metadata from context.\n *\n * Useful in render-props patterns where consumers need to expand template strings\n * that come from the server (e.g. component labels, placeholders, headings).\n *\n * @example\n * const {resolveFlowTemplateLiterals} = useThunderID();\n * resolveFlowTemplateLiterals('{{ t(signin.heading.label) }}') // → 'Sign In'\n * resolveFlowTemplateLiterals('Login to {{ meta(application.name) }}') // → 'Login to My App'\n */\n resolveFlowTemplateLiterals: (text: string | undefined) => string;\n\n /**\n * Sign-in function to initiate the authentication process.\n * @remark This is the programmatic version of the `SignInButton` component.\n * TODO: Fix the types.\n */\n signIn: (...args: any) => Promise<any>;\n\n /**\n * Optional additional parameters to be sent in the sign-in request.\n * This can include custom parameters that your authorization server supports.\n * These parameters will be included in the authorization request sent to the server.\n * If not provided, no additional parameters will be sent.\n *\n * @example\n * signInOptions: { prompt: \"login\", fidp: \"OrganizationSSO\" }\n */\n signInOptions?: SignInOptions;\n\n /**\n * Optional token request configuration. params are appended to the token endpoint POST body.\n *\n * @example\n * tokenRequest: { params: { resource: \"https://api.example.com\" } }\n */\n tokenRequest?: {\n params?: Record<string, unknown>;\n };\n\n /**\n * Silent sign-in function to re-authenticate the user without user interaction.\n * @remark This is the programmatic version of the `SilentSignIn` component.\n */\n signInSilently: ThunderIDReactClient['signInSilently'];\n\n signInUrl: string | undefined;\n /**\n * Sign-out function to terminate the authentication session.\n * @remark This is the programmatic version of the `SignOutButton` component.\n * FIXME: Fix the types.\n */\n signOut: any;\n\n /**\n * Sign-up function to initiate the registration process.\n * @remark This is the programmatic version of the `SignUpButton` component.\n */\n signUp: (...args: any[]) => Promise<any>;\n\n signUpUrl: string | undefined;\n\n user: any;\n\n /**\n * Vendor/brand namespace used to prefix storage keys, cookie names, and CSS class names.\n * Resolved from the `vendor` config option, defaulting to `'thunderid'`.\n */\n vendor: string;\n} & Pick<ThunderIDReactClient, 'clearSession'>;\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: () => {},\n clientId: undefined,\n scopes: undefined,\n discovery: {\n wellKnown: null,\n },\n exchangeToken: null as unknown as ThunderIDContextProps['exchangeToken'],\n getAccessToken: null as unknown as ThunderIDContextProps['getAccessToken'],\n getDecodedIdToken: null as unknown as ThunderIDContextProps['getDecodedIdToken'],\n getIdToken: null as unknown as ThunderIDContextProps['getIdToken'],\n getStorageManager: () => Promise.resolve(null),\n http: {\n request: () => null as unknown as Promise<HttpResponse<any>>,\n requestAll: () => null as unknown as Promise<HttpResponse<any>[]>,\n },\n instanceId: 0,\n isInitialized: false,\n isLoading: true,\n isMetaLoading: false,\n isSignedIn: false,\n meta: null,\n organizationHandle: undefined,\n reInitialize: null as unknown as ThunderIDContextProps['reInitialize'],\n recover: () => Promise.resolve({} as any),\n resolveFlowTemplateLiterals: (text: string | undefined) => text ?? '',\n signIn: () => Promise.resolve({} as any),\n signInSilently: () => 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 vendor: VendorConstants.VENDOR_PREFIX,\n});\n\nThunderIDContext.displayName = 'ThunderIDContext';\n\nexport default ThunderIDContext;\n"],"mappings":";;;;;;;;;;AA8NA,MAAMA,4CAAsG;CAC1G,gBAAgB;CAChB,eAAe;CACf,SAAS;CACT,oBAAoB;CACpB,UAAU;CACV,QAAQ;CACR,WAAW,EACT,WAAW,MACZ;CACD,eAAe;CACf,gBAAgB;CAChB,mBAAmB;CACnB,YAAY;CACZ,yBAAyB,QAAQ,QAAQ,KAAK;CAC9C,MAAM;EACJ,eAAe;EACf,kBAAkB;EACnB;CACD,YAAY;CACZ,eAAe;CACf,WAAW;CACX,eAAe;CACf,YAAY;CACZ,MAAM;CACN,oBAAoB;CACpB,cAAc;CACd,eAAe,QAAQ,QAAQ,EAAE,CAAQ;CACzC,8BAA8B,SAA6B,QAAQ;CACnE,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,sBAAsB,QAAQ,QAAQ,EAAE,CAAQ;CAChD,WAAW;CACX,eAAe,QAAQ,QAAQ,EAAE,CAAQ;CACzC,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,WAAW;CACX,MAAM;CACN,QAAQC,oCAAgB;CACzB,CAAC;AAEF,iBAAiB,cAAc;AAE/B,+BAAe"}
|
|
1
|
+
{"version":3,"file":"ThunderIDContext.cjs","names":["ThunderIDContext: Context<ThunderIDContextProps | null>","VendorConstants"],"sources":["../../../../src/contexts/ThunderID/ThunderIDContext.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 FlowMetadataResponse,\n HttpRequestConfig,\n HttpResponse,\n IdToken,\n OIDCDiscoveryApiResponse,\n SignInOptions,\n TokenExchangeRequestConfig,\n TokenResponse,\n VendorConstants,\n} from '@thunderid/browser';\nimport {Context, createContext} from 'react';\nimport {ThunderIDReactConfig} from '../../models/config';\nimport ThunderIDReactClient from '../../ThunderIDReactClient';\n\n/**\n * Props interface of {@link ThunderIDContext}\n */\nexport type ThunderIDContextProps = {\n afterSignInUrl: string | undefined;\n applicationId: string | undefined;\n baseUrl: string | undefined;\n clientId: string | undefined;\n preferences?: ThunderIDReactConfig['preferences'];\n scopes: string | string[] | undefined;\n /**\n * OIDC discovery data.\n */\n discovery: {\n /**\n * The response from the `.well-known/openid-configuration` endpoint.\n * Contains server capabilities, supported endpoints, and metadata.\n * `null` while loading or when discovery has not been fetched.\n */\n wellKnown: OIDCDiscoveryApiResponse | null;\n };\n /**\n * Swaps the current access token with a new one based on the provided configuration (with a grant type).\n * @param config - Configuration for the token exchange request.\n * @returns A promise that resolves to the token response or the raw response.\n */\n exchangeToken: (config: TokenExchangeRequestConfig) => Promise<TokenResponse | Response>;\n /**\n * Retrieves the access token stored in the storage.\n * This function retrieves the access token and returns it.\n * @remarks This does not work in the `webWorker` or any other worker environment.\n * @returns A promise that resolves to the access token.\n */\n getAccessToken: () => Promise<string>;\n /**\n * Function to retrieve the decoded ID token.\n * This function decodes the ID token and returns its payload.\n * It can be used to access user claims and other information contained in the ID token.\n *\n * @returns A promise that resolves to the decoded ID token payload.\n */\n getDecodedIdToken: () => Promise<IdToken>;\n /**\n * Function to retrieve the ID token.\n * This function retrieves the ID token and returns it.\n *\n * @returns A promise that resolves to the ID token.\n */\n getIdToken: () => Promise<string>;\n /**\n * Returns the underlying StorageManager instance for reading and writing SDK-managed storage.\n */\n getStorageManager: () => Promise<any>;\n /**\n * HTTP request function to make API calls.\n * @param requestConfig - Configuration for the HTTP request.\n * @returns A promise that resolves to the HTTP response.\n */\n http: {\n /**\n * Makes an HTTP request using the provided configuration.\n * @param requestConfig - Configuration for the HTTP request.\n * @returns A promise that resolves to the HTTP response.\n */\n request: (requestConfig?: HttpRequestConfig) => Promise<HttpResponse<any>>;\n /**\n * Makes multiple HTTP requests based on the provided configuration.\n * @param requestConfigs - Set of configurations for the HTTP requests.\n * @returns A promise that resolves to an array of HTTP responses.\n */\n requestAll: (requestConfigs?: HttpRequestConfig[]) => Promise<HttpResponse<any>[]>;\n };\n /**\n * Instance ID for multi-instance support.\n */\n instanceId: number;\n isInitialized: boolean;\n /**\n * Flag indicating whether the SDK is working in the background.\n */\n isLoading: boolean;\n /**\n * Flag indicating whether flow metadata is currently being fetched.\n */\n isMetaLoading: boolean;\n /**\n * Flag indicating whether the user is signed in or not.\n */\n isSignedIn: boolean;\n\n /**\n * Flow metadata returned by `GET /flow/meta` (v2 platform only).\n * `null` while loading or when `resolveFromMeta` is disabled.\n */\n meta: FlowMetadataResponse | null;\n\n organizationHandle: string | undefined;\n\n /**\n * Re-initializes the client with a new configuration.\n *\n * @remarks\n * This can be partial configuration to update only specific fields.\n *\n * @param config - New configuration to re-initialize the client with.\n * @returns Promise resolving to boolean indicating success.\n */\n reInitialize: (config: Partial<ThunderIDReactConfig>) => Promise<boolean>;\n\n /**\n * Recovery function to initiate the account/password recovery flow.\n */\n recover: (...args: any[]) => Promise<any>;\n\n /**\n * Resolves `{{ t(key) }}` and `{{ meta(path) }}` template expressions in a string,\n * using the current i18n translation function and flow metadata from context.\n *\n * Useful in render-props patterns where consumers need to expand template strings\n * that come from the server (e.g. component labels, placeholders, headings).\n *\n * @example\n * const {resolveFlowTemplateLiterals} = useThunderID();\n * resolveFlowTemplateLiterals('{{ t(signin.heading.label) }}') // → 'Sign In'\n * resolveFlowTemplateLiterals('Login to {{ meta(application.name) }}') // → 'Login to My App'\n */\n resolveFlowTemplateLiterals: (text: string | undefined) => string;\n\n /**\n * Sign-in function to initiate the authentication process.\n * @remark This is the programmatic version of the `SignInButton` component.\n * TODO: Fix the types.\n */\n signIn: (...args: any) => Promise<any>;\n\n /**\n * Optional additional parameters to be sent in the sign-in request.\n * This can include custom parameters that your authorization server supports.\n * These parameters will be included in the authorization request sent to the server.\n * If not provided, no additional parameters will be sent.\n *\n * @example\n * signInOptions: { prompt: \"login\", fidp: \"OrganizationSSO\" }\n */\n signInOptions?: SignInOptions;\n\n /**\n * Optional token request configuration. params are appended to the token endpoint POST body.\n *\n * @example\n * tokenRequest: { params: { resource: \"https://api.example.com\" } }\n */\n tokenRequest?: {\n params?: Record<string, unknown>;\n };\n\n /**\n * Silent sign-in function to re-authenticate the user without user interaction.\n * @remark This is the programmatic version of the `SilentSignIn` component.\n */\n signInSilently: ThunderIDReactClient['signInSilently'];\n\n signInUrl: string | undefined;\n /**\n * Sign-out function to terminate the authentication session.\n * @remark This is the programmatic version of the `SignOutButton` component.\n * FIXME: Fix the types.\n */\n signOut: any;\n\n /**\n * Sign-up function to initiate the registration process.\n * @remark This is the programmatic version of the `SignUpButton` component.\n */\n signUp: (...args: any[]) => Promise<any>;\n\n signUpUrl: string | undefined;\n\n user: any;\n\n /**\n * Vendor/brand namespace used to prefix storage keys, cookie names, and CSS class names.\n * Resolved from the `vendor` config option, defaulting to `'thunderid'`.\n */\n vendor: string;\n} & Pick<ThunderIDReactClient, 'clearSession'>;\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: () => {},\n clientId: undefined,\n preferences: undefined,\n scopes: undefined,\n discovery: {\n wellKnown: null,\n },\n exchangeToken: null as unknown as ThunderIDContextProps['exchangeToken'],\n getAccessToken: null as unknown as ThunderIDContextProps['getAccessToken'],\n getDecodedIdToken: null as unknown as ThunderIDContextProps['getDecodedIdToken'],\n getIdToken: null as unknown as ThunderIDContextProps['getIdToken'],\n getStorageManager: () => Promise.resolve(null),\n http: {\n request: () => null as unknown as Promise<HttpResponse<any>>,\n requestAll: () => null as unknown as Promise<HttpResponse<any>[]>,\n },\n instanceId: 0,\n isInitialized: false,\n isLoading: true,\n isMetaLoading: false,\n isSignedIn: false,\n meta: null,\n organizationHandle: undefined,\n reInitialize: null as unknown as ThunderIDContextProps['reInitialize'],\n recover: () => Promise.resolve({} as any),\n resolveFlowTemplateLiterals: (text: string | undefined) => text ?? '',\n signIn: () => Promise.resolve({} as any),\n signInSilently: () => 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 vendor: VendorConstants.VENDOR_PREFIX,\n});\n\nThunderIDContext.displayName = 'ThunderIDContext';\n\nexport default ThunderIDContext;\n"],"mappings":";;;;;;;;;;AA+NA,MAAMA,4CAAsG;CAC1G,gBAAgB;CAChB,eAAe;CACf,SAAS;CACT,oBAAoB;CACpB,UAAU;CACV,aAAa;CACb,QAAQ;CACR,WAAW,EACT,WAAW,MACZ;CACD,eAAe;CACf,gBAAgB;CAChB,mBAAmB;CACnB,YAAY;CACZ,yBAAyB,QAAQ,QAAQ,KAAK;CAC9C,MAAM;EACJ,eAAe;EACf,kBAAkB;EACnB;CACD,YAAY;CACZ,eAAe;CACf,WAAW;CACX,eAAe;CACf,YAAY;CACZ,MAAM;CACN,oBAAoB;CACpB,cAAc;CACd,eAAe,QAAQ,QAAQ,EAAE,CAAQ;CACzC,8BAA8B,SAA6B,QAAQ;CACnE,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,sBAAsB,QAAQ,QAAQ,EAAE,CAAQ;CAChD,WAAW;CACX,eAAe,QAAQ,QAAQ,EAAE,CAAQ;CACzC,cAAc,QAAQ,QAAQ,EAAE,CAAQ;CACxC,WAAW;CACX,MAAM;CACN,QAAQC,oCAAgB;CACzB,CAAC;AAEF,iBAAiB,cAAc;AAE/B,+BAAe"}
|
|
@@ -8,6 +8,7 @@ const require_FlowMetaProvider = require('../FlowMeta/FlowMetaProvider.cjs');
|
|
|
8
8
|
const require_I18nProvider = require('../I18n/I18nProvider.cjs');
|
|
9
9
|
const require_ThemeProvider = require('../Theme/ThemeProvider.cjs');
|
|
10
10
|
const require_UserProvider = require('../User/UserProvider.cjs');
|
|
11
|
+
const require_getUsersMe = require('../../api/getUsersMe.cjs');
|
|
11
12
|
let __thunderid_browser = require("@thunderid/browser");
|
|
12
13
|
__thunderid_browser = require_rolldown_runtime.__toESM(__thunderid_browser);
|
|
13
14
|
let react = require("react");
|
|
@@ -66,14 +67,28 @@ const ThunderIDProvider = ({ afterSignInUrl, afterSignOutUrl, baseUrl: initialBa
|
|
|
66
67
|
resolvedBaseUrl = `${(await client.getConfiguration()).baseUrl}/o`;
|
|
67
68
|
setBaseUrl(resolvedBaseUrl);
|
|
68
69
|
}
|
|
70
|
+
const shouldFetchProfile = preferences?.user?.fetchUserProfile !== false;
|
|
69
71
|
const claims = (0, __thunderid_browser.extractUserClaimsFromIdToken)(decodedToken);
|
|
70
|
-
|
|
72
|
+
let profileData = claims;
|
|
73
|
+
const currentSignInStatus = await client.isSignedIn();
|
|
74
|
+
if (currentSignInStatus && shouldFetchProfile) try {
|
|
75
|
+
const fetchedProfile = await require_getUsersMe.default({
|
|
76
|
+
baseUrl: resolvedBaseUrl,
|
|
77
|
+
instanceId
|
|
78
|
+
});
|
|
79
|
+
profileData = {
|
|
80
|
+
...claims,
|
|
81
|
+
...fetchedProfile
|
|
82
|
+
};
|
|
83
|
+
} catch (err) {
|
|
84
|
+
logger.warn("Failed to fetch user profile from /users/me:", err);
|
|
85
|
+
}
|
|
86
|
+
setUser(profileData);
|
|
71
87
|
setUserProfile({
|
|
72
|
-
flattenedProfile:
|
|
73
|
-
profile:
|
|
74
|
-
schemas: []
|
|
88
|
+
flattenedProfile: (0, __thunderid_browser.generateFlattenedUserProfile)(profileData, []),
|
|
89
|
+
profile: profileData
|
|
75
90
|
});
|
|
76
|
-
setIsSignedInSync(
|
|
91
|
+
setIsSignedInSync(currentSignInStatus);
|
|
77
92
|
} catch (error) {} finally {
|
|
78
93
|
setIsUpdatingSession(false);
|
|
79
94
|
setIsLoadingSync(client.isLoading());
|
|
@@ -207,8 +222,7 @@ const ThunderIDProvider = ({ afterSignInUrl, afterSignOutUrl, baseUrl: initialBa
|
|
|
207
222
|
const handleProfileUpdate = (payload) => {
|
|
208
223
|
setUser(payload);
|
|
209
224
|
setUserProfile((prev) => ({
|
|
210
|
-
|
|
211
|
-
flattenedProfile: (0, __thunderid_browser.generateFlattenedUserProfile)(payload, prev?.schemas ?? []),
|
|
225
|
+
flattenedProfile: (0, __thunderid_browser.generateFlattenedUserProfile)(payload),
|
|
212
226
|
profile: payload
|
|
213
227
|
}));
|
|
214
228
|
};
|
|
@@ -251,6 +265,7 @@ const ThunderIDProvider = ({ afterSignInUrl, afterSignOutUrl, baseUrl: initialBa
|
|
|
251
265
|
isSignedIn: isSignedInSync,
|
|
252
266
|
organizationChain,
|
|
253
267
|
organizationHandle: config?.organizationHandle,
|
|
268
|
+
preferences,
|
|
254
269
|
reInitialize,
|
|
255
270
|
recover,
|
|
256
271
|
signIn,
|
|
@@ -292,6 +307,7 @@ const ThunderIDProvider = ({ afterSignInUrl, afterSignOutUrl, baseUrl: initialBa
|
|
|
292
307
|
getStorageManager,
|
|
293
308
|
instanceId,
|
|
294
309
|
organizationChain,
|
|
310
|
+
preferences,
|
|
295
311
|
recover,
|
|
296
312
|
reInitialize,
|
|
297
313
|
request,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThunderIDProvider.cjs","names":["logger: ReturnType<typeof createPackageComponentLogger>","ThunderIDProvider: FC<PropsWithChildren<ThunderIDProviderProps>>","reRenderCheckRef: RefObject<boolean>","client: ThunderIDReactClient","ThunderIDReactClient","storageManagerRef: any","useBrowserUrl","resolvedBaseUrl: string","decodedToken: IdToken","claims: User","arg1: any","isV2FlowRequest: boolean","ThunderIDRuntimeError","isAlreadySignedIn: boolean","currentUrl: URL","urlParams: URLSearchParams","code: string | null","executionIdFromUrl: string | null","storedExecutionId: string | null","interval: NodeJS.Timeout","status: boolean","getDecodedIdToken: () => Promise<IdToken>","getIdToken: () => Promise<string>","getAccessToken: () => Promise<string>","getStorageManager: () => Promise<any>","storageManager: any","request: (...args: any[]) => Promise<any>","requestAll: (...args: any[]) => Promise<any>","exchangeToken: (exchangeConfig: any) => Promise<any>","signOut: (...args: any[]) => Promise<any>","recover: (payload: any) => Promise<any>","signUp: (...args: any[]) => Promise<any>","clearSession: (...args: any[]) => Promise<any>","reInitialize: (reInitConfig: any) => Promise<any>","value: any","ThunderIDContext","I18nProvider","FlowMetaProvider","ThemeProvider","FlowProvider","UserProvider","ComponentRendererProvider"],"sources":["../../../../src/contexts/ThunderID/ThunderIDProvider.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025-2026, 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 ThunderIDRuntimeError,\n generateFlattenedUserProfile,\n OIDCDiscoveryApiResponse,\n SignInOptions,\n User,\n UserProfile,\n IdToken,\n extractUserClaimsFromIdToken,\n EmbeddedSignInFlowResponse,\n createPackageComponentLogger,\n getVendorPrefix,\n} from '@thunderid/browser';\nimport {FC, RefObject, PropsWithChildren, ReactElement, useEffect, useMemo, useRef, useState, useCallback} from 'react';\nimport ThunderIDContext from './ThunderIDContext';\nimport useBrowserUrl from '../../hooks/useBrowserUrl';\nimport {ThunderIDReactConfig} from '../../models/config';\nimport ThunderIDReactClient from '../../ThunderIDReactClient';\nimport ComponentRendererProvider from '../ComponentRenderer/ComponentRendererProvider';\nimport FlowProvider from '../Flow/FlowProvider';\nimport FlowMetaProvider from '../FlowMeta/FlowMetaProvider';\nimport I18nProvider from '../I18n/I18nProvider';\nimport ThemeProvider from '../Theme/ThemeProvider';\nimport UserProvider from '../User/UserProvider';\n\nconst logger: ReturnType<typeof createPackageComponentLogger> = createPackageComponentLogger(\n '@thunderid/react',\n 'ThunderIDProvider',\n);\n\n/**\n * Props interface of {@link ThunderIDProvider}\n */\nexport type ThunderIDProviderProps = ThunderIDReactConfig;\n\nconst ThunderIDProvider: FC<PropsWithChildren<ThunderIDProviderProps>> = ({\n afterSignInUrl,\n afterSignOutUrl,\n baseUrl: initialBaseUrl,\n clientId,\n children,\n extensions,\n scopes,\n preferences,\n signInUrl,\n signUpUrl,\n organizationHandle,\n applicationId,\n signInOptions,\n tokenRequest,\n syncSession,\n instanceId = 0,\n organizationChain,\n ...rest\n}: PropsWithChildren<ThunderIDProviderProps>): ReactElement => {\n const reRenderCheckRef: RefObject<boolean> = useRef(false);\n const client: ThunderIDReactClient = useMemo(() => new ThunderIDReactClient(instanceId), [instanceId]);\n const storageManagerRef: any = useRef<any>(null);\n const {hasAuthParams, hasCalledForThisInstance} = useBrowserUrl();\n const [user, setUser] = useState<any | null>(null);\n const [isSignedInSync, setIsSignedInSync] = useState<boolean>(false);\n const [isInitializedSync, setIsInitializedSync] = useState<boolean>(false);\n const [isLoadingSync, setIsLoadingSync] = useState<boolean>(true);\n\n const [userProfile, setUserProfile] = useState<UserProfile | null>(null);\n const [baseUrl, setBaseUrl] = useState<string>(initialBaseUrl ?? '');\n const [config, setConfig] = useState<ThunderIDReactConfig>({\n afterSignInUrl: afterSignInUrl ?? window.location.origin,\n afterSignOutUrl: afterSignOutUrl ?? window.location.origin,\n applicationId,\n baseUrl,\n clientId,\n organizationChain,\n organizationHandle,\n scopes,\n signInOptions,\n tokenRequest,\n signInUrl,\n signUpUrl,\n syncSession,\n ...rest,\n });\n\n const [isUpdatingSession, setIsUpdatingSession] = useState<boolean>(false);\n const [wellKnown, setWellKnown] = useState<OIDCDiscoveryApiResponse | null>(null);\n\n useEffect(() => {\n setBaseUrl(initialBaseUrl ?? '');\n }, [initialBaseUrl]);\n\n useEffect(() => {\n (async (): Promise<void> => {\n await client.initialize(config);\n const initializedConfig: ThunderIDReactConfig = await client.getConfiguration();\n setConfig(initializedConfig);\n setWellKnown(await client.getDiscoveryResponse());\n })();\n }, []);\n\n async function updateSession(): Promise<void> {\n try {\n // Set flag to prevent loading state tracking from interfering\n setIsUpdatingSession(true);\n setIsLoadingSync(true);\n let resolvedBaseUrl: string = baseUrl;\n\n const decodedToken: IdToken = await client.getDecodedIdToken();\n\n // If there's a `user_org` claim in the ID token,\n // Treat this login as a organization login.\n if (decodedToken?.['user_org']) {\n resolvedBaseUrl = `${(await client.getConfiguration()).baseUrl}/o`;\n setBaseUrl(resolvedBaseUrl);\n }\n\n // TEMPORARY: SCIM2 and Organizations endpoints are not yet supported.\n const claims: User = extractUserClaimsFromIdToken(decodedToken) as User;\n setUser(claims);\n setUserProfile({\n flattenedProfile: claims,\n profile: claims,\n schemas: [],\n });\n\n // CRITICAL: Update sign-in status BEFORE setting loading to false\n // This prevents the race condition where ProtectedRoute sees isLoading=false but isSignedIn=false\n const currentSignInStatus: boolean = await client.isSignedIn();\n setIsSignedInSync(currentSignInStatus);\n } catch (error) {\n // TODO: Add an error log.\n } finally {\n // Clear the flag and set final loading state\n setIsUpdatingSession(false);\n setIsLoadingSync(client.isLoading());\n }\n }\n\n async function signIn(...args: any): Promise<User | EmbeddedSignInFlowResponse> {\n // Check if this is a V2 embedded flow request BEFORE calling signIn\n // This allows us to skip session checks entirely for V2 flows\n const arg1: any = args[0];\n const isV2FlowRequest: boolean =\n typeof arg1 === 'object' && arg1 !== null && ('executionId' in arg1 || 'applicationId' in arg1);\n\n try {\n if (!isV2FlowRequest) {\n setIsUpdatingSession(true);\n setIsLoadingSync(true);\n }\n\n return await client.signIn(...args);\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,\n 'thunderid-signIn-Error',\n 'react',\n 'An error occurred while trying to sign in.',\n );\n } finally {\n if (!isV2FlowRequest) {\n setIsUpdatingSession(false);\n setIsLoadingSync(client.isLoading());\n }\n }\n }\n\n /**\n * Try signing in when the component is mounted.\n */\n useEffect(() => {\n // React 18.x Strict.Mode has a new check for `Ensuring reusable state` to facilitate an upcoming react feature.\n // https://reactjs.org/docs/strict-mode.html#ensuring-reusable-state\n // This will remount all the useEffects to ensure that there are no unexpected side effects.\n // When react remounts the signIn hook of the AuthProvider, it will cause a race condition. Hence, we have to\n // prevent the re-render of this hook as suggested in the following discussion.\n // https://github.com/reactwg/react-18/discussions/18#discussioncomment-795623\n if (reRenderCheckRef.current) {\n return;\n }\n\n reRenderCheckRef.current = true;\n\n (async (): Promise<void> => {\n // Sync session state whenever sign-in completes (both redirect and embedded V2 flows).\n // Pass the user returned by the SDK's sign-in flow so SCIM2/Me result is not discarded.\n await client.on('sign-in', async () => {\n await updateSession();\n });\n\n // User is already authenticated. Skip...\n const isAlreadySignedIn: boolean = await client.isSignedIn();\n\n // Start auto-refresh with a soft failure.\n const scheduleAutoRefresh = async (): Promise<void> => {\n try {\n await client.startAutoRefreshToken();\n } catch (error) {\n logger.warn('Failed to schedule automatic token refresh.', error);\n }\n };\n\n // Restore session state and kick off the refresh timer.\n const resumeSession = async (): Promise<void> => {\n await updateSession();\n await scheduleAutoRefresh();\n };\n\n if (isAlreadySignedIn) {\n await resumeSession();\n }\n\n // The access token may have expired while the refresh token is still valid.\n // Attempt a silent refresh — startAutoRefreshToken() calls refreshAccessToken()\n // immediately when timeUntilRefresh <= 0, then re-check sign-in status.\n await scheduleAutoRefresh();\n\n if (await client.isSignedIn()) {\n await resumeSession();\n return;\n }\n\n const currentUrl: URL = new URL(window.location.href);\n const hasAuthParamsResult: boolean =\n hasAuthParams(currentUrl, config.afterSignInUrl!) && hasCalledForThisInstance(currentUrl, instanceId ?? 0);\n\n if (hasAuthParamsResult) {\n try {\n const urlParams: URLSearchParams = currentUrl.searchParams;\n const code: string | null = urlParams.get('code');\n const executionIdFromUrl: string | null = urlParams.get('executionId');\n const storedExecutionId: string | null = sessionStorage.getItem(\n `${getVendorPrefix(config.vendor)}_execution_id`,\n );\n\n if (code && !executionIdFromUrl && !storedExecutionId) {\n await signIn();\n }\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,\n 'thunderid-signIn-Error',\n 'react',\n 'An error occurred while trying to sign in.',\n );\n }\n }\n })();\n }, []);\n\n /**\n * Check if the user is signed in and update the state accordingly.\n * This will also set an interval to check for the sign-in status every second\n * until the user is signed in.\n */\n useEffect(() => {\n let interval: NodeJS.Timeout;\n\n (async (): Promise<void> => {\n try {\n const status: boolean = await client.isSignedIn();\n\n setIsSignedInSync(status);\n\n if (!status) {\n interval = setInterval(async () => {\n const newStatus: boolean = await client.isSignedIn();\n\n if (newStatus) {\n setIsSignedInSync(true);\n clearInterval(interval);\n }\n }, 1000);\n } else {\n // TODO: Add a debug log to indicate that the user is already signed in.\n }\n } catch (error) {\n setIsSignedInSync(false);\n }\n })();\n\n return (): void => {\n if (interval) {\n clearInterval(interval);\n }\n };\n }, [client]);\n\n useEffect(() => {\n (async (): Promise<void> => {\n try {\n const status: boolean = await client.isInitialized();\n\n setIsInitializedSync(status);\n } catch (error) {\n setIsInitializedSync(false);\n }\n })();\n }, [client]);\n\n /**\n * Track loading state changes from the ThunderID client\n */\n useEffect(() => {\n const checkLoadingState = (): void => {\n // Don't override loading state during critical session updates\n if (isUpdatingSession) {\n return;\n }\n\n // Don't set loading=false while auth params are in the URL and user isn't signed in yet.\n // This prevents ProtectedRoute from redirecting before the sign-in effect processes the auth code.\n const currentUrl: URL = new URL(window.location.href);\n if (!isSignedInSync && hasAuthParams(currentUrl, config.afterSignInUrl!)) {\n return;\n }\n\n setIsLoadingSync(client.isLoading());\n };\n\n // Initial check\n checkLoadingState();\n\n // Set up an interval to check for loading state changes\n const interval: NodeJS.Timeout = setInterval(checkLoadingState, 100);\n\n return (): void => {\n clearInterval(interval);\n };\n }, [client, isLoadingSync, isSignedInSync, isUpdatingSession]);\n\n const signInSilently = async (options?: SignInOptions): Promise<User | boolean> => {\n try {\n setIsUpdatingSession(true);\n setIsLoadingSync(true);\n return await client.signInSilently(options);\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Error while signing in silently: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,\n 'thunderid-signInSilently-Error',\n 'react',\n 'An error occurred while trying to sign in silently.',\n );\n } finally {\n setIsUpdatingSession(false);\n setIsLoadingSync(client.isLoading());\n }\n };\n\n const handleProfileUpdate = (payload: User): void => {\n setUser(payload);\n setUserProfile((prev: UserProfile | null) => ({\n schemas: prev?.schemas ?? [],\n flattenedProfile: generateFlattenedUserProfile(payload, prev?.schemas ?? []),\n profile: payload,\n }));\n };\n\n const getDecodedIdToken: () => Promise<IdToken> = useCallback(\n async (): Promise<IdToken> => client.getDecodedIdToken(),\n [client],\n );\n\n const getIdToken: () => Promise<string> = useCallback(async (): Promise<string> => client.getIdToken(), [client]);\n\n const getAccessToken: () => Promise<string> = useCallback(\n async (): Promise<string> => client.getAccessToken(),\n [client],\n );\n\n const getStorageManager: () => Promise<any> = useCallback(async (): Promise<any> => {\n const storageManager: any = storageManagerRef.current ?? (await client.getStorageManager());\n if (storageManager) {\n storageManagerRef.current = storageManager;\n }\n return storageManager;\n }, [client]);\n\n const request: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.request(...args),\n [client],\n );\n\n const requestAll: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.requestAll(...args),\n [client],\n );\n\n const exchangeToken: (exchangeConfig: any) => Promise<any> = useCallback(\n async (exchangeConfig: any): Promise<any> => client.exchangeToken(exchangeConfig),\n [client],\n );\n\n const signOut: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.signOut(...args),\n [client],\n );\n\n const recover: (payload: any) => Promise<any> = useCallback(\n async (payload: any): Promise<any> => client.recover(payload),\n [client],\n );\n\n const signUp: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.signUp(...args),\n [client],\n );\n\n const clearSession: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.clearSession(...args),\n [client],\n );\n\n const reInitialize: (reInitConfig: any) => Promise<any> = useCallback(\n async (reInitConfig: any): Promise<any> => client.reInitialize(reInitConfig),\n [client],\n );\n\n const value: any = useMemo(\n () => ({\n afterSignInUrl: config.afterSignInUrl,\n applicationId: config.applicationId,\n baseUrl,\n scopes: config.scopes,\n clearSession,\n clientId,\n discovery: {\n wellKnown,\n },\n exchangeToken,\n getAccessToken,\n getDecodedIdToken,\n getIdToken,\n getStorageManager,\n http: {\n request,\n requestAll,\n },\n instanceId,\n isInitialized: isInitializedSync,\n isLoading: isLoadingSync,\n isSignedIn: isSignedInSync,\n organizationChain,\n organizationHandle: config?.organizationHandle,\n reInitialize,\n recover,\n signIn,\n signInOptions,\n tokenRequest,\n signInSilently,\n signInUrl,\n signOut,\n signUp,\n signUpUrl,\n syncSession,\n user,\n vendor: getVendorPrefix(config.vendor),\n }),\n [\n applicationId,\n config?.organizationHandle,\n config.vendor,\n config.afterSignInUrl,\n config.scopes,\n signInUrl,\n signUpUrl,\n baseUrl,\n clientId,\n wellKnown,\n isInitializedSync,\n isLoadingSync,\n isSignedInSync,\n signIn,\n signInSilently,\n user,\n client,\n signInOptions,\n tokenRequest,\n syncSession,\n getDecodedIdToken,\n clearSession,\n exchangeToken,\n getAccessToken,\n getStorageManager,\n instanceId,\n organizationChain,\n recover,\n reInitialize,\n request,\n requestAll,\n signOut,\n signUp,\n ],\n );\n\n return (\n <ThunderIDContext.Provider value={value}>\n <I18nProvider preferences={preferences?.i18n} vendor={getVendorPrefix(config.vendor)}>\n <FlowMetaProvider enabled={preferences?.resolveFromMeta !== false}>\n <ThemeProvider\n theme={{\n ...preferences?.theme?.overrides,\n direction: preferences?.theme?.direction,\n }}\n >\n <FlowProvider>\n <UserProvider profile={userProfile!} onUpdateProfile={handleProfileUpdate}>\n <ComponentRendererProvider renderers={(extensions?.components?.renderers ?? {}) as any}>\n {children}\n </ComponentRendererProvider>\n </UserProvider>\n </FlowProvider>\n </ThemeProvider>\n </FlowMetaProvider>\n </I18nProvider>\n </ThunderIDContext.Provider>\n );\n};\n\nexport default ThunderIDProvider;\n"],"mappings":";;;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AAiB;gBACpD,2CAACC;OAA0B,WAAY,YAAY,YAAY,aAAa,EAAE;OAC3E;QACyB;OACf,GACF;MACD;KACC;IACN;GACW;;AAIhC,gCAAe"}
|
|
1
|
+
{"version":3,"file":"ThunderIDProvider.cjs","names":["logger: ReturnType<typeof createPackageComponentLogger>","ThunderIDProvider: FC<PropsWithChildren<ThunderIDProviderProps>>","reRenderCheckRef: RefObject<boolean>","client: ThunderIDReactClient","ThunderIDReactClient","storageManagerRef: any","useBrowserUrl","resolvedBaseUrl: string","decodedToken: IdToken","shouldFetchProfile: boolean","claims: User","currentSignInStatus: boolean","getUsersMe","arg1: any","isV2FlowRequest: boolean","ThunderIDRuntimeError","isAlreadySignedIn: boolean","currentUrl: URL","urlParams: URLSearchParams","code: string | null","executionIdFromUrl: string | null","storedExecutionId: string | null","interval: NodeJS.Timeout","status: boolean","getDecodedIdToken: () => Promise<IdToken>","getIdToken: () => Promise<string>","getAccessToken: () => Promise<string>","getStorageManager: () => Promise<any>","storageManager: any","request: (...args: any[]) => Promise<any>","requestAll: (...args: any[]) => Promise<any>","exchangeToken: (exchangeConfig: any) => Promise<any>","signOut: (...args: any[]) => Promise<any>","recover: (payload: any) => Promise<any>","signUp: (...args: any[]) => Promise<any>","clearSession: (...args: any[]) => Promise<any>","reInitialize: (reInitConfig: any) => Promise<any>","value: any","ThunderIDContext","I18nProvider","FlowMetaProvider","ThemeProvider","FlowProvider","UserProvider","ComponentRendererProvider"],"sources":["../../../../src/contexts/ThunderID/ThunderIDProvider.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025-2026, 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 ThunderIDRuntimeError,\n generateFlattenedUserProfile,\n OIDCDiscoveryApiResponse,\n SignInOptions,\n User,\n UserProfile,\n IdToken,\n extractUserClaimsFromIdToken,\n EmbeddedSignInFlowResponse,\n createPackageComponentLogger,\n getVendorPrefix,\n} from '@thunderid/browser';\nimport {FC, RefObject, PropsWithChildren, ReactElement, useEffect, useMemo, useRef, useState, useCallback} from 'react';\nimport ThunderIDContext from './ThunderIDContext';\nimport useBrowserUrl from '../../hooks/useBrowserUrl';\nimport {ThunderIDReactConfig} from '../../models/config';\nimport ThunderIDReactClient from '../../ThunderIDReactClient';\nimport ComponentRendererProvider from '../ComponentRenderer/ComponentRendererProvider';\nimport FlowProvider from '../Flow/FlowProvider';\nimport FlowMetaProvider from '../FlowMeta/FlowMetaProvider';\nimport I18nProvider from '../I18n/I18nProvider';\nimport ThemeProvider from '../Theme/ThemeProvider';\nimport UserProvider from '../User/UserProvider';\nimport getUsersMe from '../../api/getUsersMe';\n\nconst logger: ReturnType<typeof createPackageComponentLogger> = createPackageComponentLogger(\n '@thunderid/react',\n 'ThunderIDProvider',\n);\n\n/**\n * Props interface of {@link ThunderIDProvider}\n */\nexport type ThunderIDProviderProps = ThunderIDReactConfig;\n\nconst ThunderIDProvider: FC<PropsWithChildren<ThunderIDProviderProps>> = ({\n afterSignInUrl,\n afterSignOutUrl,\n baseUrl: initialBaseUrl,\n clientId,\n children,\n extensions,\n scopes,\n preferences,\n signInUrl,\n signUpUrl,\n organizationHandle,\n applicationId,\n signInOptions,\n tokenRequest,\n syncSession,\n instanceId = 0,\n organizationChain,\n ...rest\n}: PropsWithChildren<ThunderIDProviderProps>): ReactElement => {\n const reRenderCheckRef: RefObject<boolean> = useRef(false);\n const client: ThunderIDReactClient = useMemo(() => new ThunderIDReactClient(instanceId), [instanceId]);\n const storageManagerRef: any = useRef<any>(null);\n const {hasAuthParams, hasCalledForThisInstance} = useBrowserUrl();\n const [user, setUser] = useState<any | null>(null);\n const [isSignedInSync, setIsSignedInSync] = useState<boolean>(false);\n const [isInitializedSync, setIsInitializedSync] = useState<boolean>(false);\n const [isLoadingSync, setIsLoadingSync] = useState<boolean>(true);\n\n const [userProfile, setUserProfile] = useState<UserProfile | null>(null);\n const [baseUrl, setBaseUrl] = useState<string>(initialBaseUrl ?? '');\n const [config, setConfig] = useState<ThunderIDReactConfig>({\n afterSignInUrl: afterSignInUrl ?? window.location.origin,\n afterSignOutUrl: afterSignOutUrl ?? window.location.origin,\n applicationId,\n baseUrl,\n clientId,\n organizationChain,\n organizationHandle,\n scopes,\n signInOptions,\n tokenRequest,\n signInUrl,\n signUpUrl,\n syncSession,\n ...rest,\n });\n\n const [isUpdatingSession, setIsUpdatingSession] = useState<boolean>(false);\n const [wellKnown, setWellKnown] = useState<OIDCDiscoveryApiResponse | null>(null);\n\n useEffect(() => {\n setBaseUrl(initialBaseUrl ?? '');\n }, [initialBaseUrl]);\n\n useEffect(() => {\n (async (): Promise<void> => {\n await client.initialize(config);\n const initializedConfig: ThunderIDReactConfig = await client.getConfiguration();\n setConfig(initializedConfig);\n setWellKnown(await client.getDiscoveryResponse());\n })();\n }, []);\n\n async function updateSession(): Promise<void> {\n try {\n // Set flag to prevent loading state tracking from interfering\n setIsUpdatingSession(true);\n setIsLoadingSync(true);\n let resolvedBaseUrl: string = baseUrl;\n\n const decodedToken: IdToken = await client.getDecodedIdToken();\n\n // If there's a `user_org` claim in the ID token,\n // Treat this login as a organization login.\n if (decodedToken?.['user_org']) {\n resolvedBaseUrl = `${(await client.getConfiguration()).baseUrl}/o`;\n setBaseUrl(resolvedBaseUrl);\n }\n\n const shouldFetchProfile: boolean = preferences?.user?.fetchUserProfile !== false;\n const claims: User = extractUserClaimsFromIdToken(decodedToken) as User;\n let profileData = claims;\n const currentSignInStatus: boolean = await client.isSignedIn();\n\n if (currentSignInStatus && shouldFetchProfile) {\n try {\n const fetchedProfile = await getUsersMe({baseUrl: resolvedBaseUrl, instanceId});\n profileData = {...claims, ...fetchedProfile};\n } catch (err) {\n logger.warn('Failed to fetch user profile from /users/me:', err);\n }\n }\n\n setUser(profileData);\n setUserProfile({\n flattenedProfile: generateFlattenedUserProfile(profileData, []),\n profile: profileData,\n });\n\n // CRITICAL: Update sign-in status BEFORE setting loading to false\n // This prevents the race condition where ProtectedRoute sees isLoading=false but isSignedIn=false\n setIsSignedInSync(currentSignInStatus);\n } catch (error) {\n // TODO: Add an error log.\n } finally {\n // Clear the flag and set final loading state\n setIsUpdatingSession(false);\n setIsLoadingSync(client.isLoading());\n }\n }\n\n async function signIn(...args: any): Promise<User | EmbeddedSignInFlowResponse> {\n // Check if this is a V2 embedded flow request BEFORE calling signIn\n // This allows us to skip session checks entirely for V2 flows\n const arg1: any = args[0];\n const isV2FlowRequest: boolean =\n typeof arg1 === 'object' && arg1 !== null && ('executionId' in arg1 || 'applicationId' in arg1);\n\n try {\n if (!isV2FlowRequest) {\n setIsUpdatingSession(true);\n setIsLoadingSync(true);\n }\n\n return await client.signIn(...args);\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,\n 'thunderid-signIn-Error',\n 'react',\n 'An error occurred while trying to sign in.',\n );\n } finally {\n if (!isV2FlowRequest) {\n setIsUpdatingSession(false);\n setIsLoadingSync(client.isLoading());\n }\n }\n }\n\n /**\n * Try signing in when the component is mounted.\n */\n useEffect(() => {\n // React 18.x Strict.Mode has a new check for `Ensuring reusable state` to facilitate an upcoming react feature.\n // https://reactjs.org/docs/strict-mode.html#ensuring-reusable-state\n // This will remount all the useEffects to ensure that there are no unexpected side effects.\n // When react remounts the signIn hook of the AuthProvider, it will cause a race condition. Hence, we have to\n // prevent the re-render of this hook as suggested in the following discussion.\n // https://github.com/reactwg/react-18/discussions/18#discussioncomment-795623\n if (reRenderCheckRef.current) {\n return;\n }\n\n reRenderCheckRef.current = true;\n\n (async (): Promise<void> => {\n // Sync session state whenever sign-in completes (both redirect and embedded V2 flows).\n // Pass the user returned by the SDK's sign-in flow so users/me result is not discarded.\n await client.on('sign-in', async () => {\n await updateSession();\n });\n\n // User is already authenticated. Skip...\n const isAlreadySignedIn: boolean = await client.isSignedIn();\n\n // Start auto-refresh with a soft failure.\n const scheduleAutoRefresh = async (): Promise<void> => {\n try {\n await client.startAutoRefreshToken();\n } catch (error) {\n logger.warn('Failed to schedule automatic token refresh.', error);\n }\n };\n\n // Restore session state and kick off the refresh timer.\n const resumeSession = async (): Promise<void> => {\n await updateSession();\n await scheduleAutoRefresh();\n };\n\n if (isAlreadySignedIn) {\n await resumeSession();\n }\n\n // The access token may have expired while the refresh token is still valid.\n // Attempt a silent refresh — startAutoRefreshToken() calls refreshAccessToken()\n // immediately when timeUntilRefresh <= 0, then re-check sign-in status.\n await scheduleAutoRefresh();\n\n if (await client.isSignedIn()) {\n await resumeSession();\n return;\n }\n\n const currentUrl: URL = new URL(window.location.href);\n const hasAuthParamsResult: boolean =\n hasAuthParams(currentUrl, config.afterSignInUrl!) && hasCalledForThisInstance(currentUrl, instanceId ?? 0);\n\n if (hasAuthParamsResult) {\n try {\n const urlParams: URLSearchParams = currentUrl.searchParams;\n const code: string | null = urlParams.get('code');\n const executionIdFromUrl: string | null = urlParams.get('executionId');\n const storedExecutionId: string | null = sessionStorage.getItem(\n `${getVendorPrefix(config.vendor)}_execution_id`,\n );\n\n if (code && !executionIdFromUrl && !storedExecutionId) {\n await signIn();\n }\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Sign in failed: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,\n 'thunderid-signIn-Error',\n 'react',\n 'An error occurred while trying to sign in.',\n );\n }\n }\n })();\n }, []);\n\n /**\n * Check if the user is signed in and update the state accordingly.\n * This will also set an interval to check for the sign-in status every second\n * until the user is signed in.\n */\n useEffect(() => {\n let interval: NodeJS.Timeout;\n\n (async (): Promise<void> => {\n try {\n const status: boolean = await client.isSignedIn();\n\n setIsSignedInSync(status);\n\n if (!status) {\n interval = setInterval(async () => {\n const newStatus: boolean = await client.isSignedIn();\n\n if (newStatus) {\n setIsSignedInSync(true);\n clearInterval(interval);\n }\n }, 1000);\n } else {\n // TODO: Add a debug log to indicate that the user is already signed in.\n }\n } catch (error) {\n setIsSignedInSync(false);\n }\n })();\n\n return (): void => {\n if (interval) {\n clearInterval(interval);\n }\n };\n }, [client]);\n\n useEffect(() => {\n (async (): Promise<void> => {\n try {\n const status: boolean = await client.isInitialized();\n\n setIsInitializedSync(status);\n } catch (error) {\n setIsInitializedSync(false);\n }\n })();\n }, [client]);\n\n /**\n * Track loading state changes from the ThunderID client\n */\n useEffect(() => {\n const checkLoadingState = (): void => {\n // Don't override loading state during critical session updates\n if (isUpdatingSession) {\n return;\n }\n\n // Don't set loading=false while auth params are in the URL and user isn't signed in yet.\n // This prevents ProtectedRoute from redirecting before the sign-in effect processes the auth code.\n const currentUrl: URL = new URL(window.location.href);\n if (!isSignedInSync && hasAuthParams(currentUrl, config.afterSignInUrl!)) {\n return;\n }\n\n setIsLoadingSync(client.isLoading());\n };\n\n // Initial check\n checkLoadingState();\n\n // Set up an interval to check for loading state changes\n const interval: NodeJS.Timeout = setInterval(checkLoadingState, 100);\n\n return (): void => {\n clearInterval(interval);\n };\n }, [client, isLoadingSync, isSignedInSync, isUpdatingSession]);\n\n const signInSilently = async (options?: SignInOptions): Promise<User | boolean> => {\n try {\n setIsUpdatingSession(true);\n setIsLoadingSync(true);\n return await client.signInSilently(options);\n } catch (error) {\n throw new ThunderIDRuntimeError(\n `Error while signing in silently: ${error instanceof Error ? error.message : String(JSON.stringify(error))}`,\n 'thunderid-signInSilently-Error',\n 'react',\n 'An error occurred while trying to sign in silently.',\n );\n } finally {\n setIsUpdatingSession(false);\n setIsLoadingSync(client.isLoading());\n }\n };\n\n const handleProfileUpdate = (payload: User): void => {\n setUser(payload);\n setUserProfile((prev: UserProfile | null) => ({\n flattenedProfile: generateFlattenedUserProfile(payload),\n profile: payload,\n }));\n };\n\n const getDecodedIdToken: () => Promise<IdToken> = useCallback(\n async (): Promise<IdToken> => client.getDecodedIdToken(),\n [client],\n );\n\n const getIdToken: () => Promise<string> = useCallback(async (): Promise<string> => client.getIdToken(), [client]);\n\n const getAccessToken: () => Promise<string> = useCallback(\n async (): Promise<string> => client.getAccessToken(),\n [client],\n );\n\n const getStorageManager: () => Promise<any> = useCallback(async (): Promise<any> => {\n const storageManager: any = storageManagerRef.current ?? (await client.getStorageManager());\n if (storageManager) {\n storageManagerRef.current = storageManager;\n }\n return storageManager;\n }, [client]);\n\n const request: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.request(...args),\n [client],\n );\n\n const requestAll: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.requestAll(...args),\n [client],\n );\n\n const exchangeToken: (exchangeConfig: any) => Promise<any> = useCallback(\n async (exchangeConfig: any): Promise<any> => client.exchangeToken(exchangeConfig),\n [client],\n );\n\n const signOut: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.signOut(...args),\n [client],\n );\n\n const recover: (payload: any) => Promise<any> = useCallback(\n async (payload: any): Promise<any> => client.recover(payload),\n [client],\n );\n\n const signUp: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.signUp(...args),\n [client],\n );\n\n const clearSession: (...args: any[]) => Promise<any> = useCallback(\n async (...args: any[]): Promise<any> => client.clearSession(...args),\n [client],\n );\n\n const reInitialize: (reInitConfig: any) => Promise<any> = useCallback(\n async (reInitConfig: any): Promise<any> => client.reInitialize(reInitConfig),\n [client],\n );\n\n const value: any = useMemo(\n () => ({\n afterSignInUrl: config.afterSignInUrl,\n applicationId: config.applicationId,\n baseUrl,\n scopes: config.scopes,\n clearSession,\n clientId,\n discovery: {\n wellKnown,\n },\n exchangeToken,\n getAccessToken,\n getDecodedIdToken,\n getIdToken,\n getStorageManager,\n http: {\n request,\n requestAll,\n },\n instanceId,\n isInitialized: isInitializedSync,\n isLoading: isLoadingSync,\n isSignedIn: isSignedInSync,\n organizationChain,\n organizationHandle: config?.organizationHandle,\n preferences,\n reInitialize,\n recover,\n signIn,\n signInOptions,\n tokenRequest,\n signInSilently,\n signInUrl,\n signOut,\n signUp,\n signUpUrl,\n syncSession,\n user,\n vendor: getVendorPrefix(config.vendor),\n }),\n [\n applicationId,\n config?.organizationHandle,\n config.vendor,\n config.afterSignInUrl,\n config.scopes,\n signInUrl,\n signUpUrl,\n baseUrl,\n clientId,\n wellKnown,\n isInitializedSync,\n isLoadingSync,\n isSignedInSync,\n signIn,\n signInSilently,\n user,\n client,\n signInOptions,\n tokenRequest,\n syncSession,\n getDecodedIdToken,\n clearSession,\n exchangeToken,\n getAccessToken,\n getStorageManager,\n instanceId,\n organizationChain,\n preferences,\n recover,\n reInitialize,\n request,\n requestAll,\n signOut,\n signUp,\n ],\n );\n\n return (\n <ThunderIDContext.Provider value={value}>\n <I18nProvider preferences={preferences?.i18n} vendor={getVendorPrefix(config.vendor)}>\n <FlowMetaProvider enabled={preferences?.resolveFromMeta !== false}>\n <ThemeProvider\n theme={{\n ...preferences?.theme?.overrides,\n direction: preferences?.theme?.direction,\n }}\n >\n <FlowProvider>\n <UserProvider profile={userProfile!} onUpdateProfile={handleProfileUpdate}>\n <ComponentRendererProvider renderers={(extensions?.components?.renderers ?? {}) as any}>\n {children}\n </ComponentRendererProvider>\n </UserProvider>\n </FlowProvider>\n </ThemeProvider>\n </FlowMetaProvider>\n </I18nProvider>\n </ThunderIDContext.Provider>\n );\n};\n\nexport default ThunderIDProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,+DACJ,oBACA,oBACD;AAOD,MAAMC,qBAAoE,EACxE,gBACA,iBACA,SAAS,gBACT,UACA,UACA,YACA,QACA,aACA,WACA,WACA,oBACA,eACA,eACA,cACA,aACA,aAAa,GACb,kBACA,GAAG,WAC0D;CAC7D,MAAMC,qCAA8C,MAAM;CAC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S;MAAc,iBAAiB;gBACpD,2CAACC;OAA0B,WAAY,YAAY,YAAY,aAAa,EAAE;OAC3E;QACyB;OACf,GACF;MACD;KACC;IACN;GACW;;AAIhC,gCAAe"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserContext.cjs","names":["UserContext: Context<UserContextProps | null>"],"sources":["../../../../src/contexts/User/UserContext.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 {User,
|
|
1
|
+
{"version":3,"file":"UserContext.cjs","names":["UserContext: Context<UserContextProps | null>"],"sources":["../../../../src/contexts/User/UserContext.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 {User, UpdateMeProfileConfig} from '@thunderid/browser';\nimport {Context, createContext} from 'react';\n\n/**\n * Props interface of {@link UserContext}\n */\nexport interface UserContextProps {\n flattenedProfile: User | null;\n onUpdateProfile: (payload: User) => void;\n profile: User | null;\n revalidateProfile: () => Promise<void>;\n updateProfile: (\n requestConfig: UpdateMeProfileConfig,\n sessionId?: string,\n ) => Promise<{data: {user: User}; error: string; success: boolean}>;\n}\n\n/**\n * Context object for managing user profile data and related operations.\n */\nconst UserContext: Context<UserContextProps | null> = createContext<null | UserContextProps>({\n flattenedProfile: null,\n onUpdateProfile: () => null,\n profile: null,\n revalidateProfile: () => null as unknown as Promise<void>,\n updateProfile: () => null as unknown as Promise<{data: {user: User}; error: string; success: boolean}>,\n});\n\nUserContext.displayName = 'UserContext';\n\nexport default UserContext;\n"],"mappings":";;;;;;;;AAsCA,MAAMA,uCAAuF;CAC3F,kBAAkB;CAClB,uBAAuB;CACvB,SAAS;CACT,yBAAyB;CACzB,qBAAqB;CACtB,CAAC;AAEF,YAAY,cAAc;AAE1B,0BAAe"}
|
|
@@ -11,7 +11,6 @@ react_jsx_runtime = require_rolldown_runtime.__toESM(react_jsx_runtime);
|
|
|
11
11
|
*
|
|
12
12
|
* This provider:
|
|
13
13
|
* - Fetches user profile data from the ME endpoint
|
|
14
|
-
* - Retrieves SCIM2 schemas for profile structure
|
|
15
14
|
* - Generates both nested and flattened user profiles
|
|
16
15
|
* - Provides functions for refreshing and updating user data
|
|
17
16
|
* - Handles loading states and errors
|
|
@@ -40,7 +39,6 @@ const UserProvider = ({ children, profile, revalidateProfile, onUpdateProfile, u
|
|
|
40
39
|
onUpdateProfile,
|
|
41
40
|
profile: profile?.profile,
|
|
42
41
|
revalidateProfile,
|
|
43
|
-
schemas: profile?.schemas,
|
|
44
42
|
updateProfile
|
|
45
43
|
}), [
|
|
46
44
|
profile,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProvider.cjs","names":["UserProvider: FC<PropsWithChildren<UserProviderProps>>","contextValue: any","UserContext"],"sources":["../../../../src/contexts/User/UserProvider.tsx"],"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 {UpdateMeProfileConfig, User, UserProfile} from '@thunderid/browser';\nimport {FC, PropsWithChildren, ReactElement, useMemo} from 'react';\nimport UserContext from './UserContext';\n\n/**\n * Props interface of {@link UserProvider}\n */\nexport interface UserProviderProps {\n onUpdateProfile?: (payload: User) => void;\n profile: UserProfile;\n revalidateProfile?: () => Promise<void>;\n updateProfile?: (\n requestConfig: UpdateMeProfileConfig,\n sessionId?: string,\n ) => Promise<{data: {user: User}; error: string; success: boolean}>;\n}\n\n/**\n * UserProvider component that manages user profile data and provides it through UserContext.\n *\n * This provider:\n * - Fetches user profile data from the ME endpoint\n * -
|
|
1
|
+
{"version":3,"file":"UserProvider.cjs","names":["UserProvider: FC<PropsWithChildren<UserProviderProps>>","contextValue: any","UserContext"],"sources":["../../../../src/contexts/User/UserProvider.tsx"],"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 {UpdateMeProfileConfig, User, UserProfile} from '@thunderid/browser';\nimport {FC, PropsWithChildren, ReactElement, useMemo} from 'react';\nimport UserContext from './UserContext';\n\n/**\n * Props interface of {@link UserProvider}\n */\nexport interface UserProviderProps {\n onUpdateProfile?: (payload: User) => void;\n profile: UserProfile;\n revalidateProfile?: () => Promise<void>;\n updateProfile?: (\n requestConfig: UpdateMeProfileConfig,\n sessionId?: string,\n ) => Promise<{data: {user: User}; error: string; success: boolean}>;\n}\n\n/**\n * UserProvider component that manages user profile data and provides it through UserContext.\n *\n * This provider:\n * - Fetches user profile data from the ME endpoint\n * - Generates both nested and flattened user profiles\n * - Provides functions for refreshing and updating user data\n * - Handles loading states and errors\n *\n * @example\n * ```tsx\n * // Basic usage\n * <UserProvider>\n * <App />\n * </UserProvider>\n *\n * // With custom error handling\n * <UserProvider onError={(error) => console.error('User error:', error)}>\n * <App />\n * </UserProvider>\n *\n * // Disable auto-fetch (fetch manually using refreshUser)\n * <UserProvider autoFetch={false}>\n * <App />\n * </UserProvider>\n * ```\n */\nconst UserProvider: FC<PropsWithChildren<UserProviderProps>> = ({\n children,\n profile,\n revalidateProfile,\n onUpdateProfile,\n updateProfile,\n}: PropsWithChildren<UserProviderProps>): ReactElement => {\n const contextValue: any = useMemo(\n () => ({\n flattenedProfile: profile?.flattenedProfile,\n onUpdateProfile,\n profile: profile?.profile,\n revalidateProfile,\n updateProfile,\n }),\n [profile, onUpdateProfile, revalidateProfile, updateProfile],\n );\n\n return <UserContext.Provider value={contextValue}>{children}</UserContext.Provider>;\n};\n\nexport default UserProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,MAAMA,gBAA0D,EAC9D,UACA,SACA,mBACA,iBACA,oBACwD;CACxD,MAAMC,yCACG;EACL,kBAAkB,SAAS;EAC3B;EACA,SAAS,SAAS;EAClB;EACA;EACD,GACD;EAAC;EAAS;EAAiB;EAAmB;EAAc,CAC7D;AAED,QAAO,2CAACC,4BAAY;EAAS,OAAO;EAAe;GAAgC;;AAGrF,2BAAe"}
|
|
@@ -9,7 +9,6 @@ react = require_rolldown_runtime.__toESM(react);
|
|
|
9
9
|
*
|
|
10
10
|
* This hook provides access to user profile data including:
|
|
11
11
|
* - Raw profile API response
|
|
12
|
-
* - SCIM2 schemas
|
|
13
12
|
* - Nested user object
|
|
14
13
|
* - Flattened user profile
|
|
15
14
|
* - Functions to refresh and update user data
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUser.cjs","names":["context: UserContextProps | null","UserContext"],"sources":["../../../../src/contexts/User/useUser.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 {useContext} from 'react';\nimport UserContext, {UserContextProps} from './UserContext';\n\n/**\n * Hook to access the User context.\n *\n * This hook provides access to user profile data including:\n * - Raw profile API response\n * -
|
|
1
|
+
{"version":3,"file":"useUser.cjs","names":["context: UserContextProps | null","UserContext"],"sources":["../../../../src/contexts/User/useUser.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 {useContext} from 'react';\nimport UserContext, {UserContextProps} from './UserContext';\n\n/**\n * Hook to access the User context.\n *\n * This hook provides access to user profile data including:\n * - Raw profile API response\n * - Nested user object\n * - Flattened user profile\n * - Functions to refresh and update user data\n * - Loading states and error handling\n *\n * @returns {UserContextProps} The user context value containing all user-related data and functions\n * @throws {Error} Throws an error if used outside of UserProvider\n *\n * @example\n * ```tsx\n * import {useUser} from '@thunderid/react';\n *\n * function ProfileComponent() {\n * const {\n * isLoading,\n * profile,\n * schemas,\n * user,\n * flattenedUser,\n * refreshUser,\n * updateUser,\n * error\n * } = useUser();\n *\n * if (isLoading) {\n * return <div>Loading user data...</div>;\n * }\n *\n * if (error) {\n * return <div>Error: {error.message}</div>;\n * }\n *\n * return (\n * <div>\n * <h1>Welcome {user?.name?.givenName}!</h1>\n * <p>Email: {flattenedUser?.emails}</p>\n * <button onClick={refreshUser}>Refresh Profile</button>\n * </div>\n * );\n * }\n *\n * // Access specific user properties\n * function UserEmail() {\n * const {flattenedUser} = useUser();\n * return <span>{flattenedUser?.emails?.[0]}</span>;\n * }\n *\n * // Update user profile\n * function EditProfile() {\n * const {updateUser, user} = useUser();\n *\n * const handleUpdate = async () => {\n * try {\n * await updateUser({\n * name: {\n * givenName: 'John',\n * familyName: 'Doe'\n * }\n * });\n * } catch (error) {\n * console.error('Update failed:', error);\n * }\n * };\n *\n * return <button onClick={handleUpdate}>Update Name</button>;\n * }\n * ```\n */\nconst useUser = (): UserContextProps => {\n const context: UserContextProps | null = useContext(UserContext);\n\n if (!context) {\n throw new Error('useUser must be used within a UserProvider');\n }\n\n return context;\n};\n\nexport default useUser;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8FA,MAAM,gBAAkC;CACtC,MAAMA,gCAA8CC,4BAAY;AAEhE,KAAI,CAAC,QACH,OAAM,IAAI,MAAM,6CAA6C;AAG/D,QAAO;;AAGT,sBAAe"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -12,6 +12,7 @@ const require_ThemeContext = require('./contexts/Theme/ThemeContext.cjs');
|
|
|
12
12
|
const require_ThemeProvider = require('./contexts/Theme/ThemeProvider.cjs');
|
|
13
13
|
const require_UserContext = require('./contexts/User/UserContext.cjs');
|
|
14
14
|
const require_UserProvider = require('./contexts/User/UserProvider.cjs');
|
|
15
|
+
const require_getUsersMe = require('./api/getUsersMe.cjs');
|
|
15
16
|
const require_ThunderIDProvider = require('./contexts/ThunderID/ThunderIDProvider.cjs');
|
|
16
17
|
const require_useUser = require('./contexts/User/useUser.cjs');
|
|
17
18
|
const require_useFlow = require('./contexts/Flow/useFlow.cjs');
|
|
@@ -90,7 +91,6 @@ const require_BaseLanguageSwitcher = require('./components/presentation/Language
|
|
|
90
91
|
const require_LanguageSwitcher = require('./components/presentation/LanguageSwitcher/LanguageSwitcher.cjs');
|
|
91
92
|
const require_KeyValueInput = require('./components/primitives/KeyValueInput/KeyValueInput.cjs');
|
|
92
93
|
const require_BuildingAlt = require('./components/primitives/Icons/BuildingAlt.cjs');
|
|
93
|
-
const require_getScim2Me = require('./api/getScim2Me.cjs');
|
|
94
94
|
let __thunderid_browser = require("@thunderid/browser");
|
|
95
95
|
__thunderid_browser = require_rolldown_runtime.__toESM(__thunderid_browser);
|
|
96
96
|
|
|
@@ -267,7 +267,7 @@ Object.defineProperty(exports, 'getActiveTheme', {
|
|
|
267
267
|
}
|
|
268
268
|
});
|
|
269
269
|
exports.getConsentOptionalKey = require_ConsentCheckboxList.getConsentOptionalKey;
|
|
270
|
-
exports.getMeProfile =
|
|
270
|
+
exports.getMeProfile = require_getUsersMe.default;
|
|
271
271
|
Object.defineProperty(exports, 'http', {
|
|
272
272
|
enumerable: true,
|
|
273
273
|
get: function () {
|
|
@@ -17,25 +17,6 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { User, Preferences } from '@thunderid/browser';
|
|
19
19
|
import { FC, ReactElement } from 'react';
|
|
20
|
-
interface ExtendedFlatSchema {
|
|
21
|
-
path?: string;
|
|
22
|
-
schemaId?: string;
|
|
23
|
-
}
|
|
24
|
-
interface Schema extends ExtendedFlatSchema {
|
|
25
|
-
caseExact?: boolean;
|
|
26
|
-
description?: string;
|
|
27
|
-
displayName?: string;
|
|
28
|
-
displayOrder?: string;
|
|
29
|
-
multiValued?: boolean;
|
|
30
|
-
mutability?: string;
|
|
31
|
-
name?: string;
|
|
32
|
-
required?: boolean;
|
|
33
|
-
returned?: string;
|
|
34
|
-
subAttributes?: Schema[];
|
|
35
|
-
type?: string;
|
|
36
|
-
uniqueness?: string;
|
|
37
|
-
value?: any;
|
|
38
|
-
}
|
|
39
20
|
export interface BaseUserProfileProps {
|
|
40
21
|
attributeMapping?: {
|
|
41
22
|
[key: string]: string | string[] | undefined;
|
|
@@ -64,7 +45,6 @@ export interface BaseUserProfileProps {
|
|
|
64
45
|
*/
|
|
65
46
|
preferences?: Preferences;
|
|
66
47
|
profile?: User;
|
|
67
|
-
schemas?: Schema[];
|
|
68
48
|
showFields?: string[];
|
|
69
49
|
title?: string;
|
|
70
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseUserProfile.d.ts","sourceRoot":"","sources":["../../../../src/components/presentation/UserProfile/BaseUserProfile.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"BaseUserProfile.d.ts","sourceRoot":"","sources":["../../../../src/components/presentation/UserProfile/BaseUserProfile.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAC,IAAI,EAAiC,WAAW,EAAY,MAAM,oBAAoB,CAAC;AAC/F,OAAO,EAAC,EAAE,EAAE,YAAY,EAAmC,MAAM,OAAO,CAAC;AAuCzE,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,CAAC,EAAE;QACjB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;QAC7C,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;KAC9B,CAAC;IACF,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC/B,gBAAgB,CAAC,EAAE,IAAI,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,IAAI,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA+BD,QAAA,MAAM,eAAe,EAAE,EAAE,CAAC,oBAAoB,CAwkB7C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -14,8 +14,8 @@ import getDisplayName_default from "../../../utils/getDisplayName.js";
|
|
|
14
14
|
import { Avatar } from "../../primitives/Avatar/Avatar.js";
|
|
15
15
|
import Dialog_default from "../../primitives/Dialog/Dialog.js";
|
|
16
16
|
import MultiInput_default from "../../primitives/MultiInput/MultiInput.js";
|
|
17
|
-
import {
|
|
18
|
-
import { useCallback, useState } from "react";
|
|
17
|
+
import { bem, startCase, withVendorCSSClassPrefix } from "@thunderid/browser";
|
|
18
|
+
import { useCallback, useEffect, useState } from "react";
|
|
19
19
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
20
|
import { cx } from "@emotion/css";
|
|
21
21
|
|
|
@@ -38,18 +38,40 @@ const fieldsToSkip = [
|
|
|
38
38
|
"verifiedEmailAddresses",
|
|
39
39
|
"phoneNumbers.mobile",
|
|
40
40
|
"emailAddresses",
|
|
41
|
-
"preferredMFAOption"
|
|
41
|
+
"preferredMFAOption",
|
|
42
|
+
"attributes",
|
|
43
|
+
"picture",
|
|
44
|
+
"isReadOnly",
|
|
45
|
+
"isReadonly"
|
|
42
46
|
];
|
|
43
47
|
const readonlyFields = [
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
48
|
+
"attributes",
|
|
49
|
+
"id",
|
|
50
|
+
"isReadOnly",
|
|
51
|
+
"ouId",
|
|
52
|
+
"username"
|
|
47
53
|
];
|
|
48
|
-
const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, profile,
|
|
54
|
+
const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, profile, flattenedProfile, mode = "inline", title, attributeMapping = {}, editable = true, onOpenChange, onUpdate, open = false, error = null, isLoading = false, preferences, showFields = [], hideFields = [], displayNameAttributes = [] }) => {
|
|
49
55
|
const { theme, colorScheme } = useTheme_default();
|
|
50
56
|
const [editedUser, setEditedUser] = useState(flattenedProfile || profile);
|
|
51
57
|
const [editingFields, setEditingFields] = useState({});
|
|
52
58
|
const { t } = useTranslation_default(preferences?.i18n);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const nextUser = flattenedProfile ?? profile;
|
|
61
|
+
if (!nextUser) return;
|
|
62
|
+
setEditedUser((prev) => {
|
|
63
|
+
if (!prev) return nextUser;
|
|
64
|
+
const updated = { ...nextUser };
|
|
65
|
+
Object.keys(prev).forEach((key) => {
|
|
66
|
+
if (editingFields[key]) updated[key] = prev[key];
|
|
67
|
+
});
|
|
68
|
+
return updated;
|
|
69
|
+
});
|
|
70
|
+
}, [
|
|
71
|
+
flattenedProfile,
|
|
72
|
+
profile,
|
|
73
|
+
editingFields
|
|
74
|
+
]);
|
|
53
75
|
/**
|
|
54
76
|
* Determines if a field should be visible based on showFields, hideFields, and fieldsToSkip arrays.
|
|
55
77
|
* Priority order:
|
|
@@ -127,8 +149,7 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
|
|
|
127
149
|
else fieldValue = "";
|
|
128
150
|
if (Array.isArray(fieldValue)) fieldValue = fieldValue.filter((v) => v !== void 0 && v !== null && v !== "");
|
|
129
151
|
let payload = {};
|
|
130
|
-
|
|
131
|
-
else set(payload, fieldName, fieldValue);
|
|
152
|
+
set(payload, fieldName, fieldValue);
|
|
132
153
|
onUpdate(payload);
|
|
133
154
|
toggleFieldEdit(fieldName);
|
|
134
155
|
}, [
|
|
@@ -169,7 +190,7 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
|
|
|
169
190
|
const renderSchemaField = (schema, isEditing, onEditValue, onStartEdit) => {
|
|
170
191
|
if (!schema) return null;
|
|
171
192
|
const { value, displayName, description, name, type, required, mutability, subAttributes, multiValued } = schema;
|
|
172
|
-
const label = displayName || description || name
|
|
193
|
+
const label = displayName || description || (name ? startCase(name) : "");
|
|
173
194
|
if (subAttributes && Array.isArray(subAttributes)) return /* @__PURE__ */ jsx(Fragment, { children: subAttributes.map((subAttr, index) => {
|
|
174
195
|
let displayValue$1;
|
|
175
196
|
if (Array.isArray(subAttr.value)) displayValue$1 = subAttr.value.map((item) => typeof item === "object" ? JSON.stringify(item) : String(item)).join(", ");
|
|
@@ -383,60 +404,29 @@ const BaseUserProfile = ({ fallback = null, className = "", cardLayout = true, p
|
|
|
383
404
|
]
|
|
384
405
|
}),
|
|
385
406
|
/* @__PURE__ */ jsx(Divider_default, {}),
|
|
386
|
-
profileEntries.map(([key, value]
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
407
|
+
profileEntries.map(([key, value]) => {
|
|
408
|
+
const schemaWithValue = {
|
|
409
|
+
name: key,
|
|
410
|
+
mutability: readonlyFields.includes(key) ? "READ_ONLY" : "READ_WRITE",
|
|
411
|
+
value
|
|
412
|
+
};
|
|
413
|
+
return /* @__PURE__ */ jsx("div", {
|
|
414
|
+
className: styles.info,
|
|
415
|
+
children: renderUserInfo(schemaWithValue)
|
|
416
|
+
}, key);
|
|
417
|
+
})
|
|
396
418
|
] });
|
|
397
419
|
};
|
|
398
420
|
const profileContent = /* @__PURE__ */ jsxs(Card_default, {
|
|
399
421
|
className: containerClasses,
|
|
400
|
-
children: [
|
|
401
|
-
error
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
children: /* @__PURE__ */ jsx(Avatar, {
|
|
409
|
-
imageUrl: getMappedUserProfileValue_default("picture", mergedMappings, currentUser),
|
|
410
|
-
name: getDisplayName_default(mergedMappings, profile),
|
|
411
|
-
size: 80,
|
|
412
|
-
alt: `${getDisplayName_default(mergedMappings, profile)}'s avatar`,
|
|
413
|
-
isLoading
|
|
414
|
-
})
|
|
415
|
-
}),
|
|
416
|
-
/* @__PURE__ */ jsx("div", {
|
|
417
|
-
className: styles.infoContainer,
|
|
418
|
-
children: schemas && schemas.length > 0 ? schemas.filter((schema) => {
|
|
419
|
-
if (!schema.name || !shouldShowField(schema.name)) return false;
|
|
420
|
-
if (!editable) {
|
|
421
|
-
const value = flattenedProfile && schema.name ? flattenedProfile[schema.name] : void 0;
|
|
422
|
-
return value !== void 0 && value !== "" && value !== null;
|
|
423
|
-
}
|
|
424
|
-
return true;
|
|
425
|
-
}).sort((a, b) => {
|
|
426
|
-
return (a.displayOrder ? parseInt(a.displayOrder, 10) : 999) - (b.displayOrder ? parseInt(b.displayOrder, 10) : 999);
|
|
427
|
-
}).map((schema, index) => {
|
|
428
|
-
const value = flattenedProfile && schema.name ? flattenedProfile[schema.name] : void 0;
|
|
429
|
-
const schemaWithValue = {
|
|
430
|
-
...schema,
|
|
431
|
-
value
|
|
432
|
-
};
|
|
433
|
-
return /* @__PURE__ */ jsx("div", {
|
|
434
|
-
className: styles.info,
|
|
435
|
-
children: renderUserInfo(schemaWithValue)
|
|
436
|
-
}, schema.name || index);
|
|
437
|
-
}) : renderProfileWithoutSchemas()
|
|
438
|
-
})
|
|
439
|
-
]
|
|
422
|
+
children: [error && /* @__PURE__ */ jsxs(Alert_default, {
|
|
423
|
+
variant: "error",
|
|
424
|
+
className: cx(withVendorCSSClassPrefix(bem("user-profile", "alert")), styles.alert),
|
|
425
|
+
children: [/* @__PURE__ */ jsx(Alert_default.Title, { children: t("errors.heading") || "Error" }), /* @__PURE__ */ jsx(Alert_default.Description, { children: error })]
|
|
426
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
427
|
+
className: styles.infoContainer,
|
|
428
|
+
children: renderProfileWithoutSchemas()
|
|
429
|
+
})]
|
|
440
430
|
});
|
|
441
431
|
if (mode === "popup") return /* @__PURE__ */ jsx(Dialog_default, {
|
|
442
432
|
open,
|