@pooflabs/web 0.0.35 → 0.0.36
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/providers/privy-wallet-provider.d.ts +2 -0
- package/dist/{index-BLvoqeoa.js → index-Bfy2Olqg.js} +2 -2
- package/dist/{index-BLvoqeoa.js.map → index-Bfy2Olqg.js.map} +1 -1
- package/dist/{index-HhgbHQ0x.esm.js → index-BnwDqQL8.esm.js} +2 -2
- package/dist/{index-HhgbHQ0x.esm.js.map → index-BnwDqQL8.esm.js.map} +1 -1
- package/dist/{index-7EM1gtmw.js → index-BwuRyd6v.js} +100 -20
- package/dist/index-BwuRyd6v.js.map +1 -0
- package/dist/{index-BBhosQh0.esm.js → index-DuYoGtxT.esm.js} +100 -20
- package/dist/index-DuYoGtxT.esm.js.map +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -1
- package/dist/index-7EM1gtmw.js.map +0 -1
- package/dist/index-BBhosQh0.esm.js.map +0 -1
|
@@ -11920,6 +11920,11 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
11920
11920
|
if (_overrides === null || _overrides === void 0 ? void 0 : _overrides.headers) {
|
|
11921
11921
|
Object.assign(headers, _overrides.headers);
|
|
11922
11922
|
}
|
|
11923
|
+
// Signal to backend that client supports offchain transaction signing
|
|
11924
|
+
if (typeof window !== "undefined" &&
|
|
11925
|
+
window.TAROBASE_SUPPORTS_OFFCHAIN_SIGNING) {
|
|
11926
|
+
headers["X-Supports-Offchain-Signing"] = "true";
|
|
11927
|
+
}
|
|
11923
11928
|
const requestConfig = {
|
|
11924
11929
|
method,
|
|
11925
11930
|
url: `${config.apiUrl}${urlPath.startsWith("/") ? urlPath : `/${urlPath}`}`,
|
|
@@ -12302,7 +12307,6 @@ async function setMany(many, options) {
|
|
|
12302
12307
|
return transactionResult;
|
|
12303
12308
|
}
|
|
12304
12309
|
async function handleOffchainTransaction(tx, authProvider, options) {
|
|
12305
|
-
var _a, _b, _c, _d, _e;
|
|
12306
12310
|
const config = await getConfig();
|
|
12307
12311
|
// 1. Sign the transaction message using the auth provider
|
|
12308
12312
|
const signature = await authProvider.signMessage(tx.message);
|
|
@@ -12319,19 +12323,10 @@ async function setMany(many, options) {
|
|
|
12319
12323
|
};
|
|
12320
12324
|
}
|
|
12321
12325
|
// 4. Submit to RPC endpoint
|
|
12322
|
-
|
|
12323
|
-
const appId = ((_b = (_a = options === null || options === void 0 ? void 0 : options._overrides) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b['x-app-id']) || ((_d = (_c = options === null || options === void 0 ? void 0 : options._overrides) === null || _c === void 0 ? void 0 : _c.headers) === null || _d === void 0 ? void 0 : _d['X-App-Id']) || config.appId;
|
|
12324
|
-
const rpcUrl = `${config.apiUrl}/app/${appId}/rpc`;
|
|
12325
|
-
// Build headers, applying overrides if provided
|
|
12326
|
-
const headers = {
|
|
12327
|
-
'Content-Type': 'application/json',
|
|
12328
|
-
};
|
|
12329
|
-
if ((_e = options === null || options === void 0 ? void 0 : options._overrides) === null || _e === void 0 ? void 0 : _e.headers) {
|
|
12330
|
-
Object.assign(headers, options._overrides.headers);
|
|
12331
|
-
}
|
|
12326
|
+
const rpcUrl = `${config.apiUrl}/app/${config.appId}/rpc`;
|
|
12332
12327
|
const rpcResponse = await fetch(rpcUrl, {
|
|
12333
12328
|
method: 'POST',
|
|
12334
|
-
headers,
|
|
12329
|
+
headers: { 'Content-Type': 'application/json' },
|
|
12335
12330
|
body: JSON.stringify({
|
|
12336
12331
|
jsonrpc: '2.0',
|
|
12337
12332
|
id: 1,
|
|
@@ -12637,7 +12632,7 @@ async function loadDependencies() {
|
|
|
12637
12632
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
12638
12633
|
import('react'),
|
|
12639
12634
|
import('react-dom/client'),
|
|
12640
|
-
import('./index-
|
|
12635
|
+
import('./index-BnwDqQL8.esm.js')
|
|
12641
12636
|
]);
|
|
12642
12637
|
React$1 = reactModule;
|
|
12643
12638
|
ReactDOM$1 = reactDomModule;
|
|
@@ -30194,6 +30189,10 @@ class PrivyWalletProvider {
|
|
|
30194
30189
|
this.pendingLogin = null;
|
|
30195
30190
|
// This is used to store the pending transaction until the wallet is connected for workaround for the wallet not being connected after login completion
|
|
30196
30191
|
this.pendingTransaction = null;
|
|
30192
|
+
// This is used to store pending signTransaction calls until the wallet is connected
|
|
30193
|
+
this.pendingSignTransaction = null;
|
|
30194
|
+
// This is used to store pending signMessage calls until the wallet is connected
|
|
30195
|
+
this.pendingSignMessage = null;
|
|
30197
30196
|
this.networkUrl = networkUrl;
|
|
30198
30197
|
if (typeof window === 'undefined') {
|
|
30199
30198
|
throw new Error('PrivyWalletProvider can only be instantiated in a browser environment');
|
|
@@ -30220,9 +30219,11 @@ class PrivyWalletProvider {
|
|
|
30220
30219
|
if (networkUrl != null) {
|
|
30221
30220
|
if (networkUrl.includes('mainnet')) {
|
|
30222
30221
|
mainnetUrl = networkUrl;
|
|
30222
|
+
this.chainId = 'solana:mainnet';
|
|
30223
30223
|
}
|
|
30224
30224
|
else if (networkUrl.includes('devnet')) {
|
|
30225
30225
|
devnetUrl = networkUrl;
|
|
30226
|
+
this.chainId = 'solana:devnet';
|
|
30226
30227
|
}
|
|
30227
30228
|
}
|
|
30228
30229
|
if (!this.privyConfig.config.solana) {
|
|
@@ -30283,6 +30284,30 @@ class PrivyWalletProvider {
|
|
|
30283
30284
|
}
|
|
30284
30285
|
that.pendingTransaction = null;
|
|
30285
30286
|
}
|
|
30287
|
+
// If there's a pending signTransaction, execute it now
|
|
30288
|
+
if (that.pendingSignTransaction) {
|
|
30289
|
+
const { transaction, resolve, reject } = that.pendingSignTransaction;
|
|
30290
|
+
try {
|
|
30291
|
+
const result = await that.signTransaction(transaction);
|
|
30292
|
+
resolve(result);
|
|
30293
|
+
}
|
|
30294
|
+
catch (error) {
|
|
30295
|
+
reject(error);
|
|
30296
|
+
}
|
|
30297
|
+
that.pendingSignTransaction = null;
|
|
30298
|
+
}
|
|
30299
|
+
// If there's a pending signMessage, execute it now
|
|
30300
|
+
if (that.pendingSignMessage) {
|
|
30301
|
+
const { message, resolve, reject } = that.pendingSignMessage;
|
|
30302
|
+
try {
|
|
30303
|
+
const result = await that.signMessage(message);
|
|
30304
|
+
resolve(result);
|
|
30305
|
+
}
|
|
30306
|
+
catch (error) {
|
|
30307
|
+
reject(error);
|
|
30308
|
+
}
|
|
30309
|
+
that.pendingSignMessage = null;
|
|
30310
|
+
}
|
|
30286
30311
|
},
|
|
30287
30312
|
onError: (error) => {
|
|
30288
30313
|
// Only log errors that aren't user-initiated cancellations
|
|
@@ -30293,6 +30318,14 @@ class PrivyWalletProvider {
|
|
|
30293
30318
|
that.pendingTransaction.reject(error);
|
|
30294
30319
|
that.pendingTransaction = null;
|
|
30295
30320
|
}
|
|
30321
|
+
if (that.pendingSignTransaction) {
|
|
30322
|
+
that.pendingSignTransaction.reject(error);
|
|
30323
|
+
that.pendingSignTransaction = null;
|
|
30324
|
+
}
|
|
30325
|
+
if (that.pendingSignMessage) {
|
|
30326
|
+
that.pendingSignMessage.reject(error);
|
|
30327
|
+
that.pendingSignMessage = null;
|
|
30328
|
+
}
|
|
30296
30329
|
}
|
|
30297
30330
|
});
|
|
30298
30331
|
const { login } = privyImports.useLogin({
|
|
@@ -30598,19 +30631,47 @@ class PrivyWalletProvider {
|
|
|
30598
30631
|
let session = await WebSessionManager.getSession();
|
|
30599
30632
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
30600
30633
|
let privyWallet = privyWallets === null || privyWallets === void 0 ? void 0 : privyWallets.find((wallet) => wallet.address === sessionAddress);
|
|
30601
|
-
// If there's already a pending transaction, throw an error to prevent overlapping calls
|
|
30602
|
-
if (this.
|
|
30634
|
+
// If there's already a pending sign transaction, throw an error to prevent overlapping calls
|
|
30635
|
+
if (this.pendingSignTransaction) {
|
|
30603
30636
|
throw new Error("Oops... something went wrong. Please try again.");
|
|
30604
30637
|
}
|
|
30605
|
-
|
|
30606
|
-
|
|
30638
|
+
// If wallet not connected, trigger connection and queue the signing
|
|
30639
|
+
if (!privyWallets || privyWallets.length === 0 || !privyWallet) {
|
|
30640
|
+
return new Promise((resolve, reject) => {
|
|
30641
|
+
this.pendingSignTransaction = {
|
|
30642
|
+
resolve,
|
|
30643
|
+
reject,
|
|
30644
|
+
transaction
|
|
30645
|
+
};
|
|
30646
|
+
this.privyMethods.connectWallet();
|
|
30647
|
+
// Set a timeout to reject the promise if connection takes too long
|
|
30648
|
+
setTimeout(() => {
|
|
30649
|
+
if (this.pendingSignTransaction) {
|
|
30650
|
+
this.pendingSignTransaction.reject(new Error("Wallet connection timed out"));
|
|
30651
|
+
this.pendingSignTransaction = null;
|
|
30652
|
+
}
|
|
30653
|
+
}, 30000); // 30 seconds timeout
|
|
30654
|
+
});
|
|
30607
30655
|
}
|
|
30608
30656
|
const serializedForSign = transaction.serialize({ requireAllSignatures: false, verifySignatures: false });
|
|
30609
|
-
|
|
30657
|
+
const result = await ((_b = this.privyMethods) === null || _b === void 0 ? void 0 : _b.signTransaction({
|
|
30610
30658
|
transaction: serializedForSign,
|
|
30611
30659
|
wallet: privyWallet,
|
|
30612
30660
|
chain: this.chainId
|
|
30613
30661
|
}));
|
|
30662
|
+
// Privy returns { signedTransaction: Uint8Array }, unwrap and deserialize to match interface
|
|
30663
|
+
const signedBytes = (result === null || result === void 0 ? void 0 : result.signedTransaction) || result;
|
|
30664
|
+
if (signedBytes instanceof Uint8Array || Buffer.isBuffer(signedBytes)) {
|
|
30665
|
+
// Try to deserialize as VersionedTransaction first, fall back to legacy Transaction
|
|
30666
|
+
try {
|
|
30667
|
+
return VersionedTransaction.deserialize(signedBytes);
|
|
30668
|
+
}
|
|
30669
|
+
catch (_c) {
|
|
30670
|
+
return Transaction.from(signedBytes);
|
|
30671
|
+
}
|
|
30672
|
+
}
|
|
30673
|
+
// If already a Transaction object, return as-is
|
|
30674
|
+
return signedBytes;
|
|
30614
30675
|
}
|
|
30615
30676
|
catch (error) {
|
|
30616
30677
|
throw new Error(`Failed to sign and send serialized transaction: ${error.message}`);
|
|
@@ -30621,8 +30682,27 @@ class PrivyWalletProvider {
|
|
|
30621
30682
|
await this.ensureReady();
|
|
30622
30683
|
const session = await WebSessionManager.getSession();
|
|
30623
30684
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
30685
|
+
// If there's already a pending sign message, throw an error to prevent overlapping calls
|
|
30686
|
+
if (this.pendingSignMessage) {
|
|
30687
|
+
throw new Error("Oops... something went wrong. Please try again.");
|
|
30688
|
+
}
|
|
30689
|
+
// If no wallets connected, trigger wallet connection and queue the signing
|
|
30624
30690
|
if (!((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets) || this.privyMethods.wallets.length === 0) {
|
|
30625
|
-
|
|
30691
|
+
return new Promise((resolve, reject) => {
|
|
30692
|
+
this.pendingSignMessage = {
|
|
30693
|
+
resolve,
|
|
30694
|
+
reject,
|
|
30695
|
+
message
|
|
30696
|
+
};
|
|
30697
|
+
this.privyMethods.connectWallet();
|
|
30698
|
+
// Set a timeout to reject the promise if connection takes too long
|
|
30699
|
+
setTimeout(() => {
|
|
30700
|
+
if (this.pendingSignMessage) {
|
|
30701
|
+
this.pendingSignMessage.reject(new Error("Wallet connection timed out"));
|
|
30702
|
+
this.pendingSignMessage = null;
|
|
30703
|
+
}
|
|
30704
|
+
}, 30000); // 30 seconds timeout
|
|
30705
|
+
});
|
|
30626
30706
|
}
|
|
30627
30707
|
let privyWallet = this.privyMethods.wallets.find((wallet) => wallet.address === sessionAddress);
|
|
30628
30708
|
if (!privyWallet) {
|
|
@@ -31588,4 +31668,4 @@ async function getIdToken() {
|
|
|
31588
31668
|
}
|
|
31589
31669
|
|
|
31590
31670
|
export { createSessionWithPrivy as A, createSessionWithSignature as B, genAuthNonce as C, DEFAULT_TEST_ADDRESS as D, genSolanaMessage as E, refreshSession as F, signSessionCreateMessage as G, MockAuthProvider as M, OffchainAuthProvider as O, PhantomWalletProvider as P, ServerSessionManager as S, WebSessionManager as W, getCurrentUser as a, bufferExports$1 as b, onAuthLoadingChanged as c, getAuthLoading as d, logout as e, getConfig as f, getDefaultExportFromCjs$1 as g, getAuthProvider as h, init as i, get$2 as j, setMany as k, login as l, setFile as m, getFiles as n, onAuthStateChanged as o, runQueryMany as p, runExpression as q, runQuery as r, set$1 as s, runExpressionMany as t, subscribe as u, useAuth as v, getIdToken as w, PrivyWalletProvider as x, buildSetDocumentsTransaction as y, convertRemainingAccounts as z };
|
|
31591
|
-
//# sourceMappingURL=index-
|
|
31671
|
+
//# sourceMappingURL=index-DuYoGtxT.esm.js.map
|