@bounded-sh/core 0.0.63 → 0.0.65

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.
Files changed (42) hide show
  1. package/dist/client/functions.d.ts +8 -0
  2. package/dist/client/solana-operations.d.ts +0 -1
  3. package/dist/{index-BQ6e4MeP.mjs → index-BNOU00XY.mjs} +3243 -3262
  4. package/dist/index-BNOU00XY.mjs.map +1 -0
  5. package/dist/{index-BIdD2yUB.js → index-C8ocsC_W.js} +3242 -3263
  6. package/dist/index-C8ocsC_W.js.map +1 -0
  7. package/dist/index.d.ts +2 -3
  8. package/dist/index.js +1 -4
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +1 -2
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/{realtime-store-Bz4Ob6K6.js → realtime-store-I_bcryPz.js} +2 -3
  13. package/dist/{realtime-store-Bz4Ob6K6.js.map → realtime-store-I_bcryPz.js.map} +1 -1
  14. package/dist/{realtime-store-DKngqviG.mjs → realtime-store-mzFJ8bHE.mjs} +2 -3
  15. package/dist/{realtime-store-DKngqviG.mjs.map → realtime-store-mzFJ8bHE.mjs.map} +1 -1
  16. package/dist/{solana-message-B0NoE4nC.js → solana-message-D_CN0H6r.js} +10 -8
  17. package/dist/solana-message-D_CN0H6r.js.map +1 -0
  18. package/dist/{solana-message-QUfJi1Qm.mjs → solana-message-VZBGvV0S.mjs} +10 -8
  19. package/dist/solana-message-VZBGvV0S.mjs.map +1 -0
  20. package/dist/{solana-operations-B2Oy9T7D.mjs → solana-operations-BlCYbdiN.mjs} +11 -75
  21. package/dist/solana-operations-BlCYbdiN.mjs.map +1 -0
  22. package/dist/{solana-operations-ngqIkN9W.js → solana-operations-CYpu6EU8.js} +10 -75
  23. package/dist/solana-operations-CYpu6EU8.js.map +1 -0
  24. package/dist/utils/auth-api.d.ts +15 -2
  25. package/dist/utils/rn-session-manager.d.ts +57 -7
  26. package/dist/utils/server-session-manager.d.ts +6 -1
  27. package/dist/utils/sol/sol-accessors.d.ts +0 -27
  28. package/dist/utils/sol/solana-message.d.ts +1 -1
  29. package/package.json +2 -2
  30. package/dist/index-BIdD2yUB.js.map +0 -1
  31. package/dist/index-BQ6e4MeP.mjs.map +0 -1
  32. package/dist/sol-utils-Cwxyl2h6.js +0 -232
  33. package/dist/sol-utils-Cwxyl2h6.js.map +0 -1
  34. package/dist/sol-utils-DVjPeoMy.mjs +0 -229
  35. package/dist/sol-utils-DVjPeoMy.mjs.map +0 -1
  36. package/dist/solana-message-B0NoE4nC.js.map +0 -1
  37. package/dist/solana-message-QUfJi1Qm.mjs.map +0 -1
  38. package/dist/solana-operations-B2Oy9T7D.mjs.map +0 -1
  39. package/dist/solana-operations-ngqIkN9W.js.map +0 -1
  40. package/dist/utils/sol/openTv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6FDevnet-program.d.ts +0 -2906
  41. package/dist/utils/sol/openTv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6FMainnet-program.d.ts +0 -2906
  42. package/dist/utils/sol/sol-utils.d.ts +0 -34
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-message-VZBGvV0S.mjs","sources":["../.rollup-tmp/utils/sol/solana-message.js"],"sourcesContent":["import { getConfig } from \"../../client/config\";\n// NOTE: this message text must stay BYTE-IDENTICAL to what the wallet-auth\n// verifier reconstructs — any drift breaks every SIWS login.\nexport async function genSolanaMessage(address, nonce, appIdOverride) {\n var _a, _b;\n /* Domain / origin aren't available server-side – fall back to envs\n or simple placeholders. */\n const domain = (typeof process !== 'undefined' && ((_a = process.env) === null || _a === void 0 ? void 0 : _a.SESSION_DOMAIN)) || \"server\";\n const origin = (typeof process !== 'undefined' && ((_b = process.env) === null || _b === void 0 ? void 0 : _b.SESSION_ORIGIN)) || \"server\";\n // SECURITY (audit-4 CRITICAL-1): bind the signed prompt to the target app.\n // A server wallet client passes its snapshotted appId (appIdOverride) so the\n // signed \"App ID\" stays bound to the app the wallet client was created against\n // even after a later global init() (CTA-05); the default path reads the SAME\n // global config that genAuthNonce + /session use, so the signed \"App ID\" is\n // guaranteed to equal the app the session is minted for; the server verifier\n // rejects any mismatch.\n const appId = appIdOverride !== null && appIdOverride !== void 0 ? appIdOverride : (await getConfig()).appId;\n const statement = \"Sign this message to authenticate with our application.\";\n const currentDate = new Date();\n const issuedAt = currentDate.toISOString();\n const expirationTime = new Date(currentDate.getTime() + 5 * 60 * 1000).toISOString();\n return `${statement}\\n\\n` +\n `Wallet address:\\n${address}\\n\\n` +\n `App ID: ${appId}\\n` +\n `Domain: ${domain}\\n` +\n `Origin: ${origin}\\n` +\n `Nonce: ${nonce}\\n` +\n `Issued At: ${issuedAt}\\n` +\n `Expiration Time: ${expirationTime}`;\n}\n"],"names":[],"mappings":";;;;;AACA;AACA;AACO,eAAe,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE;AACtE,IAAI,IAAI,EAAE,EAAE,EAAE;AACd;AACA;AACA,IAAI,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,KAAK,WAAW,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,QAAQ;AAC9I,IAAI,MAAM,MAAM,GAAG,CAAC,OAAO,OAAO,KAAK,WAAW,KAAK,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,QAAQ;AAC9I;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,KAAK,GAAG,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,MAAM,GAAG,aAAa,GAAG,CAAC,MAAM,SAAS,EAAE,EAAE,KAAK;AAChH,IAAI,MAAM,SAAS,GAAG,yDAAyD;AAC/E,IAAI,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE;AAClC,IAAI,MAAM,QAAQ,GAAG,WAAW,CAAC,WAAW,EAAE;AAC9C,IAAI,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE;AACxF,IAAI,OAAO,CAAC,EAAE,SAAS,CAAC,IAAI,CAAC;AAC7B,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC,IAAI,CAAC;AACzC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC;AAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;AAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;AAC7B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;AAC3B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAE,CAAC;AAClC,QAAQ,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;AAC5C;;;;"}
@@ -1,8 +1,7 @@
1
- import { g as getConfig, b as bufferExports } from './index-BQ6e4MeP.mjs';
1
+ import { g as getConfig, b as bufferExports } from './index-BNOU00XY.mjs';
2
2
  import 'axios';
3
3
  import 'tweetnacl';
4
4
  import 'reconnecting-websocket';
5
- import 'bn.js';
6
5
 
7
6
  const BOUNDED_PROGRAM_MAINNET = ['open', 'Tv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F'].join('');
8
7
  const BOUNDED_PROGRAM_DEVNET = ['open', 'Tv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F'].join('');
@@ -152,80 +151,17 @@ function deserializeAndValidateServerTransaction(serializedTransaction, Versione
152
151
  assertSamePathSet(label, expectedWritePaths, actualWritePaths);
153
152
  return transaction;
154
153
  }
