@privy-io/node 0.10.0 → 0.11.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 (230) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/client.d.mts +38 -20
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +38 -20
  5. package/client.d.ts.map +1 -1
  6. package/client.js +31 -12
  7. package/client.js.map +1 -1
  8. package/client.mjs +32 -13
  9. package/client.mjs.map +1 -1
  10. package/index.d.mts +2 -0
  11. package/index.d.mts.map +1 -1
  12. package/index.d.ts +2 -0
  13. package/index.d.ts.map +1 -1
  14. package/index.js.map +1 -1
  15. package/index.mjs.map +1 -1
  16. package/internal/tslib.js +17 -17
  17. package/internal/utils/query.d.mts +2 -0
  18. package/internal/utils/query.d.mts.map +1 -0
  19. package/internal/utils/query.d.ts +2 -0
  20. package/internal/utils/query.d.ts.map +1 -0
  21. package/internal/utils/query.js +10 -0
  22. package/internal/utils/query.js.map +1 -0
  23. package/internal/utils/query.mjs +6 -0
  24. package/internal/utils/query.mjs.map +1 -0
  25. package/internal/utils.d.mts +1 -0
  26. package/internal/utils.d.ts +1 -0
  27. package/internal/utils.js +1 -0
  28. package/internal/utils.js.map +1 -1
  29. package/internal/utils.mjs +1 -0
  30. package/package.json +12 -1
  31. package/public-api/PrivyClient.d.mts +3 -0
  32. package/public-api/PrivyClient.d.mts.map +1 -1
  33. package/public-api/PrivyClient.d.ts +3 -0
  34. package/public-api/PrivyClient.d.ts.map +1 -1
  35. package/public-api/PrivyClient.js +5 -0
  36. package/public-api/PrivyClient.js.map +1 -1
  37. package/public-api/PrivyClient.mjs +5 -0
  38. package/public-api/PrivyClient.mjs.map +1 -1
  39. package/public-api/services/apps.d.mts +25 -0
  40. package/public-api/services/apps.d.mts.map +1 -0
  41. package/public-api/services/apps.d.ts +25 -0
  42. package/public-api/services/apps.d.ts.map +1 -0
  43. package/public-api/services/apps.js +56 -0
  44. package/public-api/services/apps.js.map +1 -0
  45. package/public-api/services/apps.mjs +52 -0
  46. package/public-api/services/apps.mjs.map +1 -0
  47. package/public-api/services/policies.d.mts +6 -2
  48. package/public-api/services/policies.d.mts.map +1 -1
  49. package/public-api/services/policies.d.ts +6 -2
  50. package/public-api/services/policies.d.ts.map +1 -1
  51. package/public-api/services/policies.js +6 -0
  52. package/public-api/services/policies.js.map +1 -1
  53. package/public-api/services/policies.mjs +6 -0
  54. package/public-api/services/policies.mjs.map +1 -1
  55. package/public-api/services/wallets.d.mts +5 -1
  56. package/public-api/services/wallets.d.mts.map +1 -1
  57. package/public-api/services/wallets.d.ts +5 -1
  58. package/public-api/services/wallets.d.ts.map +1 -1
  59. package/public-api/services/wallets.js +6 -0
  60. package/public-api/services/wallets.js.map +1 -1
  61. package/public-api/services/wallets.mjs +6 -0
  62. package/public-api/services/wallets.mjs.map +1 -1
  63. package/resources/accounts.d.mts +195 -4
  64. package/resources/accounts.d.mts.map +1 -1
  65. package/resources/accounts.d.ts +195 -4
  66. package/resources/accounts.d.ts.map +1 -1
  67. package/resources/apps/allowlist.d.mts +81 -0
  68. package/resources/apps/allowlist.d.mts.map +1 -0
  69. package/resources/apps/allowlist.d.ts +81 -0
  70. package/resources/apps/allowlist.d.ts.map +1 -0
  71. package/resources/apps/allowlist.js +56 -0
  72. package/resources/apps/allowlist.js.map +1 -0
  73. package/resources/apps/allowlist.mjs +52 -0
  74. package/resources/apps/allowlist.mjs.map +1 -0
  75. package/resources/apps/apps.d.mts +238 -0
  76. package/resources/apps/apps.d.mts.map +1 -0
  77. package/resources/apps/apps.d.ts +238 -0
  78. package/resources/apps/apps.d.ts.map +1 -0
  79. package/resources/apps/apps.js +44 -0
  80. package/resources/apps/apps.js.map +1 -0
  81. package/resources/apps/apps.mjs +39 -0
  82. package/resources/apps/apps.mjs.map +1 -0
  83. package/resources/apps/index.d.mts +3 -0
  84. package/resources/apps/index.d.mts.map +1 -0
  85. package/resources/apps/index.d.ts +3 -0
  86. package/resources/apps/index.d.ts.map +1 -0
  87. package/resources/apps/index.js +9 -0
  88. package/resources/apps/index.js.map +1 -0
  89. package/resources/apps/index.mjs +4 -0
  90. package/resources/apps/index.mjs.map +1 -0
  91. package/resources/apps.d.mts +1 -151
  92. package/resources/apps.d.mts.map +1 -1
  93. package/resources/apps.d.ts +1 -151
  94. package/resources/apps.d.ts.map +1 -1
  95. package/resources/apps.js +2 -5
  96. package/resources/apps.js.map +1 -1
  97. package/resources/apps.mjs +1 -3
  98. package/resources/apps.mjs.map +1 -1
  99. package/resources/client-auth.d.mts +144 -1
  100. package/resources/client-auth.d.mts.map +1 -1
  101. package/resources/client-auth.d.ts +144 -1
  102. package/resources/client-auth.d.ts.map +1 -1
  103. package/resources/index.d.mts +11 -10
  104. package/resources/index.d.mts.map +1 -1
  105. package/resources/index.d.ts +11 -10
  106. package/resources/index.d.ts.map +1 -1
  107. package/resources/index.js +4 -2
  108. package/resources/index.js.map +1 -1
  109. package/resources/index.mjs +3 -2
  110. package/resources/index.mjs.map +1 -1
  111. package/resources/intents.d.mts +2815 -31
  112. package/resources/intents.d.mts.map +1 -1
  113. package/resources/intents.d.ts +2815 -31
  114. package/resources/intents.d.ts.map +1 -1
  115. package/resources/intents.js +156 -0
  116. package/resources/intents.js.map +1 -1
  117. package/resources/intents.mjs +156 -0
  118. package/resources/intents.mjs.map +1 -1
  119. package/resources/key-quorums.d.mts +45 -2
  120. package/resources/key-quorums.d.mts.map +1 -1
  121. package/resources/key-quorums.d.ts +45 -2
  122. package/resources/key-quorums.d.ts.map +1 -1
  123. package/resources/key-quorums.js +18 -1
  124. package/resources/key-quorums.js.map +1 -1
  125. package/resources/key-quorums.mjs +18 -1
  126. package/resources/key-quorums.mjs.map +1 -1
  127. package/resources/kraken-embed.d.mts +62 -0
  128. package/resources/kraken-embed.d.mts.map +1 -0
  129. package/resources/kraken-embed.d.ts +62 -0
  130. package/resources/kraken-embed.d.ts.map +1 -0
  131. package/resources/kraken-embed.js +9 -0
  132. package/resources/kraken-embed.js.map +1 -0
  133. package/resources/kraken-embed.mjs +5 -0
  134. package/resources/kraken-embed.mjs.map +1 -0
  135. package/resources/policies.d.mts +63 -56
  136. package/resources/policies.d.mts.map +1 -1
  137. package/resources/policies.d.ts +63 -56
  138. package/resources/policies.d.ts.map +1 -1
  139. package/resources/policies.js +3 -0
  140. package/resources/policies.js.map +1 -1
  141. package/resources/policies.mjs +3 -0
  142. package/resources/policies.mjs.map +1 -1
  143. package/resources/transactions.d.mts +3 -0
  144. package/resources/transactions.d.mts.map +1 -1
  145. package/resources/transactions.d.ts +3 -0
  146. package/resources/transactions.d.ts.map +1 -1
  147. package/resources/transactions.js +3 -0
  148. package/resources/transactions.js.map +1 -1
  149. package/resources/transactions.mjs +3 -0
  150. package/resources/transactions.mjs.map +1 -1
  151. package/resources/users.d.mts +50 -47
  152. package/resources/users.d.mts.map +1 -1
  153. package/resources/users.d.ts +50 -47
  154. package/resources/users.d.ts.map +1 -1
  155. package/resources/users.js +3 -0
  156. package/resources/users.js.map +1 -1
  157. package/resources/users.mjs +3 -0
  158. package/resources/users.mjs.map +1 -1
  159. package/resources/wallets/balance.d.mts +7 -4
  160. package/resources/wallets/balance.d.mts.map +1 -1
  161. package/resources/wallets/balance.d.ts +7 -4
  162. package/resources/wallets/balance.d.ts.map +1 -1
  163. package/resources/wallets/balance.js +3 -0
  164. package/resources/wallets/balance.js.map +1 -1
  165. package/resources/wallets/balance.mjs +3 -0
  166. package/resources/wallets/balance.mjs.map +1 -1
  167. package/resources/wallets/index.d.mts +1 -1
  168. package/resources/wallets/index.d.mts.map +1 -1
  169. package/resources/wallets/index.d.ts +1 -1
  170. package/resources/wallets/index.d.ts.map +1 -1
  171. package/resources/wallets/index.js.map +1 -1
  172. package/resources/wallets/index.mjs.map +1 -1
  173. package/resources/wallets/transactions.d.mts +9 -6
  174. package/resources/wallets/transactions.d.mts.map +1 -1
  175. package/resources/wallets/transactions.d.ts +9 -6
  176. package/resources/wallets/transactions.d.ts.map +1 -1
  177. package/resources/wallets/transactions.js +3 -0
  178. package/resources/wallets/transactions.js.map +1 -1
  179. package/resources/wallets/transactions.mjs +3 -0
  180. package/resources/wallets/transactions.mjs.map +1 -1
  181. package/resources/wallets/wallets.d.mts +129 -72
  182. package/resources/wallets/wallets.d.mts.map +1 -1
  183. package/resources/wallets/wallets.d.ts +129 -72
  184. package/resources/wallets/wallets.d.ts.map +1 -1
  185. package/resources/wallets/wallets.js +11 -5
  186. package/resources/wallets/wallets.js.map +1 -1
  187. package/resources/wallets/wallets.mjs +11 -5
  188. package/resources/wallets/wallets.mjs.map +1 -1
  189. package/resources/webhooks.d.mts +319 -283
  190. package/resources/webhooks.d.mts.map +1 -1
  191. package/resources/webhooks.d.ts +319 -283
  192. package/resources/webhooks.d.ts.map +1 -1
  193. package/resources/webhooks.js.map +1 -1
  194. package/resources/webhooks.mjs.map +1 -1
  195. package/resources/yield.d.mts +26 -9
  196. package/resources/yield.d.mts.map +1 -1
  197. package/resources/yield.d.ts +26 -9
  198. package/resources/yield.d.ts.map +1 -1
  199. package/src/client.ts +203 -42
  200. package/src/index.ts +10 -0
  201. package/src/internal/utils/query.ts +7 -0
  202. package/src/internal/utils.ts +1 -0
  203. package/src/public-api/PrivyClient.ts +7 -0
  204. package/src/public-api/services/apps.ts +85 -0
  205. package/src/public-api/services/policies.ts +15 -1
  206. package/src/public-api/services/wallets.ts +14 -0
  207. package/src/resources/accounts.ts +233 -3
  208. package/src/resources/apps/allowlist.ts +126 -0
  209. package/src/resources/apps/apps.ts +391 -0
  210. package/src/resources/apps/index.ts +20 -0
  211. package/src/resources/apps.ts +1 -257
  212. package/src/resources/client-auth.ts +202 -0
  213. package/src/resources/index.ts +94 -21
  214. package/src/resources/intents.ts +4579 -40
  215. package/src/resources/key-quorums.ts +50 -2
  216. package/src/resources/kraken-embed.ts +85 -0
  217. package/src/resources/policies.ts +83 -76
  218. package/src/resources/transactions.ts +3 -0
  219. package/src/resources/users.ts +66 -63
  220. package/src/resources/wallets/balance.ts +9 -2
  221. package/src/resources/wallets/index.ts +4 -2
  222. package/src/resources/wallets/transactions.ts +10 -4
  223. package/src/resources/wallets/wallets.ts +175 -97
  224. package/src/resources/webhooks.ts +454 -438
  225. package/src/resources/yield.ts +39 -10
  226. package/src/version.ts +1 -1
  227. package/version.d.mts +1 -1
  228. package/version.d.ts +1 -1
  229. package/version.js +1 -1
  230. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -11,7 +11,7 @@ import type { APIResponseProps } from './internal/parse';
