@bounded-sh/server 0.0.17 → 0.0.19
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/README.md +44 -65
- package/dist/auth/index.d.ts +0 -4
- package/dist/auth/providers/solana-keypair-provider.d.ts +6 -5
- package/dist/explicit-client-only.d.ts +28 -0
- package/dist/index.d.ts +6 -12
- package/dist/index.js +351 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +347 -153
- package/dist/index.mjs.map +1 -1
- package/dist/wallet-client.d.ts +4 -6
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -26,39 +26,29 @@ yarn add @tarobase/server
|
|
|
26
26
|
## Basic Usage
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
|
-
import { init,
|
|
30
|
-
import { Keypair } from '@solana/web3.js';
|
|
29
|
+
import { init, createWalletClient } from '@tarobase/server';
|
|
31
30
|
|
|
32
31
|
async function main() {
|
|
33
|
-
// Initialize
|
|
32
|
+
// Initialize endpoints/app config only. Server signing identity is explicit.
|
|
34
33
|
await init({
|
|
35
34
|
apiKey: 'your-api-key',
|
|
36
35
|
appId: 'your-app-id',
|
|
37
36
|
authMethod: 'solana-keypair'
|
|
38
37
|
});
|
|
39
38
|
|
|
40
|
-
// Create
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Log in with the keypair
|
|
45
|
-
const user = await login(keypair);
|
|
46
|
-
if (!user) {
|
|
47
|
-
console.error('Login failed');
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
console.log(`Logged in as: ${user.address}`);
|
|
39
|
+
// Create a wallet-scoped client from an explicit secret key.
|
|
40
|
+
const wallet = await createWalletClient({ keypair: process.env.SERVER_WALLET_KEYPAIR! });
|
|
41
|
+
console.log(`Using wallet: ${wallet.address}`);
|
|
52
42
|
|
|
53
43
|
// Set data
|
|
54
|
-
await set('todos/123', {
|
|
44
|
+
await wallet.set('todos/123', {
|
|
55
45
|
text: 'Buy milk',
|
|
56
46
|
completed: false,
|
|
57
47
|
created: new Date().toISOString()
|
|
58
48
|
});
|
|
59
49
|
|
|
60
50
|
// Get data
|
|
61
|
-
const todo = await get('todos/123');
|
|
51
|
+
const todo = await wallet.get('todos/123');
|
|
62
52
|
console.log('Retrieved todo:', todo);
|
|
63
53
|
}
|
|
64
54
|
|
|
@@ -70,44 +60,35 @@ main().catch(console.error);
|
|
|
70
60
|
### Loading a Keypair from a Secret Key File
|
|
71
61
|
|
|
72
62
|
```typescript
|
|
73
|
-
import { init,
|
|
74
|
-
import { Keypair } from '@solana/web3.js';
|
|
63
|
+
import { init, createWalletClient } from '@tarobase/server';
|
|
75
64
|
import * as fs from 'fs';
|
|
76
65
|
|
|
77
66
|
// Load keypair from file
|
|
78
67
|
const secretKeyString = fs.readFileSync('/path/to/keypair.json', 'utf8');
|
|
79
|
-
const secretKey = Uint8Array.from(JSON.parse(secretKeyString));
|
|
80
|
-
const keypair = Keypair.fromSecretKey(secretKey);
|
|
81
68
|
|
|
82
|
-
// Initialize and
|
|
69
|
+
// Initialize and create a wallet-scoped client
|
|
83
70
|
await init({ apiKey: 'your-api-key', appId: 'your-app-id' });
|
|
84
|
-
await
|
|
71
|
+
const wallet = await createWalletClient({ keypair: secretKeyString });
|
|
85
72
|
```
|
|
86
73
|
|
|
87
74
|
### Using the SolanaKeypairProvider Directly
|
|
88
75
|
|
|
89
76
|
```typescript
|
|
90
|
-
import { init, SolanaKeypairProvider
|
|
77
|
+
import { init, SolanaKeypairProvider } from '@tarobase/server';
|
|
91
78
|
import { Keypair } from '@solana/web3.js';
|
|
92
79
|
|
|
93
80
|
// Initialize the SDK
|
|
94
81
|
await init({
|
|
95
82
|
apiKey: 'your-api-key',
|
|
96
83
|
appId: 'your-app-id',
|
|
97
|
-
rpcUrl:
|
|
84
|
+
rpcUrl: process.env.SOLANA_MAINNET_RPC_URL
|
|
98
85
|
});
|
|
99
86
|
|
|
100
|
-
//
|
|
101
|
-
const provider =
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
// Set the keypair
|
|
107
|
-
provider.setKeypair(Keypair.generate());
|
|
108
|
-
|
|
109
|
-
// Login
|
|
110
|
-
const user = await provider.login();
|
|
87
|
+
// Create a provider instance directly with your RPC endpoint and keypair.
|
|
88
|
+
const provider = new SolanaKeypairProvider(
|
|
89
|
+
"https://your-solana-rpc.example",
|
|
90
|
+
Keypair.generate()
|
|
91
|
+
);
|
|
111
92
|
|
|
112
93
|
// Sign a message
|
|
113
94
|
const signature = await provider.signMessage("Hello, world!");
|
|
@@ -115,6 +96,7 @@ const signature = await provider.signMessage("Hello, world!");
|
|
|
115
96
|
// Run a transaction (example)
|
|
116
97
|
const txResult = await provider.runTransaction(undefined, {
|
|
117
98
|
appId: 'your-app-id',
|
|
99
|
+
network: 'solana_mainnet',
|
|
118
100
|
txArgs: [{
|
|
119
101
|
setDocumentData: [{ path: 'todos/123', data: { text: 'New todo' } }],
|
|
120
102
|
deletePaths: [],
|
|
@@ -127,22 +109,19 @@ const txResult = await provider.runTransaction(undefined, {
|
|
|
127
109
|
### Subscriptions
|
|
128
110
|
|
|
129
111
|
```typescript
|
|
130
|
-
import { init,
|
|
131
|
-
import { Keypair } from '@solana/web3.js';
|
|
112
|
+
import { init, createWalletClient } from '@tarobase/server';
|
|
132
113
|
|
|
133
|
-
// Initialize and
|
|
114
|
+
// Initialize and create an explicit wallet client
|
|
134
115
|
await init({ apiKey: 'your-api-key', appId: 'your-app-id' });
|
|
135
|
-
await
|
|
116
|
+
const wallet = await createWalletClient({ keypair: process.env.SERVER_WALLET_KEYPAIR! });
|
|
136
117
|
|
|
137
118
|
// Subscribe to changes
|
|
138
|
-
const unsubscribeFunc = await subscribe('todos', (data) => {
|
|
119
|
+
const unsubscribeFunc = await wallet.subscribe('todos', (data) => {
|
|
139
120
|
console.log('Todos updated:', data);
|
|
140
121
|
});
|
|
141
122
|
|
|
142
123
|
// Later, unsubscribe when done
|
|
143
|
-
unsubscribeFunc();
|
|
144
|
-
// Or use the unsubscribe function
|
|
145
|
-
await unsubscribe('todos');
|
|
124
|
+
await unsubscribeFunc();
|
|
146
125
|
```
|
|
147
126
|
|
|
148
127
|
## API Reference
|
|
@@ -152,48 +131,44 @@ await unsubscribe('todos');
|
|
|
152
131
|
```typescript
|
|
153
132
|
function init(config: Partial<ClientConfig>): Promise<void>;
|
|
154
133
|
function getConfig(): Promise<ClientConfig>;
|
|
155
|
-
function
|
|
156
|
-
function isInitialized(): boolean;
|
|
157
|
-
function waitForInitialization(): Promise<void>;
|
|
134
|
+
function getWebhookKeysUrl(): string | undefined;
|
|
158
135
|
```
|
|
159
136
|
|
|
160
137
|
### Authentication
|
|
161
138
|
|
|
162
139
|
```typescript
|
|
163
|
-
function
|
|
164
|
-
function
|
|
165
|
-
function
|
|
166
|
-
function getAuthProvider(): Promise<AuthProvider>;
|
|
167
|
-
function getIdToken(): Promise<string | null>;
|
|
140
|
+
function createWalletClient(options: { keypair: string }): Promise<WalletClient>;
|
|
141
|
+
function getAuthProvider(): Promise<AuthProvider>; // always rejects; no process-global provider
|
|
142
|
+
function getIdToken(): Promise<string | null>; // always rejects; no process-global session
|
|
168
143
|
```
|
|
169
144
|
|
|
170
145
|
### Data Operations
|
|
171
146
|
|
|
172
147
|
```typescript
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
148
|
+
const wallet = await createWalletClient({ keypair });
|
|
149
|
+
await wallet.get(path);
|
|
150
|
+
await wallet.getMany(paths);
|
|
151
|
+
await wallet.set(path, data);
|
|
152
|
+
await wallet.setMany(many);
|
|
153
|
+
await wallet.setFile(path, file);
|
|
154
|
+
await wallet.getFiles(path);
|
|
155
|
+
await wallet.runQuery(absolutePath, queryName, queryArgs);
|
|
156
|
+
await wallet.runQueryMany(many);
|
|
181
157
|
```
|
|
182
158
|
|
|
183
159
|
### Subscriptions
|
|
184
160
|
|
|
185
161
|
```typescript
|
|
186
|
-
|
|
187
|
-
|
|
162
|
+
const unsubscribe = await wallet.subscribe(path, callback);
|
|
163
|
+
await unsubscribe();
|
|
188
164
|
```
|
|
189
165
|
|
|
190
166
|
### Solana Keypair Provider
|
|
191
167
|
|
|
192
168
|
```typescript
|
|
193
169
|
class SolanaKeypairProvider implements AuthProvider {
|
|
194
|
-
constructor(
|
|
195
|
-
|
|
196
|
-
setKeypair(keypair: Keypair | string | Uint8Array): void;
|
|
170
|
+
constructor(rpcUrl: string | null, keypair: Keypair);
|
|
171
|
+
|
|
197
172
|
login(): Promise<User | null>;
|
|
198
173
|
logout(): Promise<void>;
|
|
199
174
|
signMessage(message: string): Promise<string>;
|
|
@@ -203,6 +178,10 @@ class SolanaKeypairProvider implements AuthProvider {
|
|
|
203
178
|
}
|
|
204
179
|
```
|
|
205
180
|
|
|
181
|
+
`runTransaction` requires an explicit provider `rpcUrl` plus `solTransactionData.network`
|
|
182
|
+
set to `solana_devnet`, `solana_mainnet`, or `surfnet`; missing RPCs and unknown/missing
|
|
183
|
+
networks fail closed.
|
|
184
|
+
|
|
206
185
|
## Types
|
|
207
186
|
|
|
208
187
|
```typescript
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { AuthProvider } from '@bounded-sh/core';
|
|
2
|
-
export declare const SOLANA_DEVNET_RPC_URL = "https://idelle-8nxsep-fast-devnet.helius-rpc.com";
|
|
3
|
-
export declare const SOLANA_MAINNET_RPC_URL = "https://celestia-cegncv-fast-mainnet.helius-rpc.com";
|
|
4
|
-
export declare const SURFNET_RPC_URL = "https://surfpool.fly.dev";
|
|
5
2
|
export declare function getAuthProvider(): Promise<AuthProvider>;
|
|
6
|
-
export declare function matchAuthProvider(rpcUrl: string | null): Promise<AuthProvider>;
|
|
@@ -2,10 +2,9 @@ import { Keypair, Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
|
2
2
|
import * as anchor from '@coral-xyz/anchor';
|
|
3
3
|
import type { AuthProvider, EVMTransaction, SolTransaction, TransactionResult, User, SetOptions } from '@bounded-sh/core';
|
|
4
4
|
export declare class SolanaKeypairProvider implements AuthProvider {
|
|
5
|
-
private readonly
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
constructor(networkUrl?: string | null, keypair?: Keypair);
|
|
5
|
+
private readonly rpcUrl;
|
|
6
|
+
private readonly serverKeypair;
|
|
7
|
+
constructor(rpcUrl: string | null, serverKeypair: Keypair);
|
|
9
8
|
private get keypair();
|
|
10
9
|
login(): Promise<User | null>;
|
|
11
10
|
restoreSession(): Promise<User | null>;
|
|
@@ -17,7 +16,8 @@ export declare class SolanaKeypairProvider implements AuthProvider {
|
|
|
17
16
|
*
|
|
18
17
|
* This method handles blockhash and transaction confirmation automatically - you do NOT need to
|
|
19
18
|
* set recentBlockhash or lastValidBlockHeight on the transaction before calling this method.
|
|
20
|
-
*
|
|
19
|
+
* Requires an explicit RPC URL configured on the provider because this method has no
|
|
20
|
+
* Solana transaction payload network to resolve.
|
|
21
21
|
*
|
|
22
22
|
* @param transaction - The transaction to sign and submit (Transaction or VersionedTransaction)
|
|
23
23
|
* @param feePayer - Optional fee payer public key. If not provided and the transaction doesn't
|
|
@@ -31,6 +31,7 @@ export declare class SolanaKeypairProvider implements AuthProvider {
|
|
|
31
31
|
* Shared by both signAndSubmitTransaction and runTransactionInner.
|
|
32
32
|
*/
|
|
33
33
|
private submitAndConfirmTransaction;
|
|
34
|
+
private requireSupportedNetwork;
|
|
34
35
|
private getRpcUrl;
|
|
35
36
|
runTransaction(_evm?: EVMTransaction, sol?: SolTransaction, opts?: SetOptions): Promise<TransactionResult>;
|
|
36
37
|
private runTransactionInner;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare function get(..._args: unknown[]): Promise<never>;
|
|
2
|
+
export declare function getMany(..._args: unknown[]): Promise<never>;
|
|
3
|
+
export declare function set(..._args: unknown[]): Promise<never>;
|
|
4
|
+
export declare function setMany(..._args: unknown[]): Promise<never>;
|
|
5
|
+
export declare function setFile(..._args: unknown[]): Promise<never>;
|
|
6
|
+
export declare function getFiles(..._args: unknown[]): Promise<never>;
|
|
7
|
+
export declare function search(..._args: unknown[]): Promise<never>;
|
|
8
|
+
export declare function queryAggregate(..._args: unknown[]): Promise<never>;
|
|
9
|
+
export declare function runQuery(..._args: unknown[]): Promise<never>;
|
|
10
|
+
export declare function runQueryMany(..._args: unknown[]): Promise<never>;
|
|
11
|
+
export declare function runExpression(..._args: unknown[]): Promise<never>;
|
|
12
|
+
export declare function runExpressionMany(..._args: unknown[]): Promise<never>;
|
|
13
|
+
export declare function signMessage(..._args: unknown[]): Promise<never>;
|
|
14
|
+
export declare function signTransaction(..._args: unknown[]): Promise<never>;
|
|
15
|
+
export declare function signAndSubmitTransaction(..._args: unknown[]): Promise<never>;
|
|
16
|
+
export declare function count(..._args: unknown[]): Promise<never>;
|
|
17
|
+
export declare function aggregate(..._args: unknown[]): Promise<never>;
|
|
18
|
+
export declare function subscribe(..._args: unknown[]): Promise<never>;
|
|
19
|
+
export declare function invokeFunction(..._args: unknown[]): Promise<never>;
|
|
20
|
+
export declare function liveIntent(..._args: unknown[]): Promise<never>;
|
|
21
|
+
export declare function liveStatus(..._args: unknown[]): Promise<never>;
|
|
22
|
+
export declare const functions: {
|
|
23
|
+
invoke: (..._args: unknown[]) => Promise<never>;
|
|
24
|
+
};
|
|
25
|
+
export declare const live: {
|
|
26
|
+
intent: (..._args: unknown[]) => Promise<never>;
|
|
27
|
+
status: (..._args: unknown[]) => Promise<never>;
|
|
28
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
export { init } from
|
|
2
|
-
export { getConfig } from '@bounded-sh/core';
|
|
1
|
+
export { init } from './global';
|
|
2
|
+
export { getConfig, getWebhookKeysUrl, InsufficientBalanceError, FunctionInvokeError, LiveIntentError } from '@bounded-sh/core';
|
|
3
3
|
export { getAuthProvider } from './auth';
|
|
4
|
-
export { get, getMany, set, setMany, setFile, getFiles, search, queryAggregate, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, signAndSubmitTransaction, count, aggregate,
|
|
5
|
-
export type { GetOptions, SearchOptions, SetOptions, CountOptions, AggregateOptions, AggregateOperation, AggregateResult, AggregateSpec, AggregateRow, QueryAggregateOptions, GetManyResult, RunExpressionOptions, RunExpressionResult, RequestOverrides, RunQueryOptions } from '@bounded-sh/core';
|
|
6
|
-
export { subscribe } from '@bounded-sh/core';
|
|
7
|
-
export { functions, invokeFunction, FunctionInvokeError } from '@bounded-sh/core';
|
|
8
|
-
export type { InvokeOptions } from '@bounded-sh/core';
|
|
9
|
-
export { live, liveIntent, liveStatus, LiveIntentError } from '@bounded-sh/core';
|
|
10
|
-
export type { LiveIntentOptions, LiveStatus, LiveStatusOptions } from '@bounded-sh/core';
|
|
11
|
-
export * from '@bounded-sh/core';
|
|
4
|
+
export { get, getMany, set, setMany, setFile, getFiles, search, queryAggregate, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, signAndSubmitTransaction, count, aggregate, subscribe, functions, invokeFunction, live, liveIntent, liveStatus, } from './explicit-client-only';
|
|
5
|
+
export type { AuthProvider, ClientConfig, User, GetOptions, SearchOptions, SetOptions, CountOptions, AggregateOptions, AggregateOperation, AggregateResult, AggregateSpec, AggregateRow, QueryAggregateOptions, GetManyResult, RunExpressionOptions, RunExpressionResult, RequestOverrides, RunQueryOptions, InvokeOptions, LiveIntentOptions, LiveStatus, LiveStatusOptions, } from '@bounded-sh/core';
|
|
12
6
|
export { getIdToken } from './utils';
|
|
13
7
|
export { createWalletClient, WalletClient } from './wallet-client';
|
|
14
8
|
export type { CreateWalletClientOptions } from './wallet-client';
|
|
15
|
-
export { verifyWebhook, clearWebhookKeyCache, clearWebhookReplayCache, WebhookVerificationError, DEFAULT_WEBHOOK_KEYS_URL, InMemoryReplayStore } from './webhooks';
|
|
16
|
-
export type { WebhookPayload, WebhookPublicKey, WebhookOperation, VerifyWebhookOptions, WebhookHeaders, WebhookReplayStore } from './webhooks';
|
|
9
|
+
export { verifyWebhook, clearWebhookKeyCache, clearWebhookReplayCache, WebhookVerificationError, DEFAULT_WEBHOOK_KEYS_URL, InMemoryReplayStore, } from './webhooks';
|
|
10
|
+
export type { WebhookPayload, WebhookPublicKey, WebhookOperation, VerifyWebhookOptions, WebhookHeaders, WebhookReplayStore, } from './webhooks';
|