@turnkey/core 1.0.0 → 1.1.2

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.
Files changed (152) hide show
  1. package/dist/__clients__/core.d.ts +162 -334
  2. package/dist/__clients__/core.d.ts.map +1 -1
  3. package/dist/__clients__/core.js +418 -275
  4. package/dist/__clients__/core.js.map +1 -1
  5. package/dist/__clients__/core.mjs +369 -226
  6. package/dist/__clients__/core.mjs.map +1 -1
  7. package/dist/__generated__/sdk-client-base.d.ts +4 -2
  8. package/dist/__generated__/sdk-client-base.d.ts.map +1 -1
  9. package/dist/__generated__/sdk-client-base.js +36 -6
  10. package/dist/__generated__/sdk-client-base.js.map +1 -1
  11. package/dist/__generated__/sdk-client-base.mjs +31 -1
  12. package/dist/__generated__/sdk-client-base.mjs.map +1 -1
  13. package/dist/__generated__/version.d.ts +1 -1
  14. package/dist/__generated__/version.js +1 -1
  15. package/dist/__generated__/version.mjs +1 -1
  16. package/dist/__inputs__/public_api.types.d.ts +49 -0
  17. package/dist/__inputs__/public_api.types.d.ts.map +1 -1
  18. package/dist/__polyfills__/window.js.map +1 -1
  19. package/dist/__polyfills__/window.mjs.map +1 -1
  20. package/dist/__stampers__/api/base.d.ts +1 -1
  21. package/dist/__stampers__/api/base.d.ts.map +1 -1
  22. package/dist/__stampers__/api/base.js.map +1 -1
  23. package/dist/__stampers__/api/base.mjs.map +1 -1
  24. package/dist/__stampers__/api/mobile/stamper.d.ts +1 -1
  25. package/dist/__stampers__/api/mobile/stamper.d.ts.map +1 -1
  26. package/dist/__stampers__/api/mobile/stamper.js.map +1 -1
  27. package/dist/__stampers__/api/mobile/stamper.mjs.map +1 -1
  28. package/dist/__stampers__/api/web/stamper.d.ts +1 -1
  29. package/dist/__stampers__/api/web/stamper.d.ts.map +1 -1
  30. package/dist/__stampers__/api/web/stamper.js.map +1 -1
  31. package/dist/__stampers__/api/web/stamper.mjs.map +1 -1
  32. package/dist/__stampers__/passkey/base.d.ts +1 -1
  33. package/dist/__stampers__/passkey/base.d.ts.map +1 -1
  34. package/dist/__stampers__/passkey/base.js.map +1 -1
  35. package/dist/__stampers__/passkey/base.mjs.map +1 -1
  36. package/dist/__storage__/base.d.ts +1 -1
  37. package/dist/__storage__/base.d.ts.map +1 -1
  38. package/dist/__storage__/base.js.map +1 -1
  39. package/dist/__storage__/base.mjs.map +1 -1
  40. package/dist/__storage__/mobile/storage.d.ts +1 -1
  41. package/dist/__storage__/mobile/storage.d.ts.map +1 -1
  42. package/dist/__storage__/mobile/storage.js +3 -3
  43. package/dist/__storage__/mobile/storage.js.map +1 -1
  44. package/dist/__storage__/mobile/storage.mjs +1 -1
  45. package/dist/__storage__/mobile/storage.mjs.map +1 -1
  46. package/dist/__storage__/web/storage.d.ts +1 -1
  47. package/dist/__storage__/web/storage.d.ts.map +1 -1
  48. package/dist/__storage__/web/storage.js +3 -3
  49. package/dist/__storage__/web/storage.js.map +1 -1
  50. package/dist/__storage__/web/storage.mjs +1 -1
  51. package/dist/__storage__/web/storage.mjs.map +1 -1
  52. package/dist/__typedoc-entry__/index.d.ts +3 -0
  53. package/dist/__typedoc-entry__/index.d.ts.map +1 -0
  54. package/dist/__types__/auth.d.ts +119 -0
  55. package/dist/__types__/auth.d.ts.map +1 -0
  56. package/dist/__types__/auth.js +7 -0
  57. package/dist/__types__/auth.js.map +1 -0
  58. package/dist/__types__/auth.mjs +5 -0
  59. package/dist/__types__/auth.mjs.map +1 -0
  60. package/dist/__types__/config.d.ts +140 -0
  61. package/dist/__types__/config.d.ts.map +1 -0
  62. package/dist/__types__/enums.d.ts +59 -0
  63. package/dist/__types__/enums.d.ts.map +1 -0
  64. package/dist/__types__/{base.js → enums.js} +28 -45
  65. package/dist/__types__/enums.js.map +1 -0
  66. package/dist/__types__/{base.mjs → enums.mjs} +29 -44
  67. package/dist/__types__/enums.mjs.map +1 -0
  68. package/dist/__types__/error.d.ts +13 -0
  69. package/dist/__types__/error.d.ts.map +1 -0
  70. package/dist/__types__/error.js +18 -0
  71. package/dist/__types__/error.js.map +1 -0
  72. package/dist/__types__/error.mjs +16 -0
  73. package/dist/__types__/error.mjs.map +1 -0
  74. package/dist/__types__/export.d.ts +10 -0
  75. package/dist/__types__/export.d.ts.map +1 -0
  76. package/dist/__types__/external-wallets.d.ts +176 -0
  77. package/dist/__types__/external-wallets.d.ts.map +1 -0
  78. package/dist/__types__/index.d.ts +8 -0
  79. package/dist/__types__/index.d.ts.map +1 -0
  80. package/dist/__types__/method-types.d.ts +315 -0
  81. package/dist/__types__/method-types.d.ts.map +1 -0
  82. package/dist/__wallet__/base.d.ts +1 -1
  83. package/dist/__wallet__/base.d.ts.map +1 -1
  84. package/dist/__wallet__/base.js.map +1 -1
  85. package/dist/__wallet__/base.mjs.map +1 -1
  86. package/dist/__wallet__/connector.d.ts +3 -3
  87. package/dist/__wallet__/connector.d.ts.map +1 -1
  88. package/dist/__wallet__/connector.js +4 -4
  89. package/dist/__wallet__/connector.js.map +1 -1
  90. package/dist/__wallet__/connector.mjs +3 -3
  91. package/dist/__wallet__/connector.mjs.map +1 -1
  92. package/dist/__wallet__/mobile/manager.d.ts +1 -1
  93. package/dist/__wallet__/mobile/manager.d.ts.map +1 -1
  94. package/dist/__wallet__/mobile/manager.js +4 -4
  95. package/dist/__wallet__/mobile/manager.js.map +1 -1
  96. package/dist/__wallet__/mobile/manager.mjs +1 -1
  97. package/dist/__wallet__/mobile/manager.mjs.map +1 -1
  98. package/dist/__wallet__/stamper.d.ts +1 -1
  99. package/dist/__wallet__/stamper.d.ts.map +1 -1
  100. package/dist/__wallet__/stamper.js +8 -8
  101. package/dist/__wallet__/stamper.js.map +1 -1
  102. package/dist/__wallet__/stamper.mjs +1 -1
  103. package/dist/__wallet__/stamper.mjs.map +1 -1
  104. package/dist/__wallet__/wallet-connect/base.d.ts +4 -2
  105. package/dist/__wallet__/wallet-connect/base.d.ts.map +1 -1
  106. package/dist/__wallet__/wallet-connect/base.js +68 -26
  107. package/dist/__wallet__/wallet-connect/base.js.map +1 -1
  108. package/dist/__wallet__/wallet-connect/base.mjs +53 -11
  109. package/dist/__wallet__/wallet-connect/base.mjs.map +1 -1
  110. package/dist/__wallet__/wallet-connect/client.d.ts +30 -9
  111. package/dist/__wallet__/wallet-connect/client.d.ts.map +1 -1
  112. package/dist/__wallet__/wallet-connect/client.js +73 -11
  113. package/dist/__wallet__/wallet-connect/client.js.map +1 -1
  114. package/dist/__wallet__/wallet-connect/client.mjs +73 -11
  115. package/dist/__wallet__/wallet-connect/client.mjs.map +1 -1
  116. package/dist/__wallet__/web/manager.d.ts +1 -1
  117. package/dist/__wallet__/web/manager.d.ts.map +1 -1
  118. package/dist/__wallet__/web/manager.js +10 -10
  119. package/dist/__wallet__/web/manager.js.map +1 -1
  120. package/dist/__wallet__/web/manager.mjs +1 -1
  121. package/dist/__wallet__/web/manager.mjs.map +1 -1
  122. package/dist/__wallet__/web/native/ethereum.d.ts +3 -3
  123. package/dist/__wallet__/web/native/ethereum.d.ts.map +1 -1
  124. package/dist/__wallet__/web/native/ethereum.js +10 -10
  125. package/dist/__wallet__/web/native/ethereum.js.map +1 -1
  126. package/dist/__wallet__/web/native/ethereum.mjs +3 -3
  127. package/dist/__wallet__/web/native/ethereum.mjs.map +1 -1
  128. package/dist/__wallet__/web/native/solana.d.ts +3 -3
  129. package/dist/__wallet__/web/native/solana.d.ts.map +1 -1
  130. package/dist/__wallet__/web/native/solana.js +11 -11
  131. package/dist/__wallet__/web/native/solana.js.map +1 -1
  132. package/dist/__wallet__/web/native/solana.mjs +6 -6
  133. package/dist/__wallet__/web/native/solana.mjs.map +1 -1
  134. package/dist/index.d.ts +8 -1
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +22 -14
  137. package/dist/index.js.map +1 -1
  138. package/dist/index.mjs +4 -2
  139. package/dist/index.mjs.map +1 -1
  140. package/dist/turnkey-helpers.js.map +1 -1
  141. package/dist/turnkey-helpers.mjs.map +1 -1
  142. package/dist/utils.d.ts +4 -18
  143. package/dist/utils.d.ts.map +1 -1
  144. package/dist/utils.js +95 -32
  145. package/dist/utils.js.map +1 -1
  146. package/dist/utils.mjs +74 -13
  147. package/dist/utils.mjs.map +1 -1
  148. package/package.json +6 -6
  149. package/dist/__types__/base.d.ts +0 -527
  150. package/dist/__types__/base.d.ts.map +0 -1
  151. package/dist/__types__/base.js.map +0 -1
  152. package/dist/__types__/base.mjs.map +0 -1
