@pooflabs/web 0.0.31 → 0.0.32
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/phantom-wallet-provider.d.ts +5 -0
- package/dist/{index-BzYf0Bnq.js → index-BnFIg6Xc.js} +57 -13
- package/dist/{index-BzYf0Bnq.js.map → index-BnFIg6Xc.js.map} +1 -1
- package/dist/{index-CEiYEW9z.esm.js → index-CclX1hTc.esm.js} +57 -13
- package/dist/{index-CEiYEW9z.esm.js.map → index-CclX1hTc.esm.js.map} +1 -1
- package/dist/{index-DXYtcpKo.js → index-DhF1Kbht.js} +2 -2
- package/dist/{index-DXYtcpKo.js.map → index-DhF1Kbht.js.map} +1 -1
- package/dist/{index-DzRkhhqy.esm.js → index-ev48HLj5.esm.js} +2 -2
- package/dist/{index-DzRkhhqy.esm.js.map → index-ev48HLj5.esm.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -24,9 +24,14 @@ export declare class PhantomWalletProvider implements AuthProvider {
|
|
|
24
24
|
private resolvedProviders;
|
|
25
25
|
private pendingLogin;
|
|
26
26
|
private loginInProgress;
|
|
27
|
+
private autoLoginInProgress;
|
|
27
28
|
private initPromise;
|
|
28
29
|
constructor(networkUrl?: string | null, config?: PhantomWalletConfig);
|
|
29
30
|
private initializeAsync;
|
|
31
|
+
/**
|
|
32
|
+
* Check if social login providers are configured (non-injected providers).
|
|
33
|
+
*/
|
|
34
|
+
private hasSocialProviders;
|
|
30
35
|
static getInstance(networkUrl: string | null, config: PhantomWalletConfig): PhantomWalletProvider;
|
|
31
36
|
private resolveProviders;
|
|
32
37
|
private initialize;
|
|
@@ -12652,7 +12652,7 @@ async function loadDependencies() {
|
|
|
12652
12652
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
12653
12653
|
import('react'),
|
|
12654
12654
|
import('react-dom/client'),
|
|
12655
|
-
Promise.resolve().then(function () { return require('./index-
|
|
12655
|
+
Promise.resolve().then(function () { return require('./index-DhF1Kbht.js'); })
|
|
12656
12656
|
]);
|
|
12657
12657
|
React$1 = reactModule;
|
|
12658
12658
|
ReactDOM$1 = reactDomModule;
|
|
@@ -12669,6 +12669,7 @@ class PhantomWalletProvider {
|
|
|
12669
12669
|
this.resolvedProviders = ['injected'];
|
|
12670
12670
|
this.pendingLogin = null;
|
|
12671
12671
|
this.loginInProgress = false;
|
|
12672
|
+
this.autoLoginInProgress = false;
|
|
12672
12673
|
this.initPromise = null;
|
|
12673
12674
|
this.networkUrl = networkUrl;
|
|
12674
12675
|
this.config = config;
|
|
@@ -12691,6 +12692,12 @@ class PhantomWalletProvider {
|
|
|
12691
12692
|
// Initialize React component
|
|
12692
12693
|
this.initialize();
|
|
12693
12694
|
}
|
|
12695
|
+
/**
|
|
12696
|
+
* Check if social login providers are configured (non-injected providers).
|
|
12697
|
+
*/
|
|
12698
|
+
hasSocialProviders() {
|
|
12699
|
+
return this.resolvedProviders.some(p => p !== 'injected');
|
|
12700
|
+
}
|
|
12694
12701
|
static getInstance(networkUrl, config) {
|
|
12695
12702
|
if (!PhantomWalletProvider.instance) {
|
|
12696
12703
|
new PhantomWalletProvider(networkUrl, config);
|
|
@@ -12766,16 +12773,48 @@ class PhantomWalletProvider {
|
|
|
12766
12773
|
};
|
|
12767
12774
|
}
|
|
12768
12775
|
}, [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, solanaHook.isAvailable, connectError]);
|
|
12769
|
-
// Auto-
|
|
12770
|
-
// This handles
|
|
12776
|
+
// Auto-login: If connected but no Tarobase session, try to create one.
|
|
12777
|
+
// This handles social login callbacks where user returns from OAuth already connected.
|
|
12771
12778
|
React$1.useEffect(() => {
|
|
12772
|
-
const
|
|
12773
|
-
|
|
12774
|
-
|
|
12779
|
+
const autoCreateSession = async () => {
|
|
12780
|
+
var _a;
|
|
12781
|
+
// Only proceed when SDK is ready, connected, has addresses, and not already in a login flow
|
|
12782
|
+
if (!(phantom === null || phantom === void 0 ? void 0 : phantom.isConnected) || (phantom === null || phantom === void 0 ? void 0 : phantom.isLoading) || that.loginInProgress || that.autoLoginInProgress || that.pendingLogin) {
|
|
12783
|
+
return;
|
|
12784
|
+
}
|
|
12785
|
+
// Need solana to be available for signing
|
|
12786
|
+
if (!solana || !solanaHook.isAvailable) {
|
|
12787
|
+
return;
|
|
12788
|
+
}
|
|
12789
|
+
// Find Solana address
|
|
12790
|
+
const solAddress = (_a = phantom.addresses) === null || _a === void 0 ? void 0 : _a.find((addr) => addr.addressType === AddressType.solana);
|
|
12791
|
+
if (!solAddress) {
|
|
12775
12792
|
return;
|
|
12776
12793
|
}
|
|
12777
|
-
const
|
|
12778
|
-
if
|
|
12794
|
+
const publicKey = solAddress.address;
|
|
12795
|
+
// Check if we already have a valid session for this address
|
|
12796
|
+
const existingSession = await WebSessionManager.getSession();
|
|
12797
|
+
if (existingSession && existingSession.address === publicKey) {
|
|
12798
|
+
// Already have a valid session, nothing to do
|
|
12799
|
+
setCurrentUser({ provider: that, address: publicKey });
|
|
12800
|
+
return;
|
|
12801
|
+
}
|
|
12802
|
+
// No valid session - try to create one automatically
|
|
12803
|
+
that.autoLoginInProgress = true;
|
|
12804
|
+
try {
|
|
12805
|
+
const nonce = await genAuthNonce();
|
|
12806
|
+
const messageText = await genSolanaMessage(publicKey, nonce);
|
|
12807
|
+
// signMessage returns { signature: Uint8Array, publicKey: string }
|
|
12808
|
+
const signResult = await solana.signMessage(messageText);
|
|
12809
|
+
// Convert Uint8Array signature to base64 string
|
|
12810
|
+
const signatureBytes = signResult.signature;
|
|
12811
|
+
const signature = bufferExports$1.Buffer.from(signatureBytes).toString('base64');
|
|
12812
|
+
const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
|
|
12813
|
+
await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
|
|
12814
|
+
setCurrentUser({ provider: that, address: publicKey });
|
|
12815
|
+
}
|
|
12816
|
+
catch (error) {
|
|
12817
|
+
// User rejected signing or other error - disconnect fully
|
|
12779
12818
|
try {
|
|
12780
12819
|
await disconnect();
|
|
12781
12820
|
}
|
|
@@ -12783,9 +12822,12 @@ class PhantomWalletProvider {
|
|
|
12783
12822
|
// Ignore disconnect errors
|
|
12784
12823
|
}
|
|
12785
12824
|
}
|
|
12825
|
+
finally {
|
|
12826
|
+
that.autoLoginInProgress = false;
|
|
12827
|
+
}
|
|
12786
12828
|
};
|
|
12787
|
-
|
|
12788
|
-
}, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, disconnect]);
|
|
12829
|
+
autoCreateSession();
|
|
12830
|
+
}, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, solana, solanaHook.isAvailable, disconnect]);
|
|
12789
12831
|
// Handle modal close without connection
|
|
12790
12832
|
React$1.useEffect(() => {
|
|
12791
12833
|
// Detect when modal was open and is now closed
|
|
@@ -12889,9 +12931,11 @@ class PhantomWalletProvider {
|
|
|
12889
12931
|
if (that.config.appId) {
|
|
12890
12932
|
config.appId = that.config.appId;
|
|
12891
12933
|
}
|
|
12892
|
-
|
|
12934
|
+
// Set authOptions with redirectUrl for social login callback handling
|
|
12935
|
+
// Default to current page URL if not explicitly configured
|
|
12936
|
+
if (that.hasSocialProviders()) {
|
|
12893
12937
|
config.authOptions = {
|
|
12894
|
-
redirectUrl: that.config.redirectUrl,
|
|
12938
|
+
redirectUrl: that.config.redirectUrl || window.location.href,
|
|
12895
12939
|
};
|
|
12896
12940
|
}
|
|
12897
12941
|
return config;
|
|
@@ -31479,4 +31523,4 @@ exports.setMany = setMany;
|
|
|
31479
31523
|
exports.signSessionCreateMessage = signSessionCreateMessage;
|
|
31480
31524
|
exports.subscribe = subscribe;
|
|
31481
31525
|
exports.useAuth = useAuth;
|
|
31482
|
-
//# sourceMappingURL=index-
|
|
31526
|
+
//# sourceMappingURL=index-BnFIg6Xc.js.map
|