@privy-io/node 0.6.2 → 0.7.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 (106) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/client.d.mts +7 -7
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +7 -7
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/index.d.mts +2 -1
  9. package/index.d.mts.map +1 -1
  10. package/index.d.ts +2 -1
  11. package/index.d.ts.map +1 -1
  12. package/index.js +4 -1
  13. package/index.js.map +1 -1
  14. package/index.mjs +2 -1
  15. package/index.mjs.map +1 -1
  16. package/lib/auth.d.mts +30 -2
  17. package/lib/auth.d.mts.map +1 -1
  18. package/lib/auth.d.ts +30 -2
  19. package/lib/auth.d.ts.map +1 -1
  20. package/lib/auth.js +14 -5
  21. package/lib/auth.js.map +1 -1
  22. package/lib/auth.mjs +11 -3
  23. package/lib/auth.mjs.map +1 -1
  24. package/lib/cryptography.d.mts +35 -3
  25. package/lib/cryptography.d.mts.map +1 -1
  26. package/lib/cryptography.d.ts +35 -3
  27. package/lib/cryptography.d.ts.map +1 -1
  28. package/lib/cryptography.js +53 -6
  29. package/lib/cryptography.js.map +1 -1
  30. package/lib/cryptography.mjs +50 -3
  31. package/lib/cryptography.mjs.map +1 -1
  32. package/lib/identity-token.d.mts.map +1 -1
  33. package/lib/identity-token.d.ts.map +1 -1
  34. package/lib/identity-token.js +0 -1
  35. package/lib/identity-token.js.map +1 -1
  36. package/lib/identity-token.mjs +0 -1
  37. package/lib/identity-token.mjs.map +1 -1
  38. package/package.json +13 -1
  39. package/public-api/services/utils/auth.d.mts +10 -1
  40. package/public-api/services/utils/auth.d.mts.map +1 -1
  41. package/public-api/services/utils/auth.d.ts +10 -1
  42. package/public-api/services/utils/auth.d.ts.map +1 -1
  43. package/public-api/services/utils/auth.js +16 -5
  44. package/public-api/services/utils/auth.js.map +1 -1
  45. package/public-api/services/utils/auth.mjs +17 -6
  46. package/public-api/services/utils/auth.mjs.map +1 -1
  47. package/resources/apps.d.mts +25 -0
  48. package/resources/apps.d.mts.map +1 -1
  49. package/resources/apps.d.ts +25 -0
  50. package/resources/apps.d.ts.map +1 -1
  51. package/resources/index.d.mts +3 -3
  52. package/resources/index.d.mts.map +1 -1
  53. package/resources/index.d.ts +3 -3
  54. package/resources/index.d.ts.map +1 -1
  55. package/resources/index.js.map +1 -1
  56. package/resources/index.mjs.map +1 -1
  57. package/resources/policies.d.mts +68 -115
  58. package/resources/policies.d.mts.map +1 -1
  59. package/resources/policies.d.ts +68 -115
  60. package/resources/policies.d.ts.map +1 -1
  61. package/resources/policies.js.map +1 -1
  62. package/resources/policies.mjs.map +1 -1
  63. package/resources/users.d.mts +642 -381
  64. package/resources/users.d.mts.map +1 -1
  65. package/resources/users.d.ts +642 -381
  66. package/resources/users.d.ts.map +1 -1
  67. package/resources/wallets/index.d.mts +1 -1
  68. package/resources/wallets/index.d.mts.map +1 -1
  69. package/resources/wallets/index.d.ts +1 -1
  70. package/resources/wallets/index.d.ts.map +1 -1
  71. package/resources/wallets/index.js.map +1 -1
  72. package/resources/wallets/index.mjs.map +1 -1
  73. package/resources/wallets/wallets.d.mts +98 -4
  74. package/resources/wallets/wallets.d.mts.map +1 -1
  75. package/resources/wallets/wallets.d.ts +98 -4
  76. package/resources/wallets/wallets.d.ts.map +1 -1
  77. package/resources/wallets/wallets.js +1 -1
  78. package/resources/wallets/wallets.js.map +1 -1
  79. package/resources/wallets/wallets.mjs +1 -1
  80. package/resources/wallets/wallets.mjs.map +1 -1
  81. package/solana-kit.d.mts +53 -0
  82. package/solana-kit.d.mts.map +1 -0
  83. package/solana-kit.d.ts +53 -0
  84. package/solana-kit.d.ts.map +1 -0
  85. package/solana-kit.js +92 -0
  86. package/solana-kit.js.map +1 -0
  87. package/solana-kit.mjs +89 -0
  88. package/solana-kit.mjs.map +1 -0
  89. package/src/client.ts +131 -3
  90. package/src/index.ts +5 -0
  91. package/src/lib/auth.ts +42 -6
  92. package/src/lib/cryptography.ts +72 -3
  93. package/src/lib/identity-token.ts +38 -18
  94. package/src/public-api/services/utils/auth.ts +19 -6
  95. package/src/resources/apps.ts +44 -0
  96. package/src/resources/index.ts +66 -2
  97. package/src/resources/policies.ts +105 -191
  98. package/src/resources/users.ts +942 -625
  99. package/src/resources/wallets/index.ts +6 -0
  100. package/src/resources/wallets/wallets.ts +125 -3
  101. package/src/solana-kit.ts +148 -0
  102. package/src/version.ts +1 -1
  103. package/version.d.mts +1 -1
  104. package/version.d.ts +1 -1
  105. package/version.js +1 -1
  106. package/version.mjs +1 -1
