@privy-io/node 0.6.2 → 0.8.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 +59 -0
- package/client.d.mts +10 -7
- package/client.d.mts.map +1 -1
- package/client.d.ts +10 -7
- package/client.d.ts.map +1 -1
- package/client.js +3 -0
- package/client.js.map +1 -1
- package/client.mjs +3 -0
- package/client.mjs.map +1 -1
- package/index.d.mts +2 -1
- package/index.d.mts.map +1 -1
- package/index.d.ts +2 -1
- package/index.d.ts.map +1 -1
- package/index.js +4 -1
- package/index.js.map +1 -1
- package/index.mjs +2 -1
- package/index.mjs.map +1 -1
- package/lib/auth.d.mts +30 -2
- package/lib/auth.d.mts.map +1 -1
- package/lib/auth.d.ts +30 -2
- package/lib/auth.d.ts.map +1 -1
- package/lib/auth.js +14 -5
- package/lib/auth.js.map +1 -1
- package/lib/auth.mjs +11 -3
- package/lib/auth.mjs.map +1 -1
- package/lib/cryptography.d.mts +35 -3
- package/lib/cryptography.d.mts.map +1 -1
- package/lib/cryptography.d.ts +35 -3
- package/lib/cryptography.d.ts.map +1 -1
- package/lib/cryptography.js +53 -6
- package/lib/cryptography.js.map +1 -1
- package/lib/cryptography.mjs +50 -3
- package/lib/cryptography.mjs.map +1 -1
- package/lib/identity-token.d.mts.map +1 -1
- package/lib/identity-token.d.ts.map +1 -1
- package/lib/identity-token.js +0 -1
- package/lib/identity-token.js.map +1 -1
- package/lib/identity-token.mjs +0 -1
- package/lib/identity-token.mjs.map +1 -1
- package/package.json +13 -1
- package/public-api/services/utils/auth.d.mts +10 -1
- package/public-api/services/utils/auth.d.mts.map +1 -1
- package/public-api/services/utils/auth.d.ts +10 -1
- package/public-api/services/utils/auth.d.ts.map +1 -1
- package/public-api/services/utils/auth.js +16 -5
- package/public-api/services/utils/auth.js.map +1 -1
- package/public-api/services/utils/auth.mjs +17 -6
- package/public-api/services/utils/auth.mjs.map +1 -1
- package/resources/aggregations.d.mts +296 -0
- package/resources/aggregations.d.mts.map +1 -0
- package/resources/aggregations.d.ts +296 -0
- package/resources/aggregations.d.ts.map +1 -0
- package/resources/aggregations.js +9 -0
- package/resources/aggregations.js.map +1 -0
- package/resources/aggregations.mjs +5 -0
- package/resources/aggregations.mjs.map +1 -0
- package/resources/apps.d.mts +25 -0
- package/resources/apps.d.mts.map +1 -1
- package/resources/apps.d.ts +25 -0
- package/resources/apps.d.ts.map +1 -1
- package/resources/index.d.mts +4 -3
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +4 -3
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -0
- package/resources/index.mjs.map +1 -1
- package/resources/key-quorums.d.mts +4 -1
- package/resources/key-quorums.d.mts.map +1 -1
- package/resources/key-quorums.d.ts +4 -1
- package/resources/key-quorums.d.ts.map +1 -1
- package/resources/policies.d.mts +87 -131
- package/resources/policies.d.mts.map +1 -1
- package/resources/policies.d.ts +87 -131
- package/resources/policies.d.ts.map +1 -1
- package/resources/policies.js.map +1 -1
- package/resources/policies.mjs.map +1 -1
- package/resources/users.d.mts +642 -381
- package/resources/users.d.mts.map +1 -1
- package/resources/users.d.ts +642 -381
- package/resources/users.d.ts.map +1 -1
- package/resources/wallets/balance.d.mts +3 -3
- package/resources/wallets/balance.d.mts.map +1 -1
- package/resources/wallets/balance.d.ts +3 -3
- package/resources/wallets/balance.d.ts.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 +3 -3
- package/resources/wallets/transactions.d.mts.map +1 -1
- package/resources/wallets/transactions.d.ts +3 -3
- package/resources/wallets/transactions.d.ts.map +1 -1
- package/resources/wallets/wallets.d.mts +215 -53
- package/resources/wallets/wallets.d.mts.map +1 -1
- package/resources/wallets/wallets.d.ts +215 -53
- package/resources/wallets/wallets.d.ts.map +1 -1
- package/resources/wallets/wallets.js +1 -1
- package/resources/wallets/wallets.js.map +1 -1
- package/resources/wallets/wallets.mjs +1 -1
- package/resources/wallets/wallets.mjs.map +1 -1
- package/solana-kit.d.mts +53 -0
- package/solana-kit.d.mts.map +1 -0
- package/solana-kit.d.ts +53 -0
- package/solana-kit.d.ts.map +1 -0
- package/solana-kit.js +92 -0
- package/solana-kit.js.map +1 -0
- package/solana-kit.mjs +89 -0
- package/solana-kit.mjs.map +1 -0
- package/src/client.ts +150 -3
- package/src/index.ts +5 -0
- package/src/lib/auth.ts +42 -6
- package/src/lib/cryptography.ts +72 -3
- package/src/lib/identity-token.ts +38 -18
- package/src/public-api/services/utils/auth.ts +19 -6
- package/src/resources/aggregations.ts +497 -0
- package/src/resources/apps.ts +44 -0
- package/src/resources/index.ts +74 -2
- package/src/resources/key-quorums.ts +4 -1
- package/src/resources/policies.ts +124 -207
- package/src/resources/users.ts +942 -625
- package/src/resources/wallets/balance.ts +11 -3
- package/src/resources/wallets/index.ts +6 -0
- package/src/resources/wallets/transactions.ts +11 -3
- package/src/resources/wallets/wallets.ts +283 -52
- package/src/solana-kit.ts +148 -0
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -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.
|
|
1
|
+
export const VERSION = '0.8.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.8.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.8.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.8.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|