155
- function isHexString(value) {
156
- if (typeof value !== 'string')
157
- return false;
158
- const testValue = value.startsWith('-') ? value.slice(1) : value;
159
- return /^(0x)?[0-9a-fA-F]+$/.test(testValue);
160
- }
161
- async function handleSolanaTransaction(tx, authProvider, options, expectedWritePaths) {
162
- var _a, _b, _c, _d, _e;
163
- const chainSdk = await import('@solana/web3.js');
164
- const { PublicKey, SystemProgram, TransactionInstruction, VersionedTransaction } = chainSdk;
165
- const solTransactionData = {
166
- remainingAccounts: tx.remainingAccounts,
167
- setDocumentData: tx.transactionArgs.setDocumentData,
168
- deletePaths: tx.transactionArgs.deletePaths,
169
- idl: tx.idl,
170
- txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => ({
171
- pluginFunctionKey: txData.pluginFunctionKey,
172
- txData: bufferExports.Buffer.from(txData.txData),
173
- raIndices: (() => {
174
- const raw = txData.raIndices;
175
- if (raw == null)
176
- return bufferExports.Buffer.alloc(0);
177
- if (bufferExports.Buffer.isBuffer(raw))
178
- return raw;
179
- if (raw instanceof Uint8Array)
180
- return bufferExports.Buffer.from(raw);
181
- const arrayLike = Array.isArray(raw) ? raw :
182
- raw && typeof raw === 'object' && Array.isArray(raw.data) ? raw.data :
183
- (() => { throw new Error(`raIndices has unexpected shape: ${typeof raw}`); })();
184
- return bufferExports.Buffer.from(arrayLike.map((raIndex) => {
185
- const value = isHexString(raIndex) ? parseInt(raIndex, 16) : Number(raIndex);
186
- if (!Number.isInteger(value) || value < 0 || value > 255) {
187
- throw new Error(`raIndex ${raIndex} is not a valid u8 (must be integer in 0..255)`);
188
- }
189
- return value;
190
- }));
191
- })(),
192
- }))) !== null && _b !== void 0 ? _b : [],
193
- };
194
- const config = await getConfig();
195
- if (tx.signedTransaction) {
196
- deserializeAndValidateServerTransaction(tx.signedTransaction, VersionedTransaction, {
197
- label: 'Server signedTransaction', expectedAppId: config.appId, expectedWritePaths,
198
- });
199
- }
200
- const solTransaction = {
201
- appId: config.appId,
202
- txArgs: [solTransactionData],
203
- lutKey: (_c = tx.lutAddress) !== null && _c !== void 0 ? _c : null,
204
- additionalLutAddresses: tx.additionalLutAddresses,
205
- network: tx.network,
206
- preInstructions: (_e = (_d = tx.preInstructions) === null || _d === void 0 ? void 0 : _d.map((ix, index) => {
207
- var _a;
208
- const keys = (_a = ix.keys) === null || _a === void 0 ? void 0 : _a.map((key) => ({ pubkey: new PublicKey(key.pubkey), isSigner: key.isSigner, isWritable: key.isWritable }));
209
- const programId = ix.programId === SYSTEM_PROGRAM_ID ? SystemProgram.programId : new PublicKey(ix.programId);
210
- const instruction = new TransactionInstruction({ keys, programId, data: bufferExports.Buffer.from(ix.data) });
211
- if (instruction.programId.equals(SystemProgram.programId)) {
212
- throw new Error(`Server preInstruction[${index}] contains unauthorized System Program preInstruction`);
213
- }
214
- return instruction;
215
- })) !== null && _e !== void 0 ? _e : [],
216
- signedTransaction: tx.signedTransaction,
217
- };
218
- return authProvider.runTransaction(undefined, solTransaction, options);
219
- }
220
154
  async function handlePreBuiltTransaction(tx, authProvider, options, expectedWritePaths) {
221
- var _a, _b, _c, _d, _e;
155
+ var _a, _b, _c, _d, _e, _f, _g;
222
156
  const { Connection, VersionedTransaction } = await import('@solana/web3.js');
223
- const config = await getConfig();
157
+ // Honor a wallet client's immutable config snapshot for the expected app-id
158
+ // binding and RPC endpoint (CTA-05); otherwise read the global init() config.
159
+ const config = (_b = (_a = options === null || options === void 0 ? void 0 : options._overrides) === null || _a === void 0 ? void 0 : _a._config) !== null && _b !== void 0 ? _b : await getConfig();
224
160
  const transaction = deserializeAndValidateServerTransaction(tx.serializedTransaction, VersionedTransaction, {
225
161
  label: 'Pre-built transaction', expectedAppId: config.appId, expectedWritePaths,
226
162
  });
227
163
  const shouldSubmit = (options === null || options === void 0 ? void 0 : options.shouldSubmitTx) !== false;
228
- const rpcUrl = (_a = config.rpcUrl) === null || _a === void 0 ? void 0 : _a.trim();
164
+ const rpcUrl = (_c = config.rpcUrl) === null || _c === void 0 ? void 0 : _c.trim();
229
165
  if (shouldSubmit && !rpcUrl)
230
166
  throw new Error(`Pre-built Solana transaction submission requires init({ rpcUrl }) for ${tx.network}`);
231
167
  const signedTx = await authProvider.signTransaction(transaction);
@@ -241,22 +177,22 @@ async function handlePreBuiltTransaction(tx, authProvider, options, expectedWrit
241
177
  // #310: "confirmed" only means the network recorded the transaction, not that it
242
178
  // succeeded - a landed-but-failed transaction carries an err. Report it as a failure
243
179
  // (with on-chain logs) instead of a fake success, mirroring the server keypair provider.
244
- if ((_b = confirmation.value) === null || _b === void 0 ? void 0 : _b.err) {
180
+ if ((_d = confirmation.value) === null || _d === void 0 ? void 0 : _d.err) {
245
181
  const txInfo = await connection.getTransaction(signature, {
246
182
  maxSupportedTransactionVersion: 0,
247
183
  commitment: 'confirmed',
248
184
  });
249
- const logMessages = (_c = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _c === void 0 ? void 0 : _c.logMessages;
185
+ const logMessages = (_e = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _e === void 0 ? void 0 : _e.logMessages;
250
186
  const errorMessage = logMessages ? JSON.stringify(logMessages) : JSON.stringify(confirmation.value.err);
251
187
  throw new Error(`Transaction failed: ${errorMessage}`);
252
188
  }
253
189
  return {
254
190
  transactionSignature: signature,
255
191
  signedTransaction: bufferExports.Buffer.from(rawTx).toString('base64'),
256
- blockNumber: (_e = (_d = confirmation.context) === null || _d === void 0 ? void 0 : _d.slot) !== null && _e !== void 0 ? _e : 0,
192
+ blockNumber: (_g = (_f = confirmation.context) === null || _f === void 0 ? void 0 : _f.slot) !== null && _g !== void 0 ? _g : 0,
257
193
  gasUsed: '0',
258
194
  };
259
195
  }
260
196
 
261
- export { handlePreBuiltTransaction, handleSolanaTransaction };
262
- //# sourceMappingURL=solana-operations-B2Oy9T7D.mjs.map
197
+ export { handlePreBuiltTransaction };
198
+ //# sourceMappingURL=solana-operations-BlCYbdiN.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-operations-BlCYbdiN.mjs","sources":["../.rollup-tmp/client/solana-operations.js"],"sourcesContent":["import { Buffer } from 'buffer';\nimport { getConfig } from './config';\nconst BOUNDED_PROGRAM_MAINNET = ['open', 'Tv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F'].join('');\nconst BOUNDED_PROGRAM_DEVNET = ['open', 'Tv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F'].join('');\nconst COMPUTE_BUDGET_PROGRAM = 'ComputeBudget111111111111111111111111111111';\nconst SYSTEM_PROGRAM_ID = '11111111111111111111111111111111';\nconst ALLOWED_SERVER_TX_PROGRAMS = new Set([\n BOUNDED_PROGRAM_MAINNET,\n BOUNDED_PROGRAM_DEVNET,\n COMPUTE_BUDGET_PROGRAM,\n SYSTEM_PROGRAM_ID,\n]);\n// Canonical set_documents discriminator (single wire format: ra_indices Vec<u8>).\nconst SET_DOCUMENTS_DISCRIMINATOR = '79,46,72,73,24,79,66,245';\nconst ALLOWED_BOUNDED_SET_DISCRIMINATORS = new Set([\n SET_DOCUMENTS_DISCRIMINATOR,\n]);\nclass BorshCursor {\n constructor(data, offset, label) {\n this.data = data;\n this.offset = offset;\n this.label = label;\n }\n requireBytes(length, field) {\n if (this.offset + length > this.data.length) {\n throw new Error(`${this.label} has malformed Bounded instruction data while reading ${field}`);\n }\n }\n readU8(field) { this.requireBytes(1, field); return this.data[this.offset++]; }\n readU32(field) {\n this.requireBytes(4, field);\n const value = this.data[this.offset] | (this.data[this.offset + 1] << 8) |\n (this.data[this.offset + 2] << 16) | (this.data[this.offset + 3] << 24);\n this.offset += 4;\n return value >>> 0;\n }\n skip(length, field) { this.requireBytes(length, field); this.offset += length; }\n readString(field) {\n const length = this.readU32(`${field} length`);\n this.requireBytes(length, field);\n const raw = this.data.slice(this.offset, this.offset + length);\n this.offset += length;\n return Buffer.from(raw).toString('utf8');\n }\n skipBytes(field) { this.skip(this.readU32(`${field} length`), field); }\n isAtEnd() { return this.offset === this.data.length; }\n}\nfunction skipBoundedFieldValue(cursor) {\n const option = cursor.readU8('operation value option');\n if (option === 0)\n return;\n if (option !== 1)\n throw new Error('Server transaction has malformed Bounded field value option');\n const variant = cursor.readU8('operation value variant');\n if (variant === 0 || variant === 1)\n cursor.skip(8, 'operation numeric value');\n else if (variant === 2)\n cursor.skip(1, 'operation bool value');\n else if (variant === 3)\n cursor.readString('operation string value');\n else if (variant === 4)\n cursor.skip(32, 'operation address value');\n else\n throw new Error(`Server transaction has unsupported Bounded field value variant: ${variant}`);\n}\nfunction normalizeOnchainPath(path) {\n let normalized = path.startsWith('/') ? path.slice(1) : path;\n if (normalized.endsWith('*') && normalized.length > 1)\n normalized = normalized.slice(0, -1);\n if (normalized.endsWith('/'))\n normalized = normalized.slice(0, -1);\n return normalized;\n}\nfunction parseBoundedSetDocumentsInstruction(data, label) {\n if (data.length < 8)\n throw new Error(`${label} has malformed Bounded instruction data`);\n const discriminator = Array.from(data.slice(0, 8)).join(',');\n if (!ALLOWED_BOUNDED_SET_DISCRIMINATORS.has(discriminator)) {\n throw new Error(`${label} contains unsupported Bounded instruction`);\n }\n const cursor = new BorshCursor(data, 8, label);\n const appId = cursor.readString('appId');\n const documentPaths = [];\n const documentCount = cursor.readU32('documents length');\n for (let i = 0; i < documentCount; i++) {\n documentPaths.push(normalizeOnchainPath(cursor.readString('document path')));\n const operationCount = cursor.readU32('operations length');\n for (let j = 0; j < operationCount; j++) {\n cursor.readString('operation key');\n skipBoundedFieldValue(cursor);\n cursor.skip(1, 'operation kind');\n }\n }\n const deletePaths = [];\n const deleteCount = cursor.readU32('delete paths length');\n for (let i = 0; i < deleteCount; i++)\n deletePaths.push(normalizeOnchainPath(cursor.readString('delete path')));\n const txDataCount = cursor.readU32('txData length');\n for (let i = 0; i < txDataCount; i++) {\n cursor.readString('txData plugin function key');\n cursor.skipBytes('txData bytes');\n cursor.skipBytes('txData raIndices');\n }\n const simulate = cursor.readU8('simulate');\n if (simulate !== 0 && simulate !== 1)\n throw new Error(`${label} has malformed Bounded simulate flag`);\n if (!cursor.isAtEnd())\n throw new Error(`${label} has trailing Bounded instruction data`);\n return { appId, documentPaths, deletePaths };\n}\nfunction assertSamePathSet(label, expectedPaths, actualPaths) {\n const expected = new Set(expectedPaths.map(normalizeOnchainPath).filter(Boolean));\n const actual = new Set(actualPaths.map(normalizeOnchainPath).filter(Boolean));\n const missing = [...expected].filter(path => !actual.has(path));\n const extra = [...actual].filter(path => !expected.has(path));\n if (missing.length || extra.length) {\n const details = [missing.length ? `missing paths: ${missing.join(', ')}` : '', extra.length ? `unexpected paths: ${extra.join(', ')}` : '']\n .filter(Boolean).join('; ');\n throw new Error(`${label} Bounded instruction paths do not match requested write paths (${details})`);\n }\n}\nfunction deserializeAndValidateServerTransaction(serializedTransaction, VersionedTransactionClass, options) {\n var _a;\n const transaction = VersionedTransactionClass.deserialize(Buffer.from(serializedTransaction, 'base64'));\n const { label, expectedAppId, expectedWritePaths } = options;\n const accountKeys = transaction.message.staticAccountKeys;\n let boundedInstructionCount = 0;\n const actualWritePaths = [];\n for (const ix of transaction.message.compiledInstructions) {\n if (ix.programIdIndex >= accountKeys.length)\n throw new Error(`${label} has program ID in lookup table (not allowed)`);\n const programId = accountKeys[ix.programIdIndex].toBase58();\n if (!ALLOWED_SERVER_TX_PROGRAMS.has(programId))\n throw new Error(`${label} contains unauthorized program: ${programId}`);\n const data = ix.data instanceof Uint8Array ? ix.data : Buffer.from((_a = ix.data) !== null && _a !== void 0 ? _a : []);\n if (programId === SYSTEM_PROGRAM_ID)\n throw new Error(`${label} contains unauthorized System Program instruction`);\n if (programId === BOUNDED_PROGRAM_MAINNET || programId === BOUNDED_PROGRAM_DEVNET) {\n boundedInstructionCount++;\n const parsed = parseBoundedSetDocumentsInstruction(data, label);\n if (parsed.appId !== expectedAppId)\n throw new Error(`${label} Bounded instruction appId does not match configured appId`);\n actualWritePaths.push(...parsed.documentPaths, ...parsed.deletePaths);\n }\n }\n if (boundedInstructionCount !== 1)\n throw new Error(`${label} must contain exactly one Bounded set-documents instruction`);\n assertSamePathSet(label, expectedWritePaths, actualWritePaths);\n return transaction;\n}\nexport async function handlePreBuiltTransaction(tx, authProvider, options, expectedWritePaths) {\n var _a, _b, _c, _d, _e, _f, _g;\n const { Connection, VersionedTransaction } = await import(\"@solana/web3.js\");\n // Honor a wallet client's immutable config snapshot for the expected app-id\n // binding and RPC endpoint (CTA-05); otherwise read the global init() config.\n const config = (_b = (_a = options === null || options === void 0 ? void 0 : options._overrides) === null || _a === void 0 ? void 0 : _a._config) !== null && _b !== void 0 ? _b : await getConfig();\n const transaction = deserializeAndValidateServerTransaction(tx.serializedTransaction, VersionedTransaction, {\n label: 'Pre-built transaction', expectedAppId: config.appId, expectedWritePaths,\n });\n const shouldSubmit = (options === null || options === void 0 ? void 0 : options.shouldSubmitTx) !== false;\n const rpcUrl = (_c = config.rpcUrl) === null || _c === void 0 ? void 0 : _c.trim();\n if (shouldSubmit && !rpcUrl)\n throw new Error(`Pre-built Solana transaction submission requires init({ rpcUrl }) for ${tx.network}`);\n const signedTx = await authProvider.signTransaction(transaction);\n const rawTx = signedTx.serialize();\n if (!shouldSubmit) {\n return { transactionSignature: '', signedTransaction: Buffer.from(rawTx).toString('base64'), blockNumber: 0, gasUsed: '0' };\n }\n const connection = new Connection(rpcUrl, 'confirmed');\n const signature = await connection.sendRawTransaction(rawTx, { skipPreflight: false, maxRetries: 3 });\n const confirmation = await connection.confirmTransaction({\n signature, blockhash: tx.blockhash, lastValidBlockHeight: tx.lastValidBlockHeight,\n }, 'confirmed');\n // #310: \"confirmed\" only means the network recorded the transaction, not that it\n // succeeded - a landed-but-failed transaction carries an err. Report it as a failure\n // (with on-chain logs) instead of a fake success, mirroring the server keypair provider.\n if ((_d = confirmation.value) === null || _d === void 0 ? void 0 : _d.err) {\n const txInfo = await connection.getTransaction(signature, {\n maxSupportedTransactionVersion: 0,\n commitment: 'confirmed',\n });\n const logMessages = (_e = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _e === void 0 ? void 0 : _e.logMessages;\n const errorMessage = logMessages ? JSON.stringify(logMessages) : JSON.stringify(confirmation.value.err);\n throw new Error(`Transaction failed: ${errorMessage}`);\n }\n return {\n transactionSignature: signature,\n signedTransaction: Buffer.from(rawTx).toString('base64'),\n blockNumber: (_g = (_f = confirmation.context) === null || _f === void 0 ? void 0 : _f.slot) !== null && _g !== void 0 ? _g : 0,\n gasUsed: '0',\n };\n}\n"],"names":["Buffer"],"mappings":";;;;;AAEA,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,yCAAyC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAC5F,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,yCAAyC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAC3F,MAAM,sBAAsB,GAAG,6CAA6C;AAC5E,MAAM,iBAAiB,GAAG,kCAAkC;AAC5D,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAAC;AAC3C,IAAI,uBAAuB;AAC3B,IAAI,sBAAsB;AAC1B,IAAI,sBAAsB;AAC1B,IAAI,iBAAiB;AACrB,CAAC,CAAC;AACF;AACA,MAAM,2BAA2B,GAAG,0BAA0B;AAC9D,MAAM,kCAAkC,GAAG,IAAI,GAAG,CAAC;AACnD,IAAI,2BAA2B;AAC/B,CAAC,CAAC;AACF,MAAM,WAAW,CAAC;AAClB,IAAI,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE;AACrC,QAAQ,IAAI,CAAC,IAAI,GAAG,IAAI;AACxB,QAAQ,IAAI,CAAC,MAAM,GAAG,MAAM;AAC5B,QAAQ,IAAI,CAAC,KAAK,GAAG,KAAK;AAC1B,IAAI;AACJ,IAAI,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE;AAChC,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;AACrD,YAAY,MAAM,IAAI,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,sDAAsD,EAAE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AY,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC;AACvI,QAAQ,OAAO,EAAE,GAAG;AACpB,KAAK;AACL;;;;"}
@@ -1,10 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-BIdD2yUB.js');
3
+ var index = require('./index-C8ocsC_W.js');
4
4
  require('axios');
5
5
  require('tweetnacl');
6
6
  require('reconnecting-websocket');
7
- require('bn.js');
8
7
 
9
8
  const BOUNDED_PROGRAM_MAINNET = ['open', 'Tv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F'].join('');
10
9
  const BOUNDED_PROGRAM_DEVNET = ['open', 'Tv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F'].join('');
@@ -154,80 +153,17 @@ function deserializeAndValidateServerTransaction(serializedTransaction, Versione
154
153
  assertSamePathSet(label, expectedWritePaths, actualWritePaths);
155
154
  return transaction;
156
155
  }
157
- function isHexString(value) {
158
- if (typeof value !== 'string')
159
- return false;
160
- const testValue = value.startsWith('-') ? value.slice(1) : value;
161
- return /^(0x)?[0-9a-fA-F]+$/.test(testValue);
162
- }
163
- async function handleSolanaTransaction(tx, authProvider, options, expectedWritePaths) {
164
- var _a, _b, _c, _d, _e;
165
- const chainSdk = await import('@solana/web3.js');
166
- const { PublicKey, SystemProgram, TransactionInstruction, VersionedTransaction } = chainSdk;
167
- const solTransactionData = {
168
- remainingAccounts: tx.remainingAccounts,
169
- setDocumentData: tx.transactionArgs.setDocumentData,
170
- deletePaths: tx.transactionArgs.deletePaths,
171
- idl: tx.idl,
172
- txData: (_b = (_a = tx.txData) === null || _a === void 0 ? void 0 : _a.map((txData) => ({
173
- pluginFunctionKey: txData.pluginFunctionKey,
174
- txData: index.bufferExports.Buffer.from(txData.txData),
175
- raIndices: (() => {
176
- const raw = txData.raIndices;
177
- if (raw == null)
178
- return index.bufferExports.Buffer.alloc(0);
179
- if (index.bufferExports.Buffer.isBuffer(raw))
180
- return raw;
181
- if (raw instanceof Uint8Array)
182
- return index.bufferExports.Buffer.from(raw);
183
- const arrayLike = Array.isArray(raw) ? raw :
184
- raw && typeof raw === 'object' && Array.isArray(raw.data) ? raw.data :
185
- (() => { throw new Error(`raIndices has unexpected shape: ${typeof raw}`); })();
186
- return index.bufferExports.Buffer.from(arrayLike.map((raIndex) => {
187
- const value = isHexString(raIndex) ? parseInt(raIndex, 16) : Number(raIndex);
188
- if (!Number.isInteger(value) || value < 0 || value > 255) {
189
- throw new Error(`raIndex ${raIndex} is not a valid u8 (must be integer in 0..255)`);
190
- }
191
- return value;
192
- }));
193
- })(),
194
- }))) !== null && _b !== void 0 ? _b : [],
195
- };
196
- const config = await index.getConfig();
197
- if (tx.signedTransaction) {
198
- deserializeAndValidateServerTransaction(tx.signedTransaction, VersionedTransaction, {
199
- label: 'Server signedTransaction', expectedAppId: config.appId, expectedWritePaths,
200
- });
201
- }
202
- const solTransaction = {
203
- appId: config.appId,
204
- txArgs: [solTransactionData],
205
- lutKey: (_c = tx.lutAddress) !== null && _c !== void 0 ? _c : null,
206
- additionalLutAddresses: tx.additionalLutAddresses,
207
- network: tx.network,
208
- preInstructions: (_e = (_d = tx.preInstructions) === null || _d === void 0 ? void 0 : _d.map((ix, index$1) => {
209
- var _a;
210
- const keys = (_a = ix.keys) === null || _a === void 0 ? void 0 : _a.map((key) => ({ pubkey: new PublicKey(key.pubkey), isSigner: key.isSigner, isWritable: key.isWritable }));
211
- const programId = ix.programId === SYSTEM_PROGRAM_ID ? SystemProgram.programId : new PublicKey(ix.programId);
212
- const instruction = new TransactionInstruction({ keys, programId, data: index.bufferExports.Buffer.from(ix.data) });
213
- if (instruction.programId.equals(SystemProgram.programId)) {
214
- throw new Error(`Server preInstruction[${index$1}] contains unauthorized System Program preInstruction`);
215
- }
216
- return instruction;
217
- })) !== null && _e !== void 0 ? _e : [],
218
- signedTransaction: tx.signedTransaction,
219
- };
220
- return authProvider.runTransaction(undefined, solTransaction, options);
221
- }
222
156
  async function handlePreBuiltTransaction(tx, authProvider, options, expectedWritePaths) {
223
- var _a, _b, _c, _d, _e;
157
+ var _a, _b, _c, _d, _e, _f, _g;
224
158
  const { Connection, VersionedTransaction } = await import('@solana/web3.js');
225
- const config = await index.getConfig();
159
+ // Honor a wallet client's immutable config snapshot for the expected app-id
160
+ // binding and RPC endpoint (CTA-05); otherwise read the global init() config.
161
+ const config = (_b = (_a = options === null || options === void 0 ? void 0 : options._overrides) === null || _a === void 0 ? void 0 : _a._config) !== null && _b !== void 0 ? _b : await index.getConfig();
226
162
  const transaction = deserializeAndValidateServerTransaction(tx.serializedTransaction, VersionedTransaction, {
227
163
  label: 'Pre-built transaction', expectedAppId: config.appId, expectedWritePaths,
228
164
  });
229
165
  const shouldSubmit = (options === null || options === void 0 ? void 0 : options.shouldSubmitTx) !== false;
230
- const rpcUrl = (_a = config.rpcUrl) === null || _a === void 0 ? void 0 : _a.trim();
166
+ const rpcUrl = (_c = config.rpcUrl) === null || _c === void 0 ? void 0 : _c.trim();
231
167
  if (shouldSubmit && !rpcUrl)
232
168
  throw new Error(`Pre-built Solana transaction submission requires init({ rpcUrl }) for ${tx.network}`);
233
169
  const signedTx = await authProvider.signTransaction(transaction);
@@ -243,23 +179,22 @@ async function handlePreBuiltTransaction(tx, authProvider, options, expectedWrit
243
179
  // #310: "confirmed" only means the network recorded the transaction, not that it
244
180
  // succeeded - a landed-but-failed transaction carries an err. Report it as a failure
245
181
  // (with on-chain logs) instead of a fake success, mirroring the server keypair provider.
246
- if ((_b = confirmation.value) === null || _b === void 0 ? void 0 : _b.err) {
182
+ if ((_d = confirmation.value) === null || _d === void 0 ? void 0 : _d.err) {
247
183
  const txInfo = await connection.getTransaction(signature, {
248
184
  maxSupportedTransactionVersion: 0,
249
185
  commitment: 'confirmed',
250
186
  });
251
- const logMessages = (_c = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _c === void 0 ? void 0 : _c.logMessages;
187
+ const logMessages = (_e = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _e === void 0 ? void 0 : _e.logMessages;
252
188
  const errorMessage = logMessages ? JSON.stringify(logMessages) : JSON.stringify(confirmation.value.err);
253
189
  throw new Error(`Transaction failed: ${errorMessage}`);
254
190
  }
255
191
  return {
256
192
  transactionSignature: signature,
257
193
  signedTransaction: index.bufferExports.Buffer.from(rawTx).toString('base64'),
258
- blockNumber: (_e = (_d = confirmation.context) === null || _d === void 0 ? void 0 : _d.slot) !== null && _e !== void 0 ? _e : 0,
194
+ blockNumber: (_g = (_f = confirmation.context) === null || _f === void 0 ? void 0 : _f.slot) !== null && _g !== void 0 ? _g : 0,
259
195
  gasUsed: '0',
260
196
  };
261
197
  }
262
198
 
263
199
  exports.handlePreBuiltTransaction = handlePreBuiltTransaction;
264
- exports.handleSolanaTransaction = handleSolanaTransaction;
265
- //# sourceMappingURL=solana-operations-ngqIkN9W.js.map
200
+ //# sourceMappingURL=solana-operations-CYpu6EU8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solana-operations-CYpu6EU8.js","sources":["../.rollup-tmp/client/solana-operations.js"],"sourcesContent":["import { Buffer } from 'buffer';\nimport { getConfig } from './config';\nconst BOUNDED_PROGRAM_MAINNET = ['open', 'Tv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F'].join('');\nconst BOUNDED_PROGRAM_DEVNET = ['open', 'Tv7fbpYSseNHYmCZFZ1CZgj4r8D9fKNgEz1qo6F'].join('');\nconst COMPUTE_BUDGET_PROGRAM = 'ComputeBudget111111111111111111111111111111';\nconst SYSTEM_PROGRAM_ID = '11111111111111111111111111111111';\nconst ALLOWED_SERVER_TX_PROGRAMS = new Set([\n BOUNDED_PROGRAM_MAINNET,\n BOUNDED_PROGRAM_DEVNET,\n COMPUTE_BUDGET_PROGRAM,\n SYSTEM_PROGRAM_ID,\n]);\n// Canonical set_documents discriminator (single wire format: ra_indices Vec<u8>).\nconst SET_DOCUMENTS_DISCRIMINATOR = '79,46,72,73,24,79,66,245';\nconst ALLOWED_BOUNDED_SET_DISCRIMINATORS = new Set([\n SET_DOCUMENTS_DISCRIMINATOR,\n]);\nclass BorshCursor {\n constructor(data, offset, label) {\n this.data = data;\n this.offset = offset;\n this.label = label;\n }\n requireBytes(length, field) {\n if (this.offset + length > this.data.length) {\n throw new Error(`${this.label} has malformed Bounded instruction data while reading ${field}`);\n }\n }\n readU8(field) { this.requireBytes(1, field); return this.data[this.offset++]; }\n readU32(field) {\n this.requireBytes(4, field);\n const value = this.data[this.offset] | (this.data[this.offset + 1] << 8) |\n (this.data[this.offset + 2] << 16) | (this.data[this.offset + 3] << 24);\n this.offset += 4;\n return value >>> 0;\n }\n skip(length, field) { this.requireBytes(length, field); this.offset += length; }\n readString(field) {\n const length = this.readU32(`${field} length`);\n this.requireBytes(length, field);\n const raw = this.data.slice(this.offset, this.offset + length);\n this.offset += length;\n return Buffer.from(raw).toString('utf8');\n }\n skipBytes(field) { this.skip(this.readU32(`${field} length`), field); }\n isAtEnd() { return this.offset === this.data.length; }\n}\nfunction skipBoundedFieldValue(cursor) {\n const option = cursor.readU8('operation value option');\n if (option === 0)\n return;\n if (option !== 1)\n throw new Error('Server transaction has malformed Bounded field value option');\n const variant = cursor.readU8('operation value variant');\n if (variant === 0 || variant === 1)\n cursor.skip(8, 'operation numeric value');\n else if (variant === 2)\n cursor.skip(1, 'operation bool value');\n else if (variant === 3)\n cursor.readString('operation string value');\n else if (variant === 4)\n cursor.skip(32, 'operation address value');\n else\n throw new Error(`Server transaction has unsupported Bounded field value variant: ${variant}`);\n}\nfunction normalizeOnchainPath(path) {\n let normalized = path.startsWith('/') ? path.slice(1) : path;\n if (normalized.endsWith('*') && normalized.length > 1)\n normalized = normalized.slice(0, -1);\n if (normalized.endsWith('/'))\n normalized = normalized.slice(0, -1);\n return normalized;\n}\nfunction parseBoundedSetDocumentsInstruction(data, label) {\n if (data.length < 8)\n throw new Error(`${label} has malformed Bounded instruction data`);\n const discriminator = Array.from(data.slice(0, 8)).join(',');\n if (!ALLOWED_BOUNDED_SET_DISCRIMINATORS.has(discriminator)) {\n throw new Error(`${label} contains unsupported Bounded instruction`);\n }\n const cursor = new BorshCursor(data, 8, label);\n const appId = cursor.readString('appId');\n const documentPaths = [];\n const documentCount = cursor.readU32('documents length');\n for (let i = 0; i < documentCount; i++) {\n documentPaths.push(normalizeOnchainPath(cursor.readString('document path')));\n const operationCount = cursor.readU32('operations length');\n for (let j = 0; j < operationCount; j++) {\n cursor.readString('operation key');\n skipBoundedFieldValue(cursor);\n cursor.skip(1, 'operation kind');\n }\n }\n const deletePaths = [];\n const deleteCount = cursor.readU32('delete paths length');\n for (let i = 0; i < deleteCount; i++)\n deletePaths.push(normalizeOnchainPath(cursor.readString('delete path')));\n const txDataCount = cursor.readU32('txData length');\n for (let i = 0; i < txDataCount; i++) {\n cursor.readString('txData plugin function key');\n cursor.skipBytes('txData bytes');\n cursor.skipBytes('txData raIndices');\n }\n const simulate = cursor.readU8('simulate');\n if (simulate !== 0 && simulate !== 1)\n throw new Error(`${label} has malformed Bounded simulate flag`);\n if (!cursor.isAtEnd())\n throw new Error(`${label} has trailing Bounded instruction data`);\n return { appId, documentPaths, deletePaths };\n}\nfunction assertSamePathSet(label, expectedPaths, actualPaths) {\n const expected = new Set(expectedPaths.map(normalizeOnchainPath).filter(Boolean));\n const actual = new Set(actualPaths.map(normalizeOnchainPath).filter(Boolean));\n const missing = [...expected].filter(path => !actual.has(path));\n const extra = [...actual].filter(path => !expected.has(path));\n if (missing.length || extra.length) {\n const details = [missing.length ? `missing paths: ${missing.join(', ')}` : '', extra.length ? `unexpected paths: ${extra.join(', ')}` : '']\n .filter(Boolean).join('; ');\n throw new Error(`${label} Bounded instruction paths do not match requested write paths (${details})`);\n }\n}\nfunction deserializeAndValidateServerTransaction(serializedTransaction, VersionedTransactionClass, options) {\n var _a;\n const transaction = VersionedTransactionClass.deserialize(Buffer.from(serializedTransaction, 'base64'));\n const { label, expectedAppId, expectedWritePaths } = options;\n const accountKeys = transaction.message.staticAccountKeys;\n let boundedInstructionCount = 0;\n const actualWritePaths = [];\n for (const ix of transaction.message.compiledInstructions) {\n if (ix.programIdIndex >= accountKeys.length)\n throw new Error(`${label} has program ID in lookup table (not allowed)`);\n const programId = accountKeys[ix.programIdIndex].toBase58();\n if (!ALLOWED_SERVER_TX_PROGRAMS.has(programId))\n throw new Error(`${label} contains unauthorized program: ${programId}`);\n const data = ix.data instanceof Uint8Array ? ix.data : Buffer.from((_a = ix.data) !== null && _a !== void 0 ? _a : []);\n if (programId === SYSTEM_PROGRAM_ID)\n throw new Error(`${label} contains unauthorized System Program instruction`);\n if (programId === BOUNDED_PROGRAM_MAINNET || programId === BOUNDED_PROGRAM_DEVNET) {\n boundedInstructionCount++;\n const parsed = parseBoundedSetDocumentsInstruction(data, label);\n if (parsed.appId !== expectedAppId)\n throw new Error(`${label} Bounded instruction appId does not match configured appId`);\n actualWritePaths.push(...parsed.documentPaths, ...parsed.deletePaths);\n }\n }\n if (boundedInstructionCount !== 1)\n throw new Error(`${label} must contain exactly one Bounded set-documents instruction`);\n assertSamePathSet(label, expectedWritePaths, actualWritePaths);\n return transaction;\n}\nexport async function handlePreBuiltTransaction(tx, authProvider, options, expectedWritePaths) {\n var _a, _b, _c, _d, _e, _f, _g;\n const { Connection, VersionedTransaction } = await import(\"@solana/web3.js\");\n // Honor a wallet client's immutable config snapshot for the expected app-id\n // binding and RPC endpoint (CTA-05); otherwise read the global init() config.\n const config = (_b = (_a = options === null || options === void 0 ? void 0 : options._overrides) === null || _a === void 0 ? void 0 : _a._config) !== null && _b !== void 0 ? _b : await getConfig();\n const transaction = deserializeAndValidateServerTransaction(tx.serializedTransaction, VersionedTransaction, {\n label: 'Pre-built transaction', expectedAppId: config.appId, expectedWritePaths,\n });\n const shouldSubmit = (options === null || options === void 0 ? void 0 : options.shouldSubmitTx) !== false;\n const rpcUrl = (_c = config.rpcUrl) === null || _c === void 0 ? void 0 : _c.trim();\n if (shouldSubmit && !rpcUrl)\n throw new Error(`Pre-built Solana transaction submission requires init({ rpcUrl }) for ${tx.network}`);\n const signedTx = await authProvider.signTransaction(transaction);\n const rawTx = signedTx.serialize();\n if (!shouldSubmit) {\n return { transactionSignature: '', signedTransaction: Buffer.from(rawTx).toString('base64'), blockNumber: 0, gasUsed: '0' };\n }\n const connection = new Connection(rpcUrl, 'confirmed');\n const signature = await connection.sendRawTransaction(rawTx, { skipPreflight: false, maxRetries: 3 });\n const confirmation = await connection.confirmTransaction({\n signature, blockhash: tx.blockhash, lastValidBlockHeight: tx.lastValidBlockHeight,\n }, 'confirmed');\n // #310: \"confirmed\" only means the network recorded the transaction, not that it\n // succeeded - a landed-but-failed transaction carries an err. Report it as a failure\n // (with on-chain logs) instead of a fake success, mirroring the server keypair provider.\n if ((_d = confirmation.value) === null || _d === void 0 ? void 0 : _d.err) {\n const txInfo = await connection.getTransaction(signature, {\n maxSupportedTransactionVersion: 0,\n commitment: 'confirmed',\n });\n const logMessages = (_e = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _e === void 0 ? void 0 : _e.logMessages;\n const errorMessage = logMessages ? JSON.stringify(logMessages) : JSON.stringify(confirmation.value.err);\n throw new Error(`Transaction failed: ${errorMessage}`);\n }\n return {\n transactionSignature: signature,\n signedTransaction: Buffer.from(rawTx).toString('base64'),\n blockNumber: (_g = (_f = confirmation.context) === null || _f === void 0 ? void 0 : _f.slot) !== null && _g !== void 0 ? _g : 0,\n gasUsed: '0',\n };\n}\n"],"names":["Buffer","getConfig"],"mappings":";;;;;;;AAEA,MAAM,uBAAuB,GAAG,CAAC,MAAM,EAAE,yCAAyC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAC5F,MAAM,sBAAsB,GAAG,CAAC,MAAM,EAAE,yCAAyC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AAC3F,MAA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AM,GAAG,MAAM,UAAU,CAAC,cAAc,CAAC,SAAS,EAAE;AAClE,YAAY,8BAA8B,EAAE,CAAC;AAC7C,YAAY,UAAU,EAAE,WAAW;AACnC,SAAS,CAAC;AACV,QAAQ,MAAM,WAAW,GAAG,CAAC,EAAE,GAAG,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,IAAI,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,WAAW;AAClJ,QAAQ,MAAM,YAAY,GAAG,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC;AAC/G,QAAQ,MAAM,IAAI,KAAK,CAAC,CAAC,oBAAoB,EAAE,YAAY,CAAC,CAAC,CAAC;AAC9D,IAAI;AACJ,IAAI,OAAO;AACX,QAAQ,oBAAoB,EAAE,SAAS;AACvC,QAAQ,iBAAiB,EAAEA,0BAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAChE,QAAQ,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,YAAY,CAAC,OAAO,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,IAAI,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC;AACvI,QAAQ,OAAO,EAAE,GAAG;AACpB,KAAK;AACL;;;;"}
@@ -1,5 +1,18 @@
1
+ import { type ClientConfig } from '../client/config';
2
+ /**
3
+ * The immutable subset of a resolved {@link ClientConfig} a session mint needs:
4
+ * the target app and its wallet/SIWS issuer, plus the configured auth method.
5
+ *
6
+ * A server `WalletClient` snapshots this at construction and threads it into
7
+ * every nonce/session/refresh call so the mint is BOUND to the app+issuer the
8
+ * client was created against. Without it, `genAuthNonce`/`createSessionWithSignature`
9
+ * read the mutable process-global config, so a later `init(...)` for a different
10
+ * app or environment would silently retarget the wallet client's session mint
11
+ * (CTA-05).
12
+ */
13
+ export type SessionMintConfig = Pick<ClientConfig, 'appId' | 'authApiUrl' | 'authMethod'>;
1
14
  export declare function genNonce(): Promise<any>;
2
- export declare function genAuthNonce(): Promise<any>;
15
+ export declare function genAuthNonce(sessionConfig?: SessionMintConfig): Promise<any>;
3
16
  /**
4
17
  * Exchange a wallet signature for a Bounded session at the /session issuer.
5
18
  *
@@ -9,7 +22,7 @@ export declare function genAuthNonce(): Promise<any>;
9
22
  * Solana wallet/guest method passes through verbatim, and anything else
10
23
  * defaults to the canonical 'phantom' the issuer accepts for a signature.
11
24
  */
12
- export declare function createSessionWithSignature(address: string, message: string, signature: string, authMethodOverride?: string): Promise<any>;
25
+ export declare function createSessionWithSignature(address: string, message: string, signature: string, authMethodOverride?: string, sessionConfig?: SessionMintConfig): Promise<any>;
13
26
  export declare function refreshSession(refreshToken: string, issuer?: string): Promise<any>;
14
27
  export declare class SessionRevokeError extends Error {
15
28
  readonly cause?: unknown;
@@ -13,13 +13,24 @@ import { type CommitResult, type ExpectedSession } from "./session-mutation";
13
13
  /**
14
14
  * Synchronous storage adapter for React Native session persistence.
15
15
  *
16
- * **Security: tokens (access, identity, refresh) are stored as plaintext JSON.**
17
- * Use an encrypted storage backend in production — for example:
18
- * - MMKV with an encryption key (`new MMKV({ encryptionKey: '...' })`)
19
- * - expo-secure-store
20
- * - react-native-keychain
16
+ * The session manager writes the WHOLE credential set - access token, identity
17
+ * token, and the long-lived (rolling) REFRESH token - through this adapter as a
18
+ * single JSON string. Whatever `setItem` persists is exactly what an attacker with
19
+ * device access reads back.
21
20
  *
22
- * Plaintext token storage on a rooted/jailbroken device is a credential theft risk.
21
+ * **You MUST supply an ENCRYPTED backend.** The manager cannot introspect a
22
+ * caller-supplied adapter to confirm it encrypts at rest, so this is your
23
+ * responsibility (`allowUnsafePlaintext` on the config is the explicit escape hatch
24
+ * for the unencrypted case - see `configure()`). Supported encrypted patterns:
25
+ * - MMKV with an encryption key held in the OS keystore:
26
+ * `new MMKV({ encryptionKey })` where `encryptionKey` comes from
27
+ * react-native-keychain / expo-secure-store (NEVER a hardcoded constant)
28
+ * - expo-secure-store directly
29
+ * - react-native-keychain directly
30
+ *
31
+ * A keyless MMKV instance (constructed with no encryptionKey) or AsyncStorage is
32
+ * PLAINTEXT: on a rooted/jailbroken device or in a device backup the refresh token
33
+ * is a portable, replayable credential.
23
34
  */
24
35
  export interface RNStorageAdapter {
25
36
  getItem(key: string): string | null;
@@ -30,18 +41,49 @@ interface RNSessionConfig {
30
41
  storage: RNStorageAdapter;
31
42
  /** base64 → binary string (replaces browser atob). */
32
43
  atob: (input: string) => string;
44
+ /**
45
+ * Explicit acknowledgment that `storage` is UNENCRYPTED (plaintext).
46
+ *
47
+ * The supported/secure default is an encrypted backend (see `configure()`); the
48
+ * manager cannot verify a caller's adapter actually encrypts, so it cannot enforce
49
+ * it for you. If you deliberately supply a plaintext adapter (e.g. bare MMKV or
50
+ * AsyncStorage during development) you MUST set this to `true` to acknowledge that
51
+ * the access/identity/refresh tokens are readable from a rooted device or a device
52
+ * backup. It is a conscious-choice gate that also emits a loud one-time warning at
53
+ * `configure()`; leave it unset for any encrypted backend.
54
+ */
55
+ allowUnsafePlaintext?: boolean;
33
56
  }
34
57
  export declare class ReactNativeSessionManager {
35
58
  private static BOUNDED_SESSION_STORAGE_KEY;
36
59
  /**
37
60
  * Must be called once before any other method.
38
61
  *
62
+ * SECURITY: the persisted blob includes the long-lived refresh token, so the
63
+ * `storage` adapter MUST encrypt at rest. The supported pattern is MMKV with an
64
+ * `encryptionKey` held in the OS keystore (Keychain on iOS / Keystore on Android)
65
+ * via react-native-keychain - NOT a keyless MMKV instance, and NEVER a hardcoded key.
66
+ *
39
67
  * ```ts
40
68
  * import { ReactNativeSessionManager } from '@bounded-sh/core';
41
69
  * import { MMKV } from 'react-native-mmkv';
70
+ * import * as Keychain from 'react-native-keychain';
42
71
  * import { decode } from 'base-64';
43
72
  *
44
- * const mmkv = new MMKV();
73
+ * // Fetch (or lazily mint) a random 256-bit key stored in the OS keystore.
74
+ * // The keystore - not the app bundle - is the root of trust for the key.
75
+ * async function getMmkvEncryptionKey(): Promise<string> {
76
+ * const service = 'sh.bounded.session.mmkv';
77
+ * const existing = await Keychain.getGenericPassword({ service });
78
+ * if (existing) return existing.password;
79
+ * const bytes = crypto.getRandomValues(new Uint8Array(32));
80
+ * const key = [...bytes].map((b) => b.toString(16).padStart(2, '0')).join('');
81
+ * await Keychain.setGenericPassword('bounded', key, { service });
82
+ * return key;
83
+ * }
84
+ *
85
+ * const encryptionKey = await getMmkvEncryptionKey();
86
+ * const mmkv = new MMKV({ id: 'bounded-session', encryptionKey });
45
87
  * ReactNativeSessionManager.configure({
46
88
  * storage: {
47
89
  * getItem: (k) => mmkv.getString(k) ?? null,
@@ -51,6 +93,14 @@ export declare class ReactNativeSessionManager {
51
93
  * atob: decode,
52
94
  * });
53
95
  * ```
96
+ *
97
+ * Unencrypted adapters (bare MMKV, AsyncStorage) are a credential-theft risk and
98
+ * require an explicit opt-in - the manager cannot verify encryption for you:
99
+ *
100
+ * ```ts
101
+ * // Development only: acknowledge that tokens are stored in plaintext.
102
+ * ReactNativeSessionManager.configure({ storage, atob: decode, allowUnsafePlaintext: true });
103
+ * ```
54
104
  */
55
105
  static configure(cfg: RNSessionConfig): void;
56
106
  /**
@@ -1,4 +1,5 @@
1
1
  import type { Keypair } from "@solana/web3.js";
2
+ import { type SessionMintConfig } from "./auth-api";
2
3
  /**
3
4
  * Server-side SessionManager
4
5
  * --------------------------
@@ -21,12 +22,16 @@ export declare class ServerSessionManager {
21
22
  private generation;
22
23
  private readonly keypair;
23
24
  private readonly sessionFactory;
25
+ private readonly sessionConfig;
24
26
  private constructor();
25
27
  /**
26
28
  * Create a session manager for a specific keypair.
27
29
  * Each instance has its own independent session cache.
30
+ *
31
+ * `sessionConfig` (optional) pins the app+issuer the keypair signs/mints
32
+ * against, so re-signing after expiry never follows a later global init().
28
33
  */
29
- static forKeypair(keypair: Keypair): ServerSessionManager;
34
+ static forKeypair(keypair: Keypair, sessionConfig?: SessionMintConfig): ServerSessionManager;
30
35
  /**
31
36
  * Create an isolated server session manager for a non-Solana signer (currently
32
37
  * EVM/SIWE). The factory must perform the signature exchange and return the
@@ -1,29 +1,2 @@
1
- import type { Connection, PublicKey, Transaction, TransactionInstruction, VersionedTransaction } from "@solana/web3.js";
2
- import type { AnchorProvider } from "@coral-xyz/anchor";
3
- import type { TxData } from "./sol-utils";
4
- export type RemainingAccount = {
5
- pubkey: PublicKey;
6
- isWritable: boolean;
7
- isSigner: boolean;
8
- };
9
- /** Load the Anchor/Web3 transaction builder only when an onchain write uses it. */
10
- export declare function buildSetDocumentsTransaction(connection: Connection, idl: any, programProvider: AnchorProvider, payerPublicKey: PublicKey, args: {
11
- app_id: string;
12
- documents: {
13
- path: string;
14
- operations: {
15
- key: string;
16
- value: any;
17
- operation: number;
18
- }[];
19
- }[];
20
- delete_paths: string[];
21
- txData: TxData[];
22
- }, remainingAccounts: RemainingAccount[], lutKey: PublicKey | null, preInstructions: TransactionInstruction[], simulate: boolean, additionalLutAddresses?: string[]): Promise<{
23
- tx: VersionedTransaction | Transaction;
24
- blockhash: string;
25
- lastValidBlockHeight: number;
26
- }>;
27
1
  /** SIWS message creation is async already, so its onchain module can be lazy. */
28
2
  export declare function genSolanaMessage(address: string, nonce: string): Promise<string>;
29
- export declare function convertRemainingAccounts(remainingAccounts: any[]): RemainingAccount[];
@@ -1 +1 @@
1
- export declare function genSolanaMessage(address: string, nonce: string): Promise<string>;
1
+ export declare function genSolanaMessage(address: string, nonce: string, appIdOverride?: string): Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bounded-sh/core",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "description": "Shared client, data-plane, and transport primitives for Bounded, the full-stack app builder and runtime for AI-built apps: policy-enforced operations, files, functions, and realtime.",
5
5
  "homepage": "https://bounded.sh/docs/sdk",
6
6
  "main": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "scripts": {
17
17
  "build": "rm -rf ./dist ./.rollup-tmp && tsc -p tsconfig.build.json --outDir .rollup-tmp --declarationDir .rollup-tmp --emitDeclarationOnly false && rollup -c && tsc -p tsconfig.build.json --emitDeclarationOnly --declarationDir dist && rm -rf ./.rollup-tmp",
18
18
  "watch": "rollup -c -w",
19
- "test": "node src/client/run-config-network-test.mjs && node src/client/run-read-principal-test.mjs && node src/client/run-principal-collision-test.mjs && node src/client/run-abortable-read-test.mjs && node src/utils/run-api-abort-test.mjs && node src/utils/run-api-transient-get-retry-test.mjs && node src/utils/run-auth-api-issuer-switch-test.mjs && node src/utils/run-session-manager-binding-test.mjs && node src/utils/run-session-protocol-test.mjs && node src/utils/run-auth-token-freshness-test.mjs && node src/utils/run-api-401-recovery-test.mjs && node src/utils/run-server-session-manager-test.mjs && node src/utils/api-refresh-inflight-key.source.test.mjs && node src/client/run-row-shape-test.mjs && node src/client/run-transport-test.mjs && node src/client/run-queries-coalesce-test.mjs && node src/client/run-runexpression-overrides-test.mjs && node src/client/run-subscribe-query-test.mjs && node src/client/subscribe-query-defaults.source.test.mjs && node src/client/run-public-export-surface-test.mjs && node src/client/run-live-auth-test.mjs && node src/client/run-live-view-principal-test.mjs && node src/client/run-subscription-auth-error-test.mjs && node src/client/run-subscription-confirmation-retry-test.mjs && node src/client/subscription-handoff-grace.source.test.mjs && node src/client/run-onchain-validation-test.mjs && node src/client/run-evm-dispatch-test.mjs && node src/utils/evm/run-evm-utils-test.mjs && node src/client/websocket-auth-url.test.mjs && node src/client/run-create-client-http-test.mjs && node src/client/run-create-client-subscribe-test.mjs",
19
+ "test": "node src/client/run-config-network-test.mjs && node src/client/run-read-principal-test.mjs && node src/client/run-principal-collision-test.mjs && node src/client/run-abortable-read-test.mjs && node src/utils/run-api-abort-test.mjs && node src/utils/run-api-transient-get-retry-test.mjs && node src/utils/run-auth-api-issuer-switch-test.mjs && node src/utils/run-auth-api-server-credential-test.mjs && node src/utils/run-session-manager-binding-test.mjs && node src/utils/rn-session-manager-example.source.test.mjs && node src/utils/run-session-protocol-test.mjs && node src/utils/run-auth-token-freshness-test.mjs && node src/utils/run-api-401-recovery-test.mjs && node src/utils/run-server-session-manager-test.mjs && node src/utils/api-refresh-inflight-key.source.test.mjs && node src/client/run-row-shape-test.mjs && node src/client/run-transport-test.mjs && node src/client/run-queries-coalesce-test.mjs && node src/client/run-runexpression-overrides-test.mjs && node src/client/run-subscribe-query-test.mjs && node src/client/subscribe-query-defaults.source.test.mjs && node src/client/run-public-export-surface-test.mjs && node src/client/run-live-auth-test.mjs && node src/client/run-live-view-principal-test.mjs && node src/client/run-subscription-auth-error-test.mjs && node src/client/run-subscription-confirmation-retry-test.mjs && node src/client/subscription-handoff-grace.source.test.mjs && node src/client/run-onchain-validation-test.mjs && node src/client/run-evm-dispatch-test.mjs && node src/utils/evm/run-evm-utils-test.mjs && node src/client/websocket-auth-url.test.mjs && node src/client/run-create-client-http-test.mjs && node src/client/run-create-client-subscribe-test.mjs && node src/client/run-wallet-config-binding-test.mjs",
20
20
  "prepare": "npm run build"
21
21
  },
22
22
  "files": [