@@ -10,6 +10,12 @@ export {
10
10
  type WalletChainType,
11
11
  type ExtendedChainType,
12
12
  type WalletCustodian,
13
+ type CustodialWalletProvider,
14
+ type CustodialWalletChainType,
15
+ type CustodialWalletCreateInput,
16
+ type CustodialWallet,
17
+ type HpkeImportConfig,
18
+ type SuiCommandName,
13
19
  type EthereumPersonalSignRpcInput,
14
20
  type EthereumSignTransactionRpcInput,
15
21
  type EthereumSendTransactionRpcInput,
@@ -17,7 +17,7 @@ export class Wallets extends APIResource {
17
17
  balance: BalanceAPI.Balance = new BalanceAPI.Balance(this._client);
18
18
 
19
19
  /**
20
- * Create a new wallet.
20
+ * Creates a new wallet on the requested chain and for the requested owner.
21
21
  *
22
22
  * @example
23
23
  * ```ts
@@ -399,6 +399,108 @@ export interface WalletCustodian {
399
399
  name: string;
400
400
  }
401
401
 
402
+ /**
403
+ * The provider of the custodial wallet.
404
+ */
405
+ export type CustodialWalletProvider = 'bridge';
406
+
407
+ /**
408
+ * The chain type of the custodial wallet.
409
+ */
410
+ export type CustodialWalletChainType = 'ethereum';
411
+
412
+ /**
413
+ * The input for creating a custodial wallet.
414
+ */
415
+ export interface CustodialWalletCreateInput {
416
+ /**
417
+ * The chain type of the custodial wallet.
418
+ */
419
+ chain_type: CustodialWalletChainType;
420
+
421
+ /**
422
+ * The provider of the custodial wallet.
423
+ */
424
+ provider: CustodialWalletProvider;
425
+
426
+ /**
427
+ * The resource ID of the beneficiary of the custodial wallet, given by the
428
+ * licensing provider.
429
+ */
430
+ provider_user_id: string;
431
+
432
+ additional_signers?: Array<CustodialWalletCreateInput.AdditionalSigner>;
433
+
434
+ owner?: CustodialWalletCreateInput.UserID | CustodialWalletCreateInput.PublicKey | null;
435
+
436
+ policy_ids?: Array<string>;
437
+ }
438
+
439
+ export namespace CustodialWalletCreateInput {
440
+ export interface AdditionalSigner {
441
+ signer_id: string;
442
+
443
+ override_policy_ids?: Array<string>;
444
+ }
445
+
446
+ export interface UserID {
447
+ user_id: string;
448
+ }
449
+
450
+ export interface PublicKey {
451
+ public_key: string;
452
+ }
453
+ }
454
+
455
+ /**
456
+ * Information about a custodial wallet.
457
+ */
458
+ export interface CustodialWallet {
459
+ id: string;
460
+
461
+ address: string;
462
+
463
+ /**
464
+ * The chain type of the custodial wallet.
465
+ */
466
+ chainType: CustodialWalletChainType;
467
+
468
+ /**
469
+ * The provider of the custodial wallet.
470
+ */
471
+ provider: CustodialWalletProvider;
472
+ }
473
+
474
+ /**
475
+ * Optional HPKE configuration for wallet import decryption. These parameters allow
476
+ * importing wallets encrypted by external providers that use different HPKE
477
+ * configurations.
478
+ */
479
+ export interface HpkeImportConfig {
480
+ /**
481
+ * Additional Authenticated Data (AAD) used during encryption. Should be
482
+ * base64-encoded bytes.
483
+ */
484
+ aad?: string;
485
+
486
+ /**
487
+ * The AEAD algorithm used for encryption. Defaults to CHACHA20_POLY1305 if not
488
+ * specified.
489
+ */
490
+ aead_algorithm?: 'CHACHA20_POLY1305' | 'AES_GCM256';
491
+
492
+ /**
493
+ * Application-specific context information (INFO) used during HPKE encryption.
494
+ * Should be base64-encoded bytes.
495
+ */
496
+ info?: string;
497
+ }
498
+
499
+ /**
500
+ * SUI transaction commands allowlist for raw_sign endpoint policy evaluation
501
+ */
502
+ export type SuiCommandName = 'TransferObjects' | 'SplitCoins' | 'MergeCoins';
503
+
402
504
  /**
403
505
  * Executes the EVM `personal_sign` RPC (EIP-191) to sign a message.
404
506
  */
@@ -1252,12 +1354,12 @@ export namespace WalletRawSignParams {
1252
1354
  /**
1253
1355
  * The encoding scheme for the bytes.
1254
1356
  */
1255
- encoding: 'utf-8' | 'hex';
1357
+ encoding: 'utf-8' | 'hex' | 'base64';
1256
1358
 
1257
1359
  /**
1258
1360
  * The hash function to hash the bytes.
1259
1361
  */
1260
- hash_function: 'keccak256' | 'sha256';
1362
+ hash_function: 'keccak256' | 'sha256' | 'blake2b256';
1261
1363
  }
1262
1364
  }
1263
1365
 
@@ -1861,6 +1963,13 @@ export namespace WalletSubmitImportParams {
1861
1963
  * The index of the wallet to import.
1862
1964
  */
1863
1965
  index: number;
1966
+
1967
+ /**
1968
+ * Optional HPKE configuration for wallet import decryption. These parameters allow
1969
+ * importing wallets encrypted by external providers that use different HPKE
1970
+ * configurations.
1971
+ */
1972
+ hpke_config?: WalletsAPI.HpkeImportConfig;
1864
1973
  }
1865
1974
 
1866
1975
  export interface PrivateKeySubmitInput {
@@ -1892,6 +2001,13 @@ export namespace WalletSubmitImportParams {
1892
2001
  encryption_type: 'HPKE';
1893
2002
 
1894
2003
  entropy_type: 'private-key';
2004
+
2005
+ /**
2006
+ * Optional HPKE configuration for wallet import decryption. These parameters allow
2007
+ * importing wallets encrypted by external providers that use different HPKE
2008
+ * configurations.
2009
+ */
2010
+ hpke_config?: WalletsAPI.HpkeImportConfig;
1895
2011
  }
1896
2012
 
1897
2013
  export interface AdditionalSigner {
@@ -2055,6 +2171,12 @@ export declare namespace Wallets {
2055
2171
  type WalletChainType as WalletChainType,
2056
2172
  type ExtendedChainType as ExtendedChainType,
2057
2173
  type WalletCustodian as WalletCustodian,
2174
+ type CustodialWalletProvider as CustodialWalletProvider,
2175
+ type CustodialWalletChainType as CustodialWalletChainType,
2176
+ type CustodialWalletCreateInput as CustodialWalletCreateInput,
2177
+ type CustodialWallet as CustodialWallet,
2178
+ type HpkeImportConfig as HpkeImportConfig,
2179
+ type SuiCommandName as SuiCommandName,
2058
2180
  type EthereumPersonalSignRpcInput as EthereumPersonalSignRpcInput,
2059
2181
  type EthereumSignTransactionRpcInput as EthereumSignTransactionRpcInput,
2060
2182
  type EthereumSendTransactionRpcInput as EthereumSendTransactionRpcInput,
@@ -0,0 +1,148 @@
1
+ import {
2
+ getBase64EncodedWireTransaction,
3
+ getTransactionDecoder,
4
+ type Address,
5
+ type SignatureBytes,
6
+ } from '@solana/kit';
7
+ import { base58, base64 } from '@scure/base';
8
+ import type {
9
+ MessagePartialSigner,
10
+ TransactionPartialSigner,
11
+ TransactionSendingSigner,
12
+ } from '@solana/signers';
13
+ import type { AuthorizationContext } from './lib/authorization';
14
+ import type { PrivyClient } from './public-api/PrivyClient';
15
+
16
+ export interface CreateSolanaKitSignerInput {
17
+ /** ID for the wallet. */
18
+ walletId: string;
19
+ /** Solana address for the wallet. */
20
+ address: Address;
21
+ /** Authorization context for the wallet. */
22
+ authorizationContext?: AuthorizationContext;
23
+ /**
24
+ * CAIP-2 for the Solana network.
25
+ * @optional This field is only required for sending transactions.
26
+ */
27
+ caip2?: string;
28
+ }
29
+
30
+ /**
31
+ * Defines a signer that uses a {@link PrivyClient} to sign messages and transactions.
32
+ *
33
+ * It implements the {@link MessagePartialSigner}, {@link TransactionPartialSigner},
34
+ * and {@link TransactionSendingSigner} interfaces and keeps track of the ID of the
35
+ * wallet used to sign them.
36
+ */
37
+ export type SolanaKitSigner = MessagePartialSigner &
38
+ TransactionPartialSigner &
39
+ TransactionSendingSigner &
40
+ Readonly<{ walletId: string; address: Address }>;
41
+
42
+ /**
43
+ * Creates a {@link SolanaKitSigner} from a provided Privy wallet and authorization context.
44
+ *
45
+ * The returned signer implements:
46
+ * - {@link MessagePartialSigner} - for signing messages via `signMessages`
47
+ * - {@link TransactionPartialSigner} - for signing transactions via `signTransactions`
48
+ * - {@link TransactionSendingSigner} - for signing and sending transactions via `signAndSendTransactions`
49
+ *
50
+ * And it keeps track of the `walletId` used to sign them.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import { PrivyClient } from '@privy-io/node';
55
+ * import { createSolanaKitSigner } from '@privy-io/node/solana-kit';
56
+ * import { address } from '@solana/kit';
57
+ *
58
+ * const client = new PrivyClient({ appId: '...', appSecret: '...' });
59
+ * const signer = createSolanaKitSigner(client, {
60
+ * walletId: 'wallet-id',
61
+ * address: address('...'),
62
+ * });
63
+ * ```
64
+ */
65
+ export function createSolanaKitSigner(
66
+ client: PrivyClient,
67
+ { walletId, address, authorizationContext, caip2 }: CreateSolanaKitSignerInput,
68
+ ): SolanaKitSigner {
69
+ const authCtxOptions = authorizationContext ? { authorization_context: authorizationContext } : {};
70
+ return {
71
+ address,
72
+ walletId,
73
+
74
+ async signMessages(messages) {
75
+ return await Promise.all(
76
+ messages.map(async (message) => {
77
+ const response = await client
78
+ .wallets()
79
+ .solana()
80
+ .signMessage(walletId, {
81
+ message: message.content,
82
+ ...authCtxOptions,
83
+ });
84
+
85
+ // We assert the signature is valid by casting to `SignatureBytes`
86
+ const signatureBytes = base64.decode(response.signature) as SignatureBytes;
87
+ return {
88
+ [address]: signatureBytes,
89
+ };
90
+ }),
91
+ );
92
+ },
93
+
94
+ async signTransactions(transactions) {
95
+ return await Promise.all(
96
+ transactions.map(async (transaction) => {
97
+ // Convert compiled transaction to wire format base64
98
+ const transactionBase64 = getBase64EncodedWireTransaction(transaction);
99
+
100
+ const response = await client
101
+ .wallets()
102
+ .solana()
103
+ .signTransaction(walletId, {
104
+ transaction: transactionBase64,
105
+ ...authCtxOptions,
106
+ });
107
+
108
+ const signedTransactionBytes = base64.decode(response.signed_transaction);
109
+ const decoder = getTransactionDecoder();
110
+ const signedTransaction = decoder.decode(signedTransactionBytes);
111
+
112
+ return {
113
+ // We assert the signature exists by asserting as non-null
114
+ [address]: signedTransaction.signatures[address]!,
115
+ };
116
+ }),
117
+ );
118
+ },
119
+
120
+ async signAndSendTransactions(transactions) {
121
+ if (!caip2) {
122
+ throw new Error(
123
+ 'CAIP-2 is required for sending transactions. Please provide one in the createSolanaKitSigner input.',
124
+ );
125
+ }
126
+
127
+ return await Promise.all(
128
+ transactions.map(async (transaction) => {
129
+ // Convert compiled transaction to wire format base64
130
+ const transactionBase64 = getBase64EncodedWireTransaction(transaction);
131
+
132
+ const response = await client
133
+ .wallets()
134
+ .solana()
135
+ .signAndSendTransaction(walletId, {
136
+ transaction: transactionBase64,
137
+ caip2,
138
+ ...authCtxOptions,
139
+ });
140
+
141
+ // The hash returned is base58-encoded, convert to bytes
142
+ // and cast as a SignatureBytes, asserting it is a valid signature.
143
+ return base58.decode(response.hash) as SignatureBytes;
144
+ }),
145
+ );
146
+ },
147
+ };
148
+ }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.6.2'; // x-release-please-version
1
+ export const VERSION = '0.7.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.6.2";
1
+ export declare const VERSION = "0.7.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.6.2";
1
+ export declare const VERSION = "0.7.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.6.2'; // x-release-please-version
4
+ exports.VERSION = '0.7.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.6.2'; // x-release-please-version
1
+ export const VERSION = '0.7.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map