@@ -1,13 +1,20 @@
1
1
  import { TurnkeySDKClientBase } from "../__generated__/sdk-client-base";
2
- import { TDeleteSubOrganizationResponse, Session, TStampLoginResponse, v1AddressFormat, v1Attestation, v1Pagination, v1SignRawPayloadResult, v1TransactionType, v1User, ProxyTGetWalletKitConfigResponse, v1WalletAccountParams, v1PayloadEncoding, v1HashFunction, v1Curve, v1PrivateKey, WalletAuthResult, BaseAuthResult, AuthAction, PasskeyAuthResult, v1CreatePolicyIntentV3 } from "@turnkey/sdk-types";
3
- import { ExportBundle, StamperType, TurnkeySDKClientConfig, WalletAccount, Wallet, OtpType, CreateSubOrgParams, Chain, WalletManagerBase, WalletProvider, SwitchableChain } from "../__types__/base";
2
+ import { type TDeleteSubOrganizationResponse, type Session, type TStampLoginResponse, type v1SignRawPayloadResult, type v1User, type ProxyTGetWalletKitConfigResponse, type v1PrivateKey, type WalletAuthResult, type BaseAuthResult, AuthAction, type PasskeyAuthResult } from "@turnkey/sdk-types";
3
+ import { Chain, type ExportBundle, type TurnkeySDKClientConfig, type WalletAccount, type Wallet, type WalletManagerBase, type WalletProvider, type CreatePasskeyParams, type CreatePasskeyResult, type LogoutParams, type LoginWithPasskeyParams, type SignUpWithPasskeyParams, type SwitchWalletAccountChainParams, type LoginWithWalletParams, type SignUpWithWalletParams, type LoginOrSignupWithWalletParams, type InitOtpParams, type VerifyOtpParams, type VerifyOtpResult, type LoginWithOtpParams, type SignUpWithOtpParams, type CompleteOtpParams, type CompleteOauthParams, type LoginWithOauthParams, type SignUpWithOauthParams, type FetchWalletsParams, type FetchWalletAccountsParams, type FetchPrivateKeysParams, type SignMessageParams, type SignTransactionParams, type SignAndSendTransactionParams, type FetchUserParams, type FetchOrCreateP256ApiKeyUserParams, type FetchOrCreatePoliciesParams, type FetchOrCreatePoliciesResult, type UpdateUserEmailParams, type RemoveUserEmailParams, type UpdateUserPhoneNumberParams, type RemoveUserPhoneNumberParams, type UpdateUserNameParams, type AddOauthProviderParams, type RemoveOauthProvidersParams, type AddPasskeyParams, type RemovePasskeyParams, type CreateWalletParams, type CreateWalletAccountsParams, type ExportWalletParams, type ExportPrivateKeyParams, type ExportWalletAccountParams, type ImportWalletParams, type ImportPrivateKeyParams, type DeleteSubOrganizationParams, type StoreSessionParams, type ClearSessionParams, type RefreshSessionParams, type GetSessionParams, type SetActiveSessionParams, type CreateApiKeyPairParams } from "../__types__";
4
4
  import { CrossPlatformApiKeyStamper } from "../__stampers__/api/base";
5
5
  import { CrossPlatformPasskeyStamper } from "../__stampers__/passkey/base";
6
+ /**
7
+ * @internal
8
+ * Gathers all public methods exposed in our core client and turns it into a type that
9
+ * can be used to extend clients created for other packages built off core
10
+ *
11
+ * Should be used to keep any packages that extend this core package in sync with each
12
+ * other, meaning any new additions to core should also be reflected in those packages
13
+ */
6
14
  type PublicMethods<T> = {
7
- [K in keyof T as K extends string | number | symbol ? K extends "init" | "constructor" | "config" | "httpClient" | "user" | "wallets" ? never : K : never]: T[K] extends (...args: any[]) => any ? T[K] : never;
15
+ [K in keyof T as T[K] extends Function ? K : never]: T[K];
8
16
  };
