@bounded-sh/client 0.0.59 → 0.0.60
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/{email-auth-provider-N-dfsNnE.js → email-auth-provider-B5yIZe1l.js} +2 -2
- package/dist/{email-auth-provider-N-dfsNnE.js.map → email-auth-provider-B5yIZe1l.js.map} +1 -1
- package/dist/{email-auth-provider-BSw9FRjg.js → email-auth-provider-BCEdcnRu.js} +2 -2
- package/dist/{email-auth-provider-BSw9FRjg.js.map → email-auth-provider-BCEdcnRu.js.map} +1 -1
- package/dist/{email-auth-provider-deB_ADc5.mjs → email-auth-provider-BF-vvbAt.mjs} +2 -2
- package/dist/{email-auth-provider-deB_ADc5.mjs.map → email-auth-provider-BF-vvbAt.mjs.map} +1 -1
- package/dist/{email-auth-provider-DhAMOILG.mjs → email-auth-provider-nBv7mW9q.mjs} +2 -2
- package/dist/{email-auth-provider-DhAMOILG.mjs.map → email-auth-provider-nBv7mW9q.mjs.map} +1 -1
- package/dist/{guest-auth-provider-BFodq9Rc.js → guest-auth-provider-CZ-CpNhD.js} +2 -2
- package/dist/{guest-auth-provider-BFodq9Rc.js.map → guest-auth-provider-CZ-CpNhD.js.map} +1 -1
- package/dist/{guest-auth-provider-Czl48mOP.js → guest-auth-provider-CrRreOyf.js} +2 -2
- package/dist/{guest-auth-provider-Czl48mOP.js.map → guest-auth-provider-CrRreOyf.js.map} +1 -1
- package/dist/{guest-auth-provider-D9wbogwi.mjs → guest-auth-provider-DFNAHmtY.mjs} +2 -2
- package/dist/{guest-auth-provider-B78Ugfar.mjs.map → guest-auth-provider-DFNAHmtY.mjs.map} +1 -1
- package/dist/{guest-auth-provider-B78Ugfar.mjs → guest-auth-provider-DGvQgIwm.mjs} +2 -2
- package/dist/{guest-auth-provider-D9wbogwi.mjs.map → guest-auth-provider-DGvQgIwm.mjs.map} +1 -1
- package/dist/{index-SHt4VZZV.mjs → index-CQtGkKVd.mjs} +151 -43
- package/dist/index-CQtGkKVd.mjs.map +1 -0
- package/dist/{index-uu8hKP-p.js → index-iu8vB4ye.js} +152 -42
- package/dist/index-iu8vB4ye.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{index.native-D48QQ0-q.js → index.native-CDfx0N6p.js} +151 -41
- package/dist/index.native-CDfx0N6p.js.map +1 -0
- package/dist/{index.native-D-8IAEy-.mjs → index.native-Crfn_NOB.mjs} +150 -42
- package/dist/index.native-Crfn_NOB.mjs.map +1 -0
- package/dist/index.native.d.ts +2 -2
- package/dist/index.native.js +3 -1
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +1 -1
- package/dist/{injected-evm-wallet-provider-CJsLX16m.mjs → injected-evm-wallet-provider-Bi9G3X35.mjs} +2 -2
- package/dist/{injected-evm-wallet-provider-CJsLX16m.mjs.map → injected-evm-wallet-provider-Bi9G3X35.mjs.map} +1 -1
- package/dist/{injected-evm-wallet-provider-HQMOL_mZ.js → injected-evm-wallet-provider-CGa692L1.js} +2 -2
- package/dist/{injected-evm-wallet-provider-HQMOL_mZ.js.map → injected-evm-wallet-provider-CGa692L1.js.map} +1 -1
- package/dist/{injected-evm-wallet-provider-UWvcy-LO.mjs → injected-evm-wallet-provider-D8lYGcM2.mjs} +2 -2
- package/dist/{injected-evm-wallet-provider-UWvcy-LO.mjs.map → injected-evm-wallet-provider-D8lYGcM2.mjs.map} +1 -1
- package/dist/{injected-evm-wallet-provider-CItxws1D.js → injected-evm-wallet-provider-LTWiACl5.js} +2 -2
- package/dist/{injected-evm-wallet-provider-CItxws1D.js.map → injected-evm-wallet-provider-LTWiACl5.js.map} +1 -1
- package/dist/{injected-wallet-provider-CNYAynIB.mjs → injected-wallet-provider-CcyA5JBS.mjs} +2 -2
- package/dist/{injected-wallet-provider-CNYAynIB.mjs.map → injected-wallet-provider-CcyA5JBS.mjs.map} +1 -1
- package/dist/{injected-wallet-provider-CVeZgfEt.js → injected-wallet-provider-DYZFxIdd.js} +2 -2
- package/dist/{injected-wallet-provider-CVeZgfEt.js.map → injected-wallet-provider-DYZFxIdd.js.map} +1 -1
- package/dist/{injected-wallet-provider-CmXqreEE.js → injected-wallet-provider-TPx8Wzvq.js} +2 -2
- package/dist/{injected-wallet-provider-CmXqreEE.js.map → injected-wallet-provider-TPx8Wzvq.js.map} +1 -1
- package/dist/{injected-wallet-provider-BihII94U.mjs → injected-wallet-provider-kx8tcMKM.mjs} +2 -2
- package/dist/{injected-wallet-provider-BihII94U.mjs.map → injected-wallet-provider-kx8tcMKM.mjs.map} +1 -1
- package/dist/onramp.d.ts +51 -9
- package/package.json +2 -2
- package/dist/index-SHt4VZZV.mjs.map +0 -1
- package/dist/index-uu8hKP-p.js.map +0 -1
- package/dist/index.native-D-8IAEy-.mjs.map +0 -1
- package/dist/index.native-D48QQ0-q.js.map +0 -1
|
@@ -4453,7 +4453,7 @@ async function getAuthProvider(config) {
|
|
|
4453
4453
|
// manager as legacy email sessions. Human login should be started
|
|
4454
4454
|
// with loginWithRedirect(); this provider is kept as the restore and
|
|
4455
4455
|
// logout surface for those sessions.
|
|
4456
|
-
currentAuthProvider = new (await import('./email-auth-provider-
|
|
4456
|
+
currentAuthProvider = new (await import('./email-auth-provider-BF-vvbAt.mjs')).EmailAuthProvider();
|
|
4457
4457
|
break;
|
|
4458
4458
|
case "wallet":
|
|
4459
4459
|
case "phantom": {
|
|
@@ -4472,7 +4472,7 @@ async function getAuthProvider(config) {
|
|
|
4472
4472
|
if (!isWalletLoginEnabled(config)) {
|
|
4473
4473
|
throw walletLoginNotEnabledError(authMethod);
|
|
4474
4474
|
}
|
|
4475
|
-
const { InjectedWalletProvider } = await import('./injected-wallet-provider-
|
|
4475
|
+
const { InjectedWalletProvider } = await import('./injected-wallet-provider-CcyA5JBS.mjs');
|
|
4476
4476
|
currentAuthProvider = new InjectedWalletProvider(resolveInjectedWalletConfig(config), rpcUrl, configuredNetwork);
|
|
4477
4477
|
break;
|
|
4478
4478
|
}
|
|
@@ -4485,7 +4485,7 @@ async function getAuthProvider(config) {
|
|
|
4485
4485
|
// Selecting authMethod:'evm-wallet' IS the opt-in — pass evmWalletConfig
|
|
4486
4486
|
// to point at a specific wallet or set chainId/domain.
|
|
4487
4487
|
const evmWalletConfig = ((_a = config.evmWalletConfig) !== null && _a !== void 0 ? _a : {});
|
|
4488
|
-
const { InjectedEvmWalletProvider } = await import('./injected-evm-wallet-provider-
|
|
4488
|
+
const { InjectedEvmWalletProvider } = await import('./injected-evm-wallet-provider-Bi9G3X35.mjs');
|
|
4489
4489
|
currentAuthProvider = new InjectedEvmWalletProvider(evmWalletConfig);
|
|
4490
4490
|
break;
|
|
4491
4491
|
}
|
|
@@ -4513,7 +4513,7 @@ async function getAuthProvider(config) {
|
|
|
4513
4513
|
break;
|
|
4514
4514
|
case "guest":
|
|
4515
4515
|
// Anonymous auth: a device-local ed25519 keypair signs the challenge.
|
|
4516
|
-
currentAuthProvider = new (await import('./guest-auth-provider-
|
|
4516
|
+
currentAuthProvider = new (await import('./guest-auth-provider-DFNAHmtY.mjs')).GuestAuthProvider();
|
|
4517
4517
|
break;
|
|
4518
4518
|
}
|
|
4519
4519
|
if (!currentAuthProvider) {
|
|
@@ -4569,7 +4569,7 @@ async function signInAnonymously() {
|
|
|
4569
4569
|
// Lazy-load the guest provider so its ed25519/web3 dependencies stay out of
|
|
4570
4570
|
// the main bundle for data-only apps. Specifier is a static string literal
|
|
4571
4571
|
// so bundle-splitting can see it.
|
|
4572
|
-
const provider = new (await import('./guest-auth-provider-
|
|
4572
|
+
const provider = new (await import('./guest-auth-provider-DFNAHmtY.mjs')).GuestAuthProvider();
|
|
4573
4573
|
setAuthLoading(true); // reflect "signing in…" while the guest keypair session is minted
|
|
4574
4574
|
const commit = (user) => {
|
|
4575
4575
|
// No await/interleaving inside this block: provider/method/config/marker
|
|
@@ -4754,7 +4754,7 @@ function getCurrentAuthMethod() {
|
|
|
4754
4754
|
// allowlist here: on a trusted origin we end the issuer session with a
|
|
4755
4755
|
// top-level bounce; anywhere else (custom domains, http dev) we keep the
|
|
4756
4756
|
// local-only logout instead of stranding the user on the issuer origin.
|
|
4757
|
-
function issuerLogoutBounceUrl(issuerBase) {
|
|
4757
|
+
function issuerLogoutBounceUrl(issuerBase, idTokenHint) {
|
|
4758
4758
|
if (typeof window === 'undefined' || typeof document === 'undefined')
|
|
4759
4759
|
return null; // RN/Node: no shared cookie jar to clear this way
|
|
4760
4760
|
try {
|
|
@@ -4777,12 +4777,27 @@ function issuerLogoutBounceUrl(issuerBase) {
|
|
|
4777
4777
|
if (!trusted)
|
|
4778
4778
|
return null;
|
|
4779
4779
|
const base = issuerBase.replace(/\/$/, '');
|
|
4780
|
-
|
|
4780
|
+
// #228: send the id_token_hint so the issuer can bind the post-logout redirect to this
|
|
4781
|
+
// session + app + registered origin. Without it the issuer safely falls back to its own
|
|
4782
|
+
// origin (it no longer trusts a bare suffix match), so the return-to-app bounce is a no-op.
|
|
4783
|
+
const hint = idTokenHint ? `&id_token_hint=${encodeURIComponent(idTokenHint)}` : '';
|
|
4784
|
+
return `${base}/logout?redirect_uri=${encodeURIComponent(here.href)}${hint}`;
|
|
4781
4785
|
}
|
|
4782
4786
|
catch (_b) {
|
|
4783
4787
|
return null;
|
|
4784
4788
|
}
|
|
4785
4789
|
}
|
|
4790
|
+
// #228 helper, deliberately OUTSIDE logout(): the logout body is source-guarded
|
|
4791
|
+
// against any `catch` so a revokeSession failure can never be swallowed, and a
|
|
4792
|
+
// missing id token is the one benign absence worth tolerating here.
|
|
4793
|
+
function idTokenHintOrNull(sm) {
|
|
4794
|
+
try {
|
|
4795
|
+
return sm.getIdToken();
|
|
4796
|
+
}
|
|
4797
|
+
catch (_a) {
|
|
4798
|
+
return null; /* no id token to hint with */
|
|
4799
|
+
}
|
|
4800
|
+
}
|
|
4786
4801
|
async function logout$1(options) {
|
|
4787
4802
|
// Re-initialize the provider if it was cleared by a prior logout — the exact mirror
|
|
4788
4803
|
// of login()'s self-heal above. A hosted popup/redirect login (loginWithPopup /
|
|
@@ -4807,6 +4822,9 @@ async function logout$1(options) {
|
|
|
4807
4822
|
const sm = getActiveSessionManager();
|
|
4808
4823
|
const refreshToken = sm.getRefreshToken();
|
|
4809
4824
|
const sessionIssuer = sm.getIssuer();
|
|
4825
|
+
// #228: capture the id token NOW, before currentAuthProvider.logout() clears the session, so we
|
|
4826
|
+
// can hand it to the issuer /logout as an id_token_hint (which binds the post-logout redirect).
|
|
4827
|
+
const idTokenHint = idTokenHintOrNull(sm);
|
|
4810
4828
|
if (refreshToken)
|
|
4811
4829
|
await revokeSession(refreshToken, sessionIssuer !== null && sessionIssuer !== void 0 ? sessionIssuer : undefined);
|
|
4812
4830
|
// Hosted sessions ('email' covers the whole hosted surface: email OTP +
|
|
@@ -4827,7 +4845,7 @@ async function logout$1(options) {
|
|
|
4827
4845
|
const issuerBase = sessionIssuer
|
|
4828
4846
|
|| (await getConfig()).humanAuthApiUrl
|
|
4829
4847
|
|| 'https://auth.bounded.sh';
|
|
4830
|
-
const bounce = issuerLogoutBounceUrl(issuerBase);
|
|
4848
|
+
const bounce = issuerLogoutBounceUrl(issuerBase, idTokenHint);
|
|
4831
4849
|
// Local state is already cleared, so even if the navigation is stopped
|
|
4832
4850
|
// (tab close, extension) the app-side logout has fully happened.
|
|
4833
4851
|
if (bounce)
|
|
@@ -5810,30 +5828,117 @@ async function deserializeTransaction(tx) {
|
|
|
5810
5828
|
// session is bound server-side to the caller's verified Bounded JWT, and the
|
|
5811
5829
|
// destination defaults to that user's embedded wallet.
|
|
5812
5830
|
//
|
|
5831
|
+
// Amount semantics:
|
|
5832
|
+
// amountUsd - exact fiat in; the fee/output breakdown comes back as `quote`.
|
|
5833
|
+
// minAmountOut - a FLOOR on crypto received. The platform quotes Coinbase's
|
|
5834
|
+
// worst-fee payment method (card) and pads by `slippagePad` (default 1%),
|
|
5835
|
+
// so cheaper methods overshoot the floor rather than undershooting it. The
|
|
5836
|
+
// floor holds unless the market moves more than the pad while the user sits
|
|
5837
|
+
// on the checkout screen - which is why completion is VERIFIED: after the
|
|
5838
|
+
// popup closes we poll the platform's status leg and resolve with the
|
|
5839
|
+
// actual filled amount when Coinbase reports it.
|
|
5840
|
+
//
|
|
5813
5841
|
// Works on Bounded-served origins (<app>.bounded.page / custom domains). On a
|
|
5814
5842
|
// local dev origin the session endpoint does not exist; we fail with a clear
|
|
5815
5843
|
// error rather than guessing a host.
|
|
5816
5844
|
function hasDOM() {
|
|
5817
5845
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
5818
5846
|
}
|
|
5847
|
+
async function authedFetch(path, init) {
|
|
5848
|
+
const idToken = await getIdToken();
|
|
5849
|
+
if (!idToken)
|
|
5850
|
+
throw new Error('onramp: no active session - call login() first');
|
|
5851
|
+
return fetch(`${window.location.origin}${path}`, Object.assign(Object.assign({}, init), { headers: Object.assign(Object.assign({}, init === null || init === void 0 ? void 0 : init.headers), { Authorization: `Bearer ${idToken}` }) }));
|
|
5852
|
+
}
|
|
5853
|
+
async function readError(res) {
|
|
5854
|
+
var _a;
|
|
5855
|
+
try {
|
|
5856
|
+
return (_a = (await res.json()).error) !== null && _a !== void 0 ? _a : '';
|
|
5857
|
+
}
|
|
5858
|
+
catch (_b) {
|
|
5859
|
+
return '';
|
|
5860
|
+
}
|
|
5861
|
+
}
|
|
5862
|
+
function sessionBody(options, extra) {
|
|
5863
|
+
return JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (options.asset ? { asset: options.asset } : {})), (options.address ? { address: options.address } : {})), (options.amountUsd !== undefined ? { amountUsd: options.amountUsd } : {})), (options.minAmountOut !== undefined ? { minAmountOut: options.minAmountOut } : {})), (options.slippagePad !== undefined ? { slippagePad: options.slippagePad } : {})), extra));
|
|
5864
|
+
}
|
|
5865
|
+
function resolveAddress(options) {
|
|
5866
|
+
var _a, _b;
|
|
5867
|
+
const user = getCurrentUser();
|
|
5868
|
+
const address = (_b = (_a = options.address) !== null && _a !== void 0 ? _a : user === null || user === void 0 ? void 0 : user.address) !== null && _b !== void 0 ? _b : undefined;
|
|
5869
|
+
if (!address) {
|
|
5870
|
+
throw new Error(user
|
|
5871
|
+
? 'onramp: the signed-in account has no wallet address - pass { address } explicitly'
|
|
5872
|
+
: 'onramp: no signed-in user - call login() first or pass { address }');
|
|
5873
|
+
}
|
|
5874
|
+
return address;
|
|
5875
|
+
}
|
|
5876
|
+
/**
|
|
5877
|
+
* Preview a quote (fees + exact/floor output) WITHOUT opening any window or
|
|
5878
|
+
* consuming a session. Show this to the user, then call onramp() to check out.
|
|
5879
|
+
*/
|
|
5880
|
+
async function onrampQuote(options = {}) {
|
|
5881
|
+
if (!hasDOM())
|
|
5882
|
+
throw new Error('onrampQuote is web-only');
|
|
5883
|
+
resolveAddress(options);
|
|
5884
|
+
const res = await authedFetch('/__bounded/onramp/session', {
|
|
5885
|
+
method: 'POST',
|
|
5886
|
+
headers: { 'content-type': 'application/json' },
|
|
5887
|
+
body: sessionBody(options, { quoteOnly: true }),
|
|
5888
|
+
});
|
|
5889
|
+
if (!res.ok)
|
|
5890
|
+
throw new Error(`onrampQuote: failed (${res.status}${await readError(res).then((e) => (e ? `: ${e}` : ''))})`);
|
|
5891
|
+
return (await res.json());
|
|
5892
|
+
}
|
|
5893
|
+
/** The signed-in user's recent onramp transactions (newest first). */
|
|
5894
|
+
async function onrampStatus(sinceMs) {
|
|
5895
|
+
if (!hasDOM())
|
|
5896
|
+
throw new Error('onrampStatus is web-only');
|
|
5897
|
+
const res = await authedFetch(`/__bounded/onramp/status${sinceMs ? `?since=${Math.floor(sinceMs)}` : ''}`);
|
|
5898
|
+
if (!res.ok)
|
|
5899
|
+
throw new Error(`onrampStatus: failed (${res.status})`);
|
|
5900
|
+
return (await res.json()).transactions;
|
|
5901
|
+
}
|
|
5902
|
+
function isSuccess(t) {
|
|
5903
|
+
return /SUCCESS|COMPLETED/i.test(t.status);
|
|
5904
|
+
}
|
|
5905
|
+
function isPending(t) {
|
|
5906
|
+
return /PROGRESS|PENDING|CREATED/i.test(t.status);
|
|
5907
|
+
}
|
|
5908
|
+
async function verifyCompletion(openedAt, asset, timeoutMs) {
|
|
5909
|
+
const deadline = Date.now() + timeoutMs;
|
|
5910
|
+
// 60s of clock-skew slack on `since`: Coinbase stamps server-side.
|
|
5911
|
+
const since = openedAt - 60000;
|
|
5912
|
+
for (;;) {
|
|
5913
|
+
let sawPending = false;
|
|
5914
|
+
try {
|
|
5915
|
+
const txs = await onrampStatus(since);
|
|
5916
|
+
const done = txs.find((t) => isSuccess(t) && (t.asset === null || t.asset === asset));
|
|
5917
|
+
if (done)
|
|
5918
|
+
return done;
|
|
5919
|
+
sawPending = txs.some(isPending);
|
|
5920
|
+
}
|
|
5921
|
+
catch ( /* transient - keep polling until the deadline */_a) { /* transient - keep polling until the deadline */ }
|
|
5922
|
+
// No completed fill and nothing in flight: one grace poll cycle still
|
|
5923
|
+
// runs (Coinbase's record can lag the redirect), but don't burn the
|
|
5924
|
+
// full window when the user plainly abandoned checkout.
|
|
5925
|
+
if (Date.now() >= deadline)
|
|
5926
|
+
return null;
|
|
5927
|
+
if (!sawPending && Date.now() >= openedAt + 12000 && Date.now() - openedAt > timeoutMs / 2)
|
|
5928
|
+
return null;
|
|
5929
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
5930
|
+
}
|
|
5931
|
+
}
|
|
5819
5932
|
/**
|
|
5820
|
-
* Open Coinbase Onramp for the signed-in user. Resolves
|
|
5933
|
+
* Open Coinbase Onramp for the signed-in user. Resolves after the window
|
|
5934
|
+
* closes, with completion VERIFIED against Coinbase when possible.
|
|
5821
5935
|
* Call from a click handler - popup blockers require user activation.
|
|
5822
5936
|
*/
|
|
5823
5937
|
async function onramp(options = {}) {
|
|
5824
|
-
var _a
|
|
5938
|
+
var _a;
|
|
5825
5939
|
if (!hasDOM())
|
|
5826
5940
|
throw new Error('onramp() is web-only');
|
|
5827
|
-
|
|
5828
|
-
const address = (_b = (_a = options.address) !== null && _a !== void 0 ? _a : user === null || user === void 0 ? void 0 : user.address) !== null && _b !== void 0 ? _b : undefined;
|
|
5829
|
-
if (!address) {
|
|
5830
|
-
throw new Error(user
|
|
5831
|
-
? 'onramp(): the signed-in account has no wallet address - pass { address } explicitly'
|
|
5832
|
-
: 'onramp(): no signed-in user - call login() first or pass { address }');
|
|
5833
|
-
}
|
|
5834
|
-
const idToken = await getIdToken();
|
|
5835
|
-
if (!idToken)
|
|
5836
|
-
throw new Error('onramp(): no active session - call login() first');
|
|
5941
|
+
resolveAddress(options);
|
|
5837
5942
|
// Open the window synchronously so the click's user-activation window is not
|
|
5838
5943
|
// consumed by the fetch below (same hard-won pattern as loginWithPopup).
|
|
5839
5944
|
let popup = null;
|
|
@@ -5846,21 +5951,17 @@ async function onramp(options = {}) {
|
|
|
5846
5951
|
}
|
|
5847
5952
|
let session;
|
|
5848
5953
|
try {
|
|
5849
|
-
const res = await
|
|
5954
|
+
const res = await authedFetch('/__bounded/onramp/session', {
|
|
5850
5955
|
method: 'POST',
|
|
5851
|
-
headers: {
|
|
5852
|
-
body:
|
|
5956
|
+
headers: { 'content-type': 'application/json' },
|
|
5957
|
+
body: sessionBody(options),
|
|
5853
5958
|
});
|
|
5854
5959
|
if (!res.ok) {
|
|
5855
|
-
|
|
5856
|
-
try {
|
|
5857
|
-
detail = (_c = (await res.json()).error) !== null && _c !== void 0 ? _c : '';
|
|
5858
|
-
}
|
|
5859
|
-
catch ( /* keep status only */_d) { /* keep status only */ }
|
|
5960
|
+
const detail = await readError(res);
|
|
5860
5961
|
if (res.status === 404) {
|
|
5861
|
-
throw new Error('onramp
|
|
5962
|
+
throw new Error('onramp: session endpoint not found - onramp works on Bounded-served origins (your deployed app URL), not local dev servers');
|
|
5862
5963
|
}
|
|
5863
|
-
throw new Error(`onramp
|
|
5964
|
+
throw new Error(`onramp: session mint failed (${res.status}${detail ? `: ${detail}` : ''})`);
|
|
5864
5965
|
}
|
|
5865
5966
|
session = (await res.json());
|
|
5866
5967
|
}
|
|
@@ -5868,40 +5969,47 @@ async function onramp(options = {}) {
|
|
|
5868
5969
|
try {
|
|
5869
5970
|
popup === null || popup === void 0 ? void 0 : popup.close();
|
|
5870
5971
|
}
|
|
5871
|
-
catch ( /* ignore */
|
|
5972
|
+
catch ( /* ignore */_b) { /* ignore */ }
|
|
5872
5973
|
throw error;
|
|
5873
5974
|
}
|
|
5975
|
+
const openedAt = Date.now();
|
|
5976
|
+
const base = Object.assign({ address: session.address, asset: session.asset }, (session.quote ? { quote: session.quote } : {}));
|
|
5874
5977
|
if (popup) {
|
|
5875
5978
|
try {
|
|
5876
5979
|
popup.location.replace(session.url);
|
|
5877
5980
|
}
|
|
5878
|
-
catch (
|
|
5981
|
+
catch (_c) {
|
|
5879
5982
|
try {
|
|
5880
5983
|
popup.location.href = session.url;
|
|
5881
5984
|
}
|
|
5882
|
-
catch (
|
|
5985
|
+
catch (_d) {
|
|
5883
5986
|
try {
|
|
5884
5987
|
popup.close();
|
|
5885
5988
|
}
|
|
5886
|
-
catch ( /* ignore */
|
|
5887
|
-
throw new Error('onramp
|
|
5989
|
+
catch ( /* ignore */_e) { /* ignore */ }
|
|
5990
|
+
throw new Error('onramp: popup failed to navigate - retry with { newTab: true }');
|
|
5888
5991
|
}
|
|
5889
5992
|
}
|
|
5890
|
-
|
|
5993
|
+
await new Promise((resolve) => {
|
|
5891
5994
|
const timer = setInterval(() => {
|
|
5892
5995
|
if (popup.closed) {
|
|
5893
5996
|
clearInterval(timer);
|
|
5894
|
-
resolve(
|
|
5997
|
+
resolve();
|
|
5895
5998
|
}
|
|
5896
5999
|
}, 500);
|
|
5897
6000
|
});
|
|
6001
|
+
const fill = await verifyCompletion(openedAt, session.asset, (_a = options.completionTimeoutMs) !== null && _a !== void 0 ? _a : 24000);
|
|
6002
|
+
if (fill) {
|
|
6003
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, base), { status: 'completed' }), (fill.amountOut !== null ? { actualOut: fill.amountOut } : {})), (fill.txHash ? { txHash: fill.txHash } : {}));
|
|
6004
|
+
}
|
|
6005
|
+
return Object.assign(Object.assign({}, base), { status: 'closed' });
|
|
5898
6006
|
}
|
|
5899
6007
|
// New-tab path (popup was blocked or explicitly requested): cross-origin tab
|
|
5900
|
-
// close is not observable, so resolve immediately.
|
|
6008
|
+
// close is not observable, so resolve immediately; verify via onrampStatus().
|
|
5901
6009
|
const tab = window.open(session.url, '_blank');
|
|
5902
6010
|
if (!tab)
|
|
5903
|
-
throw new Error('onramp
|
|
5904
|
-
return { status: 'opened'
|
|
6011
|
+
throw new Error('onramp: window.open was blocked - call onramp() from a click handler');
|
|
6012
|
+
return Object.assign(Object.assign({}, base), { status: 'opened' });
|
|
5905
6013
|
}
|
|
5906
6014
|
|
|
5907
6015
|
/**
|
|
@@ -6287,5 +6395,5 @@ class PrivyExpoProvider {
|
|
|
6287
6395
|
}
|
|
6288
6396
|
}
|
|
6289
6397
|
|
|
6290
|
-
export { useAuth as A, useQuery as B, useBuildRun as C, apps as D, EMBEDDED_WALLET_UNSUPPORTED as E, deserializeTransaction as F, getIdToken as G, onramp as H,
|
|
6291
|
-
//# sourceMappingURL=index.native-
|
|
6398
|
+
export { useAuth as A, useQuery as B, useBuildRun as C, apps as D, EMBEDDED_WALLET_UNSUPPORTED as E, deserializeTransaction as F, getIdToken as G, onramp as H, onrampQuote as I, onrampStatus as J, setPlatform as K, builds as L, BuildsApiError as M, NON_TERMINAL_STATES as N, OffchainAuthProvider as O, PrivyExpoProvider as P, PARK_REASONS as Q, RUN_STATES as R, FAILURE_REASONS as S, TERMINAL_STATES as T, BUILD_REVIEW_CAPABILITY_SCHEMA as U, BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA as V, BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA as W, hasEmbeddedEvmWallet as a, embeddedSignAndSubmit as b, setAuthLoading as c, bufferExports as d, embeddedRunEvmTransaction as e, bs58 as f, getPlatform as g, hasEmbeddedWallet as h, confirmAndCheckTransaction as i, init as j, getCurrentUser as k, onAuthLoadingChanged as l, getAuthLoading as m, normalizeSolanaRpcUrl as n, onAuthStateChanged as o, login as p, logout as q, resolveSolanaRpcUrl as r, setCurrentUser as s, getAuthProvider as t, signInAnonymously as u, loginWithPrivy as v, loginWithRedirect as w, completeLoginFromRedirect as x, loginWithPopup as y, completeLoginInPopup as z };
|
|
6399
|
+
//# sourceMappingURL=index.native-Crfn_NOB.mjs.map
|