@turnkey/core 1.0.0-beta.6 → 1.1.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.
Files changed (156) hide show
  1. package/README.MD +3 -1
  2. package/dist/__clients__/core.d.ts +196 -324
  3. package/dist/__clients__/core.d.ts.map +1 -1
  4. package/dist/__clients__/core.js +571 -271
  5. package/dist/__clients__/core.js.map +1 -1
  6. package/dist/__clients__/core.mjs +522 -222
  7. package/dist/__clients__/core.mjs.map +1 -1
  8. package/dist/__generated__/sdk-client-base.d.ts +8 -2
  9. package/dist/__generated__/sdk-client-base.d.ts.map +1 -1
  10. package/dist/__generated__/sdk-client-base.js +95 -6
  11. package/dist/__generated__/sdk-client-base.js.map +1 -1
  12. package/dist/__generated__/sdk-client-base.mjs +90 -1
  13. package/dist/__generated__/sdk-client-base.mjs.map +1 -1
  14. package/dist/__generated__/version.d.ts +1 -1
  15. package/dist/__generated__/version.d.ts.map +1 -1
  16. package/dist/__generated__/version.js +1 -1
  17. package/dist/__generated__/version.mjs +1 -1
  18. package/dist/__inputs__/public_api.types.d.ts +163 -26
  19. package/dist/__inputs__/public_api.types.d.ts.map +1 -1
  20. package/dist/__polyfills__/window.js.map +1 -1
  21. package/dist/__polyfills__/window.mjs.map +1 -1
  22. package/dist/__stampers__/api/base.d.ts +1 -1
  23. package/dist/__stampers__/api/base.d.ts.map +1 -1
  24. package/dist/__stampers__/api/base.js.map +1 -1
  25. package/dist/__stampers__/api/base.mjs.map +1 -1
  26. package/dist/__stampers__/api/mobile/stamper.d.ts +1 -1
  27. package/dist/__stampers__/api/mobile/stamper.d.ts.map +1 -1
  28. package/dist/__stampers__/api/mobile/stamper.js.map +1 -1
  29. package/dist/__stampers__/api/mobile/stamper.mjs.map +1 -1
  30. package/dist/__stampers__/api/web/stamper.d.ts +1 -1
  31. package/dist/__stampers__/api/web/stamper.d.ts.map +1 -1
  32. package/dist/__stampers__/api/web/stamper.js.map +1 -1
  33. package/dist/__stampers__/api/web/stamper.mjs.map +1 -1
  34. package/dist/__stampers__/passkey/base.d.ts +1 -1
  35. package/dist/__stampers__/passkey/base.d.ts.map +1 -1
  36. package/dist/__stampers__/passkey/base.js.map +1 -1
  37. package/dist/__stampers__/passkey/base.mjs.map +1 -1
  38. package/dist/__storage__/base.d.ts +1 -1
  39. package/dist/__storage__/base.d.ts.map +1 -1
  40. package/dist/__storage__/base.js.map +1 -1
  41. package/dist/__storage__/base.mjs.map +1 -1
  42. package/dist/__storage__/mobile/storage.d.ts +1 -1
  43. package/dist/__storage__/mobile/storage.d.ts.map +1 -1
  44. package/dist/__storage__/mobile/storage.js +4 -3
  45. package/dist/__storage__/mobile/storage.js.map +1 -1
  46. package/dist/__storage__/mobile/storage.mjs +2 -1
  47. package/dist/__storage__/mobile/storage.mjs.map +1 -1
  48. package/dist/__storage__/web/storage.d.ts +1 -1
  49. package/dist/__storage__/web/storage.d.ts.map +1 -1
  50. package/dist/__storage__/web/storage.js +4 -3
  51. package/dist/__storage__/web/storage.js.map +1 -1
  52. package/dist/__storage__/web/storage.mjs +2 -1
  53. package/dist/__storage__/web/storage.mjs.map +1 -1
  54. package/dist/__typedoc-entry__/index.d.ts +3 -0
  55. package/dist/__typedoc-entry__/index.d.ts.map +1 -0
  56. package/dist/__types__/auth.d.ts +150 -0
  57. package/dist/__types__/auth.d.ts.map +1 -0
  58. package/dist/__types__/auth.js +43 -0
  59. package/dist/__types__/auth.js.map +1 -0
  60. package/dist/__types__/auth.mjs +40 -0
  61. package/dist/__types__/auth.mjs.map +1 -0
  62. package/dist/__types__/config.d.ts +140 -0
  63. package/dist/__types__/config.d.ts.map +1 -0
  64. package/dist/__types__/error.d.ts +13 -0
  65. package/dist/__types__/error.d.ts.map +1 -0
  66. package/dist/__types__/error.js +18 -0
  67. package/dist/__types__/error.js.map +1 -0
  68. package/dist/__types__/error.mjs +16 -0
  69. package/dist/__types__/error.mjs.map +1 -0
  70. package/dist/__types__/export.d.ts +10 -0
  71. package/dist/__types__/export.d.ts.map +1 -0
  72. package/dist/__types__/external-wallets.d.ts +202 -0
  73. package/dist/__types__/external-wallets.d.ts.map +1 -0
  74. package/dist/__types__/external-wallets.js +35 -0
  75. package/dist/__types__/external-wallets.js.map +1 -0
  76. package/dist/__types__/external-wallets.mjs +35 -0
  77. package/dist/__types__/external-wallets.mjs.map +1 -0
  78. package/dist/__types__/index.d.ts +7 -0
  79. package/dist/__types__/index.d.ts.map +1 -0
  80. package/dist/__types__/method-types.d.ts +314 -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 +6 -6
  85. package/dist/__wallet__/base.js.map +1 -1
  86. package/dist/__wallet__/base.mjs +2 -2
  87. package/dist/__wallet__/base.mjs.map +1 -1
  88. package/dist/__wallet__/connector.d.ts +3 -3
  89. package/dist/__wallet__/connector.d.ts.map +1 -1
  90. package/dist/__wallet__/connector.js +5 -4
  91. package/dist/__wallet__/connector.js.map +1 -1
  92. package/dist/__wallet__/connector.mjs +4 -3
  93. package/dist/__wallet__/connector.mjs.map +1 -1
  94. package/dist/__wallet__/mobile/manager.d.ts +1 -1
  95. package/dist/__wallet__/mobile/manager.d.ts.map +1 -1
  96. package/dist/__wallet__/mobile/manager.js +5 -4
  97. package/dist/__wallet__/mobile/manager.js.map +1 -1
  98. package/dist/__wallet__/mobile/manager.mjs +2 -1
  99. package/dist/__wallet__/mobile/manager.mjs.map +1 -1
  100. package/dist/__wallet__/stamper.d.ts +1 -1
  101. package/dist/__wallet__/stamper.d.ts.map +1 -1
  102. package/dist/__wallet__/stamper.js +9 -8
  103. package/dist/__wallet__/stamper.js.map +1 -1
  104. package/dist/__wallet__/stamper.mjs +2 -1
  105. package/dist/__wallet__/stamper.mjs.map +1 -1
  106. package/dist/__wallet__/wallet-connect/base.d.ts +4 -2
  107. package/dist/__wallet__/wallet-connect/base.d.ts.map +1 -1
  108. package/dist/__wallet__/wallet-connect/base.js +74 -32
  109. package/dist/__wallet__/wallet-connect/base.js.map +1 -1
  110. package/dist/__wallet__/wallet-connect/base.mjs +55 -13
  111. package/dist/__wallet__/wallet-connect/base.mjs.map +1 -1
  112. package/dist/__wallet__/wallet-connect/client.d.ts +30 -9
  113. package/dist/__wallet__/wallet-connect/client.d.ts.map +1 -1
  114. package/dist/__wallet__/wallet-connect/client.js +73 -11
  115. package/dist/__wallet__/wallet-connect/client.js.map +1 -1
  116. package/dist/__wallet__/wallet-connect/client.mjs +73 -11
  117. package/dist/__wallet__/wallet-connect/client.mjs.map +1 -1
  118. package/dist/__wallet__/web/manager.d.ts +1 -1
  119. package/dist/__wallet__/web/manager.d.ts.map +1 -1
  120. package/dist/__wallet__/web/manager.js +11 -10
  121. package/dist/__wallet__/web/manager.js.map +1 -1
  122. package/dist/__wallet__/web/manager.mjs +2 -1
  123. package/dist/__wallet__/web/manager.mjs.map +1 -1
  124. package/dist/__wallet__/web/native/ethereum.d.ts +3 -3
  125. package/dist/__wallet__/web/native/ethereum.d.ts.map +1 -1
  126. package/dist/__wallet__/web/native/ethereum.js +11 -10
  127. package/dist/__wallet__/web/native/ethereum.js.map +1 -1
  128. package/dist/__wallet__/web/native/ethereum.mjs +4 -3
  129. package/dist/__wallet__/web/native/ethereum.mjs.map +1 -1
  130. package/dist/__wallet__/web/native/solana.d.ts +3 -3
  131. package/dist/__wallet__/web/native/solana.d.ts.map +1 -1
  132. package/dist/__wallet__/web/native/solana.js +13 -13
  133. package/dist/__wallet__/web/native/solana.js.map +1 -1
  134. package/dist/__wallet__/web/native/solana.mjs +8 -8
  135. package/dist/__wallet__/web/native/solana.mjs.map +1 -1
  136. package/dist/index.d.ts +2 -1
  137. package/dist/index.d.ts.map +1 -1
  138. package/dist/index.js +29 -21
  139. package/dist/index.js.map +1 -1
  140. package/dist/index.mjs +4 -2
  141. package/dist/index.mjs.map +1 -1
  142. package/dist/turnkey-helpers.js.map +1 -1
  143. package/dist/turnkey-helpers.mjs.map +1 -1
  144. package/dist/utils.d.ts +11 -23
  145. package/dist/utils.d.ts.map +1 -1
  146. package/dist/utils.js +120 -45
  147. package/dist/utils.js.map +1 -1
  148. package/dist/utils.mjs +102 -30
  149. package/dist/utils.mjs.map +1 -1
  150. package/package.json +8 -9
  151. package/dist/__types__/base.d.ts +0 -527
  152. package/dist/__types__/base.d.ts.map +0 -1
  153. package/dist/__types__/base.js +0 -89
  154. package/dist/__types__/base.js.map +0 -1
  155. package/dist/__types__/base.mjs +0 -85
  156. 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 } 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
  *
