@0xkey-io/core 0.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 (183) hide show
  1. package/LICENSE +201 -0
  2. package/README.MD +7 -0
  3. package/dist/0xkey-helpers.d.ts +68 -0
  4. package/dist/0xkey-helpers.d.ts.map +1 -0
  5. package/dist/0xkey-helpers.js +466 -0
  6. package/dist/0xkey-helpers.js.map +1 -0
  7. package/dist/0xkey-helpers.mjs +399 -0
  8. package/dist/0xkey-helpers.mjs.map +1 -0
  9. package/dist/__clients__/core.d.ts +1201 -0
  10. package/dist/__clients__/core.d.ts.map +1 -0
  11. package/dist/__clients__/core.js +3489 -0
  12. package/dist/__clients__/core.js.map +1 -0
  13. package/dist/__clients__/core.mjs +3487 -0
  14. package/dist/__clients__/core.mjs.map +1 -0
  15. package/dist/__generated__/sdk-client-base.d.ts +281 -0
  16. package/dist/__generated__/sdk-client-base.d.ts.map +1 -0
  17. package/dist/__generated__/sdk-client-base.js +3906 -0
  18. package/dist/__generated__/sdk-client-base.js.map +1 -0
  19. package/dist/__generated__/sdk-client-base.mjs +3904 -0
  20. package/dist/__generated__/sdk-client-base.mjs.map +1 -0
  21. package/dist/__generated__/version.d.ts +2 -0
  22. package/dist/__generated__/version.d.ts.map +1 -0
  23. package/dist/__generated__/version.js +6 -0
  24. package/dist/__generated__/version.js.map +1 -0
  25. package/dist/__generated__/version.mjs +4 -0
  26. package/dist/__generated__/version.mjs.map +1 -0
  27. package/dist/__inputs__/public_api.types.d.ts +6014 -0
  28. package/dist/__inputs__/public_api.types.d.ts.map +1 -0
  29. package/dist/__polyfills__/jest.setup.webcrypto.d.ts +2 -0
  30. package/dist/__polyfills__/jest.setup.webcrypto.d.ts.map +1 -0
  31. package/dist/__polyfills__/window.d.ts +15 -0
  32. package/dist/__polyfills__/window.d.ts.map +1 -0
  33. package/dist/__polyfills__/window.js +30 -0
  34. package/dist/__polyfills__/window.js.map +1 -0
  35. package/dist/__polyfills__/window.mjs +28 -0
  36. package/dist/__polyfills__/window.mjs.map +1 -0
  37. package/dist/__stampers__/api/base.d.ts +27 -0
  38. package/dist/__stampers__/api/base.d.ts.map +1 -0
  39. package/dist/__stampers__/api/base.js +102 -0
  40. package/dist/__stampers__/api/base.js.map +1 -0
  41. package/dist/__stampers__/api/base.mjs +100 -0
  42. package/dist/__stampers__/api/base.mjs.map +1 -0
  43. package/dist/__stampers__/api/mobile/stamper.d.ts +15 -0
  44. package/dist/__stampers__/api/mobile/stamper.d.ts.map +1 -0
  45. package/dist/__stampers__/api/mobile/stamper.js +119 -0
  46. package/dist/__stampers__/api/mobile/stamper.js.map +1 -0
  47. package/dist/__stampers__/api/mobile/stamper.mjs +117 -0
  48. package/dist/__stampers__/api/mobile/stamper.mjs.map +1 -0
  49. package/dist/__stampers__/api/web/stamper.d.ts +14 -0
  50. package/dist/__stampers__/api/web/stamper.d.ts.map +1 -0
  51. package/dist/__stampers__/api/web/stamper.js +201 -0
  52. package/dist/__stampers__/api/web/stamper.js.map +1 -0
  53. package/dist/__stampers__/api/web/stamper.mjs +199 -0
  54. package/dist/__stampers__/api/web/stamper.mjs.map +1 -0
  55. package/dist/__stampers__/passkey/base.d.ts +16 -0
  56. package/dist/__stampers__/passkey/base.d.ts.map +1 -0
  57. package/dist/__stampers__/passkey/base.js +138 -0
  58. package/dist/__stampers__/passkey/base.js.map +1 -0
  59. package/dist/__stampers__/passkey/base.mjs +134 -0
  60. package/dist/__stampers__/passkey/base.mjs.map +1 -0
  61. package/dist/__storage__/base.d.ts +3 -0
  62. package/dist/__storage__/base.d.ts.map +1 -0
  63. package/dist/__storage__/base.js +27 -0
  64. package/dist/__storage__/base.js.map +1 -0
  65. package/dist/__storage__/base.mjs +25 -0
  66. package/dist/__storage__/base.mjs.map +1 -0
  67. package/dist/__storage__/mobile/storage.d.ts +18 -0
  68. package/dist/__storage__/mobile/storage.d.ts.map +1 -0
  69. package/dist/__storage__/mobile/storage.js +76 -0
  70. package/dist/__storage__/mobile/storage.js.map +1 -0
  71. package/dist/__storage__/mobile/storage.mjs +74 -0
  72. package/dist/__storage__/mobile/storage.mjs.map +1 -0
  73. package/dist/__storage__/web/storage.d.ts +19 -0
  74. package/dist/__storage__/web/storage.d.ts.map +1 -0
  75. package/dist/__storage__/web/storage.js +79 -0
  76. package/dist/__storage__/web/storage.js.map +1 -0
  77. package/dist/__storage__/web/storage.mjs +77 -0
  78. package/dist/__storage__/web/storage.mjs.map +1 -0
  79. package/dist/__typedoc-entry__/index.d.ts +3 -0
  80. package/dist/__typedoc-entry__/index.d.ts.map +1 -0
  81. package/dist/__types__/auth.d.ts +120 -0
  82. package/dist/__types__/auth.d.ts.map +1 -0
  83. package/dist/__types__/auth.js +7 -0
  84. package/dist/__types__/auth.js.map +1 -0
  85. package/dist/__types__/auth.mjs +5 -0
  86. package/dist/__types__/auth.mjs.map +1 -0
  87. package/dist/__types__/config.d.ts +145 -0
  88. package/dist/__types__/config.d.ts.map +1 -0
  89. package/dist/__types__/enums.d.ts +59 -0
  90. package/dist/__types__/enums.d.ts.map +1 -0
  91. package/dist/__types__/enums.js +72 -0
  92. package/dist/__types__/enums.js.map +1 -0
  93. package/dist/__types__/enums.mjs +70 -0
  94. package/dist/__types__/enums.mjs.map +1 -0
  95. package/dist/__types__/error.d.ts +13 -0
  96. package/dist/__types__/error.d.ts.map +1 -0
  97. package/dist/__types__/error.js +18 -0
  98. package/dist/__types__/error.js.map +1 -0
  99. package/dist/__types__/error.mjs +16 -0
  100. package/dist/__types__/error.mjs.map +1 -0
  101. package/dist/__types__/export.d.ts +10 -0
  102. package/dist/__types__/export.d.ts.map +1 -0
  103. package/dist/__types__/external-wallets.d.ts +203 -0
  104. package/dist/__types__/external-wallets.d.ts.map +1 -0
  105. package/dist/__types__/http.d.ts +17 -0
  106. package/dist/__types__/http.d.ts.map +1 -0
  107. package/dist/__types__/http.js +11 -0
  108. package/dist/__types__/http.js.map +1 -0
  109. package/dist/__types__/http.mjs +9 -0
  110. package/dist/__types__/http.mjs.map +1 -0
  111. package/dist/__types__/index.d.ts +10 -0
  112. package/dist/__types__/index.d.ts.map +1 -0
  113. package/dist/__types__/method-types/import-export-params.d.ts +38 -0
  114. package/dist/__types__/method-types/import-export-params.d.ts.map +1 -0
  115. package/dist/__types__/method-types/shared.d.ts +378 -0
  116. package/dist/__types__/method-types/shared.d.ts.map +1 -0
  117. package/dist/__wallet__/base.d.ts +14 -0
  118. package/dist/__wallet__/base.d.ts.map +1 -0
  119. package/dist/__wallet__/base.js +35 -0
  120. package/dist/__wallet__/base.js.map +1 -0
  121. package/dist/__wallet__/base.mjs +33 -0
  122. package/dist/__wallet__/base.mjs.map +1 -0
  123. package/dist/__wallet__/connector.d.ts +60 -0
  124. package/dist/__wallet__/connector.d.ts.map +1 -0
  125. package/dist/__wallet__/connector.js +93 -0
  126. package/dist/__wallet__/connector.js.map +1 -0
  127. package/dist/__wallet__/connector.mjs +91 -0
  128. package/dist/__wallet__/connector.mjs.map +1 -0
  129. package/dist/__wallet__/mobile/manager.d.ts +51 -0
  130. package/dist/__wallet__/mobile/manager.d.ts.map +1 -0
  131. package/dist/__wallet__/mobile/manager.js +115 -0
  132. package/dist/__wallet__/mobile/manager.js.map +1 -0
  133. package/dist/__wallet__/mobile/manager.mjs +113 -0
  134. package/dist/__wallet__/mobile/manager.mjs.map +1 -0
  135. package/dist/__wallet__/stamper.d.ts +90 -0
  136. package/dist/__wallet__/stamper.d.ts.map +1 -0
  137. package/dist/__wallet__/stamper.js +183 -0
  138. package/dist/__wallet__/stamper.js.map +1 -0
  139. package/dist/__wallet__/stamper.mjs +180 -0
  140. package/dist/__wallet__/stamper.mjs.map +1 -0
  141. package/dist/__wallet__/wallet-connect/base.d.ts +182 -0
  142. package/dist/__wallet__/wallet-connect/base.d.ts.map +1 -0
  143. package/dist/__wallet__/wallet-connect/base.js +606 -0
  144. package/dist/__wallet__/wallet-connect/base.js.map +1 -0
  145. package/dist/__wallet__/wallet-connect/base.mjs +604 -0
  146. package/dist/__wallet__/wallet-connect/base.mjs.map +1 -0
  147. package/dist/__wallet__/wallet-connect/client.d.ts +132 -0
  148. package/dist/__wallet__/wallet-connect/client.d.ts.map +1 -0
  149. package/dist/__wallet__/wallet-connect/client.js +262 -0
  150. package/dist/__wallet__/wallet-connect/client.js.map +1 -0
  151. package/dist/__wallet__/wallet-connect/client.mjs +260 -0
  152. package/dist/__wallet__/wallet-connect/client.mjs.map +1 -0
  153. package/dist/__wallet__/web/manager.d.ts +70 -0
  154. package/dist/__wallet__/web/manager.d.ts.map +1 -0
  155. package/dist/__wallet__/web/manager.js +177 -0
  156. package/dist/__wallet__/web/manager.js.map +1 -0
  157. package/dist/__wallet__/web/manager.mjs +175 -0
  158. package/dist/__wallet__/web/manager.mjs.map +1 -0
  159. package/dist/__wallet__/web/native/ethereum.d.ts +101 -0
  160. package/dist/__wallet__/web/native/ethereum.d.ts.map +1 -0
  161. package/dist/__wallet__/web/native/ethereum.js +339 -0
  162. package/dist/__wallet__/web/native/ethereum.js.map +1 -0
  163. package/dist/__wallet__/web/native/ethereum.mjs +336 -0
  164. package/dist/__wallet__/web/native/ethereum.mjs.map +1 -0
  165. package/dist/__wallet__/web/native/solana.d.ts +72 -0
  166. package/dist/__wallet__/web/native/solana.d.ts.map +1 -0
  167. package/dist/__wallet__/web/native/solana.js +215 -0
  168. package/dist/__wallet__/web/native/solana.js.map +1 -0
  169. package/dist/__wallet__/web/native/solana.mjs +212 -0
  170. package/dist/__wallet__/web/native/solana.mjs.map +1 -0
  171. package/dist/index.d.ts +19 -0
  172. package/dist/index.d.ts.map +1 -0
  173. package/dist/index.js +83 -0
  174. package/dist/index.js.map +1 -0
  175. package/dist/index.mjs +10 -0
  176. package/dist/index.mjs.map +1 -0
  177. package/dist/utils.d.ts +160 -0
  178. package/dist/utils.d.ts.map +1 -0
  179. package/dist/utils.js +1047 -0
  180. package/dist/utils.js.map +1 -0
  181. package/dist/utils.mjs +1007 -0
  182. package/dist/utils.mjs.map +1 -0
  183. package/package.json +80 -0