9
- /**@internal */
10
- export type TurnkeyClientMethods = PublicMethods<TurnkeyClient>;
17
+ export type TurnkeyClientMethods = Omit<PublicMethods<TurnkeyClient>, "init" | "config" | "httpClient" | "constructor">;
11
18
  export declare class TurnkeyClient {
12
19
  config: TurnkeySDKClientConfig;
13
20
  httpClient: TurnkeySDKClientBase;
@@ -25,21 +32,11 @@ export declare class TurnkeyClient {
25
32
  * - The resulting attestation and challenge can be used to register the passkey with Turnkey.
26
33
  *
27
34
  * @param params.name - display name for the passkey (defaults to a generated name based on the current timestamp).
28
- * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
29
35
  * @param params.challenge - challenge string to use for passkey registration. If not provided, a new challenge will be generated.
30
- * @returns A promise that resolves to an object containing:
31
- * - attestation: attestation object returned from the passkey creation process.
32
- * - encodedChallenge: encoded challenge string used for passkey registration.
36
+ * @returns A promise that resolves to {@link CreatePasskeyResult}
33
37
  * @throws {TurnkeyError} If there is an error during passkey creation, or if the platform is unsupported.
34
38
  */
35
- createPasskey: (params?: {
36
- name?: string;
37
- stampWith?: StamperType | undefined;
38
- challenge?: string;
39
- }) => Promise<{
40
- attestation: v1Attestation;
41
- encodedChallenge: string;
42
- }>;
39
+ createPasskey: (params: CreatePasskeyParams) => Promise<CreatePasskeyResult>;
43
40
  /**
44
41
  * Logs out the current client session.
45
42
  *
@@ -51,9 +48,7 @@ export declare class TurnkeyClient {
51
48
  * @returns A promise that resolves when the logout process is complete.
52
49
  * @throws {TurnkeyError} If there is no active session or if there is an error during the logout process.
53
50
  */
54
- logout: (params?: {
55
- sessionKey?: string;
56
- }) => Promise<void>;
51
+ logout: (params?: LogoutParams) => Promise<void>;
57
52
  /**
58
53
  * Logs in a user using a passkey, optionally specifying the public key, session key, and session expiration.
59
54
  *
@@ -66,16 +61,13 @@ export declare class TurnkeyClient {
66
61
  * @param params.publicKey - public key to use for authentication. If not provided, a new key pair will be generated.
67
62
  * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
68
63
  * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
64
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
69
65
  * @returns A promise that resolves to a {@link PasskeyAuthResult}, which includes:
70
66
  * - `sessionToken`: the signed JWT session token.
71
67
  * - `credentialId`: an empty string.
72
68
  * @throws {TurnkeyError} If there is an error during the passkey login process or if the user cancels the passkey prompt.
73
69
  */
74
- loginWithPasskey: (params?: {
75
- publicKey?: string;
76
- sessionKey?: string;
77
- expirationSeconds?: string;
78
- }) => Promise<PasskeyAuthResult>;
70
+ loginWithPasskey: (params?: LoginWithPasskeyParams) => Promise<PasskeyAuthResult>;
79
71
  /**
80
72
  * Signs up a user using a passkey, creating a new sub-organization and session.
81
73
  *
@@ -90,18 +82,13 @@ export declare class TurnkeyClient {
90
82
  * @param params.sessionKey - session key to use for storing the session (defaults to the default session key).
91
83
  * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
92
84
  * @param params.challenge - challenge string to use for passkey registration. If not provided, a new challenge will be generated.
85
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
93
86
  * @returns A promise that resolves to a {@link PasskeyAuthResult}, which includes:
94
87
  * - `sessionToken`: the signed JWT session token.
95
88
  * - `credentialId`: the credential ID associated with the passkey created.
96
89
  * @throws {TurnkeyError} If there is an error during passkey creation, sub-organization creation, or session storage.
97
90
  */
98
- signUpWithPasskey: (params?: {
99
- createSubOrgParams?: CreateSubOrgParams;
100
- sessionKey?: string;
101
- passkeyDisplayName?: string;
102
- expirationSeconds?: string;
103
- challenge?: string;
104
- }) => Promise<PasskeyAuthResult>;
91
+ signUpWithPasskey: (params?: SignUpWithPasskeyParams) => Promise<PasskeyAuthResult>;
105
92
  /**
106
93
  * Retrieves wallet providers from the initialized wallet manager.
107
94
  *
@@ -119,10 +106,10 @@ export declare class TurnkeyClient {
119
106
  * - Requires the wallet manager and its connector to be initialized.
120
107
  *
121
108
  * @param walletProvider - wallet provider to connect.
122
- * @returns A promise that resolves once the wallet account is connected.
109
+ * @returns A promise that resolves with the connected wallet's address.
123
110
  * @throws {TurnkeyError} If the wallet manager is uninitialized or the connection fails.
124
111
  */
125
- connectWalletAccount: (walletProvider: WalletProvider) => Promise<void>;
112
+ connectWalletAccount: (walletProvider: WalletProvider) => Promise<string>;
126
113
  /**
127
114
  * Disconnects the specified wallet account.
128
115
  *
@@ -149,11 +136,7 @@ export declare class TurnkeyClient {
149
136
  *
150
137
  * @throws {TurnkeyError} If the wallet manager is uninitialized, the provider is not connected, or the switch fails.
151
138
  */
152
- switchWalletAccountChain: (params: {
153
- walletAccount: WalletAccount;
154
- chainOrId: string | SwitchableChain;
155
- walletProviders?: WalletProvider[] | undefined;
156
- }) => Promise<void>;
139
+ switchWalletAccountChain: (params: SwitchWalletAccountChainParams) => Promise<void>;
157
140
  /**
158
141
  * Logs in a user using the specified wallet provider.
159
142
  *
@@ -167,17 +150,13 @@ export declare class TurnkeyClient {
167
150
  * @param params.publicKey - optional public key to associate with the session (generated if not provided).
168
151
  * @param params.sessionKey - optional key to store the session under (defaults to the default session key).
169
152
  * @param params.expirationSeconds - optional session expiration time in seconds (defaults to the configured default).
153
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
170
154
  * @returns A promise that resolves to a {@link WalletAuthResult}, which includes:
171
155
  * - `sessionToken`: the signed JWT session token.
172
156
  * - `address`: the authenticated wallet address.
173
157
  * @throws {TurnkeyError} If the wallet stamper is uninitialized, a public key cannot be found or generated, or login fails.
174
158
  */
175
- loginWithWallet: (params: {
176
- walletProvider: WalletProvider;
177
- publicKey?: string;
178
- sessionKey?: string;
179
- expirationSeconds?: string;
180
- }) => Promise<WalletAuthResult>;
159
+ loginWithWallet: (params: LoginWithWalletParams) => Promise<WalletAuthResult>;
181
160
  /**
182
161
  * Signs up a user using a wallet, creating a new sub-organization and session.
183
162
  *
@@ -191,17 +170,13 @@ export declare class TurnkeyClient {
191
170
  * @param params.createSubOrgParams - parameters for creating a sub-organization (e.g., authenticators, user metadata).
192
171
  * @param params.sessionKey - session key to use for storing the session (defaults to the default session key).
193
172
  * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
173
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
194
174
  * @returns A promise that resolves to a {@link WalletAuthResult}, which includes:
195
175
  * - `sessionToken`: the signed JWT session token.
196
176
  * - `address`: the authenticated wallet address.
197
177
  * @throws {TurnkeyError} If there is an error during wallet authentication, sub-organization creation, session storage, or cleanup.
198
178
  */
199
- signUpWithWallet: (params: {
200
- walletProvider: WalletProvider;
201
- createSubOrgParams?: CreateSubOrgParams;
202
- sessionKey?: string;
203
- expirationSeconds?: string;
204
- }) => Promise<WalletAuthResult>;
179
+ signUpWithWallet: (params: SignUpWithWalletParams) => Promise<WalletAuthResult>;
205
180
  /**
206
181
  * Logs in an existing user or signs up a new user using a wallet, creating a new sub-organization if needed.
207
182
  *
@@ -216,18 +191,14 @@ export declare class TurnkeyClient {
216
191
  * @param params.createSubOrgParams - optional parameters for creating a sub-organization (e.g., authenticators, user metadata).
217
192
  * @param params.sessionKey - session key to use for storing the session (defaults to the default session key).
218
193
  * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
194
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
219
195
  * @returns A promise that resolves to an object containing:
220
196
  * - `sessionToken`: the signed JWT session token.
221
197
  * - `address`: the authenticated wallet address.
222
198
  * - `action`: whether the flow resulted in a login or signup ({@link AuthAction}).
223
199
  * @throws {TurnkeyError} If there is an error during wallet authentication, sub-organization creation, or session storage.
224
200
  */
225
- loginOrSignupWithWallet: (params: {
226
- walletProvider: WalletProvider;
227
- createSubOrgParams?: CreateSubOrgParams;
228
- sessionKey?: string;
229
- expirationSeconds?: string;
230
- }) => Promise<WalletAuthResult & {
201
+ loginOrSignupWithWallet: (params: LoginOrSignupWithWalletParams) => Promise<WalletAuthResult & {
231
202
  action: AuthAction;
232
203
  }>;
233
204
  /**
@@ -239,13 +210,11 @@ export declare class TurnkeyClient {
239
210
  *
240
211
  * @param params.otpType - type of OTP to initialize (OtpType.Email or OtpType.Sms).
241
212
  * @param params.contact - contact information for the user (e.g., email address or phone number).
213
+ * @param params.organizationId - optional organization ID to target (defaults to the session's organization ID or the parent organization ID).
242
214
  * @returns A promise that resolves to the OTP ID required for verification.
243
215
  * @throws {TurnkeyError} If there is an error during the OTP initialization process or if the maximum number of OTPs has been reached.
244
216
  */
245
- initOtp: (params: {
246
- otpType: OtpType;
247
- contact: string;
248
- }) => Promise<string>;
217
+ initOtp: (params: InitOtpParams) => Promise<string>;
249
218
  /**
250
219
  * Verifies the OTP code sent to the user.
251
220
  *
@@ -263,15 +232,7 @@ export declare class TurnkeyClient {
263
232
  * - verificationToken: verification token to be used for login or sign-up.
264
233
  * @throws {TurnkeyError} If there is an error during the OTP verification process, such as an invalid code or network failure.
265
234
  */
266
- verifyOtp: (params: {
267
- otpId: string;
268
- otpCode: string;
269
- contact: string;
270
- otpType: OtpType;
271
- }) => Promise<{
272
- subOrganizationId: string;
273
- verificationToken: string;
274
- }>;
235
+ verifyOtp: (params: VerifyOtpParams) => Promise<VerifyOtpResult>;
275
236
  /**
276
237
  * Logs in a user using an OTP verification token.
277
238
  *
@@ -283,18 +244,14 @@ export declare class TurnkeyClient {
283
244
  *
284
245
  * @param params.verificationToken - verification token received after OTP verification.
285
246
  * @param params.publicKey - public key to use for authentication. If not provided, a new key pair will be generated.
247
+ * @param params.organizationId - optional organization ID to target (defaults to the verified subOrg ID linked to the verification token contact).
286
248
  * @param params.invalidateExisting - flag to invalidate existing session for the user.
287
249
  * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
288
250
  * @returns A promise that resolves to a {@link BaseAuthResult}, which includes:
289
251
  * - `sessionToken`: the signed JWT session token.
290
252
  * @throws {TurnkeyError} If there is an error during the OTP login process or if key pair cleanup fails.
291
253
  */
292
- loginWithOtp: (params: {
293
- verificationToken: string;
294
- publicKey?: string;
295
- invalidateExisting?: boolean;
296
- sessionKey?: string;
297
- }) => Promise<BaseAuthResult>;
254
+ loginWithOtp: (params: LoginWithOtpParams) => Promise<BaseAuthResult>;
298
255
  /**
299
256
  * Signs up a user using an OTP verification token.
300
257
  *
@@ -314,14 +271,7 @@ export declare class TurnkeyClient {
314
271
  * - `sessionToken`: the signed JWT session token.
315
272
  * @throws {TurnkeyError} If there is an error during the OTP sign-up process or session storage.
316
273
  */
317
- signUpWithOtp: (params: {
318
- verificationToken: string;
319
- contact: string;
320
- otpType: OtpType;
321
- createSubOrgParams?: CreateSubOrgParams;
322
- invalidateExisting?: boolean;
323
- sessionKey?: string;
324
- }) => Promise<BaseAuthResult>;
274
+ signUpWithOtp: (params: SignUpWithOtpParams) => Promise<BaseAuthResult>;
325
275
  /**
326
276
  * Completes the OTP authentication flow by verifying the OTP code and then either signing up or logging in the user.
327
277
  *
@@ -345,16 +295,7 @@ export declare class TurnkeyClient {
345
295
  * - `action`: whether the flow resulted in a login or signup ({@link AuthAction}).
346
296
  * @throws {TurnkeyError} If there is an error during OTP verification, sign-up, or login.
347
297
  */
348
- completeOtp: (params: {
349
- otpId: string;
350
- otpCode: string;
351
- contact: string;
352
- otpType: OtpType;
353
- publicKey?: string;
354
- invalidateExisting?: boolean;
355
- sessionKey?: string;
356
- createSubOrgParams?: CreateSubOrgParams;
357
- }) => Promise<BaseAuthResult & {
298
+ completeOtp: (params: CompleteOtpParams) => Promise<BaseAuthResult & {
358
299
  verificationToken: string;
359
300
  action: AuthAction;
360
301
  }>;
@@ -378,14 +319,7 @@ export declare class TurnkeyClient {
378
319
  * - `action`: whether the flow resulted in a login or signup ({@link AuthAction}).
379
320
  * @throws {TurnkeyError} If there is an error during the OAuth completion process, such as account lookup, sign-up, or login.
380
321
  */
381
- completeOauth: (params: {
382
- oidcToken: string;
383
- publicKey: string;
384
- providerName?: string;
385
- sessionKey?: string;
386
- invalidateExisting?: boolean;
387
- createSubOrgParams?: CreateSubOrgParams;
388
- }) => Promise<BaseAuthResult & {
322
+ completeOauth: (params: CompleteOauthParams) => Promise<BaseAuthResult & {
389
323
  action: AuthAction;
390
324
  }>;
391
325
  /**
@@ -404,12 +338,7 @@ export declare class TurnkeyClient {
404
338
  * - `sessionToken`: the signed JWT session token.
405
339
  * @throws {TurnkeyError} If there is an error during the OAuth login process or if key pair cleanup fails.
406
340
  */
407
- loginWithOauth: (params: {
408
- oidcToken: string;
409
- publicKey: string;
410
- invalidateExisting?: boolean;
411
- sessionKey?: string;
412
- }) => Promise<BaseAuthResult>;
341
+ loginWithOauth: (params: LoginWithOauthParams) => Promise<BaseAuthResult>;
413
342
  /**
414
343
  * Signs up a user using OAuth authentication.
415
344
  *
@@ -427,13 +356,7 @@ export declare class TurnkeyClient {
427
356
  * - `sessionToken`: the signed JWT session token.
428
357
  * @throws {TurnkeyError} If there is an error during the OAuth sign-up or login process.
429
358
  */
430
- signUpWithOauth: (params: {
431
- oidcToken: string;
432
- publicKey: string;
433
- providerName: string;
434
- createSubOrgParams?: CreateSubOrgParams;
435
- sessionKey?: string;
436
- }) => Promise<BaseAuthResult>;
359
+ signUpWithOauth: (params: SignUpWithOauthParams) => Promise<BaseAuthResult>;
437
360
  /**
438
361
  * Fetches all wallets for the current user, including both embedded and connected wallets.
439
362
  *
@@ -443,15 +366,15 @@ export declare class TurnkeyClient {
443
366
  * - Returns both embedded and connected wallets in a single array, each with their respective accounts populated.
444
367
  * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
445
368
  *
446
- * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
447
369
  * @param params.walletProviders - array of wallet providers to use for fetching wallets.
370
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
371
+ * @param params.userId - user ID to target (defaults to the session's user ID).
372
+ * @param params.connectedOnly - if true, fetches only connected wallets; if false or undefined, fetches both embedded and connected wallets.
373
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
448
374
  * @returns A promise that resolves to an array of `Wallet` objects.
449
375
  * @throws {TurnkeyError} If no active session is found or if there is an error fetching wallets.
450
376
  */
451
- fetchWallets: (params?: {
452
- walletProviders?: WalletProvider[] | undefined;
453
- stampWith?: StamperType | undefined;
454
- }) => Promise<Wallet[]>;
377
+ fetchWallets: (params?: FetchWalletsParams) => Promise<Wallet[]>;
455
378
  /**
456
379
  * Fetches all accounts for a specific wallet, including both embedded and connected wallet accounts.
457
380
  *
@@ -465,15 +388,13 @@ export declare class TurnkeyClient {
465
388
  * @param params.walletProviders - list of wallet providers to filter by (used for connected wallets).
466
389
  * @param params.paginationOptions - pagination options for embedded wallets.
467
390
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
391
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
392
+ * @param params.userId - user ID to target (defaults to the session's user ID).
393
+ *
468
394
  * @returns A promise that resolves to an array of `v1WalletAccount` objects.
469
395
  * @throws {TurnkeyError} If no active session is found or if there is an error fetching wallet accounts.
470
396
  */
471
- fetchWalletAccounts: (params: {
472
- wallet: Wallet;
473
- walletProviders?: WalletProvider[];
474
- paginationOptions?: v1Pagination;
475
- stampWith?: StamperType | undefined;
476
- }) => Promise<WalletAccount[]>;
397
+ fetchWalletAccounts: (params: FetchWalletAccountsParams) => Promise<WalletAccount[]>;
477
398
  /**
478
399
  * Fetches all private keys for the current user.
479
400
  *
@@ -481,97 +402,103 @@ export declare class TurnkeyClient {
481
402
  * - Supports stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
482
403
  *
483
404
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
405
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
484
406
  * @returns A promise that resolves to an array of `v1PrivateKey` objects.
485
407
  * @throws {TurnkeyError} If no active session is found or if there is an error fetching private keys.
486
408
  */
487
- fetchPrivateKeys: (params?: {
488
- stampWith?: StamperType | undefined;
489
- }) => Promise<v1PrivateKey[]>;
409
+ fetchPrivateKeys: (params?: FetchPrivateKeysParams) => Promise<v1PrivateKey[]>;
490
410
  /**
491
411
  * Signs a message using the specified wallet account.
492
412
  *
493
- * - Supports both embedded and connected wallets.
494
- * - For **connected wallets**:
413
+ * Behavior differs depending on the wallet type:
414
+ *
415
+ * - **Connected wallets**
495
416
  * - Delegates signing to the wallet provider’s native signing method.
496
- * - **Important:** For Ethereum wallets (e.g., MetaMask), signatures follow [EIP-191](https://eips.ethereum.org/EIPS/eip-191).
497
- * The message is automatically prefixed with `"\x19Ethereum Signed Message:\n" + message length`
498
- * before signing. As a result, this signature **cannot be used as a raw transaction signature**
499
- * or broadcast on-chain.
500
- * - For **embedded wallets**, uses the Turnkey API to sign the message directly.
501
- * - Automatically handles message encoding and hashing based on the wallet account’s address format,
417
+ * - *Ethereum*: signatures always follow [EIP-191](https://eips.ethereum.org/EIPS/eip-191).
418
+ * - The wallet automatically prefixes messages with
419
+ * `"\x19Ethereum Signed Message:\n" + message length` before signing.
420
+ * - As a result, these signatures cannot be used as raw transaction signatures or broadcast on-chain.
421
+ * - If `addEthereumPrefix` is set to `false`, an error is thrown because connected Ethereum wallets always prefix.
422
+ * - *Other chains*: follows the native connected wallet behavior.
423
+ *
424
+ * - **Embedded wallets**
425
+ * - Uses the Turnkey API to sign the message directly.
426
+ * - Supports optional `addEthereumPrefix`:
427
+ * - If `true` (default for Ethereum), the message is prefixed before signing.
428
+ * - If `false`, the raw message is signed without any prefix.
429
+ *
430
+ * Additional details:
431
+ * - Automatically handles encoding and hashing based on the wallet account’s address format,
502
432
  * unless explicitly overridden.
433
+ * - Optionally allows stamping with a specific stamper
434
+ * (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
503
435
  *
504
- * @param params.message - message to sign.
436
+ * @param params.message - plaintext (UTF-8) message to sign.
505
437
  * @param params.walletAccount - wallet account to use for signing.
506
- * @param params.encoding - override for the payload encoding (defaults to the encoding appropriate for the address type).
507
- * @param params.hashFunction - override for the hash function (defaults to the hash function appropriate for the address type).
508
- * @param params.stampWith - stamper to tag the signing request (e.g., Passkey, ApiKey, or Wallet).
509
- * @param params.addEthereumPrefix - whether to prefix the message with Ethereum's `"\x19Ethereum Signed Message:\n"` string.
510
- * - If `true` (default for Ethereum), the message is prefixed before signing.
511
- * - If `false`:
512
- * - Connected wallets will throw an error because they always prefix automatically.
513
- * - Embedded wallets will sign the raw message without any prefix.
514
- *
515
- * @returns A promise resolving to a `v1SignRawPayloadResult` containing the signature and metadata.
516
- * @throws {TurnkeyError} If signing fails, if the wallet account does not support signing, or if the response is invalid.
438
+ * @param params.encoding - override for payload encoding (defaults to the encoding appropriate for the address format).
439
+ * @param params.hashFunction - override for hash function (defaults to the function appropriate for the address format).
440
+ * @param params.stampWith - optional stamper for the signing request.
441
+ * @param params.addEthereumPrefix - whether to prefix the message with Ethereums
442
+ * `"\x19Ethereum Signed Message:\n"` string (default: `true` for Ethereum).
443
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
444
+ *
445
+ * @returns A promise that resolves to a `v1SignRawPayloadResult` containing the signature and metadata.
446
+ * @throws {TurnkeyError} If signing fails, the wallet type does not support message signing, or the response is invalid.
517
447
  */
518
- signMessage: (params: {
519
- message: string;
520
- walletAccount: WalletAccount;
521
- encoding?: v1PayloadEncoding;
522
- hashFunction?: v1HashFunction;
523
- stampWith?: StamperType | undefined;
524
- addEthereumPrefix?: boolean;
525
- }) => Promise<v1SignRawPayloadResult>;
448
+ signMessage: (params: SignMessageParams) => Promise<v1SignRawPayloadResult>;
526
449
  /**
527
450
  * Signs a transaction using the specified wallet account.
528
451
  *
529
- * - This function signs a blockchain transaction using the provided wallet address and transaction data.
530
- * - Supports all Turnkey-supported blockchain networks (e.g., Ethereum, Solana, Tron).
531
- * - Automatically determines the appropriate signing method based on the transaction type.
532
- * - Delegates signing to the Turnkey API, which returns the signed transaction and related metadata.
533
- * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
452
+ * Behavior differs depending on the type of wallet:
453
+ *
454
+ * - **Connected wallets**
455
+ * - Ethereum: does not support raw transaction signing. Calling this function will throw an error instructing you to use `signAndSendTransaction` instead.
456
+ * - Solana: supports raw transaction signing via the connected wallet provider.
457
+ * - Other chains: not supported; will throw an error.
534
458
  *
535
- * @param params.walletAccount - wallet account to use for signing the transaction.
536
- * @param params.unsignedTransaction - unsigned transaction data (serialized as a string) to be signed.
459
+ * - **Embedded wallets**
460
+ * - Delegates signing to the Turnkey API, which returns the signed transaction.
461
+ * - Supports all Turnkey-supported transaction types (e.g., Ethereum, Solana, Tron).
462
+ * - Optionally allows stamping with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
463
+ *
464
+ * @param params.walletAccount - wallet account to use for signing.
465
+ * @param params.unsignedTransaction - unsigned transaction data as a serialized
466
+ * string in the canonical encoding for the given `transactionType`.
537
467
  * @param params.transactionType - type of transaction (e.g., "TRANSACTION_TYPE_ETHEREUM", "TRANSACTION_TYPE_SOLANA", "TRANSACTION_TYPE_TRON").
538
- * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
539
- * @returns A promise that resolves to a `TSignTransactionResponse` object containing the signed transaction and any additional signing metadata.
540
- * @throws {TurnkeyError} If there is an error signing the transaction or if the response is invalid.
468
+ * @param params.stampWith - stamper to use for signing (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
469
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
470
+ * @returns A promise that resolves to the signed transaction string.
471
+ * @throws {TurnkeyError} If the wallet type is unsupported, signing fails, or the response is invalid.
541
472
  */
542
- signTransaction: (params: {
543
- unsignedTransaction: string;
544
- transactionType: v1TransactionType;
545
- walletAccount: WalletAccount;
546
- stampWith?: StamperType | undefined;
547
- }) => Promise<string>;
473
+ signTransaction: (params: SignTransactionParams) => Promise<string>;
548
474
  /**
549
475
  * Signs and broadcasts a transaction using the specified wallet account.
550
476
  *
551
- * - For **connected wallets**:
552
- * - Calls the wallet’s native `signAndSendTransaction` method.
553
- * - Does **not** require an `rpcUrl`.
477
+ * Behavior differs depending on the type of wallet:
478
+ *
479
+ * - **Connected wallets**
480
+ * - *Ethereum*: delegates to the wallet’s native `signAndSendTransaction` method.
481
+ * - Does **not** require an `rpcUrl` (the wallet handles broadcasting).
482
+ * - *Solana*: signs the transaction locally with the connected wallet, but requires an `rpcUrl` to broadcast it.
483
+ * - Other chains: not supported; will throw an error.
554
484
  *
555
- * - For **embedded wallets**:
485
+ * - **Embedded wallets**
556
486
  * - Signs the transaction using the Turnkey API.
557
- * - Requires an `rpcUrl` to broadcast the transaction.
558
- * - Broadcasts the transaction using a JSON-RPC client.
559
- *
560
- * @param params.walletAccount - wallet account to use for signing and sending.
561
- * @param params.unsignedTransaction - unsigned transaction (serialized string).
562
- * @param params.transactionType - transaction type (e.g., "TRANSACTION_TYPE_SOLANA").
563
- * @param params.rpcUrl - required for embedded wallets to broadcast the signed transaction.
564
- * @param params.stampWith - optional stamper to tag the signing request.
487
+ * - Requires an `rpcUrl` to broadcast the signed transaction, since Turnkey does not broadcast directly.
488
+ * - Broadcasts the transaction using a JSON-RPC client and returns the resulting transaction hash/signature.
489
+ * - Optionally allows stamping with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
490
+ *
491
+ * @param params.walletAccount - wallet account to use for signing and broadcasting.
492
+ * @param params.unsignedTransaction - unsigned transaction data as a serialized
493
+ * string in the canonical encoding for the given `transactionType`.
494
+ * @param params.transactionType - type of transaction (e.g., `"TRANSACTION_TYPE_SOLANA"`, `"TRANSACTION_TYPE_ETHEREUM"`).
495
+ * @param params.rpcUrl - JSON-RPC endpoint used for broadcasting (required for Solana connected wallets and all embedded wallets).
496
+ * @param params.stampWith - optional stamper to use when signing (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
497
+ * @param params.organizationId - **Only for Turnkey embedded wallets**: organization ID to target (defaults to the session's organization ID).
565
498
  * @returns A promise that resolves to a transaction signature or hash.
566
- * @throws {TurnkeyError} If signing or broadcasting fails.
499
+ * @throws {TurnkeyError} If the wallet type is unsupported, or if signing/broadcasting fails.
567
500
  */
568
- signAndSendTransaction: (params: {
569
- unsignedTransaction: string;
570
- transactionType: v1TransactionType;
571
- walletAccount: WalletAccount;
572
- rpcUrl?: string;
573
- stampWith?: StamperType | undefined;
574
- }) => Promise<string>;
501
+ signAndSendTransaction: (params: SignAndSendTransactionParams) => Promise<string>;
575
502
  /**
576
503
  * Fetches the user details for the current session or a specified user.
577
504
  *
@@ -587,11 +514,7 @@ export declare class TurnkeyClient {
587
514
  * @returns A promise that resolves to a `v1User` object containing the user details.
588
515
  * @throws {TurnkeyError} If there is no active session, if there is no userId, or if there is an error fetching user details.
589
516
  */
590
- fetchUser: (params?: {
591
- organizationId?: string;
592
- userId?: string;
593
- stampWith?: StamperType | undefined;
594
- }) => Promise<v1User>;
517
+ fetchUser: (params?: FetchUserParams) => Promise<v1User>;
595
518
  /**
596
519
  * Fetches an existing user by P-256 API key public key, or creates a new one if none exists.
597
520
  *
@@ -603,16 +526,12 @@ export declare class TurnkeyClient {
603
526
  * @param params.publicKey - the P-256 public key to use for lookup and creation.
604
527
  * @param params.createParams.userName - optional username to assign if creating a new user (defaults to `"Public Key User"`).
605
528
  * @param params.createParams.apiKeyName - optional API key name to assign if creating a new API key (defaults to `public-key-user-${publicKey}`).
529
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
530
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
606
531
  * @returns A promise that resolves to the existing or newly created {@link v1User}.
607
532
  * @throws {TurnkeyError} If there is no active session, if the input is invalid, if user retrieval fails, or if user creation fails.
608
533
  */
609
- fetchOrCreateP256ApiKeyUser: (params: {
610
- publicKey: string;
611
- createParams?: {
612
- apiKeyName?: string;
613
- userName?: string;
614
- };
615
- }) => Promise<v1User>;
534
+ fetchOrCreateP256ApiKeyUser: (params: FetchOrCreateP256ApiKeyUserParams) => Promise<v1User>;
616
535
  /**
617
536
  * Fetches each requested policy if it exists, or creates it if it does not.
618
537
  *
@@ -622,6 +541,8 @@ export declare class TurnkeyClient {
622
541
  * - If it does not exist, it is created and returned with its new `policyId`.
623
542
  *
624
543
  * @param params.policies - the list of policies to fetch or create.
544
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
545
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
625
546
  * @returns A promise that resolves to an array of objects, each containing:
626
547
  * - `policyId`: the unique identifier of the policy.
627
548
  * - `policyName`: human-readable name of the policy.
@@ -632,11 +553,7 @@ export declare class TurnkeyClient {
632
553
  * @throws {TurnkeyError} If there is no active session, if the input is invalid,
633
554
  * if fetching policies fails, or if creating policies fails.
634
555
  */
635
- fetchOrCreatePolicies: (params: {
636
- policies: v1CreatePolicyIntentV3[];
637
- }) => Promise<({
638
- policyId: string;
639
- } & v1CreatePolicyIntentV3)[]>;
556
+ fetchOrCreatePolicies: (params: FetchOrCreatePoliciesParams) => Promise<FetchOrCreatePoliciesResult>;
640
557
  /**
641
558
  * Updates the user's email address.
642
559
  *
@@ -650,15 +567,11 @@ export declare class TurnkeyClient {
650
567
  * @param params.verificationToken - verification token from OTP email verification (required if verifying the email).
651
568
  * @param params.userId - user ID to update a specific user's email (defaults to the current session's userId).
652
569
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
570
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
653
571
  * @returns A promise that resolves to the userId of the updated user.
654
572
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error updating or verifying the user email.
655
573
  */
656
- updateUserEmail: (params: {
657
- email: string;
658
- verificationToken?: string;
659
- userId?: string;
660
- stampWith?: StamperType | undefined;
661
- }) => Promise<string>;
574
+ updateUserEmail: (params: UpdateUserEmailParams) => Promise<string>;
662
575
  /**
663
576
  * Removes the user's email address.
664
577
  *
@@ -669,13 +582,11 @@ export declare class TurnkeyClient {
669
582
  *
670
583
  * @param params.userId - user ID to remove a specific user's email address (defaults to the current session's userId).
671
584
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
585
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
672
586
  * @returns A promise that resolves to the userId of the user whose email was removed.
673
587
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error removing the user email.
674
588
  */
675
- removeUserEmail: (params?: {
676
- userId?: string;
677
- stampWith?: StamperType | undefined;
678
- }) => Promise<string>;
589
+ removeUserEmail: (params?: RemoveUserEmailParams) => Promise<string>;
679
590
  /**
680
591
  * Updates the user's phone number.
681
592
  *
@@ -689,15 +600,11 @@ export declare class TurnkeyClient {
689
600
  * @param params.verificationToken - verification token from OTP phone verification (required if verifying the phone number).
690
601
  * @param params.userId - user ID to update a specific user's phone number (defaults to the current session's userId).
691
602
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
603
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
692
604
  * @returns A promise that resolves to the userId of the updated user.
693
605
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error updating or verifying the user phone number.
694
606
  */
695
- updateUserPhoneNumber: (params: {
696
- phoneNumber: string;
697
- verificationToken?: string;
698
- userId?: string;
699
- stampWith?: StamperType | undefined;
700
- }) => Promise<string>;
607
+ updateUserPhoneNumber: (params: UpdateUserPhoneNumberParams) => Promise<string>;
701
608
  /**
702
609
  * Removes the user's phone number.
703
610
  *
@@ -708,13 +615,11 @@ export declare class TurnkeyClient {
708
615
  *
709
616
  * @param params.userId - user ID to remove a specific user's phone number (defaults to the current session's userId).
710
617
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
618
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
711
619
  * @returns A promise that resolves to the userId of the user whose phone number was removed.
712
620
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error removing the user phone number.
713
621
  */
714
- removeUserPhoneNumber: (params?: {
715
- userId?: string;
716
- stampWith?: StamperType | undefined;
717
- }) => Promise<string>;
622
+ removeUserPhoneNumber: (params?: RemoveUserPhoneNumberParams) => Promise<string>;
718
623
  /**
719
624
  * Updates the user's name.
720
625
  *
@@ -727,14 +632,11 @@ export declare class TurnkeyClient {
727
632
  * @param params.userName - new name to set for the user.
728
633
  * @param params.userId - user ID to update a specific user's name (defaults to the current session's userId).
729
634
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
635
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
730
636
  * @returns A promise that resolves to the userId of the updated user.
731
637
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error updating the user name.
732
638
  */
733
- updateUserName: (params: {
734
- userName: string;
735
- userId?: string;
736
- stampWith?: StamperType | undefined;
737
- }) => Promise<string>;
639
+ updateUserName: (params: UpdateUserNameParams) => Promise<string>;
738
640
  /**
739
641
  * Adds an OAuth provider to the user.
740
642
  *
@@ -747,17 +649,13 @@ export declare class TurnkeyClient {
747
649
  *
748
650
  * @param params.providerName - name of the OAuth provider to add (e.g., "Google", "Apple").
749
651
  * @param params.oidcToken - OIDC token for the OAuth provider.
652
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
750
653
  * @param params.userId - user ID to add the provider for a specific user (defaults to current session's userId).
751
654
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
752
655
  * @returns A promise that resolves to an array of provider IDs associated with the user.
753
656
  * @throws {TurnkeyError} If there is no active session, if the account already exists, or if there is an error adding the OAuth provider.
754
657
  */
755
- addOauthProvider: (params: {
756
- providerName: string;
757
- oidcToken: string;
758
- userId?: string;
759
- stampWith?: StamperType | undefined;
760
- }) => Promise<string[]>;
658
+ addOauthProvider: (params: AddOauthProviderParams) => Promise<string[]>;
761
659
  /**
762
660
  * Removes a list of OAuth providers from the user.
763
661
  *
@@ -770,14 +668,11 @@ export declare class TurnkeyClient {
770
668
  * @param params.providerIds - IDs of the OAuth providers to remove.
771
669
  * @param params.userId - user ID to remove the provider for a specific user (defaults to the current session's userId).
772
670
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
671
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
773
672
  * @returns A promise that resolves to an array of provider IDs that were removed.
774
673
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error removing the OAuth provider.
775
674
  */
776
- removeOauthProviders: (params: {
777
- providerIds: string[];
778
- userId?: string;
779
- stampWith?: StamperType | undefined;
780
- }) => Promise<string[]>;
675
+ removeOauthProviders: (params: RemoveOauthProvidersParams) => Promise<string[]>;
781
676
  /**
782
677
  * Adds a new passkey authenticator for the user.
783
678
  *
@@ -791,15 +686,11 @@ export declare class TurnkeyClient {
791
686
  * @param params.displayName - display name of the passkey (defaults to the value of `name`).
792
687
  * @param params.userId - user ID to add the passkey for a specific user (defaults to the current session's userId).
793
688
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
689
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
794
690
  * @returns A promise that resolves to an array of authenticator IDs for the newly added passkey(s).
795
691
  * @throws {TurnkeyError} If there is no active session, if passkey creation fails, or if there is an error adding the passkey.
796
692
  */
797
- addPasskey: (params?: {
798
- name?: string;
799
- displayName?: string;
800
- userId?: string;
801
- stampWith?: StamperType | undefined;
802
- }) => Promise<string[]>;
693
+ addPasskey: (params?: AddPasskeyParams) => Promise<string[]>;
803
694
  /**
804
695
  * Removes passkeys (authenticator) from the user.
805
696
  *
@@ -812,14 +703,11 @@ export declare class TurnkeyClient {
812
703
  * @param params.authenticatorIds - IDs of the authenticators (passkeys) to remove.
813
704
  * @param params.userId - user ID to remove the passkeys for a specific user (defaults to the current session's userId).
814
705
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
706
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
815
707
  * @returns A promise that resolves to an array of authenticator IDs that were removed.
816
708
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error removing the passkeys.
817
709
  */
818
- removePasskeys: (params: {
819
- authenticatorIds: string[];
820
- userId?: string;
821
- stampWith?: StamperType | undefined;
822
- }) => Promise<string[]>;
710
+ removePasskeys: (params: RemovePasskeyParams) => Promise<string[]>;
823
711
  /**
824
712
  * Creates a new wallet for sub-organization.
825
713
  *
@@ -839,13 +727,7 @@ export declare class TurnkeyClient {
839
727
  * @returns A promise that resolves to the ID of the newly created wallet.
840
728
  * @throws {TurnkeyError} If there is no active session or if there is an error creating the wallet.
841
729
  */
842
- createWallet: (params: {
843
- walletName: string;
844
- accounts?: v1WalletAccountParams[] | v1AddressFormat[];
845
- organizationId?: string;
846
- mnemonicLength?: number;
847
- stampWith?: StamperType | undefined;
848
- }) => Promise<string>;
730
+ createWallet: (params: CreateWalletParams) => Promise<string>;
849
731
  /**
850
732
  * Creates new accounts in the specified wallet.
851
733
  *
@@ -863,12 +745,7 @@ export declare class TurnkeyClient {
863
745
  * @returns A promise that resolves to an array of addresses for the newly created accounts.
864
746
  * @throws {TurnkeyError} If there is no active session, if the wallet does not exist, or if there is an error creating the wallet accounts.
865
747
  */
866
- createWalletAccounts: (params: {
867
- accounts: v1WalletAccountParams[] | v1AddressFormat[];
868
- walletId: string;
869
- organizationId?: string;
870
- stampWith?: StamperType | undefined;
871
- }) => Promise<string[]>;
748
+ createWalletAccounts: (params: CreateWalletAccountsParams) => Promise<string[]>;
872
749
  /**
873
750
  * Exports a wallet as an encrypted bundle.
874
751
  *
@@ -886,12 +763,7 @@ export declare class TurnkeyClient {
886
763
  * @returns A promise that resolves to an `ExportBundle` object containing the encrypted wallet seed phrase and metadata.
887
764
  * @throws {TurnkeyError} If there is no active session, if the targetPublicKey is missing, or if there is an error exporting the wallet.
888
765
  */
889
- exportWallet: (params: {
890
- walletId: string;
891
- targetPublicKey: string;
892
- organizationId?: string;
893
- stampWith?: StamperType | undefined;
894
- }) => Promise<ExportBundle>;
766
+ exportWallet: (params: ExportWalletParams) => Promise<ExportBundle>;
895
767
  /**
896
768
  * Exports a private key as an encrypted bundle.
897
769
  *
@@ -908,12 +780,7 @@ export declare class TurnkeyClient {
908
780
  * @returns A promise that resolves to an `ExportBundle` object containing the encrypted private key and metadata.
909
781
  * @throws {TurnkeyError} If there is no active session, if the targetPublicKey is missing, or if there is an error exporting the private key.
910
782
  */
911
- exportPrivateKey: (params: {
912
- privateKeyId: string;
913
- targetPublicKey: string;
914
- organizationId?: string;
915
- stampWith?: StamperType | undefined;
916
- }) => Promise<ExportBundle>;
783
+ exportPrivateKey: (params: ExportPrivateKeyParams) => Promise<ExportBundle>;
917
784
  /**
918
785
  * Exports a wallet account as an encrypted bundle.
919
786
  *
@@ -931,12 +798,7 @@ export declare class TurnkeyClient {
931
798
  * @throws {TurnkeyError} If there is no active session, if the targetPublicKey is missing, or if there is an error exporting the wallet account.
932
799
  *
933
800
  */
934
- exportWalletAccount: (params: {
935
- address: string;
936
- targetPublicKey: string;
937
- organizationId?: string;
938
- stampWith?: StamperType | undefined;
939
- }) => Promise<ExportBundle>;
801
+ exportWalletAccount: (params: ExportWalletAccountParams) => Promise<ExportBundle>;
940
802
  /**
941
803
  * Imports a wallet from an encrypted bundle.
942
804
  *
@@ -950,18 +812,13 @@ export declare class TurnkeyClient {
950
812
  * @param params.encryptedBundle - encrypted bundle containing the wallet seed phrase and metadata.
951
813
  * @param params.walletName - name of the wallet to create upon import.
952
814
  * @param params.accounts - array of account parameters to create in the imported wallet (defaults to standard Ethereum and Solana accounts).
815
+ * @param params.organizationId - organization ID to import the wallet under a specific sub-organization (wallet will be associated with the sub-organization).
953
816
  * @param params.userId - user ID to import the wallet for a specific user (defaults to the current session's userId).
954
817
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
955
818
  * @returns A promise that resolves to the ID of the imported wallet.
956
819
  * @throws {TurnkeyError} If there is no active session, if the encrypted bundle is invalid, or if there is an error importing the wallet.
957
820
  */
958
- importWallet: (params: {
959
- encryptedBundle: string;
960
- walletName: string;
961
- accounts?: v1WalletAccountParams[];
962
- userId?: string;
963
- stampWith?: StamperType | undefined;
964
- }) => Promise<string>;
821
+ importWallet: (params: ImportWalletParams) => Promise<string>;
965
822
  /**
966
823
  * Imports a private key from an encrypted bundle.
967
824
  *
@@ -977,19 +834,13 @@ export declare class TurnkeyClient {
977
834
  * @param params.privateKeyName - name of the private key to create upon import.
978
835
  * @param params.curve - the cryptographic curve used to generate a given private key
979
836
  * @param params.addressFormat - address format of the private key to import.
837
+ * @param params.organizationId - organization ID to import the private key under a specific sub-organization (private key will be associated with the sub-organization).
980
838
  * @param params.userId - user ID to import the wallet for a specific user (defaults to the current session's userId).
981
839
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
982
840
  * @returns A promise that resolves to the ID of the imported wallet.
983
841
  * @throws {TurnkeyError} If there is no active session, if the encrypted bundle is invalid, or if there is an error importing the wallet.
984
842
  */
985
- importPrivateKey: (params: {
986
- encryptedBundle: string;
987
- privateKeyName: string;
988
- curve: v1Curve;
989
- addressFormats: v1AddressFormat[];
990
- userId?: string;
991
- stampWith?: StamperType | undefined;
992
- }) => Promise<string>;
843
+ importPrivateKey: (params: ImportPrivateKeyParams) => Promise<string>;
993
844
  /**
994
845
  * Deletes the current sub-organization (sub-org) for the active session.
995
846
  *
@@ -1000,14 +851,12 @@ export declare class TurnkeyClient {
1000
851
  * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
1001
852
  *
1002
853
  * @param params.deleteWithoutExport - flag to delete the sub-organization without requiring all wallets to be exported first (defaults to false).
854
+ * @param params.organizationId - organization ID to delete a specific sub-organization (defaults to the current session's organizationId).
1003
855
  * @param params.stampWith - parameter to stamp the request with a specific stamper.
1004
856
  * @returns A promise that resolves to a `TDeleteSubOrganizationResponse` object containing the result of the deletion.
1005
857
  * @throws {TurnkeyError} If there is no active session or if there is an error deleting the sub-organization.
1006
858
  */
1007
- deleteSubOrganization: (params?: {
1008
- deleteWithoutExport?: boolean;
1009
- stampWith?: StamperType | undefined;
1010
- }) => Promise<TDeleteSubOrganizationResponse>;
859
+ deleteSubOrganization: (params?: DeleteSubOrganizationParams) => Promise<TDeleteSubOrganizationResponse>;
1011
860
  /**
1012
861
  * Stores a session token and updates the session associated with the specified session key, or by default the active session.
1013
862
  *
@@ -1022,10 +871,7 @@ export declare class TurnkeyClient {
1022
871
  * @returns A promise that resolves when the session is successfully stored.
1023
872
  * @throws {TurnkeyError} If there is an error storing the session or cleaning up key pairs.
1024
873
  */
1025
- storeSession: (params: {
1026
- sessionToken: string;
1027
- sessionKey?: string;
1028
- }) => Promise<void>;
874
+ storeSession: (params: StoreSessionParams) => Promise<void>;
1029
875
  /**
1030
876
  * Clears the session associated with the specified session key, or the active session by default.
1031
877
  *
@@ -1038,9 +884,7 @@ export declare class TurnkeyClient {
1038
884
  * @returns A promise that resolves when the session is successfully cleared.
1039
885
  * @throws {TurnkeyError} If the session does not exist or if there is an error clearing the session.
1040
886
  */
1041
- clearSession: (params?: {
1042
- sessionKey?: string;
1043
- }) => Promise<void>;
887
+ clearSession: (params?: ClearSessionParams) => Promise<void>;
1044
888
  /**
1045
889
  * Clears all sessions and resets the active session state.
1046
890
  *
@@ -1071,13 +915,7 @@ export declare class TurnkeyClient {
1071
915
  * @returns A promise that resolves to a `TStampLoginResponse` object containing the refreshed session details.
1072
916
  * @throws {TurnkeyError} If the session key does not exist, if there is no active session, or if there is an error refreshing the session.
1073
917
  */
1074
- refreshSession: (params?: {
1075
- expirationSeconds?: string;
1076
- publicKey?: string;
1077
- sessionKey?: string;
1078
- invalidateExisitng?: boolean;
1079
- stampWith?: StamperType | undefined;
1080
- }) => Promise<TStampLoginResponse | undefined>;
918
+ refreshSession: (params?: RefreshSessionParams) => Promise<TStampLoginResponse | undefined>;
1081
919
  /**
1082
920
  * Retrieves the session associated with the specified session key, or the active session by default.
1083
921
  *
@@ -1089,9 +927,7 @@ export declare class TurnkeyClient {
1089
927
  * @returns A promise that resolves to a `Session` object containing the session details, or undefined if not found.
1090
928
  * @throws {TurnkeyError} If there is an error retrieving the session from storage.
1091
929
  */
1092
- getSession: (params?: {
1093
- sessionKey?: string;
1094
- }) => Promise<Session | undefined>;
930
+ getSession: (params?: GetSessionParams) => Promise<Session | undefined>;
1095
931
  /**
1096
932
  * Retrieves all sessions stored in persistent storage.
1097
933
  *
@@ -1116,9 +952,7 @@ export declare class TurnkeyClient {
1116
952
  * @returns A promise that resolves when the active session key is successfully set.
1117
953
  * @throws {TurnkeyError} If the client is not initialized or if there is an error setting the active session key.
1118
954
  */
1119
- setActiveSession: (params: {
1120
- sessionKey: string;
1121
- }) => Promise<void>;
955
+ setActiveSession: (params: SetActiveSessionParams) => Promise<void>;
1122
956
  /**
1123
957
  * Retrieves the active session key currently set in persistent storage.
1124
958
  *
@@ -1157,13 +991,7 @@ export declare class TurnkeyClient {
1157
991
  * @returnparams.s A promise that resolves to the public key of the created or provided API key pair as a string.
1158
992
  * @throws {TurnkeyError} If the API key stamper is not initialized or if there is an error during key pair creation or storage.
1159
993
  */
1160
- createApiKeyPair: (params?: {
1161
- externalKeyPair?: CryptoKeyPair | {
1162
- publicKey: string;
1163
- privateKey: string;
1164
- };
1165
- storeOverride?: boolean;
1166
- }) => Promise<string>;
994
+ createApiKeyPair: (params?: CreateApiKeyPairParams) => Promise<string>;
1167
995
  /**
1168
996
  * Fetches the WalletKit proxy authentication configuration from the auth proxy.
1169
997
  *