@privy-io/node 0.8.0 → 0.10.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 (158) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/client.d.mts +23 -10
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +23 -10
  5. package/client.d.ts.map +1 -1
  6. package/client.js +30 -3
  7. package/client.js.map +1 -1
  8. package/client.mjs +30 -3
  9. package/client.mjs.map +1 -1
  10. package/index.d.mts +1 -1
  11. package/index.d.mts.map +1 -1
  12. package/index.d.ts +1 -1
  13. package/index.d.ts.map +1 -1
  14. package/internal/parse.d.mts.map +1 -1
  15. package/internal/parse.d.ts.map +1 -1
  16. package/internal/parse.js +5 -0
  17. package/internal/parse.js.map +1 -1
  18. package/internal/parse.mjs +5 -0
  19. package/internal/parse.mjs.map +1 -1
  20. package/package.json +21 -1
  21. package/public-api/services/ethereum.d.mts +4 -1
  22. package/public-api/services/ethereum.d.mts.map +1 -1
  23. package/public-api/services/ethereum.d.ts +4 -1
  24. package/public-api/services/ethereum.d.ts.map +1 -1
  25. package/public-api/services/ethereum.js +8 -0
  26. package/public-api/services/ethereum.js.map +1 -1
  27. package/public-api/services/ethereum.mjs +8 -0
  28. package/public-api/services/ethereum.mjs.map +1 -1
  29. package/public-api/services/webhooks.d.mts +3 -1
  30. package/public-api/services/webhooks.d.mts.map +1 -1
  31. package/public-api/services/webhooks.d.ts +3 -1
  32. package/public-api/services/webhooks.d.ts.map +1 -1
  33. package/public-api/services/webhooks.js +1 -0
  34. package/public-api/services/webhooks.js.map +1 -1
  35. package/public-api/services/webhooks.mjs +1 -0
  36. package/public-api/services/webhooks.mjs.map +1 -1
  37. package/resources/accounts.d.mts +72 -0
  38. package/resources/accounts.d.mts.map +1 -0
  39. package/resources/accounts.d.ts +72 -0
  40. package/resources/accounts.d.ts.map +1 -0
  41. package/resources/accounts.js +9 -0
  42. package/resources/accounts.js.map +1 -0
  43. package/resources/accounts.mjs +5 -0
  44. package/resources/accounts.mjs.map +1 -0
  45. package/resources/aggregations.d.mts +213 -2
  46. package/resources/aggregations.d.mts.map +1 -1
  47. package/resources/aggregations.d.ts +213 -2
  48. package/resources/aggregations.d.ts.map +1 -1
  49. package/resources/client-auth.d.mts +182 -2
  50. package/resources/client-auth.d.mts.map +1 -1
  51. package/resources/client-auth.d.ts +182 -2
  52. package/resources/client-auth.d.ts.map +1 -1
  53. package/resources/index.d.mts +8 -4
  54. package/resources/index.d.mts.map +1 -1
  55. package/resources/index.d.ts +8 -4
  56. package/resources/index.d.ts.map +1 -1
  57. package/resources/index.js +9 -1
  58. package/resources/index.js.map +1 -1
  59. package/resources/index.mjs +4 -0
  60. package/resources/index.mjs.map +1 -1
  61. package/resources/intents.d.mts +104 -0
  62. package/resources/intents.d.mts.map +1 -0
  63. package/resources/intents.d.ts +104 -0
  64. package/resources/intents.d.ts.map +1 -0
  65. package/resources/intents.js +9 -0
  66. package/resources/intents.js.map +1 -0
  67. package/resources/intents.mjs +5 -0
  68. package/resources/intents.mjs.map +1 -0
  69. package/resources/key-quorums.d.mts +14 -0
  70. package/resources/key-quorums.d.mts.map +1 -1
  71. package/resources/key-quorums.d.ts +14 -0
  72. package/resources/key-quorums.d.ts.map +1 -1
  73. package/resources/policies.d.mts +10 -12
  74. package/resources/policies.d.mts.map +1 -1
  75. package/resources/policies.d.ts +10 -12
  76. package/resources/policies.d.ts.map +1 -1
  77. package/resources/users.d.mts +16 -6
  78. package/resources/users.d.mts.map +1 -1
  79. package/resources/users.d.ts +16 -6
  80. package/resources/users.d.ts.map +1 -1
  81. package/resources/wallets/balance.d.mts +10 -5
  82. package/resources/wallets/balance.d.mts.map +1 -1
  83. package/resources/wallets/balance.d.ts +10 -5
  84. package/resources/wallets/balance.d.ts.map +1 -1
  85. package/resources/wallets/balance.js +1 -2
  86. package/resources/wallets/balance.js.map +1 -1
  87. package/resources/wallets/balance.mjs +1 -2
  88. package/resources/wallets/balance.mjs.map +1 -1
  89. package/resources/wallets/index.d.mts +1 -1
  90. package/resources/wallets/index.d.mts.map +1 -1
  91. package/resources/wallets/index.d.ts +1 -1
  92. package/resources/wallets/index.d.ts.map +1 -1
  93. package/resources/wallets/index.js.map +1 -1
  94. package/resources/wallets/index.mjs.map +1 -1
  95. package/resources/wallets/transactions.d.mts +2 -2
  96. package/resources/wallets/transactions.d.mts.map +1 -1
  97. package/resources/wallets/transactions.d.ts +2 -2
  98. package/resources/wallets/transactions.d.ts.map +1 -1
  99. package/resources/wallets/wallets.d.mts +141 -14
  100. package/resources/wallets/wallets.d.mts.map +1 -1
  101. package/resources/wallets/wallets.d.ts +141 -14
  102. package/resources/wallets/wallets.d.ts.map +1 -1
  103. package/resources/wallets/wallets.js.map +1 -1
  104. package/resources/wallets/wallets.mjs.map +1 -1
  105. package/resources/webhooks.d.mts +977 -0
  106. package/resources/webhooks.d.mts.map +1 -0
  107. package/resources/webhooks.d.ts +977 -0
  108. package/resources/webhooks.d.ts.map +1 -0
  109. package/resources/webhooks.js +9 -0
  110. package/resources/webhooks.js.map +1 -0
  111. package/resources/webhooks.mjs +5 -0
  112. package/resources/webhooks.mjs.map +1 -0
  113. package/resources/yield.d.mts +311 -0
  114. package/resources/yield.d.mts.map +1 -0
  115. package/resources/yield.d.ts +311 -0
  116. package/resources/yield.d.ts.map +1 -0
  117. package/resources/yield.js +9 -0
  118. package/resources/yield.js.map +1 -0
  119. package/resources/yield.mjs +5 -0
  120. package/resources/yield.mjs.map +1 -0
  121. package/src/client.ts +229 -9
  122. package/src/index.ts +1 -1
  123. package/src/internal/parse.ts +6 -0
  124. package/src/public-api/services/ethereum.ts +16 -0
  125. package/src/public-api/services/webhooks.ts +49 -2
  126. package/src/resources/accounts.ts +90 -0
  127. package/src/resources/aggregations.ts +361 -5
  128. package/src/resources/client-auth.ts +310 -1
  129. package/src/resources/index.ts +95 -3
  130. package/src/resources/intents.ts +138 -0
  131. package/src/resources/key-quorums.ts +17 -0
  132. package/src/resources/policies.ts +10 -12
  133. package/src/resources/users.ts +52 -35
  134. package/src/resources/wallets/balance.ts +15 -5
  135. package/src/resources/wallets/index.ts +6 -2
  136. package/src/resources/wallets/transactions.ts +2 -2
  137. package/src/resources/wallets/wallets.ts +185 -31
  138. package/src/resources/webhooks.ts +1347 -0
  139. package/src/resources/yield.ts +389 -0
  140. package/src/types/x402.d.ts +18 -0
  141. package/src/version.ts +1 -1
  142. package/src/x402.ts +87 -0
  143. package/version.d.mts +1 -1
  144. package/version.d.mts.map +1 -1
  145. package/version.d.ts +1 -1
  146. package/version.d.ts.map +1 -1
  147. package/version.js +1 -1
  148. package/version.js.map +1 -1
  149. package/version.mjs +1 -1
  150. package/version.mjs.map +1 -1
  151. package/x402.d.mts +54 -0
  152. package/x402.d.mts.map +1 -0
  153. package/x402.d.ts +54 -0
  154. package/x402.d.ts.map +1 -0
  155. package/x402.js +75 -0
  156. package/x402.js.map +1 -0
  157. package/x402.mjs +72 -0
  158. package/x402.mjs.map +1 -0
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.Yield = void 0;
5
+ const resource_1 = require("../core/resource.js");
6
+ class Yield extends resource_1.APIResource {
7
+ }
8
+ exports.Yield = Yield;
9
+ //# sourceMappingURL=yield.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yield.js","sourceRoot":"","sources":["../src/resources/yield.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAE/C,MAAa,KAAM,SAAQ,sBAAW;CAAG;AAAzC,sBAAyC"}
@@ -0,0 +1,5 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+ import { APIResource } from "../core/resource.mjs";
3
+ export class Yield extends APIResource {
4
+ }
5
+ //# sourceMappingURL=yield.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yield.mjs","sourceRoot":"","sources":["../src/resources/yield.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAEtB,MAAM,OAAO,KAAM,SAAQ,WAAW;CAAG"}
package/src/client.ts CHANGED
@@ -19,9 +19,17 @@ import { AbstractPage, type CursorParams, CursorResponse } from './core/paginati
19
19
  import * as Uploads from './core/uploads';