@@ -112,17 +99,17 @@ export declare class TurnkeyClient {
112
99
  * @returns A promise that resolves to an array of wallet providers.
113
100
  * @throws {TurnkeyError} If the wallet manager is uninitialized or provider retrieval fails.
114
101
  */
115
- getWalletProviders: (chain?: Chain) => Promise<WalletProvider[]>;
102
+ fetchWalletProviders: (chain?: Chain) => Promise<WalletProvider[]>;
116
103
  /**
117
104
  * Connects the specified wallet account.
118
105
  *
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
  *
@@ -144,16 +131,12 @@ export declare class TurnkeyClient {
144
131
  *
145
132
  * @param params.walletAccount - The wallet account whose provider should be switched.
146
133
  * @param params.chainOrId - The target chain, specified as a chain ID string or a SwitchableChain object.
147
- * @param params.walletProviders - Optional list of wallet providers to search; falls back to `getWalletProviders()` if omitted.
134
+ * @param params.walletProviders - Optional list of wallet providers to search; falls back to `fetchWalletProviders()` if omitted.
148
135
  * @returns A promise that resolves once the chain switch is complete.
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
  *
@@ -289,12 +250,7 @@ export declare class TurnkeyClient {
289
250
  * - `sessionToken`: the signed JWT session token.
290
251
  * @throws {TurnkeyError} If there is an error during the OTP login process or if key pair cleanup fails.
291
252
  */
292
- loginWithOtp: (params: {
293
- verificationToken: string;
294
- publicKey?: string;
295
- invalidateExisting?: boolean;
296
- sessionKey?: string;
297
- }) => Promise<BaseAuthResult>;
253
+ loginWithOtp: (params: LoginWithOtpParams) => Promise<BaseAuthResult>;
298
254
  /**
299
255
  * Signs up a user using an OTP verification token.
300
256
  *
@@ -314,14 +270,7 @@ export declare class TurnkeyClient {
314
270
  * - `sessionToken`: the signed JWT session token.
315
271
  * @throws {TurnkeyError} If there is an error during the OTP sign-up process or session storage.
316
272
  */
317
- signUpWithOtp: (params: {
318
- verificationToken: string;
319
- contact: string;
320
- otpType: OtpType;
321
- createSubOrgParams?: CreateSubOrgParams;
322
- invalidateExisting?: boolean;
323
- sessionKey?: string;
324
- }) => Promise<BaseAuthResult>;
273
+ signUpWithOtp: (params: SignUpWithOtpParams) => Promise<BaseAuthResult>;
325
274
  /**
326
275
  * Completes the OTP authentication flow by verifying the OTP code and then either signing up or logging in the user.
327
276
  *
@@ -345,16 +294,7 @@ export declare class TurnkeyClient {
345
294
  * - `action`: whether the flow resulted in a login or signup ({@link AuthAction}).
346
295
  * @throws {TurnkeyError} If there is an error during OTP verification, sign-up, or login.
347
296
  */
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 & {
297
+ completeOtp: (params: CompleteOtpParams) => Promise<BaseAuthResult & {
358
298
  verificationToken: string;
359
299
  action: AuthAction;
360
300
  }>;
@@ -378,14 +318,7 @@ export declare class TurnkeyClient {
378
318
  * - `action`: whether the flow resulted in a login or signup ({@link AuthAction}).
379
319
  * @throws {TurnkeyError} If there is an error during the OAuth completion process, such as account lookup, sign-up, or login.
380
320
  */
381
- completeOauth: (params: {
382
- oidcToken: string;
383
- publicKey: string;
384
- providerName?: string;
385
- sessionKey?: string;
386
- invalidateExisting?: boolean;
387
- createSubOrgParams?: CreateSubOrgParams;
388
- }) => Promise<BaseAuthResult & {
321
+ completeOauth: (params: CompleteOauthParams) => Promise<BaseAuthResult & {
389
322
  action: AuthAction;
390
323
  }>;
391
324
  /**
@@ -404,12 +337,7 @@ export declare class TurnkeyClient {
404
337
  * - `sessionToken`: the signed JWT session token.
405
338
  * @throws {TurnkeyError} If there is an error during the OAuth login process or if key pair cleanup fails.
406
339
  */
407
- loginWithOauth: (params: {
408
- oidcToken: string;
409
- publicKey: string;
410
- invalidateExisting?: boolean;
411
- sessionKey?: string;
412
- }) => Promise<BaseAuthResult>;
340
+ loginWithOauth: (params: LoginWithOauthParams) => Promise<BaseAuthResult>;
413
341
  /**
414
342
  * Signs up a user using OAuth authentication.
415
343
  *
@@ -427,13 +355,7 @@ export declare class TurnkeyClient {
427
355
  * - `sessionToken`: the signed JWT session token.
428
356
  * @throws {TurnkeyError} If there is an error during the OAuth sign-up or login process.
429
357
  */
430
- signUpWithOauth: (params: {
431
- oidcToken: string;
432
- publicKey: string;
433
- providerName: string;
434
- createSubOrgParams?: CreateSubOrgParams;
435
- sessionKey?: string;
436
- }) => Promise<BaseAuthResult>;
358
+ signUpWithOauth: (params: SignUpWithOauthParams) => Promise<BaseAuthResult>;
437
359
  /**
438
360
  * Fetches all wallets for the current user, including both embedded and connected wallets.
439
361
  *
@@ -443,15 +365,15 @@ export declare class TurnkeyClient {
443
365
  * - Returns both embedded and connected wallets in a single array, each with their respective accounts populated.
444
366
  * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
445
367
  *
446
- * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
447
368
  * @param params.walletProviders - array of wallet providers to use for fetching wallets.
369
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
370
+ * @param params.userId - user ID to target (defaults to the session's user ID).
371
+ * @param params.connectedOnly - if true, fetches only connected wallets; if false or undefined, fetches both embedded and connected wallets.
372
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
448
373
  * @returns A promise that resolves to an array of `Wallet` objects.
449
374
  * @throws {TurnkeyError} If no active session is found or if there is an error fetching wallets.
450
375
  */
451
- fetchWallets: (params?: {
452
- walletProviders?: WalletProvider[] | undefined;
453
- stampWith?: StamperType | undefined;
454
- }) => Promise<Wallet[]>;
376
+ fetchWallets: (params?: FetchWalletsParams) => Promise<Wallet[]>;
455
377
  /**
456
378
  * Fetches all accounts for a specific wallet, including both embedded and connected wallet accounts.
457
379
  *
@@ -465,15 +387,13 @@ export declare class TurnkeyClient {
465
387
  * @param params.walletProviders - list of wallet providers to filter by (used for connected wallets).
466
388
  * @param params.paginationOptions - pagination options for embedded wallets.
467
389
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
390
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
391
+ * @param params.userId - user ID to target (defaults to the session's user ID).
392
+ *
468
393
  * @returns A promise that resolves to an array of `v1WalletAccount` objects.
469
394
  * @throws {TurnkeyError} If no active session is found or if there is an error fetching wallet accounts.
470
395
  */
471
- fetchWalletAccounts: (params: {
472
- wallet: Wallet;
473
- walletProviders?: WalletProvider[];
474
- paginationOptions?: v1Pagination;
475
- stampWith?: StamperType | undefined;
476
- }) => Promise<WalletAccount[]>;
396
+ fetchWalletAccounts: (params: FetchWalletAccountsParams) => Promise<WalletAccount[]>;
477
397
  /**
478
398
  * Fetches all private keys for the current user.
479
399
  *
@@ -481,97 +401,103 @@ export declare class TurnkeyClient {
481
401
  * - Supports stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
482
402
  *
483
403
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
404
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
484
405
  * @returns A promise that resolves to an array of `v1PrivateKey` objects.
485
406
  * @throws {TurnkeyError} If no active session is found or if there is an error fetching private keys.
486
407
  */
487
- fetchPrivateKeys: (params?: {
488
- stampWith?: StamperType | undefined;
489
- }) => Promise<v1PrivateKey[]>;
408
+ fetchPrivateKeys: (params?: FetchPrivateKeysParams) => Promise<v1PrivateKey[]>;
490
409
  /**
491
410
  * Signs a message using the specified wallet account.
492
411
  *
493
- * - Supports both embedded and connected wallets.
494
- * - For **connected wallets**:
412
+ * Behavior differs depending on the wallet type:
413
+ *
414
+ * - **Connected wallets**
495
415
  * - 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,
416
+ * - *Ethereum*: signatures always follow [EIP-191](https://eips.ethereum.org/EIPS/eip-191).
417
+ * - The wallet automatically prefixes messages with
418
+ * `"\x19Ethereum Signed Message:\n" + message length` before signing.
419
+ * - As a result, these signatures cannot be used as raw transaction signatures or broadcast on-chain.
420
+ * - If `addEthereumPrefix` is set to `false`, an error is thrown because connected Ethereum wallets always prefix.
421
+ * - *Other chains*: follows the native connected wallet behavior.
422
+ *
423
+ * - **Embedded wallets**
424
+ * - Uses the Turnkey API to sign the message directly.
425
+ * - Supports optional `addEthereumPrefix`:
426
+ * - If `true` (default for Ethereum), the message is prefixed before signing.
427
+ * - If `false`, the raw message is signed without any prefix.
428
+ *
429
+ * Additional details:
430
+ * - Automatically handles encoding and hashing based on the wallet account’s address format,
502
431
  * unless explicitly overridden.
432
+ * - Optionally allows stamping with a specific stamper
433
+ * (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
503
434
  *
504
- * @param params.message - message to sign.
435
+ * @param params.message - plaintext (UTF-8) message to sign.
505
436
  * @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.
437
+ * @param params.encoding - override for payload encoding (defaults to the encoding appropriate for the address format).
438
+ * @param params.hashFunction - override for hash function (defaults to the function appropriate for the address format).
439
+ * @param params.stampWith - optional stamper for the signing request.
440
+ * @param params.addEthereumPrefix - whether to prefix the message with Ethereums
441
+ * `"\x19Ethereum Signed Message:\n"` string (default: `true` for Ethereum).
442
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
443
+ *
444
+ * @returns A promise that resolves to a `v1SignRawPayloadResult` containing the signature and metadata.
445
+ * @throws {TurnkeyError} If signing fails, the wallet type does not support message signing, or the response is invalid.
517
446
  */
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>;
447
+ signMessage: (params: SignMessageParams) => Promise<v1SignRawPayloadResult>;
526
448
  /**
527
449
  * Signs a transaction using the specified wallet account.
528
450
  *
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).
451
+ * Behavior differs depending on the type of wallet:
452
+ *
453
+ * - **Connected wallets**
454
+ * - Ethereum: does not support raw transaction signing. Calling this function will throw an error instructing you to use `signAndSendTransaction` instead.
455
+ * - Solana: supports raw transaction signing via the connected wallet provider.
456
+ * - Other chains: not supported; will throw an error.
457
+ *
458
+ * - **Embedded wallets**
459
+ * - Delegates signing to the Turnkey API, which returns the signed transaction.
460
+ * - Supports all Turnkey-supported transaction types (e.g., Ethereum, Solana, Tron).
461
+ * - Optionally allows stamping with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
534
462
  *
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.
463
+ * @param params.walletAccount - wallet account to use for signing.
464
+ * @param params.unsignedTransaction - unsigned transaction data as a serialized
465
+ * string in the canonical encoding for the given `transactionType`.
537
466
  * @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.
467
+ * @param params.stampWith - stamper to use for signing (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
468
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
469
+ * @returns A promise that resolves to the signed transaction string.
470
+ * @throws {TurnkeyError} If the wallet type is unsupported, signing fails, or the response is invalid.
541
471
  */
542
- signTransaction: (params: {
543
- unsignedTransaction: string;
544
- transactionType: v1TransactionType;
545
- walletAccount: WalletAccount;
546
- stampWith?: StamperType | undefined;
547
- }) => Promise<string>;
472
+ signTransaction: (params: SignTransactionParams) => Promise<string>;
548
473
  /**
549
474
  * Signs and broadcasts a transaction using the specified wallet account.
550
475
  *
551
- * - For **connected wallets**:
552
- * - Calls the wallet’s native `signAndSendTransaction` method.
553
- * - Does **not** require an `rpcUrl`.
476
+ * Behavior differs depending on the type of wallet:
554
477
  *
555
- * - For **embedded wallets**:
478
+ * - **Connected wallets**
479
+ * - *Ethereum*: delegates to the wallet’s native `signAndSendTransaction` method.
480
+ * - Does **not** require an `rpcUrl` (the wallet handles broadcasting).
481
+ * - *Solana*: signs the transaction locally with the connected wallet, but requires an `rpcUrl` to broadcast it.
482
+ * - Other chains: not supported; will throw an error.
483
+ *
484
+ * - **Embedded wallets**
556
485
  * - 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.
486
+ * - Requires an `rpcUrl` to broadcast the signed transaction, since Turnkey does not broadcast directly.
487
+ * - Broadcasts the transaction using a JSON-RPC client and returns the resulting transaction hash/signature.
488
+ * - Optionally allows stamping with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
489
+ *
490
+ * @param params.walletAccount - wallet account to use for signing and broadcasting.
491
+ * @param params.unsignedTransaction - unsigned transaction data as a serialized
492
+ * string in the canonical encoding for the given `transactionType`.
493
+ * @param params.transactionType - type of transaction (e.g., `"TRANSACTION_TYPE_SOLANA"`, `"TRANSACTION_TYPE_ETHEREUM"`).
494
+ * @param params.rpcUrl - JSON-RPC endpoint used for broadcasting (required for Solana connected wallets and all embedded wallets).
495
+ * @param params.stampWith - optional stamper to use when signing (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
496
+ * @param params.organizationId - **Only for Turnkey embedded wallets**: organization ID to target (defaults to the session's organization ID).
565
497
  * @returns A promise that resolves to a transaction signature or hash.
566
- * @throws {TurnkeyError} If signing or broadcasting fails.
498
+ * @throws {TurnkeyError} If the wallet type is unsupported, or if signing/broadcasting fails.
567
499
  */
568
- signAndSendTransaction: (params: {
569
- unsignedTransaction: string;
570
- transactionType: v1TransactionType;
571
- walletAccount: WalletAccount;
572
- rpcUrl?: string;
573
- stampWith?: StamperType | undefined;
574
- }) => Promise<string>;
500
+ signAndSendTransaction: (params: SignAndSendTransactionParams) => Promise<string>;
575
501
  /**
576
502
  * Fetches the user details for the current session or a specified user.
577
503
  *
@@ -587,11 +513,46 @@ export declare class TurnkeyClient {
587
513
  * @returns A promise that resolves to a `v1User` object containing the user details.
588
514
  * @throws {TurnkeyError} If there is no active session, if there is no userId, or if there is an error fetching user details.
589
515
  */
590
- fetchUser: (params?: {
591
- organizationId?: string;
592
- userId?: string;
593
- stampWith?: StamperType | undefined;
594
- }) => Promise<v1User>;
516
+ fetchUser: (params?: FetchUserParams) => Promise<v1User>;
517
+ /**
518
+ * Fetches an existing user by P-256 API key public key, or creates a new one if none exists.
519
+ *
520
+ * - This function is idempotent: multiple calls with the same `publicKey` will always return the same user.
521
+ * - Attempts to find a user whose API keys include the given P-256 public key.
522
+ * - If a matching user is found, it is returned as-is.
523
+ * - If no matching user is found, a new user is created with the given public key as a P-256 API key.
524
+ *
525
+ * @param params.publicKey - the P-256 public key to use for lookup and creation.
526
+ * @param params.createParams.userName - optional username to assign if creating a new user (defaults to `"Public Key User"`).
527
+ * @param params.createParams.apiKeyName - optional API key name to assign if creating a new API key (defaults to `public-key-user-${publicKey}`).
528
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
529
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
530
+ * @returns A promise that resolves to the existing or newly created {@link v1User}.
531
+ * @throws {TurnkeyError} If there is no active session, if the input is invalid, if user retrieval fails, or if user creation fails.
532
+ */
533
+ fetchOrCreateP256ApiKeyUser: (params: FetchOrCreateP256ApiKeyUserParams) => Promise<v1User>;
534
+ /**
535
+ * Fetches each requested policy if it exists, or creates it if it does not.
536
+ *
537
+ * - This function is idempotent: multiple calls with the same policies will not create duplicates.
538
+ * - For every policy in the request:
539
+ * - If it already exists, it is returned with its `policyId`.
540
+ * - If it does not exist, it is created and returned with its new `policyId`.
541
+ *
542
+ * @param params.policies - the list of policies to fetch or create.
543
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
544
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
545
+ * @returns A promise that resolves to an array of objects, each containing:
546
+ * - `policyId`: the unique identifier of the policy.
547
+ * - `policyName`: human-readable name of the policy.
548
+ * - `effect`: the instruction to DENY or ALLOW an activity.
549
+ * - `condition`: (optional) the condition expression that triggers the effect.
550
+ * - `consensus`: (optional) the consensus expression that triggers the effect.
551
+ * - `notes`: (optional) developer notes or description for the policy.
552
+ * @throws {TurnkeyError} If there is no active session, if the input is invalid,
553
+ * if fetching policies fails, or if creating policies fails.
554
+ */
555
+ fetchOrCreatePolicies: (params: FetchOrCreatePoliciesParams) => Promise<FetchOrCreatePoliciesResult>;
595
556
  /**
596
557
  * Updates the user's email address.
597
558
  *
@@ -605,15 +566,11 @@ export declare class TurnkeyClient {
605
566
  * @param params.verificationToken - verification token from OTP email verification (required if verifying the email).
606
567
  * @param params.userId - user ID to update a specific user's email (defaults to the current session's userId).
607
568
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
569
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
608
570
  * @returns A promise that resolves to the userId of the updated user.
609
571
  * @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.
610
572
  */
611
- updateUserEmail: (params: {
612
- email: string;
613
- verificationToken?: string;
614
- userId?: string;
615
- stampWith?: StamperType | undefined;
616
- }) => Promise<string>;
573
+ updateUserEmail: (params: UpdateUserEmailParams) => Promise<string>;
617
574
  /**
618
575
  * Removes the user's email address.
619
576
  *
@@ -624,13 +581,11 @@ export declare class TurnkeyClient {
624
581
  *
625
582
  * @param params.userId - user ID to remove a specific user's email address (defaults to the current session's userId).
626
583
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
584
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
627
585
  * @returns A promise that resolves to the userId of the user whose email was removed.
628
586
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error removing the user email.
629
587
  */
630
- removeUserEmail: (params?: {
631
- userId?: string;
632
- stampWith?: StamperType | undefined;
633
- }) => Promise<string>;
588
+ removeUserEmail: (params?: RemoveUserEmailParams) => Promise<string>;
634
589
  /**
635
590
  * Updates the user's phone number.
636
591
  *
@@ -644,15 +599,11 @@ export declare class TurnkeyClient {
644
599
  * @param params.verificationToken - verification token from OTP phone verification (required if verifying the phone number).
645
600
  * @param params.userId - user ID to update a specific user's phone number (defaults to the current session's userId).
646
601
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
602
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
647
603
  * @returns A promise that resolves to the userId of the updated user.
648
604
  * @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.
649
605
  */
650
- updateUserPhoneNumber: (params: {
651
- phoneNumber: string;
652
- verificationToken?: string;
653
- userId?: string;
654
- stampWith?: StamperType | undefined;
655
- }) => Promise<string>;
606
+ updateUserPhoneNumber: (params: UpdateUserPhoneNumberParams) => Promise<string>;
656
607
  /**
657
608
  * Removes the user's phone number.
658
609
  *
@@ -663,13 +614,11 @@ export declare class TurnkeyClient {
663
614
  *
664
615
  * @param params.userId - user ID to remove a specific user's phone number (defaults to the current session's userId).
665
616
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
617
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
666
618
  * @returns A promise that resolves to the userId of the user whose phone number was removed.
667
619
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error removing the user phone number.
668
620
  */
669
- removeUserPhoneNumber: (params?: {
670
- userId?: string;
671
- stampWith?: StamperType | undefined;
672
- }) => Promise<string>;
621
+ removeUserPhoneNumber: (params?: RemoveUserPhoneNumberParams) => Promise<string>;
673
622
  /**
674
623
  * Updates the user's name.
675
624
  *
@@ -682,14 +631,11 @@ export declare class TurnkeyClient {
682
631
  * @param params.userName - new name to set for the user.
683
632
  * @param params.userId - user ID to update a specific user's name (defaults to the current session's userId).
684
633
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
634
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
685
635
  * @returns A promise that resolves to the userId of the updated user.
686
636
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error updating the user name.
687
637
  */
688
- updateUserName: (params: {
689
- userName: string;
690
- userId?: string;
691
- stampWith?: StamperType | undefined;
692
- }) => Promise<string>;
638
+ updateUserName: (params: UpdateUserNameParams) => Promise<string>;
693
639
  /**
694
640
  * Adds an OAuth provider to the user.
695
641
  *
@@ -702,17 +648,13 @@ export declare class TurnkeyClient {
702
648
  *
703
649
  * @param params.providerName - name of the OAuth provider to add (e.g., "Google", "Apple").
704
650
  * @param params.oidcToken - OIDC token for the OAuth provider.
651
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
705
652
  * @param params.userId - user ID to add the provider for a specific user (defaults to current session's userId).
706
653
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
707
654
  * @returns A promise that resolves to an array of provider IDs associated with the user.
708
655
  * @throws {TurnkeyError} If there is no active session, if the account already exists, or if there is an error adding the OAuth provider.
709
656
  */
710
- addOauthProvider: (params: {
711
- providerName: string;
712
- oidcToken: string;
713
- userId?: string;
714
- stampWith?: StamperType | undefined;
715
- }) => Promise<string[]>;
657
+ addOauthProvider: (params: AddOauthProviderParams) => Promise<string[]>;
716
658
  /**
717
659
  * Removes a list of OAuth providers from the user.
718
660
  *
@@ -725,14 +667,11 @@ export declare class TurnkeyClient {
725
667
  * @param params.providerIds - IDs of the OAuth providers to remove.
726
668
  * @param params.userId - user ID to remove the provider for a specific user (defaults to the current session's userId).
727
669
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
670
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
728
671
  * @returns A promise that resolves to an array of provider IDs that were removed.
729
672
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error removing the OAuth provider.
730
673
  */
731
- removeOauthProviders: (params: {
732
- providerIds: string[];
733
- userId?: string;
734
- stampWith?: StamperType | undefined;
735
- }) => Promise<string[]>;
674
+ removeOauthProviders: (params: RemoveOauthProvidersParams) => Promise<string[]>;
736
675
  /**
737
676
  * Adds a new passkey authenticator for the user.
738
677
  *
@@ -746,15 +685,11 @@ export declare class TurnkeyClient {
746
685
  * @param params.displayName - display name of the passkey (defaults to the value of `name`).
747
686
  * @param params.userId - user ID to add the passkey for a specific user (defaults to the current session's userId).
748
687
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
688
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
749
689
  * @returns A promise that resolves to an array of authenticator IDs for the newly added passkey(s).
750
690
  * @throws {TurnkeyError} If there is no active session, if passkey creation fails, or if there is an error adding the passkey.
751
691
  */
752
- addPasskey: (params?: {
753
- name?: string;
754
- displayName?: string;
755
- userId?: string;
756
- stampWith?: StamperType | undefined;
757
- }) => Promise<string[]>;
692
+ addPasskey: (params?: AddPasskeyParams) => Promise<string[]>;
758
693
  /**
759
694
  * Removes passkeys (authenticator) from the user.
760
695
  *
@@ -767,14 +702,11 @@ export declare class TurnkeyClient {
767
702
  * @param params.authenticatorIds - IDs of the authenticators (passkeys) to remove.
768
703
  * @param params.userId - user ID to remove the passkeys for a specific user (defaults to the current session's userId).
769
704
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
705
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
770
706
  * @returns A promise that resolves to an array of authenticator IDs that were removed.
771
707
  * @throws {TurnkeyError} If there is no active session, if the userId is missing, or if there is an error removing the passkeys.
772
708
  */
773
- removePasskeys: (params: {
774
- authenticatorIds: string[];
775
- userId?: string;
776
- stampWith?: StamperType | undefined;
777
- }) => Promise<string[]>;
709
+ removePasskeys: (params: RemovePasskeyParams) => Promise<string[]>;
778
710
  /**
779
711
  * Creates a new wallet for sub-organization.
780
712
  *
@@ -794,13 +726,7 @@ export declare class TurnkeyClient {
794
726
  * @returns A promise that resolves to the ID of the newly created wallet.
795
727
  * @throws {TurnkeyError} If there is no active session or if there is an error creating the wallet.
796
728
  */
797
- createWallet: (params: {
798
- walletName: string;
799
- accounts?: v1WalletAccountParams[] | v1AddressFormat[];
800
- organizationId?: string;
801
- mnemonicLength?: number;
802
- stampWith?: StamperType | undefined;
803
- }) => Promise<string>;
729
+ createWallet: (params: CreateWalletParams) => Promise<string>;
804
730
  /**
805
731
  * Creates new accounts in the specified wallet.
806
732
  *
@@ -818,12 +744,7 @@ export declare class TurnkeyClient {
818
744
  * @returns A promise that resolves to an array of addresses for the newly created accounts.
819
745
  * @throws {TurnkeyError} If there is no active session, if the wallet does not exist, or if there is an error creating the wallet accounts.
820
746
  */
821
- createWalletAccounts: (params: {
822
- accounts: v1WalletAccountParams[] | v1AddressFormat[];
823
- walletId: string;
824
- organizationId?: string;
825
- stampWith?: StamperType | undefined;
826
- }) => Promise<string[]>;
747
+ createWalletAccounts: (params: CreateWalletAccountsParams) => Promise<string[]>;
827
748
  /**
828
749
  * Exports a wallet as an encrypted bundle.
829
750
  *
@@ -841,12 +762,7 @@ export declare class TurnkeyClient {
841
762
  * @returns A promise that resolves to an `ExportBundle` object containing the encrypted wallet seed phrase and metadata.
842
763
  * @throws {TurnkeyError} If there is no active session, if the targetPublicKey is missing, or if there is an error exporting the wallet.
843
764
  */
844
- exportWallet: (params: {
845
- walletId: string;
846
- targetPublicKey: string;
847
- organizationId?: string;
848
- stampWith?: StamperType | undefined;
849
- }) => Promise<ExportBundle>;
765
+ exportWallet: (params: ExportWalletParams) => Promise<ExportBundle>;
850
766
  /**
851
767
  * Exports a private key as an encrypted bundle.
852
768
  *
@@ -863,12 +779,7 @@ export declare class TurnkeyClient {
863
779
  * @returns A promise that resolves to an `ExportBundle` object containing the encrypted private key and metadata.
864
780
  * @throws {TurnkeyError} If there is no active session, if the targetPublicKey is missing, or if there is an error exporting the private key.
865
781
  */
866
- exportPrivateKey: (params: {
867
- privateKeyId: string;
868
- targetPublicKey: string;
869
- organizationId?: string;
870
- stampWith?: StamperType | undefined;
871
- }) => Promise<ExportBundle>;
782
+ exportPrivateKey: (params: ExportPrivateKeyParams) => Promise<ExportBundle>;
872
783
  /**
873
784
  * Exports a wallet account as an encrypted bundle.
874
785
  *
@@ -886,12 +797,7 @@ export declare class TurnkeyClient {
886
797
  * @throws {TurnkeyError} If there is no active session, if the targetPublicKey is missing, or if there is an error exporting the wallet account.
887
798
  *
888
799
  */
889
- exportWalletAccount: (params: {
890
- address: string;
891
- targetPublicKey: string;
892
- organizationId?: string;
893
- stampWith?: StamperType | undefined;
894
- }) => Promise<ExportBundle>;
800
+ exportWalletAccount: (params: ExportWalletAccountParams) => Promise<ExportBundle>;
895
801
  /**
896
802
  * Imports a wallet from an encrypted bundle.
897
803
  *
@@ -905,18 +811,13 @@ export declare class TurnkeyClient {
905
811
  * @param params.encryptedBundle - encrypted bundle containing the wallet seed phrase and metadata.
906
812
  * @param params.walletName - name of the wallet to create upon import.
907
813
  * @param params.accounts - array of account parameters to create in the imported wallet (defaults to standard Ethereum and Solana accounts).
814
+ * @param params.organizationId - organization ID to import the wallet under a specific sub-organization (wallet will be associated with the sub-organization).
908
815
  * @param params.userId - user ID to import the wallet for a specific user (defaults to the current session's userId).
909
816
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
910
817
  * @returns A promise that resolves to the ID of the imported wallet.
911
818
  * @throws {TurnkeyError} If there is no active session, if the encrypted bundle is invalid, or if there is an error importing the wallet.
912
819
  */
913
- importWallet: (params: {
914
- encryptedBundle: string;
915
- walletName: string;
916
- accounts?: v1WalletAccountParams[];
917
- userId?: string;
918
- stampWith?: StamperType | undefined;
919
- }) => Promise<string>;
820
+ importWallet: (params: ImportWalletParams) => Promise<string>;
920
821
  /**
921
822
  * Imports a private key from an encrypted bundle.
922
823
  *
@@ -932,19 +833,13 @@ export declare class TurnkeyClient {
932
833
  * @param params.privateKeyName - name of the private key to create upon import.
933
834
  * @param params.curve - the cryptographic curve used to generate a given private key
934
835
  * @param params.addressFormat - address format of the private key to import.
836
+ * @param params.organizationId - organization ID to import the private key under a specific sub-organization (private key will be associated with the sub-organization).
935
837
  * @param params.userId - user ID to import the wallet for a specific user (defaults to the current session's userId).
936
838
  * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
937
839
  * @returns A promise that resolves to the ID of the imported wallet.
938
840
  * @throws {TurnkeyError} If there is no active session, if the encrypted bundle is invalid, or if there is an error importing the wallet.
939
841
  */
940
- importPrivateKey: (params: {
941
- encryptedBundle: string;
942
- privateKeyName: string;
943
- curve: v1Curve;
944
- addressFormats: v1AddressFormat[];
945
- userId?: string;
946
- stampWith?: StamperType | undefined;
947
- }) => Promise<string>;
842
+ importPrivateKey: (params: ImportPrivateKeyParams) => Promise<string>;
948
843
  /**
949
844
  * Deletes the current sub-organization (sub-org) for the active session.
950
845
  *
@@ -955,14 +850,12 @@ export declare class TurnkeyClient {
955
850
  * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
956
851
  *
957
852
  * @param params.deleteWithoutExport - flag to delete the sub-organization without requiring all wallets to be exported first (defaults to false).
853
+ * @param params.organizationId - organization ID to delete a specific sub-organization (defaults to the current session's organizationId).
958
854
  * @param params.stampWith - parameter to stamp the request with a specific stamper.
959
855
  * @returns A promise that resolves to a `TDeleteSubOrganizationResponse` object containing the result of the deletion.
960
856
  * @throws {TurnkeyError} If there is no active session or if there is an error deleting the sub-organization.
961
857
  */
962
- deleteSubOrganization: (params?: {
963
- deleteWithoutExport?: boolean;
964
- stampWith?: StamperType | undefined;
965
- }) => Promise<TDeleteSubOrganizationResponse>;
858
+ deleteSubOrganization: (params?: DeleteSubOrganizationParams) => Promise<TDeleteSubOrganizationResponse>;
966
859
  /**
967
860
  * Stores a session token and updates the session associated with the specified session key, or by default the active session.
968
861
  *
@@ -977,10 +870,7 @@ export declare class TurnkeyClient {
977
870
  * @returns A promise that resolves when the session is successfully stored.
978
871
  * @throws {TurnkeyError} If there is an error storing the session or cleaning up key pairs.
979
872
  */
980
- storeSession: (params: {
981
- sessionToken: string;
982
- sessionKey?: string;
983
- }) => Promise<void>;
873
+ storeSession: (params: StoreSessionParams) => Promise<void>;
984
874
  /**
985
875
  * Clears the session associated with the specified session key, or the active session by default.
986
876
  *
@@ -993,9 +883,7 @@ export declare class TurnkeyClient {
993
883
  * @returns A promise that resolves when the session is successfully cleared.
994
884
  * @throws {TurnkeyError} If the session does not exist or if there is an error clearing the session.
995
885
  */
996
- clearSession: (params?: {
997
- sessionKey?: string;
998
- }) => Promise<void>;
886
+ clearSession: (params?: ClearSessionParams) => Promise<void>;
999
887
  /**
1000
888
  * Clears all sessions and resets the active session state.
1001
889
  *
@@ -1026,13 +914,7 @@ export declare class TurnkeyClient {
1026
914
  * @returns A promise that resolves to a `TStampLoginResponse` object containing the refreshed session details.
1027
915
  * @throws {TurnkeyError} If the session key does not exist, if there is no active session, or if there is an error refreshing the session.
1028
916
  */
1029
- refreshSession: (params?: {
1030
- expirationSeconds?: string;
1031
- publicKey?: string;
1032
- sessionKey?: string;
1033
- invalidateExisitng?: boolean;
1034
- stampWith?: StamperType | undefined;
1035
- }) => Promise<TStampLoginResponse | undefined>;
917
+ refreshSession: (params?: RefreshSessionParams) => Promise<TStampLoginResponse | undefined>;
1036
918
  /**
1037
919
  * Retrieves the session associated with the specified session key, or the active session by default.
1038
920
  *
@@ -1044,9 +926,7 @@ export declare class TurnkeyClient {
1044
926
  * @returns A promise that resolves to a `Session` object containing the session details, or undefined if not found.
1045
927
  * @throws {TurnkeyError} If there is an error retrieving the session from storage.
1046
928
  */
1047
- getSession: (params?: {
1048
- sessionKey?: string;
1049
- }) => Promise<Session | undefined>;
929
+ getSession: (params?: GetSessionParams) => Promise<Session | undefined>;
1050
930
  /**
1051
931
  * Retrieves all sessions stored in persistent storage.
1052
932
  *
@@ -1071,9 +951,7 @@ export declare class TurnkeyClient {
1071
951
  * @returns A promise that resolves when the active session key is successfully set.
1072
952
  * @throws {TurnkeyError} If the client is not initialized or if there is an error setting the active session key.
1073
953
  */
1074
- setActiveSession: (params: {
1075
- sessionKey: string;
1076
- }) => Promise<void>;
954
+ setActiveSession: (params: SetActiveSessionParams) => Promise<void>;
1077
955
  /**
1078
956
  * Retrieves the active session key currently set in persistent storage.
1079
957
  *
@@ -1112,13 +990,7 @@ export declare class TurnkeyClient {
1112
990
  * @returnparams.s A promise that resolves to the public key of the created or provided API key pair as a string.
1113
991
  * @throws {TurnkeyError} If the API key stamper is not initialized or if there is an error during key pair creation or storage.
1114
992
  */
1115
- createApiKeyPair: (params?: {
1116
- externalKeyPair?: CryptoKeyPair | {
1117
- publicKey: string;
1118
- privateKey: string;
1119
- };
1120
- storeOverride?: boolean;
1121
- }) => Promise<string>;
993
+ createApiKeyPair: (params?: CreateApiKeyPairParams) => Promise<string>;
1122
994
  /**
1123
995
  * Fetches the WalletKit proxy authentication configuration from the auth proxy.
1124
996
  *