@pooflabs/web 0.0.28 → 0.0.29
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/index.esm.js +45 -42
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +45 -42
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -10344,7 +10344,7 @@ class PhantomWalletProvider {
|
|
|
10344
10344
|
} : null,
|
|
10345
10345
|
};
|
|
10346
10346
|
}
|
|
10347
|
-
}, [phantom, phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, connect, disconnect, isDisconnecting, modal, modal.isOpened, solana, connectError]);
|
|
10347
|
+
}, [phantom, phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, connect, disconnect, isDisconnecting, modal, modal.isOpened, solana, solana === null || solana === void 0 ? void 0 : solana.isAvailable, connectError]);
|
|
10348
10348
|
// Handle modal close without connection
|
|
10349
10349
|
React$1.useEffect(() => {
|
|
10350
10350
|
// Detect when modal was open and is now closed
|
|
@@ -10371,52 +10371,55 @@ class PhantomWalletProvider {
|
|
|
10371
10371
|
React$1.useEffect(() => {
|
|
10372
10372
|
const handleConnectionSuccess = async () => {
|
|
10373
10373
|
var _a;
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10392
|
-
|
|
10393
|
-
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
|
|
10397
|
-
|
|
10398
|
-
|
|
10399
|
-
return;
|
|
10400
|
-
}
|
|
10401
|
-
// Create new session with signature
|
|
10402
|
-
const nonce = await genAuthNonce();
|
|
10403
|
-
const messageText = await genSolanaMessage(publicKey, nonce);
|
|
10404
|
-
// signMessage returns a string directly
|
|
10405
|
-
const signature = await solana.signMessage(messageText);
|
|
10406
|
-
const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
|
|
10407
|
-
await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
|
|
10374
|
+
// All conditions must be met for login to proceed
|
|
10375
|
+
if (!(phantom === null || phantom === void 0 ? void 0 : phantom.isConnected) || !((_a = phantom === null || phantom === void 0 ? void 0 : phantom.addresses) === null || _a === void 0 ? void 0 : _a.length) || !that.pendingLogin || !that.loginInProgress) {
|
|
10376
|
+
return;
|
|
10377
|
+
}
|
|
10378
|
+
// Solana must be available for signing
|
|
10379
|
+
// If not ready yet, just return - this effect will re-run when solana?.isAvailable changes
|
|
10380
|
+
if (!solana || !solana.isAvailable) {
|
|
10381
|
+
console.log('[Phantom] Waiting for Solana to be available...');
|
|
10382
|
+
return;
|
|
10383
|
+
}
|
|
10384
|
+
try {
|
|
10385
|
+
// Immediately set loginInProgress to false to prevent double execution
|
|
10386
|
+
// if the effect runs again before async operations complete
|
|
10387
|
+
that.loginInProgress = false;
|
|
10388
|
+
// Find Solana address
|
|
10389
|
+
const solAddress = phantom.addresses.find((addr) => addr.addressType === AddressType.solana);
|
|
10390
|
+
if (!solAddress) {
|
|
10391
|
+
that.pendingLogin.reject(new Error('No Solana address returned'));
|
|
10392
|
+
that.pendingLogin = null;
|
|
10393
|
+
return;
|
|
10394
|
+
}
|
|
10395
|
+
const publicKey = solAddress.address;
|
|
10396
|
+
// Check if we already have a valid session
|
|
10397
|
+
const existingSession = await WebSessionManager.getSession();
|
|
10398
|
+
if (existingSession && existingSession.address === publicKey) {
|
|
10408
10399
|
const user = { provider: that, address: publicKey };
|
|
10409
10400
|
setCurrentUser(user);
|
|
10410
10401
|
that.pendingLogin.resolve(user);
|
|
10411
10402
|
that.pendingLogin = null;
|
|
10412
|
-
|
|
10403
|
+
return;
|
|
10413
10404
|
}
|
|
10414
|
-
|
|
10415
|
-
|
|
10416
|
-
|
|
10417
|
-
|
|
10418
|
-
|
|
10419
|
-
|
|
10405
|
+
console.log('[Phantom] Creating session with signature...');
|
|
10406
|
+
// Create new session with signature
|
|
10407
|
+
const nonce = await genAuthNonce();
|
|
10408
|
+
const messageText = await genSolanaMessage(publicKey, nonce);
|
|
10409
|
+
// signMessage returns a string directly - this should trigger the Phantom sign popup
|
|
10410
|
+
const signature = await solana.signMessage(messageText);
|
|
10411
|
+
const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
|
|
10412
|
+
await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
|
|
10413
|
+
const user = { provider: that, address: publicKey };
|
|
10414
|
+
setCurrentUser(user);
|
|
10415
|
+
that.pendingLogin.resolve(user);
|
|
10416
|
+
that.pendingLogin = null;
|
|
10417
|
+
}
|
|
10418
|
+
catch (error) {
|
|
10419
|
+
if (that.pendingLogin) {
|
|
10420
|
+
that.pendingLogin.reject(error);
|
|
10421
|
+
that.pendingLogin = null;
|
|
10422
|
+
that.loginInProgress = false;
|
|
10420
10423
|
}
|
|
10421
10424
|
}
|
|
10422
10425
|
};
|