@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.
- package/CHANGELOG.md +73 -0
- package/client.d.mts +23 -10
- package/client.d.mts.map +1 -1
- package/client.d.ts +23 -10
- package/client.d.ts.map +1 -1
- package/client.js +30 -3
- package/client.js.map +1 -1
- package/client.mjs +30 -3
- package/client.mjs.map +1 -1
- package/index.d.mts +1 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/internal/parse.d.mts.map +1 -1
- package/internal/parse.d.ts.map +1 -1
- package/internal/parse.js +5 -0
- package/internal/parse.js.map +1 -1
- package/internal/parse.mjs +5 -0
- package/internal/parse.mjs.map +1 -1
- package/package.json +21 -1
- package/public-api/services/ethereum.d.mts +4 -1
- package/public-api/services/ethereum.d.mts.map +1 -1
- package/public-api/services/ethereum.d.ts +4 -1
- package/public-api/services/ethereum.d.ts.map +1 -1
- package/public-api/services/ethereum.js +8 -0
- package/public-api/services/ethereum.js.map +1 -1
- package/public-api/services/ethereum.mjs +8 -0
- package/public-api/services/ethereum.mjs.map +1 -1
- package/public-api/services/webhooks.d.mts +3 -1
- package/public-api/services/webhooks.d.mts.map +1 -1
- package/public-api/services/webhooks.d.ts +3 -1
- package/public-api/services/webhooks.d.ts.map +1 -1
- package/public-api/services/webhooks.js +1 -0
- package/public-api/services/webhooks.js.map +1 -1
- package/public-api/services/webhooks.mjs +1 -0
- package/public-api/services/webhooks.mjs.map +1 -1
- package/resources/accounts.d.mts +72 -0
- package/resources/accounts.d.mts.map +1 -0
- package/resources/accounts.d.ts +72 -0
- package/resources/accounts.d.ts.map +1 -0
- package/resources/accounts.js +9 -0
- package/resources/accounts.js.map +1 -0
- package/resources/accounts.mjs +5 -0
- package/resources/accounts.mjs.map +1 -0
- package/resources/aggregations.d.mts +213 -2
- package/resources/aggregations.d.mts.map +1 -1
- package/resources/aggregations.d.ts +213 -2
- package/resources/aggregations.d.ts.map +1 -1
- package/resources/client-auth.d.mts +182 -2
- package/resources/client-auth.d.mts.map +1 -1
- package/resources/client-auth.d.ts +182 -2
- package/resources/client-auth.d.ts.map +1 -1
- package/resources/index.d.mts +8 -4
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +8 -4
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +9 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +4 -0
- package/resources/index.mjs.map +1 -1
- package/resources/intents.d.mts +104 -0
- package/resources/intents.d.mts.map +1 -0
- package/resources/intents.d.ts +104 -0
- package/resources/intents.d.ts.map +1 -0
- package/resources/intents.js +9 -0
- package/resources/intents.js.map +1 -0
- package/resources/intents.mjs +5 -0
- package/resources/intents.mjs.map +1 -0
- package/resources/key-quorums.d.mts +14 -0
- package/resources/key-quorums.d.mts.map +1 -1
- package/resources/key-quorums.d.ts +14 -0
- package/resources/key-quorums.d.ts.map +1 -1
- package/resources/policies.d.mts +10 -12
- package/resources/policies.d.mts.map +1 -1
- package/resources/policies.d.ts +10 -12
- package/resources/policies.d.ts.map +1 -1
- package/resources/users.d.mts +16 -6
- package/resources/users.d.mts.map +1 -1
- package/resources/users.d.ts +16 -6
- package/resources/users.d.ts.map +1 -1
- package/resources/wallets/balance.d.mts +10 -5
- package/resources/wallets/balance.d.mts.map +1 -1
- package/resources/wallets/balance.d.ts +10 -5
- package/resources/wallets/balance.d.ts.map +1 -1
- package/resources/wallets/balance.js +1 -2
- package/resources/wallets/balance.js.map +1 -1
- package/resources/wallets/balance.mjs +1 -2
- package/resources/wallets/balance.mjs.map +1 -1
- package/resources/wallets/index.d.mts +1 -1
- package/resources/wallets/index.d.mts.map +1 -1
- package/resources/wallets/index.d.ts +1 -1
- package/resources/wallets/index.d.ts.map +1 -1
- package/resources/wallets/index.js.map +1 -1
- package/resources/wallets/index.mjs.map +1 -1
- package/resources/wallets/transactions.d.mts +2 -2
- package/resources/wallets/transactions.d.mts.map +1 -1
- package/resources/wallets/transactions.d.ts +2 -2
- package/resources/wallets/transactions.d.ts.map +1 -1
- package/resources/wallets/wallets.d.mts +141 -14
- package/resources/wallets/wallets.d.mts.map +1 -1
- package/resources/wallets/wallets.d.ts +141 -14
- package/resources/wallets/wallets.d.ts.map +1 -1
- package/resources/wallets/wallets.js.map +1 -1
- package/resources/wallets/wallets.mjs.map +1 -1
- package/resources/webhooks.d.mts +977 -0
- package/resources/webhooks.d.mts.map +1 -0
- package/resources/webhooks.d.ts +977 -0
- package/resources/webhooks.d.ts.map +1 -0
- package/resources/webhooks.js +9 -0
- package/resources/webhooks.js.map +1 -0
- package/resources/webhooks.mjs +5 -0
- package/resources/webhooks.mjs.map +1 -0
- package/resources/yield.d.mts +311 -0
- package/resources/yield.d.mts.map +1 -0
- package/resources/yield.d.ts +311 -0
- package/resources/yield.d.ts.map +1 -0
- package/resources/yield.js +9 -0
- package/resources/yield.js.map +1 -0
- package/resources/yield.mjs +5 -0
- package/resources/yield.mjs.map +1 -0
- package/src/client.ts +229 -9
- package/src/index.ts +1 -1
- package/src/internal/parse.ts +6 -0
- package/src/public-api/services/ethereum.ts +16 -0
- package/src/public-api/services/webhooks.ts +49 -2
- package/src/resources/accounts.ts +90 -0
- package/src/resources/aggregations.ts +361 -5
- package/src/resources/client-auth.ts +310 -1
- package/src/resources/index.ts +95 -3
- package/src/resources/intents.ts +138 -0
- package/src/resources/key-quorums.ts +17 -0
- package/src/resources/policies.ts +10 -12
- package/src/resources/users.ts +52 -35
- package/src/resources/wallets/balance.ts +15 -5
- package/src/resources/wallets/index.ts +6 -2
- package/src/resources/wallets/transactions.ts +2 -2
- package/src/resources/wallets/wallets.ts +185 -31
- package/src/resources/webhooks.ts +1347 -0
- package/src/resources/yield.ts +389 -0
- package/src/types/x402.d.ts +18 -0
- package/src/version.ts +1 -1
- package/src/x402.ts +87 -0
- package/version.d.mts +1 -1
- package/version.d.mts.map +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
- package/x402.d.mts +54 -0
- package/x402.d.mts.map +1 -0
- package/x402.d.ts +54 -0
- package/x402.d.ts.map +1 -0
- package/x402.js +75 -0
- package/x402.js.map +1 -0
- package/x402.mjs +72 -0
- package/x402.mjs.map +1 -0
package/x402.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createX402Client = createX402Client;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const kit_1 = require("@solana/kit");
|
|
6
|
+
const fetch_1 = require("@x402/fetch");
|
|
7
|
+
const client_1 = require("@x402/evm/exact/client");
|
|
8
|
+
const client_2 = require("@x402/svm/exact/client");
|
|
9
|
+
const viem_2 = require("./viem.js");
|
|
10
|
+
const solana_kit_1 = require("./solana-kit.js");
|
|
11
|
+
/**
|
|
12
|
+
* Creates an x402 client configured with a Privy wallet for automatic payment handling.
|
|
13
|
+
*
|
|
14
|
+
* The returned client can be used with x402's `wrapFetchWithPayment` or `wrapAxiosWithPayment`
|
|
15
|
+
* to automatically handle HTTP 402 Payment Required responses.
|
|
16
|
+
*
|
|
17
|
+
* @experimental This API is experimental and may change in future versions.
|
|
18
|
+
*
|
|
19
|
+
* @param client - The Privy client instance
|
|
20
|
+
* @param input - Configuration for the x402 client
|
|
21
|
+
* @param input.walletId - ID of the Privy wallet to use for payments
|
|
22
|
+
* @param input.address - Address of the wallet
|
|
23
|
+
* @param input.authorizationContext - Authorization context for the wallet
|
|
24
|
+
* @returns A configured x402Client instance
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { PrivyClient } from '@privy-io/node';
|
|
29
|
+
* import { createX402Client } from '@privy-io/node/x402';
|
|
30
|
+
* import { wrapFetchWithPayment } from '@x402/fetch';
|
|
31
|
+
*
|
|
32
|
+
* const privyClient = new PrivyClient({ appId, appSecret });
|
|
33
|
+
*
|
|
34
|
+
* // Get wallet details
|
|
35
|
+
* const wallet = await privyClient.wallets().get('walletId');
|
|
36
|
+
*
|
|
37
|
+
* // Create x402 client
|
|
38
|
+
* const x402client = createX402Client(privyClient, {
|
|
39
|
+
* walletId: wallet.id,
|
|
40
|
+
* address: wallet.address,
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // Use with fetch
|
|
44
|
+
* const fetchWithPayment = wrapFetchWithPayment(fetch, x402client);
|
|
45
|
+
* const response = await fetchWithPayment('https://api.example.com/premium');
|
|
46
|
+
*
|
|
47
|
+
* // Or use with axios
|
|
48
|
+
* // import { wrapAxiosWithPayment } from '@x402/axios';
|
|
49
|
+
* // const axiosWithPayment = wrapAxiosWithPayment(axios, x402client);
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
function createX402Client(client, { walletId, address, authorizationContext }) {
|
|
53
|
+
const x402client = new fetch_1.x402Client();
|
|
54
|
+
if ((0, viem_1.isAddress)(address)) {
|
|
55
|
+
const evmSigner = (0, viem_2.createViemAccount)(client, {
|
|
56
|
+
walletId,
|
|
57
|
+
address: address,
|
|
58
|
+
...(authorizationContext ? { authorizationContext } : {}),
|
|
59
|
+
});
|
|
60
|
+
(0, client_1.registerExactEvmScheme)(x402client, { signer: evmSigner });
|
|
61
|
+
}
|
|
62
|
+
else if ((0, kit_1.isAddress)(address)) {
|
|
63
|
+
const solanaSigner = (0, solana_kit_1.createSolanaKitSigner)(client, {
|
|
64
|
+
walletId,
|
|
65
|
+
address: address,
|
|
66
|
+
...(authorizationContext ? { authorizationContext } : {}),
|
|
67
|
+
});
|
|
68
|
+
(0, client_2.registerExactSvmScheme)(x402client, { signer: solanaSigner });
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw new Error(`Invalid wallet address: ${address}. Address must be a valid EVM or Solana address.`);
|
|
72
|
+
}
|
|
73
|
+
return x402client;
|
|
74
|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B,OAAO,kDAAkD,CAAC,CAAC;IACxG,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
package/x402.mjs
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { isAddress as isEvmAddress } from 'viem';
|
|
2
|
+
import { isAddress as isSolanaAddress } from '@solana/kit';
|
|
3
|
+
import { x402Client } from '@x402/fetch';
|
|
4
|
+
import { registerExactEvmScheme } from '@x402/evm/exact/client';
|
|
5
|
+
import { registerExactSvmScheme } from '@x402/svm/exact/client';
|
|
6
|
+
import { createViemAccount } from "./viem.mjs";
|
|
7
|
+
import { createSolanaKitSigner } from "./solana-kit.mjs";
|
|
8
|
+
/**
|
|
9
|
+
* Creates an x402 client configured with a Privy wallet for automatic payment handling.
|
|
10
|
+
*
|
|
11
|
+
* The returned client can be used with x402's `wrapFetchWithPayment` or `wrapAxiosWithPayment`
|
|
12
|
+
* to automatically handle HTTP 402 Payment Required responses.
|
|
13
|
+
*
|
|
14
|
+
* @experimental This API is experimental and may change in future versions.
|
|
15
|
+
*
|
|
16
|
+
* @param client - The Privy client instance
|
|
17
|
+
* @param input - Configuration for the x402 client
|
|
18
|
+
* @param input.walletId - ID of the Privy wallet to use for payments
|
|
19
|
+
* @param input.address - Address of the wallet
|
|
20
|
+
* @param input.authorizationContext - Authorization context for the wallet
|
|
21
|
+
* @returns A configured x402Client instance
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* import { PrivyClient } from '@privy-io/node';
|
|
26
|
+
* import { createX402Client } from '@privy-io/node/x402';
|
|
27
|
+
* import { wrapFetchWithPayment } from '@x402/fetch';
|
|
28
|
+
*
|
|
29
|
+
* const privyClient = new PrivyClient({ appId, appSecret });
|
|
30
|
+
*
|
|
31
|
+
* // Get wallet details
|
|
32
|
+
* const wallet = await privyClient.wallets().get('walletId');
|
|
33
|
+
*
|
|
34
|
+
* // Create x402 client
|
|
35
|
+
* const x402client = createX402Client(privyClient, {
|
|
36
|
+
* walletId: wallet.id,
|
|
37
|
+
* address: wallet.address,
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* // Use with fetch
|
|
41
|
+
* const fetchWithPayment = wrapFetchWithPayment(fetch, x402client);
|
|
42
|
+
* const response = await fetchWithPayment('https://api.example.com/premium');
|
|
43
|
+
*
|
|
44
|
+
* // Or use with axios
|
|
45
|
+
* // import { wrapAxiosWithPayment } from '@x402/axios';
|
|
46
|
+
* // const axiosWithPayment = wrapAxiosWithPayment(axios, x402client);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function createX402Client(client, { walletId, address, authorizationContext }) {
|
|
50
|
+
const x402client = new x402Client();
|
|
51
|
+
if (isEvmAddress(address)) {
|
|
52
|
+
const evmSigner = createViemAccount(client, {
|
|
53
|
+
walletId,
|
|
54
|
+
address: address,
|
|
55
|
+
...(authorizationContext ? { authorizationContext } : {}),
|
|
56
|
+
});
|
|
57
|
+
registerExactEvmScheme(x402client, { signer: evmSigner });
|
|
58
|
+
}
|
|
59
|
+
else if (isSolanaAddress(address)) {
|
|
60
|
+
const solanaSigner = createSolanaKitSigner(client, {
|
|
61
|
+
walletId,
|
|
62
|
+
address: address,
|
|
63
|
+
...(authorizationContext ? { authorizationContext } : {}),
|
|
64
|
+
});
|
|
65
|
+
registerExactSvmScheme(x402client, { signer: solanaSigner });
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
throw new Error(`Invalid wallet address: ${address}. Address must be a valid EVM or Solana address.`);
|
|
69
|
+
}
|
|
70
|
+
return x402client;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=x402.mjs.map
|
package/x402.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"x402.mjs","sourceRoot":"","sources":["src/x402.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,IAAI,YAAY,EAAY,MAAM,MAAM;OACnD,EAAE,SAAS,IAAI,eAAe,EAAgB,MAAM,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