@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
|
@@ -6704,7 +6704,14 @@ async function createSessionWithPrivy(authToken, address, privyIdToken) {
|
|
|
6704
6704
|
const appId = config.appId;
|
|
6705
6705
|
const response = await client.post('/session', {
|
|
6706
6706
|
appId,
|
|
6707
|
-
|
|
6707
|
+
// createSessionWithPrivy is, by definition, the Privy session path, so the
|
|
6708
|
+
// server must receive authMethod:'privy' (its branch validates authToken+
|
|
6709
|
+
// idToken+appId). Do NOT read config.authMethod here: on a Phantom-primary app
|
|
6710
|
+
// with the staged Privy email swap, config.authMethod is still 'phantom' at this
|
|
6711
|
+
// point (commitPrivy runs after login() resolves), which routes the request to
|
|
6712
|
+
// the signature/message branch and fails. Hardcoding 'privy' also correctly
|
|
6713
|
+
// covers 'privy-expo', which the backend expects mapped to 'privy'.
|
|
6714
|
+
authMethod: 'privy',
|
|
6708
6715
|
authToken,
|
|
6709
6716
|
idToken: privyIdToken,
|
|
6710
6717
|
address
|
|
@@ -9961,6 +9968,14 @@ async function updateIdTokenAndAccessToken(idToken, accessToken, isServer = fals
|
|
|
9961
9968
|
await WebSessionManager.updateIdTokenAndAccessToken(idToken, accessToken);
|
|
9962
9969
|
}
|
|
9963
9970
|
|
|
9971
|
+
var utils = /*#__PURE__*/Object.freeze({
|
|
9972
|
+
__proto__: null,
|
|
9973
|
+
createAuthHeader: createAuthHeader,
|
|
9974
|
+
getIdToken: getIdToken$1,
|
|
9975
|
+
getRefreshToken: getRefreshToken,
|
|
9976
|
+
updateIdTokenAndAccessToken: updateIdTokenAndAccessToken
|
|
9977
|
+
});
|
|
9978
|
+
|
|
9964
9979
|
const apiClient = globalAxios.create();
|
|
9965
9980
|
axiosRetry(apiClient, {
|
|
9966
9981
|
retries: 2,
|
|
@@ -10388,7 +10403,7 @@ async function get(path, opts = {}) {
|
|
|
10388
10403
|
// For realtime chains, prefer WebSocket reads (lower latency, already connected)
|
|
10389
10404
|
const config = await getConfig();
|
|
10390
10405
|
const pathIsDocument = normalizedPath.split("/").length % 2 === 0;
|
|
10391
|
-
if (((_a = config.chain) === null || _a === void 0 ? void 0 : _a.startsWith('realtime_')) && !config.isServer && !opts.prompt && !opts.shape && !opts.cursor) {
|
|
10406
|
+
if (((_a = config.chain) === null || _a === void 0 ? void 0 : _a.startsWith('realtime_')) && !config.isServer && !opts.prompt && !opts.shape && !opts.cursor && !opts.includeSubPaths) {
|
|
10392
10407
|
try {
|
|
10393
10408
|
const { wsGet, wsQuery, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
|
|
10394
10409
|
if (hasActiveConnection()) {
|
|
@@ -10619,7 +10634,7 @@ async function set(path, document, options) {
|
|
|
10619
10634
|
return result;
|
|
10620
10635
|
}
|
|
10621
10636
|
async function setMany(many, options) {
|
|
10622
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10637
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10623
10638
|
// Returns the data that was set, or undefined if the document was already set.
|
|
10624
10639
|
try {
|
|
10625
10640
|
const config = await getConfig();
|
|
@@ -10662,12 +10677,24 @@ async function setMany(many, options) {
|
|
|
10662
10677
|
try {
|
|
10663
10678
|
const { wsSet, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
|
|
10664
10679
|
if (hasActiveConnection()) {
|
|
10680
|
+
// Connection is active — send via WS. If this throws, the write
|
|
10681
|
+
// may have been applied server-side (ack lost). Do NOT fall through
|
|
10682
|
+
// to HTTP, as that would double-apply non-idempotent ops (Increment).
|
|
10665
10683
|
const wsResult = await wsSet(documents);
|
|
10666
|
-
// Normalize to same shape as HTTP 200 response so downstream handling is identical
|
|
10667
10684
|
setResponse = { data: wsResult, status: 200 };
|
|
10668
10685
|
}
|
|
10669
10686
|
}
|
|
10670
|
-
catch (
|
|
10687
|
+
catch (wsError) {
|
|
10688
|
+
// Only fall through to HTTP if the request was never sent (connection not available).
|
|
10689
|
+
// If the request was sent and ack was lost (timeout), the server may have
|
|
10690
|
+
// applied it — re-sending via HTTP risks double-write for non-idempotent ops.
|
|
10691
|
+
const msg = (_d = wsError === null || wsError === void 0 ? void 0 : wsError.message) !== null && _d !== void 0 ? _d : '';
|
|
10692
|
+
const neverSent = msg.includes('not available') || msg.includes('connection timeout');
|
|
10693
|
+
if (!neverSent) {
|
|
10694
|
+
throw wsError;
|
|
10695
|
+
}
|
|
10696
|
+
// Safe to retry via HTTP — request was never sent
|
|
10697
|
+
}
|
|
10671
10698
|
}
|
|
10672
10699
|
if (!setResponse) {
|
|
10673
10700
|
setResponse = await makeApiRequest('PUT', `items`, { documents }, options === null || options === void 0 ? void 0 : options._overrides);
|
|
@@ -10675,9 +10702,9 @@ async function setMany(many, options) {
|
|
|
10675
10702
|
}
|
|
10676
10703
|
catch (error) {
|
|
10677
10704
|
if ((error === null || error === void 0 ? void 0 : error.statusCode) === 402 && (error === null || error === void 0 ? void 0 : error.error) === 'INSUFFICIENT_BALANCE') {
|
|
10678
|
-
const deficitLamports = Number((
|
|
10679
|
-
const deficitSol = Number((
|
|
10680
|
-
throw new InsufficientBalanceError(String((
|
|
10705
|
+
const deficitLamports = Number((_e = error.deficitLamports) !== null && _e !== void 0 ? _e : 0);
|
|
10706
|
+
const deficitSol = Number((_f = error.deficitSol) !== null && _f !== void 0 ? _f : deficitLamports / 1000000000);
|
|
10707
|
+
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);
|
|
10681
10708
|
}
|
|
10682
10709
|
throw error;
|
|
10683
10710
|
}
|
|
@@ -10699,7 +10726,13 @@ async function setMany(many, options) {
|
|
|
10699
10726
|
let signedTransaction = undefined;
|
|
10700
10727
|
for (let i = 0; i < transactions.length; i++) {
|
|
10701
10728
|
const curTx = transactions[i];
|
|
10702
|
-
|
|
10729
|
+
let transactionResult;
|
|
10730
|
+
if (curTx.serializedTransaction) {
|
|
10731
|
+
transactionResult = await handlePreBuiltTransaction(curTx, authProvider, options);
|
|
10732
|
+
}
|
|
10733
|
+
else {
|
|
10734
|
+
transactionResult = await handleSolanaTransaction(curTx, authProvider, options);
|
|
10735
|
+
}
|
|
10703
10736
|
lastTxSignature = transactionResult.transactionSignature;
|
|
10704
10737
|
signedTransaction = transactionResult.signedTransaction;
|
|
10705
10738
|
}
|
|
@@ -10805,6 +10838,68 @@ async function setMany(many, options) {
|
|
|
10805
10838
|
const transactionResult = await authProvider.runTransaction(undefined, solTransaction, options);
|
|
10806
10839
|
return transactionResult;
|
|
10807
10840
|
}
|
|
10841
|
+
async function handlePreBuiltTransaction(tx, authProvider, options) {
|
|
10842
|
+
var _a, _b;
|
|
10843
|
+
const config = await getConfig();
|
|
10844
|
+
const rpcUrl = config.rpcUrl || (tx.network === 'solana_devnet'
|
|
10845
|
+
? 'https://api.devnet.solana.com'
|
|
10846
|
+
: 'https://api.mainnet-beta.solana.com');
|
|
10847
|
+
const connection = new web3_js.Connection(rpcUrl, 'confirmed');
|
|
10848
|
+
const txBytes = bufferExports$1.Buffer.from(tx.serializedTransaction, 'base64');
|
|
10849
|
+
const transaction = web3_js.VersionedTransaction.deserialize(txBytes);
|
|
10850
|
+
// Validate the transaction before signing: ensure only allowed programs
|
|
10851
|
+
// and no unauthorized System program instructions (e.g., SOL transfers)
|
|
10852
|
+
const TAROBASE_PROGRAM = 'poof4b5pk1L9tmThvBmaABjcyjfhFGbMbQP5BXk2QZp';
|
|
10853
|
+
const COMPUTE_BUDGET = 'ComputeBudget111111111111111111111111111111';
|
|
10854
|
+
const SYSTEM_PROGRAM = '11111111111111111111111111111111';
|
|
10855
|
+
const ALLOWED_PROGRAMS = new Set([TAROBASE_PROGRAM, COMPUTE_BUDGET, SYSTEM_PROGRAM]);
|
|
10856
|
+
// System program instruction discriminators (first 4 bytes, little-endian u32)
|
|
10857
|
+
const SYSTEM_TRANSFER = 2; // Transfer instruction index
|
|
10858
|
+
const SYSTEM_TRANSFER_WITH_SEED = 11;
|
|
10859
|
+
const accountKeys = transaction.message.staticAccountKeys;
|
|
10860
|
+
for (const ix of transaction.message.compiledInstructions) {
|
|
10861
|
+
if (ix.programIdIndex >= accountKeys.length) {
|
|
10862
|
+
throw new Error('Pre-built transaction has program ID in lookup table (not allowed)');
|
|
10863
|
+
}
|
|
10864
|
+
const programId = accountKeys[ix.programIdIndex].toBase58();
|
|
10865
|
+
if (!ALLOWED_PROGRAMS.has(programId)) {
|
|
10866
|
+
throw new Error(`Pre-built transaction contains unauthorized program: ${programId}`);
|
|
10867
|
+
}
|
|
10868
|
+
// Block System program transfer instructions — a compromised DO could
|
|
10869
|
+
// embed a SOL drain. Only allow createAccount/allocate (needed for PDA init).
|
|
10870
|
+
if (programId === SYSTEM_PROGRAM && ix.data.length >= 4) {
|
|
10871
|
+
const ixIndex = ix.data[0] | (ix.data[1] << 8) | (ix.data[2] << 16) | (ix.data[3] << 24);
|
|
10872
|
+
if (ixIndex === SYSTEM_TRANSFER || ixIndex === SYSTEM_TRANSFER_WITH_SEED) {
|
|
10873
|
+
throw new Error('Pre-built transaction contains unauthorized System transfer instruction');
|
|
10874
|
+
}
|
|
10875
|
+
}
|
|
10876
|
+
}
|
|
10877
|
+
const signedTx = await authProvider.signTransaction(transaction);
|
|
10878
|
+
const rawTx = signedTx.serialize();
|
|
10879
|
+
if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
|
|
10880
|
+
return {
|
|
10881
|
+
transactionSignature: '',
|
|
10882
|
+
signedTransaction: bufferExports$1.Buffer.from(rawTx).toString('base64'),
|
|
10883
|
+
blockNumber: 0,
|
|
10884
|
+
gasUsed: '0',
|
|
10885
|
+
};
|
|
10886
|
+
}
|
|
10887
|
+
const signature = await connection.sendRawTransaction(rawTx, {
|
|
10888
|
+
skipPreflight: false,
|
|
10889
|
+
maxRetries: 3,
|
|
10890
|
+
});
|
|
10891
|
+
const confirmation = await connection.confirmTransaction({
|
|
10892
|
+
signature,
|
|
10893
|
+
blockhash: tx.blockhash,
|
|
10894
|
+
lastValidBlockHeight: tx.lastValidBlockHeight,
|
|
10895
|
+
}, 'confirmed');
|
|
10896
|
+
return {
|
|
10897
|
+
transactionSignature: signature,
|
|
10898
|
+
signedTransaction: bufferExports$1.Buffer.from(rawTx).toString('base64'),
|
|
10899
|
+
blockNumber: (_b = (_a = confirmation.context) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : 0,
|
|
10900
|
+
gasUsed: '0',
|
|
10901
|
+
};
|
|
10902
|
+
}
|
|
10808
10903
|
async function handleOffchainTransaction(tx, authProvider, options) {
|
|
10809
10904
|
var _a, _b, _c, _d, _e, _f;
|
|
10810
10905
|
const config = await getConfig();
|
|
@@ -12117,30 +12212,53 @@ class RealtimeStore {
|
|
|
12117
12212
|
this.idbDirtyKeys = new Set();
|
|
12118
12213
|
this.closed = false;
|
|
12119
12214
|
this.authToken = null;
|
|
12215
|
+
this.isServer = false;
|
|
12216
|
+
this.tokenRefreshTimer = null;
|
|
12217
|
+
// -----------------------------------------------------------------------
|
|
12218
|
+
// WebSocket connection
|
|
12219
|
+
// -----------------------------------------------------------------------
|
|
12220
|
+
this.initPromise = null;
|
|
12120
12221
|
}
|
|
12121
12222
|
// -----------------------------------------------------------------------
|
|
12122
12223
|
// Initialization
|
|
12123
12224
|
// -----------------------------------------------------------------------
|
|
12124
12225
|
async init() {
|
|
12125
|
-
var _a, _b;
|
|
12126
12226
|
const config = await getConfig();
|
|
12127
12227
|
this.appId = config.appId;
|
|
12128
12228
|
this.wsUrl = config.wsApiUrl;
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
}
|
|
12136
|
-
|
|
12229
|
+
this.isServer = config.isServer;
|
|
12230
|
+
await this.refreshToken();
|
|
12231
|
+
this.startTokenRefresh();
|
|
12232
|
+
}
|
|
12233
|
+
async refreshToken() {
|
|
12234
|
+
try {
|
|
12235
|
+
const { getIdToken } = await Promise.resolve().then(function () { return utils; });
|
|
12236
|
+
const token = await getIdToken(this.isServer);
|
|
12237
|
+
if (token)
|
|
12238
|
+
this.authToken = token;
|
|
12137
12239
|
}
|
|
12240
|
+
catch ( /* no auth available */_a) { /* no auth available */ }
|
|
12241
|
+
}
|
|
12242
|
+
startTokenRefresh() {
|
|
12243
|
+
if (this.tokenRefreshTimer)
|
|
12244
|
+
return;
|
|
12245
|
+
this.tokenRefreshTimer = setInterval(async () => {
|
|
12246
|
+
var _a;
|
|
12247
|
+
const prevToken = this.authToken;
|
|
12248
|
+
await this.refreshToken();
|
|
12249
|
+
if (this.authToken && this.authToken !== prevToken && ((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN) {
|
|
12250
|
+
// Token changed — reconnect with fresh token
|
|
12251
|
+
this.ws.close(1000, 'Token refreshed');
|
|
12252
|
+
}
|
|
12253
|
+
}, 5 * 60 * 1000); // Check every 5 minutes
|
|
12138
12254
|
}
|
|
12139
|
-
// -----------------------------------------------------------------------
|
|
12140
|
-
// WebSocket connection
|
|
12141
|
-
// -----------------------------------------------------------------------
|
|
12142
12255
|
async ensureConnected() {
|
|
12143
12256
|
var _a;
|
|
12257
|
+
if (!this.appId) {
|
|
12258
|
+
if (!this.initPromise)
|
|
12259
|
+
this.initPromise = this.init();
|
|
12260
|
+
await this.initPromise;
|
|
12261
|
+
}
|
|
12144
12262
|
if (((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === WebSocket.OPEN)
|
|
12145
12263
|
return;
|
|
12146
12264
|
if (this.connectPromise)
|
|
@@ -12156,10 +12274,12 @@ class RealtimeStore {
|
|
|
12156
12274
|
}
|
|
12157
12275
|
const params = new URLSearchParams();
|
|
12158
12276
|
params.set('apiKey', this.appId);
|
|
12159
|
-
|
|
12277
|
+
if (this.authToken)
|
|
12278
|
+
params.set('authorization', this.authToken);
|
|
12279
|
+
// Note: token in URL is required until DO server supports subprotocol auth.
|
|
12280
|
+
// WSS encrypts the full URL including query params on the wire.
|
|
12160
12281
|
const url = `${this.wsUrl}?${params.toString()}`;
|
|
12161
|
-
const
|
|
12162
|
-
const ws = protocols ? new WebSocket(url, protocols) : new WebSocket(url);
|
|
12282
|
+
const ws = new WebSocket(url);
|
|
12163
12283
|
this.ws = ws;
|
|
12164
12284
|
const onOpen = () => {
|
|
12165
12285
|
ws.removeEventListener('error', onError);
|
|
@@ -12790,6 +12910,8 @@ class RealtimeStore {
|
|
|
12790
12910
|
clearTimeout(this.reconnectTimer);
|
|
12791
12911
|
if (this.idbFlushTimer)
|
|
12792
12912
|
clearTimeout(this.idbFlushTimer);
|
|
12913
|
+
if (this.tokenRefreshTimer)
|
|
12914
|
+
clearInterval(this.tokenRefreshTimer);
|
|
12793
12915
|
this.flushIdb();
|
|
12794
12916
|
if (this.ws) {
|
|
12795
12917
|
this.ws.close(1000, 'Store closed');
|
|
@@ -13163,6 +13285,15 @@ class OffchainAuthProvider {
|
|
|
13163
13285
|
async getNativeMethods() {
|
|
13164
13286
|
return this.wrappedProvider.getNativeMethods();
|
|
13165
13287
|
}
|
|
13288
|
+
// Forward wallet export to the wrapped provider (only Privy embedded wallets
|
|
13289
|
+
// implement it). Duck-typed so wrappers around non-embedded providers throw
|
|
13290
|
+
// a clear error rather than a "not a function" crash.
|
|
13291
|
+
async exportWallet(address) {
|
|
13292
|
+
if (typeof this.wrappedProvider.exportWallet !== 'function') {
|
|
13293
|
+
throw new Error('Wallet export is not available for this wallet.');
|
|
13294
|
+
}
|
|
13295
|
+
await this.wrappedProvider.exportWallet(address);
|
|
13296
|
+
}
|
|
13166
13297
|
// ============ signMessage delegates to wrapped provider ============
|
|
13167
13298
|
async signMessage(message) {
|
|
13168
13299
|
// Delegate to wrapped provider for real wallet signing
|
|
@@ -14133,7 +14264,11 @@ async function login$1(options) {
|
|
|
14133
14264
|
return null;
|
|
14134
14265
|
}
|
|
14135
14266
|
function getCurrentAuthMethod() {
|
|
14136
|
-
|
|
14267
|
+
// Fall back to the persisted login method so consumers (e.g. a "show export
|
|
14268
|
+
// wallet" gate) get the correct value synchronously on reload, before init()
|
|
14269
|
+
// has rebuilt the in-memory provider. The stored value is cleared on logout,
|
|
14270
|
+
// so a logged-out user still yields null.
|
|
14271
|
+
return currentAuthMethod !== null && currentAuthMethod !== void 0 ? currentAuthMethod : getStoredAuthMethod();
|
|
14137
14272
|
}
|
|
14138
14273
|
async function logout$1() {
|
|
14139
14274
|
if (!currentAuthProvider) {
|
|
@@ -14144,6 +14279,21 @@ async function logout$1() {
|
|
|
14144
14279
|
currentAuthProvider = null;
|
|
14145
14280
|
currentAuthMethod = null;
|
|
14146
14281
|
}
|
|
14282
|
+
/**
|
|
14283
|
+
* Opens the active provider's wallet-export flow (Privy's hosted modal). Only
|
|
14284
|
+
* embedded (email) wallets implement `exportWallet`; external wallets (Phantom)
|
|
14285
|
+
* throw. The private key is revealed only to the user on Privy's origin — it is
|
|
14286
|
+
* never exposed to this SDK or the host app.
|
|
14287
|
+
*/
|
|
14288
|
+
async function exportWallet(address) {
|
|
14289
|
+
if (!currentAuthProvider) {
|
|
14290
|
+
throw new Error("Auth provider not initialized. Please call init() first.");
|
|
14291
|
+
}
|
|
14292
|
+
if (typeof currentAuthProvider.exportWallet !== 'function') {
|
|
14293
|
+
throw new Error("Wallet export is only available for embedded (email) wallets.");
|
|
14294
|
+
}
|
|
14295
|
+
await currentAuthProvider.exportWallet(address);
|
|
14296
|
+
}
|
|
14147
14297
|
|
|
14148
14298
|
let authProviderInstance = null;
|
|
14149
14299
|
let currentUser = null;
|
|
@@ -16820,7 +16970,7 @@ async function loadDependencies() {
|
|
|
16820
16970
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
16821
16971
|
import('react'),
|
|
16822
16972
|
import('react-dom/client'),
|
|
16823
|
-
Promise.resolve().then(function () { return require('./index-
|
|
16973
|
+
Promise.resolve().then(function () { return require('./index-CdKrnAsF.js'); })
|
|
16824
16974
|
]);
|
|
16825
16975
|
// Extract default export from ESM module namespace
|
|
16826
16976
|
// Dynamic import() returns { default: Module, ...exports }, not the module directly
|
|
@@ -21977,6 +22127,25 @@ class PrivyWalletProvider {
|
|
|
21977
22127
|
await this.ensureReady();
|
|
21978
22128
|
return (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.usePrivy;
|
|
21979
22129
|
}
|
|
22130
|
+
/**
|
|
22131
|
+
* Opens Privy's hosted export modal so the user can reveal/copy the private key
|
|
22132
|
+
* for their embedded Solana wallet. The key is assembled on Privy's origin —
|
|
22133
|
+
* neither this SDK nor the host app ever receives it. Only available for Privy
|
|
22134
|
+
* embedded wallets (email login); throws otherwise.
|
|
22135
|
+
*/
|
|
22136
|
+
async exportWallet(address) {
|
|
22137
|
+
var _a, _b;
|
|
22138
|
+
await this.ensureReady({ waitForWallets: true });
|
|
22139
|
+
const exportFn = (_b = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.useSolanaWallets) === null || _b === void 0 ? void 0 : _b.exportWallet;
|
|
22140
|
+
if (typeof exportFn !== 'function') {
|
|
22141
|
+
throw new Error('Wallet export is not available for this wallet.');
|
|
22142
|
+
}
|
|
22143
|
+
// Default to the session's embedded wallet address so the correct wallet is
|
|
22144
|
+
// exported in any HD/multi-wallet case; omit to let Privy export index 0.
|
|
22145
|
+
const session = await WebSessionManager.getSession();
|
|
22146
|
+
const target = address !== null && address !== void 0 ? address : session === null || session === void 0 ? void 0 : session.address;
|
|
22147
|
+
await exportFn(target ? { address: target } : undefined);
|
|
22148
|
+
}
|
|
21980
22149
|
async logout() {
|
|
21981
22150
|
await this.ensureReady();
|
|
21982
22151
|
await this.privyMethods.logout();
|
|
@@ -23052,7 +23221,7 @@ async function registerMobileWalletAdapter(config) {
|
|
|
23052
23221
|
if (typeof window === 'undefined')
|
|
23053
23222
|
return;
|
|
23054
23223
|
try {
|
|
23055
|
-
const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-
|
|
23224
|
+
const walletStandardMobile = await Promise.resolve().then(function () { return require('./index.browser-Um9-5Cbs.js'); });
|
|
23056
23225
|
const registerMwa = walletStandardMobile.registerMwa || ((_a = walletStandardMobile.default) === null || _a === void 0 ? void 0 : _a.registerMwa);
|
|
23057
23226
|
if (!registerMwa) {
|
|
23058
23227
|
console.warn('[SolanaMobileWallet] registerMwa not found in @solana-mobile/wallet-standard-mobile');
|
|
@@ -23191,7 +23360,7 @@ class SolanaMobileWalletProvider {
|
|
|
23191
23360
|
async ensureWallet() {
|
|
23192
23361
|
if (this.wallet)
|
|
23193
23362
|
return this.wallet;
|
|
23194
|
-
const mod = await Promise.resolve().then(function () { return require('./index.browser-
|
|
23363
|
+
const mod = await Promise.resolve().then(function () { return require('./index.browser-Um9-5Cbs.js'); });
|
|
23195
23364
|
const chain = mapChainToWalletStandard(this.cluster);
|
|
23196
23365
|
this.wallet = new mod.LocalSolanaMobileWalletAdapterWallet({
|
|
23197
23366
|
appIdentity: this.appIdentity,
|
|
@@ -24401,11 +24570,13 @@ exports.bufferExports = bufferExports;
|
|
|
24401
24570
|
exports.buildSetDocumentsTransaction = buildSetDocumentsTransaction;
|
|
24402
24571
|
exports.clearCache = clearCache;
|
|
24403
24572
|
exports.closeAllSubscriptions = closeAllSubscriptions;
|
|
24573
|
+
exports.commonjsRequire = commonjsRequire;
|
|
24404
24574
|
exports.convertRemainingAccounts = convertRemainingAccounts;
|
|
24405
24575
|
exports.count = count;
|
|
24406
24576
|
exports.createSessionWithPrivy = createSessionWithPrivy;
|
|
24407
24577
|
exports.createSessionWithSignature = createSessionWithSignature;
|
|
24408
24578
|
exports.deserializeTransaction = deserializeTransaction;
|
|
24579
|
+
exports.exportWallet = exportWallet;
|
|
24409
24580
|
exports.genAuthNonce = genAuthNonce;
|
|
24410
24581
|
exports.genSolanaMessage = genSolanaMessage;
|
|
24411
24582
|
exports.get = get;
|
|
@@ -24413,6 +24584,7 @@ exports.getAuthLoading = getAuthLoading;
|
|
|
24413
24584
|
exports.getAuthProvider = getAuthProvider;
|
|
24414
24585
|
exports.getCachedData = getCachedData;
|
|
24415
24586
|
exports.getConfig = getConfig;
|
|
24587
|
+
exports.getCurrentAuthMethod = getCurrentAuthMethod;
|
|
24416
24588
|
exports.getCurrentUser = getCurrentUser;
|
|
24417
24589
|
exports.getDefaultExportFromCjs = getDefaultExportFromCjs$1;
|
|
24418
24590
|
exports.getFiles = getFiles;
|
|
@@ -24430,6 +24602,7 @@ exports.onAuthStateChanged = onAuthStateChanged;
|
|
|
24430
24602
|
exports.reconnectWithNewAuth = reconnectWithNewAuth;
|
|
24431
24603
|
exports.refreshSession = refreshSession;
|
|
24432
24604
|
exports.registerMobileWalletAdapter = registerMobileWalletAdapter;
|
|
24605
|
+
exports.require$$0 = require$$0;
|
|
24433
24606
|
exports.resetRealtimeStore = resetRealtimeStore;
|
|
24434
24607
|
exports.runExpression = runExpression;
|
|
24435
24608
|
exports.runExpressionMany = runExpressionMany;
|
|
@@ -24450,4 +24623,4 @@ exports.wsGet = wsGet;
|
|
|
24450
24623
|
exports.wsGetMany = wsGetMany;
|
|
24451
24624
|
exports.wsQuery = wsQuery;
|
|
24452
24625
|
exports.wsSet = wsSet;
|
|
24453
|
-
//# sourceMappingURL=index-
|
|
24626
|
+
//# sourceMappingURL=index-DOz63COz.js.map
|