20
20
  import * as API from './resources/index';
21
21
  import { APIPromise } from './core/api-promise';
22
+ import {
23
+ AccountResponse,
24
+ AccountWallet,
25
+ AccountWalletConfigurationItem,
26
+ Accounts,
27
+ CreateAccountInput,
28
+ } from './resources/accounts';
22
29
  import {
23
30
  Aggregation,
24
31
  AggregationGroupBy,
32
+ AggregationInput,
25
33
  AggregationMethod,
26
34
  AggregationMetric,
27
35
  AggregationWindow,
@@ -30,12 +38,37 @@ import {
30
38
  import { Analytics, AnalyticsEventInput } from './resources/analytics';
31
39
  import { AppResponse, Apps } from './resources/apps';
32
40
  import {
41
+ BridgeBrlFiatVirtualAccountDepositInstructions,
42
+ BridgeDestinationAsset,
43
+ BridgeEurFiatVirtualAccountDepositInstructions,
44
+ BridgeFiatCustomerResponse,
45
+ BridgeFiatRejectionReason,
46
+ BridgeFiatVirtualAccountDepositInstructions,
47
+ BridgeFiatVirtualAccountDestination,
48
+ BridgeFiatVirtualAccountRequest,
49
+ BridgeFiatVirtualAccountResponse,
50
+ BridgeFiatVirtualAccountSource,
51
+ BridgeGbpFiatVirtualAccountDepositInstructions,
52
+ BridgeMxnFiatVirtualAccountDepositInstructions,
53
+ BridgeOnrampProvider,
54
+ BridgeSandboxFiatCustomerResponse,
55
+ BridgeSandboxFiatVirtualAccountRequest,
56
+ BridgeSandboxFiatVirtualAccountResponse,
57
+ BridgeSourceAsset,
58
+ BridgeUsdFiatVirtualAccountDepositInstructions,
33
59
  ClientAuth,
60
+ CreateOrUpdateFiatCustomerRequestInput,
34
61
  CustomOAuthProviderID,
35
62
  ExternalOAuthProviderID,
63
+ FiatCustomerResponse,
64
+ FiatVirtualAccountRequest,
65
+ FiatVirtualAccountResponse,
66
+ GetFiatCustomerRequestInput,
36
67
  OAuthProviderID,
68
+ OnrampProvider,
37
69
  PrivyOAuthProviderID,
38
70
  } from './resources/client-auth';
71
+ import { IntentAuthorizationKeyQuorumMember, IntentAuthorizationMember, Intents } from './resources/intents';
39
72
  import {
40
73
  KeyQuorum,
41
74
  KeyQuorumCreateParams,
@@ -106,6 +139,7 @@ import {
106
139
  LinkedAccountLinkedInInput,
107
140
  LinkedAccountLinkedInOAuth,
108
141
  LinkedAccountPasskey,
142
+ LinkedAccountPasskeyInput,
109
143
  LinkedAccountPhone,
110
144
  LinkedAccountPhoneInput,
111
145
  LinkedAccountSmartWallet,
@@ -153,6 +187,60 @@ import {
153
187
  Users,
154
188
  UsersCursor,
155
189
  } from './resources/users';
190
+ import {
191
+ FundsDepositedWebhookPayload,
192
+ FundsWithdrawnWebhookPayload,
193
+ KrakenEmbedQuoteCancelledWebhookPayload,
194
+ KrakenEmbedQuoteExecutedWebhookPayload,
195
+ KrakenEmbedQuoteExecutionFailedWebhookPayload,
196
+ KrakenEmbedUserClosedWebhookPayload,
197
+ KrakenEmbedUserDisabledWebhookPayload,
198
+ KrakenEmbedUserVerifiedWebhookPayload,
199
+ KrakenEmbedVerificationCompletedWebhookPayload,
200
+ KrakenEmbedVerificationFailedWebhookPayload,
201
+ MfaDisabledWebhookPayload,
202
+ MfaEnabledWebhookPayload,
203
+ PrivateKeyExportWebhookPayload,
204
+ TransactionBroadcastedWebhookPayload,
205
+ TransactionConfirmedWebhookPayload,
206
+ TransactionExecutionRevertedWebhookPayload,
207
+ TransactionFailedWebhookPayload,
208
+ TransactionProviderErrorWebhookPayload,
209
+ TransactionReplacedWebhookPayload,
210
+ TransactionStillPendingWebhookPayload,
211
+ UserAuthenticatedWebhookPayload,
212
+ UserCreatedWebhookPayload,
213
+ UserLinkedAccountWebhookPayload,
214
+ UserTransferredAccountWebhookPayload,
215
+ UserUnlinkedAccountWebhookPayload,
216
+ UserUpdatedAccountWebhookPayload,
217
+ UserWalletCreatedWebhookPayload,
218
+ WalletRecoveredWebhookPayload,
219
+ WalletRecoverySetupWebhookPayload,
220
+ Webhooks,
221
+ YieldDepositConfirmedWebhookPayload,
222
+ YieldWithdrawConfirmedWebhookPayload,
223
+ } from './resources/webhooks';
224
+ import {
225
+ EthereumVaultDetailsInput,
226
+ EthereumVaultDetailsResponse,
227
+ EthereumVaultPosition,
228
+ EthereumVaultResponse,
229
+ EthereumYieldClaimInput,
230
+ EthereumYieldClaimResponse,
231
+ EthereumYieldClaimReward,
232
+ EthereumYieldDepositInput,
233
+ EthereumYieldPositionResponse,
234
+ EthereumYieldPositionsInput,
235
+ EthereumYieldProvider,
236
+ EthereumYieldSweepIDInput,
237
+ EthereumYieldSweepResponse,
238
+ EthereumYieldSweepStatus,
239
+ EthereumYieldSweepType,
240
+ EthereumYieldWithdrawInput,
241
+ EvmCaip2ChainID,
242
+ Yield,
243
+ } from './resources/yield';
156
244
  import {
157
245
  CurveSigningChainType,
158
246
  CustodialWallet,
@@ -186,6 +274,10 @@ import {
186
274
  Wallet,
187
275
  WalletAuthenticateWithJwtParams,
188
276
  WalletAuthenticateWithJwtResponse,
277
+ WalletBatchCreateInput,
278
+ WalletBatchCreateResponse,
279
+ WalletBatchCreateResult,
280
+ WalletBatchItemInput,
189
281
  WalletChainType,
190
282
  WalletCreateParams,
191
283
  WalletCreateWalletsWithRecoveryParams,
@@ -678,7 +770,7 @@ export class PrivyAPI {
678
770
  loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
679
771
 
680
772
  const errText = await response.text().catch((err: any) => castToError(err).message);
681
- const errJSON = safeJSON(errText);
773
+ const errJSON = safeJSON(errText) as any;
682
774
  const errMessage = errJSON ? undefined : errText;
683
775
 
684
776
  loggerFor(this).debug(
@@ -715,9 +807,14 @@ export class PrivyAPI {
715
807
  getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
716
808
  path: string,
717
809
  Page: new (...args: any[]) => PageClass,
718
- opts?: RequestOptions,
810
+ opts?: PromiseOrValue<RequestOptions>,
719
811
  ): Pagination.PagePromise<PageClass, Item> {
720
- return this.requestAPIList(Page, { method: 'get', path, ...opts });
812
+ return this.requestAPIList(
813
+ Page,
814
+ opts && 'then' in opts ?
815
+ opts.then((opts) => ({ method: 'get', path, ...opts }))
816
+ : { method: 'get', path, ...opts },
817
+ );
721
818
  }
722
819
 
723
820
  requestAPIList<
@@ -725,7 +822,7 @@ export class PrivyAPI {
725
822
  PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
726
823
  >(
727
824
  Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
728
- options: FinalRequestOptions,
825
+ options: PromiseOrValue<FinalRequestOptions>,
729
826
  ): Pagination.PagePromise<PageClass, Item> {
730
827
  const request = this.makeRequest(options, null, undefined);
731
828
  return new Pagination.PagePromise<PageClass, Item>(this as any as PrivyAPI, request, Page);
@@ -738,9 +835,10 @@ export class PrivyAPI {
738
835
  controller: AbortController,
739
836
  ): Promise<Response> {
740
837
  const { signal, method, ...options } = init || {};
741
- if (signal) signal.addEventListener('abort', () => controller.abort());
838
+ const abort = this._makeAbort(controller);
839
+ if (signal) signal.addEventListener('abort', abort, { once: true });
742
840
 
743
- const timeout = setTimeout(() => controller.abort(), ms);
841
+ const timeout = setTimeout(abort, ms);
744
842
 
745
843
  const isReadableBody =
746
844
  ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
@@ -908,6 +1006,12 @@ export class PrivyAPI {
908
1006
  return headers.values;
909
1007
  }
910
1008
 
1009
+ private _makeAbort(controller: AbortController) {
1010
+ // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
1011
+ // would capture all request options, and cause a memory leak.
1012
+ return () => controller.abort();
1013
+ }
1014
+
911
1015
  private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
912
1016
  bodyHeaders: HeadersLike;
913
1017
  body: BodyInit | undefined;
@@ -940,6 +1044,14 @@ export class PrivyAPI {
940
1044
  (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
941
1045
  ) {
942
1046
  return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
1047
+ } else if (
1048
+ typeof body === 'object' &&
1049
+ headers.values.get('content-type') === 'application/x-www-form-urlencoded'
1050
+ ) {
1051
+ return {
1052
+ bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
1053
+ body: this.stringifyQuery(body as Record<string, unknown>),
1054
+ };
943
1055
  } else {
944
1056
  return this.#encoder({ body, headers });
945
1057
  }
@@ -973,6 +1085,10 @@ export class PrivyAPI {
973
1085
  analytics: API.Analytics = new API.Analytics(this);
974
1086
  apps: API.Apps = new API.Apps(this);
975
1087
  aggregations: API.Aggregations = new API.Aggregations(this);
1088
+ webhooks: API.Webhooks = new API.Webhooks(this);
1089
+ accounts: API.Accounts = new API.Accounts(this);
1090
+ yield: API.Yield = new API.Yield(this);
1091
+ intents: API.Intents = new API.Intents(this);
976
1092
  }
977
1093
 
978
1094
  PrivyAPI.Wallets = Wallets;
@@ -984,6 +1100,10 @@ PrivyAPI.ClientAuth = ClientAuth;
984
1100
  PrivyAPI.Analytics = Analytics;
985
1101
  PrivyAPI.Apps = Apps;
986
1102
  PrivyAPI.Aggregations = Aggregations;
1103
+ PrivyAPI.Webhooks = Webhooks;
1104
+ PrivyAPI.Accounts = Accounts;
1105
+ PrivyAPI.Yield = Yield;
1106
+ PrivyAPI.Intents = Intents;
987
1107
 
988
1108
  export declare namespace PrivyAPI {
989
1109
  export type RequestOptions = Opts.RequestOptions;
@@ -993,11 +1113,11 @@ export declare namespace PrivyAPI {
993
1113
 
994
1114
  export {
995
1115
  Wallets as Wallets,
1116
+ type Wallet as Wallet,
996
1117
  type CurveSigningChainType as CurveSigningChainType,
1118
+ type ExtendedChainType as ExtendedChainType,
997
1119
  type FirstClassChainType as FirstClassChainType,
998
- type Wallet as Wallet,
999
1120
  type WalletChainType as WalletChainType,
1000
- type ExtendedChainType as ExtendedChainType,
1001
1121
  type WalletCustodian as WalletCustodian,
1002
1122
  type CustodialWalletProvider as CustodialWalletProvider,
1003
1123
  type CustodialWalletChainType as CustodialWalletChainType,
@@ -1005,6 +1125,10 @@ export declare namespace PrivyAPI {
1005
1125
  type CustodialWallet as CustodialWallet,
1006
1126
  type HpkeImportConfig as HpkeImportConfig,
1007
1127
  type SuiCommandName as SuiCommandName,
1128
+ type WalletBatchItemInput as WalletBatchItemInput,
1129
+ type WalletBatchCreateInput as WalletBatchCreateInput,
1130
+ type WalletBatchCreateResult as WalletBatchCreateResult,
1131
+ type WalletBatchCreateResponse as WalletBatchCreateResponse,
1008
1132
  type EthereumPersonalSignRpcInput as EthereumPersonalSignRpcInput,
1009
1133
  type EthereumSignTransactionRpcInput as EthereumSignTransactionRpcInput,
1010
1134
  type EthereumSendTransactionRpcInput as EthereumSendTransactionRpcInput,
@@ -1047,7 +1171,6 @@ export declare namespace PrivyAPI {
1047
1171
  export {
1048
1172
  Users as Users,
1049
1173
  type AuthenticatedUser as AuthenticatedUser,
1050
- type LinkedAccount as LinkedAccount,
1051
1174
  type User as User,
1052
1175
  type LinkedAccountEmail as LinkedAccountEmail,
1053
1176
  type LinkedAccountPhone as LinkedAccountPhone,
@@ -1084,6 +1207,7 @@ export declare namespace PrivyAPI {
1084
1207
  type CrossAppSmartWallet as CrossAppSmartWallet,
1085
1208
  type LinkedAccountCrossApp as LinkedAccountCrossApp,
1086
1209
  type LinkedAccountAuthorizationKey as LinkedAccountAuthorizationKey,
1210
+ type LinkedAccount as LinkedAccount,
1087
1211
  type LinkedAccountType as LinkedAccountType,
1088
1212
  type CustomMetadata as CustomMetadata,
1089
1213
  type LinkedAccountWalletInput as LinkedAccountWalletInput,
@@ -1103,6 +1227,7 @@ export declare namespace PrivyAPI {
1103
1227
  type LinkedAccountFarcasterInput as LinkedAccountFarcasterInput,
1104
1228
  type LinkedAccountTelegramInput as LinkedAccountTelegramInput,
1105
1229
  type LinkedAccountCustomJwtInput as LinkedAccountCustomJwtInput,
1230
+ type LinkedAccountPasskeyInput as LinkedAccountPasskeyInput,
1106
1231
  type LinkedAccountInput as LinkedAccountInput,
1107
1232
  type UserBatchCreateInput as UserBatchCreateInput,
1108
1233
  type SMSMfaMethod as SMSMfaMethod,
@@ -1171,6 +1296,30 @@ export declare namespace PrivyAPI {
1171
1296
  type PrivyOAuthProviderID as PrivyOAuthProviderID,
1172
1297
  type CustomOAuthProviderID as CustomOAuthProviderID,
1173
1298
  type OAuthProviderID as OAuthProviderID,
1299
+ type BridgeOnrampProvider as BridgeOnrampProvider,
1300
+ type OnrampProvider as OnrampProvider,
1301
+ type GetFiatCustomerRequestInput as GetFiatCustomerRequestInput,
1302
+ type CreateOrUpdateFiatCustomerRequestInput as CreateOrUpdateFiatCustomerRequestInput,
1303
+ type BridgeFiatRejectionReason as BridgeFiatRejectionReason,
1304
+ type BridgeFiatCustomerResponse as BridgeFiatCustomerResponse,
1305
+ type BridgeSandboxFiatCustomerResponse as BridgeSandboxFiatCustomerResponse,
1306
+ type FiatCustomerResponse as FiatCustomerResponse,
1307
+ type BridgeDestinationAsset as BridgeDestinationAsset,
1308
+ type BridgeSourceAsset as BridgeSourceAsset,
1309
+ type BridgeFiatVirtualAccountSource as BridgeFiatVirtualAccountSource,
1310
+ type BridgeFiatVirtualAccountDestination as BridgeFiatVirtualAccountDestination,
1311
+ type BridgeFiatVirtualAccountRequest as BridgeFiatVirtualAccountRequest,
1312
+ type BridgeSandboxFiatVirtualAccountRequest as BridgeSandboxFiatVirtualAccountRequest,
1313
+ type FiatVirtualAccountRequest as FiatVirtualAccountRequest,
1314
+ type BridgeUsdFiatVirtualAccountDepositInstructions as BridgeUsdFiatVirtualAccountDepositInstructions,
1315
+ type BridgeEurFiatVirtualAccountDepositInstructions as BridgeEurFiatVirtualAccountDepositInstructions,
1316
+ type BridgeMxnFiatVirtualAccountDepositInstructions as BridgeMxnFiatVirtualAccountDepositInstructions,
1317
+ type BridgeBrlFiatVirtualAccountDepositInstructions as BridgeBrlFiatVirtualAccountDepositInstructions,
1318
+ type BridgeGbpFiatVirtualAccountDepositInstructions as BridgeGbpFiatVirtualAccountDepositInstructions,
1319
+ type BridgeFiatVirtualAccountDepositInstructions as BridgeFiatVirtualAccountDepositInstructions,
1320
+ type BridgeFiatVirtualAccountResponse as BridgeFiatVirtualAccountResponse,
1321
+ type BridgeSandboxFiatVirtualAccountResponse as BridgeSandboxFiatVirtualAccountResponse,
1322
+ type FiatVirtualAccountResponse as FiatVirtualAccountResponse,
1174
1323
  };
1175
1324
 
1176
1325
  export { Analytics as Analytics, type AnalyticsEventInput as AnalyticsEventInput };
@@ -1184,5 +1333,76 @@ export declare namespace PrivyAPI {
1184
1333
  type AggregationWindow as AggregationWindow,
1185
1334
  type AggregationGroupBy as AggregationGroupBy,
1186
1335
  type Aggregation as Aggregation,
1336
+ type AggregationInput as AggregationInput,
1337
+ };
1338
+
1339
+ export {
1340
+ 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,
1348
+ type TransactionBroadcastedWebhookPayload as TransactionBroadcastedWebhookPayload,
1349
+ type TransactionConfirmedWebhookPayload as TransactionConfirmedWebhookPayload,
1350
+ type TransactionExecutionRevertedWebhookPayload as TransactionExecutionRevertedWebhookPayload,
1351
+ type TransactionStillPendingWebhookPayload as TransactionStillPendingWebhookPayload,
1352
+ type TransactionFailedWebhookPayload as TransactionFailedWebhookPayload,
1353
+ type TransactionReplacedWebhookPayload as TransactionReplacedWebhookPayload,
1354
+ type TransactionProviderErrorWebhookPayload as TransactionProviderErrorWebhookPayload,
1355
+ type FundsDepositedWebhookPayload as FundsDepositedWebhookPayload,
1356
+ type FundsWithdrawnWebhookPayload as FundsWithdrawnWebhookPayload,
1357
+ type PrivateKeyExportWebhookPayload as PrivateKeyExportWebhookPayload,
1358
+ type WalletRecoverySetupWebhookPayload as WalletRecoverySetupWebhookPayload,
1359
+ type WalletRecoveredWebhookPayload as WalletRecoveredWebhookPayload,
1360
+ type MfaEnabledWebhookPayload as MfaEnabledWebhookPayload,
1361
+ type MfaDisabledWebhookPayload as MfaDisabledWebhookPayload,
1362
+ type KrakenEmbedVerificationCompletedWebhookPayload as KrakenEmbedVerificationCompletedWebhookPayload,
1363
+ type KrakenEmbedVerificationFailedWebhookPayload as KrakenEmbedVerificationFailedWebhookPayload,
1364
+ type KrakenEmbedQuoteExecutedWebhookPayload as KrakenEmbedQuoteExecutedWebhookPayload,
1365
+ type KrakenEmbedQuoteExecutionFailedWebhookPayload as KrakenEmbedQuoteExecutionFailedWebhookPayload,
1366
+ type KrakenEmbedQuoteCancelledWebhookPayload as KrakenEmbedQuoteCancelledWebhookPayload,
1367
+ type KrakenEmbedUserVerifiedWebhookPayload as KrakenEmbedUserVerifiedWebhookPayload,
1368
+ type KrakenEmbedUserDisabledWebhookPayload as KrakenEmbedUserDisabledWebhookPayload,
1369
+ type KrakenEmbedUserClosedWebhookPayload as KrakenEmbedUserClosedWebhookPayload,
1370
+ type YieldDepositConfirmedWebhookPayload as YieldDepositConfirmedWebhookPayload,
1371
+ type YieldWithdrawConfirmedWebhookPayload as YieldWithdrawConfirmedWebhookPayload,
1372
+ };
1373
+
1374
+ export {
1375
+ Accounts as Accounts,
1376
+ type AccountWallet as AccountWallet,
1377
+ type AccountResponse as AccountResponse,
1378
+ type AccountWalletConfigurationItem as AccountWalletConfigurationItem,
1379
+ type CreateAccountInput as CreateAccountInput,
1380
+ };
1381
+
1382
+ export {
1383
+ Yield as Yield,
1384
+ type EvmCaip2ChainID as EvmCaip2ChainID,
1385
+ type EthereumYieldProvider as EthereumYieldProvider,
1386
+ type EthereumYieldSweepType as EthereumYieldSweepType,
1387
+ type EthereumYieldSweepStatus as EthereumYieldSweepStatus,
1388
+ type EthereumYieldDepositInput as EthereumYieldDepositInput,
1389
+ type EthereumYieldWithdrawInput as EthereumYieldWithdrawInput,
1390
+ type EthereumYieldSweepResponse as EthereumYieldSweepResponse,
1391
+ type EthereumVaultDetailsInput as EthereumVaultDetailsInput,
1392
+ type EthereumYieldSweepIDInput as EthereumYieldSweepIDInput,
1393
+ type EthereumVaultResponse as EthereumVaultResponse,
1394
+ type EthereumVaultDetailsResponse as EthereumVaultDetailsResponse,
1395
+ type EthereumYieldPositionsInput as EthereumYieldPositionsInput,
1396
+ type EthereumVaultPosition as EthereumVaultPosition,
1397
+ type EthereumYieldPositionResponse as EthereumYieldPositionResponse,
1398
+ type EthereumYieldClaimInput as EthereumYieldClaimInput,
1399
+ type EthereumYieldClaimReward as EthereumYieldClaimReward,
1400
+ type EthereumYieldClaimResponse as EthereumYieldClaimResponse,
1401
+ };
1402
+
1403
+ export {
1404
+ Intents as Intents,
1405
+ type IntentAuthorizationKeyQuorumMember as IntentAuthorizationKeyQuorumMember,
1406
+ type IntentAuthorizationMember as IntentAuthorizationMember,
1187
1407
  };
1188
1408
  }
package/src/index.ts CHANGED
@@ -19,7 +19,7 @@ export {
19
19
  type VerifyIdentityTokenInput,
20
20
  } from './lib/auth';
21
21
 
22
- export { type User, type LinkedAccountEmbeddedWallet } from './resources/users';
22
+ export { type User, type LinkedAccountEmbeddedWallet, type LinkedAccount } from './resources/users';
23
23
  export { type Wallet } from './resources/wallets';
24
24
  export { type Policy } from './resources/policies';
25
25
  export { type KeyQuorum } from './resources/key-quorums';
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: PrivyAPI, props: APIRespon
29
29
  const mediaType = contentType?.split(';')[0]?.trim();
30
30
  const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
31
31
  if (isJSON) {
32
+ const contentLength = response.headers.get('content-length');
33
+ if (contentLength === '0') {
34
+ // if there is no content we can't do anything
35
+ return undefined as T;
36
+ }
37
+
32
38
  const json = await response.json();
33
39
  return json as T;
34
40
  }
@@ -5,6 +5,7 @@ import {
5
5
  EthereumSign7702AuthorizationRpcResponse,
6
6
  EthereumSignTransactionRpcResponse,
7
7
  EthereumSignTypedDataRpcResponse,
8
+ EthereumSignUserOperationRpcResponse,
8
9
  WalletRpcParams,
9
10
  } from '../../resources';
10
11
  import { ReplaceParams, PrivyWalletsService } from './wallets';
@@ -94,6 +95,19 @@ export class PrivyEthereumService {
94
95
  return response.data;
95
96
  }
96
97
 
98
+ public async signUserOperation(
99
+ walletId: string,
100
+ input: PrivyEthereumService.SignUserOperationInput,
101
+ ): Promise<EthereumSignUserOperationRpcResponse.Data> {
102
+ const response = await this.privyWalletsService.rpc(walletId, {
103
+ ...input,
104
+ method: 'eth_signUserOperation',
105
+ chain_type: 'ethereum',
106
+ });
107
+
108
+ return response.data;
109
+ }
110
+
97
111
  public async sendTransaction(
98
112
  walletId: string,
99
113
  input: PrivyEthereumService.SendTransactionInput,
@@ -129,6 +143,8 @@ export namespace PrivyEthereumService {
129
143
  export type SignTransactionInput = PrivyWalletsRpcInput<WalletRpcParams.EthereumSignTransactionRpcInput>;
130
144
  /** The input type for the {@link PrivyEthereumService.signTypedData} method. */
131
145
  export type SignTypedDataInput = PrivyWalletsRpcInput<WalletRpcParams.EthereumSignTypedDataRpcInput>;
146
+ /** The input type for the {@link PrivyEthereumService.signUserOperation} method. */
147
+ export type SignUserOperationInput = PrivyWalletsRpcInput<WalletRpcParams.EthereumSignUserOperationRpcInput>;
132
148
  /** The input type for the {@link PrivyEthereumService.sendTransaction} method. */
133
149
  export type SendTransactionInput = PrivyWalletsRpcInput<WalletRpcParams.EthereumSendTransactionRpcInput>;
134
150
  }
@@ -1,5 +1,51 @@
1
1
  import { Webhook } from 'svix';
2
2
  import { PrivyAPIError } from '../../core/error';
3
+ import type {
4
+ UserCreatedWebhookPayload,
5
+ UserAuthenticatedWebhookPayload,
6
+ UserLinkedAccountWebhookPayload,
7
+ UserUnlinkedAccountWebhookPayload,
8
+ UserUpdatedAccountWebhookPayload,
9
+ UserTransferredAccountWebhookPayload,
10
+ UserWalletCreatedWebhookPayload,
11
+ TransactionBroadcastedWebhookPayload,
12
+ TransactionConfirmedWebhookPayload,
13
+ TransactionExecutionRevertedWebhookPayload,
14
+ TransactionStillPendingWebhookPayload,
15
+ TransactionFailedWebhookPayload,
16
+ TransactionReplacedWebhookPayload,
17
+ TransactionProviderErrorWebhookPayload,
18
+ FundsDepositedWebhookPayload,
19
+ FundsWithdrawnWebhookPayload,
20
+ PrivateKeyExportWebhookPayload,
21
+ WalletRecoverySetupWebhookPayload,
22
+ WalletRecoveredWebhookPayload,
23
+ MfaEnabledWebhookPayload,
24
+ MfaDisabledWebhookPayload,
25
+ } from '../../resources/webhooks';
26
+
27
+ export type WebhookEvent =
28
+ | UserCreatedWebhookPayload
29
+ | UserAuthenticatedWebhookPayload
30
+ | UserLinkedAccountWebhookPayload
31
+ | UserUnlinkedAccountWebhookPayload
32
+ | UserUpdatedAccountWebhookPayload
33
+ | UserTransferredAccountWebhookPayload
34
+ | UserWalletCreatedWebhookPayload
35
+ | TransactionBroadcastedWebhookPayload
36
+ | TransactionConfirmedWebhookPayload
37
+ | TransactionExecutionRevertedWebhookPayload
38
+ | TransactionStillPendingWebhookPayload
39
+ | TransactionFailedWebhookPayload
40
+ | TransactionReplacedWebhookPayload
41
+ | TransactionProviderErrorWebhookPayload
42
+ | FundsDepositedWebhookPayload
43
+ | FundsWithdrawnWebhookPayload
44
+ | PrivateKeyExportWebhookPayload
45
+ | WalletRecoverySetupWebhookPayload
46
+ | WalletRecoveredWebhookPayload
47
+ | MfaEnabledWebhookPayload
48
+ | MfaDisabledWebhookPayload;
3
49
 
4
50
  export class PrivyWebhooksService {
5
51
  private webhookSigningSecret: string | undefined;
@@ -17,7 +63,7 @@ export class PrivyWebhooksService {
17
63
  * @param input.signing_secret The webhook secret to use for verifying the webhook request.
18
64
  * @returns verified payload if the webhook signature is valid otherwise throws.
19
65
  */
20
- async verify({ payload, svix, signing_secret }: PrivyWebhooksService.VerifyInput): Promise<unknown> {
66
+ async verify({ payload, svix, signing_secret }: PrivyWebhooksService.VerifyInput): Promise<WebhookEvent> {
21
67
  const signingSecret = signing_secret ?? this.webhookSigningSecret;
22
68
  if (!signingSecret) {
23
69
  throw new InvalidWebhookError('Webhook signing secret is required');
@@ -31,7 +77,8 @@ export class PrivyWebhooksService {
31
77
  'svix-timestamp': svix.timestamp,
32
78
  'svix-signature': svix.signature,
33
79
  };
34
- return webhook.verify(stringPayload, svixHeaders);
80
+ // Casting is safe here because `verify` succeeds meaning the API sent this event.
81
+ return webhook.verify(stringPayload, svixHeaders) as WebhookEvent;
35
82
  } catch (error) {
36
83
  if (error instanceof Error) {
37
84
  throw new InvalidWebhookError(`Webhook verification failed: ${error.message}`);
@@ -0,0 +1,90 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as WalletsAPI from './wallets/wallets';
5
+
6
+ export class Accounts extends APIResource {}
7
+
8
+ /**
9
+ * A wallet belonging to a digital asset account.
10
+ */
11
+ export interface AccountWallet {
12
+ /**
13
+ * The wallet ID.
14
+ */
15
+ id: string;
16
+
17
+ /**
18
+ * The on-chain address of the wallet.
19
+ */
20
+ address: string;
21
+
22
+ /**
23
+ * The wallet chain types that offer first class support.
24
+ */
25
+ chain_type: WalletsAPI.FirstClassChainType;
26
+
27
+ /**
28
+ * Information about the custodian managing this wallet.
29
+ */
30
+ custody?: WalletsAPI.WalletCustodian;
31
+ }
32
+
33
+ /**
34
+ * A digital asset account that groups wallets under a single entity.
35
+ */
36
+ export interface AccountResponse {
37
+ /**
38
+ * The account ID.
39
+ */
40
+ id: string;
41
+
42
+ /**
43
+ * An optional display name for the account.
44
+ */
45
+ display_name: string | null;
46
+
47
+ /**
48
+ * The wallets belonging to this account.
49
+ */
50
+ wallets: Array<AccountWallet>;
51
+ }
52
+
53
+ /**
54
+ * Configuration for a wallet to create within an account.
55
+ */
56
+ export interface AccountWalletConfigurationItem {
57
+ /**
58
+ * The wallet chain types that offer first class support.
59
+ */
60
+ chain_type: WalletsAPI.FirstClassChainType;
61
+
62
+ /**
63
+ * Information about the custodian managing this wallet.
64
+ */
65
+ custody?: WalletsAPI.WalletCustodian;
66
+ }
67
+
68
+ /**
69
+ * Input for creating a digital asset account.
70
+ */
71
+ export interface CreateAccountInput {
72
+ /**
73
+ * Configuration for wallets to create.
74
+ */
75
+ wallets_configuration: Array<AccountWalletConfigurationItem>;
76
+
77
+ /**
78
+ * An optional display name for the account.
79
+ */
80
+ display_name?: string;
81
+ }
82
+
83
+ export declare namespace Accounts {
84
+ export {
85
+ type AccountWallet as AccountWallet,
86
+ type AccountResponse as AccountResponse,
87
+ type AccountWalletConfigurationItem as AccountWalletConfigurationItem,
88
+ type CreateAccountInput as CreateAccountInput,
89
+ };
90
+ }