@bounded-sh/server 0.0.18 → 0.0.20
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/offchain-auth-provider.d.ts +0 -4
- 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 -192
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -117
- 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
|
@@ -2,9 +2,6 @@ import { AuthProvider } from '@bounded-sh/core';
|
|
|
2
2
|
import { Transaction, VersionedTransaction } from '@solana/web3.js';
|
|
3
3
|
/**
|
|
4
4
|
* Server-side OffchainAuthProvider wrapper for the poofnet environment.
|
|
5
|
-
*
|
|
6
|
-
* For signMessage, this generates a mock signature using SHA-256 hashing.
|
|
7
|
-
* This is used for offchain transaction signing.
|
|
8
5
|
*/
|
|
9
6
|
export declare class OffchainAuthProvider implements AuthProvider {
|
|
10
7
|
private wrappedProvider;
|
|
@@ -14,7 +11,6 @@ export declare class OffchainAuthProvider implements AuthProvider {
|
|
|
14
11
|
restoreSession(): Promise<any>;
|
|
15
12
|
getNativeMethods(): Promise<any>;
|
|
16
13
|
signMessage(message: string): Promise<string>;
|
|
17
|
-
signMessageMock(message: string): Promise<string>;
|
|
18
14
|
signTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
|
|
19
15
|
/**
|
|
20
16
|
* Sign and submit transaction - not supported in poofnet environment.
|
|
@@ -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,12 +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
|
-
var crypto = require('crypto');
|
|
10
9
|
|
|
11
10
|
function _interopNamespaceDefault(e) {
|
|
12
11
|
var n = Object.create(null);
|
|
@@ -26,16 +25,52 @@ function _interopNamespaceDefault(e) {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
var anchor__namespace = /*#__PURE__*/_interopNamespaceDefault(anchor);
|
|
29
|
-
var crypto__namespace = /*#__PURE__*/_interopNamespaceDefault(crypto);
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
async function init(newConfig) {
|
|
30
|
+
await core.init(Object.assign(Object.assign({}, newConfig), { authProvider: null, isServer: true, skipBackendInit: true }));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function getAuthProvider() {
|
|
34
|
+
throw new Error('Server auth providers are not process-global. Use createWalletClient({ keypair }) and call that client\'s methods.');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function explicitClientOnly(name) {
|
|
38
|
+
throw new Error(`${name} is not available as a tarobase-server top-level auth operation. ` +
|
|
39
|
+
'Use createWalletClient({ keypair }) and call the returned client method.');
|
|
40
|
+
}
|
|
41
|
+
async function get(..._args) { explicitClientOnly('get'); }
|
|
42
|
+
async function getMany(..._args) { explicitClientOnly('getMany'); }
|
|
43
|
+
async function set(..._args) { explicitClientOnly('set'); }
|
|
44
|
+
async function setMany(..._args) { explicitClientOnly('setMany'); }
|
|
45
|
+
async function setFile(..._args) { explicitClientOnly('setFile'); }
|
|
46
|
+
async function getFiles(..._args) { explicitClientOnly('getFiles'); }
|
|
47
|
+
async function search(..._args) { explicitClientOnly('search'); }
|
|
48
|
+
async function queryAggregate(..._args) { explicitClientOnly('queryAggregate'); }
|
|
49
|
+
async function runQuery(..._args) { explicitClientOnly('runQuery'); }
|
|
50
|
+
async function runQueryMany(..._args) { explicitClientOnly('runQueryMany'); }
|
|
51
|
+
async function runExpression(..._args) { explicitClientOnly('runExpression'); }
|
|
52
|
+
async function runExpressionMany(..._args) { explicitClientOnly('runExpressionMany'); }
|
|
53
|
+
async function signMessage(..._args) { explicitClientOnly('signMessage'); }
|
|
54
|
+
async function signTransaction(..._args) { explicitClientOnly('signTransaction'); }
|
|
55
|
+
async function signAndSubmitTransaction(..._args) { explicitClientOnly('signAndSubmitTransaction'); }
|
|
56
|
+
async function count(..._args) { explicitClientOnly('count'); }
|
|
57
|
+
async function aggregate(..._args) { explicitClientOnly('aggregate'); }
|
|
58
|
+
async function subscribe(..._args) { explicitClientOnly('subscribe'); }
|
|
59
|
+
async function invokeFunction(..._args) { explicitClientOnly('invokeFunction'); }
|
|
60
|
+
async function liveIntent(..._args) { explicitClientOnly('liveIntent'); }
|
|
61
|
+
async function liveStatus(..._args) { explicitClientOnly('liveStatus'); }
|
|
62
|
+
const functions = {
|
|
63
|
+
invoke: async (..._args) => explicitClientOnly('functions.invoke'),
|
|
64
|
+
};
|
|
65
|
+
const live = {
|
|
66
|
+
intent: async (..._args) => explicitClientOnly('live.intent'),
|
|
67
|
+
status: async (..._args) => explicitClientOnly('live.status'),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
async function getIdToken() {
|
|
71
|
+
throw new Error('getIdToken is not available as a tarobase-server top-level auth operation. Use createWalletClient({ keypair }) and call the returned client methods.');
|
|
72
|
+
}
|
|
73
|
+
|
|
39
74
|
const PRESIGNED_BLOCKHASH_ERROR = 'Server signedTransaction blockhash is stale or expired';
|
|
40
75
|
const BOUNDED_PROGRAM_MAINNET = 'poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZp';
|
|
41
76
|
const BOUNDED_PROGRAM_DEVNET = 'taro6CvKqwrYrDc16ufYgzQ2NZcyyVKStffbtudrhRu';
|
|
@@ -55,32 +90,6 @@ const ALLOWED_BOUNDED_SET_DISCRIMINATORS = new Set([
|
|
|
55
90
|
SET_DOCUMENTS_DISCRIMINATOR,
|
|
56
91
|
SET_DOCUMENTS_V2_DISCRIMINATOR,
|
|
57
92
|
]);
|
|
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
93
|
/* ──────────────────────────────────────────────────────────
|
|
85
94
|
* Helper – fetch getPriorityFeeEstimate
|
|
86
95
|
* ──────────────────────────────────────────────────────── */
|
|
@@ -309,13 +318,15 @@ function assertAllowedServerPreInstructions(preInstructions) {
|
|
|
309
318
|
}
|
|
310
319
|
}
|
|
311
320
|
class SolanaKeypairProvider {
|
|
312
|
-
constructor(rpcUrl
|
|
321
|
+
constructor(rpcUrl, serverKeypair) {
|
|
313
322
|
this.rpcUrl = rpcUrl;
|
|
314
|
-
this.
|
|
323
|
+
this.serverKeypair = serverKeypair;
|
|
315
324
|
}
|
|
316
325
|
get keypair() {
|
|
317
|
-
|
|
318
|
-
|
|
326
|
+
if (!this.serverKeypair) {
|
|
327
|
+
throw new Error('Server keypair is required; use createWalletClient({ keypair }) or pass a Keypair to SolanaKeypairProvider.');
|
|
328
|
+
}
|
|
329
|
+
return this.serverKeypair;
|
|
319
330
|
}
|
|
320
331
|
/* ----------------------------------------------------------- *
|
|
321
332
|
* (Auth stubs – fill in later if needed)
|
|
@@ -630,9 +641,6 @@ class SolanaKeypairProvider {
|
|
|
630
641
|
|
|
631
642
|
/**
|
|
632
643
|
* Server-side OffchainAuthProvider wrapper for the poofnet environment.
|
|
633
|
-
*
|
|
634
|
-
* For signMessage, this generates a mock signature using SHA-256 hashing.
|
|
635
|
-
* This is used for offchain transaction signing.
|
|
636
644
|
*/
|
|
637
645
|
class OffchainAuthProvider {
|
|
638
646
|
constructor(wrappedProvider) {
|
|
@@ -651,15 +659,8 @@ class OffchainAuthProvider {
|
|
|
651
659
|
return this.wrappedProvider.getNativeMethods();
|
|
652
660
|
}
|
|
653
661
|
async signMessage(message) {
|
|
654
|
-
// Delegate to wrapped provider for real signing
|
|
655
662
|
return this.wrappedProvider.signMessage(message);
|
|
656
663
|
}
|
|
657
|
-
async signMessageMock(message) {
|
|
658
|
-
// Generate mock signature (SHA-256 hash of message, base64 encoded)
|
|
659
|
-
// This is used for offchain transaction signing
|
|
660
|
-
const hash = crypto__namespace.createHash('sha256').update(message).digest('base64');
|
|
661
|
-
return hash;
|
|
662
|
-
}
|
|
663
664
|
async signTransaction(transaction) {
|
|
664
665
|
throw new Error('Poofnet does not support real Solana transactions. Deploy your project to mainnet to use this feature.');
|
|
665
666
|
}
|
|
@@ -676,44 +677,6 @@ class OffchainAuthProvider {
|
|
|
676
677
|
}
|
|
677
678
|
}
|
|
678
679
|
|
|
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
680
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
718
681
|
var t = {};
|
|
719
682
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
@@ -863,8 +826,7 @@ class WalletClient {
|
|
|
863
826
|
return core.queryAggregate(path, spec, Object.assign(Object.assign({}, opts), { _overrides: this.mergeReadOverrides(opts === null || opts === void 0 ? void 0 : opts._overrides) }));
|
|
864
827
|
}
|
|
865
828
|
/**
|
|
866
|
-
* Subscribe to real-time updates as THIS wallet's identity.
|
|
867
|
-
* `subscribe`, this needs no `BOUNDED_PRIVATE_KEY` env var — the WS connection
|
|
829
|
+
* Subscribe to real-time updates as THIS wallet's identity. The WS connection
|
|
868
830
|
* authenticates with the wallet's own session (so read rules see the right
|
|
869
831
|
* principal), and is scoped to its own connection so it never crosses another
|
|
870
832
|
* identity. Accepts a bare callback or `{ onData, onError, filter, ... }`.
|
|
@@ -880,10 +842,9 @@ class WalletClient {
|
|
|
880
842
|
} }));
|
|
881
843
|
}
|
|
882
844
|
/**
|
|
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
|
|
845
|
+
* Invoke a deployed Bounded Function AS this wallet's identity. The dispatcher
|
|
846
|
+
* sees the wallet's verified session, so the function's `auth` rule +
|
|
847
|
+
* `ctx.user` reflect this client. Returns the function's JSON; throws
|
|
887
848
|
* `FunctionInvokeError` on 401/403/404/503.
|
|
888
849
|
*/
|
|
889
850
|
async invoke(name, args = {}, opts = {}) {
|
|
@@ -1191,117 +1152,46 @@ Object.defineProperty(exports, "LiveIntentError", {
|
|
|
1191
1152
|
enumerable: true,
|
|
1192
1153
|
get: function () { return core.LiveIntentError; }
|
|
1193
1154
|
});
|
|
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
1155
|
Object.defineProperty(exports, "getConfig", {
|
|
1211
1156
|
enumerable: true,
|
|
1212
1157
|
get: function () { return core.getConfig; }
|
|
1213
1158
|
});
|
|
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", {
|
|
1159
|
+
Object.defineProperty(exports, "getWebhookKeysUrl", {
|
|
1223
1160
|
enumerable: true,
|
|
1224
|
-
get: function () { return core.
|
|
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", {
|
|
1267
|
-
enumerable: true,
|
|
1268
|
-
get: function () { return core.setFile; }
|
|
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; }
|
|
1161
|
+
get: function () { return core.getWebhookKeysUrl; }
|
|
1289
1162
|
});
|
|
1290
1163
|
exports.DEFAULT_WEBHOOK_KEYS_URL = DEFAULT_WEBHOOK_KEYS_URL;
|
|
1291
1164
|
exports.InMemoryReplayStore = InMemoryReplayStore;
|
|
1292
1165
|
exports.WalletClient = WalletClient;
|
|
1293
1166
|
exports.WebhookVerificationError = WebhookVerificationError;
|
|
1167
|
+
exports.aggregate = aggregate;
|
|
1294
1168
|
exports.clearWebhookKeyCache = clearWebhookKeyCache;
|
|
1295
1169
|
exports.clearWebhookReplayCache = clearWebhookReplayCache;
|
|
1170
|
+
exports.count = count;
|
|
1296
1171
|
exports.createWalletClient = createWalletClient;
|
|
1172
|
+
exports.functions = functions;
|
|
1173
|
+
exports.get = get;
|
|
1297
1174
|
exports.getAuthProvider = getAuthProvider;
|
|
1175
|
+
exports.getFiles = getFiles;
|
|
1298
1176
|
exports.getIdToken = getIdToken;
|
|
1177
|
+
exports.getMany = getMany;
|
|
1299
1178
|
exports.init = init;
|
|
1179
|
+
exports.invokeFunction = invokeFunction;
|
|
1180
|
+
exports.live = live;
|
|
1181
|
+
exports.liveIntent = liveIntent;
|
|
1182
|
+
exports.liveStatus = liveStatus;
|
|
1183
|
+
exports.queryAggregate = queryAggregate;
|
|
1184
|
+
exports.runExpression = runExpression;
|
|
1185
|
+
exports.runExpressionMany = runExpressionMany;
|
|
1186
|
+
exports.runQuery = runQuery;
|
|
1187
|
+
exports.runQueryMany = runQueryMany;
|
|
1188
|
+
exports.search = search;
|
|
1189
|
+
exports.set = set;
|
|
1190
|
+
exports.setFile = setFile;
|
|
1191
|
+
exports.setMany = setMany;
|
|
1192
|
+
exports.signAndSubmitTransaction = signAndSubmitTransaction;
|
|
1193
|
+
exports.signMessage = signMessage;
|
|
1194
|
+
exports.signTransaction = signTransaction;
|
|
1195
|
+
exports.subscribe = subscribe;
|
|
1300
1196
|
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
1197
|
//# sourceMappingURL=index.js.map
|