@pooflabs/web 0.0.92 → 0.0.94
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/auth/index.d.ts +7 -0
- package/dist/auth/providers/offchain-auth-provider.d.ts +1 -0
- package/dist/auth/providers/privy-wallet-provider.d.ts +7 -0
- package/dist/{index-dEUHmDSl.esm.js → index-Blxu9ZBh.esm.js} +2407 -2
- package/dist/index-Blxu9ZBh.esm.js.map +1 -0
- package/dist/index-C2VF8Cds.esm.js +6 -0
- package/dist/index-C2VF8Cds.esm.js.map +1 -0
- package/dist/{index-m53xb2JA.js → index-CGei1juZ.js} +2407 -3
- package/dist/index-CGei1juZ.js.map +1 -0
- package/dist/{index-vi52dsn6.js → index-CdKrnAsF.js} +2406 -2
- package/dist/index-CdKrnAsF.js.map +1 -0
- package/dist/{index-6iINLG88.esm.js → index-Cnx5UBPU.esm.js} +200 -31
- package/dist/index-Cnx5UBPU.esm.js.map +1 -0
- package/dist/{index-GeHpO_Ud.js → index-DOz63COz.js} +202 -29
- package/dist/index-DOz63COz.js.map +1 -0
- package/dist/{index-Dg3y_pRI.esm.js → index-DSSkK8ZR.esm.js} +2406 -3
- package/dist/index-DSSkK8ZR.esm.js.map +1 -0
- package/dist/{index-eFFOC8cE.js → index-DzZ1tiet.js} +2 -2
- package/dist/index-DzZ1tiet.js.map +1 -0
- package/dist/{index.browser-RwalL3F4.esm.js → index.browser-AkckBwjb.esm.js} +2 -2
- package/dist/{index.browser-RwalL3F4.esm.js.map → index.browser-AkckBwjb.esm.js.map} +1 -1
- package/dist/{index.browser-D6XPhu6r.js → index.browser-By5vlelY.js} +2 -2
- package/dist/{index.browser-D6XPhu6r.js.map → index.browser-By5vlelY.js.map} +1 -1
- package/dist/{index.browser-wZkBhwtI.esm.js → index.browser-ClqAxUrJ.esm.js} +2 -2
- package/dist/{index.browser-wZkBhwtI.esm.js.map → index.browser-ClqAxUrJ.esm.js.map} +1 -1
- package/dist/{index.browser-B1Zbn8LC.js → index.browser-Um9-5Cbs.js} +2 -2
- package/dist/{index.browser-B1Zbn8LC.js.map → index.browser-Um9-5Cbs.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/{index.native-Dd783Qva.esm.js → index.native-9ugIwvrJ.esm.js} +166 -31
- package/dist/index.native-9ugIwvrJ.esm.js.map +1 -0
- package/dist/{index.native-Bjx72Wnj.js → index.native-CpA5KDvL.js} +166 -29
- package/dist/index.native-CpA5KDvL.js.map +1 -0
- package/dist/index.native.esm.js +1 -1
- package/dist/index.native.js +1 -1
- package/dist/{phantom-wallet-provider-DUVViY9g.js → phantom-wallet-provider-LGxBWZXy.js} +4 -4
- package/dist/{phantom-wallet-provider-DUVViY9g.js.map → phantom-wallet-provider-LGxBWZXy.js.map} +1 -1
- package/dist/{phantom-wallet-provider-Dloixy8s.esm.js → phantom-wallet-provider-wskKKVNr.esm.js} +4 -4
- package/dist/{phantom-wallet-provider-Dloixy8s.esm.js.map → phantom-wallet-provider-wskKKVNr.esm.js.map} +1 -1
- package/dist/{privy-wallet-provider-BQbIRyXF.esm.js → privy-wallet-provider-B3bghDWY.esm.js} +22 -3
- package/dist/{privy-wallet-provider-BQbIRyXF.esm.js.map → privy-wallet-provider-B3bghDWY.esm.js.map} +1 -1
- package/dist/{privy-wallet-provider-CEdQMBT2.js → privy-wallet-provider-DsHSkIJJ.js} +22 -3
- package/dist/{privy-wallet-provider-CEdQMBT2.js.map → privy-wallet-provider-DsHSkIJJ.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-ARvDWjP7.esm.js → solana-mobile-wallet-provider-CFYL4aOO.esm.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-ARvDWjP7.esm.js.map → solana-mobile-wallet-provider-CFYL4aOO.esm.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-CgQWQ7Sk.js → solana-mobile-wallet-provider-EkUSbs-q.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-CgQWQ7Sk.js.map → solana-mobile-wallet-provider-EkUSbs-q.js.map} +1 -1
- package/package.json +2 -2
- package/dist/index-6iINLG88.esm.js.map +0 -1
- package/dist/index-CWD6VMLX.esm.js +0 -6
- package/dist/index-CWD6VMLX.esm.js.map +0 -1
- package/dist/index-Dg3y_pRI.esm.js.map +0 -1
- package/dist/index-GeHpO_Ud.js.map +0 -1
- package/dist/index-dEUHmDSl.esm.js.map +0 -1
- package/dist/index-eFFOC8cE.js.map +0 -1
- package/dist/index-m53xb2JA.js.map +0 -1
- package/dist/index-vi52dsn6.js.map +0 -1
- package/dist/index.native-Bjx72Wnj.js.map +0 -1
- package/dist/index.native-Dd783Qva.esm.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { init, getCurrentUser, onAuthStateChanged, onAuthLoadingChanged, getAuthLoading, login, logout, } from "./global";
|
|
2
2
|
export type { LoginOptions } from "./global";
|
|
3
3
|
export { getConfig } from "@pooflabs/core";
|
|
4
|
-
export { getAuthProvider } from "./auth";
|
|
4
|
+
export { getAuthProvider, getCurrentAuthMethod, exportWallet } from "./auth";
|
|
5
5
|
export { get, set, setMany, setFile, getFiles, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, signAndSubmitTransaction, count, aggregate, GetOptions, SetOptions, CountOptions, AggregateOptions, AggregateOperation, AggregateResult, } from "@pooflabs/core";
|
|
6
6
|
export type { GetOptions as TarobaseGetOptions } from "@pooflabs/core";
|
|
7
7
|
export { subscribe } from "@pooflabs/core";
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { L as DEFAULT_TEST_ADDRESS, T as InsufficientBalanceError, M as MockAuthProvider, O as OffchainAuthProvider, P as PhantomWalletProvider, R as PrivyExpoProvider, K as PrivyWalletProvider, U as ReactNativeSessionManager, V as RealtimeStore, W as ServerSessionManager, S as SolanaMobileWalletProvider, X as WebSessionManager, D as aggregate, Y as buildSetDocumentsTransaction, Z as clearCache, _ as closeAllSubscriptions, $ as convertRemainingAccounts, C as count, a0 as createSessionWithPrivy, a1 as createSessionWithSignature, G as deserializeTransaction, n as exportWallet, a2 as genAuthNonce, a3 as genSolanaMessage, p as get, f as getAuthLoading, k as getAuthProvider, a4 as getCachedData, j as getConfig, m as getCurrentAuthMethod, d as getCurrentUser, u as getFiles, H as getIdToken, a5 as getMany, J as getPlatform, a6 as getRealtimeStore, a7 as hasActiveConnection, i as init, N as isMobileWalletAvailable, l as login, h as logout, e as onAuthLoadingChanged, o as onAuthStateChanged, a8 as reconnectWithNewAuth, a9 as refreshSession, Q as registerMobileWalletAdapter, aa as resetRealtimeStore, x as runExpression, y as runExpressionMany, v as runQuery, w as runQueryMany, s as set, t as setFile, q as setMany, I as setPlatform, B as signAndSubmitTransaction, z as signMessage, ab as signSessionCreateMessage, A as signTransaction, E as subscribe, F as useAuth, ac as wsDelete, ad as wsGet, ae as wsGetMany, af as wsQuery, ag as wsSet } from './index-Cnx5UBPU.esm.js';
|
|
2
2
|
import 'axios';
|
|
3
3
|
import '@solana/web3.js';
|
|
4
4
|
import '@coral-xyz/anchor';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-DOz63COz.js');
|
|
4
4
|
require('axios');
|
|
5
5
|
require('@solana/web3.js');
|
|
6
6
|
require('@coral-xyz/anchor');
|
|
@@ -29,6 +29,7 @@ exports.count = index.count;
|
|
|
29
29
|
exports.createSessionWithPrivy = index.createSessionWithPrivy;
|
|
30
30
|
exports.createSessionWithSignature = index.createSessionWithSignature;
|
|
31
31
|
exports.deserializeTransaction = index.deserializeTransaction;
|
|
32
|
+
exports.exportWallet = index.exportWallet;
|
|
32
33
|
exports.genAuthNonce = index.genAuthNonce;
|
|
33
34
|
exports.genSolanaMessage = index.genSolanaMessage;
|
|
34
35
|
exports.get = index.get;
|
|
@@ -36,6 +37,7 @@ exports.getAuthLoading = index.getAuthLoading;
|
|
|
36
37
|
exports.getAuthProvider = index.getAuthProvider;
|
|
37
38
|
exports.getCachedData = index.getCachedData;
|
|
38
39
|
exports.getConfig = index.getConfig;
|
|
40
|
+
exports.getCurrentAuthMethod = index.getCurrentAuthMethod;
|
|
39
41
|
exports.getCurrentUser = index.getCurrentUser;
|
|
40
42
|
exports.getFiles = index.getFiles;
|
|
41
43
|
exports.getIdToken = index.getIdToken;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import globalAxios from 'axios';
|
|
2
|
-
import { PublicKey, SystemProgram, TransactionInstruction, ComputeBudgetProgram, Keypair,
|
|
2
|
+
import { PublicKey, SystemProgram, TransactionInstruction, Connection, VersionedTransaction, ComputeBudgetProgram, Keypair, TransactionMessage, Transaction } from '@solana/web3.js';
|
|
3
3
|
import * as anchor from '@coral-xyz/anchor';
|
|
4
4
|
import { Program } from '@coral-xyz/anchor';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -6683,7 +6683,14 @@ async function createSessionWithPrivy(authToken, address, privyIdToken) {
|
|
|
6683
6683
|
const appId = config.appId;
|
|
6684
6684
|
const response = await client.post('/session', {
|
|
6685
6685
|
appId,
|
|
6686
|
-
|
|
6686
|
+
// createSessionWithPrivy is, by definition, the Privy session path, so the
|
|
6687
|
+
// server must receive authMethod:'privy' (its branch validates authToken+
|
|
6688
|
+
// idToken+appId). Do NOT read config.authMethod here: on a Phantom-primary app
|
|
6689
|
+
// with the staged Privy email swap, config.authMethod is still 'phantom' at this
|
|
6690
|
+
// point (commitPrivy runs after login() resolves), which routes the request to
|
|
6691
|
+
// the signature/message branch and fails. Hardcoding 'privy' also correctly
|
|
6692
|
+
// covers 'privy-expo', which the backend expects mapped to 'privy'.
|
|
6693
|
+
authMethod: 'privy',
|
|
6687
6694
|
authToken,
|
|
6688
6695
|
idToken: privyIdToken,
|
|
6689
6696
|
address
|
|
@@ -9940,6 +9947,14 @@ async function updateIdTokenAndAccessToken(idToken, accessToken, isServer = fals
|
|
|
9940
9947
|
await WebSessionManager.updateIdTokenAndAccessToken(idToken, accessToken);
|
|
9941
9948
|
}
|
|
9942
9949
|
|
|
9950
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
9951
|
+
__proto__: null,
|
|
9952
|
+
createAuthHeader: createAuthHeader,
|
|
9953
|
+
getIdToken: getIdToken$1,
|
|
9954
|
+
getRefreshToken: getRefreshToken,
|
|
9955
|
+
updateIdTokenAndAccessToken: updateIdTokenAndAccessToken
|
|
9956
|
+
});
|
|
9957
|
+
|
|
9943
9958
|
const apiClient = globalAxios.create();
|
|
9944
9959
|
axiosRetry(apiClient, {
|
|
9945
9960
|
retries: 2,
|
|
@@ -10367,7 +10382,7 @@ async function get(path, opts = {}) {
|
|
|
10367
10382
|
// For realtime chains, prefer WebSocket reads (lower latency, already connected)
|
|
10368
10383
|
const config = await getConfig();
|
|
10369
10384
|
const pathIsDocument = normalizedPath.split("/").length % 2 === 0;
|
|
10370
|
-
if (((_a = config.chain) === null || _a === void 0 ? void 0 : _a.startsWith('realtime_')) && !config.isServer && !opts.prompt && !opts.shape && !opts.cursor) {
|
|
10385
|
+
if (((_a = config.chain) === null || _a === void 0 ? void 0 : _a.startsWith('realtime_')) && !config.isServer && !opts.prompt && !opts.shape && !opts.cursor && !opts.includeSubPaths) {
|
|
10371
10386
|
try {
|
|
10372
10387
|
const { wsGet, wsQuery, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
|
|
10373
10388
|
if (hasActiveConnection()) {
|
|
@@ -10598,7 +10613,7 @@ async function set(path, document, options) {
|
|
|
10598
10613
|
return result;
|
|
10599
10614
|
}
|
|
10600
10615
|
async function setMany(many, options) {
|
|
10601
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10616
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10602
10617
|
// Returns the data that was set, or undefined if the document was already set.
|
|
10603
10618
|
try {
|
|
10604
10619
|
const config = await getConfig();
|
|
@@ -10641,12 +10656,24 @@ async function setMany(many, options) {
|
|
|
10641
10656
|
try {
|
|
10642
10657
|
const { wsSet, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
|
|
10643
10658
|
if (hasActiveConnection()) {
|
|
10659
|
+
// Connection is active — send via WS. If this throws, the write
|
|
10660
|
+
// may have been applied server-side (ack lost). Do NOT fall through
|
|
10661
|
+
// to HTTP, as that would double-apply non-idempotent ops (Increment).
|
|
10644
10662
|
const wsResult = await wsSet(documents);
|
|
10645
|
-
// Normalize to same shape as HTTP 200 response so downstream handling is identical
|
|
10646
10663
|
setResponse = { data: wsResult, status: 200 };
|
|
10647
10664
|
}
|
|
10648
10665
|
}
|
|
10649
|
-
catch (
|
|
10666
|
+
catch (wsError) {
|
|
10667
|
+
// Only fall through to HTTP if the request was never sent (connection not available).
|
|
10668
|
+
// If the request was sent and ack was lost (timeout), the server may have
|
|
10669
|
+
// applied it — re-sending via HTTP risks double-write for non-idempotent ops.
|
|
10670
|
+
const msg = (_d = wsError === null || wsError === void 0 ? void 0 : wsError.message) !== null && _d !== void 0 ? _d : '';
|
|
10671
|
+
const neverSent = msg.includes('not available') || msg.includes('connection timeout');
|
|
10672
|
+
if (!neverSent) {
|
|
10673
|
+
throw wsError;
|
|
10674
|
+
}
|
|
10675
|
+
// Safe to retry via HTTP — request was never sent
|
|
10676
|
+
}
|
|
10650
10677
|
}
|
|
10651
10678
|
if (!setResponse) {
|
|
10652
10679
|
setResponse = await makeApiRequest('PUT', `items`, { documents }, options === null || options === void 0 ? void 0 : options._overrides);
|
|
@@ -10654,9 +10681,9 @@ async function setMany(many, options) {
|
|
|
10654
10681
|
}
|
|
10655
10682
|
catch (error) {
|
|
10656
10683
|
if ((error === null || error === void 0 ? void 0 : error.statusCode) === 402 && (error === null || error === void 0 ? void 0 : error.error) === 'INSUFFICIENT_BALANCE') {
|
|
10657
|
-
const deficitLamports = Number((
|
|
10658
|
-
const deficitSol = Number((
|
|
10659
|
-
throw new InsufficientBalanceError(String((
|
|
10684
|
+
const deficitLamports = Number((_e = error.deficitLamports) !== null && _e !== void 0 ? _e : 0);
|
|
10685
|
+
const deficitSol = Number((_f = error.deficitSol) !== null && _f !== void 0 ? _f : deficitLamports / 1000000000);
|
|
10686
|
+
throw new InsufficientBalanceError(String((_g = error.address) !== null && _g !== void 0 ? _g : ''), Number((_h = error.balanceLamports) !== null && _h !== void 0 ? _h : 0), Number((_j = error.estimatedCostLamports) !== null && _j !== void 0 ? _j : 0), deficitLamports, deficitSol);
|
|
10660
10687
|
}
|
|
10661
10688
|
throw error;
|
|
10662
10689
|
}
|
|
@@ -10678,7 +10705,13 @@ async function setMany(many, options) {
|
|
|
10678
10705
|
let signedTransaction = undefined;
|
|
10679
10706
|
for (let i = 0; i < transactions.length; i++) {
|
|
10680
10707
|
const curTx = transactions[i];
|
|
10681
|
-
|
|
10708
|
+
let transactionResult;
|
|
10709
|
+
if (curTx.serializedTransaction) {
|
|
10710
|
+
transactionResult = await handlePreBuiltTransaction(curTx, authProvider, options);
|
|
10711
|
+
}
|
|
10712
|
+
else {
|
|
10713
|
+
transactionResult = await handleSolanaTransaction(curTx, authProvider, options);
|
|
10714
|
+
}
|
|
10682
10715
|
lastTxSignature = transactionResult.transactionSignature;
|
|
10683
10716
|
signedTransaction = transactionResult.signedTransaction;
|
|
10684
10717
|
}
|
|
@@ -10784,6 +10817,68 @@ async function setMany(many, options) {
|
|
|
10784
10817
|
const transactionResult = await authProvider.runTransaction(undefined, solTransaction, options);
|
|
10785
10818
|
return transactionResult;
|
|
10786
10819
|
}
|
|
10820
|
+
async function handlePreBuiltTransaction(tx, authProvider, options) {
|
|
10821
|
+
var _a, _b;
|
|
10822
|
+
const config = await getConfig();
|
|
10823
|
+
const rpcUrl = config.rpcUrl || (tx.network === 'solana_devnet'
|
|
10824
|
+
? 'https://api.devnet.solana.com'
|
|
10825
|
+
: 'https://api.mainnet-beta.solana.com');
|
|
10826
|
+
const connection = new Connection(rpcUrl, 'confirmed');
|
|
10827
|
+
const txBytes = bufferExports.Buffer.from(tx.serializedTransaction, 'base64');
|
|
10828
|
+
const transaction = VersionedTransaction.deserialize(txBytes);
|
|
10829
|
+
// Validate the transaction before signing: ensure only allowed programs
|
|
10830
|
+
// and no unauthorized System program instructions (e.g., SOL transfers)
|
|
10831
|
+
const TAROBASE_PROGRAM = 'poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZp';
|
|
10832
|
+
const COMPUTE_BUDGET = 'ComputeBudget111111111111111111111111111111';
|
|
10833
|
+
const SYSTEM_PROGRAM = '11111111111111111111111111111111';
|
|
10834
|
+
const ALLOWED_PROGRAMS = new Set([TAROBASE_PROGRAM, COMPUTE_BUDGET, SYSTEM_PROGRAM]);
|
|
10835
|
+
// System program instruction discriminators (first 4 bytes, little-endian u32)
|
|
10836
|
+
const SYSTEM_TRANSFER = 2; // Transfer instruction index
|
|
10837
|
+
const SYSTEM_TRANSFER_WITH_SEED = 11;
|
|
10838
|
+
const accountKeys = transaction.message.staticAccountKeys;
|
|
10839
|
+
for (const ix of transaction.message.compiledInstructions) {
|
|
10840
|
+
if (ix.programIdIndex >= accountKeys.length) {
|
|
10841
|
+
throw new Error('Pre-built transaction has program ID in lookup table (not allowed)');
|
|
10842
|
+
}
|
|
10843
|
+
const programId = accountKeys[ix.programIdIndex].toBase58();
|
|
10844
|
+
if (!ALLOWED_PROGRAMS.has(programId)) {
|
|
10845
|
+
throw new Error(`Pre-built transaction contains unauthorized program: ${programId}`);
|
|
10846
|
+
}
|
|
10847
|
+
// Block System program transfer instructions — a compromised DO could
|
|
10848
|
+
// embed a SOL drain. Only allow createAccount/allocate (needed for PDA init).
|
|
10849
|
+
if (programId === SYSTEM_PROGRAM && ix.data.length >= 4) {
|
|
10850
|
+
const ixIndex = ix.data[0] | (ix.data[1] << 8) | (ix.data[2] << 16) | (ix.data[3] << 24);
|
|
10851
|
+
if (ixIndex === SYSTEM_TRANSFER || ixIndex === SYSTEM_TRANSFER_WITH_SEED) {
|
|
10852
|
+
throw new Error('Pre-built transaction contains unauthorized System transfer instruction');
|
|
10853
|
+
}
|
|
10854
|
+
}
|
|
10855
|
+
}
|
|
10856
|
+
const signedTx = await authProvider.signTransaction(transaction);
|
|
10857
|
+
const rawTx = signedTx.serialize();
|
|
10858
|
+
if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
|
|
10859
|
+
return {
|
|
10860
|
+
transactionSignature: '',
|
|
10861
|
+
signedTransaction: bufferExports.Buffer.from(rawTx).toString('base64'),
|
|
10862
|
+
blockNumber: 0,
|
|
10863
|
+
gasUsed: '0',
|
|
10864
|
+
};
|
|
10865
|
+
}
|
|
10866
|
+
const signature = await connection.sendRawTransaction(rawTx, {
|
|
10867
|
+
skipPreflight: false,
|
|
10868
|
+
maxRetries: 3,
|
|
10869
|
+
});
|
|
10870
|
+
const confirmation = await connection.confirmTransaction({
|
|
10871
|
+
signature,
|
|
10872
|
+
blockhash: tx.blockhash,
|
|
10873
|
+
lastValidBlockHeight: tx.lastValidBlockHeight,
|
|
10874
|
+
}, 'confirmed');
|
|
10875
|
+
return {
|
|
10876
|
+
transactionSignature: signature,
|
|
10877
|
+
signedTransaction: bufferExports.Buffer.from(rawTx).toString('base64'),
|
|
10878
|
+
blockNumber: (_b = (_a = confirmation.context) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : 0,
|
|
10879
|
+
gasUsed: '0',
|
|
10880
|
+
};
|
|
10881
|
+
}
|
|
10787
10882
|
async function handleOffchainTransaction(tx, authProvider, options) {
|
|
10788
10883
|
var _a, _b, _c, _d, _e, _f;
|
|
10789
10884
|
const config = await getConfig();
|
|
@@ -12096,30 +12191,53 @@ class RealtimeStore {
|
|
|
12096
12191
|
this.idbDirtyKeys = new Set();
|
|
12097
12192
|
this.closed = false;
|
|
12098
12193
|
this.authToken = null;
|
|
12194
|
+
this.isServer = false;
|
|
12195
|
+
this.tokenRefreshTimer = null;
|
|
12196
|
+
// -----------------------------------------------------------------------
|
|
12197
|
+
// WebSocket connection
|
|
12198
|
+
// -----------------------------------------------------------------------
|
|
12199
|
+
this.initPromise = null;
|
|
12099
12200
|
}
|
|
12100
12201
|
// -----------------------------------------------------------------------
|
|
12101
12202
|
// Initialization
|
|
12102
12203
|
// -----------------------------------------------------------------------
|
|
12103
12204
|
async init() {
|
|
12104
|
-
var _a, _b;
|
|
12105
12205
|
const config = await getConfig();
|
|
12106
12206
|
this.appId = config.appId;
|
|
12107
12207
|
this.wsUrl = config.wsApiUrl;
|
|
12108
|
-
|
|
12109
|
-
|
|
12110
|
-
|
|
12111
|
-
|
|
12112
|
-
|
|
12113
|
-
|
|
12114
|
-
}
|
|
12115
|
-
|
|
12208
|
+
this.isServer = config.isServer;
|
|
12209
|
+
await this.refreshToken();
|
|
12210
|
+
this.startTokenRefresh();
|
|
12211
|
+
}
|
|
12212
|
+
async refreshToken() {
|
|
12213
|
+
try {
|
|
12214
|
+
const { getIdToken } = await Promise.resolve().then(function () { return utils; });
|
|
12215
|
+
const token = await getIdToken(this.isServer);
|
|
12216
|
+
if (token)
|
|
12217
|
+
this.authToken = token;
|
|
12116
12218
|
}
|
|
12219
|
+
catch ( /* no auth available */_a) { /* no auth available */ }
|
|
12220
|
+
}
|
|
12221
|
+
startTokenRefresh() {
|
|
12222
|
+
if (this.tokenRefreshTimer)
|
|
12223
|
+
return;
|
|
12224
|
+
this.tokenRefreshTimer = setInterval(async () => {
|
|
12225
|
+
var _a;
|
|
12226
|
+
const prevToken = this.authToken;
|
|
12227
|
+
await this.refreshToken();
|
|
12228
|
+
if (this.authToken && this.authToken !== prevToken && ((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN) {
|
|
12229
|
+
// Token changed — reconnect with fresh token
|
|
12230
|
+
this.ws.close(1000, 'Token refreshed');
|
|
12231
|
+
}
|
|
12232
|
+
}, 5 * 60 * 1000); // Check every 5 minutes
|
|
12117
12233
|
}
|
|
12118
|
-
// -----------------------------------------------------------------------
|
|
12119
|
-
// WebSocket connection
|
|
12120
|
-
// -----------------------------------------------------------------------
|
|
12121
12234
|
async ensureConnected() {
|
|
12122
12235
|
var _a;
|
|
12236
|
+
if (!this.appId) {
|
|
12237
|
+
if (!this.initPromise)
|
|
12238
|
+
this.initPromise = this.init();
|
|
12239
|
+
await this.initPromise;
|
|
12240
|
+
}
|
|
12123
12241
|
if (((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN)
|
|
12124
12242
|
return;
|
|
12125
12243
|
if (this.connectPromise)
|
|
@@ -12135,10 +12253,12 @@ class RealtimeStore {
|
|
|
12135
12253
|
}
|
|
12136
12254
|
const params = new URLSearchParams();
|
|
12137
12255
|
params.set('apiKey', this.appId);
|
|
12138
|
-
|
|
12256
|
+
if (this.authToken)
|
|
12257
|
+
params.set('authorization', this.authToken);
|
|
12258
|
+
// Note: token in URL is required until DO server supports subprotocol auth.
|
|
12259
|
+
// WSS encrypts the full URL including query params on the wire.
|
|
12139
12260
|
const url = `${this.wsUrl}?${params.toString()}`;
|
|
12140
|
-
const
|
|
12141
|
-
const ws = protocols ? new WebSocket(url, protocols) : new WebSocket(url);
|
|
12261
|
+
const ws = new WebSocket(url);
|
|
12142
12262
|
this.ws = ws;
|
|
12143
12263
|
const onOpen = () => {
|
|
12144
12264
|
ws.removeEventListener('error', onError);
|
|
@@ -12769,6 +12889,8 @@ class RealtimeStore {
|
|
|
12769
12889
|
clearTimeout(this.reconnectTimer);
|
|
12770
12890
|
if (this.idbFlushTimer)
|
|
12771
12891
|
clearTimeout(this.idbFlushTimer);
|
|
12892
|
+
if (this.tokenRefreshTimer)
|
|
12893
|
+
clearInterval(this.tokenRefreshTimer);
|
|
12772
12894
|
this.flushIdb();
|
|
12773
12895
|
if (this.ws) {
|
|
12774
12896
|
this.ws.close(1000, 'Store closed');
|
|
@@ -13142,6 +13264,15 @@ class OffchainAuthProvider {
|
|
|
13142
13264
|
async getNativeMethods() {
|
|
13143
13265
|
return this.wrappedProvider.getNativeMethods();
|
|
13144
13266
|
}
|
|
13267
|
+
// Forward wallet export to the wrapped provider (only Privy embedded wallets
|
|
13268
|
+
// implement it). Duck-typed so wrappers around non-embedded providers throw
|
|
13269
|
+
// a clear error rather than a "not a function" crash.
|
|
13270
|
+
async exportWallet(address) {
|
|
13271
|
+
if (typeof this.wrappedProvider.exportWallet !== 'function') {
|
|
13272
|
+
throw new Error('Wallet export is not available for this wallet.');
|
|
13273
|
+
}
|
|
13274
|
+
await this.wrappedProvider.exportWallet(address);
|
|
13275
|
+
}
|
|
13145
13276
|
// ============ signMessage delegates to wrapped provider ============
|
|
13146
13277
|
async signMessage(message) {
|
|
13147
13278
|
// Delegate to wrapped provider for real wallet signing
|
|
@@ -13869,15 +14000,15 @@ function clearIncompatibleSession() {
|
|
|
13869
14000
|
// Lazy loaders for web-only providers.
|
|
13870
14001
|
// Using dynamic import() ensures Metro (RN) never resolves these modules.
|
|
13871
14002
|
async function loadPrivyWalletProvider() {
|
|
13872
|
-
const mod = await import('./privy-wallet-provider-
|
|
14003
|
+
const mod = await import('./privy-wallet-provider-B3bghDWY.esm.js');
|
|
13873
14004
|
return mod.PrivyWalletProvider;
|
|
13874
14005
|
}
|
|
13875
14006
|
async function loadPhantomWalletProvider() {
|
|
13876
|
-
const mod = await import('./phantom-wallet-provider-
|
|
14007
|
+
const mod = await import('./phantom-wallet-provider-wskKKVNr.esm.js');
|
|
13877
14008
|
return { PhantomWalletProvider: mod.PhantomWalletProvider };
|
|
13878
14009
|
}
|
|
13879
14010
|
async function loadSolanaMobileWalletProvider() {
|
|
13880
|
-
const mod = await import('./solana-mobile-wallet-provider-
|
|
14011
|
+
const mod = await import('./solana-mobile-wallet-provider-CFYL4aOO.esm.js');
|
|
13881
14012
|
return mod.SolanaMobileWalletProvider;
|
|
13882
14013
|
}
|
|
13883
14014
|
async function hotSwapToPrivyProvider(config) {
|
|
@@ -14112,7 +14243,11 @@ async function login$1(options) {
|
|
|
14112
14243
|
return null;
|
|
14113
14244
|
}
|
|
14114
14245
|
function getCurrentAuthMethod() {
|
|
14115
|
-
|
|
14246
|
+
// Fall back to the persisted login method so consumers (e.g. a "show export
|
|
14247
|
+
// wallet" gate) get the correct value synchronously on reload, before init()
|
|
14248
|
+
// has rebuilt the in-memory provider. The stored value is cleared on logout,
|
|
14249
|
+
// so a logged-out user still yields null.
|
|
14250
|
+
return currentAuthMethod !== null && currentAuthMethod !== void 0 ? currentAuthMethod : getStoredAuthMethod();
|
|
14116
14251
|
}
|
|
14117
14252
|
async function logout$1() {
|
|
14118
14253
|
if (!currentAuthProvider) {
|
|
@@ -17288,5 +17423,5 @@ class PrivyExpoProvider {
|
|
|
17288
17423
|
}
|
|
17289
17424
|
}
|
|
17290
17425
|
|
|
17291
|
-
export {
|
|
17292
|
-
//# sourceMappingURL=index.native-
|
|
17426
|
+
export { InsufficientBalanceError as $, getConfig as A, getAuthProvider as B, get as C, set as D, setMany as E, setFile as F, getFiles as G, runQuery as H, runQueryMany as I, runExpression as J, runExpressionMany as K, signMessage as L, signTransaction as M, signAndSubmitTransaction as N, count as O, aggregate as P, subscribe as Q, useAuth as R, SOLANA_MAINNET_RPC_URL as S, deserializeTransaction as T, getIdToken as U, setPlatform as V, WebSessionManager as W, MockAuthProvider as X, DEFAULT_TEST_ADDRESS as Y, OffchainAuthProvider as Z, PrivyExpoProvider as _, SOLANA_DEVNET_RPC_URL as a, ReactNativeSessionManager as a0, RealtimeStore as a1, ServerSessionManager as a2, clearCache as a3, closeAllSubscriptions as a4, getCachedData as a5, getMany as a6, getRealtimeStore as a7, hasActiveConnection as a8, reconnectWithNewAuth as a9, refreshSession as aa, resetRealtimeStore as ab, signSessionCreateMessage as ac, wsDelete as ad, wsGet as ae, wsGetMany as af, wsQuery as ag, wsSet as ah, index as ai, buildSetDocumentsTransaction as b, convertRemainingAccounts as c, base58 as d, confirmAndCheckTransaction as e, createSessionWithPrivy as f, getPlatform as g, SURFNET_RPC_URL$1 as h, detectMobile as i, detectAndroid as j, setAuthLoading as k, genAuthNonce as l, genSolanaMessage as m, createSessionWithSignature as n, commonjsRequire as o, require$$0 as p, getDefaultExportFromCjs$1 as q, requireBuffer as r, setCurrentUser as s, init as t, getCurrentUser as u, onAuthStateChanged as v, onAuthLoadingChanged as w, getAuthLoading as x, login as y, logout as z };
|
|
17427
|
+
//# sourceMappingURL=index.native-9ugIwvrJ.esm.js.map
|