@@ -0,0 +1,1201 @@
1
+ import { ZeroXKeySDKClientBase } from "../__generated__/sdk-client-base";
2
+ import { type TDeleteSubOrganizationResponse, type Session, type TStampLoginResponse, type v1SignRawPayloadResult, type v1User, type ProxyTGetWalletKitConfigResponse, type v1PrivateKey, type WalletAuthResult, type BaseAuthResult, type PasskeyAuthResult, type v1BootProof, type TGetSendTransactionStatusResponse, AuthAction } from "@0xkey-io/sdk-types";
3
+ import { Chain, type ExportBundle, type ZeroXKeySDKClientConfig, 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 InitOtpResult, 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 EthSendErc20TransferParams, type EthSendTransactionParams, type SolSendTransactionParams, 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, type FetchBootProofForAppProofParams, type CreateHttpClientParams, type BuildWalletLoginRequestResult, type BuildWalletLoginRequestParams, type VerifyAppProofsParams, type PollTransactionStatusParams } from "../__types__";
4
+ import { CrossPlatformApiKeyStamper } from "../__stampers__/api/base";
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
+ */
14
+ type PublicMethods<T> = {
15
+ [K in keyof T as T[K] extends Function ? K : never]: T[K];
16
+ };
17
+ export type ZeroXKeyClientMethods = Omit<PublicMethods<ZeroXKeyClient>, "init" | "config" | "httpClient" | "constructor">;
18
+ export declare class ZeroXKeyClient {
19
+ config: ZeroXKeySDKClientConfig;
20
+ httpClient: ZeroXKeySDKClientBase;
21
+ private apiKeyStamper?;
22
+ private passkeyStamper?;
23
+ private walletManager?;
24
+ private storageManager;
25
+ constructor(config: ZeroXKeySDKClientConfig, apiKeyStamper?: CrossPlatformApiKeyStamper, passkeyStamper?: CrossPlatformPasskeyStamper, walletManager?: WalletManagerBase);
26
+ init(): Promise<void>;
27
+ /**
28
+ * Creates a new ZeroXKeySDKClientBase instance with the provided configuration.
29
+ * This method is used internally to create the HTTP client for making API requests,
30
+ * but can also be used to create an additional client with different configurations if needed.
31
+ * By default, it uses the configuration provided during the ZeroXKeyClient initialization.
32
+ *
33
+ * @param params - Optional configuration parameters to override the default client configuration.
34
+ * @param params.apiBaseUrl - The base URL of the ZeroXKey API (defaults to `https://api.0xkey.com` if not provided).
35
+ * @param params.organizationId - The organization ID to associate requests with.
36
+ * @param params.authProxyUrl - The base URL of the Auth Proxy (defaults to `https://authproxy.0xkey.com` if not provided).
37
+ * @param params.authProxyConfigId - The configuration ID to use when making Auth Proxy requests.
38
+ * @param params.defaultStamperType - The default stamper type to use for signing requests
39
+ * (overrides automatic detection of ApiKey, Passkey, or Wallet stampers).
40
+ *
41
+ * @returns A new instance of {@link ZeroXKeySDKClientBase} configured with the provided parameters.
42
+ */
43
+ createHttpClient: (params?: CreateHttpClientParams) => ZeroXKeySDKClientBase;
44
+ /**
45
+ * Creates a new passkey authenticator for the user.
46
+ *
47
+ * - This function generates a new passkey attestation and challenge, suitable for registration with the user's device.
48
+ * - Handles both web and React Native environments, automatically selecting the appropriate passkey creation flow.
49
+ * - The resulting attestation and challenge can be used to register the passkey with ZeroXKey.
50
+ *
51
+ * @param params.name - display name for the passkey (defaults to a generated name based on the current timestamp).
52
+ * @param params.challenge - challenge string to use for passkey registration. If not provided, a new challenge will be generated.
53
+ * @returns A promise that resolves to {@link CreatePasskeyResult}
54
+ * @throws {ZeroXKeyError} If there is an error during passkey creation, or if the platform is unsupported.
55
+ */
56
+ createPasskey: (params: CreatePasskeyParams) => Promise<CreatePasskeyResult>;
57
+ /**
58
+ * Logs out the current client session.
59
+ *
60
+ * - This function clears the specified session and removes any associated key pairs from storage.
61
+ * - If a sessionKey is provided, it logs out from that session; otherwise, it logs out from the active session.
62
+ * - Cleans up any api keys associated with the session.
63
+ *
64
+ * @param params.sessionKey - session key to specify which session to log out from (defaults to the active session).
65
+ * @returns A promise that resolves when the logout process is complete.
66
+ * @throws {ZeroXKeyError} If there is no active session or if there is an error during the logout process.
67
+ */
68
+ logout: (params?: LogoutParams) => Promise<void>;
69
+ /**
70
+ * Logs in a user using a passkey, optionally specifying the public key, session key, and session expiration.
71
+ *
72
+ * - This function initiates the login process with a passkey and handles session creation and storage.
73
+ * - If a public key is not provided, a new key pair will be generated for authentication.
74
+ * - If a session key is not provided, the default session key will be used.
75
+ * - The session expiration can be customized via the expirationSeconds parameter.
76
+ * - Handles cleanup of unused key pairs if login fails.
77
+ *
78
+ * @param params.publicKey - public key to use for authentication. If not provided, a new key pair will be generated.
79
+ * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
80
+ * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
81
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
82
+ * @returns A promise that resolves to a {@link PasskeyAuthResult}, which includes:
83
+ * - `sessionToken`: the signed JWT session token.
84
+ * - `credentialId`: an empty string.
85
+ * @throws {ZeroXKeyError} If there is an error during the passkey login process or if the user cancels the passkey prompt.
86
+ */
87
+ loginWithPasskey: (params?: LoginWithPasskeyParams) => Promise<PasskeyAuthResult>;
88
+ /**
89
+ * Signs up a user using a passkey, creating a new sub-organization and session.
90
+ *
91
+ * - This function creates a new passkey authenticator and uses it to register a new sub-organization for the user.
92
+ * - Handles both passkey creation and sub-organization creation in a single flow.
93
+ * - Optionally accepts additional sub-organization parameters, a custom session key, a custom passkey display name, and a custom session expiration.
94
+ * - Automatically generates a new API key pair for authentication and session management.
95
+ * - Stores the resulting session token and manages cleanup of unused key pairs.
96
+ *
97
+ * @param params.passkeyDisplayName - display name for the passkey (defaults to a generated name based on the current timestamp).
98
+ * @param params.challenge - challenge string to use for passkey registration. If not provided, a new challenge will be generated.
99
+ * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
100
+ * @param params.createSubOrgParams - parameters for creating a sub-organization (e.g., authenticators, user metadata).
101
+ * @param params.sessionKey - session key to use for storing the session (defaults to the default session key).
102
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
103
+ * @returns A promise that resolves to a {@link PasskeyAuthResult}, which includes:
104
+ * - `sessionToken`: the signed JWT session token.
105
+ * - `credentialId`: the credential ID associated with the passkey created.
106
+ * @throws {ZeroXKeyError} If there is an error during passkey creation, sub-organization creation, or session storage.
107
+ */
108
+ signUpWithPasskey: (params?: SignUpWithPasskeyParams) => Promise<PasskeyAuthResult>;
109
+ /**
110
+ * Retrieves wallet providers from the initialized wallet manager.
111
+ *
112
+ * - Optionally filters providers by the specified blockchain chain.
113
+ * - Throws an error if the wallet manager is not initialized.
114
+ *
115
+ * @param chain - optional blockchain chain to filter the returned providers.
116
+ * @returns A promise that resolves to an array of wallet providers.
117
+ * @throws {ZeroXKeyError} If the wallet manager is uninitialized or provider retrieval fails.
118
+ */
119
+ fetchWalletProviders: (chain?: Chain) => Promise<WalletProvider[]>;
120
+ /**
121
+ * Connects the specified wallet account.
122
+ *
123
+ * - Requires the wallet manager and its connector to be initialized.
124
+ *
125
+ * @param walletProvider - wallet provider to connect.
126
+ * @returns A promise that resolves with the connected wallet's address.
127
+ * @throws {ZeroXKeyError} If the wallet manager is uninitialized or the connection fails.
128
+ */
129
+ connectWalletAccount: (walletProvider: WalletProvider) => Promise<string>;
130
+ /**
131
+ * Disconnects the specified wallet account.
132
+ *
133
+ * - Requires the wallet manager and its connector to be initialized.
134
+ *
135
+ * @param walletProvider - wallet provider to disconnect.
136
+ * @returns A promise that resolves once the wallet account is disconnected.
137
+ * @throws {ZeroXKeyError} If the wallet manager is uninitialized or the disconnection fails.
138
+ */
139
+ disconnectWalletAccount: (walletProvider: WalletProvider) => Promise<void>;
140
+ /**
141
+ * Switches the wallet provider associated with a given wallet account
142
+ * to a different chain.
143
+ *
144
+ * - Requires the wallet manager and its connector to be initialized
145
+ * - Only works for connected wallet accounts
146
+ * - Looks up the provider for the given account address
147
+ * - Does nothing if the provider is already on the desired chain.
148
+ *
149
+ * @param params.walletAccount - The wallet account whose provider should be switched.
150
+ * @param params.chainOrId - The target chain, specified as a chain ID string or a SwitchableChain object.
151
+ * @param params.walletProviders - Optional list of wallet providers to search; falls back to `fetchWalletProviders()` if omitted.
152
+ * @returns A promise that resolves once the chain switch is complete.
153
+ *
154
+ * @throws {ZeroXKeyError} If the wallet manager is uninitialized, the provider is not connected, or the switch fails.
155
+ */
156
+ switchWalletAccountChain: (params: SwitchWalletAccountChainParams) => Promise<void>;
157
+ /**
158
+ * Builds and signs a wallet login request without submitting it to ZeroXKey.
159
+ *
160
+ * - This function prepares a signed request for wallet authentication, which can later be used
161
+ * to log in or sign up a user with ZeroXKey.
162
+ * - It initializes the wallet stamper, ensures a valid session public key (generating one if needed),
163
+ * and signs the login intent with the connected wallet.
164
+ * - For Ethereum wallets, derives the public key from the stamped request header.
165
+ * - For Solana wallets, retrieves the public key directly from the connected wallet.
166
+ * - The signed request is not sent to ZeroXKey immediately; it is meant to be used in a subsequent flow
167
+ * (e.g., `loginOrSignupWithWallet`) where sub-organization existence is verified or created first.
168
+ *
169
+ * @param params.walletProvider - the wallet provider used for authentication and signing.
170
+ * @param params.publicKey - optional pre-generated session public key (auto-generated if not provided).
171
+ * @param params.expirationSeconds - optional session expiration time in seconds (defaults to the configured default).
172
+ * @returns A promise resolving to an object containing:
173
+ * - `signedRequest`: the signed wallet login request.
174
+ * - `publicKey`: the public key associated with the signed request.
175
+ * @throws {ZeroXKeyError} If the wallet stamper is not initialized, the signing process fails,
176
+ * or the public key cannot be derived or generated.
177
+ */
178
+ buildWalletLoginRequest: (params: BuildWalletLoginRequestParams) => Promise<BuildWalletLoginRequestResult>;
179
+ /**
180
+ * Logs in a user using the specified wallet provider.
181
+ *
182
+ * - This function logs in a user by authenticating with the provided wallet provider via a wallet-based signature.
183
+ * - If a public key is not provided, a new one will be generated for authentication.
184
+ * - Optionally accepts a custom session key and session expiration time.
185
+ * - Stores the resulting session token under the specified session key, or the default session key if not provided.
186
+ * - Throws an error if a public key cannot be found or generated, or if the login process fails.
187
+ *
188
+ * @param params.walletProvider - wallet provider to use for authentication.
189
+ * @param params.publicKey - optional public key to associate with the session (generated if not provided).
190
+ * @param params.sessionKey - optional key to store the session under (defaults to the default session key).
191
+ * @param params.expirationSeconds - optional session expiration time in seconds (defaults to the configured default).
192
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
193
+ * @returns A promise that resolves to a {@link WalletAuthResult}, which includes:
194
+ * - `sessionToken`: the signed JWT session token.
195
+ * - `address`: the authenticated wallet address.
196
+ * @throws {ZeroXKeyError} If the wallet stamper is uninitialized, a public key cannot be found or generated, or login fails.
197
+ */
198
+ loginWithWallet: (params: LoginWithWalletParams) => Promise<WalletAuthResult>;
199
+ /**
200
+ * Signs up a user using a wallet, creating a new sub-organization and session.
201
+ *
202
+ * - This function creates a new wallet authenticator and uses it to register a new sub-organization for the user.
203
+ * - Handles both wallet authentication and sub-organization creation in a single flow.
204
+ * - Optionally accepts additional sub-organization parameters, a custom session key, and a custom session expiration.
205
+ * - Automatically generates additional API key pairs for authentication and session management.
206
+ * - Stores the resulting session token under the specified session key, or the default session key if not provided, and manages cleanup of unused key pairs.
207
+ *
208
+ * @param params.walletProvider - wallet provider to use for authentication.
209
+ * @param params.createSubOrgParams - parameters for creating a sub-organization (e.g., authenticators, user metadata).
210
+ * @param params.sessionKey - session key to use for storing the session (defaults to the default session key).
211
+ * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
212
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
213
+ * @returns A promise that resolves to a {@link WalletAuthResult}, which includes:
214
+ * - `sessionToken`: the signed JWT session token.
215
+ * - `address`: the authenticated wallet address.
216
+ * @throws {ZeroXKeyError} If there is an error during wallet authentication, sub-organization creation, session storage, or cleanup.
217
+ */
218
+ signUpWithWallet: (params: SignUpWithWalletParams) => Promise<WalletAuthResult>;
219
+ /**
220
+ * Logs in an existing user or signs up a new user using a wallet, creating a new sub-organization if needed.
221
+ *
222
+ * - This function attempts to log in the user by stamping a login request with the provided wallet.
223
+ * - If the wallet’s public key is not associated with an existing sub-organization, a new one is created.
224
+ * - Handles both wallet authentication and sub-organization creation in a single flow.
225
+ * - For Ethereum wallets, derives the public key from the signed request header; for Solana wallets, retrieves it directly from the wallet.
226
+ * - Optionally accepts additional sub-organization parameters, a custom session key, and a custom session expiration.
227
+ * - Stores the resulting session token under the specified session key, or the default session key if not provided.
228
+ *
229
+ * @param params.walletProvider - wallet provider to use for authentication.
230
+ * @param params.publicKey - optional public key to associate with the session (generated if not provided).
231
+ * @param params.createSubOrgParams - optional parameters for creating a sub-organization (e.g., authenticators, user metadata).
232
+ * @param params.sessionKey - session key to use for storing the session (defaults to the default session key).
233
+ * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
234
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
235
+ * @returns A promise that resolves to an object containing:
236
+ * - `sessionToken`: the signed JWT session token.
237
+ * - `address`: the authenticated wallet address.
238
+ * - `action`: whether the flow resulted in a login or signup ({@link AuthAction}).
239
+ * @throws {ZeroXKeyError} If there is an error during wallet authentication, sub-organization creation, or session storage.
240
+ */
241
+ loginOrSignupWithWallet: (params: LoginOrSignupWithWalletParams) => Promise<WalletAuthResult & {
242
+ action: AuthAction;
243
+ }>;
244
+ /**
245
+ * Initializes the OTP process by sending an OTP code to the provided contact.
246
+ *
247
+ * - This function initiates the OTP flow by sending a one-time password (OTP) code to the user's contact information (email address or phone number) via the auth proxy.
248
+ * - Supports both email and SMS OTP types.
249
+ * - Returns an OTP ID that is required for subsequent OTP verification.
250
+ *
251
+ * @param params.otpType - type of OTP to initialize (OtpType.Email or OtpType.Sms).
252
+ * @param params.contact - contact information for the user (e.g., email address or phone number).
253
+ * @param params.organizationId - optional organization ID to target (defaults to the session's organization ID or the parent organization ID).
254
+ * @returns A promise that resolves to the OTP ID required for verification.
255
+ * @throws {ZeroXKeyError} If there is an error during the OTP initialization process or if the maximum number of OTPs has been reached.
256
+ */
257
+ initOtp: (params: InitOtpParams) => Promise<InitOtpResult>;
258
+ /**
259
+ * Verifies the OTP code sent to the user.
260
+ *
261
+ * - This function verifies the OTP code entered by the user against the OTP sent to their contact information (email or phone) using the auth proxy.
262
+ * - If verification is successful, it returns the sub-organization ID associated with the contact (if it exists) and a verification token.
263
+ * - The verification token can be used for subsequent login or sign-up flows.
264
+ * - Handles both email and SMS OTP types.
265
+ *
266
+ * @param params.otpId - ID of the OTP to verify (returned from `initOtp`).
267
+ * @param params.otpCode - OTP code entered by the user.
268
+ * @param params.contact - contact information for the user (e.g., email address or phone number).
269
+ * @param params.otpType - type of OTP being verified (OtpType.Email or OtpType.Sms).
270
+ * @param params.publicKey - public key the verification token is bound to for ownership verification (client signature verification during login/signup). This public key is optional; if not provided, a new key pair will be generated.
271
+ * @returns A promise that resolves to an object containing:
272
+ * - subOrganizationId: sub-organization ID if the contact is already associated with a sub-organization, or an empty string if not.
273
+ * - verificationToken: verification token to be used for login or sign-up.
274
+ * @throws {ZeroXKeyError} If there is an error during the OTP verification process, such as an invalid code or network failure.
275
+ */
276
+ verifyOtp: (params: VerifyOtpParams) => Promise<VerifyOtpResult>;
277
+ /**
278
+ * Logs in a user using an OTP verification token.
279
+ *
280
+ * - This function logs in a user using the verification token received after OTP verification (from email or SMS).
281
+ * - If a public key is not provided, a new API key pair will be generated for authentication.
282
+ * - Optionally invalidates any existing sessions for the user if `invalidateExisting` is set to true.
283
+ * - Stores the resulting session token under the specified session key, or the default session key if not provided.
284
+ * - Handles cleanup of unused key pairs if login fails.
285
+ *
286
+ * @param params.verificationToken - verification token received after OTP verification.
287
+ * @param params.publicKey - public key to use for authentication. If not provided, a new key pair will be generated.
288
+ * @param params.organizationId - optional organization ID to target (defaults to the verified subOrg ID linked to the verification token contact).
289
+ * @param params.invalidateExisting - flag to invalidate existing session for the user.
290
+ * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
291
+ * @returns A promise that resolves to a {@link BaseAuthResult}, which includes:
292
+ * - `sessionToken`: the signed JWT session token.
293
+ * @throws {ZeroXKeyError} If there is an error during the OTP login process or if key pair cleanup fails.
294
+ */
295
+ loginWithOtp: (params: LoginWithOtpParams) => Promise<BaseAuthResult>;
296
+ /**
297
+ * Signs up a user using an OTP verification token.
298
+ *
299
+ * - This function signs up a user using the verification token received after OTP verification (from email or SMS).
300
+ * - Creates a new sub-organization for the user with the provided parameters and associates the contact (email or phone) with the sub-organization.
301
+ * - Automatically generates a new API key pair for authentication and session management.
302
+ * - Stores the resulting session token under the specified session key, or the default session key if not provided.
303
+ * - Handles both email and SMS OTP types, and supports additional sub-organization creation parameters.
304
+ *
305
+ * @param params.verificationToken - verification token received after OTP verification.
306
+ * @param params.contact - contact information for the user (e.g., email address or phone number).
307
+ * @param params.otpType - type of OTP being used (OtpType.Email or OtpType.Sms).
308
+ * @param params.createSubOrgParams - parameters for creating a sub-organization (e.g., authenticators, user metadata).
309
+ * @param params.invalidateExisting - flag to invalidate existing session for the user.
310
+ * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
311
+ * @returns A promise that resolves to a {@link BaseAuthResult}, which includes:
312
+ * - `sessionToken`: the signed JWT session token.
313
+ * @throws {ZeroXKeyError} If there is an error during the OTP sign-up process or session storage.
314
+ */
315
+ signUpWithOtp: (params: SignUpWithOtpParams) => Promise<BaseAuthResult>;
316
+ /**
317
+ * Completes the OTP authentication flow by verifying the OTP code and then either signing up or logging in the user.
318
+ *
319
+ * - This function first verifies the OTP code for the provided contact and OTP type.
320
+ * - If the contact is not associated with an existing sub-organization, it will automatically create a new sub-organization and complete the sign-up flow.
321
+ * - If the contact is already associated with a sub-organization, it will complete the login flow.
322
+ * - Supports passing a custom public key for authentication, invalidating existing session, specifying a session key, and providing additional sub-organization creation parameters.
323
+ * - Handles both email and SMS OTP types.
324
+ *
325
+ * @param params.otpId - ID of the OTP to complete (returned from `initOtp`).
326
+ * @param params.otpCode - OTP code entered by the user.
327
+ * @param params.contact - contact information for the user (e.g., email address or phone number).
328
+ * @param params.otpType - type of OTP being completed (OtpType.Email or OtpType.Sms).
329
+ * @param params.publicKey - public key to use for authentication. If not provided, a new key pair may be generated.
330
+ * @param params.invalidateExisting - flag to invalidate existing sessions for the user.
331
+ * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
332
+ * @param params.createSubOrgParams - parameters for sub-organization creation (e.g., authenticators, user metadata).
333
+ * @returns A promise that resolves to an object containing:
334
+ * - `sessionToken`: the signed JWT session token.
335
+ * - `verificationToken`: the OTP verification token.
336
+ * - `action`: whether the flow resulted in a login or signup ({@link AuthAction}).
337
+ * @throws {ZeroXKeyError} If there is an error during OTP verification, sign-up, or login.
338
+ */
339
+ completeOtp: (params: CompleteOtpParams) => Promise<BaseAuthResult & {
340
+ verificationToken: string;
341
+ action: AuthAction;
342
+ }>;
343
+ /**
344
+ * Completes the OAuth authentication flow by either signing up or logging in the user, depending on whether a sub-organization already exists for the provided OIDC token.
345
+ *
346
+ * - This function first checks if there is an existing sub-organization associated with the OIDC token.
347
+ * - If a sub-organization exists, it proceeds with the OAuth login flow.
348
+ * - If no sub-organization exists, it creates a new sub-organization and completes the sign-up flow.
349
+ * - Optionally accepts a custom OAuth provider name, session key, and additional sub-organization creation parameters.
350
+ * - Handles session storage and management, and supports invalidating existing sessions if specified.
351
+ *
352
+ * @param params.oidcToken - OIDC token received after successful authentication with the OAuth provider.
353
+ * @param params.publicKey - public key to use for authentication. Must be generated prior to calling this function, this is because the OIDC nonce has to be set to `sha256(publicKey)`.
354
+ * @param params.providerName - name of the OAuth provider (defaults to a generated name with a timestamp).
355
+ * @param params.createSubOrgParams - parameters for sub-organization creation (e.g., authenticators, user metadata).
356
+ * @param params.invalidateExisting - flag to invalidate existing sessions for the user.
357
+ * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
358
+ *
359
+ * @returns A promise that resolves to an object containing:
360
+ * - `sessionToken`: the signed JWT session token.
361
+ * - `action`: whether the flow resulted in a login or signup ({@link AuthAction}).
362
+ * @throws {ZeroXKeyError} If there is an error during the OAuth completion process, such as account lookup, sign-up, or login.
363
+ */
364
+ completeOauth: (params: CompleteOauthParams) => Promise<BaseAuthResult & {
365
+ action: AuthAction;
366
+ }>;
367
+ /**
368
+ * Logs in a user using OAuth authentication.
369
+ *
370
+ * - This function logs in a user using the provided OIDC token and public key.
371
+ * - Optionally invalidates any existing sessions for the user if `invalidateExisting` is set to true.
372
+ * - Stores the resulting session token under the specified session key, or the default session key if not provided.
373
+ * - Handles cleanup of unused key pairs if login fails.
374
+ *
375
+ * @param params.oidcToken - OIDC token received after successful authentication with the OAuth provider.
376
+ * @param params.publicKey - The public key bound to the login session. This key is required because it is directly
377
+ * tied to the nonce used during OIDC token generation and must match the value
378
+ * encoded in the token.
379
+ * @param params.organizationId - ID of the organization to target when creating the session.
380
+ * @param params.invalidateExisting - flag to invalidate existing sessions for the user.
381
+ * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
382
+ * @returns A promise that resolves to a {@link BaseAuthResult}, which includes:
383
+ * - `sessionToken`: the signed JWT session token.
384
+ * @throws {ZeroXKeyError} If there is an error during the OAuth login process or if key pair cleanup fails.
385
+ */
386
+ loginWithOauth: (params: LoginWithOauthParams) => Promise<BaseAuthResult>;
387
+ /**
388
+ * Signs up a user using OAuth authentication.
389
+ *
390
+ * - This function creates a new sub-organization for the user using the provided OIDC token, public key, and provider name.
391
+ * - Handles the full OAuth sign-up flow, including sub-organization creation and session management.
392
+ * - Optionally accepts additional sub-organization creation parameters and a custom session key.
393
+ * - After successful sign-up, automatically logs in the user and returns a signed JWT session token.
394
+ *
395
+ * @param params.oidcToken - OIDC token received after successful authentication with the OAuth provider.
396
+ * @param params.publicKey - public key to associate with the new sub-organization.
397
+ * @param params.providerName - name of the OAuth provider (e.g., "Google", "Apple").
398
+ * @param params.createSubOrgParams - parameters for sub-organization creation (e.g., authenticators, user metadata).
399
+ * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
400
+ * @returns A promise that resolves to a {@link BaseAuthResult}, which includes:
401
+ * - `sessionToken`: the signed JWT session token.
402
+ * @throws {ZeroXKeyError} If there is an error during the OAuth sign-up or login process.
403
+ */
404
+ signUpWithOauth: (params: SignUpWithOauthParams) => Promise<BaseAuthResult>;
405
+ /**
406
+ * Fetches all wallets for the current user, including both embedded and connected wallets.
407
+ *
408
+ * - Retrieves all wallets associated with the organizationId from the current active session.
409
+ * - For each embedded wallet, automatically fetches and attaches all associated wallet accounts.
410
+ * - For connected wallets (e.g., browser extensions or external providers), groups providers by wallet name and attaches all connected accounts.
411
+ * - Returns both embedded and connected wallets in a single array, each with their respective accounts populated.
412
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
413
+ *
414
+ * @param params.walletProviders - array of wallet providers to use for fetching wallets.
415
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
416
+ * @param params.userId - user ID to target (defaults to the session's user ID).
417
+ * @param params.connectedOnly - if true, fetches only connected wallets; if false or undefined, fetches both embedded and connected wallets.
418
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
419
+ * @returns A promise that resolves to an array of `Wallet` objects.
420
+ * @throws {ZeroXKeyError} If no active session is found or if there is an error fetching wallets.
421
+ */
422
+ fetchWallets: (params?: FetchWalletsParams) => Promise<Wallet[]>;
423
+ /**
424
+ * Fetches all accounts for a specific wallet, including both embedded and connected wallet accounts.
425
+ *
426
+ * - For embedded wallets, retrieves accounts from the ZeroXKey API, supporting pagination (defaults to the first page with a limit of 100 accounts).
427
+ * - For connected wallets (e.g., browser extensions or external providers), constructs account objects for each connected address from the provided or discovered wallet providers.
428
+ * - Automatically determines the account type and populates relevant fields such as address, curve, and signing capability.
429
+ * - Optionally allows filtering by a specific set of wallet providers and supports custom pagination options.
430
+ * - Supports stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
431
+ *
432
+ * @param params.wallet - wallet for which to fetch accounts.
433
+ * @param params.walletProviders - list of wallet providers to filter by (used for connected wallets).
434
+ * @param params.paginationOptions - pagination options for embedded wallets.
435
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
436
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
437
+ * @param params.userId - user ID to target (defaults to the session's user ID).
438
+ * @param params.authenticatorAddresses - optional authenticator addresses to avoid redundant user fetches (this is used for connected wallets to determine if a connected wallet is an authenticator)
439
+ *
440
+ * @returns A promise that resolves to an array of `v1WalletAccount` objects.
441
+ * @throws {ZeroXKeyError} If no active session is found or if there is an error fetching wallet accounts.
442
+ */
443
+ fetchWalletAccounts: (params: FetchWalletAccountsParams) => Promise<WalletAccount[]>;
444
+ /**
445
+ * Fetches all private keys for the current user.
446
+ *
447
+ * - Retrieves private keys from the ZeroXKey API.
448
+ * - Supports stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
449
+ *
450
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
451
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
452
+ * @returns A promise that resolves to an array of `v1PrivateKey` objects.
453
+ * @throws {ZeroXKeyError} If no active session is found or if there is an error fetching private keys.
454
+ */
455
+ fetchPrivateKeys: (params?: FetchPrivateKeysParams) => Promise<v1PrivateKey[]>;
456
+ /**
457
+ * Signs a message using the specified wallet account.
458
+ *
459
+ * Behavior differs depending on the wallet type:
460
+ *
461
+ * - **Connected wallets**
462
+ * - Delegates signing to the wallet provider’s native signing method.
463
+ * - *Ethereum*: signatures always follow [EIP-191](https://eips.ethereum.org/EIPS/eip-191).
464
+ * - The wallet automatically prefixes messages with
465
+ * `"\x19Ethereum Signed Message:\n" + message length` before signing.
466
+ * - As a result, these signatures cannot be used as raw transaction signatures or broadcast on-chain.
467
+ * - If `addEthereumPrefix` is set to `false`, an error is thrown because connected Ethereum wallets always prefix.
468
+ * - *Other chains*: follows the native connected wallet behavior.
469
+ *
470
+ * - **Embedded wallets**
471
+ * - Uses the ZeroXKey API to sign the message directly.
472
+ * - Supports optional `addEthereumPrefix`:
473
+ * - If `true` (default for Ethereum), the message is prefixed before signing.
474
+ * - If `false`, the raw message is signed without any prefix.
475
+ *
476
+ * Additional details:
477
+ * - Automatically handles encoding and hashing based on the wallet account’s address format,
478
+ * unless explicitly overridden.
479
+ * - Optionally allows stamping with a specific stamper
480
+ * (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
481
+ *
482
+ * @param params.message - plaintext (UTF-8) message to sign.
483
+ * @param params.walletAccount - wallet account to use for signing.
484
+ * @param params.encoding - override for payload encoding (defaults to the encoding appropriate for the address format).
485
+ * @param params.hashFunction - override for hash function (defaults to the function appropriate for the address format).
486
+ * @param params.stampWith - optional stamper for the signing request.
487
+ * @param params.addEthereumPrefix - whether to prefix the message with Ethereum’s
488
+ * `"\x19Ethereum Signed Message:\n"` string (default: `true` for Ethereum).
489
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
490
+ *
491
+ * @returns A promise that resolves to a `v1SignRawPayloadResult` containing the signature and metadata.
492
+ * @throws {ZeroXKeyError} If signing fails, the wallet type does not support message signing, or the response is invalid.
493
+ */
494
+ signMessage: (params: SignMessageParams) => Promise<v1SignRawPayloadResult>;
495
+ /**
496
+ * Signs a transaction using the specified wallet account.
497
+ *
498
+ * Behavior differs depending on the type of wallet:
499
+ *
500
+ * - **Connected wallets**
501
+ * - Ethereum: does not support raw transaction signing. Calling this function will throw an error instructing you to use `signAndSendTransaction` instead.
502
+ * - Solana: supports raw transaction signing via the connected wallet provider.
503
+ * - Other chains: not supported; will throw an error.
504
+ *
505
+ * - **Embedded wallets**
506
+ * - Delegates signing to the ZeroXKey API, which returns the signed transaction.
507
+ * - Supports all ZeroXKey-supported transaction types (e.g., Ethereum/EVM, Solana, Tron).
508
+ * - BSC and other EVM-compatible chains use `TRANSACTION_TYPE_ETHEREUM`; the chain is identified by the unsigned transaction's `chainId`.
509
+ * - Optionally allows stamping with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
510
+ * - Note: For embedded Ethereum wallets, the returned signature doesn’t include the `0x` prefix. You should add `0x` before
511
+ * broadcasting if it’s missing. It’s a good idea to check whether the signature already starts with `0x` before adding it,
512
+ * since we plan to include the prefix by default in a future breaking change.
513
+ *
514
+ * @param params.walletAccount - wallet account to use for signing.
515
+ * @param params.unsignedTransaction - unsigned transaction data as a serialized
516
+ * string in the canonical encoding for the given `transactionType`.
517
+ * @param params.transactionType - type of transaction (e.g., "TRANSACTION_TYPE_ETHEREUM", "TRANSACTION_TYPE_SOLANA", "TRANSACTION_TYPE_TRON"). Use "TRANSACTION_TYPE_ETHEREUM" for BSC.
518
+ * @param params.stampWith - stamper to use for signing (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
519
+ * @param params.organizationId - organization ID to target (defaults to the session's organization ID).
520
+ * @returns A promise that resolves to the signed transaction string.
521
+ * @throws {ZeroXKeyError} If the wallet type is unsupported, signing fails, or the response is invalid.
522
+ */
523
+ signTransaction: (params: SignTransactionParams) => Promise<string>;
524
+ /**
525
+ * Signs and broadcasts a transaction using the specified wallet account.
526
+ *
527
+ * Behavior differs depending on the type of wallet:
528
+ *
529
+ * - **Connected wallets**
530
+ * - *Ethereum*: delegates to the wallet’s native `signAndSendTransaction` method.
531
+ * - Does **not** require an `rpcUrl` (the wallet handles broadcasting).
532
+ * - *Solana*: signs the transaction locally with the connected wallet, but requires an `rpcUrl` to broadcast it.
533
+ * - Other chains: not supported; will throw an error.
534
+ *
535
+ * - **Embedded wallets**
536
+ * - Signs the transaction using the ZeroXKey API.
537
+ * - Requires an `rpcUrl` to broadcast the signed transaction, since ZeroXKey does not broadcast directly.
538
+ * - Broadcasts the transaction using a JSON-RPC client and returns the resulting transaction hash/signature.
539
+ * - Optionally allows stamping with a specific stamper (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
540
+ *
541
+ * @param params.walletAccount - wallet account to use for signing and broadcasting.
542
+ * @param params.unsignedTransaction - unsigned transaction data as a serialized
543
+ * string in the canonical encoding for the given `transactionType`.
544
+ * @param params.transactionType - type of transaction (e.g., `"TRANSACTION_TYPE_SOLANA"`, `"TRANSACTION_TYPE_ETHEREUM"`).
545
+ * @param params.rpcUrl - JSON-RPC endpoint used for broadcasting (required for Solana connected wallets and all embedded wallets).
546
+ * @param params.stampWith - optional stamper to use when signing (`StamperType.Passkey`, `StamperType.ApiKey`, or `StamperType.Wallet`).
547
+ * @param params.organizationId - **Only for ZeroXKey embedded wallets**: organization ID to target (defaults to the session's organization ID).
548
+ * @returns A promise that resolves to a transaction signature or hash.
549
+ * @throws {ZeroXKeyError} If the wallet type is unsupported, or if signing/broadcasting fails.
550
+ */
551
+ signAndSendTransaction: (params: SignAndSendTransactionParams) => Promise<string>;
552
+ /**
553
+ * @beta
554
+ * * **API subject to change**
555
+ *
556
+ * Signs and submits an ERC20 `transfer(address,uint256)` as an Ethereum transaction
557
+ * using a ZeroXKey-managed (embedded) wallet.
558
+ *
559
+ * This is a convenience wrapper around `ethSendTransaction`:
560
+ * - Encodes ERC20 transfer calldata.
561
+ * - Sends a transaction to the token contract.
562
+ * - Returns a `sendTransactionStatusId` for polling with `pollTransactionStatus`.
563
+ *
564
+ * @param params.organizationId - Organization ID to execute the transaction under.
565
+ * Defaults to the active session's organization.
566
+ * @param params.stampWith - Optional stamper to authorize signing (e.g., passkey).
567
+ * @param params.transfer - ERC20 transfer parameters.
568
+ * @returns A promise resolving to the `sendTransactionStatusId`.
569
+ * @throws {ZeroXKeyError} If amount encoding fails or ZeroXKey rejects the transaction.
570
+ */
571
+ ethSendErc20Transfer: (params: EthSendErc20TransferParams) => Promise<string>;
572
+ /**
573
+ * @beta
574
+ * * **API subject to change**
575
+ *
576
+ * Signs and submits an Ethereum transaction using a ZeroXKey-managed (embedded) wallet.
577
+ *
578
+ * This method performs **authorization and signing**, and submits the transaction
579
+ * to ZeroXKey’s coordinator. It **does not perform any polling** — callers must use
580
+ * `pollTransactionStatus` to obtain the final on-chain result.
581
+ *
582
+ * Behavior:
583
+ *
584
+ * - **Connected wallets**
585
+ * - Connected wallets are **not supported** by this method.
586
+ * - They must instead use `signAndSendTransaction`.
587
+ *
588
+ * - **Embedded wallets**
589
+ * - Constructs the payload for ZeroXKey's `eth_send_transaction` endpoint.
590
+ * - Forwards transaction fields directly to ZeroXKey's coordinator.
591
+ * - Signs and submits the transaction through ZeroXKey.
592
+ * - Returns a `sendTransactionStatusId`, which the caller must pass to
593
+ * `pollTransactionStatus` to obtain the final result (tx hash + status).
594
+ *
595
+ * @param params.organizationId - Organization ID to execute the transaction under.
596
+ * Defaults to the active session's organization.
597
+ *
598
+ * @param params.stampWith - Optional stamper to authorize signing (e.g., passkey).
599
+ *
600
+ * @param params.transaction - The Ethereum transaction details.
601
+ * @returns A promise resolving to the `sendTransactionStatusId`.
602
+ * This ID must be passed to `pollTransactionStatus`.
603
+ *
604
+ * @throws {ZeroXKeyError} If the transaction is invalid or ZeroXKey rejects it.
605
+ */
606
+ ethSendTransaction: (params: EthSendTransactionParams) => Promise<string>;
607
+ /**
608
+ * @beta
609
+ * * **API subject to change**
610
+ *
611
+ * Signs and submits a Solana transaction using a ZeroXKey-managed (embedded) wallet.
612
+ *
613
+ * This method performs **authorization and signing**, and submits the transaction
614
+ * to ZeroXKey’s coordinator. It **does not perform any polling** — callers must use
615
+ * `pollTransactionStatus` to obtain the final on-chain result.
616
+ *
617
+ * Behavior:
618
+ *
619
+ * - **Connected wallets**
620
+ * - Connected wallets are **not supported** by this method.
621
+ * - They must instead use `signAndSendTransaction`.
622
+ *
623
+ * - **Embedded wallets**
624
+ * - Constructs the payload for ZeroXKey's `sol_send_transaction` endpoint.
625
+ * - Signs and submits the transaction through ZeroXKey.
626
+ * - Returns a `sendTransactionStatusId`, which the caller must pass to
627
+ * `pollTransactionStatus` to obtain the final result (signature + status).
628
+ *
629
+ * @param params.organizationId - Organization ID to execute the transaction under.
630
+ * Defaults to the active session's organization.
631
+ * @param params.stampWith - Optional stamper to authorize signing (e.g., passkey).
632
+ * @param params.transaction - The Solana transaction details.
633
+ * @returns A promise resolving to the `sendTransactionStatusId`.
634
+ * This ID must be passed to `pollTransactionStatus`.
635
+ * @throws {ZeroXKeyError} If the transaction is invalid or ZeroXKey rejects it.
636
+ */
637
+ solSendTransaction: (params: SolSendTransactionParams) => Promise<string>;
638
+ /**
639
+ * @beta
640
+ * **API subject to change**
641
+ *
642
+ * Polls ZeroXKey for the final result of a previously submitted transaction.
643
+ *
644
+ * This function repeatedly calls `getSendTransactionStatus` until the transaction
645
+ * reaches a terminal state.
646
+ *
647
+ * Terminal states:
648
+ * - **COMPLETED** or **INCLUDED** → resolves with chain-specific transaction details
649
+ * - **FAILED** rejects with an error
650
+ *
651
+ * Behavior:
652
+ *
653
+ * - Queries ZeroXKey every 500ms.
654
+ * - Stops polling automatically when a terminal state is reached.
655
+ * - Returns the full status payload from ZeroXKey.
656
+ * - When available, Ethereum transaction details are exposed at `resp.eth.txHash`.
657
+ *
658
+ * @param params.organizationId - Organization ID under which the transaction was submitted.
659
+ * @param params.sendTransactionStatusId - Status ID returned by `ethSendTransaction` or `solSendTransaction`.
660
+ * @param params.pollingIntervalMs - Optional polling interval in milliseconds (default: 500ms).
661
+ * @param params.stampWith - Optional stamper to use for polling.
662
+ *
663
+ * @returns A promise resolving to the transaction status payload if successful.
664
+ * @throws {ZeroXKeyError} If the transaction fails, is cancelled, or times out.
665
+ */
666
+ pollTransactionStatus(params: PollTransactionStatusParams): Promise<TGetSendTransactionStatusResponse>;
667
+ /**
668
+ * Fetches the user details for the current session or a specified user.
669
+ *
670
+ * - Retrieves user details from the ZeroXKey API using the provided userId and organizationId, or defaults to those from the active session.
671
+ * - If no userId is provided, the userId from the current session is used.
672
+ * - If no organizationId is provided, the organizationId from the current session is used.
673
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
674
+ * - Ensures that an active session exists before making the request.
675
+ *
676
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
677
+ * @param params.userId - user ID to fetch specific user details (defaults to the current session's userId).
678
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
679
+ * @returns A promise that resolves to a `v1User` object containing the user details.
680
+ * @throws {ZeroXKeyError} If there is no active session, if there is no userId, or if there is an error fetching user details.
681
+ */
682
+ fetchUser: (params?: FetchUserParams) => Promise<v1User>;
683
+ /**
684
+ * Fetches an existing user by P-256 API key public key, or creates a new one if none exists.
685
+ *
686
+ * - This function is idempotent: multiple calls with the same `publicKey` will always return the same user.
687
+ * - Attempts to find a user whose API keys include the given P-256 public key.
688
+ * - If a matching user is found, it is returned as-is.
689
+ * - If no matching user is found, a new user is created with the given public key as a P-256 API key.
690
+ *
691
+ * @param params.publicKey - the P-256 public key to use for lookup and creation.
692
+ * @param params.createParams.userName - optional username to assign if creating a new user (defaults to `"Public Key User"`).
693
+ * @param params.createParams.apiKeyName - optional API key name to assign if creating a new API key (defaults to `public-key-user-${publicKey}`).
694
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
695
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
696
+ * @returns A promise that resolves to the existing or newly created {@link v1User}.
697
+ * @throws {ZeroXKeyError} If there is no active session, if the input is invalid, if user retrieval fails, or if user creation fails.
698
+ */
699
+ fetchOrCreateP256ApiKeyUser: (params: FetchOrCreateP256ApiKeyUserParams) => Promise<v1User>;
700
+ /**
701
+ * Fetches each requested policy if it exists, or creates it if it does not.
702
+ *
703
+ * - This function is idempotent: multiple calls with the same policies will not create duplicates.
704
+ * - For every policy in the request:
705
+ * - If it already exists, it is returned with its `policyId`.
706
+ * - If it does not exist, it is created and returned with its new `policyId`.
707
+ *
708
+ * @param params.policies - the list of policies to fetch or create.
709
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
710
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
711
+ * @returns A promise that resolves to an array of objects, each containing:
712
+ * - `policyId`: the unique identifier of the policy.
713
+ * - `policyName`: human-readable name of the policy.
714
+ * - `effect`: the instruction to DENY or ALLOW an activity.
715
+ * - `condition`: (optional) the condition expression that triggers the effect.
716
+ * - `consensus`: (optional) the consensus expression that triggers the effect.
717
+ * - `notes`: (optional) developer notes or description for the policy.
718
+ * @throws {ZeroXKeyError} If there is no active session, if the input is invalid,
719
+ * if fetching policies fails, or if creating policies fails.
720
+ */
721
+ fetchOrCreatePolicies: (params: FetchOrCreatePoliciesParams) => Promise<FetchOrCreatePoliciesResult>;
722
+ /**
723
+ * Updates the user's email address.
724
+ *
725
+ * - This function updates the user's email address and, if provided, verifies it using a verification token (typically from an OTP flow).
726
+ * - If a userId is provided, it updates the email for that specific user; otherwise, it uses the current session's userId.
727
+ * - If a verificationToken is not provided, the email will be updated but will not be marked as verified.
728
+ * - Automatically ensures an active session exists before making the request.
729
+ * - Handles session management and error reporting for both update and verification flows.
730
+ *
731
+ * @param params.email - new email address to set for the user.
732
+ * @param params.verificationToken - verification token from OTP email verification (required if verifying the email).
733
+ * @param params.userId - user ID to update a specific user's email (defaults to the current session's userId).
734
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
735
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
736
+ * @returns A promise that resolves to the userId of the updated user.
737
+ * @throws {ZeroXKeyError} If there is no active session, if the userId is missing, or if there is an error updating or verifying the user email.
738
+ */
739
+ updateUserEmail: (params: UpdateUserEmailParams) => Promise<string>;
740
+ /**
741
+ * Removes the user's email address.
742
+ *
743
+ * - This function removes the user's email address by setting it to an empty string.
744
+ * - If a userId is provided, it removes the email for that specific user; otherwise, it uses the current session's userId.
745
+ * - Automatically ensures an active session exists before making the request.
746
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
747
+ *
748
+ * @param params.userId - user ID to remove a specific user's email address (defaults to the current session's userId).
749
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
750
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
751
+ * @returns A promise that resolves to the userId of the user whose email was removed.
752
+ * @throws {ZeroXKeyError} If there is no active session, if the userId is missing, or if there is an error removing the user email.
753
+ */
754
+ removeUserEmail: (params?: RemoveUserEmailParams) => Promise<string>;
755
+ /**
756
+ * Updates the user's phone number.
757
+ *
758
+ * - This function updates the user's phone number and, if provided, verifies it using a verification token (from an OTP flow).
759
+ * - If a userId is provided, it updates the phone number for that specific user; otherwise, it uses the current session's userId.
760
+ * - If a verificationToken is not provided, the phone number will be updated but will not be marked as verified.
761
+ * - Automatically ensures an active session exists before making the request.
762
+ * - Handles session management and error reporting for both update and verification flows.
763
+ *
764
+ * @param params.phoneNumber - new phone number to set for the user.
765
+ * @param params.verificationToken - verification token from OTP phone verification (required if verifying the phone number).
766
+ * @param params.userId - user ID to update a specific user's phone number (defaults to the current session's userId).
767
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
768
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
769
+ * @returns A promise that resolves to the userId of the updated user.
770
+ * @throws {ZeroXKeyError} If there is no active session, if the userId is missing, or if there is an error updating or verifying the user phone number.
771
+ */
772
+ updateUserPhoneNumber: (params: UpdateUserPhoneNumberParams) => Promise<string>;
773
+ /**
774
+ * Removes the user's phone number.
775
+ *
776
+ * - This function removes the user's phone number by setting it to an empty string.
777
+ * - If a userId is provided, it removes the phone number for that specific user; otherwise, it uses the current session's userId.
778
+ * - Automatically ensures an active session exists before making the request.
779
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
780
+ *
781
+ * @param params.userId - user ID to remove a specific user's phone number (defaults to the current session's userId).
782
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
783
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
784
+ * @returns A promise that resolves to the userId of the user whose phone number was removed.
785
+ * @throws {ZeroXKeyError} If there is no active session, if the userId is missing, or if there is an error removing the user phone number.
786
+ */
787
+ removeUserPhoneNumber: (params?: RemoveUserPhoneNumberParams) => Promise<string>;
788
+ /**
789
+ * Updates the user's name.
790
+ *
791
+ * - This function updates the user's display name.
792
+ * - If a userId is provided, it updates the name for that specific user; otherwise, it uses the current session's userId.
793
+ * - Automatically ensures an active session exists before making the request.
794
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
795
+ * - Handles session management and error reporting for the update flow.
796
+ *
797
+ * @param params.userName - new name to set for the user.
798
+ * @param params.userId - user ID to update a specific user's name (defaults to the current session's userId).
799
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
800
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
801
+ * @returns A promise that resolves to the userId of the updated user.
802
+ * @throws {ZeroXKeyError} If there is no active session, if the userId is missing, or if there is an error updating the user name.
803
+ */
804
+ updateUserName: (params: UpdateUserNameParams) => Promise<string>;
805
+ /**
806
+ * Adds an OAuth provider to the user.
807
+ *
808
+ * - This function adds an OAuth provider (e.g., Google, Apple) to the user account.
809
+ * - If a userId is provided, it adds the provider for that specific user; otherwise, it uses the current session's userId.
810
+ * - Automatically checks if an account already exists for the provided OIDC token and prevents duplicate associations.
811
+ * - If the user's email is not set or not verified, attempts to update and verify the email using the email from the OIDC token.
812
+ * - Handles session management and error reporting for the add provider flow.
813
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
814
+ *
815
+ * @param params.providerName - name of the OAuth provider to add (e.g., "Google", "Apple").
816
+ * @param params.oidcToken - OIDC token for the OAuth provider.
817
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
818
+ * @param params.userId - user ID to add the provider for a specific user (defaults to current session's userId).
819
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
820
+ * @returns A promise that resolves to an array of provider IDs associated with the user.
821
+ * @throws {ZeroXKeyError} If there is no active session, if the account already exists, or if there is an error adding the OAuth provider.
822
+ */
823
+ addOauthProvider: (params: AddOauthProviderParams) => Promise<string[]>;
824
+ /**
825
+ * Removes a list of OAuth providers from the user.
826
+ *
827
+ * - This function removes OAuth providers (e.g., Google, Apple) from the user's account.
828
+ * - If a userId is provided, it removes the providers for that specific user; otherwise, it uses the current session's userId.
829
+ * - Automatically ensures an active session exists before making the request.
830
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
831
+ * - Returns an array of remaining provider IDs associated with the user after removal.
832
+ *
833
+ * @param params.providerIds - IDs of the OAuth providers to remove.
834
+ * @param params.userId - user ID to remove the provider for a specific user (defaults to the current session's userId).
835
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
836
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
837
+ * @returns A promise that resolves to an array of provider IDs that were removed.
838
+ * @throws {ZeroXKeyError} If there is no active session, if the userId is missing, or if there is an error removing the OAuth provider.
839
+ */
840
+ removeOauthProviders: (params: RemoveOauthProvidersParams) => Promise<string[]>;
841
+ /**
842
+ * Adds a new passkey authenticator for the user.
843
+ *
844
+ * - This function prompts the user to create a new passkey (WebAuthn/FIDO2) and adds it as an authenticator for the user.
845
+ * - Handles both web and React Native environments, automatically selecting the appropriate passkey creation flow.
846
+ * - If a userId is provided, the passkey is added for that specific user; otherwise, it uses the current session's userId.
847
+ * - The passkey's name and display name can be customized; if not provided, defaults are generated.
848
+ * - The resulting passkey attestation and challenge are registered with ZeroXKey as a new authenticator.
849
+ *
850
+ * @param params.name - name of the passkey (defaults to "ZeroXKey Passkey-`timestamp`").
851
+ * @param params.displayName - display name of the passkey (defaults to the value of `name`).
852
+ * @param params.userId - user ID to add the passkey for a specific user (defaults to the current session's userId).
853
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
854
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
855
+ * @returns A promise that resolves to an array of authenticator IDs for the newly added passkey(s).
856
+ * @throws {ZeroXKeyError} If there is no active session, if passkey creation fails, or if there is an error adding the passkey.
857
+ */
858
+ addPasskey: (params?: AddPasskeyParams) => Promise<string[]>;
859
+ /**
860
+ * Removes passkeys (authenticator) from the user.
861
+ *
862
+ * - This function removes passkeys (WebAuthn/FIDO2 authenticators) from the user's account.
863
+ * - If a userId is provided, it removes the passkeys for that specific user; otherwise, it uses the current session's userId.
864
+ * - Automatically ensures an active session exists before making the request.
865
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
866
+ * - Returns an array of remaining authenticator IDs for the user after removal.
867
+ *
868
+ * @param params.authenticatorIds - IDs of the authenticators (passkeys) to remove.
869
+ * @param params.userId - user ID to remove the passkeys for a specific user (defaults to the current session's userId).
870
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
871
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
872
+ * @returns A promise that resolves to an array of authenticator IDs that were removed.
873
+ * @throws {ZeroXKeyError} If there is no active session, if the userId is missing, or if there is an error removing the passkeys.
874
+ */
875
+ removePasskeys: (params: RemovePasskeyParams) => Promise<string[]>;
876
+ /**
877
+ * Creates a new wallet for sub-organization.
878
+ *
879
+ * - This function creates a new wallet for the current sub-organization.
880
+ * - If an organizationId is provided, the wallet will be created under that specific sub-organization; otherwise, it uses the current session's organizationId.
881
+ * - If a list of address formats is provided, accounts will be created in the wallet based on those formats (starting from path index 0).
882
+ * - If a list of account parameters is provided, those accounts will be created in the wallet.
883
+ * - If no accounts or address formats are provided, default Ethereum and Solana accounts will be created.
884
+ * - Optionally allows specifying the mnemonic length for the wallet seed phrase (defaults to 12).
885
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
886
+ *
887
+ * @param params.walletName - name of the wallet to create.
888
+ * @param params.accounts - array of account parameters or address formats to create in the wallet.
889
+ * @param params.organizationId - organization ID to create the wallet under a specific sub-organization (defaults to the current session's organizationId).
890
+ * @param params.mnemonicLength - mnemonic length for the wallet seed phrase (defaults to 12).
891
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
892
+ * @returns A promise that resolves to the ID of the newly created wallet.
893
+ * @throws {ZeroXKeyError} If there is no active session or if there is an error creating the wallet.
894
+ */
895
+ createWallet: (params: CreateWalletParams) => Promise<string>;
896
+ /**
897
+ * Creates new accounts in the specified wallet.
898
+ *
899
+ * - This function creates new wallet accounts based on the provided account parameters or address formats.
900
+ * - If a walletId is provided, it creates the accounts in that specific wallet; otherwise, it uses the current session's wallet.
901
+ * - If a list of address formats is provided, it will create accounts in the wallet based on those formats, automatically determining the next available path indexes to avoid duplicates with existing accounts.
902
+ * - If account parameters are provided, they are used directly for account creation.
903
+ * - Automatically queries existing wallet accounts to prevent duplicate account creation for the same address format and path.
904
+ * - Supports stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
905
+ *
906
+ * @param params.accounts - An array of account parameters or address formats to create in the wallet.
907
+ * @param params.walletId - ID of the wallet to create accounts in.
908
+ * @param params.organizationId - organization ID to create the accounts under a specific organization (walletId must be associated with the sub-organization).
909
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
910
+ * @returns A promise that resolves to an array of addresses for the newly created accounts.
911
+ * @throws {ZeroXKeyError} If there is no active session, if the wallet does not exist, or if there is an error creating the wallet accounts.
912
+ */
913
+ createWalletAccounts: (params: CreateWalletAccountsParams) => Promise<string[]>;
914
+ /**
915
+ * Exports a wallet as an encrypted bundle.
916
+ *
917
+ * - This function exports the specified wallet and its accounts as an encrypted bundle, suitable for backup or transfer.
918
+ * - The exported bundle contains the wallet's seed phrase, encrypted to the provided target public key.
919
+ * - If a targetPublicKey is provided, the bundle will be encrypted to that public key; otherwise, an error will be thrown.
920
+ * - If an organizationId is provided, the wallet will be exported under that sub-organization; otherwise, the current session's organizationId is used.
921
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
922
+ * - The exported bundle can later be imported using the `importWallet` method.
923
+ *
924
+ * @param params.walletId - ID of the wallet to export.
925
+ * @param params.targetPublicKey - public key to encrypt the bundle to (required).
926
+ * @param params.organizationId - organization ID to export the wallet under a specific sub-organization (walletId must be associated with the sub-organization).
927
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
928
+ * @returns A promise that resolves to an `ExportBundle` object containing the encrypted wallet seed phrase and metadata.
929
+ * @throws {ZeroXKeyError} If there is no active session, if the targetPublicKey is missing, or if there is an error exporting the wallet.
930
+ */
931
+ exportWallet: (params: ExportWalletParams) => Promise<ExportBundle>;
932
+ /**
933
+ * Exports a private key as an encrypted bundle.
934
+ *
935
+ * - This function exports the specified private key as an encrypted bundle, suitable for backup or transfer.
936
+ * - The exported bundle contains the private key's key material, encrypted to the provided target public key.
937
+ * - If a targetPublicKey is provided, the bundle will be encrypted to that public key; otherwise, an error will be thrown.
938
+ * - If an organizationId is provided, the private key will be exported under that sub-organization; otherwise, the current session's organizationId is used.
939
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
940
+ *
941
+ * @param params.privateKeyId - ID of the private key to export.
942
+ * @param params.targetPublicKey - public key to encrypt the bundle to (required).
943
+ * @param params.organizationId - organization ID to export the private key under a specific sub
944
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
945
+ * @returns A promise that resolves to an `ExportBundle` object containing the encrypted private key and metadata.
946
+ * @throws {ZeroXKeyError} If there is no active session, if the targetPublicKey is missing, or if there is an error exporting the private key.
947
+ */
948
+ exportPrivateKey: (params: ExportPrivateKeyParams) => Promise<ExportBundle>;
949
+ /**
950
+ * Exports a wallet account as an encrypted bundle.
951
+ *
952
+ * - This function exports the specified wallet account as an encrypted bundle, suitable for backup or transfer.
953
+ * - The exported bundle contains the wallet account's key material, encrypted to the provided target public key.
954
+ * - If a targetPublicKey is provided, the bundle will be encrypted to that public key; otherwise, an error will be thrown.
955
+ * - If an organizationId is provided, the wallet account will be exported under that sub-organization; otherwise, the current session's organizationId is used.
956
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
957
+ *
958
+ * @param params.address - address of the wallet account to export.
959
+ * @param params.targetPublicKey - public key to encrypt the bundle to.
960
+ * @param params.organizationId - organization ID to export the wallet account under a specific sub-organization.
961
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
962
+ * @returns A promise that resolves to an `ExportBundle` object containing the encrypted wallet account and metadata.
963
+ * @throws {ZeroXKeyError} If there is no active session, if the targetPublicKey is missing, or if there is an error exporting the wallet account.
964
+ *
965
+ */
966
+ exportWalletAccount: (params: ExportWalletAccountParams) => Promise<ExportBundle>;
967
+ /**
968
+ * Imports a wallet from an encrypted bundle.
969
+ *
970
+ * - This function imports a wallet using the provided encrypted bundle and creates accounts based on the provided parameters.
971
+ * - If a userId is provided, the wallet will be imported for that specific user; otherwise, it uses the current session's userId.
972
+ * - If an accounts array is provided, those accounts will be created in the imported wallet; otherwise, default Ethereum and Solana accounts will be created.
973
+ * - The encrypted bundle MUST be encrypted to
974
+ * - Automatically ensures an active session exists before making the request.
975
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
976
+ *
977
+ * @param params.encryptedBundle - encrypted bundle containing the wallet seed phrase and metadata.
978
+ * @param params.walletName - name of the wallet to create upon import.
979
+ * @param params.accounts - array of account parameters to create in the imported wallet (defaults to standard Ethereum and Solana accounts).
980
+ * @param params.organizationId - organization ID to import the wallet under a specific sub-organization (wallet will be associated with the sub-organization).
981
+ * @param params.userId - user ID to import the wallet for a specific user (defaults to the current session's userId).
982
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
983
+ * @returns A promise that resolves to the ID of the imported wallet.
984
+ * @throws {ZeroXKeyError} If there is no active session, if the encrypted bundle is invalid, or if there is an error importing the wallet.
985
+ */
986
+ importWallet: (params: ImportWalletParams) => Promise<string>;
987
+ /**
988
+ * Imports a private key from an encrypted bundle.
989
+ *
990
+ * - This function imports a private key using the provided encrypted bundle.
991
+ * - If a userId is provided, the private key will be imported for that specific user; otherwise, it uses the current session's userId.
992
+ * - Requires address formats to
993
+ * - Automatically infers the cryptographic curve used to generate the private key based on the address format (can be optionally overriden if needed).
994
+ * - The encrypted bundle MUST be encrypted to ensure security.
995
+ * - Automatically ensures an active session exists before making the request.
996
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
997
+ *
998
+ * @param params.encryptedBundle - encrypted bundle containing the private key key material and metadata.
999
+ * @param params.privateKeyName - name of the private key to create upon import.
1000
+ * @param params.curve - the cryptographic curve used to generate a given private key
1001
+ * @param params.addressFormat - address format of the private key to import.
1002
+ * @param params.organizationId - organization ID to import the private key under a specific sub-organization (private key will be associated with the sub-organization).
1003
+ * @param params.userId - user ID to import the wallet for a specific user (defaults to the current session's userId).
1004
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
1005
+ * @returns A promise that resolves to the ID of the imported wallet.
1006
+ * @throws {ZeroXKeyError} If there is no active session, if the encrypted bundle is invalid, or if there is an error importing the wallet.
1007
+ */
1008
+ importPrivateKey: (params: ImportPrivateKeyParams) => Promise<string>;
1009
+ /**
1010
+ * Deletes the current sub-organization (sub-org) for the active session.
1011
+ *
1012
+ * - This function deletes the sub-organization associated with the current active session.
1013
+ * - By default, the deletion will fail if any wallets associated with the sub-organization have not been exported.
1014
+ * - If `deleteWithoutExport` is set to true, the sub-organization will be deleted even if its wallets have not been exported (potentially resulting in loss of access to those wallets).
1015
+ * - Requires an active session; otherwise, an error is thrown.
1016
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
1017
+ *
1018
+ * @param params.deleteWithoutExport - flag to delete the sub-organization without requiring all wallets to be exported first (defaults to false).
1019
+ * @param params.organizationId - organization ID to delete a specific sub-organization (defaults to the current session's organizationId).
1020
+ * @param params.stampWith - parameter to stamp the request with a specific stamper.
1021
+ * @returns A promise that resolves to a `TDeleteSubOrganizationResponse` object containing the result of the deletion.
1022
+ * @throws {ZeroXKeyError} If there is no active session or if there is an error deleting the sub-organization.
1023
+ */
1024
+ deleteSubOrganization: (params?: DeleteSubOrganizationParams) => Promise<TDeleteSubOrganizationResponse>;
1025
+ /**
1026
+ * Stores a session token and updates the session associated with the specified session key, or by default the active session.
1027
+ *
1028
+ * - This function parses and stores a signed JWT session token in local storage, associating it with the given session key.
1029
+ * - If a sessionKey is provided, the session will be stored under that key; otherwise, it will use the default session key.
1030
+ * - If a session already exists for the session key, its associated key pair will be deleted before storing the new session.
1031
+ * - After storing the session, any unused key pairs are automatically cleared from storage.
1032
+ * - Ensures that session management is consistent and prevents orphaned key pairs.
1033
+ *
1034
+ * @param params.sessionToken - JWT session token to store.
1035
+ * @param params.sessionKey - session key to store the session under (defaults to the default session key).
1036
+ * @returns A promise that resolves when the session is successfully stored.
1037
+ * @throws {ZeroXKeyError} If there is an error storing the session or cleaning up key pairs.
1038
+ */
1039
+ storeSession: (params: StoreSessionParams) => Promise<void>;
1040
+ /**
1041
+ * Clears the session associated with the specified session key, or the active session by default.
1042
+ *
1043
+ * - This function deletes the session and its associated key pair from storage.
1044
+ * - If a sessionKey is provided, it will clear the session under that key; otherwise, it will clear the default (active) session.
1045
+ * - Removes the session data from local storage and deletes the corresponding API key pair from the key store.
1046
+ * - Throws an error if the session does not exist or if there is an error during the clearing process.
1047
+ *
1048
+ * @param params.sessionKey - session key to clear the session under (defaults to the default session key).
1049
+ * @returns A promise that resolves when the session is successfully cleared.
1050
+ * @throws {ZeroXKeyError} If the session does not exist or if there is an error clearing the session.
1051
+ */
1052
+ clearSession: (params?: ClearSessionParams) => Promise<void>;
1053
+ /**
1054
+ * Clears all sessions and resets the active session state.
1055
+ *
1056
+ * - This function removes all session data from the client and persistent storage, including all associated key pairs.
1057
+ * - Iterates through all stored session keys, clearing each session and deleting its corresponding API key pair.
1058
+ * - After clearing, there will be no active session, and all session-related data will be removed from local storage.
1059
+ * - Throws an error if no sessions exist or if there is an error during the clearing process.
1060
+ *
1061
+ * @returns A promise that resolves when all sessions are successfully cleared.
1062
+ * @throws {ZeroXKeyError} If no sessions exist or if there is an error clearing all sessions.
1063
+ */
1064
+ clearAllSessions: () => Promise<void>;
1065
+ /**
1066
+ * Refreshes the session associated with the specified session key, or the active session by default.
1067
+ *
1068
+ * - This function refreshes the session and updates the session token and key pair associated with the given session key.
1069
+ * - If a sessionKey is provided, it will refresh the session under that key; otherwise, it will use the current active session key.
1070
+ * - Optionally allows specifying a new expiration time for the session, a custom public key, and whether to invalidate the existing session after refreshing.
1071
+ * - Makes a request to the ZeroXKey API to stamp a new login and stores the refreshed session token.
1072
+ * - Automatically manages key pair cleanup and session storage to ensure consistency.
1073
+ * - Optionally allows stamping the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
1074
+ *
1075
+ * @param params.sessionKey - session key to refresh the session under (defaults to the active session key).
1076
+ * @param params.expirationSeconds - expiration time in seconds for the refreshed session (defaults to the configured default).
1077
+ * @param params.publicKey - public key to use for the refreshed session (if not provided, a new key pair will be generated).
1078
+ * @param params.invalidateExisitng - flag to invalidate the existing session before refreshing (defaults to false).
1079
+ * @param params.stampWith - parameter to stamp the request with a specific stamper.
1080
+ * @returns A promise that resolves to a `TStampLoginResponse` object containing the refreshed session details.
1081
+ * @throws {ZeroXKeyError} If the session key does not exist, if there is no active session, or if there is an error refreshing the session.
1082
+ */
1083
+ refreshSession: (params?: RefreshSessionParams) => Promise<TStampLoginResponse | undefined>;
1084
+ /**
1085
+ * Retrieves the session associated with the specified session key, or the active session by default.
1086
+ *
1087
+ * - This function retrieves the session object from storage, using the provided session key or, if not specified, the current active session key.
1088
+ * - If no session key is provided and there is no active session, it returns undefined.
1089
+ * - Returns the session details, including public key, organization ID, user ID, and expiration.
1090
+ *
1091
+ * @param params.sessionKey - session key to retrieve a specific session (defaults to the current active session key).
1092
+ * @returns A promise that resolves to a `Session` object containing the session details, or undefined if not found.
1093
+ * @throws {ZeroXKeyError} If there is an error retrieving the session from storage.
1094
+ */
1095
+ getSession: (params?: GetSessionParams) => Promise<Session | undefined>;
1096
+ /**
1097
+ * Retrieves all sessions stored in persistent storage.
1098
+ *
1099
+ * - This function fetches all session objects currently stored by the client, including those that are not active.
1100
+ * - Returns a record mapping each session key to its corresponding `Session` object.
1101
+ * - Useful for session management, auditing, or displaying all available sessions to the user.
1102
+ * - Automatically skips any session keys that do not have a valid session object.
1103
+ *
1104
+ * @returns A promise that resolves to a record of session keys and their corresponding `Session` objects, or `undefined` if no sessions exist.
1105
+ * @throws {ZeroXKeyError} If there is an error retrieving sessions from storage.
1106
+ */
1107
+ getAllSessions: () => Promise<Record<string, Session> | undefined>;
1108
+ /**
1109
+ * Sets the active session to the specified session key.
1110
+ *
1111
+ * - This function updates the `activeSessionKey` in persistent storage to the specified session key.
1112
+ * - Ensures that subsequent operations use the session associated with this key as the active session.
1113
+ * - Does not validate whether the session key exists or is valid; it simply updates the pointer.
1114
+ * - Useful for switching between multiple stored sessions or restoring a previous session context.
1115
+ *
1116
+ * @param params.sessionKey - session key to set as the active session.
1117
+ * @returns A promise that resolves when the active session key is successfully set.
1118
+ * @throws {ZeroXKeyError} If the client is not initialized or if there is an error setting the active session key.
1119
+ */
1120
+ setActiveSession: (params: SetActiveSessionParams) => Promise<void>;
1121
+ /**
1122
+ * Retrieves the active session key currently set in persistent storage.
1123
+ *
1124
+ * - This function fetches the session key that is currently marked as active in the client's persistent storage.
1125
+ * - The active session key determines which session is used for all session-dependent operations.
1126
+ * - If no active session key is set, returns `undefined`.
1127
+ * - Useful for determining which session is currently in use, especially when managing multiple sessions.
1128
+ *
1129
+ * @returns A promise that resolves to the active session key as a string, or `undefined` if no active session is set.
1130
+ * @throws {ZeroXKeyError} If there is an error retrieving the active session key from storage.
1131
+ */
1132
+ getActiveSessionKey: () => Promise<string | undefined>;
1133
+ /**
1134
+ * Clears any unused API key pairs from persistent storage.
1135
+ *
1136
+ * - This function scans all API key pairs stored in indexedDB and removes any key pairs that are not associated with a session in persistent storage.
1137
+ * - Ensures that only key pairs referenced by existing sessions are retained, preventing orphaned or stale key pairs from accumulating.
1138
+ * - Iterates through all stored session keys and builds a map of in-use public keys, then deletes any key pairs not present in this map.
1139
+ * - Intended to be called after session changes (e.g., login, logout, session replacement) to keep key storage clean and secure.
1140
+ *
1141
+ * @returns A promise that resolves when all unused key pairs are successfully cleared.
1142
+ * @throws {ZeroXKeyError} If there is an error listing, checking, or deleting unused key pairs.
1143
+ */
1144
+ clearUnusedKeyPairs: () => Promise<void>;
1145
+ /**
1146
+ * Creates a new API key pair and returns the public key.
1147
+ *
1148
+ * - This function generates a new API key pair and stores it in the underlying key store (IndexedDB).
1149
+ * - If an external key pair is provided, it will use that key pair for creation instead of generating a new one.
1150
+ * - If `storeOverride` is set to true, the generated or provided public key will be set as the override key in the API key stamper, making it the active key for subsequent signing operations.
1151
+ * - Ensures the API key stamper is initialized before proceeding.
1152
+ * - Handles both native CryptoKeyPair objects and raw key material.
1153
+ *
1154
+ * @param params.externalKeyPair - An externally generated key pair (either a CryptoKeyPair or an object with publicKey/privateKey strings) to use instead of generating a new one.
1155
+ * @param params.storeOverride - If true, sets the generated or provided public key as the override key in the API key stamper (defaults to false).
1156
+ * @return A promise that resolves to the public key of the created or provided API key pair as a string.
1157
+ * @throws {ZeroXKeyError} If the API key stamper is not initialized or if there is an error during key pair creation or storage.
1158
+ */
1159
+ createApiKeyPair: (params?: CreateApiKeyPairParams) => Promise<string>;
1160
+ /**
1161
+ * Fetches the WalletKit proxy authentication configuration from the auth proxy.
1162
+ *
1163
+ * - This function makes a request to the ZeroXKey auth proxy to retrieve the current WalletKit configuration,
1164
+ * including supported authentication methods, OAuth providers, and any custom proxy settings.
1165
+ * - Useful for dynamically configuring the client UI or authentication flows based on the proxy's capabilities.
1166
+ * - Ensures that the client is aware of the latest proxy-side configuration, which may affect available login/signup options.
1167
+ *
1168
+ * @returns A promise that resolves to a `ProxyTGetWalletKitConfigResponse` object containing the proxy authentication configuration.
1169
+ * @throws {ZeroXKeyError} If there is an error retrieving the proxy authentication configuration from the auth proxy.
1170
+ */
1171
+ getProxyAuthConfig: () => Promise<ProxyTGetWalletKitConfigResponse>;
1172
+ /**
1173
+ * Fetches the boot proof for a given app proof.
1174
+ *
1175
+ * - This function is idempotent: multiple calls with the same `app proof` will always return the boot proof.
1176
+ * - Attempts to find the boot proof for the given app proof.
1177
+ * - If a boot proof is found, it is returned as is.
1178
+ * - If no boot proof is found, an error is thrown.
1179
+ *
1180
+ * @param params.appProof - the app proof for which the boot proof is being fetched.
1181
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
1182
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
1183
+ * @returns A promise that resolves to the {@link v1BootProof} associated with the given app proof.
1184
+ * @throws {ZeroXKeyError} If there is no active session, if the input is invalid, or if boot proof retrieval fails.
1185
+ */
1186
+ fetchBootProofForAppProof: (params: FetchBootProofForAppProofParams) => Promise<v1BootProof>;
1187
+ /**
1188
+ * Verifies a list of app proofs against their corresponding boot proofs.
1189
+ *
1190
+ * - This function iterates through each provided app proof, fetches the corresponding boot proof, and verifies the app proof against the boot proof.
1191
+ * - If any app proof fails verification, an error is thrown.
1192
+ * @param params.appProofs - the app proofs to verify.
1193
+ * @param params.organizationId - organization ID to specify the sub-organization (defaults to the current session's organizationId).
1194
+ * @param params.stampWith - parameter to stamp the request with a specific stamper (StamperType.Passkey, StamperType.ApiKey, or StamperType.Wallet).
1195
+ * @returns A promise that resolves when all app proofs have been successfully verified.
1196
+ * @throws {ZeroXKeyError} If there is no active session, if the input is invalid, or if verification fails.
1197
+ */
1198
+ verifyAppProofs: (params: VerifyAppProofsParams) => Promise<void>;
1199
+ }
1200
+ export {};
1201
+ //# sourceMappingURL=core.d.ts.map