@turnkey/react-wallet-kit
Version:
The easiest and most powerful way to integrate Turnkey's Embedded Wallets into your React applications.
196 lines • 8.35 kB
TypeScript
import type { CreateSubOrgParams, StamperType, TurnkeySDKClientConfig } from "@turnkey/core";
import type { AuthAction, Session, TurnkeyError, TurnkeyNetworkError } from "@turnkey/sdk-types";
import type { ThemeOverrides } from "../providers/theme/Overrides";
import { KeyFormat as IframeKeyFormat } from "@turnkey/iframe-stamper";
export type OauthProviderConfig = {
/** Client ID for this OAuth provider. Used as the primary audience for the OIDC token. */
primaryClientId?: string;
/** Additional client IDs to register as secondary OAuth providers (additional audiences) during sub-organization creation or provider linking. */
secondaryClientIds?: string[];
};
export declare enum WalletSelectorMode {
/** Auth mode: user is logging in or signing up with a wallet */
Auth = "auth",
/** Connect mode: user is connecting/disconnecting an external wallet */
Connect = "connect"
}
export interface TurnkeyCallbacks {
onOauthRedirect?: (response: {
idToken: string;
publicKey: string;
sessionKey?: string;
}) => void;
beforeSessionExpiry?: (params: {
sessionKey: string;
}) => void;
onSessionExpired?: (params: {
sessionKey: string;
}) => void;
onAuthenticationSuccess?: (params: {
session: Session | undefined;
action: AuthAction;
method: AuthMethod;
identifier: string;
}) => void;
onError?: (error: TurnkeyError | TurnkeyNetworkError) => void;
}
/**
* Configuration for the TurnkeyProvider.
* This interface extends the TurnkeySDKClientConfig to include additional UI and auth configurations.
* It is used to initialize the TurnkeyProvider with various options such as colors, dark mode, auth methods, and more.
*
* @interface TurnkeyProviderConfig
* @extends {TurnkeySDKClientConfig}
*/
export interface TurnkeyProviderConfig extends TurnkeySDKClientConfig {
/** URL for the export iframe. */
exportIframeUrl?: string | undefined;
/** URL for the import iframe. */
importIframeUrl?: string | undefined;
/** configuration for authentication. */
auth?: {
/** configuration for OAuth authentication. */
oauthConfig?: {
/** redirect URI for OAuth. */
oauthRedirectUri?: string;
/** Google OAuth provider configuration. */
google?: OauthProviderConfig;
/** Apple OAuth provider configuration. */
apple?: OauthProviderConfig;
/** Facebook OAuth provider configuration. */
facebook?: OauthProviderConfig;
/** X (formerly Twitter) OAuth provider configuration. */
x?: OauthProviderConfig;
/** Discord OAuth provider configuration. */
discord?: OauthProviderConfig;
/** whether to open OAuth in the same page. Always true on mobile devices. */
openOauthInPage?: boolean;
};
/** session expiration time in seconds. If using the auth proxy, you must configure this setting through the dashboard. Changing this through the TurnkeyProvider will have no effect. */
sessionExpirationSeconds?: string;
/** If otp sent will be alphanumeric. If using the auth proxy, you must configure this setting through the dashboard. Changing this through the TurnkeyProvider will have no effect. */
otpAlphanumeric?: boolean;
/** length of the OTP. If using the auth proxy, you must configure this setting through the dashboard. Changing this through the TurnkeyProvider will have no effect. */
otpLength?: string;
/** parameters for creating a sub-organization for each authentication method. */
createSuborgParams?: {
/** parameters for email OTP authentication. */
emailOtpAuth?: CreateSubOrgParams;
/** parameters for SMS OTP authentication. */
smsOtpAuth?: CreateSubOrgParams;
/** parameters for passkey authentication. */
passkeyAuth?: CreateSubOrgParams & {
passkeyName?: string;
};
/** parameters for wallet authentication. */
walletAuth?: CreateSubOrgParams;
/** parameters for OAuth authentication. */
oauth?: CreateSubOrgParams;
};
/** whether to automatically refresh the session. */
autoRefreshSession?: boolean;
/** whether to scope passkey authentication to the authenticated user's authenticators. Defaults to true. */
scopePasskeyToUser?: boolean;
/** whether to verify the app proof generated by a proxySignup request if the request includes wallet account creation. The end user will see a modal during this process. */
verifyWalletOnSignup?: boolean;
};
/** whether to automatically refresh managed state variables */
autoRefreshManagedState?: boolean;
/** whether to automatically fetch the wallet kit config on initialization. */
autoFetchWalletKitConfig?: boolean;
/** default stamper type to use for requests that require stamping. */
defaultStamperType?: StamperType;
/** UI configuration. */
ui?: {
authModal?: {
/** toggles visibility of authentication methods in the auth modal. */
methods?: {
emailOtpAuthEnabled?: boolean;
smsOtpAuthEnabled?: boolean;
passkeyAuthEnabled?: boolean;
walletAuthEnabled?: boolean;
googleOauthEnabled?: boolean;
appleOauthEnabled?: boolean;
xOauthEnabled?: boolean;
discordOauthEnabled?: boolean;
facebookOauthEnabled?: boolean;
};
/** order of authentication methods in the auth modal. */
methodOrder?: Array<"socials" | "email" | "sms" | "passkey" | "wallet">;
/** order of OAuth authentication methods in the auth modal. */
oauthOrder?: Array<"google" | "apple" | "facebook" | "x" | "discord">;
};
/** logo for the auth component */
logoLight?: string;
logoDark?: string;
/** enables or disables dark mode. */
darkMode?: boolean;
/** color scheme configuration. */
colors?: {
/** light color scheme overrides. */
light?: Partial<ThemeOverrides>;
/** dark color scheme overrides. */
dark?: Partial<ThemeOverrides>;
};
/** whether to use large action buttons. */
preferLargeActionButtons?: boolean;
/** border radius for UI elements. */
borderRadius?: string | number;
/** background blur for UI elements. */
backgroundBlur?: string | number;
/** whether to render the modal in the provider. */
renderModalInProvider?: boolean;
/** Nonce applied to the injected theme override <style> tag for strict CSP. Only works in dynamically-rendered apps. */
styleNonce?: string;
/** whether to suppress missing styles error. */
supressMissingStylesError?: boolean;
};
}
/**@internal */
export declare enum ExportType {
Wallet = "WALLET",
PrivateKey = "PRIVATE_KEY",
WalletAccount = "WALLET_ACCOUNT"
}
/**@internal */
export declare enum ImportType {
Wallet = "WALLET",
PrivateKey = "PRIVATE_KEY"
}
export { IframeKeyFormat as KeyFormat };
/**
* Enum representing the authentication states of the user.
* - Unauthenticated: The user is not authenticated.
* - Authenticated: The user is authenticated.
*/
export declare enum AuthState {
Unauthenticated = "unauthenticated",
Authenticated = "authenticated"
}
/**
* Enum representing the states of the client.
* - Loading: The client is currently loading.
* - Ready: The client is ready for use.
* - Error: An error occurred while initializing the client.
*/
export declare enum ClientState {
Loading = "loading",
Ready = "ready",
Error = "error"
}
/** @internal */
export type WalletId = string;
/** @internal */
export type PrivateKeyId = string;
/** @internal */
export type Address = string;
/**
* Enum representing the authentication methods.
*/
export declare enum AuthMethod {
Otp = "otp",
Passkey = "passkey",
Wallet = "wallet",
Oauth = "oauth"
}
//# sourceMappingURL=base.d.ts.map