11
11
  import { getPlatformHeaders } from './internal/detect-platform';
12
12
  import * as Shims from './internal/shims';
13
13
  import * as Opts from './internal/request-options';
14
- import * as qs from './internal/qs';
14
+ import { stringifyQuery } from './internal/utils/query';
15
15
  import { VERSION } from './version';
16
16
  import * as Errors from './core/error';
17
17
  import * as Pagination from './core/pagination';
@@ -20,11 +20,19 @@ import * as Uploads from './core/uploads';
20
20
  import * as API from './resources/index';
21
21
  import { APIPromise } from './core/api-promise';
22
22
  import {
23
+ AccountBalanceParams,
24
+ AccountBalanceResponse,
25
+ AccountDisplayName,
23
26
  AccountResponse,
24
27
  AccountWallet,
25
28
  AccountWalletConfigurationItem,
29
+ AccountWalletsConfiguration,
26
30
  Accounts,
31
+ AccountsDashboardListResponse,
32
+ AccountsListResponse,
33
+ AssetAccountWithBalance,
27
34
  CreateAccountInput,
35
+ UpdateAccountInput,
28
36
  } from './resources/accounts';
29
37
  import {
30
38
  Aggregation,
@@ -36,7 +44,6 @@ import {
36
44
  Aggregations,
37
45
  } from './resources/aggregations';
38
46
  import { Analytics, AnalyticsEventInput } from './resources/analytics';
39
- import { AppResponse, Apps } from './resources/apps';
40
47
  import {
41
48
  BridgeBrlFiatVirtualAccountDepositInstructions,
42
49
  BridgeDestinationAsset,
@@ -56,19 +63,59 @@ import {
56
63
  BridgeSandboxFiatVirtualAccountResponse,
57
64
  BridgeSourceAsset,
58
65
  BridgeUsdFiatVirtualAccountDepositInstructions,
66
+ Caip2ChainID,
59
67
  ClientAuth,
60
68
  CreateOrUpdateFiatCustomerRequestInput,
69
+ CryptoCurrencyCode,
61
70
  CustomOAuthProviderID,
62
71
  ExternalOAuthProviderID,
72
+ FiatAmount,
73
+ FiatCurrencyCode,
63
74
  FiatCustomerResponse,
75
+ FiatOnrampDestination,
76
+ FiatOnrampEnvironment,
77
+ FiatOnrampProvider,
78
+ FiatOnrampQuote,
79
+ FiatOnrampSource,
80
+ FiatOnrampTransactionStatus,
64
81
  FiatVirtualAccountRequest,
65
82
  FiatVirtualAccountResponse,
66
83
  GetFiatCustomerRequestInput,
84
+ GetFiatOnrampQuotesInput,
85
+ GetFiatOnrampQuotesResponse,
86
+ GetFiatOnrampTransactionStatusInput,
87
+ GetFiatOnrampTransactionStatusResponse,
88
+ GetFiatOnrampURLInput,
89
+ GetFiatOnrampURLResponse,
67
90
  OAuthProviderID,
68
91
  OnrampProvider,
69
92
  PrivyOAuthProviderID,
70
93
  } from './resources/client-auth';
71
- import { IntentAuthorizationKeyQuorumMember, IntentAuthorizationMember, Intents } from './resources/intents';
94
+ import {
95
+ BaseActionResult,
96
+ IntentAuthorization,
97
+ IntentAuthorizationKeyQuorumMember,
98
+ IntentAuthorizationMember,
99
+ IntentCreatePolicyRuleParams,
100
+ IntentDeletePolicyRuleParams,
101
+ IntentListParams,
102
+ IntentResponse,
103
+ IntentResponsesCursor,
104
+ IntentRpcParams,
105
+ IntentStatus,
106
+ IntentType,
107
+ IntentUpdateKeyQuorumParams,
108
+ IntentUpdatePolicyParams,
109
+ IntentUpdatePolicyRuleParams,
110
+ IntentUpdateWalletParams,
111
+ Intents,
112
+ KeyQuorumIntentResponse,
113
+ PolicyIntentResponse,
114
+ RpcIntentResponse,
115
+ RuleIntentRequestDetails,
116
+ RuleIntentResponse,
117
+ WalletIntentResponse,
118
+ } from './resources/intents';
72
119
  import {
73
120
  KeyQuorum,
74
121
  KeyQuorumCreateParams,
@@ -77,6 +124,12 @@ import {
77
124
  KeyQuorumUpdateParams,
78
125
  KeyQuorums,
79
126
  } from './resources/key-quorums';
127
+ import {
128
+ KrakenEmbed,
129
+ KrakenEmbedCurrentDayPnl,
130
+ KrakenEmbedGetPortfolioSummaryQueryParams,
131
+ KrakenEmbedGetPortfolioSummaryResponse,
132
+ } from './resources/kraken-embed';
80
133
  import {
81
134
  Policies,
82
135
  Policy,
@@ -190,14 +243,16 @@ import {
190
243
  import {
191
244
  FundsDepositedWebhookPayload,
192
245
  FundsWithdrawnWebhookPayload,
246
+ IntentAuthorizedWebhookPayload,
247
+ IntentCreatedWebhookPayload,
248
+ IntentExecutedWebhookPayload,
249
+ IntentFailedWebhookPayload,
193
250
  KrakenEmbedQuoteCancelledWebhookPayload,
194
251
  KrakenEmbedQuoteExecutedWebhookPayload,
195
252
  KrakenEmbedQuoteExecutionFailedWebhookPayload,
196
253
  KrakenEmbedUserClosedWebhookPayload,
197
254
  KrakenEmbedUserDisabledWebhookPayload,
198
255
  KrakenEmbedUserVerifiedWebhookPayload,
199
- KrakenEmbedVerificationCompletedWebhookPayload,
200
- KrakenEmbedVerificationFailedWebhookPayload,
201
256
  MfaDisabledWebhookPayload,
202
257
  MfaEnabledWebhookPayload,
203
258
  PrivateKeyExportWebhookPayload,
@@ -211,13 +266,16 @@ import {
211
266
  UserAuthenticatedWebhookPayload,
212
267
  UserCreatedWebhookPayload,
213
268
  UserLinkedAccountWebhookPayload,
269
+ UserOperationCompletedWebhookPayload,
214
270
  UserTransferredAccountWebhookPayload,
215
271
  UserUnlinkedAccountWebhookPayload,
216
272
  UserUpdatedAccountWebhookPayload,
217
273
  UserWalletCreatedWebhookPayload,
218
274
  WalletRecoveredWebhookPayload,
219
275
  WalletRecoverySetupWebhookPayload,
276
+ WebhookPayload,
220
277
  Webhooks,
278
+ YieldClaimConfirmedWebhookPayload,
221
279
  YieldDepositConfirmedWebhookPayload,
222
280
  YieldWithdrawConfirmedWebhookPayload,
223
281
  } from './resources/webhooks';
@@ -226,6 +284,7 @@ import {
226
284
  EthereumVaultDetailsResponse,
227
285
  EthereumVaultPosition,
228
286
  EthereumVaultResponse,
287
+ EthereumYieldClaimIDInput,
229
288
  EthereumYieldClaimInput,
230
289
  EthereumYieldClaimResponse,
231
290
  EthereumYieldClaimReward,
@@ -241,6 +300,18 @@ import {
241
300
  EvmCaip2ChainID,
242
301
  Yield,
243
302
  } from './resources/yield';
303
+ import {
304
+ AllowlistDeletionResponse,
305
+ AllowlistEntry,
306
+ AppResponse,
307
+ Apps,
308
+ EmailInviteInput,
309
+ PhoneInviteInput,
310
+ TestAccount,
311
+ TestAccountsResponse,
312
+ UserInviteInput,
313
+ WalletInviteInput,
314
+ } from './resources/apps/apps';
244
315
  import {
245
316
  CurveSigningChainType,
246
317
  CustodialWallet,
@@ -291,9 +362,11 @@ import {
291
362
  WalletRawSignParams,
292
363
  WalletRawSignResponse,
293
364
  WalletRpcParams,
365
+ WalletRpcRequestBody,
294
366
  WalletRpcResponse,
295
367
  WalletSubmitImportParams,
296
368
  WalletUpdateParams,
369
+ WalletUpdateRequestBody,
297
370
  Wallets,
298
371
  WalletsCursor,
299
372
  } from './resources/wallets/wallets';
@@ -548,8 +621,8 @@ export class PrivyAPI {
548
621
  return buildHeaders([{ Authorization }]);
549
622
  }
550
623
 
551
- protected stringifyQuery(query: Record<string, unknown>): string {
552
- return qs.stringify(query, { arrayFormat: 'comma' });
624
+ protected stringifyQuery(query: object | Record<string, unknown>): string {
625
+ return stringifyQuery(query);
553
626
  }
554
627
 
555
628
  private getUserAgent(): string {
@@ -581,12 +654,13 @@ export class PrivyAPI {
581
654
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
582
655
 
583
656
  const defaultQuery = this.defaultQuery();
584
- if (!isEmptyObj(defaultQuery)) {
585
- query = { ...defaultQuery, ...query };
657
+ const pathQuery = Object.fromEntries(url.searchParams);
658
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
659
+ query = { ...pathQuery, ...defaultQuery, ...query };
586
660
  }
587
661
 
588
662
  if (typeof query === 'object' && query && !Array.isArray(query)) {
589
- url.search = this.stringifyQuery(query as Record<string, unknown>);
663
+ url.search = this.stringifyQuery(query);
590
664
  }
591
665
 
592
666
  return url.toString();
@@ -915,9 +989,9 @@ export class PrivyAPI {
915
989
  }
916
990
  }
917
991
 
918
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
919
- // just do what it says, but otherwise calculate a default
920
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
992
+ // If the API asks us to wait a certain amount of time, just do what it
993
+ // says, but otherwise calculate a default
994
+ if (timeoutMillis === undefined) {
921
995
  const maxRetries = options.maxRetries ?? this.maxRetries;
922
996
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
923
997
  }
@@ -1050,7 +1124,7 @@ export class PrivyAPI {
1050
1124
  ) {
1051
1125
  return {
1052
1126
  bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
1053
- body: this.stringifyQuery(body as Record<string, unknown>),
1127
+ body: this.stringifyQuery(body),
1054
1128
  };
1055
1129
  } else {
1056
1130
  return this.#encoder({ body, headers });
@@ -1077,18 +1151,34 @@ export class PrivyAPI {
1077
1151
  static toFile = Uploads.toFile;
1078
1152
 
1079
1153
  wallets: API.Wallets = new API.Wallets(this);
1154
+ /**
1155
+ * Operations related to users
1156
+ */
1080
1157
  users: API.Users = new API.Users(this);
1158
+ /**
1159
+ * Operations related to policies
1160
+ */
1081
1161
  policies: API.Policies = new API.Policies(this);
1162
+ /**
1163
+ * Operations related to transactions
1164
+ */
1082
1165
  transactions: API.Transactions = new API.Transactions(this);
1166
+ /**
1167
+ * Operations related to key quorums
1168
+ */
1083
1169
  keyQuorums: API.KeyQuorums = new API.KeyQuorums(this);
1170
+ intents: API.Intents = new API.Intents(this);
1171
+ /**
1172
+ * Operations related to app settings and allowlist management
1173
+ */
1174
+ apps: API.Apps = new API.Apps(this);
1084
1175
  clientAuth: API.ClientAuth = new API.ClientAuth(this);
1085
1176
  analytics: API.Analytics = new API.Analytics(this);
1086
- apps: API.Apps = new API.Apps(this);
1087
1177
  aggregations: API.Aggregations = new API.Aggregations(this);
1088
1178
  webhooks: API.Webhooks = new API.Webhooks(this);
1089
1179
  accounts: API.Accounts = new API.Accounts(this);
1090
1180
  yield: API.Yield = new API.Yield(this);
1091
- intents: API.Intents = new API.Intents(this);
1181
+ krakenEmbed: API.KrakenEmbed = new API.KrakenEmbed(this);
1092
1182
  }
1093
1183
 
1094
1184
  PrivyAPI.Wallets = Wallets;
@@ -1096,14 +1186,15 @@ PrivyAPI.Users = Users;
1096
1186
  PrivyAPI.Policies = Policies;
1097
1187
  PrivyAPI.Transactions = Transactions;
1098
1188
  PrivyAPI.KeyQuorums = KeyQuorums;
1189
+ PrivyAPI.Intents = Intents;
1190
+ PrivyAPI.Apps = Apps;
1099
1191
  PrivyAPI.ClientAuth = ClientAuth;
1100
1192
  PrivyAPI.Analytics = Analytics;
1101
- PrivyAPI.Apps = Apps;
1102
1193
  PrivyAPI.Aggregations = Aggregations;
1103
1194
  PrivyAPI.Webhooks = Webhooks;
1104
1195
  PrivyAPI.Accounts = Accounts;
1105
1196
  PrivyAPI.Yield = Yield;
1106
- PrivyAPI.Intents = Intents;
1197
+ PrivyAPI.KrakenEmbed = KrakenEmbed;
1107
1198
 
1108
1199
  export declare namespace PrivyAPI {
1109
1200
  export type RequestOptions = Opts.RequestOptions;
@@ -1113,7 +1204,6 @@ export declare namespace PrivyAPI {
1113
1204
 
1114
1205
  export {
1115
1206
  Wallets as Wallets,
1116
- type Wallet as Wallet,
1117
1207
  type CurveSigningChainType as CurveSigningChainType,
1118
1208
  type ExtendedChainType as ExtendedChainType,
1119
1209
  type FirstClassChainType as FirstClassChainType,
@@ -1125,6 +1215,8 @@ export declare namespace PrivyAPI {
1125
1215
  type CustodialWallet as CustodialWallet,
1126
1216
  type HpkeImportConfig as HpkeImportConfig,
1127
1217
  type SuiCommandName as SuiCommandName,
1218
+ type Wallet as Wallet,
1219
+ type WalletUpdateRequestBody as WalletUpdateRequestBody,
1128
1220
  type WalletBatchItemInput as WalletBatchItemInput,
1129
1221
  type WalletBatchCreateInput as WalletBatchCreateInput,
1130
1222
  type WalletBatchCreateResult as WalletBatchCreateResult,
@@ -1149,10 +1241,11 @@ export declare namespace PrivyAPI {
1149
1241
  type SolanaSignTransactionRpcResponse as SolanaSignTransactionRpcResponse,
1150
1242
  type SolanaSignAndSendTransactionRpcResponse as SolanaSignAndSendTransactionRpcResponse,
1151
1243
  type SolanaSignMessageRpcResponse as SolanaSignMessageRpcResponse,
1244
+ type WalletRpcRequestBody as WalletRpcRequestBody,
1245
+ type WalletRpcResponse as WalletRpcResponse,
1152
1246
  type WalletExportResponse as WalletExportResponse,
1153
1247
  type WalletInitImportResponse as WalletInitImportResponse,
1154
1248
  type WalletRawSignResponse as WalletRawSignResponse,
1155
- type WalletRpcResponse as WalletRpcResponse,
1156
1249
  type WalletAuthenticateWithJwtResponse as WalletAuthenticateWithJwtResponse,
1157
1250
  type WalletCreateWalletsWithRecoveryResponse as WalletCreateWalletsWithRecoveryResponse,
1158
1251
  type WalletsCursor as WalletsCursor,
@@ -1170,8 +1263,6 @@ export declare namespace PrivyAPI {
1170
1263
 
1171
1264
  export {
1172
1265
  Users as Users,
1173
- type AuthenticatedUser as AuthenticatedUser,
1174
- type User as User,
1175
1266
  type LinkedAccountEmail as LinkedAccountEmail,
1176
1267
  type LinkedAccountPhone as LinkedAccountPhone,
1177
1268
  type LinkedAccountBaseWallet as LinkedAccountBaseWallet,
@@ -1234,8 +1325,10 @@ export declare namespace PrivyAPI {
1234
1325
  type TotpMfaMethod as TotpMfaMethod,
1235
1326
  type PasskeyMfaMethod as PasskeyMfaMethod,
1236
1327
  type LinkedMfaMethod as LinkedMfaMethod,
1328
+ type User as User,
1237
1329
  type OAuthTokens as OAuthTokens,
1238
1330
  type UserWithIdentityToken as UserWithIdentityToken,
1331
+ type AuthenticatedUser as AuthenticatedUser,
1239
1332
  type UsersCursor as UsersCursor,
1240
1333
  type UserCreateParams as UserCreateParams,
1241
1334
  type UserListParams as UserListParams,
@@ -1259,12 +1352,12 @@ export declare namespace PrivyAPI {
1259
1352
 
1260
1353
  export {
1261
1354
  Policies as Policies,
1262
- type Policy as Policy,
1263
1355
  type SuiTransactionCommandOperator as SuiTransactionCommandOperator,
1264
1356
  type SuiTransferObjectsCommandField as SuiTransferObjectsCommandField,
1265
1357
  type TronTransactionCondition as TronTransactionCondition,
1266
1358
  type SuiTransactionCommandCondition as SuiTransactionCommandCondition,
1267
1359
  type SuiTransferObjectsCommandCondition as SuiTransferObjectsCommandCondition,
1360
+ type Policy as Policy,
1268
1361
  type PolicyCreateRuleResponse as PolicyCreateRuleResponse,
1269
1362
  type PolicyDeleteResponse as PolicyDeleteResponse,
1270
1363
  type PolicyDeleteRuleResponse as PolicyDeleteRuleResponse,
@@ -1283,13 +1376,52 @@ export declare namespace PrivyAPI {
1283
1376
 
1284
1377
  export {
1285
1378
  KeyQuorums as KeyQuorums,
1379
+ type KeyQuorumCreateParams as KeyQuorumCreateParams,
1286
1380
  type KeyQuorum as KeyQuorum,
1287
1381
  type KeyQuorumDeleteResponse as KeyQuorumDeleteResponse,
1288
- type KeyQuorumCreateParams as KeyQuorumCreateParams,
1289
1382
  type KeyQuorumDeleteParams as KeyQuorumDeleteParams,
1290
1383
  type KeyQuorumUpdateParams as KeyQuorumUpdateParams,
1291
1384
  };
1292
1385
 
1386
+ export {
1387
+ Intents as Intents,
1388
+ type IntentType as IntentType,
1389
+ type IntentStatus as IntentStatus,
1390
+ type RuleIntentRequestDetails as RuleIntentRequestDetails,
1391
+ type IntentAuthorizationKeyQuorumMember as IntentAuthorizationKeyQuorumMember,
1392
+ type IntentAuthorizationMember as IntentAuthorizationMember,
1393
+ type IntentAuthorization as IntentAuthorization,
1394
+ type BaseActionResult as BaseActionResult,
1395
+ type RpcIntentResponse as RpcIntentResponse,
1396
+ type WalletIntentResponse as WalletIntentResponse,
1397
+ type PolicyIntentResponse as PolicyIntentResponse,
1398
+ type KeyQuorumIntentResponse as KeyQuorumIntentResponse,
1399
+ type RuleIntentResponse as RuleIntentResponse,
1400
+ type IntentResponse as IntentResponse,
1401
+ type IntentResponsesCursor as IntentResponsesCursor,
1402
+ type IntentListParams as IntentListParams,
1403
+ type IntentCreatePolicyRuleParams as IntentCreatePolicyRuleParams,
1404
+ type IntentDeletePolicyRuleParams as IntentDeletePolicyRuleParams,
1405
+ type IntentRpcParams as IntentRpcParams,
1406
+ type IntentUpdateKeyQuorumParams as IntentUpdateKeyQuorumParams,
1407
+ type IntentUpdatePolicyParams as IntentUpdatePolicyParams,
1408
+ type IntentUpdatePolicyRuleParams as IntentUpdatePolicyRuleParams,
1409
+ type IntentUpdateWalletParams as IntentUpdateWalletParams,
1410
+ };
1411
+
1412
+ export {
1413
+ Apps as Apps,
1414
+ type AppResponse as AppResponse,
1415
+ type EmailInviteInput as EmailInviteInput,
1416
+ type WalletInviteInput as WalletInviteInput,
1417
+ type PhoneInviteInput as PhoneInviteInput,
1418
+ type UserInviteInput as UserInviteInput,
1419
+ type AllowlistEntry as AllowlistEntry,
1420
+ type AllowlistDeletionResponse as AllowlistDeletionResponse,
1421
+ type TestAccount as TestAccount,
1422
+ type TestAccountsResponse as TestAccountsResponse,
1423
+ };
1424
+
1293
1425
  export {
1294
1426
  ClientAuth as ClientAuth,
1295
1427
  type ExternalOAuthProviderID as ExternalOAuthProviderID,
@@ -1304,6 +1436,22 @@ export declare namespace PrivyAPI {
1304
1436
  type BridgeFiatCustomerResponse as BridgeFiatCustomerResponse,
1305
1437
  type BridgeSandboxFiatCustomerResponse as BridgeSandboxFiatCustomerResponse,
1306
1438
  type FiatCustomerResponse as FiatCustomerResponse,
1439
+ type FiatCurrencyCode as FiatCurrencyCode,
1440
+ type CryptoCurrencyCode as CryptoCurrencyCode,
1441
+ type Caip2ChainID as Caip2ChainID,
1442
+ type FiatAmount as FiatAmount,
1443
+ type FiatOnrampSource as FiatOnrampSource,
1444
+ type FiatOnrampDestination as FiatOnrampDestination,
1445
+ type FiatOnrampEnvironment as FiatOnrampEnvironment,
1446
+ type FiatOnrampProvider as FiatOnrampProvider,
1447
+ type GetFiatOnrampQuotesInput as GetFiatOnrampQuotesInput,
1448
+ type FiatOnrampQuote as FiatOnrampQuote,
1449
+ type GetFiatOnrampQuotesResponse as GetFiatOnrampQuotesResponse,
1450
+ type GetFiatOnrampURLInput as GetFiatOnrampURLInput,
1451
+ type GetFiatOnrampURLResponse as GetFiatOnrampURLResponse,
1452
+ type FiatOnrampTransactionStatus as FiatOnrampTransactionStatus,
1453
+ type GetFiatOnrampTransactionStatusInput as GetFiatOnrampTransactionStatusInput,
1454
+ type GetFiatOnrampTransactionStatusResponse as GetFiatOnrampTransactionStatusResponse,
1307
1455
  type BridgeDestinationAsset as BridgeDestinationAsset,
1308
1456
  type BridgeSourceAsset as BridgeSourceAsset,
1309
1457
  type BridgeFiatVirtualAccountSource as BridgeFiatVirtualAccountSource,
@@ -1324,8 +1472,6 @@ export declare namespace PrivyAPI {
1324
1472
 
1325
1473
  export { Analytics as Analytics, type AnalyticsEventInput as AnalyticsEventInput };
1326
1474
 
1327
- export { Apps as Apps, type AppResponse as AppResponse };
1328
-
1329
1475
  export {
1330
1476
  Aggregations as Aggregations,
1331
1477
  type AggregationMethod as AggregationMethod,
@@ -1338,13 +1484,12 @@ export declare namespace PrivyAPI {
1338
1484
 
1339
1485
  export {
1340
1486
  Webhooks as Webhooks,
1341
- type UserCreatedWebhookPayload as UserCreatedWebhookPayload,
1342
- type UserAuthenticatedWebhookPayload as UserAuthenticatedWebhookPayload,
1343
- type UserLinkedAccountWebhookPayload as UserLinkedAccountWebhookPayload,
1344
- type UserUnlinkedAccountWebhookPayload as UserUnlinkedAccountWebhookPayload,
1345
- type UserUpdatedAccountWebhookPayload as UserUpdatedAccountWebhookPayload,
1346
- type UserTransferredAccountWebhookPayload as UserTransferredAccountWebhookPayload,
1347
- type UserWalletCreatedWebhookPayload as UserWalletCreatedWebhookPayload,
1487
+ type IntentCreatedWebhookPayload as IntentCreatedWebhookPayload,
1488
+ type IntentAuthorizedWebhookPayload as IntentAuthorizedWebhookPayload,
1489
+ type IntentExecutedWebhookPayload as IntentExecutedWebhookPayload,
1490
+ type IntentFailedWebhookPayload as IntentFailedWebhookPayload,
1491
+ type MfaEnabledWebhookPayload as MfaEnabledWebhookPayload,
1492
+ type MfaDisabledWebhookPayload as MfaDisabledWebhookPayload,
1348
1493
  type TransactionBroadcastedWebhookPayload as TransactionBroadcastedWebhookPayload,
1349
1494
  type TransactionConfirmedWebhookPayload as TransactionConfirmedWebhookPayload,
1350
1495
  type TransactionExecutionRevertedWebhookPayload as TransactionExecutionRevertedWebhookPayload,
@@ -1352,23 +1497,29 @@ export declare namespace PrivyAPI {
1352
1497
  type TransactionFailedWebhookPayload as TransactionFailedWebhookPayload,
1353
1498
  type TransactionReplacedWebhookPayload as TransactionReplacedWebhookPayload,
1354
1499
  type TransactionProviderErrorWebhookPayload as TransactionProviderErrorWebhookPayload,
1500
+ type UserOperationCompletedWebhookPayload as UserOperationCompletedWebhookPayload,
1501
+ type UserCreatedWebhookPayload as UserCreatedWebhookPayload,
1502
+ type UserAuthenticatedWebhookPayload as UserAuthenticatedWebhookPayload,
1503
+ type UserLinkedAccountWebhookPayload as UserLinkedAccountWebhookPayload,
1504
+ type UserUnlinkedAccountWebhookPayload as UserUnlinkedAccountWebhookPayload,
1505
+ type UserUpdatedAccountWebhookPayload as UserUpdatedAccountWebhookPayload,
1506
+ type UserTransferredAccountWebhookPayload as UserTransferredAccountWebhookPayload,
1507
+ type UserWalletCreatedWebhookPayload as UserWalletCreatedWebhookPayload,
1355
1508
  type FundsDepositedWebhookPayload as FundsDepositedWebhookPayload,
1356
1509
  type FundsWithdrawnWebhookPayload as FundsWithdrawnWebhookPayload,
1357
1510
  type PrivateKeyExportWebhookPayload as PrivateKeyExportWebhookPayload,
1358
1511
  type WalletRecoverySetupWebhookPayload as WalletRecoverySetupWebhookPayload,
1359
1512
  type WalletRecoveredWebhookPayload as WalletRecoveredWebhookPayload,
1360
- type MfaEnabledWebhookPayload as MfaEnabledWebhookPayload,
1361
- type MfaDisabledWebhookPayload as MfaDisabledWebhookPayload,
1362
- type KrakenEmbedVerificationCompletedWebhookPayload as KrakenEmbedVerificationCompletedWebhookPayload,
1363
- type KrakenEmbedVerificationFailedWebhookPayload as KrakenEmbedVerificationFailedWebhookPayload,
1513
+ type YieldDepositConfirmedWebhookPayload as YieldDepositConfirmedWebhookPayload,
1514
+ type YieldWithdrawConfirmedWebhookPayload as YieldWithdrawConfirmedWebhookPayload,
1515
+ type YieldClaimConfirmedWebhookPayload as YieldClaimConfirmedWebhookPayload,
1516
+ type WebhookPayload as WebhookPayload,
1364
1517
  type KrakenEmbedQuoteExecutedWebhookPayload as KrakenEmbedQuoteExecutedWebhookPayload,
1365
1518
  type KrakenEmbedQuoteExecutionFailedWebhookPayload as KrakenEmbedQuoteExecutionFailedWebhookPayload,
1366
1519
  type KrakenEmbedQuoteCancelledWebhookPayload as KrakenEmbedQuoteCancelledWebhookPayload,
1367
1520
  type KrakenEmbedUserVerifiedWebhookPayload as KrakenEmbedUserVerifiedWebhookPayload,
1368
1521
  type KrakenEmbedUserDisabledWebhookPayload as KrakenEmbedUserDisabledWebhookPayload,
1369
1522
  type KrakenEmbedUserClosedWebhookPayload as KrakenEmbedUserClosedWebhookPayload,
1370
- type YieldDepositConfirmedWebhookPayload as YieldDepositConfirmedWebhookPayload,
1371
- type YieldWithdrawConfirmedWebhookPayload as YieldWithdrawConfirmedWebhookPayload,
1372
1523
  };
1373
1524
 
1374
1525
  export {
@@ -1376,7 +1527,15 @@ export declare namespace PrivyAPI {
1376
1527
  type AccountWallet as AccountWallet,
1377
1528
  type AccountResponse as AccountResponse,
1378
1529
  type AccountWalletConfigurationItem as AccountWalletConfigurationItem,
1530
+ type AccountDisplayName as AccountDisplayName,
1531
+ type AccountWalletsConfiguration as AccountWalletsConfiguration,
1379
1532
  type CreateAccountInput as CreateAccountInput,
1533
+ type UpdateAccountInput as UpdateAccountInput,
1534
+ type AccountsListResponse as AccountsListResponse,
1535
+ type AssetAccountWithBalance as AssetAccountWithBalance,
1536
+ type AccountsDashboardListResponse as AccountsDashboardListResponse,
1537
+ type AccountBalanceResponse as AccountBalanceResponse,
1538
+ type AccountBalanceParams as AccountBalanceParams,
1380
1539
  };
1381
1540
 
1382
1541
  export {
@@ -1398,11 +1557,13 @@ export declare namespace PrivyAPI {
1398
1557
  type EthereumYieldClaimInput as EthereumYieldClaimInput,
1399
1558
  type EthereumYieldClaimReward as EthereumYieldClaimReward,
1400
1559
  type EthereumYieldClaimResponse as EthereumYieldClaimResponse,
1560
+ type EthereumYieldClaimIDInput as EthereumYieldClaimIDInput,
1401
1561
  };
1402
1562
 
1403
1563
  export {
1404
- Intents as Intents,
1405
- type IntentAuthorizationKeyQuorumMember as IntentAuthorizationKeyQuorumMember,
1406
- type IntentAuthorizationMember as IntentAuthorizationMember,
1564
+ KrakenEmbed as KrakenEmbed,
1565
+ type KrakenEmbedGetPortfolioSummaryQueryParams as KrakenEmbedGetPortfolioSummaryQueryParams,
1566
+ type KrakenEmbedCurrentDayPnl as KrakenEmbedCurrentDayPnl,
1567
+ type KrakenEmbedGetPortfolioSummaryResponse as KrakenEmbedGetPortfolioSummaryResponse,
1407
1568
  };
1408
1569
  }
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export { type PrivyPoliciesService } from './public-api/services/policies';
6
6
  export { type PrivyTransactionsService } from './public-api/services/transactions';
7
7
  export { type PrivyKeyQuorumsService } from './public-api/services/key-quorums';
8
8
  export { type PrivyUsersService } from './public-api/services/users';
9
+ export { type PrivyAppsService } from './public-api/services/apps';
9
10
  export { type PrivyUtils } from './public-api/services/utils';
10
11
  export {
11
12
  InvalidAuthTokenError,
@@ -20,6 +21,15 @@ export {
20
21
  } from './lib/auth';
21
22
 
22
23
  export { type User, type LinkedAccountEmbeddedWallet, type LinkedAccount } from './resources/users';
24
+ export {
25
+ type AppResponse,
26
+ type AllowlistEntry,
27
+ type AllowlistDeletionResponse,
28
+ type UserInviteInput,
29
+ type EmailInviteInput,
30
+ type WalletInviteInput,
31
+ type PhoneInviteInput,
32
+ } from './resources/apps/apps';
23
33
  export { type Wallet } from './resources/wallets';
24
34
  export { type Policy } from './resources/policies';
25
35
  export { type KeyQuorum } from './resources/key-quorums';
@@ -0,0 +1,7 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as qs from '../qs/stringify';
4
+
5
+ export function stringifyQuery(query: object | Record<string, unknown>) {
6
+ return qs.stringify(query, { arrayFormat: 'comma' });
7
+ }
@@ -6,3 +6,4 @@ export * from './utils/env';
6
6
  export * from './utils/log';
7
7
  export * from './utils/uuid';
8
8
  export * from './utils/sleep';
9
+ export * from './utils/query';
@@ -5,6 +5,7 @@ import { PrivyPoliciesService } from './services/policies';
5
5
  import { PrivyTransactionsService } from './services/transactions';
6
6
  import { PrivyKeyQuorumsService } from './services/key-quorums';
7
7
  import { PrivyUsersService } from './services/users';
8
+ import { PrivyAppsService } from './services/apps';
8
9
  import { PrivyUtils } from './services/utils';
9
10
  import { JwtExchangeService } from '../lib/jwt-exchange';
10
11
  import { VERSION } from '../version';
@@ -31,6 +32,7 @@ export class PrivyClient {
31
32
  private transactionsService: PrivyTransactionsService;
32
33
  private keyQuorumsService: PrivyKeyQuorumsService;
33
34
  private usersService: PrivyUsersService;
35
+ private appsService: PrivyAppsService;
34
36
  private utilsService: PrivyUtils;
35
37
  private jwtExchangeService: JwtExchangeService;
36
38
 
@@ -76,6 +78,7 @@ export class PrivyClient {
76
78
  this.transactionsService = new PrivyTransactionsService(this.privyApiClient);
77
79
  this.keyQuorumsService = new PrivyKeyQuorumsService(this.privyApiClient, this);
78
80
  this.usersService = new PrivyUsersService(this.privyApiClient, appJwks);
81
+ this.appsService = new PrivyAppsService(this.privyApiClient);
79
82
  this.utilsService = new PrivyUtils(this.privyApiClient, this, appJwks);
80
83
  this.webhooksService = new PrivyWebhooksService(webhookSigningSecret);
81
84
  }
@@ -104,6 +107,10 @@ export class PrivyClient {
104
107
  return this.usersService;
105
108
  }
106
109
 
110
+ public apps(): PrivyAppsService {
111
+ return this.appsService;
112
+ }
113
+
107
114
  public utils(): PrivyUtils {
108
115
  return this.utilsService;
109
116
  }
@@ -0,0 +1,85 @@
1
+ import { PrivyAPI } from '../../client';
2
+ import type {
3
+ AllowlistEntry,
4
+ AllowlistDeletionResponse,
5
+ AppResponse,
6
+ UserInviteInput,
7
+ } from '../../resources/apps/apps';
8
+ import type { AllowlistListResponse } from '../../resources/apps/allowlist';
9
+ import { Apps } from '../../resources/apps/apps';
10
+ import { AuthenticatedUser } from '../../resources';
11
+
12
+ export class PrivyAppsService extends Apps {
13
+ constructor(privyApiClient: PrivyAPI) {
14
+ super(privyApiClient);
15
+ }
16
+
17
+ async getAllowlist(): Promise<AllowlistListResponse> {
18
+ return this.allowlist.list(this._client.appID);
19
+ }
20
+
21
+ async inviteToAllowlist(entry: UserInviteInput): Promise<AllowlistEntry> {
22
+ return this.allowlist.create(this._client.appID, entry);
23
+ }
24
+
25
+ async removeFromAllowlist(entry: UserInviteInput): Promise<AllowlistDeletionResponse> {
26
+ return this.allowlist.delete(this._client.appID, entry);
27
+ }
28
+
29
+ async getSettings(): Promise<AppResponse> {
30
+ return this.get(this._client.appID);
31
+ }
32
+
33
+ async getTestAccessToken(
34
+ params?: PrivyAppsService.GetTestAccessTokenParams,
35
+ ): Promise<PrivyAppsService.TestAccessTokenResponse> {
36
+ const { data: testAccounts } = await this.getTestCredentials(this._client.appID);
37
+
38
+ if (!testAccounts || testAccounts.length === 0) {
39
+ throw new Error('No test accounts found for this app. Create test accounts in the Privy dashboard.');
40
+ }
41
+
42
+ let account;
43
+ if (params && 'email' in params) {
44
+ account = testAccounts.find((a) => a.email === params.email);
45
+ if (!account) {
46
+ throw new Error(
47
+ `No test account found with email "${params.email}". Available: ${testAccounts
48
+ .map((a) => a.email)
49
+ .join(', ')}`,
50
+ );
51
+ }
52
+ } else if (params && 'phone_number' in params) {
53
+ account = testAccounts.find((a) => a.phone_number === params.phone_number);
54
+ if (!account) {
55
+ throw new Error(
56
+ `No test account found with phone number "${params.phone_number}". Available: ${testAccounts
57
+ .map((a) => a.phone_number)
58
+ .join(', ')}`,
59
+ );
60
+ }
61
+ } else {
62
+ account = testAccounts[0]!;
63
+ }
64
+
65
+ const authResponse = await this._client.post<AuthenticatedUser>('/v1/passwordless/authenticate', {
66
+ body: { email: account.email, code: account.otp_code },
67
+ });
68
+
69
+ if (!authResponse.token) {
70
+ throw new Error('Unable to authenticate with the test account.');
71
+ }
72
+
73
+ return { access_token: authResponse.token };
74
+ }
75
+ }
76
+
77
+ export namespace PrivyAppsService {
78
+ export type GetTestAccessTokenParams =
79
+ | { email: string; phone_number?: never }
80
+ | { phone_number: string; email?: never };
81
+
82
+ export interface TestAccessTokenResponse {
83
+ access_token: string;
84
+ }
85
+ }