import { IdTokenClaims, LoginFlowMessage, LoginFlowState, SDKOptions } from '@strivacity/sdk-core'; import { PopupFlow } from '@strivacity/sdk-core/flows/PopupFlow'; import { RedirectFlow } from '@strivacity/sdk-core/flows/RedirectFlow'; import { NativeFlow } from '@strivacity/sdk-core/flows/NativeFlow'; export type Children = React.ReactElement | React.ReactNode | Array; /** * Represents the session state, including authentication details and token information. */ export type Session = { /** * Indicates if the session is being loaded. */ loading: boolean; /** * The SDK options used to configure the session. */ options: SDKOptions; /** * Indicates whether the user is authenticated. */ isAuthenticated: boolean; /** * Claims from the ID token or `null` if not available. */ idTokenClaims: IdTokenClaims | null; /** * The access token or `null` if not available. */ accessToken: string | null; /** * The refresh token or `null` if not available. */ refreshToken: string | null; /** * Indicates if the access token has expired. */ accessTokenExpired: boolean; /** * Expiration date of the access token or `null` if not set. */ accessTokenExpirationDate: number | null; }; /** * Represents the available authentication flows and operations for Popup-based interactions. */ export type PopupSDK = { /** * Represents the SDK instance. */ sdk: InstanceType; /** * Initiates the login process. */ login: InstanceType['login']; /** * Registers a new user. */ register: InstanceType['register']; /** * Initiates the entry process. */ entry: InstanceType['entry']; /** * Refreshes the user's session. */ refresh: InstanceType['refresh']; /** * Revokes the current session tokens. */ revoke: InstanceType['revoke']; /** * Logs out the user. */ logout: InstanceType['logout']; /** * Handles the callback after authentication or token exchange. */ handleCallback: InstanceType['handleCallback']; }; /** * Represents the available authentication flows and operations for Redirect-based interactions. */ export type RedirectSDK = { /** * Represents the SDK instance. */ sdk: InstanceType; /** * Initiates the login process. */ login: InstanceType['login']; /** * Registers a new user. */ register: InstanceType['register']; /** * Initiates the entry process. */ entry: InstanceType['entry']; /** * Refreshes the user's session. */ refresh: InstanceType['refresh']; /** * Revokes the current session tokens. */ revoke: InstanceType['revoke']; /** * Logs out the user. */ logout: InstanceType['logout']; /** * Handles the callback after authentication or token exchange. */ handleCallback: InstanceType['handleCallback']; }; /** * Represents the available authentication flows and operations for Native-based interactions. */ export type NativeSDK = { /** * Represents the SDK instance. */ sdk: InstanceType; /** * Initiates the login process. */ login: InstanceType['login']; /** * Registers a new user. */ register: InstanceType['register']; /** * Initiates the entry process. */ entry: InstanceType['entry']; /** * Refreshes the user's session. */ refresh: InstanceType['refresh']; /** * Revokes the current session tokens. */ revoke: InstanceType['revoke']; /** * Logs out the user. */ logout: InstanceType['logout']; /** * Handles the callback after authentication or token exchange. */ handleCallback: InstanceType['handleCallback']; }; /** * Represents a combined context for Popup-based flows, containing both the Popup SDK and the session state. */ export type PopupContext = PopupSDK & Session; /** * Represents a combined context for Redirect-based flows, containing both the Redirect SDK and the session state. */ export type RedirectContext = RedirectSDK & Session; /** * Represents a combined context for Native-based flows, containing both the Native SDK and the session state. */ export type NativeContext = NativeSDK & Session; export type NativeFlowContextValue = { loading: boolean; forms: Record>; messages: Record>; state: Partial; submitForm: (formId: string) => Promise; triggerFallback: (hostedUrl?: string) => void; triggerClose: () => void; setFormValue: (formId: string, widgetId: string, value: unknown) => void; setMessage: (formId: string, widgetId: string, value: LoginFlowMessage) => void; };