@pooflabs/web 0.0.31 → 0.0.33
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/global.d.ts +3 -0
- package/dist/{index-BzYf0Bnq.js → index-CyYOGixN.js} +82 -14
- package/dist/{index-BzYf0Bnq.js.map → index-CyYOGixN.js.map} +1 -1
- package/dist/{index-DXYtcpKo.js → index-DVFbwTxe.js} +2 -2
- package/dist/{index-DXYtcpKo.js.map → index-DVFbwTxe.js.map} +1 -1
- package/dist/{index-DzRkhhqy.esm.js → index-DtGP-cwj.esm.js} +2 -2
- package/dist/{index-DzRkhhqy.esm.js.map → index-DtGP-cwj.esm.js.map} +1 -1
- package/dist/{index-CEiYEW9z.esm.js → index-GsU0usWB.esm.js} +81 -15
- package/dist/{index-CEiYEW9z.esm.js.map → index-GsU0usWB.esm.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/package.json +1 -1
|
@@ -12632,7 +12632,7 @@ async function loadDependencies() {
|
|
|
12632
12632
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
12633
12633
|
import('react'),
|
|
12634
12634
|
import('react-dom/client'),
|
|
12635
|
-
import('./index-
|
|
12635
|
+
import('./index-DtGP-cwj.esm.js')
|
|
12636
12636
|
]);
|
|
12637
12637
|
React$1 = reactModule;
|
|
12638
12638
|
ReactDOM$1 = reactDomModule;
|
|
@@ -12649,6 +12649,7 @@ class PhantomWalletProvider {
|
|
|
12649
12649
|
this.resolvedProviders = ['injected'];
|
|
12650
12650
|
this.pendingLogin = null;
|
|
12651
12651
|
this.loginInProgress = false;
|
|
12652
|
+
this.autoLoginInProgress = false;
|
|
12652
12653
|
this.initPromise = null;
|
|
12653
12654
|
this.networkUrl = networkUrl;
|
|
12654
12655
|
this.config = config;
|
|
@@ -12671,6 +12672,12 @@ class PhantomWalletProvider {
|
|
|
12671
12672
|
// Initialize React component
|
|
12672
12673
|
this.initialize();
|
|
12673
12674
|
}
|
|
12675
|
+
/**
|
|
12676
|
+
* Check if social login providers are configured (non-injected providers).
|
|
12677
|
+
*/
|
|
12678
|
+
hasSocialProviders() {
|
|
12679
|
+
return this.resolvedProviders.some(p => p !== 'injected');
|
|
12680
|
+
}
|
|
12674
12681
|
static getInstance(networkUrl, config) {
|
|
12675
12682
|
if (!PhantomWalletProvider.instance) {
|
|
12676
12683
|
new PhantomWalletProvider(networkUrl, config);
|
|
@@ -12746,16 +12753,49 @@ class PhantomWalletProvider {
|
|
|
12746
12753
|
};
|
|
12747
12754
|
}
|
|
12748
12755
|
}, [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]);
|
|
12749
|
-
// Auto-
|
|
12750
|
-
// This handles
|
|
12756
|
+
// Auto-login: If connected but no Tarobase session, try to create one.
|
|
12757
|
+
// This handles social login callbacks where user returns from OAuth already connected.
|
|
12751
12758
|
React$1.useEffect(() => {
|
|
12752
|
-
const
|
|
12753
|
-
|
|
12754
|
-
|
|
12759
|
+
const autoCreateSession = async () => {
|
|
12760
|
+
var _a;
|
|
12761
|
+
// Only proceed when SDK is ready, connected, has addresses, and not already in a login flow
|
|
12762
|
+
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) {
|
|
12755
12763
|
return;
|
|
12756
12764
|
}
|
|
12757
|
-
|
|
12758
|
-
if (!
|
|
12765
|
+
// Need solana to be available for signing
|
|
12766
|
+
if (!solana || !solanaHook.isAvailable) {
|
|
12767
|
+
return;
|
|
12768
|
+
}
|
|
12769
|
+
// Find Solana address
|
|
12770
|
+
const solAddress = (_a = phantom.addresses) === null || _a === void 0 ? void 0 : _a.find((addr) => addr.addressType === AddressType.solana);
|
|
12771
|
+
if (!solAddress) {
|
|
12772
|
+
return;
|
|
12773
|
+
}
|
|
12774
|
+
const publicKey = solAddress.address;
|
|
12775
|
+
// Check if we already have a valid session for this address
|
|
12776
|
+
const existingSession = await WebSessionManager.getSession();
|
|
12777
|
+
if (existingSession && existingSession.address === publicKey) {
|
|
12778
|
+
// Already have a valid session, nothing to do
|
|
12779
|
+
setCurrentUser({ provider: that, address: publicKey });
|
|
12780
|
+
return;
|
|
12781
|
+
}
|
|
12782
|
+
// No valid session - try to create one automatically
|
|
12783
|
+
that.autoLoginInProgress = true;
|
|
12784
|
+
setAuthLoading(true);
|
|
12785
|
+
try {
|
|
12786
|
+
const nonce = await genAuthNonce();
|
|
12787
|
+
const messageText = await genSolanaMessage(publicKey, nonce);
|
|
12788
|
+
// signMessage returns { signature: Uint8Array, publicKey: string }
|
|
12789
|
+
const signResult = await solana.signMessage(messageText);
|
|
12790
|
+
// Convert Uint8Array signature to base64 string
|
|
12791
|
+
const signatureBytes = signResult.signature;
|
|
12792
|
+
const signature = bufferExports$1.Buffer.from(signatureBytes).toString('base64');
|
|
12793
|
+
const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
|
|
12794
|
+
await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
|
|
12795
|
+
setCurrentUser({ provider: that, address: publicKey });
|
|
12796
|
+
}
|
|
12797
|
+
catch (error) {
|
|
12798
|
+
// User rejected signing or other error - disconnect fully
|
|
12759
12799
|
try {
|
|
12760
12800
|
await disconnect();
|
|
12761
12801
|
}
|
|
@@ -12763,9 +12803,13 @@ class PhantomWalletProvider {
|
|
|
12763
12803
|
// Ignore disconnect errors
|
|
12764
12804
|
}
|
|
12765
12805
|
}
|
|
12806
|
+
finally {
|
|
12807
|
+
that.autoLoginInProgress = false;
|
|
12808
|
+
setAuthLoading(false);
|
|
12809
|
+
}
|
|
12766
12810
|
};
|
|
12767
|
-
|
|
12768
|
-
}, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.isLoading, disconnect]);
|
|
12811
|
+
autoCreateSession();
|
|
12812
|
+
}, [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]);
|
|
12769
12813
|
// Handle modal close without connection
|
|
12770
12814
|
React$1.useEffect(() => {
|
|
12771
12815
|
// Detect when modal was open and is now closed
|
|
@@ -12869,9 +12913,11 @@ class PhantomWalletProvider {
|
|
|
12869
12913
|
if (that.config.appId) {
|
|
12870
12914
|
config.appId = that.config.appId;
|
|
12871
12915
|
}
|
|
12872
|
-
|
|
12916
|
+
// Set authOptions with redirectUrl for social login callback handling
|
|
12917
|
+
// Default to current page URL if not explicitly configured
|
|
12918
|
+
if (that.hasSocialProviders()) {
|
|
12873
12919
|
config.authOptions = {
|
|
12874
|
-
redirectUrl: that.config.redirectUrl,
|
|
12920
|
+
redirectUrl: that.config.redirectUrl || window.location.href,
|
|
12875
12921
|
};
|
|
12876
12922
|
}
|
|
12877
12923
|
return config;
|
|
@@ -31306,7 +31352,9 @@ async function logout$1() {
|
|
|
31306
31352
|
let authProviderInstance = null;
|
|
31307
31353
|
let currentUser = null;
|
|
31308
31354
|
let authStateListeners = [];
|
|
31355
|
+
let authLoadingListeners = [];
|
|
31309
31356
|
let initCompleted = false;
|
|
31357
|
+
let isAuthLoading = false;
|
|
31310
31358
|
// This file acts as a middleware for the global state of the SDK
|
|
31311
31359
|
// This mostly involves setting up the AuthProvider and managing the current user
|
|
31312
31360
|
async function init(newConfig) {
|
|
@@ -31330,6 +31378,20 @@ function onAuthStateChanged(callback) {
|
|
|
31330
31378
|
callback(currentUser);
|
|
31331
31379
|
}
|
|
31332
31380
|
}
|
|
31381
|
+
function onAuthLoadingChanged(callback) {
|
|
31382
|
+
authLoadingListeners.push(callback);
|
|
31383
|
+
// Call immediately with current loading state
|
|
31384
|
+
callback(isAuthLoading);
|
|
31385
|
+
}
|
|
31386
|
+
function setAuthLoading(loading) {
|
|
31387
|
+
if (isAuthLoading !== loading) {
|
|
31388
|
+
isAuthLoading = loading;
|
|
31389
|
+
authLoadingListeners.forEach((callback) => callback(loading));
|
|
31390
|
+
}
|
|
31391
|
+
}
|
|
31392
|
+
function getAuthLoading() {
|
|
31393
|
+
return isAuthLoading;
|
|
31394
|
+
}
|
|
31333
31395
|
async function login() {
|
|
31334
31396
|
if (!authProviderInstance) {
|
|
31335
31397
|
throw new Error('SDK not initialized. Please call init() first.');
|
|
@@ -31372,11 +31434,15 @@ function useAuth() {
|
|
|
31372
31434
|
}
|
|
31373
31435
|
const [user, setUser] = React$2.useState(null);
|
|
31374
31436
|
const [loading, setLoading] = React$2.useState(true);
|
|
31437
|
+
const [sdkLoading, setSdkLoading] = React$2.useState(false);
|
|
31375
31438
|
React$2.useEffect(() => {
|
|
31376
31439
|
onAuthStateChanged((user) => {
|
|
31377
31440
|
setUser(user);
|
|
31378
31441
|
setLoading(false);
|
|
31379
31442
|
});
|
|
31443
|
+
onAuthLoadingChanged((loading) => {
|
|
31444
|
+
setSdkLoading(loading);
|
|
31445
|
+
});
|
|
31380
31446
|
return () => {
|
|
31381
31447
|
};
|
|
31382
31448
|
}, []);
|
|
@@ -31413,7 +31479,7 @@ function useAuth() {
|
|
|
31413
31479
|
return {
|
|
31414
31480
|
login: login$1,
|
|
31415
31481
|
logout: logout$1,
|
|
31416
|
-
loading,
|
|
31482
|
+
loading: loading || sdkLoading,
|
|
31417
31483
|
user,
|
|
31418
31484
|
};
|
|
31419
31485
|
}
|
|
@@ -31423,5 +31489,5 @@ async function getIdToken() {
|
|
|
31423
31489
|
return getIdToken$1(false);
|
|
31424
31490
|
}
|
|
31425
31491
|
|
|
31426
|
-
export {
|
|
31427
|
-
//# sourceMappingURL=index-
|
|
31492
|
+
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 };
|
|
31493
|
+
//# sourceMappingURL=index-GsU0usWB.esm.js.map
|