@bounded-sh/server 0.0.18 → 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 +38 -64
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/providers/solana-keypair-provider.d.ts +2 -3
- package/dist/explicit-client-only.d.ts +28 -0
- package/dist/index.d.ts +6 -12
- package/dist/index.js +82 -180
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -106
- package/dist/index.mjs.map +1 -1
- package/dist/wallet-client.d.ts +4 -6
- package/package.json +3 -3
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,24 +60,21 @@ 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
|
|
@@ -97,17 +84,11 @@ await init({
|
|
|
97
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!");
|
|
@@ -128,22 +109,19 @@ const txResult = await provider.runTransaction(undefined, {
|
|
|
128
109
|
### Subscriptions
|
|
129
110
|
|
|
130
111
|
```typescript
|
|
131
|
-
import { init,
|
|
132
|
-
import { Keypair } from '@solana/web3.js';
|
|
112
|
+
import { init, createWalletClient } from '@tarobase/server';
|
|
133
113
|
|
|
134
|
-
// Initialize and
|
|
114
|
+
// Initialize and create an explicit wallet client
|
|
135
115
|
await init({ apiKey: 'your-api-key', appId: 'your-app-id' });
|
|
136
|
-
await
|
|
116
|
+
const wallet = await createWalletClient({ keypair: process.env.SERVER_WALLET_KEYPAIR! });
|
|
137
117
|
|
|
138
118
|
// Subscribe to changes
|
|
139
|
-
const unsubscribeFunc = await subscribe('todos', (data) => {
|
|
119
|
+
const unsubscribeFunc = await wallet.subscribe('todos', (data) => {
|
|
140
120
|
console.log('Todos updated:', data);
|
|
141
121
|
});
|
|
142
122
|
|
|
143
123
|
// Later, unsubscribe when done
|
|
144
|
-
unsubscribeFunc();
|
|
145
|
-
// Or use the unsubscribe function
|
|
146
|
-
await unsubscribe('todos');
|
|
124
|
+
await unsubscribeFunc();
|
|
147
125
|
```
|
|
148
126
|
|
|
149
127
|
## API Reference
|
|
@@ -153,48 +131,44 @@ await unsubscribe('todos');
|
|
|
153
131
|
```typescript
|
|
154
132
|
function init(config: Partial<ClientConfig>): Promise<void>;
|
|
155
133
|
function getConfig(): Promise<ClientConfig>;
|
|
156
|
-
function
|
|
157
|
-
function isInitialized(): boolean;
|
|
158
|
-
function waitForInitialization(): Promise<void>;
|
|
134
|
+
function getWebhookKeysUrl(): string | undefined;
|
|
159
135
|
```
|
|
160
136
|
|
|
161
137
|
### Authentication
|
|
162
138
|
|
|
163
139
|
```typescript
|
|
164
|
-
function
|
|
165
|
-
function
|
|
166
|
-
function
|
|
167
|
-
function getAuthProvider(): Promise<AuthProvider>;
|
|
168
|
-
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
|
|
169
143
|
```
|
|
170
144
|
|
|
171
145
|
### Data Operations
|
|
172
146
|
|
|
173
147
|
```typescript
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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);
|
|
182
157
|
```
|
|
183
158
|
|
|
184
159
|
### Subscriptions
|
|
185
160
|
|
|
186
161
|
```typescript
|
|
187
|
-
|
|
188
|
-
|
|
162
|
+
const unsubscribe = await wallet.subscribe(path, callback);
|
|
163
|
+
await unsubscribe();
|
|
189
164
|
```
|
|
190
165
|
|
|
191
166
|
### Solana Keypair Provider
|
|
192
167
|
|
|
193
168
|
```typescript
|
|
194
169
|
class SolanaKeypairProvider implements AuthProvider {
|
|
195
|
-
constructor(rpcUrl
|
|
196
|
-
|
|
197
|
-
setKeypair(keypair: Keypair | string | Uint8Array): void;
|
|
170
|
+
constructor(rpcUrl: string | null, keypair: Keypair);
|
|
171
|
+
|
|
198
172
|
login(): Promise<User | null>;
|
|
199
173
|
logout(): Promise<void>;
|
|
200
174
|
signMessage(message: string): Promise<string>;
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -3,9 +3,8 @@ 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
5
|
private readonly rpcUrl;
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
constructor(rpcUrl?: string | null, keypair?: Keypair);
|
|
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>;
|
|
@@ -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';
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@bounded-sh/core');
|
|
4
|
-
var buffer = require('buffer');
|
|
5
4
|
var web3_js = require('@solana/web3.js');
|
|
5
|
+
var bs58 = require('bs58');
|
|
6
|
+
var buffer = require('buffer');
|
|
6
7
|
var anchor = require('@coral-xyz/anchor');
|
|
7
8
|
var nacl = require('tweetnacl');
|
|
8
|
-
var bs58 = require('bs58');
|
|
9
9
|
var crypto = require('crypto');
|
|
10
10
|
|
|
11
11
|
function _interopNamespaceDefault(e) {
|
|
@@ -28,14 +28,51 @@ function _interopNamespaceDefault(e) {
|
|
|
28
28
|
var anchor__namespace = /*#__PURE__*/_interopNamespaceDefault(anchor);
|
|
29
29
|
var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
async function init(newConfig) {
|
|
32
|
+
await core.init(Object.assign(Object.assign({}, newConfig), { authProvider: null, isServer: true, skipBackendInit: true }));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function getAuthProvider() {
|
|
36
|
+
throw new Error('Server auth providers are not process-global. Use createWalletClient({ keypair }) and call that client\'s methods.');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function explicitClientOnly(name) {
|
|
40
|
+
throw new Error(`${name} is not available as a tarobase-server top-level auth operation. ` +
|
|
41
|
+
'Use createWalletClient({ keypair }) and call the returned client method.');
|
|
42
|
+
}
|
|
43
|
+
async function get(..._args) { explicitClientOnly('get'); }
|
|
44
|
+
async function getMany(..._args) { explicitClientOnly('getMany'); }
|
|
45
|
+
async function set(..._args) { explicitClientOnly('set'); }
|
|
46
|
+
async function setMany(..._args) { explicitClientOnly('setMany'); }
|
|
47
|
+
async function setFile(..._args) { explicitClientOnly('setFile'); }
|
|
48
|
+
async function getFiles(..._args) { explicitClientOnly('getFiles'); }
|
|
49
|
+
async function search(..._args) { explicitClientOnly('search'); }
|
|
50
|
+
async function queryAggregate(..._args) { explicitClientOnly('queryAggregate'); }
|
|
51
|
+
async function runQuery(..._args) { explicitClientOnly('runQuery'); }
|
|
52
|
+
async function runQueryMany(..._args) { explicitClientOnly('runQueryMany'); }
|
|
53
|
+
async function runExpression(..._args) { explicitClientOnly('runExpression'); }
|
|
54
|
+
async function runExpressionMany(..._args) { explicitClientOnly('runExpressionMany'); }
|
|
55
|
+
async function signMessage(..._args) { explicitClientOnly('signMessage'); }
|
|
56
|
+
async function signTransaction(..._args) { explicitClientOnly('signTransaction'); }
|
|
57
|
+
async function signAndSubmitTransaction(..._args) { explicitClientOnly('signAndSubmitTransaction'); }
|
|
58
|
+
async function count(..._args) { explicitClientOnly('count'); }
|
|
59
|
+
async function aggregate(..._args) { explicitClientOnly('aggregate'); }
|
|
60
|
+
async function subscribe(..._args) { explicitClientOnly('subscribe'); }
|
|
61
|
+
async function invokeFunction(..._args) { explicitClientOnly('invokeFunction'); }
|
|
62
|
+
async function liveIntent(..._args) { explicitClientOnly('liveIntent'); }
|
|
63
|
+
async function liveStatus(..._args) { explicitClientOnly('liveStatus'); }
|
|
64
|
+
const functions = {
|
|
65
|
+
invoke: async (..._args) => explicitClientOnly('functions.invoke'),
|
|
66
|
+
};
|
|
67
|
+
const live = {
|
|
68
|
+
intent: async (..._args) => explicitClientOnly('live.intent'),
|
|
69
|
+
status: async (..._args) => explicitClientOnly('live.status'),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
async function getIdToken() {
|
|
73
|
+
throw new Error('getIdToken is not available as a tarobase-server top-level auth operation. Use createWalletClient({ keypair }) and call the returned client methods.');
|
|
74
|
+
}
|
|
75
|
+
|
|
39
76
|
const PRESIGNED_BLOCKHASH_ERROR = 'Server signedTransaction blockhash is stale or expired';
|
|
40
77
|
const BOUNDED_PROGRAM_MAINNET = 'poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZp';
|
|
41
78
|
const BOUNDED_PROGRAM_DEVNET = 'taro6CvKqwrYrDc16ufYgzQ2NZcyyVKStffbtudrhRu';
|
|
@@ -55,32 +92,6 @@ const ALLOWED_BOUNDED_SET_DISCRIMINATORS = new Set([
|
|
|
55
92
|
SET_DOCUMENTS_DISCRIMINATOR,
|
|
56
93
|
SET_DOCUMENTS_V2_DISCRIMINATOR,
|
|
57
94
|
]);
|
|
58
|
-
function loadKeypairFromEnv() {
|
|
59
|
-
var _a;
|
|
60
|
-
let secret;
|
|
61
|
-
let found;
|
|
62
|
-
for (const name of ENV_VARS) {
|
|
63
|
-
const v = (_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a[name];
|
|
64
|
-
if (v) {
|
|
65
|
-
secret = v;
|
|
66
|
-
found = name;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
if (!secret) {
|
|
71
|
-
throw new Error(`No server keypair: set ${ENV_VARS[0]} to a base58 secret key (or JSON array), ` +
|
|
72
|
-
`or pass one explicitly via createWalletClient({ keypair }).`);
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const secretKey = secret.trim().startsWith('[')
|
|
76
|
-
? Uint8Array.from(JSON.parse(secret))
|
|
77
|
-
: bs58.decode(secret.trim());
|
|
78
|
-
return web3_js.Keypair.fromSecretKey(secretKey);
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
throw new Error(`Unable to parse ${found}. Ensure it is valid base58 or a JSON array.`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
95
|
/* ──────────────────────────────────────────────────────────
|
|
85
96
|
* Helper – fetch getPriorityFeeEstimate
|
|
86
97
|
* ──────────────────────────────────────────────────────── */
|
|
@@ -309,13 +320,15 @@ function assertAllowedServerPreInstructions(preInstructions) {
|
|
|
309
320
|
}
|
|
310
321
|
}
|
|
311
322
|
class SolanaKeypairProvider {
|
|
312
|
-
constructor(rpcUrl
|
|
323
|
+
constructor(rpcUrl, serverKeypair) {
|
|
313
324
|
this.rpcUrl = rpcUrl;
|
|
314
|
-
this.
|
|
325
|
+
this.serverKeypair = serverKeypair;
|
|
315
326
|
}
|
|
316
327
|
get keypair() {
|
|
317
|
-
|
|
318
|
-
|
|
328
|
+
if (!this.serverKeypair) {
|
|
329
|
+
throw new Error('Server keypair is required; use createWalletClient({ keypair }) or pass a Keypair to SolanaKeypairProvider.');
|
|
330
|
+
}
|
|
331
|
+
return this.serverKeypair;
|
|
319
332
|
}
|
|
320
333
|
/* ----------------------------------------------------------- *
|
|
321
334
|
* (Auth stubs – fill in later if needed)
|
|
@@ -676,44 +689,6 @@ class OffchainAuthProvider {
|
|
|
676
689
|
}
|
|
677
690
|
}
|
|
678
691
|
|
|
679
|
-
let currentAuthProvider = null;
|
|
680
|
-
async function getAuthProvider() {
|
|
681
|
-
var _a;
|
|
682
|
-
const config = await core.getConfig();
|
|
683
|
-
if (currentAuthProvider) {
|
|
684
|
-
// If provider exists but chain is "offchain" and it's not already wrapped, rewrap it
|
|
685
|
-
if (config.chain === "offchain" && !(currentAuthProvider instanceof OffchainAuthProvider)) {
|
|
686
|
-
currentAuthProvider = new OffchainAuthProvider(currentAuthProvider);
|
|
687
|
-
}
|
|
688
|
-
return currentAuthProvider;
|
|
689
|
-
}
|
|
690
|
-
currentAuthProvider = await matchAuthProvider((_a = config.rpcUrl) !== null && _a !== void 0 ? _a : null);
|
|
691
|
-
// Wrap with OffchainAuthProvider for offchain chain
|
|
692
|
-
if (config.chain === "offchain") {
|
|
693
|
-
currentAuthProvider = new OffchainAuthProvider(currentAuthProvider);
|
|
694
|
-
}
|
|
695
|
-
return currentAuthProvider;
|
|
696
|
-
}
|
|
697
|
-
async function matchAuthProvider(rpcUrl) {
|
|
698
|
-
return new SolanaKeypairProvider(rpcUrl);
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
let authProviderInstance = null;
|
|
702
|
-
async function init(newConfig) {
|
|
703
|
-
// Initialize config first so getAuthProvider can access it
|
|
704
|
-
// Server-side skips backend init since it already has all needed config
|
|
705
|
-
await core.init(Object.assign(Object.assign({}, newConfig), { isServer: true, skipBackendInit: true }));
|
|
706
|
-
// Get the auth provider (which will wrap it if chain is "offchain")
|
|
707
|
-
authProviderInstance = await getAuthProvider();
|
|
708
|
-
// Update config with the wrapped provider
|
|
709
|
-
await core.init(Object.assign(Object.assign({}, newConfig), { authProvider: authProviderInstance, isServer: true, skipBackendInit: true }));
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
// Wrapper for getIdToken - passes isServer=true for server-side usage
|
|
713
|
-
async function getIdToken() {
|
|
714
|
-
return core.getIdToken(true);
|
|
715
|
-
}
|
|
716
|
-
|
|
717
692
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
718
693
|
var t = {};
|
|
719
694
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -863,8 +838,7 @@ class WalletClient {
|
|
|
863
838
|
return core.queryAggregate(path, spec, Object.assign(Object.assign({}, opts), { _overrides: this.mergeReadOverrides(opts === null || opts === void 0 ? void 0 : opts._overrides) }));
|
|
864
839
|
}
|
|
865
840
|
/**
|
|
866
|
-
* Subscribe to real-time updates as THIS wallet's identity.
|
|
867
|
-
* `subscribe`, this needs no `BOUNDED_PRIVATE_KEY` env var — the WS connection
|
|
841
|
+
* Subscribe to real-time updates as THIS wallet's identity. The WS connection
|
|
868
842
|
* authenticates with the wallet's own session (so read rules see the right
|
|
869
843
|
* principal), and is scoped to its own connection so it never crosses another
|
|
870
844
|
* identity. Accepts a bare callback or `{ onData, onError, filter, ... }`.
|
|
@@ -880,10 +854,9 @@ class WalletClient {
|
|
|
880
854
|
} }));
|
|
881
855
|
}
|
|
882
856
|
/**
|
|
883
|
-
* Invoke a deployed Bounded Function AS this wallet's identity.
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
* rule + `ctx.user` reflect this client. Returns the function's JSON; throws
|
|
857
|
+
* Invoke a deployed Bounded Function AS this wallet's identity. The dispatcher
|
|
858
|
+
* sees the wallet's verified session, so the function's `auth` rule +
|
|
859
|
+
* `ctx.user` reflect this client. Returns the function's JSON; throws
|
|
887
860
|
* `FunctionInvokeError` on 401/403/404/503.
|
|
888
861
|
*/
|
|
889
862
|
async invoke(name, args = {}, opts = {}) {
|
|
@@ -1191,117 +1164,46 @@ Object.defineProperty(exports, "LiveIntentError", {
|
|
|
1191
1164
|
enumerable: true,
|
|
1192
1165
|
get: function () { return core.LiveIntentError; }
|
|
1193
1166
|
});
|
|
1194
|
-
Object.defineProperty(exports, "aggregate", {
|
|
1195
|
-
enumerable: true,
|
|
1196
|
-
get: function () { return core.aggregate; }
|
|
1197
|
-
});
|
|
1198
|
-
Object.defineProperty(exports, "count", {
|
|
1199
|
-
enumerable: true,
|
|
1200
|
-
get: function () { return core.count; }
|
|
1201
|
-
});
|
|
1202
|
-
Object.defineProperty(exports, "functions", {
|
|
1203
|
-
enumerable: true,
|
|
1204
|
-
get: function () { return core.functions; }
|
|
1205
|
-
});
|
|
1206
|
-
Object.defineProperty(exports, "get", {
|
|
1207
|
-
enumerable: true,
|
|
1208
|
-
get: function () { return core.get; }
|
|
1209
|
-
});
|
|
1210
1167
|
Object.defineProperty(exports, "getConfig", {
|
|
1211
1168
|
enumerable: true,
|
|
1212
1169
|
get: function () { return core.getConfig; }
|
|
1213
1170
|
});
|
|
1214
|
-
Object.defineProperty(exports, "
|
|
1215
|
-
enumerable: true,
|
|
1216
|
-
get: function () { return core.getFiles; }
|
|
1217
|
-
});
|
|
1218
|
-
Object.defineProperty(exports, "getMany", {
|
|
1219
|
-
enumerable: true,
|
|
1220
|
-
get: function () { return core.getMany; }
|
|
1221
|
-
});
|
|
1222
|
-
Object.defineProperty(exports, "invokeFunction", {
|
|
1223
|
-
enumerable: true,
|
|
1224
|
-
get: function () { return core.invokeFunction; }
|
|
1225
|
-
});
|
|
1226
|
-
Object.defineProperty(exports, "live", {
|
|
1227
|
-
enumerable: true,
|
|
1228
|
-
get: function () { return core.live; }
|
|
1229
|
-
});
|
|
1230
|
-
Object.defineProperty(exports, "liveIntent", {
|
|
1231
|
-
enumerable: true,
|
|
1232
|
-
get: function () { return core.liveIntent; }
|
|
1233
|
-
});
|
|
1234
|
-
Object.defineProperty(exports, "liveStatus", {
|
|
1235
|
-
enumerable: true,
|
|
1236
|
-
get: function () { return core.liveStatus; }
|
|
1237
|
-
});
|
|
1238
|
-
Object.defineProperty(exports, "queryAggregate", {
|
|
1239
|
-
enumerable: true,
|
|
1240
|
-
get: function () { return core.queryAggregate; }
|
|
1241
|
-
});
|
|
1242
|
-
Object.defineProperty(exports, "runExpression", {
|
|
1243
|
-
enumerable: true,
|
|
1244
|
-
get: function () { return core.runExpression; }
|
|
1245
|
-
});
|
|
1246
|
-
Object.defineProperty(exports, "runExpressionMany", {
|
|
1247
|
-
enumerable: true,
|
|
1248
|
-
get: function () { return core.runExpressionMany; }
|
|
1249
|
-
});
|
|
1250
|
-
Object.defineProperty(exports, "runQuery", {
|
|
1251
|
-
enumerable: true,
|
|
1252
|
-
get: function () { return core.runQuery; }
|
|
1253
|
-
});
|
|
1254
|
-
Object.defineProperty(exports, "runQueryMany", {
|
|
1255
|
-
enumerable: true,
|
|
1256
|
-
get: function () { return core.runQueryMany; }
|
|
1257
|
-
});
|
|
1258
|
-
Object.defineProperty(exports, "search", {
|
|
1259
|
-
enumerable: true,
|
|
1260
|
-
get: function () { return core.search; }
|
|
1261
|
-
});
|
|
1262
|
-
Object.defineProperty(exports, "set", {
|
|
1263
|
-
enumerable: true,
|
|
1264
|
-
get: function () { return core.set; }
|
|
1265
|
-
});
|
|
1266
|
-
Object.defineProperty(exports, "setFile", {
|
|
1171
|
+
Object.defineProperty(exports, "getWebhookKeysUrl", {
|
|
1267
1172
|
enumerable: true,
|
|
1268
|
-
get: function () { return core.
|
|
1269
|
-
});
|
|
1270
|
-
Object.defineProperty(exports, "setMany", {
|
|
1271
|
-
enumerable: true,
|
|
1272
|
-
get: function () { return core.setMany; }
|
|
1273
|
-
});
|
|
1274
|
-
Object.defineProperty(exports, "signAndSubmitTransaction", {
|
|
1275
|
-
enumerable: true,
|
|
1276
|
-
get: function () { return core.signAndSubmitTransaction; }
|
|
1277
|
-
});
|
|
1278
|
-
Object.defineProperty(exports, "signMessage", {
|
|
1279
|
-
enumerable: true,
|
|
1280
|
-
get: function () { return core.signMessage; }
|
|
1281
|
-
});
|
|
1282
|
-
Object.defineProperty(exports, "signTransaction", {
|
|
1283
|
-
enumerable: true,
|
|
1284
|
-
get: function () { return core.signTransaction; }
|
|
1285
|
-
});
|
|
1286
|
-
Object.defineProperty(exports, "subscribe", {
|
|
1287
|
-
enumerable: true,
|
|
1288
|
-
get: function () { return core.subscribe; }
|
|
1173
|
+
get: function () { return core.getWebhookKeysUrl; }
|
|
1289
1174
|
});
|
|
1290
1175
|
exports.DEFAULT_WEBHOOK_KEYS_URL = DEFAULT_WEBHOOK_KEYS_URL;
|
|
1291
1176
|
exports.InMemoryReplayStore = InMemoryReplayStore;
|
|
1292
1177
|
exports.WalletClient = WalletClient;
|
|
1293
1178
|
exports.WebhookVerificationError = WebhookVerificationError;
|
|
1179
|
+
exports.aggregate = aggregate;
|
|
1294
1180
|
exports.clearWebhookKeyCache = clearWebhookKeyCache;
|
|
1295
1181
|
exports.clearWebhookReplayCache = clearWebhookReplayCache;
|
|
1182
|
+
exports.count = count;
|
|
1296
1183
|
exports.createWalletClient = createWalletClient;
|
|
1184
|
+
exports.functions = functions;
|
|
1185
|
+
exports.get = get;
|
|
1297
1186
|
exports.getAuthProvider = getAuthProvider;
|
|
1187
|
+
exports.getFiles = getFiles;
|
|
1298
1188
|
exports.getIdToken = getIdToken;
|
|
1189
|
+
exports.getMany = getMany;
|
|
1299
1190
|
exports.init = init;
|
|
1191
|
+
exports.invokeFunction = invokeFunction;
|
|
1192
|
+
exports.live = live;
|
|
1193
|
+
exports.liveIntent = liveIntent;
|
|
1194
|
+
exports.liveStatus = liveStatus;
|
|
1195
|
+
exports.queryAggregate = queryAggregate;
|
|
1196
|
+
exports.runExpression = runExpression;
|
|
1197
|
+
exports.runExpressionMany = runExpressionMany;
|
|
1198
|
+
exports.runQuery = runQuery;
|
|
1199
|
+
exports.runQueryMany = runQueryMany;
|
|
1200
|
+
exports.search = search;
|
|
1201
|
+
exports.set = set;
|
|
1202
|
+
exports.setFile = setFile;
|
|
1203
|
+
exports.setMany = setMany;
|
|
1204
|
+
exports.signAndSubmitTransaction = signAndSubmitTransaction;
|
|
1205
|
+
exports.signMessage = signMessage;
|
|
1206
|
+
exports.signTransaction = signTransaction;
|
|
1207
|
+
exports.subscribe = subscribe;
|
|
1300
1208
|
exports.verifyWebhook = verifyWebhook;
|
|
1301
|
-
Object.keys(core).forEach(function (k) {
|
|
1302
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1303
|
-
enumerable: true,
|
|
1304
|
-
get: function () { return core[k]; }
|
|
1305
|
-
});
|
|
1306
|
-
});
|
|
1307
1209
|
//# sourceMappingURL=index.js.map
|