@pooflabs/web 0.0.47 → 0.0.49
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 +1 -0
- package/dist/auth/providers/phantom-wallet-provider.d.ts +5 -6
- package/dist/{index-R_GFZpLo.esm.js → index-B-RIRJEL.esm.js} +2 -2
- package/dist/{index-R_GFZpLo.esm.js.map → index-B-RIRJEL.esm.js.map} +1 -1
- package/dist/{index-BEla3UUZ.js → index-BM6eGmtn.js} +2 -2
- package/dist/{index-BEla3UUZ.js.map → index-BM6eGmtn.js.map} +1 -1
- package/dist/{index-7SWQ00_t.js → index-BluuzeCc.js} +143 -218
- package/dist/{index-7SWQ00_t.js.map → index-BluuzeCc.js.map} +1 -1
- package/dist/{index-B6X0fhJf.esm.js → index-DbpX94X9.esm.js} +143 -218
- package/dist/{index-B6X0fhJf.esm.js.map → index-DbpX94X9.esm.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -13051,138 +13051,7 @@ function requireBuffer () {
|
|
|
13051
13051
|
|
|
13052
13052
|
var bufferExports = requireBuffer();
|
|
13053
13053
|
|
|
13054
|
-
const VALID_PROVIDERS = ['injected', 'google', 'apple', 'deeplink'];
|
|
13055
|
-
// Storage key for preserving the original path before OAuth redirect
|
|
13056
|
-
const PHANTOM_ORIGINAL_PATH_KEY = 'phantom_oauth_original_path';
|
|
13057
|
-
/**
|
|
13058
|
-
* Check if the current URL contains Phantom OAuth callback parameters.
|
|
13059
|
-
* Phantom uses various params like phantom_encryption_public_key, data, nonce for deeplink callbacks,
|
|
13060
|
-
* and wallet_id, session_id for social login callbacks.
|
|
13061
|
-
*/
|
|
13062
|
-
function hasPhantomOAuthParams() {
|
|
13063
|
-
if (typeof window === 'undefined')
|
|
13064
|
-
return false;
|
|
13065
|
-
const url = new URL(window.location.href);
|
|
13066
|
-
const params = url.searchParams;
|
|
13067
|
-
const hash = url.hash;
|
|
13068
|
-
// Check for Phantom OAuth callback params in query string
|
|
13069
|
-
// These are common params used by Phantom for OAuth callbacks
|
|
13070
|
-
const oauthParams = [
|
|
13071
|
-
'phantom_encryption_public_key',
|
|
13072
|
-
'data',
|
|
13073
|
-
'nonce',
|
|
13074
|
-
'wallet_id',
|
|
13075
|
-
'session_id',
|
|
13076
|
-
'errorCode',
|
|
13077
|
-
'errorMessage'
|
|
13078
|
-
];
|
|
13079
|
-
for (const param of oauthParams) {
|
|
13080
|
-
if (params.has(param)) {
|
|
13081
|
-
return true;
|
|
13082
|
-
}
|
|
13083
|
-
}
|
|
13084
|
-
// Also check hash fragment for encoded auth data
|
|
13085
|
-
if (hash && (hash.includes('phantom') || hash.includes('wallet_id') || hash.includes('session_id'))) {
|
|
13086
|
-
return true;
|
|
13087
|
-
}
|
|
13088
|
-
return false;
|
|
13089
|
-
}
|
|
13090
|
-
/**
|
|
13091
|
-
* Store the current path before OAuth redirect so we can restore it after.
|
|
13092
|
-
*/
|
|
13093
|
-
function storeOriginalPath() {
|
|
13094
|
-
if (typeof window === 'undefined' || typeof sessionStorage === 'undefined')
|
|
13095
|
-
return;
|
|
13096
|
-
const currentPath = window.location.pathname + window.location.search;
|
|
13097
|
-
// Only store if not already on the root path
|
|
13098
|
-
if (currentPath !== '/' && currentPath !== '') {
|
|
13099
|
-
try {
|
|
13100
|
-
sessionStorage.setItem(PHANTOM_ORIGINAL_PATH_KEY, currentPath);
|
|
13101
|
-
}
|
|
13102
|
-
catch (_a) {
|
|
13103
|
-
// sessionStorage might not be available
|
|
13104
|
-
}
|
|
13105
|
-
}
|
|
13106
|
-
}
|
|
13107
|
-
/**
|
|
13108
|
-
* Get and clear the stored original path after OAuth callback.
|
|
13109
|
-
* Returns the path to redirect to, or null if no redirect needed.
|
|
13110
|
-
*/
|
|
13111
|
-
function getAndClearOriginalPath() {
|
|
13112
|
-
if (typeof window === 'undefined' || typeof sessionStorage === 'undefined')
|
|
13113
|
-
return null;
|
|
13114
|
-
try {
|
|
13115
|
-
const originalPath = sessionStorage.getItem(PHANTOM_ORIGINAL_PATH_KEY);
|
|
13116
|
-
if (originalPath) {
|
|
13117
|
-
sessionStorage.removeItem(PHANTOM_ORIGINAL_PATH_KEY);
|
|
13118
|
-
// Only return if we're not already on that path
|
|
13119
|
-
const currentPath = window.location.pathname + window.location.search;
|
|
13120
|
-
if (originalPath !== currentPath) {
|
|
13121
|
-
return originalPath;
|
|
13122
|
-
}
|
|
13123
|
-
}
|
|
13124
|
-
}
|
|
13125
|
-
catch (_a) {
|
|
13126
|
-
// sessionStorage might not be available
|
|
13127
|
-
}
|
|
13128
|
-
return null;
|
|
13129
|
-
}
|
|
13130
|
-
/**
|
|
13131
|
-
* Remove OAuth callback parameters from the current URL without a full page reload.
|
|
13132
|
-
* Uses history.replaceState to update the URL in place.
|
|
13133
|
-
*/
|
|
13134
|
-
function cleanupOAuthParams() {
|
|
13135
|
-
if (typeof window === 'undefined')
|
|
13136
|
-
return;
|
|
13137
|
-
const url = new URL(window.location.href);
|
|
13138
|
-
const paramsToRemove = [
|
|
13139
|
-
'response_type',
|
|
13140
|
-
'phantom_encryption_public_key',
|
|
13141
|
-
'data',
|
|
13142
|
-
'nonce',
|
|
13143
|
-
'wallet_id',
|
|
13144
|
-
'session_id',
|
|
13145
|
-
'organization_id',
|
|
13146
|
-
'selected_account_index',
|
|
13147
|
-
'expires_in_ms',
|
|
13148
|
-
'auth_user_id',
|
|
13149
|
-
'errorCode',
|
|
13150
|
-
'errorMessage'
|
|
13151
|
-
];
|
|
13152
|
-
let hasChanges = false;
|
|
13153
|
-
for (const param of paramsToRemove) {
|
|
13154
|
-
if (url.searchParams.has(param)) {
|
|
13155
|
-
url.searchParams.delete(param);
|
|
13156
|
-
hasChanges = true;
|
|
13157
|
-
}
|
|
13158
|
-
}
|
|
13159
|
-
if (hasChanges) {
|
|
13160
|
-
// Use replaceState to update URL without page reload
|
|
13161
|
-
window.history.replaceState({}, '', url.pathname + url.search + url.hash);
|
|
13162
|
-
}
|
|
13163
|
-
}
|
|
13164
|
-
/**
|
|
13165
|
-
* Get the effective redirect URL for Phantom OAuth.
|
|
13166
|
-
* If OAuth callback params are detected in the current URL, use the current URL
|
|
13167
|
-
* to ensure the SDK can process them. Otherwise, use the configured redirect URL
|
|
13168
|
-
* or fall back to the origin (base URL without path).
|
|
13169
|
-
*/
|
|
13170
|
-
function getEffectiveRedirectUrl(configuredRedirectUrl) {
|
|
13171
|
-
if (typeof window === 'undefined')
|
|
13172
|
-
return '';
|
|
13173
|
-
// If we detect OAuth params in current URL, use the current URL
|
|
13174
|
-
// This ensures the SDK can process the callback regardless of path
|
|
13175
|
-
if (hasPhantomOAuthParams()) {
|
|
13176
|
-
return window.location.href;
|
|
13177
|
-
}
|
|
13178
|
-
// If explicitly configured, use that
|
|
13179
|
-
if (configuredRedirectUrl) {
|
|
13180
|
-
return configuredRedirectUrl;
|
|
13181
|
-
}
|
|
13182
|
-
// Default to origin (base URL) - this is safer than using the full href
|
|
13183
|
-
// because OAuth callbacks are typically configured for specific URLs
|
|
13184
|
-
return window.location.origin;
|
|
13185
|
-
}
|
|
13054
|
+
const VALID_PROVIDERS = ['injected', 'google', 'apple', 'deeplink', 'phantom'];
|
|
13186
13055
|
// Dynamically import React and Phantom SDK - only when needed
|
|
13187
13056
|
let React$1;
|
|
13188
13057
|
let ReactDOM$1;
|
|
@@ -13203,7 +13072,7 @@ async function loadDependencies() {
|
|
|
13203
13072
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
13204
13073
|
import('react'),
|
|
13205
13074
|
import('react-dom/client'),
|
|
13206
|
-
Promise.resolve().then(function () { return require('./index-
|
|
13075
|
+
Promise.resolve().then(function () { return require('./index-BM6eGmtn.js'); })
|
|
13207
13076
|
]);
|
|
13208
13077
|
// Extract default export from ESM module namespace
|
|
13209
13078
|
// Dynamic import() returns { default: Module, ...exports }, not the module directly
|
|
@@ -13224,7 +13093,7 @@ class PhantomWalletProvider {
|
|
|
13224
13093
|
this.loginInProgress = false;
|
|
13225
13094
|
this.autoLoginInProgress = false;
|
|
13226
13095
|
this.initPromise = null;
|
|
13227
|
-
/** Callback to swap to a Privy provider when the user clicks "Log in with
|
|
13096
|
+
/** Callback to swap to a Privy provider when the user clicks "Log in with email" */
|
|
13228
13097
|
this.onSwitchToPrivy = null;
|
|
13229
13098
|
this.networkUrl = networkUrl;
|
|
13230
13099
|
this.config = config;
|
|
@@ -13264,14 +13133,18 @@ class PhantomWalletProvider {
|
|
|
13264
13133
|
const configProviders = this.config.providers;
|
|
13265
13134
|
this.resolvedProviders = configProviders.filter((p) => VALID_PROVIDERS.includes(p));
|
|
13266
13135
|
if (this.resolvedProviders.length === 0) {
|
|
13267
|
-
this.resolvedProviders = ['injected'
|
|
13136
|
+
this.resolvedProviders = ['injected'];
|
|
13268
13137
|
}
|
|
13269
13138
|
}
|
|
13270
13139
|
else if (this.config.appId) {
|
|
13271
13140
|
this.resolvedProviders = ['injected', 'google', 'apple', 'deeplink'];
|
|
13272
13141
|
}
|
|
13273
13142
|
else {
|
|
13274
|
-
this.resolvedProviders = ['injected'
|
|
13143
|
+
this.resolvedProviders = ['injected'];
|
|
13144
|
+
}
|
|
13145
|
+
// When Privy handles social logins, strip them from Phantom
|
|
13146
|
+
if (this.config.enablePrivyFallback) {
|
|
13147
|
+
this.resolvedProviders = this.resolvedProviders.filter(p => p !== 'google' && p !== 'apple');
|
|
13275
13148
|
}
|
|
13276
13149
|
}
|
|
13277
13150
|
initialize() {
|
|
@@ -13355,17 +13228,6 @@ class PhantomWalletProvider {
|
|
|
13355
13228
|
if (existingSession && existingSession.address === publicKey) {
|
|
13356
13229
|
// Already have a valid session, just set user
|
|
13357
13230
|
setCurrentUser({ provider: that, address: publicKey });
|
|
13358
|
-
// If this was an OAuth callback, clean up the URL
|
|
13359
|
-
if (hasPhantomOAuthParams()) {
|
|
13360
|
-
const originalPath = getAndClearOriginalPath();
|
|
13361
|
-
if (originalPath) {
|
|
13362
|
-
window.location.replace(originalPath);
|
|
13363
|
-
}
|
|
13364
|
-
else {
|
|
13365
|
-
// No stored path (e.g., user was on root), clean up OAuth params in place
|
|
13366
|
-
cleanupOAuthParams();
|
|
13367
|
-
}
|
|
13368
|
-
}
|
|
13369
13231
|
return;
|
|
13370
13232
|
}
|
|
13371
13233
|
// No valid session - try to create one automatically
|
|
@@ -13381,23 +13243,15 @@ class PhantomWalletProvider {
|
|
|
13381
13243
|
const signature = bufferExports.Buffer.from(signatureBytes).toString('base64');
|
|
13382
13244
|
const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
|
|
13383
13245
|
await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
const originalPath = getAndClearOriginalPath();
|
|
13388
|
-
if (originalPath) {
|
|
13389
|
-
window.location.replace(originalPath);
|
|
13390
|
-
}
|
|
13391
|
-
else {
|
|
13392
|
-
// No stored path (e.g., user was on root), clean up OAuth params in place
|
|
13393
|
-
cleanupOAuthParams();
|
|
13394
|
-
}
|
|
13246
|
+
// Mark auth method so clearIncompatibleSession() doesn't wipe this session
|
|
13247
|
+
try {
|
|
13248
|
+
localStorage.setItem('tarobase_last_auth_method', 'phantom');
|
|
13395
13249
|
}
|
|
13250
|
+
catch (_b) { }
|
|
13251
|
+
setCurrentUser({ provider: that, address: publicKey });
|
|
13396
13252
|
}
|
|
13397
13253
|
catch (error) {
|
|
13398
13254
|
// User rejected signing or other error - disconnect fully
|
|
13399
|
-
// Clear stored path since login failed
|
|
13400
|
-
getAndClearOriginalPath();
|
|
13401
13255
|
try {
|
|
13402
13256
|
await disconnect();
|
|
13403
13257
|
}
|
|
@@ -13478,6 +13332,11 @@ class PhantomWalletProvider {
|
|
|
13478
13332
|
const signature = bufferExports.Buffer.from(signatureBytes).toString('base64');
|
|
13479
13333
|
const createSessionResult = await createSessionWithSignature(publicKey, messageText, signature);
|
|
13480
13334
|
await WebSessionManager.storeSession(publicKey, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
|
|
13335
|
+
// Mark auth method so clearIncompatibleSession() doesn't wipe this session
|
|
13336
|
+
try {
|
|
13337
|
+
localStorage.setItem('tarobase_last_auth_method', 'phantom');
|
|
13338
|
+
}
|
|
13339
|
+
catch (_b) { }
|
|
13481
13340
|
const user = { provider: that, address: publicKey };
|
|
13482
13341
|
setCurrentUser(user);
|
|
13483
13342
|
that.pendingLogin.resolve(user);
|
|
@@ -13500,33 +13359,79 @@ class PhantomWalletProvider {
|
|
|
13500
13359
|
};
|
|
13501
13360
|
handleConnectionSuccess();
|
|
13502
13361
|
}, [phantom === null || phantom === void 0 ? void 0 : phantom.isConnected, phantom === null || phantom === void 0 ? void 0 : phantom.addresses, solana, solana === null || solana === void 0 ? void 0 : solana.connected, solanaHook.isAvailable]);
|
|
13503
|
-
//
|
|
13504
|
-
//
|
|
13505
|
-
//
|
|
13362
|
+
// When enablePrivyFallback is true, enhance the Phantom modal:
|
|
13363
|
+
// 1. Auto-click "Other Wallets" to skip to the wallet list view
|
|
13364
|
+
// 2. Hide the "Other Wallets" header and back arrow
|
|
13365
|
+
// 3. Inject "Log in with email" button styled to match Phantom SDK buttons
|
|
13506
13366
|
React$1.useEffect(() => {
|
|
13507
13367
|
if (!that.config.enablePrivyFallback || !modal.isOpened) {
|
|
13508
13368
|
return;
|
|
13509
13369
|
}
|
|
13510
|
-
let
|
|
13511
|
-
|
|
13512
|
-
|
|
13513
|
-
|
|
13514
|
-
return;
|
|
13515
|
-
// Find the Phantom overlay within our own container (scoped to avoid false matches)
|
|
13516
|
-
// The modal renders inline (not portaled), so it's inside our [data-phantom-provider] div
|
|
13370
|
+
let socialBtnContainer = null;
|
|
13371
|
+
let didAutoClick = false;
|
|
13372
|
+
const enhanceModal = () => {
|
|
13373
|
+
var _a, _b;
|
|
13517
13374
|
const overlayEl = ((_a = that.containerElement) === null || _a === void 0 ? void 0 : _a.querySelector('div[style*="z-index"]'))
|
|
13518
13375
|
|| document.querySelector('div[style*="z-index: 9999"]');
|
|
13519
13376
|
const modalCard = overlayEl === null || overlayEl === void 0 ? void 0 : overlayEl.firstElementChild;
|
|
13520
13377
|
if (!modalCard)
|
|
13521
13378
|
return;
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13379
|
+
// Auto-click "Other Wallets" button to jump to wallet list
|
|
13380
|
+
if (!didAutoClick) {
|
|
13381
|
+
const buttons = modalCard.querySelectorAll('button');
|
|
13382
|
+
for (const b of buttons) {
|
|
13383
|
+
if ((_b = b.textContent) === null || _b === void 0 ? void 0 : _b.includes('Other Wallets')) {
|
|
13384
|
+
didAutoClick = true;
|
|
13385
|
+
b.click();
|
|
13386
|
+
return; // Modal re-renders; observer fires again
|
|
13387
|
+
}
|
|
13388
|
+
}
|
|
13389
|
+
}
|
|
13390
|
+
const allDivs = modalCard.querySelectorAll('div');
|
|
13391
|
+
for (const div of allDivs) {
|
|
13392
|
+
const style = div.getAttribute('style') || '';
|
|
13393
|
+
if (style.includes('28px 32px 0') && style.includes('32px')) {
|
|
13394
|
+
const children = div.children;
|
|
13395
|
+
for (let i = 0; i < children.length; i++) {
|
|
13396
|
+
const child = children[i];
|
|
13397
|
+
const childStyle = child.getAttribute('style') || '';
|
|
13398
|
+
// Keep the close button (positioned right), hide everything else
|
|
13399
|
+
if (childStyle.includes('right:'))
|
|
13400
|
+
continue;
|
|
13401
|
+
child.style.display = 'none';
|
|
13402
|
+
}
|
|
13403
|
+
break;
|
|
13404
|
+
}
|
|
13405
|
+
}
|
|
13406
|
+
// Inject the email login button if not already present
|
|
13407
|
+
if (socialBtnContainer || modalCard.querySelector('[data-privy-fallback-btn]'))
|
|
13408
|
+
return;
|
|
13409
|
+
socialBtnContainer = document.createElement('div');
|
|
13410
|
+
socialBtnContainer.setAttribute('data-privy-fallback-btn', 'true');
|
|
13411
|
+
socialBtnContainer.style.cssText = 'padding:0 32px 16px;';
|
|
13525
13412
|
const btn = document.createElement('button');
|
|
13526
|
-
btn.
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13413
|
+
btn.style.cssText = [
|
|
13414
|
+
'display:flex',
|
|
13415
|
+
'align-items:center',
|
|
13416
|
+
'justify-content:center',
|
|
13417
|
+
'width:100%',
|
|
13418
|
+
'height:56px',
|
|
13419
|
+
'padding:12px 16px',
|
|
13420
|
+
'border:none',
|
|
13421
|
+
'border-radius:16px',
|
|
13422
|
+
'background-color:rgba(152,151,156,0.1)',
|
|
13423
|
+
'color:#FFFFFF',
|
|
13424
|
+
'font-family:"SF Pro Text",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',
|
|
13425
|
+
'font-size:14px',
|
|
13426
|
+
'font-weight:600',
|
|
13427
|
+
'line-height:17px',
|
|
13428
|
+
'letter-spacing:-0.14px',
|
|
13429
|
+
'cursor:pointer',
|
|
13430
|
+
'transition:background-color 0.2s',
|
|
13431
|
+
].join(';') + ';';
|
|
13432
|
+
btn.textContent = 'Log in with email';
|
|
13433
|
+
btn.addEventListener('mouseenter', () => { btn.style.backgroundColor = 'rgba(152,151,156,0.15)'; });
|
|
13434
|
+
btn.addEventListener('mouseleave', () => { btn.style.backgroundColor = 'rgba(152,151,156,0.1)'; });
|
|
13530
13435
|
btn.addEventListener('click', async () => {
|
|
13531
13436
|
// Clear loginInProgress BEFORE closing modal so the modal-close
|
|
13532
13437
|
// handler doesn't race and reject pendingLogin with "User cancelled"
|
|
@@ -13541,7 +13446,6 @@ class PhantomWalletProvider {
|
|
|
13541
13446
|
that.pendingLogin = null;
|
|
13542
13447
|
}
|
|
13543
13448
|
else if (that.pendingLogin) {
|
|
13544
|
-
// User cancelled Privy login (returned null)
|
|
13545
13449
|
that.pendingLogin.reject(new Error('User cancelled login'));
|
|
13546
13450
|
that.pendingLogin = null;
|
|
13547
13451
|
}
|
|
@@ -13554,18 +13458,18 @@ class PhantomWalletProvider {
|
|
|
13554
13458
|
}
|
|
13555
13459
|
}
|
|
13556
13460
|
});
|
|
13557
|
-
|
|
13558
|
-
modalCard.appendChild(
|
|
13461
|
+
socialBtnContainer.appendChild(btn);
|
|
13462
|
+
modalCard.appendChild(socialBtnContainer);
|
|
13559
13463
|
};
|
|
13560
13464
|
// Try immediately, then watch for DOM changes (modal may render async)
|
|
13561
|
-
|
|
13562
|
-
const observer = new MutationObserver(() =>
|
|
13465
|
+
enhanceModal();
|
|
13466
|
+
const observer = new MutationObserver(() => enhanceModal());
|
|
13563
13467
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
13564
13468
|
return () => {
|
|
13565
13469
|
observer.disconnect();
|
|
13566
|
-
if (
|
|
13567
|
-
|
|
13568
|
-
|
|
13470
|
+
if (socialBtnContainer)
|
|
13471
|
+
socialBtnContainer.remove();
|
|
13472
|
+
socialBtnContainer = null;
|
|
13569
13473
|
};
|
|
13570
13474
|
}, [modal.isOpened]);
|
|
13571
13475
|
return null; // Invisible component
|
|
@@ -13583,13 +13487,6 @@ class PhantomWalletProvider {
|
|
|
13583
13487
|
if (that.config.appId) {
|
|
13584
13488
|
config.appId = that.config.appId;
|
|
13585
13489
|
}
|
|
13586
|
-
// Set authOptions with redirectUrl for social login callback handling
|
|
13587
|
-
// Use getEffectiveRedirectUrl to handle OAuth callbacks from any path
|
|
13588
|
-
if (that.hasSocialProviders()) {
|
|
13589
|
-
config.authOptions = {
|
|
13590
|
-
redirectUrl: getEffectiveRedirectUrl(that.config.redirectUrl),
|
|
13591
|
-
};
|
|
13592
|
-
}
|
|
13593
13490
|
return config;
|
|
13594
13491
|
}, []);
|
|
13595
13492
|
const theme = that.config.theme === 'light' ? lightTheme : darkTheme;
|
|
@@ -13676,8 +13573,8 @@ class PhantomWalletProvider {
|
|
|
13676
13573
|
}
|
|
13677
13574
|
/**
|
|
13678
13575
|
* Login using the Phantom connect modal.
|
|
13679
|
-
*
|
|
13680
|
-
*
|
|
13576
|
+
* When enablePrivyFallback is true, the modal is enhanced via React effect to
|
|
13577
|
+
* auto-skip to the wallet list and show a "Log in with email" button.
|
|
13681
13578
|
*/
|
|
13682
13579
|
async login() {
|
|
13683
13580
|
var _a, _b;
|
|
@@ -13704,11 +13601,6 @@ class PhantomWalletProvider {
|
|
|
13704
13601
|
return new Promise((resolve, reject) => {
|
|
13705
13602
|
this.pendingLogin = { resolve, reject };
|
|
13706
13603
|
this.loginInProgress = true;
|
|
13707
|
-
// Store current path before OAuth redirect (for social login providers)
|
|
13708
|
-
// so we can redirect back after auth completes
|
|
13709
|
-
if (this.hasSocialProviders()) {
|
|
13710
|
-
storeOriginalPath();
|
|
13711
|
-
}
|
|
13712
13604
|
// Open the Phantom connect modal
|
|
13713
13605
|
this.phantomMethods.openModal();
|
|
13714
13606
|
// Safety timeout
|
|
@@ -32636,7 +32528,7 @@ const defaultPrivyConfig = {
|
|
|
32636
32528
|
}
|
|
32637
32529
|
},
|
|
32638
32530
|
appearance: {
|
|
32639
|
-
walletChainType: 'solana-only'
|
|
32531
|
+
walletChainType: 'solana-only'
|
|
32640
32532
|
},
|
|
32641
32533
|
externalWallets: { solana: { connectors: q() } }
|
|
32642
32534
|
}
|
|
@@ -32677,6 +32569,13 @@ class PrivyWalletProvider {
|
|
|
32677
32569
|
this.privyConfig.config.appearance.logo = appLogoUrl;
|
|
32678
32570
|
}
|
|
32679
32571
|
}
|
|
32572
|
+
// Ensure externalWallets connectors are always configured — required for
|
|
32573
|
+
// useWallets().ready to resolve even when no browser extension is present
|
|
32574
|
+
if (!this.privyConfig.config.externalWallets) {
|
|
32575
|
+
this.privyConfig.config.externalWallets = {
|
|
32576
|
+
solana: { connectors: q() }
|
|
32577
|
+
};
|
|
32578
|
+
}
|
|
32680
32579
|
// Add Solana RPC configuration for v3
|
|
32681
32580
|
let devnetUrl = SOLANA_DEVNET_RPC_URL;
|
|
32682
32581
|
let mainnetUrl = SOLANA_MAINNET_RPC_URL;
|
|
@@ -32865,7 +32764,7 @@ class PrivyWalletProvider {
|
|
|
32865
32764
|
}
|
|
32866
32765
|
});
|
|
32867
32766
|
React.useEffect(() => {
|
|
32868
|
-
if (privy.ready
|
|
32767
|
+
if (privy.ready) {
|
|
32869
32768
|
that.privyMethods = {
|
|
32870
32769
|
ready: privy.ready,
|
|
32871
32770
|
walletReady: walletReady,
|
|
@@ -32954,7 +32853,7 @@ class PrivyWalletProvider {
|
|
|
32954
32853
|
}
|
|
32955
32854
|
async runTransaction(_evmTransactionData, solTransactionData, options) {
|
|
32956
32855
|
var _a;
|
|
32957
|
-
await this.ensureReady();
|
|
32856
|
+
await this.ensureReady({ waitForWallets: true });
|
|
32958
32857
|
let session = await WebSessionManager.getSession();
|
|
32959
32858
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
32960
32859
|
let privyWallets = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets;
|
|
@@ -33060,7 +32959,7 @@ class PrivyWalletProvider {
|
|
|
33060
32959
|
*/
|
|
33061
32960
|
async signTransaction(transaction) {
|
|
33062
32961
|
var _a;
|
|
33063
|
-
await this.ensureReady();
|
|
32962
|
+
await this.ensureReady({ waitForWallets: true });
|
|
33064
32963
|
let privyWallets = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets;
|
|
33065
32964
|
let session = await WebSessionManager.getSession();
|
|
33066
32965
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
@@ -33134,7 +33033,7 @@ class PrivyWalletProvider {
|
|
|
33134
33033
|
*/
|
|
33135
33034
|
async signAndSubmitTransaction(transaction, feePayer) {
|
|
33136
33035
|
var _a;
|
|
33137
|
-
await this.ensureReady();
|
|
33036
|
+
await this.ensureReady({ waitForWallets: true });
|
|
33138
33037
|
let privyWallets = (_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.wallets;
|
|
33139
33038
|
let session = await WebSessionManager.getSession();
|
|
33140
33039
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
@@ -33308,7 +33207,7 @@ class PrivyWalletProvider {
|
|
|
33308
33207
|
}
|
|
33309
33208
|
async signMessage(message) {
|
|
33310
33209
|
var _a, _b;
|
|
33311
|
-
await this.ensureReady();
|
|
33210
|
+
await this.ensureReady({ waitForWallets: true });
|
|
33312
33211
|
const session = await WebSessionManager.getSession();
|
|
33313
33212
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
33314
33213
|
// If there's already a pending sign message, throw an error to prevent overlapping calls
|
|
@@ -33374,17 +33273,26 @@ class PrivyWalletProvider {
|
|
|
33374
33273
|
const createSessionResult = await createSessionWithPrivy(accessToken, address, idToken);
|
|
33375
33274
|
await WebSessionManager.storeSession(address, createSessionResult.accessToken, createSessionResult.idToken, createSessionResult.refreshToken);
|
|
33376
33275
|
}
|
|
33377
|
-
async ensureReady() {
|
|
33378
|
-
|
|
33379
|
-
|
|
33276
|
+
async ensureReady({ waitForWallets = false, timeoutMs = 15000 } = {}) {
|
|
33277
|
+
const isReady = () => {
|
|
33278
|
+
var _a, _b;
|
|
33279
|
+
if (!((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.ready))
|
|
33280
|
+
return false;
|
|
33281
|
+
if (waitForWallets && !((_b = this.privyMethods) === null || _b === void 0 ? void 0 : _b.walletReady))
|
|
33282
|
+
return false;
|
|
33283
|
+
return true;
|
|
33284
|
+
};
|
|
33285
|
+
if (isReady())
|
|
33380
33286
|
return;
|
|
33381
|
-
|
|
33382
|
-
|
|
33287
|
+
return new Promise((resolve, reject) => {
|
|
33288
|
+
const startTime = Date.now();
|
|
33383
33289
|
const check = () => {
|
|
33384
|
-
|
|
33385
|
-
if (((_a = this.privyMethods) === null || _a === void 0 ? void 0 : _a.ready) && ((_b = this.privyMethods) === null || _b === void 0 ? void 0 : _b.walletReady)) {
|
|
33290
|
+
if (isReady()) {
|
|
33386
33291
|
resolve();
|
|
33387
33292
|
}
|
|
33293
|
+
else if (Date.now() - startTime > timeoutMs) {
|
|
33294
|
+
reject(new Error('Login provider failed to initialize. This can happen in incognito mode or when third-party cookies are blocked. Try using a regular browser window.'));
|
|
33295
|
+
}
|
|
33388
33296
|
else {
|
|
33389
33297
|
setTimeout(check, 100);
|
|
33390
33298
|
}
|
|
@@ -34270,9 +34178,19 @@ function clearIncompatibleSession() {
|
|
|
34270
34178
|
return true;
|
|
34271
34179
|
}
|
|
34272
34180
|
async function hotSwapToPrivyProvider(config) {
|
|
34273
|
-
var _a, _b, _c;
|
|
34181
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
34274
34182
|
const rpcUrl = (_a = config.rpcUrl) !== null && _a !== void 0 ? _a : null;
|
|
34275
|
-
|
|
34183
|
+
// Build an email-only Privy config: hide wallet connectors, show only email login.
|
|
34184
|
+
// Must include embeddedWallets so Privy auto-creates Solana wallets for email login users.
|
|
34185
|
+
const fallbackPrivyConfig = {
|
|
34186
|
+
appId: (_c = (_b = config.privyConfig) === null || _b === void 0 ? void 0 : _b.appId) !== null && _c !== void 0 ? _c : 'cm4ve714908o27dk2yurpnfhd',
|
|
34187
|
+
config: Object.assign(Object.assign({}, (_d = config.privyConfig) === null || _d === void 0 ? void 0 : _d.config), { loginMethods: ['email'], embeddedWallets: {
|
|
34188
|
+
solana: {
|
|
34189
|
+
createOnLogin: 'users-without-wallets'
|
|
34190
|
+
}
|
|
34191
|
+
}, appearance: Object.assign(Object.assign({}, (_f = (_e = config.privyConfig) === null || _e === void 0 ? void 0 : _e.config) === null || _f === void 0 ? void 0 : _f.appearance), { walletChainType: 'solana-only', showWalletLoginFirst: false, theme: 'dark', walletList: [] }) })
|
|
34192
|
+
};
|
|
34193
|
+
const privyProvider = new PrivyWalletProvider((_g = config.name) !== null && _g !== void 0 ? _g : null, (_h = config.logoUrl) !== null && _h !== void 0 ? _h : null, fallbackPrivyConfig, rpcUrl);
|
|
34276
34194
|
let provider = privyProvider;
|
|
34277
34195
|
if (config.chain === "offchain") {
|
|
34278
34196
|
provider = new OffchainAuthProvider(privyProvider);
|
|
@@ -34344,9 +34262,6 @@ async function getAuthProvider(config) {
|
|
|
34344
34262
|
console.log("[Offchain] Wrapping auth provider for Poofnet transaction tracking");
|
|
34345
34263
|
currentAuthProvider = new OffchainAuthProvider(currentAuthProvider);
|
|
34346
34264
|
}
|
|
34347
|
-
// Update core config to reflect the actual auth method being used
|
|
34348
|
-
const coreConfig = await getConfig();
|
|
34349
|
-
coreConfig.authMethod = authMethod;
|
|
34350
34265
|
return currentAuthProvider;
|
|
34351
34266
|
}
|
|
34352
34267
|
async function login$1() {
|
|
@@ -34355,6 +34270,7 @@ async function login$1() {
|
|
|
34355
34270
|
currentAuthProvider = await getAuthProvider(initConfig);
|
|
34356
34271
|
const coreConfig = await getConfig();
|
|
34357
34272
|
coreConfig.authProvider = currentAuthProvider;
|
|
34273
|
+
coreConfig.authMethod = currentAuthMethod;
|
|
34358
34274
|
setAuthProviderInstance(currentAuthProvider);
|
|
34359
34275
|
}
|
|
34360
34276
|
if (!currentAuthProvider) {
|
|
@@ -34368,6 +34284,9 @@ async function login$1() {
|
|
|
34368
34284
|
}
|
|
34369
34285
|
return null;
|
|
34370
34286
|
}
|
|
34287
|
+
function getCurrentAuthMethod() {
|
|
34288
|
+
return currentAuthMethod;
|
|
34289
|
+
}
|
|
34371
34290
|
async function logout$1() {
|
|
34372
34291
|
if (!currentAuthProvider) {
|
|
34373
34292
|
throw new Error("Auth provider not initialized. Please call init() first.");
|
|
@@ -34391,6 +34310,12 @@ async function init(newConfig) {
|
|
|
34391
34310
|
authProviderInstance = await getAuthProvider(newConfig);
|
|
34392
34311
|
// Initialize config with auth provider
|
|
34393
34312
|
await init$1(Object.assign(Object.assign({}, newConfig), { authProvider: authProviderInstance }));
|
|
34313
|
+
// Now that core is initialized, update the auth method on the config
|
|
34314
|
+
const authMethod = getCurrentAuthMethod();
|
|
34315
|
+
if (authMethod) {
|
|
34316
|
+
const coreConfig = await getConfig();
|
|
34317
|
+
coreConfig.authMethod = authMethod;
|
|
34318
|
+
}
|
|
34394
34319
|
// Wait for restoreSession to complete
|
|
34395
34320
|
// The appId check is done in SessionManager.getSession which is called by restoreSession
|
|
34396
34321
|
// If there's an appId mismatch, the session will be cleared and restoreSession will return null
|
|
@@ -34581,4 +34506,4 @@ exports.signSessionCreateMessage = signSessionCreateMessage;
|
|
|
34581
34506
|
exports.signTransaction = signTransaction;
|
|
34582
34507
|
exports.subscribe = subscribe;
|
|
34583
34508
|
exports.useAuth = useAuth;
|
|
34584
|
-
//# sourceMappingURL=index-
|
|
34509
|
+
//# sourceMappingURL=index-BluuzeCc.js.map
|