@bounded-sh/client 0.0.110 → 0.0.112-ux-audit.1
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/README.md +1 -1
- package/dist/auth/index.d.ts +3 -1
- package/dist/auth/oidc-auth.d.ts +2 -0
- package/dist/auth/providers/email-auth-provider.d.ts +1 -1
- package/dist/auth/providers/guest-auth-provider.d.ts +1 -1
- package/dist/auth/providers/injected-evm-wallet-provider.d.ts +1 -1
- package/dist/auth/providers/injected-wallet-provider.d.ts +1 -1
- package/dist/auth/providers/offchain-auth-provider.d.ts +1 -1
- package/dist/auth/providers/privy-expo-provider.d.ts +1 -1
- package/dist/auth/solana-rpc.d.ts +9 -0
- package/dist/{email-auth-provider-D9SQu9c1.mjs → email-auth-provider-BfCH7K6N.mjs} +4 -3
- package/dist/email-auth-provider-BfCH7K6N.mjs.map +1 -0
- package/dist/{email-auth-provider-T-Go_9h9.js → email-auth-provider-CG5cxOj0.js} +4 -3
- package/dist/email-auth-provider-CG5cxOj0.js.map +1 -0
- package/dist/{email-auth-provider-Czo-xM6n.js → email-auth-provider-DTrCfOJd.js} +4 -3
- package/dist/email-auth-provider-DTrCfOJd.js.map +1 -0
- package/dist/{email-auth-provider-BPeQo6xL.mjs → email-auth-provider-eyi3Wpnx.mjs} +4 -3
- package/dist/email-auth-provider-eyi3Wpnx.mjs.map +1 -0
- package/dist/{guest-auth-provider-BIohNOHi.mjs → guest-auth-provider-BsW56oJg.mjs} +10 -5
- package/dist/guest-auth-provider-BsW56oJg.mjs.map +1 -0
- package/dist/{guest-auth-provider-DsFTB844.mjs → guest-auth-provider-DjOFjtnk.mjs} +10 -5
- package/dist/guest-auth-provider-DjOFjtnk.mjs.map +1 -0
- package/dist/{guest-auth-provider-BDhwvzem.js → guest-auth-provider-Dtl1J-2F.js} +10 -5
- package/dist/guest-auth-provider-Dtl1J-2F.js.map +1 -0
- package/dist/{guest-auth-provider-DJ5nCGjq.js → guest-auth-provider-Tndt6tzJ.js} +10 -5
- package/dist/guest-auth-provider-Tndt6tzJ.js.map +1 -0
- package/dist/{index-Cs5nPIzA.js → index-Brdwqgqs.js} +256 -67
- package/dist/index-Brdwqgqs.js.map +1 -0
- package/dist/{index-DbXoOlIa.mjs → index-CRxls8Qc.mjs} +257 -68
- package/dist/index-CRxls8Qc.mjs.map +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{index.native-BSOqaKIz.mjs → index.native-CAH_ks0s.mjs} +245 -63
- package/dist/index.native-CAH_ks0s.mjs.map +1 -0
- package/dist/{index.native-BpcNwWQX.js → index.native-ingNhWPw.js} +244 -62
- package/dist/index.native-ingNhWPw.js.map +1 -0
- package/dist/index.native.js +1 -1
- package/dist/index.native.mjs +1 -1
- package/dist/{injected-evm-wallet-provider-BjqqLfPD.mjs → injected-evm-wallet-provider-BjkCeRBL.mjs} +4 -3
- package/dist/injected-evm-wallet-provider-BjkCeRBL.mjs.map +1 -0
- package/dist/{injected-evm-wallet-provider-_UNpc_hM.js → injected-evm-wallet-provider-Cao1U0NZ.js} +4 -3
- package/dist/{injected-evm-wallet-provider-_UNpc_hM.js.map → injected-evm-wallet-provider-Cao1U0NZ.js.map} +1 -1
- package/dist/{injected-evm-wallet-provider-CMl0Fyxk.js → injected-evm-wallet-provider-CwOGXCDt.js} +4 -3
- package/dist/injected-evm-wallet-provider-CwOGXCDt.js.map +1 -0
- package/dist/{injected-evm-wallet-provider-Xb2G-ZGI.mjs → injected-evm-wallet-provider-DXjwPjLW.mjs} +4 -3
- package/dist/{injected-evm-wallet-provider-Xb2G-ZGI.mjs.map → injected-evm-wallet-provider-DXjwPjLW.mjs.map} +1 -1
- package/dist/{injected-wallet-provider-D-Pq9QVK.mjs → injected-wallet-provider-BG6gGNch.mjs} +4 -3
- package/dist/{injected-wallet-provider-D-Pq9QVK.mjs.map → injected-wallet-provider-BG6gGNch.mjs.map} +1 -1
- package/dist/{injected-wallet-provider-DZOwvKgd.mjs → injected-wallet-provider-CfYNIIHd.mjs} +4 -3
- package/dist/{injected-wallet-provider-DZOwvKgd.mjs.map → injected-wallet-provider-CfYNIIHd.mjs.map} +1 -1
- package/dist/{injected-wallet-provider-C7Q0haGY.js → injected-wallet-provider-DSlHfgMU.js} +4 -3
- package/dist/{injected-wallet-provider-C7Q0haGY.js.map → injected-wallet-provider-DSlHfgMU.js.map} +1 -1
- package/dist/{injected-wallet-provider-CgHOrtmj.js → injected-wallet-provider-LTnqoaYD.js} +4 -3
- package/dist/{injected-wallet-provider-CgHOrtmj.js.map → injected-wallet-provider-LTnqoaYD.js.map} +1 -1
- package/package.json +2 -2
- package/dist/email-auth-provider-BPeQo6xL.mjs.map +0 -1
- package/dist/email-auth-provider-Czo-xM6n.js.map +0 -1
- package/dist/email-auth-provider-D9SQu9c1.mjs.map +0 -1
- package/dist/email-auth-provider-T-Go_9h9.js.map +0 -1
- package/dist/guest-auth-provider-BDhwvzem.js.map +0 -1
- package/dist/guest-auth-provider-BIohNOHi.mjs.map +0 -1
- package/dist/guest-auth-provider-DJ5nCGjq.js.map +0 -1
- package/dist/guest-auth-provider-DsFTB844.mjs.map +0 -1
- package/dist/index-Cs5nPIzA.js.map +0 -1
- package/dist/index-DbXoOlIa.mjs.map +0 -1
- package/dist/index.native-BSOqaKIz.mjs.map +0 -1
- package/dist/index.native-BpcNwWQX.js.map +0 -1
- package/dist/injected-evm-wallet-provider-BjqqLfPD.mjs.map +0 -1
- package/dist/injected-evm-wallet-provider-CMl0Fyxk.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getConfig, getActiveSessionManager, WebSessionManager, ReactNativeSessionManager, revokeSession, reconnectWithNewAuth, init as init$2,
|
|
1
|
+
import { getConfig, getActiveSessionManager, WebSessionManager, ReactNativeSessionManager, revokeSession, reconnectWithNewAuth, deriveUserIdentityFromIdToken, init as init$2, onSessionCleared, subscribe, getFreshAuthToken, getSessionGeneration, getIdToken as getIdToken$1, genAuthNonce, genSolanaMessage, createSessionWithSignature } from '@bounded-sh/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
function walletContextFromClaims(claims, baseUrl, expectedAppId, tenantOrigin) {
|
|
@@ -256,8 +256,9 @@ class OffchainAuthProvider {
|
|
|
256
256
|
async logout() {
|
|
257
257
|
await this.wrappedProvider.logout();
|
|
258
258
|
}
|
|
259
|
-
async restoreSession() {
|
|
260
|
-
const
|
|
259
|
+
async restoreSession(beforeCommit) {
|
|
260
|
+
const provider = this.wrappedProvider;
|
|
261
|
+
const user = await provider.restoreSession(beforeCommit);
|
|
261
262
|
if (user) {
|
|
262
263
|
return Object.assign(Object.assign({}, user), { provider: this });
|
|
263
264
|
}
|
|
@@ -758,15 +759,35 @@ function resolveSolanaWalletStandardChain(network, context) {
|
|
|
758
759
|
`Expected one of: solana_devnet, solana_mainnet.`);
|
|
759
760
|
}
|
|
760
761
|
}
|
|
762
|
+
/**
|
|
763
|
+
* The platform RPC endpoint for a supported Solana network, or null when the
|
|
764
|
+
* network is missing or unsupported. Used when the app passes no rpcUrl.
|
|
765
|
+
*/
|
|
766
|
+
function defaultSolanaRpcUrl(network) {
|
|
767
|
+
switch (network) {
|
|
768
|
+
case "solana_mainnet":
|
|
769
|
+
return SOLANA_MAINNET_RPC_URL;
|
|
770
|
+
case "solana_devnet":
|
|
771
|
+
return SOLANA_DEVNET_RPC_URL;
|
|
772
|
+
default:
|
|
773
|
+
return null;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* An explicit rpcUrl always wins. Otherwise the platform RPC for the configured
|
|
778
|
+
* network is used. With neither, fail closed.
|
|
779
|
+
*/
|
|
761
780
|
function resolveSolanaRpcUrl(explicitRpcUrl, network, context) {
|
|
781
|
+
var _a;
|
|
762
782
|
if (network != null && network !== "" && !isSupportedSolanaRpcNetwork(network)) {
|
|
763
783
|
throw new Error(`${context} does not support Solana network "${network}". ` +
|
|
764
784
|
`Expected one of: solana_devnet, solana_mainnet.`);
|
|
765
785
|
}
|
|
766
|
-
const rpcUrl = normalizeSolanaRpcUrl(explicitRpcUrl);
|
|
786
|
+
const rpcUrl = (_a = normalizeSolanaRpcUrl(explicitRpcUrl)) !== null && _a !== void 0 ? _a : defaultSolanaRpcUrl(network);
|
|
767
787
|
if (rpcUrl)
|
|
768
788
|
return rpcUrl;
|
|
769
|
-
throw new Error(`${context} requires
|
|
789
|
+
throw new Error(`${context} requires a Solana network. Set init({ chain: "solana_mainnet" | "solana_devnet" }) ` +
|
|
790
|
+
`or pass config.rpcUrl before signing or submitting onchain transactions.`);
|
|
770
791
|
}
|
|
771
792
|
|
|
772
793
|
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
@@ -5491,7 +5512,8 @@ async function loginWithRedirect(opts) {
|
|
|
5491
5512
|
return runNativeLogin(opts);
|
|
5492
5513
|
if (!hasDOM$2())
|
|
5493
5514
|
throw new Error('loginWithRedirect requires a browser or a configured React Native platform');
|
|
5494
|
-
const { url, pkce } = await buildAuthorize(opts);
|
|
5515
|
+
const { url, pkce } = await untilAborted(buildAuthorize(opts), opts.signal);
|
|
5516
|
+
throwIfCancelled(opts.signal);
|
|
5495
5517
|
// Stash the verifier + state so the redirect_uri page can finish the exchange. sessionStorage
|
|
5496
5518
|
// is per-tab and cleared on close — appropriate for a short-lived auth handshake. Keyed by
|
|
5497
5519
|
// this attempt's own state so a second concurrent login cannot overwrite it.
|
|
@@ -5520,9 +5542,29 @@ async function completeLoginFromRedirect() {
|
|
|
5520
5542
|
throw error;
|
|
5521
5543
|
return result.user;
|
|
5522
5544
|
}
|
|
5545
|
+
function throwIfCancelled(signal) {
|
|
5546
|
+
if (signal === null || signal === void 0 ? void 0 : signal.aborted)
|
|
5547
|
+
throw new Error('cancelled');
|
|
5548
|
+
}
|
|
5549
|
+
async function untilAborted(work, signal) {
|
|
5550
|
+
if (!signal)
|
|
5551
|
+
return work;
|
|
5552
|
+
throwIfCancelled(signal);
|
|
5553
|
+
let onAbort;
|
|
5554
|
+
try {
|
|
5555
|
+
return await Promise.race([work, new Promise((_, reject) => {
|
|
5556
|
+
onAbort = () => reject(new Error('cancelled'));
|
|
5557
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
5558
|
+
})]);
|
|
5559
|
+
}
|
|
5560
|
+
finally {
|
|
5561
|
+
signal.removeEventListener('abort', onAbort);
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5523
5564
|
/** Popup variant: open the hosted login in a popup; resolves with the User once the popup's
|
|
5524
5565
|
* redirect_uri page initializes the SDK, which hands the code back automatically. */
|
|
5525
5566
|
async function loginWithPopup(opts) {
|
|
5567
|
+
throwIfCancelled(opts.signal);
|
|
5526
5568
|
if (!hasDOM$2())
|
|
5527
5569
|
throw new Error('loginWithPopup is web-only — on React Native use loginWithRedirect()');
|
|
5528
5570
|
// Open synchronously, before PKCE/config awaits consume the click's user-
|
|
@@ -5540,7 +5582,7 @@ async function loginWithPopup(opts) {
|
|
|
5540
5582
|
throw new Error('Popup blocked — use loginWithRedirect() instead');
|
|
5541
5583
|
let authorization;
|
|
5542
5584
|
try {
|
|
5543
|
-
authorization = await buildAuthorize(opts, 'popup');
|
|
5585
|
+
authorization = await untilAborted(buildAuthorize(opts, 'popup'), opts.signal);
|
|
5544
5586
|
}
|
|
5545
5587
|
catch (error) {
|
|
5546
5588
|
try {
|
|
@@ -5557,6 +5599,7 @@ async function loginWithPopup(opts) {
|
|
|
5557
5599
|
// window with no listener or watchdog attached.
|
|
5558
5600
|
let expectedOrigin;
|
|
5559
5601
|
try {
|
|
5602
|
+
throwIfCancelled(opts.signal);
|
|
5560
5603
|
expectedOrigin = new URL(pkce.redirectUri).origin;
|
|
5561
5604
|
sessionStorage.setItem(pkceKey(pkce.state), JSON.stringify(pkce));
|
|
5562
5605
|
}
|
|
@@ -5588,20 +5631,42 @@ async function loginWithPopup(opts) {
|
|
|
5588
5631
|
setAuthLoading(true); // reflect "signing in…" while the popup is open
|
|
5589
5632
|
try {
|
|
5590
5633
|
return await new Promise((resolve, reject) => {
|
|
5634
|
+
var _a, _b;
|
|
5591
5635
|
let settled = false;
|
|
5636
|
+
let handedOff = false;
|
|
5637
|
+
let committing = false;
|
|
5592
5638
|
let timer;
|
|
5593
5639
|
let navigationTimer;
|
|
5594
5640
|
let completionTimer;
|
|
5595
5641
|
const cleanup = () => {
|
|
5596
|
-
settled = true;
|
|
5597
5642
|
clearInterval(timer);
|
|
5598
5643
|
clearTimeout(navigationTimer);
|
|
5599
5644
|
clearTimeout(completionTimer);
|
|
5600
5645
|
window.removeEventListener('message', onMsg);
|
|
5601
5646
|
removeAttempt(pkce.state);
|
|
5602
5647
|
};
|
|
5648
|
+
const finish = (error, user) => {
|
|
5649
|
+
var _a;
|
|
5650
|
+
if (settled)
|
|
5651
|
+
return;
|
|
5652
|
+
settled = true;
|
|
5653
|
+
cleanup();
|
|
5654
|
+
(_a = opts.signal) === null || _a === void 0 ? void 0 : _a.removeEventListener('abort', onAbort);
|
|
5655
|
+
try {
|
|
5656
|
+
popup.close();
|
|
5657
|
+
}
|
|
5658
|
+
catch ( /* ignore */_b) { /* ignore */ }
|
|
5659
|
+
if (error)
|
|
5660
|
+
reject(error);
|
|
5661
|
+
else
|
|
5662
|
+
resolve(user);
|
|
5663
|
+
};
|
|
5664
|
+
// Provider adoption commits synchronously after its final guard. An auth
|
|
5665
|
+
// listener dismissing the card there cannot cancel an already signed-in user.
|
|
5666
|
+
const onAbort = () => { if (!committing)
|
|
5667
|
+
finish(new Error('cancelled')); };
|
|
5603
5668
|
const onMsg = async (ev) => {
|
|
5604
|
-
if (settled || ev.origin !== expectedOrigin || ev.source !== popup)
|
|
5669
|
+
if (settled || handedOff || ev.origin !== expectedOrigin || ev.source !== popup)
|
|
5605
5670
|
return;
|
|
5606
5671
|
const d = ev.data;
|
|
5607
5672
|
if (!d || d.type !== 'bounded-oidc-code' ||
|
|
@@ -5615,35 +5680,30 @@ async function loginWithPopup(opts) {
|
|
|
5615
5680
|
return;
|
|
5616
5681
|
if (d.appId !== pkce.appId || d.issuer !== pkce.issuer)
|
|
5617
5682
|
return;
|
|
5683
|
+
handedOff = true;
|
|
5618
5684
|
cleanup();
|
|
5619
5685
|
try {
|
|
5686
|
+
throwIfCancelled(opts.signal);
|
|
5620
5687
|
await validateAttempt(pkce, new URL(d.callbackUrl));
|
|
5688
|
+
throwIfCancelled(opts.signal);
|
|
5621
5689
|
popup.postMessage({ type: 'bounded-oidc-accepted', state: pkce.state }, expectedOrigin);
|
|
5622
5690
|
if (d.error)
|
|
5623
5691
|
throw new Error(typeof d.errorDescription === 'string' ? d.errorDescription : `Login failed: ${d.error}`);
|
|
5624
|
-
const user = await exchangeCode(d.code, pkce);
|
|
5625
|
-
|
|
5626
|
-
popup.close();
|
|
5627
|
-
}
|
|
5628
|
-
catch ( /* ignore */_a) { /* ignore */ }
|
|
5629
|
-
resolve(user);
|
|
5692
|
+
const user = await exchangeCode(d.code, pkce, opts.signal, () => { committing = true; });
|
|
5693
|
+
finish(undefined, user);
|
|
5630
5694
|
}
|
|
5631
5695
|
catch (e) {
|
|
5632
|
-
|
|
5633
|
-
popup.close();
|
|
5634
|
-
}
|
|
5635
|
-
catch ( /* ignore */_b) { /* ignore */ }
|
|
5636
|
-
reject(e);
|
|
5696
|
+
finish(e);
|
|
5637
5697
|
}
|
|
5638
5698
|
};
|
|
5699
|
+
(_a = opts.signal) === null || _a === void 0 ? void 0 : _a.addEventListener('abort', onAbort, { once: true });
|
|
5700
|
+
if ((_b = opts.signal) === null || _b === void 0 ? void 0 : _b.aborted) {
|
|
5701
|
+
onAbort();
|
|
5702
|
+
return;
|
|
5703
|
+
}
|
|
5639
5704
|
window.addEventListener('message', onMsg);
|
|
5640
5705
|
completionTimer = setTimeout(() => {
|
|
5641
|
-
|
|
5642
|
-
try {
|
|
5643
|
-
popup.close();
|
|
5644
|
-
}
|
|
5645
|
-
catch ( /* ignore */_a) { /* ignore */ }
|
|
5646
|
-
reject(new Error('Login expired or its popup disconnected. Start sign-in again.'));
|
|
5706
|
+
finish(new Error('Login expired or its popup disconnected. Start sign-in again.'));
|
|
5647
5707
|
}, LOGIN_TIMEOUT_MS);
|
|
5648
5708
|
// Some browser/extension combinations can return a real popup handle but
|
|
5649
5709
|
// strand the window at about:blank instead of navigating to the hosted
|
|
@@ -5664,23 +5724,18 @@ async function loginWithPopup(opts) {
|
|
|
5664
5724
|
const NAVIGATION_RECHECK_MS = 2000;
|
|
5665
5725
|
const navigationStartedAt = Date.now();
|
|
5666
5726
|
const checkNavigation = () => {
|
|
5667
|
-
if (settled || popup.closed)
|
|
5727
|
+
if (settled || handedOff || popup.closed)
|
|
5668
5728
|
return;
|
|
5669
5729
|
try {
|
|
5670
5730
|
if (popup.location.href === 'about:blank') {
|
|
5671
5731
|
if (Date.now() - navigationStartedAt >= NAVIGATION_GRACE_MS) {
|
|
5672
|
-
|
|
5673
|
-
try {
|
|
5674
|
-
popup.close();
|
|
5675
|
-
}
|
|
5676
|
-
catch ( /* ignore */_a) { /* ignore */ }
|
|
5677
|
-
reject(new Error('Popup stalled at about:blank - use loginWithRedirect() instead'));
|
|
5732
|
+
finish(new Error('Popup stalled at about:blank - use loginWithRedirect() instead'));
|
|
5678
5733
|
return;
|
|
5679
5734
|
}
|
|
5680
5735
|
navigationTimer = setTimeout(checkNavigation, NAVIGATION_RECHECK_MS);
|
|
5681
5736
|
}
|
|
5682
5737
|
}
|
|
5683
|
-
catch ( /* cross-origin hosted auth loaded normally */
|
|
5738
|
+
catch ( /* cross-origin hosted auth loaded normally */_a) { /* cross-origin hosted auth loaded normally */ }
|
|
5684
5739
|
};
|
|
5685
5740
|
navigationTimer = setTimeout(checkNavigation, NAVIGATION_RECHECK_MS);
|
|
5686
5741
|
// The popup posts its code and then closes ITSELF, so a naive "popup.closed -> reject"
|
|
@@ -5690,10 +5745,8 @@ async function loginWithPopup(opts) {
|
|
|
5690
5745
|
timer = setInterval(() => {
|
|
5691
5746
|
if (popup.closed) {
|
|
5692
5747
|
clearInterval(timer);
|
|
5693
|
-
setTimeout(() => { if (!settled)
|
|
5694
|
-
|
|
5695
|
-
reject(new Error('Login window closed'));
|
|
5696
|
-
} }, 500);
|
|
5748
|
+
setTimeout(() => { if (!settled && !handedOff)
|
|
5749
|
+
finish(new Error('Login window closed')); }, 500);
|
|
5697
5750
|
}
|
|
5698
5751
|
}, 500);
|
|
5699
5752
|
});
|
|
@@ -5744,9 +5797,10 @@ async function inlineAuthEndpoint() {
|
|
|
5744
5797
|
const cfg = await getConfig();
|
|
5745
5798
|
return { base: await issuerBase(), appId: cfg.appId };
|
|
5746
5799
|
}
|
|
5747
|
-
async function exchangeCode(code, pkce) {
|
|
5800
|
+
async function exchangeCode(code, pkce, signal, onCommitting) {
|
|
5748
5801
|
const generation = getInitializationGeneration();
|
|
5749
5802
|
const beforeCommit = () => {
|
|
5803
|
+
throwIfCancelled(signal);
|
|
5750
5804
|
if (generation !== getInitializationGeneration())
|
|
5751
5805
|
throw new Error('Login was superseded by SDK reinitialization. Start sign-in again.');
|
|
5752
5806
|
};
|
|
@@ -5762,7 +5816,7 @@ async function exchangeCode(code, pkce) {
|
|
|
5762
5816
|
let res;
|
|
5763
5817
|
try {
|
|
5764
5818
|
res = await fetch(`${base}/api/auth/oauth2/token`, {
|
|
5765
|
-
method: 'POST', headers: { 'content-type': 'application/x-www-form-urlencoded' }, body: body.toString(),
|
|
5819
|
+
method: 'POST', headers: { 'content-type': 'application/x-www-form-urlencoded' }, body: body.toString(), signal,
|
|
5766
5820
|
});
|
|
5767
5821
|
}
|
|
5768
5822
|
catch (err) {
|
|
@@ -5788,7 +5842,7 @@ async function exchangeCode(code, pkce) {
|
|
|
5788
5842
|
// Adopt on EVERY session surface (see establishInlineSession) - hosted
|
|
5789
5843
|
// popup/redirect completions all land here, so this closes their gap too.
|
|
5790
5844
|
try {
|
|
5791
|
-
await adoptSessionProvider({ provider: oidcProviderSingleton, method: 'email', configKey: 'direct:oidc', user, beforeCommit });
|
|
5845
|
+
await adoptSessionProvider({ provider: oidcProviderSingleton, method: 'email', configKey: 'direct:oidc', user, beforeCommit: () => { beforeCommit(); onCommitting === null || onCommitting === void 0 ? void 0 : onCommitting(); } });
|
|
5792
5846
|
}
|
|
5793
5847
|
catch (error) {
|
|
5794
5848
|
if (typeof rollback === 'function')
|
|
@@ -5857,6 +5911,31 @@ function idTokenIsGuest(idToken, expectedAddress) {
|
|
|
5857
5911
|
function storedSessionIsGuest() {
|
|
5858
5912
|
return idTokenIsGuest(getStoredIdToken());
|
|
5859
5913
|
}
|
|
5914
|
+
/** Internal: select a cross-tab restore from bearer claims, never global hints. */
|
|
5915
|
+
function storedSessionAuthMethod(config) {
|
|
5916
|
+
try {
|
|
5917
|
+
const token = getStoredIdToken();
|
|
5918
|
+
if (!token)
|
|
5919
|
+
return null;
|
|
5920
|
+
let payload = token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/');
|
|
5921
|
+
payload += '='.repeat((4 - payload.length % 4) % 4);
|
|
5922
|
+
const claims = JSON.parse(getPlatform().atob(payload));
|
|
5923
|
+
const method = claims.is_anonymous === true ? 'guest'
|
|
5924
|
+
: claims['custom:walletProvider'] === 'turnkey' || claims.email ? 'email'
|
|
5925
|
+
: claims['custom:evmWalletAddress'] ? 'evm-wallet'
|
|
5926
|
+
: claims['custom:walletAddress'] ? 'phantom' : 'email';
|
|
5927
|
+
if (config.authMethod != null && canonicalWalletAuthMethod(config.authMethod) !== method)
|
|
5928
|
+
return null;
|
|
5929
|
+
if (method === 'evm-wallet' && config.authMethod !== 'evm-wallet')
|
|
5930
|
+
return null;
|
|
5931
|
+
if (method === 'phantom' && (isWalletLoginDisabled(config) || isEmailRequired(config)))
|
|
5932
|
+
return null;
|
|
5933
|
+
return method;
|
|
5934
|
+
}
|
|
5935
|
+
catch (_a) {
|
|
5936
|
+
return null;
|
|
5937
|
+
}
|
|
5938
|
+
}
|
|
5860
5939
|
/**
|
|
5861
5940
|
* Pick the provider used for an ordinary `init({ appId })` restore.
|
|
5862
5941
|
*
|
|
@@ -6118,9 +6197,10 @@ function optionalProviderError(method) {
|
|
|
6118
6197
|
`loginWithRedirect(...) for Bounded Auth, signInAnonymously() for guests, ` +
|
|
6119
6198
|
`or install/import an explicit wallet-provider entry once your app opts into "${method}".`);
|
|
6120
6199
|
}
|
|
6121
|
-
async function getAuthProvider(config) {
|
|
6200
|
+
async function getAuthProvider(config, fromStorage = false) {
|
|
6122
6201
|
var _a;
|
|
6123
|
-
const
|
|
6202
|
+
const requestedAuthMethod = config ? (fromStorage ? storedSessionAuthMethod(config) : authMethodForInit(config)) : null;
|
|
6203
|
+
const nextProviderConfigKey = config ? authProviderConfigKey(Object.assign(Object.assign({}, config), { authMethod: requestedAuthMethod })) : null;
|
|
6124
6204
|
if (currentAuthProvider && (!config || currentAuthProviderConfigKey === nextProviderConfigKey)) {
|
|
6125
6205
|
return currentAuthProvider;
|
|
6126
6206
|
}
|
|
@@ -6135,7 +6215,8 @@ async function getAuthProvider(config) {
|
|
|
6135
6215
|
initConfig = config;
|
|
6136
6216
|
// Keep what the app actually wrote for error text; everything else runs on
|
|
6137
6217
|
// the canonical method so exactly one string reaches storage and the issuer.
|
|
6138
|
-
|
|
6218
|
+
if (!requestedAuthMethod)
|
|
6219
|
+
throw new Error('The stored session is incompatible with this app authentication configuration.');
|
|
6139
6220
|
const authMethod = canonicalWalletAuthMethod(requestedAuthMethod);
|
|
6140
6221
|
const rpcUrl = normalizeSolanaRpcUrl(config.rpcUrl);
|
|
6141
6222
|
const configuredNetwork = getConfiguredSolanaNetwork(config);
|
|
@@ -6160,7 +6241,7 @@ async function getAuthProvider(config) {
|
|
|
6160
6241
|
// manager as legacy email sessions. Human login should be started
|
|
6161
6242
|
// with loginWithRedirect(); this provider is kept as the restore and
|
|
6162
6243
|
// logout surface for those sessions.
|
|
6163
|
-
currentAuthProvider = new (await import('./email-auth-provider-
|
|
6244
|
+
currentAuthProvider = new (await import('./email-auth-provider-eyi3Wpnx.mjs')).EmailAuthProvider();
|
|
6164
6245
|
break;
|
|
6165
6246
|
case "phantom": {
|
|
6166
6247
|
// First-class Solana WALLET LOGIN (the poof/TaroBase-style "connect
|
|
@@ -6202,7 +6283,7 @@ async function getAuthProvider(config) {
|
|
|
6202
6283
|
// (bounded-login-widget.ts), so registration never counts as
|
|
6203
6284
|
// evidence the user has a wallet.
|
|
6204
6285
|
await ensureSolanaMobileWalletRegistered(config, configuredNetwork);
|
|
6205
|
-
const { InjectedWalletProvider } = await import('./injected-wallet-provider-
|
|
6286
|
+
const { InjectedWalletProvider } = await import('./injected-wallet-provider-BG6gGNch.mjs');
|
|
6206
6287
|
currentAuthProvider = new InjectedWalletProvider(resolveInjectedWalletConfig(config), rpcUrl, configuredNetwork);
|
|
6207
6288
|
break;
|
|
6208
6289
|
}
|
|
@@ -6215,7 +6296,7 @@ async function getAuthProvider(config) {
|
|
|
6215
6296
|
// Selecting authMethod:'evm-wallet' IS the opt-in — pass evmWalletConfig
|
|
6216
6297
|
// to point at a specific wallet or set chainId/domain.
|
|
6217
6298
|
const evmWalletConfig = ((_a = config.evmWalletConfig) !== null && _a !== void 0 ? _a : {});
|
|
6218
|
-
const { InjectedEvmWalletProvider } = await import('./injected-evm-wallet-provider-
|
|
6299
|
+
const { InjectedEvmWalletProvider } = await import('./injected-evm-wallet-provider-BjkCeRBL.mjs');
|
|
6219
6300
|
currentAuthProvider = new InjectedEvmWalletProvider(evmWalletConfig);
|
|
6220
6301
|
break;
|
|
6221
6302
|
}
|
|
@@ -6240,7 +6321,7 @@ async function getAuthProvider(config) {
|
|
|
6240
6321
|
break;
|
|
6241
6322
|
case "guest":
|
|
6242
6323
|
// Anonymous auth: a device-local ed25519 keypair signs the challenge.
|
|
6243
|
-
currentAuthProvider = new (await import('./guest-auth-provider-
|
|
6324
|
+
currentAuthProvider = new (await import('./guest-auth-provider-BsW56oJg.mjs')).GuestAuthProvider();
|
|
6244
6325
|
break;
|
|
6245
6326
|
}
|
|
6246
6327
|
if (!currentAuthProvider) {
|
|
@@ -6302,7 +6383,7 @@ async function signInAnonymously() {
|
|
|
6302
6383
|
// Lazy-load the guest provider so its ed25519/web3 dependencies stay out of
|
|
6303
6384
|
// the main bundle for data-only apps. Specifier is a static string literal
|
|
6304
6385
|
// so bundle-splitting can see it.
|
|
6305
|
-
const provider = new (await import('./guest-auth-provider-
|
|
6386
|
+
const provider = new (await import('./guest-auth-provider-BsW56oJg.mjs')).GuestAuthProvider();
|
|
6306
6387
|
setAuthLoading(true); // reflect "signing in…" while the guest keypair session is minted
|
|
6307
6388
|
// adoptSessionProvider awaits only getConfig() (already resolved here) and then
|
|
6308
6389
|
// runs every write - provider/method/config/marker/user - in one synchronous
|
|
@@ -6473,7 +6554,7 @@ function ensureSharedWalletLoginReady() {
|
|
|
6473
6554
|
if (!sharedWalletReady) {
|
|
6474
6555
|
sharedWalletReady = (async () => {
|
|
6475
6556
|
await getConfig();
|
|
6476
|
-
await import('./injected-wallet-provider-
|
|
6557
|
+
await import('./injected-wallet-provider-BG6gGNch.mjs');
|
|
6477
6558
|
})().catch((error) => {
|
|
6478
6559
|
sharedWalletReady = null;
|
|
6479
6560
|
throw error;
|
|
@@ -6576,7 +6657,7 @@ async function loginWithWallet(options) {
|
|
|
6576
6657
|
await ensureSharedWalletLoginReady();
|
|
6577
6658
|
else
|
|
6578
6659
|
await ensureWalletLoginReady();
|
|
6579
|
-
const { InjectedWalletProvider } = await import('./injected-wallet-provider-
|
|
6660
|
+
const { InjectedWalletProvider } = await import('./injected-wallet-provider-BG6gGNch.mjs');
|
|
6580
6661
|
// Keep the RAW wallet provider: the offchain wrapper forwards only a fixed
|
|
6581
6662
|
// set of methods, so cleanup below must speak to the provider that actually
|
|
6582
6663
|
// holds the config rather than to whatever is wrapping it.
|
|
@@ -6848,9 +6929,21 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
6848
6929
|
logout: logout$1,
|
|
6849
6930
|
preloadWalletLogin: preloadWalletLogin,
|
|
6850
6931
|
resolveAuthMode: resolveAuthMode,
|
|
6851
|
-
signInAnonymously: signInAnonymously
|
|
6932
|
+
signInAnonymously: signInAnonymously,
|
|
6933
|
+
storedSessionAuthMethod: storedSessionAuthMethod
|
|
6852
6934
|
});
|
|
6853
6935
|
|
|
6936
|
+
/**
|
|
6937
|
+
* An explicit rpcUrl wins; otherwise a Solana chain gets the platform RPC so
|
|
6938
|
+
* every onchain path (wallet signing, submission, reconcile) has one.
|
|
6939
|
+
*/
|
|
6940
|
+
function withDefaultSolanaRpcUrl(config) {
|
|
6941
|
+
var _a;
|
|
6942
|
+
if (normalizeSolanaRpcUrl(config.rpcUrl))
|
|
6943
|
+
return config;
|
|
6944
|
+
const rpcUrl = defaultSolanaRpcUrl((_a = config.chain) === null || _a === void 0 ? void 0 : _a.trim());
|
|
6945
|
+
return rpcUrl ? Object.assign(Object.assign({}, config), { rpcUrl }) : config;
|
|
6946
|
+
}
|
|
6854
6947
|
/**
|
|
6855
6948
|
* Subscribed once per process, not per init(): re-registering on every init would
|
|
6856
6949
|
* stack duplicate handlers on repeated initialization.
|
|
@@ -6915,11 +7008,80 @@ let isAuthLoading = false;
|
|
|
6915
7008
|
let authReadyPromise = null;
|
|
6916
7009
|
let initializingConfig = null;
|
|
6917
7010
|
let initializationGeneration = 0;
|
|
7011
|
+
let initializedConfig = null;
|
|
7012
|
+
let storageBridgeRegistered = false;
|
|
7013
|
+
let observedIdToken = null;
|
|
7014
|
+
let observedIssuer = null;
|
|
7015
|
+
// Storage events carry no authority. Re-read the active manager's app/issuer
|
|
7016
|
+
// namespace, then use the ordinary initializer/provider restore and listeners.
|
|
7017
|
+
function registerStorageBridge() {
|
|
7018
|
+
if (storageBridgeRegistered || !getPlatform().hasDOM || typeof window === 'undefined')
|
|
7019
|
+
return;
|
|
7020
|
+
storageBridgeRegistered = true;
|
|
7021
|
+
window.addEventListener('storage', (event) => {
|
|
7022
|
+
if (event.storageArea !== window.localStorage || !initializedConfig)
|
|
7023
|
+
return;
|
|
7024
|
+
void syncStoredSession().catch((error) => console.warn('Bounded session synchronization failed:', error));
|
|
7025
|
+
});
|
|
7026
|
+
}
|
|
7027
|
+
async function syncStoredSession() {
|
|
7028
|
+
const config = initializedConfig;
|
|
7029
|
+
if (!config)
|
|
7030
|
+
return;
|
|
7031
|
+
const token = WebSessionManager.getIdToken();
|
|
7032
|
+
const issuer = WebSessionManager.getIssuer();
|
|
7033
|
+
if (token === observedIdToken && issuer === observedIssuer)
|
|
7034
|
+
return;
|
|
7035
|
+
observedIdToken = token;
|
|
7036
|
+
observedIssuer = issuer;
|
|
7037
|
+
const generation = ++initializationGeneration;
|
|
7038
|
+
// Hide the former principal while the replacement is validated. This also
|
|
7039
|
+
// reconnects live reads through the existing auth-state change path.
|
|
7040
|
+
setCurrentUser(null);
|
|
7041
|
+
if (authReadyPromise)
|
|
7042
|
+
await authReadyPromise.catch(() => { });
|
|
7043
|
+
if (generation !== initializationGeneration || config !== initializedConfig)
|
|
7044
|
+
return;
|
|
7045
|
+
const record = await WebSessionManager.readSessionWithGeneration();
|
|
7046
|
+
if (generation !== initializationGeneration || config !== initializedConfig)
|
|
7047
|
+
return;
|
|
7048
|
+
if (!record)
|
|
7049
|
+
return;
|
|
7050
|
+
const normalize = (url) => (url || '').replace(/\/+$/, '');
|
|
7051
|
+
const resolvedConfig = await getConfig();
|
|
7052
|
+
if (generation !== initializationGeneration || config !== initializedConfig)
|
|
7053
|
+
return;
|
|
7054
|
+
const allowedIssuers = [normalize(resolvedConfig.humanAuthApiUrl || 'https://auth.bounded.sh'), normalize(resolvedConfig.authApiUrl)].filter(Boolean);
|
|
7055
|
+
// A legacy shared blob can belong to another app. Never restore or clear
|
|
7056
|
+
// that app's credential; the current app remains signed out.
|
|
7057
|
+
if ((record.appId && record.appId !== config.appId)
|
|
7058
|
+
|| (record.issuer && !allowedIssuers.includes(normalize(record.issuer))))
|
|
7059
|
+
return;
|
|
7060
|
+
if (!storedSessionAuthMethod(config))
|
|
7061
|
+
return;
|
|
7062
|
+
const restored = startInitialization(config, true);
|
|
7063
|
+
const restoreGeneration = initializationGeneration;
|
|
7064
|
+
try {
|
|
7065
|
+
await restored;
|
|
7066
|
+
}
|
|
7067
|
+
catch (error) {
|
|
7068
|
+
if (restoreGeneration === initializationGeneration && WebSessionManager.getIdToken())
|
|
7069
|
+
throw error;
|
|
7070
|
+
}
|
|
7071
|
+
}
|
|
6918
7072
|
/** Internal guard for a login result arriving after the app reconfigured the SDK. */
|
|
6919
7073
|
function getInitializationGeneration() { return initializationGeneration; }
|
|
6920
7074
|
// This file acts as a middleware for the global state of the SDK
|
|
6921
7075
|
// This mostly involves setting up the AuthProvider and managing the current user
|
|
6922
|
-
async function initialize(
|
|
7076
|
+
async function initialize(requestedConfig, fromStorage) {
|
|
7077
|
+
const newConfig = withDefaultSolanaRpcUrl(requestedConfig);
|
|
7078
|
+
const generation = initializationGeneration;
|
|
7079
|
+
const validateStorage = fromStorage ? WebSessionManager.captureSessionEstablishment() : undefined;
|
|
7080
|
+
const beforeCommit = () => {
|
|
7081
|
+
if (generation !== initializationGeneration)
|
|
7082
|
+
throw new Error('Session restore was superseded.');
|
|
7083
|
+
validateStorage === null || validateStorage === void 0 ? void 0 : validateStorage();
|
|
7084
|
+
};
|
|
6923
7085
|
// Mark auth as loading for the ENTIRE init/restore window so consumers render
|
|
6924
7086
|
// a neutral/loading state instead of the signed-out UI while we rehydrate the
|
|
6925
7087
|
// session — otherwise getCurrentUser() is null + loading is false during the
|
|
@@ -6938,8 +7100,9 @@ async function initialize(newConfig) {
|
|
|
6938
7100
|
// onAuthStateChanged never fired, and every consumer UI went on showing a
|
|
6939
7101
|
// connected wallet for a session the server no longer knew about.
|
|
6940
7102
|
registerSessionClearedBridge();
|
|
7103
|
+
registerStorageBridge();
|
|
6941
7104
|
// Get auth provider first
|
|
6942
|
-
authProviderInstance = await getAuthProvider(newConfig);
|
|
7105
|
+
authProviderInstance = await getAuthProvider(newConfig, fromStorage);
|
|
6943
7106
|
// Initialize config with auth provider
|
|
6944
7107
|
await init$2(Object.assign(Object.assign({}, newConfig), { authProvider: authProviderInstance }));
|
|
6945
7108
|
// A return establishes its own provider/session, or hands off a popup.
|
|
@@ -6964,7 +7127,8 @@ async function initialize(newConfig) {
|
|
|
6964
7127
|
// Wait for restoreSession to complete
|
|
6965
7128
|
// The appId check is done in SessionManager.getSession which is called by restoreSession
|
|
6966
7129
|
// If there's an appId mismatch, the session will be cleared and restoreSession will return null
|
|
6967
|
-
let user = await authProviderInstance.restoreSession();
|
|
7130
|
+
let user = await authProviderInstance.restoreSession(beforeCommit);
|
|
7131
|
+
beforeCommit();
|
|
6968
7132
|
// If a session exists but was created before auth method tracking (legacy session),
|
|
6969
7133
|
// clear it to avoid mismatches when the app switches auth methods (e.g. email → phantom)
|
|
6970
7134
|
//
|
|
@@ -6972,9 +7136,10 @@ async function initialize(newConfig) {
|
|
|
6972
7136
|
// unawaited call would return a Promise (always truthy) — nulling the user
|
|
6973
7137
|
// unconditionally AND letting setCurrentUser run while the old credential
|
|
6974
7138
|
// was still in storage.
|
|
6975
|
-
if (user && await clearIncompatibleSession()) {
|
|
7139
|
+
if (user && !fromStorage && await clearIncompatibleSession()) {
|
|
6976
7140
|
user = null;
|
|
6977
7141
|
}
|
|
7142
|
+
beforeCommit();
|
|
6978
7143
|
setCurrentUser(user);
|
|
6979
7144
|
// Mark init as completed
|
|
6980
7145
|
initCompleted = true;
|
|
@@ -7014,13 +7179,17 @@ function sameConfigValue(a, b, seen = new WeakMap()) {
|
|
|
7014
7179
|
&& sameConfigValue(a[key], b[key], seen));
|
|
7015
7180
|
}
|
|
7016
7181
|
function init$1(newConfig) {
|
|
7182
|
+
return startInitialization(newConfig, false);
|
|
7183
|
+
}
|
|
7184
|
+
function startInitialization(newConfig, fromStorage) {
|
|
7017
7185
|
if (initializingConfig) {
|
|
7018
7186
|
if (sameConfigValue(initializingConfig, newConfig)) {
|
|
7019
7187
|
return authReadyPromise;
|
|
7020
7188
|
}
|
|
7021
7189
|
return Promise.reject(new Error('SDK initialization is in progress. Await init() before changing its configuration.'));
|
|
7022
7190
|
}
|
|
7023
|
-
|
|
7191
|
+
initializedConfig = Object.assign({}, newConfig);
|
|
7192
|
+
initializingConfig = initializedConfig;
|
|
7024
7193
|
initializationGeneration++;
|
|
7025
7194
|
let resolveReady;
|
|
7026
7195
|
let rejectReady;
|
|
@@ -7032,7 +7201,7 @@ function init$1(newConfig) {
|
|
|
7032
7201
|
// auth-loading listener to call waitForAuthReady() synchronously when init()
|
|
7033
7202
|
// announces that session restoration has begun.
|
|
7034
7203
|
authReadyPromise = ready;
|
|
7035
|
-
void initialize(initializingConfig).then(() => { initializingConfig = null; resolveReady(); }, (error) => { initializingConfig = null; rejectReady(error); });
|
|
7204
|
+
void initialize(initializingConfig, fromStorage).then(() => { initializingConfig = null; resolveReady(); }, (error) => { initializingConfig = null; rejectReady(error); });
|
|
7036
7205
|
return ready;
|
|
7037
7206
|
}
|
|
7038
7207
|
/**
|
|
@@ -7105,6 +7274,13 @@ function userPrincipalKey(user) {
|
|
|
7105
7274
|
}
|
|
7106
7275
|
// Update the currentUser and notify listeners
|
|
7107
7276
|
function setCurrentUser(user) {
|
|
7277
|
+
observedIdToken = getCurrentIdToken();
|
|
7278
|
+
try {
|
|
7279
|
+
observedIssuer = getActiveSessionManager().getIssuer();
|
|
7280
|
+
}
|
|
7281
|
+
catch (_a) {
|
|
7282
|
+
observedIssuer = null;
|
|
7283
|
+
}
|
|
7108
7284
|
// Enrich with the universal identity fields (id/email) derived from the
|
|
7109
7285
|
// active session's idToken — central chokepoint so every provider's user
|
|
7110
7286
|
// object gains { id, address, email } without each construction site
|
|
@@ -8052,7 +8228,8 @@ async function prepareAndOpen(opts, pending) {
|
|
|
8052
8228
|
return authApi.loginWithRedirect(options);
|
|
8053
8229
|
// Invoke immediately inside the click handler to retain popup activation.
|
|
8054
8230
|
return authApi.loginWithPopup(options).catch((error) => {
|
|
8055
|
-
|
|
8231
|
+
var _a;
|
|
8232
|
+
if (!((_a = options.signal) === null || _a === void 0 ? void 0 : _a.aborted) && shouldFallbackToRedirect(error))
|
|
8056
8233
|
return authApi.loginWithRedirect(options);
|
|
8057
8234
|
throw error;
|
|
8058
8235
|
});
|
|
@@ -8190,6 +8367,12 @@ async function prepareAndOpen(opts, pending) {
|
|
|
8190
8367
|
let activeAttempt = 0;
|
|
8191
8368
|
let abortScopedLogin = null;
|
|
8192
8369
|
let abortGesture = null;
|
|
8370
|
+
const startHostedLogin = (options) => {
|
|
8371
|
+
const controller = new AbortController();
|
|
8372
|
+
const abort = () => controller.abort();
|
|
8373
|
+
abortScopedLogin = abort;
|
|
8374
|
+
return hostedLogin(Object.assign(Object.assign({}, options), { signal: controller.signal }));
|
|
8375
|
+
};
|
|
8193
8376
|
/** Reject a gesture promise already waiting on a view that is going away. */
|
|
8194
8377
|
const abortPendingGesture = () => {
|
|
8195
8378
|
const abort = abortGesture;
|
|
@@ -8215,6 +8398,7 @@ async function prepareAndOpen(opts, pending) {
|
|
|
8215
8398
|
if (!attemptIsCurrent(id))
|
|
8216
8399
|
return false;
|
|
8217
8400
|
activeAttempt = 0;
|
|
8401
|
+
abortScopedLogin = null;
|
|
8218
8402
|
return true;
|
|
8219
8403
|
};
|
|
8220
8404
|
/** Take the card back (Back, a lane switch, settling the modal). Deliberately
|
|
@@ -8369,7 +8553,7 @@ async function prepareAndOpen(opts, pending) {
|
|
|
8369
8553
|
loginHint: input.value,
|
|
8370
8554
|
redirectUri: opts.redirectUri,
|
|
8371
8555
|
};
|
|
8372
|
-
|
|
8556
|
+
startHostedLogin(emailOpts)
|
|
8373
8557
|
// A hosted login that RESOLVES minted a real session, so it settles
|
|
8374
8558
|
// the card even if another lane has since taken it - dropping it
|
|
8375
8559
|
// would leave the app signed in behind a widget that says it is not.
|
|
@@ -8419,7 +8603,7 @@ async function prepareAndOpen(opts, pending) {
|
|
|
8419
8603
|
}
|
|
8420
8604
|
setBusy(b, "Opening secure sign-in\u2026");
|
|
8421
8605
|
const socialOpts = { provider: method, redirectUri: opts.redirectUri };
|
|
8422
|
-
|
|
8606
|
+
startHostedLogin(socialOpts)
|
|
8423
8607
|
.then((u) => {
|
|
8424
8608
|
if (u) {
|
|
8425
8609
|
settleAttempt(attempt);
|
|
@@ -10431,7 +10615,7 @@ class PrivyExpoProvider {
|
|
|
10431
10615
|
if (isLegacyTx) {
|
|
10432
10616
|
const legacyTx = transaction;
|
|
10433
10617
|
if (!legacyTx.recentBlockhash) {
|
|
10434
|
-
const rpcUrl = this.getRpcUrl();
|
|
10618
|
+
const rpcUrl = await this.getRpcUrl();
|
|
10435
10619
|
const connection = new Connection(rpcUrl, 'confirmed');
|
|
10436
10620
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash('confirmed');
|
|
10437
10621
|
legacyTx.recentBlockhash = blockhash;
|
|
@@ -10444,7 +10628,7 @@ class PrivyExpoProvider {
|
|
|
10444
10628
|
else {
|
|
10445
10629
|
const versionedTx = transaction;
|
|
10446
10630
|
if (!versionedTx.message.recentBlockhash) {
|
|
10447
|
-
const rpcUrl = this.getRpcUrl();
|
|
10631
|
+
const rpcUrl = await this.getRpcUrl();
|
|
10448
10632
|
const connection = new Connection(rpcUrl, 'confirmed');
|
|
10449
10633
|
const { blockhash } = await connection.getLatestBlockhash('confirmed');
|
|
10450
10634
|
versionedTx.message.recentBlockhash = blockhash;
|
|
@@ -10464,7 +10648,7 @@ class PrivyExpoProvider {
|
|
|
10464
10648
|
await this.ensureReady();
|
|
10465
10649
|
const { Connection, PublicKey } = await import('@solana/web3.js');
|
|
10466
10650
|
const wallet = await this.getWalletOrThrow('submitting this transaction');
|
|
10467
|
-
const rpcUrl = this.getRpcUrl();
|
|
10651
|
+
const rpcUrl = await this.getRpcUrl();
|
|
10468
10652
|
const connection = new Connection(rpcUrl, 'confirmed');
|
|
10469
10653
|
// Ensure blockhash.
|
|
10470
10654
|
// DS3-0414: a Solana signature covers the compiled message (recentBlockhash
|
|
@@ -10491,8 +10675,9 @@ class PrivyExpoProvider {
|
|
|
10491
10675
|
const { signature } = await this.signAndSubmitInternal(transaction, wallet, connection);
|
|
10492
10676
|
return signature;
|
|
10493
10677
|
}
|
|
10494
|
-
async restoreSession() {
|
|
10678
|
+
async restoreSession(beforeCommit) {
|
|
10495
10679
|
const session = await getActiveSessionManager().getSession();
|
|
10680
|
+
beforeCommit === null || beforeCommit === void 0 ? void 0 : beforeCommit();
|
|
10496
10681
|
if (session) {
|
|
10497
10682
|
this.authenticatedAddress = session.address;
|
|
10498
10683
|
return { provider: this, address: session.address };
|
|
@@ -10565,8 +10750,12 @@ class PrivyExpoProvider {
|
|
|
10565
10750
|
const txInfo = await confirmAndCheckTransaction(connection, signature);
|
|
10566
10751
|
return { signature, txInfo };
|
|
10567
10752
|
}
|
|
10568
|
-
|
|
10569
|
-
|
|
10753
|
+
// The constructor rpcUrl wins, then init()'s rpcUrl, then the platform RPC
|
|
10754
|
+
// for init()'s chain.
|
|
10755
|
+
async getRpcUrl() {
|
|
10756
|
+
var _a;
|
|
10757
|
+
const config = await getConfig();
|
|
10758
|
+
return resolveSolanaRpcUrl((_a = this.networkUrl) !== null && _a !== void 0 ? _a : config.rpcUrl, isSupportedSolanaRpcNetwork(config.chain) ? config.chain : null, "Privy Expo Solana transaction");
|
|
10570
10759
|
}
|
|
10571
10760
|
async ensureReady(timeoutMs = 15000) {
|
|
10572
10761
|
if (!this.privyMethods) {
|
|
@@ -11003,4 +11192,4 @@ function init(config = {}) {
|
|
|
11003
11192
|
}
|
|
11004
11193
|
|
|
11005
11194
|
export { onrampStatus as $, getAuthProvider as A, signInAnonymously as B, loginWithPrivy as C, loginWithWallet as D, ensureWalletLoginReady as E, ensureSharedWalletLoginReady as F, preloadWalletLogin as G, loginWithRedirect as H, completeLoginFromRedirect as I, getLoginReturnError as J, loginWithPopup as K, openBoundedWidget as L, ensureSignedIn as M, useAuth as N, useQuery as O, useBuildRun as P, apps as Q, signSolanaMessageViaTurnkey as R, getOrCreateTurnkeyWallet as S, openTurnkeyKeyExport as T, getTurnkeyWalletSessionState as U, getTurnkeyWalletRecoveryUrl as V, WalletConfigError as W, startTurnkeyEmailLogin as X, getIdToken as Y, onramp as Z, onrampQuote as _, signMessageWithTurnkey as a, setPlatform as a0, OffchainAuthProvider as a1, PrivyExpoProvider as a2, requestEip6963Providers as a3, connectBroadcast as a4, connectServiceSession as a5, builds as a6, BuildsApiError as a7, mediaAgentTools as a8, NON_TERMINAL_STATES as a9, TERMINAL_STATES as aa, RUN_STATES as ab, PARK_REASONS as ac, FAILURE_REASONS as ad, BUILD_REVIEW_CAPABILITY_SCHEMA as ae, BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA as af, BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA as ag, signTransactionWithTurnkey as b, signTransactionV1WithTurnkey as c, signAndSubmitTransactionWithTurnkey as d, bs58 as e, defaultInjectedProvider as f, getPlatform as g, hasTurnkeyWallet as h, firstStandardWalletProvider as i, setAuthLoading as j, bufferExports as k, setStoredAuthMethod as l, confirmAndCheckTransaction as m, normalizeSolanaRpcUrl as n, defaultInjectedEvmProvider as o, init as p, getCurrentUser as q, resolveSolanaRpcUrl as r, setCurrentUser as s, transactionHasSignature as t, onAuthStateChanged as u, onAuthLoadingChanged as v, getAuthLoading as w, waitForAuthReady as x, login as y, logout as z };
|
|
11006
|
-
//# sourceMappingURL=index-
|
|
11195
|
+
//# sourceMappingURL=index-CRxls8Qc.mjs.map
|