@bounded-sh/core 0.0.89 → 0.0.91
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/dist/client/client-transaction-versions.d.ts +2 -0
- package/dist/client/solana-operations.d.ts +63 -0
- package/dist/client/solana-transaction-read.d.ts +13 -0
- package/dist/client/solana-v1-operations.d.ts +9 -0
- package/dist/{index-BxzaztPl.js → index-BjLa1c_O.js} +71 -10
- package/dist/index-BjLa1c_O.js.map +1 -0
- package/dist/{index-P9HgYxQ6.mjs → index-DM016I43.mjs} +70 -11
- package/dist/index-DM016I43.mjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{realtime-store-BfnJefdw.js → realtime-store-O-5CDrGm.js} +2 -2
- package/dist/{realtime-store-BfnJefdw.js.map → realtime-store-O-5CDrGm.js.map} +1 -1
- package/dist/{realtime-store-65vgABGG.mjs → realtime-store-zORqBwjW.mjs} +2 -2
- package/dist/{realtime-store-65vgABGG.mjs.map → realtime-store-zORqBwjW.mjs.map} +1 -1
- package/dist/{solana-message-CIwmajWk.mjs → solana-message-CmvedcGr.mjs} +2 -2
- package/dist/{solana-message-CIwmajWk.mjs.map → solana-message-CmvedcGr.mjs.map} +1 -1
- package/dist/{solana-message-CfwyiOZc.js → solana-message-DY0FVgHp.js} +2 -2
- package/dist/{solana-message-CfwyiOZc.js.map → solana-message-DY0FVgHp.js.map} +1 -1
- package/dist/{solana-operations-BFH2w7qn.js → solana-operations-DSAWnjWi.js} +146 -28
- package/dist/solana-operations-DSAWnjWi.js.map +1 -0
- package/dist/{solana-operations-BbyfKGSN.mjs → solana-operations-D_e7AMhd.mjs} +139 -29
- package/dist/solana-operations-D_e7AMhd.mjs.map +1 -0
- package/dist/solana-v1-operations-ByWdgO_7.js +175 -0
- package/dist/solana-v1-operations-ByWdgO_7.js.map +1 -0
- package/dist/solana-v1-operations-DF6Cp0IX.mjs +173 -0
- package/dist/solana-v1-operations-DF6Cp0IX.mjs.map +1 -0
- package/dist/types.d.ts +36 -0
- package/package.json +2 -1
- package/dist/index-BxzaztPl.js.map +0 -1
- package/dist/index-P9HgYxQ6.mjs.map +0 -1
- package/dist/solana-operations-BFH2w7qn.js.map +0 -1
- package/dist/solana-operations-BbyfKGSN.mjs.map +0 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
export { getTransactionJson, SOLANA_MAX_SUPPORTED_TRANSACTION_VERSION } from './solana-transaction-read';
|
|
1
2
|
import type { VersionedTransaction } from '@solana/web3.js';
|
|
2
3
|
import type { AuthProvider, SolanaTransactionResult } from '../types';
|
|
3
4
|
import type { SetOptions } from './operations';
|
|
5
|
+
/**
|
|
6
|
+
* Minimal base58 encoder, used ONLY to derive a Solana transaction signature
|
|
7
|
+
* from already-signed bytes. Core deliberately does not take a `bs58`
|
|
8
|
+
* dependency for eighteen lines of arithmetic.
|
|
9
|
+
*/
|
|
10
|
+
export declare function encodeBase58(bytes: Uint8Array): string;
|
|
4
11
|
/**
|
|
5
12
|
* Derive the transaction signature from the SIGNED bytes, before broadcasting.
|
|
6
13
|
*
|
|
@@ -9,8 +16,33 @@ import type { SetOptions } from './operations';
|
|
|
9
16
|
* nothing recorded — and a retry builds a DIFFERENT transaction that can land
|
|
10
17
|
* beside the first.
|
|
11
18
|
*/
|
|
19
|
+
/** true when the base64 wire is a SIMD-0385 v1 transaction (first byte 0x81). */
|
|
20
|
+
export declare function isTransactionV1Base64(serializedTransaction: string): boolean;
|
|
12
21
|
export declare function deriveTransactionSignature(signedTransaction: VersionedTransaction): string;
|
|
13
22
|
export declare function isDefinitiveSolanaSendFailure(error: unknown): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether a definitive Solana send/confirm failure is the BOUNDED PROGRAM
|
|
25
|
+
* rejecting the write in simulation - a policy rule or a cap/invariant check -
|
|
26
|
+
* as opposed to an infra failure (blockhash, fees, account not found). Only the
|
|
27
|
+
* former is a stale-mirror race and safe to advertise as retryable.
|
|
28
|
+
*/
|
|
29
|
+
export declare function isBoundedOnchainRuleRejection(error: unknown, extraLogs?: unknown): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* A Bounded on-chain rule/invariant rejection surfaced with a message the caller
|
|
32
|
+
* can act on. This write already PASSED the off-chain preflight (otherwise it
|
|
33
|
+
* would have been declined before a transaction was ever built), so the program
|
|
34
|
+
* disagreeing here means the authoritative on-chain state is ahead of a
|
|
35
|
+
* not-yet-converged read mirror - re-read and retry. If it keeps failing, the
|
|
36
|
+
* rule is genuinely unsatisfied (the cap is truly exceeded, or the write is not
|
|
37
|
+
* authorized). Carries the original error as `cause` and the raw program logs.
|
|
38
|
+
*/
|
|
39
|
+
export declare class BoundedOnchainRuleRejection extends Error {
|
|
40
|
+
readonly boundedRuleRejection = true;
|
|
41
|
+
readonly retryable = true;
|
|
42
|
+
readonly logs: string[];
|
|
43
|
+
constructor(cause: unknown, extraLogs?: unknown);
|
|
44
|
+
}
|
|
45
|
+
export declare function errorText(error: unknown): string;
|
|
14
46
|
/**
|
|
15
47
|
* One expected field operation, derived from the caller's request document.
|
|
16
48
|
* `value`/`delta` are the JSON-round-tripped request values (what the server
|
|
@@ -58,6 +90,37 @@ export declare function buildExpectedWriteIntent(documents: Array<{
|
|
|
58
90
|
destinationPath: string;
|
|
59
91
|
document: any;
|
|
60
92
|
}>): ExpectedWriteIntent;
|
|
93
|
+
/**
|
|
94
|
+
* Minimal base58 decoder, used ONLY to recognize a declared-Address field: a
|
|
95
|
+
* request string that decodes to exactly the 32 bytes the instruction carries
|
|
96
|
+
* is a faithful AddressVal encoding of that string. Returns null on any
|
|
97
|
+
* non-base58 character.
|
|
98
|
+
*/
|
|
99
|
+
export declare function decodeBase58(text: string): Uint8Array | null;
|
|
100
|
+
type PublicKeyClass = typeof import('@solana/web3.js')['PublicKey'];
|
|
101
|
+
type PublicKeyInstance = InstanceType<PublicKeyClass>;
|
|
102
|
+
export interface ServerTransactionInstructionView {
|
|
103
|
+
programId: string;
|
|
104
|
+
accountKeyIndexes: number[];
|
|
105
|
+
data: Uint8Array;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The format-blind half of pre-sign validation: every instruction must be a
|
|
109
|
+
* program the server builder is allowed to emit, the two setup shapes must
|
|
110
|
+
* recompute to this write's values, and exactly one Bounded set-documents
|
|
111
|
+
* instruction must bind the caller's own intent (OA-0001). The v0 path feeds it
|
|
112
|
+
* web3.js's compiled message; the SIMD-0385 v1 lane feeds it kit's decoded
|
|
113
|
+
* instruction headers and payloads.
|
|
114
|
+
*/
|
|
115
|
+
export declare function validateServerTransactionSemantics(input: {
|
|
116
|
+
label: string;
|
|
117
|
+
expectedAppId: string;
|
|
118
|
+
expectedIntent: ExpectedWriteIntent;
|
|
119
|
+
accountKeys: PublicKeyInstance[];
|
|
120
|
+
isAccountSigner: (index: number) => boolean;
|
|
121
|
+
instructions: ServerTransactionInstructionView[];
|
|
122
|
+
PublicKeyCtor: PublicKeyClass;
|
|
123
|
+
}): void;
|
|
61
124
|
export declare function handlePreBuiltTransaction(tx: {
|
|
62
125
|
serializedTransaction: string;
|
|
63
126
|
blockhash: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SolanaWriteRpc } from '../types';
|
|
2
|
+
/** The highest Solana transaction version this SDK reads back (SIMD-0385 v1). */
|
|
3
|
+
export declare const SOLANA_MAX_SUPPORTED_TRANSACTION_VERSION = 1;
|
|
4
|
+
/**
|
|
5
|
+
* getTransaction that survives a SIMD-0385 v1 response. @solana/web3.js 1.98.x
|
|
6
|
+
* validates `version` against `0 | 'legacy'` and THROWS on 1 even when the request
|
|
7
|
+
* raised the ceiling, so a real `Connection` (which exposes `rpcEndpoint`) is read
|
|
8
|
+
* as raw JSON-RPC instead. An injected double without an endpoint goes through its
|
|
9
|
+
* own `getTransaction` with the ceiling raised. Returns the RPC `result` (null when
|
|
10
|
+
* the signature is unknown); RPC and transport failures throw so callers keep
|
|
11
|
+
* treating a failed lookup as inconclusive rather than as absence.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getTransactionJson(rpc: SolanaWriteRpc, signature: string, commitment?: 'confirmed' | 'finalized'): Promise<any | null>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AuthProvider, SolanaTransactionResult } from '../types';
|
|
2
|
+
import type { SetOptions } from './operations';
|
|
3
|
+
import { type ExpectedWriteIntent } from './solana-operations';
|
|
4
|
+
export declare function handlePreBuiltV1Transaction(tx: {
|
|
5
|
+
serializedTransaction: string;
|
|
6
|
+
blockhash: string;
|
|
7
|
+
lastValidBlockHeight: number;
|
|
8
|
+
network: string;
|
|
9
|
+
}, authProvider: AuthProvider, options: SetOptions | undefined, expectedIntent: ExpectedWriteIntent): Promise<SolanaTransactionResult>;
|
|
@@ -4133,7 +4133,7 @@ class ServerSessionManager {
|
|
|
4133
4133
|
const sessionConfig = (_a = this.sessionConfig) !== null && _a !== void 0 ? _a : undefined;
|
|
4134
4134
|
/* fetch nonce from auth API (bound to the snapshotted app+issuer) */
|
|
4135
4135
|
const nonce = await genAuthNonce(sessionConfig);
|
|
4136
|
-
const { genSolanaMessage } = await Promise.resolve().then(function () { return require('./solana-message-
|
|
4136
|
+
const { genSolanaMessage } = await Promise.resolve().then(function () { return require('./solana-message-DY0FVgHp.js'); });
|
|
4137
4137
|
const message = await genSolanaMessage(address, nonce, sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.appId);
|
|
4138
4138
|
/* sign the message */
|
|
4139
4139
|
const sigBytes = nacl.sign.detached(new TextEncoder().encode(message), kp.secretKey);
|
|
@@ -5157,6 +5157,23 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
5157
5157
|
}
|
|
5158
5158
|
}
|
|
5159
5159
|
|
|
5160
|
+
async function resolveClientTransactionVersions(authProvider) {
|
|
5161
|
+
if (!authProvider)
|
|
5162
|
+
return ['legacy', 0];
|
|
5163
|
+
if (typeof authProvider.supportedTransactionVersions === 'function') {
|
|
5164
|
+
try {
|
|
5165
|
+
const declared = await authProvider.supportedTransactionVersions();
|
|
5166
|
+
const versions = declared.filter((v) => v === 'legacy' || v === 0 || v === 1);
|
|
5167
|
+
// v1 needs a v1 signer no matter what the provider claims.
|
|
5168
|
+
return versions.filter((v) => v !== 1 || typeof authProvider.signTransactionV1 === 'function');
|
|
5169
|
+
}
|
|
5170
|
+
catch (_a) {
|
|
5171
|
+
return ['legacy', 0];
|
|
5172
|
+
}
|
|
5173
|
+
}
|
|
5174
|
+
return typeof authProvider.signTransactionV1 === 'function' ? ['legacy', 0, 1] : ['legacy', 0];
|
|
5175
|
+
}
|
|
5176
|
+
|
|
5160
5177
|
/**
|
|
5161
5178
|
* WebSocket v2 Subscription Manager
|
|
5162
5179
|
*
|
|
@@ -6901,7 +6918,7 @@ async function doReconnectWithNewAuth() {
|
|
|
6901
6918
|
console.warn('[WS v2] Failed to clear HTTP read cache on auth change:', error);
|
|
6902
6919
|
}
|
|
6903
6920
|
try {
|
|
6904
|
-
const { reconnectRealtimeStoreWithNewAuth } = await Promise.resolve().then(function () { return require('./realtime-store-
|
|
6921
|
+
const { reconnectRealtimeStoreWithNewAuth } = await Promise.resolve().then(function () { return require('./realtime-store-O-5CDrGm.js'); });
|
|
6905
6922
|
await reconnectRealtimeStoreWithNewAuth();
|
|
6906
6923
|
}
|
|
6907
6924
|
catch (error) {
|
|
@@ -8281,7 +8298,10 @@ async function setMany(many, options) {
|
|
|
8281
8298
|
}
|
|
8282
8299
|
let setResponse;
|
|
8283
8300
|
try {
|
|
8284
|
-
|
|
8301
|
+
// SIMD-0385: tell the worker which Solana transaction formats this client
|
|
8302
|
+
// can sign, so it builds v1 only for a client that can complete it.
|
|
8303
|
+
const clientTransactionVersions = await resolveClientTransactionVersions(authProvider);
|
|
8304
|
+
setResponse = await makeApiRequest('PUT', `items`, { documents, clientTransactionVersions }, options === null || options === void 0 ? void 0 : options._overrides);
|
|
8285
8305
|
}
|
|
8286
8306
|
catch (error) {
|
|
8287
8307
|
if ((error === null || error === void 0 ? void 0 : error.statusCode) === 402 && (error === null || error === void 0 ? void 0 : error.error) === 'INSUFFICIENT_BALANCE') {
|
|
@@ -8348,7 +8368,7 @@ async function setMany(many, options) {
|
|
|
8348
8368
|
'Nothing was signed or submitted.');
|
|
8349
8369
|
}
|
|
8350
8370
|
const solanaChain = workerChain;
|
|
8351
|
-
const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-
|
|
8371
|
+
const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-DSAWnjWi.js'); });
|
|
8352
8372
|
// OA-0001: derive the expected intent from OUR OWN request (the one
|
|
8353
8373
|
// ground truth a tampered builder response cannot change) so the
|
|
8354
8374
|
// validator can reject any transaction whose operation semantics
|
|
@@ -8669,6 +8689,48 @@ var operations = /*#__PURE__*/Object.freeze({
|
|
|
8669
8689
|
syncItems: syncItems
|
|
8670
8690
|
});
|
|
8671
8691
|
|
|
8692
|
+
/** The highest Solana transaction version this SDK reads back (SIMD-0385 v1). */
|
|
8693
|
+
const SOLANA_MAX_SUPPORTED_TRANSACTION_VERSION = 1;
|
|
8694
|
+
/**
|
|
8695
|
+
* getTransaction that survives a SIMD-0385 v1 response. @solana/web3.js 1.98.x
|
|
8696
|
+
* validates `version` against `0 | 'legacy'` and THROWS on 1 even when the request
|
|
8697
|
+
* raised the ceiling, so a real `Connection` (which exposes `rpcEndpoint`) is read
|
|
8698
|
+
* as raw JSON-RPC instead. An injected double without an endpoint goes through its
|
|
8699
|
+
* own `getTransaction` with the ceiling raised. Returns the RPC `result` (null when
|
|
8700
|
+
* the signature is unknown); RPC and transport failures throw so callers keep
|
|
8701
|
+
* treating a failed lookup as inconclusive rather than as absence.
|
|
8702
|
+
*/
|
|
8703
|
+
async function getTransactionJson(rpc, signature, commitment = 'confirmed') {
|
|
8704
|
+
var _a;
|
|
8705
|
+
const endpoint = typeof (rpc === null || rpc === void 0 ? void 0 : rpc.rpcEndpoint) === 'string' ? rpc.rpcEndpoint.trim() : '';
|
|
8706
|
+
if (!endpoint) {
|
|
8707
|
+
return rpc.getTransaction(signature, {
|
|
8708
|
+
maxSupportedTransactionVersion: SOLANA_MAX_SUPPORTED_TRANSACTION_VERSION,
|
|
8709
|
+
commitment,
|
|
8710
|
+
});
|
|
8711
|
+
}
|
|
8712
|
+
const response = await fetch(endpoint, {
|
|
8713
|
+
method: 'POST',
|
|
8714
|
+
headers: { 'content-type': 'application/json' },
|
|
8715
|
+
body: JSON.stringify({
|
|
8716
|
+
jsonrpc: '2.0',
|
|
8717
|
+
id: 1,
|
|
8718
|
+
method: 'getTransaction',
|
|
8719
|
+
params: [signature, {
|
|
8720
|
+
commitment,
|
|
8721
|
+
encoding: 'json',
|
|
8722
|
+
maxSupportedTransactionVersion: SOLANA_MAX_SUPPORTED_TRANSACTION_VERSION,
|
|
8723
|
+
}],
|
|
8724
|
+
}),
|
|
8725
|
+
});
|
|
8726
|
+
if (!response.ok)
|
|
8727
|
+
throw new Error(`getTransaction http ${response.status}`);
|
|
8728
|
+
const body = await response.json();
|
|
8729
|
+
if (body === null || body === void 0 ? void 0 : body.error)
|
|
8730
|
+
throw new Error(`getTransaction rpc error ${body.error.code}: ${body.error.message}`);
|
|
8731
|
+
return (_a = body === null || body === void 0 ? void 0 : body.result) !== null && _a !== void 0 ? _a : null;
|
|
8732
|
+
}
|
|
8733
|
+
|
|
8672
8734
|
const DEFAULT_TIMEOUT_MS = 60000;
|
|
8673
8735
|
const DEFAULT_MAX_ATTEMPTS = 20;
|
|
8674
8736
|
const DEFAULT_POLL_INTERVAL_MS = 3000;
|
|
@@ -8798,10 +8860,7 @@ async function reconcileSolana(receipt, config, options) {
|
|
|
8798
8860
|
// Expired. Prove absence from history before declaring the write retry-safe.
|
|
8799
8861
|
let history;
|
|
8800
8862
|
try {
|
|
8801
|
-
history = await rpc
|
|
8802
|
-
maxSupportedTransactionVersion: 0,
|
|
8803
|
-
commitment: 'confirmed',
|
|
8804
|
-
});
|
|
8863
|
+
history = await getTransactionJson(rpc, receipt.transactionId, 'confirmed');
|
|
8805
8864
|
}
|
|
8806
8865
|
catch (error) {
|
|
8807
8866
|
return stillSubmitted(receipt, `history lookup failed after expiry: ${errorText(error)}`);
|
|
@@ -9794,7 +9853,7 @@ function toMillis(seconds) {
|
|
|
9794
9853
|
|
|
9795
9854
|
/** SIWS message creation is async already, so its onchain module can be lazy. */
|
|
9796
9855
|
async function genSolanaMessage(address, nonce) {
|
|
9797
|
-
const implementation = await Promise.resolve().then(function () { return require('./solana-message-
|
|
9856
|
+
const implementation = await Promise.resolve().then(function () { return require('./solana-message-DY0FVgHp.js'); });
|
|
9798
9857
|
return implementation.genSolanaMessage(address, nonce);
|
|
9799
9858
|
}
|
|
9800
9859
|
|
|
@@ -10281,6 +10340,7 @@ exports.LiveIntentError = LiveIntentError;
|
|
|
10281
10340
|
exports.MIN_QUERY_POLL_INTERVAL_MS = MIN_QUERY_POLL_INTERVAL_MS;
|
|
10282
10341
|
exports.RATE_LIMIT_EVENT_NAME = RATE_LIMIT_EVENT_NAME;
|
|
10283
10342
|
exports.ReactNativeSessionManager = ReactNativeSessionManager;
|
|
10343
|
+
exports.SOLANA_MAX_SUPPORTED_TRANSACTION_VERSION = SOLANA_MAX_SUPPORTED_TRANSACTION_VERSION;
|
|
10284
10344
|
exports.ScopedClientReadOnlyError = ScopedClientReadOnlyError;
|
|
10285
10345
|
exports.ServerSessionManager = ServerSessionManager;
|
|
10286
10346
|
exports.SessionEnvironmentError = SessionEnvironmentError;
|
|
@@ -10316,6 +10376,7 @@ exports.getFreshAuthToken = getFreshAuthToken;
|
|
|
10316
10376
|
exports.getIdToken = getIdToken;
|
|
10317
10377
|
exports.getMany = getMany;
|
|
10318
10378
|
exports.getSessionGeneration = getSessionGeneration;
|
|
10379
|
+
exports.getTransactionJson = getTransactionJson;
|
|
10319
10380
|
exports.getWebhookKeysUrl = getWebhookKeysUrl;
|
|
10320
10381
|
exports.hasActiveConnection = hasActiveConnection;
|
|
10321
10382
|
exports.increment = increment;
|
|
@@ -10355,4 +10416,4 @@ exports.toMillis = toMillis;
|
|
|
10355
10416
|
exports.toSeconds = toSeconds;
|
|
10356
10417
|
exports.waitForSetResult = waitForSetResult;
|
|
10357
10418
|
exports.withEffects = withEffects;
|
|
10358
|
-
//# sourceMappingURL=index-
|
|
10419
|
+
//# sourceMappingURL=index-BjLa1c_O.js.map
|