@bounded-sh/client 0.0.117-sync.0 → 0.0.117

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.
Files changed (28) hide show
  1. package/dist/connections.d.ts +40 -0
  2. package/dist/{email-auth-provider-BFOw9iI9.js → email-auth-provider-BCWTczE2.js} +2 -2
  3. package/dist/{email-auth-provider-BFOw9iI9.js.map → email-auth-provider-BCWTczE2.js.map} +1 -1
  4. package/dist/{email-auth-provider-CmbRj-_I.mjs → email-auth-provider-CMfwB-Uj.mjs} +2 -2
  5. package/dist/{email-auth-provider-CmbRj-_I.mjs.map → email-auth-provider-CMfwB-Uj.mjs.map} +1 -1
  6. package/dist/{guest-auth-provider-Bvoaq-zC.mjs → guest-auth-provider-DH4iA0oS.mjs} +2 -2
  7. package/dist/{guest-auth-provider-Bvoaq-zC.mjs.map → guest-auth-provider-DH4iA0oS.mjs.map} +1 -1
  8. package/dist/{guest-auth-provider-DJD3zkBU.js → guest-auth-provider-DkX8cQqr.js} +2 -2
  9. package/dist/{guest-auth-provider-DJD3zkBU.js.map → guest-auth-provider-DkX8cQqr.js.map} +1 -1
  10. package/dist/{index-C2xAP67N.js → index-DrVV40Si.js} +136 -8
  11. package/dist/index-DrVV40Si.js.map +1 -0
  12. package/dist/{index-BmBLsYn2.mjs → index-Sx-Caknc.mjs} +132 -9
  13. package/dist/index-Sx-Caknc.mjs.map +1 -0
  14. package/dist/index.d.ts +2 -0
  15. package/dist/index.js +6 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +1 -1
  18. package/dist/{injected-evm-wallet-provider-B2xteR2I.mjs → injected-evm-wallet-provider-BCZQuyPF.mjs} +2 -2
  19. package/dist/{injected-evm-wallet-provider-B2xteR2I.mjs.map → injected-evm-wallet-provider-BCZQuyPF.mjs.map} +1 -1
  20. package/dist/{injected-evm-wallet-provider-CL_FBjLe.js → injected-evm-wallet-provider-CVMhv4xf.js} +2 -2
  21. package/dist/{injected-evm-wallet-provider-CL_FBjLe.js.map → injected-evm-wallet-provider-CVMhv4xf.js.map} +1 -1
  22. package/dist/{injected-wallet-provider-Bc_xtyRd.js → injected-wallet-provider-BroBvwi6.js} +2 -2
  23. package/dist/{injected-wallet-provider-Bc_xtyRd.js.map → injected-wallet-provider-BroBvwi6.js.map} +1 -1
  24. package/dist/{injected-wallet-provider-DwozZ926.mjs → injected-wallet-provider-ezYLhye8.mjs} +2 -2
  25. package/dist/{injected-wallet-provider-DwozZ926.mjs.map → injected-wallet-provider-ezYLhye8.mjs.map} +1 -1
  26. package/package.json +2 -2
  27. package/dist/index-BmBLsYn2.mjs.map +0 -1
  28. package/dist/index-C2xAP67N.js.map +0 -1
@@ -6475,7 +6475,7 @@ async function getAuthProvider(config, fromStorage = false) {
6475
6475
  // manager as legacy email sessions. Human login should be started
6476
6476
  // with loginWithRedirect(); this provider is kept as the restore and
6477
6477
  // logout surface for those sessions.
6478
- currentAuthProvider = new (await import('./email-auth-provider-CmbRj-_I.mjs')).EmailAuthProvider();
6478
+ currentAuthProvider = new (await import('./email-auth-provider-CMfwB-Uj.mjs')).EmailAuthProvider();
6479
6479
  break;
6480
6480
  case "phantom": {
6481
6481
  // First-class Solana WALLET LOGIN (the poof/TaroBase-style "connect
@@ -6517,7 +6517,7 @@ async function getAuthProvider(config, fromStorage = false) {
6517
6517
  // (bounded-login-widget.ts), so registration never counts as
6518
6518
  // evidence the user has a wallet.
6519
6519
  await ensureSolanaMobileWalletRegistered(config, configuredNetwork);
6520
- const { InjectedWalletProvider } = await import('./injected-wallet-provider-DwozZ926.mjs');
6520
+ const { InjectedWalletProvider } = await import('./injected-wallet-provider-ezYLhye8.mjs');
6521
6521
  currentAuthProvider = new InjectedWalletProvider(resolveInjectedWalletConfig(config), rpcUrl, configuredNetwork);
6522
6522
  break;
6523
6523
  }
@@ -6530,7 +6530,7 @@ async function getAuthProvider(config, fromStorage = false) {
6530
6530
  // Selecting authMethod:'evm-wallet' IS the opt-in — pass evmWalletConfig
6531
6531
  // to point at a specific wallet or set chainId/domain.
6532
6532
  const evmWalletConfig = ((_a = config.evmWalletConfig) !== null && _a !== void 0 ? _a : {});
6533
- const { InjectedEvmWalletProvider } = await import('./injected-evm-wallet-provider-B2xteR2I.mjs');
6533
+ const { InjectedEvmWalletProvider } = await import('./injected-evm-wallet-provider-BCZQuyPF.mjs');
6534
6534
  currentAuthProvider = new InjectedEvmWalletProvider(evmWalletConfig);
6535
6535
  break;
6536
6536
  }
@@ -6555,7 +6555,7 @@ async function getAuthProvider(config, fromStorage = false) {
6555
6555
  break;
6556
6556
  case "guest":
6557
6557
  // Anonymous auth: a device-local ed25519 keypair signs the challenge.
6558
- currentAuthProvider = new (await import('./guest-auth-provider-Bvoaq-zC.mjs')).GuestAuthProvider();
6558
+ currentAuthProvider = new (await import('./guest-auth-provider-DH4iA0oS.mjs')).GuestAuthProvider();
6559
6559
  break;
6560
6560
  }
6561
6561
  if (!currentAuthProvider) {
@@ -6617,7 +6617,7 @@ async function signInAnonymously() {
6617
6617
  // Lazy-load the guest provider so its ed25519/web3 dependencies stay out of
6618
6618
  // the main bundle for data-only apps. Specifier is a static string literal
6619
6619
  // so bundle-splitting can see it.
6620
- const provider = new (await import('./guest-auth-provider-Bvoaq-zC.mjs')).GuestAuthProvider();
6620
+ const provider = new (await import('./guest-auth-provider-DH4iA0oS.mjs')).GuestAuthProvider();
6621
6621
  setAuthLoading(true); // reflect "signing in…" while the guest keypair session is minted
6622
6622
  // adoptSessionProvider awaits only getConfig() (already resolved here) and then
6623
6623
  // runs every write - provider/method/config/marker/user - in one synchronous
@@ -6788,7 +6788,7 @@ function ensureSharedWalletLoginReady() {
6788
6788
  if (!sharedWalletReady) {
6789
6789
  sharedWalletReady = (async () => {
6790
6790
  await getConfig();
6791
- await import('./injected-wallet-provider-DwozZ926.mjs');
6791
+ await import('./injected-wallet-provider-ezYLhye8.mjs');
6792
6792
  })().catch((error) => {
6793
6793
  sharedWalletReady = null;
6794
6794
  throw error;
@@ -6893,7 +6893,7 @@ async function loginWithWallet(options) {
6893
6893
  await ensureSharedWalletLoginReady();
6894
6894
  else
6895
6895
  await ensureWalletLoginReady();
6896
- const { InjectedWalletProvider } = await import('./injected-wallet-provider-DwozZ926.mjs');
6896
+ const { InjectedWalletProvider } = await import('./injected-wallet-provider-ezYLhye8.mjs');
6897
6897
  // Keep the RAW wallet provider: the offchain wrapper forwards only a fixed
6898
6898
  // set of methods, so cleanup below must speak to the provider that actually
6899
6899
  // holds the config rather than to whatever is wrapping it.
@@ -10774,6 +10774,129 @@ async function onramp(options = {}) {
10774
10774
  return Object.assign(Object.assign({}, base), { status: 'closed' });
10775
10775
  }
10776
10776
 
10777
+ // Connections: the signed-in user proves they own an account on another service
10778
+ // (X today) and Bounded records it for THIS app at `__connections__/<userId>`.
10779
+ // Policy rules read it, e.g. `get(/__connections__/@user.id).xHandle`; only the
10780
+ // platform can write it, and only after the provider's own consent screen.
10781
+ //
10782
+ // await connect('x') // leaves the page for X's consent screen
10783
+ // const done = await completeConnection() // on the page X sent the user back to
10784
+ // const { x } = await getConnections() // { id, handle, imageUrl, linkedAt } | null
10785
+ // await disconnect('x')
10786
+ //
10787
+ // Only identity is kept: the provider token is discarded after one profile read.
10788
+ // The return page must be on an origin that serves this app (its bounded.page or
10789
+ // custom domain, or an origin the owner registered, such as localhost).
10790
+ /** `code` is the platform's error code, e.g. `cancelled`, `x_link_expired`, `connection_return_origin_not_allowed`. */
10791
+ class ConnectionError extends Error {
10792
+ constructor(code) {
10793
+ super(`Connection failed: ${code}`);
10794
+ this.code = code;
10795
+ this.name = 'ConnectionError';
10796
+ }
10797
+ }
10798
+ const RETURN_PARAMS = ['x_link', 'x_link_error'];
10799
+ async function request(path, init) {
10800
+ var _a;
10801
+ const base = (_a = (await getConfig()).devApiUrl) === null || _a === void 0 ? void 0 : _a.replace(/\/$/, '');
10802
+ if (!base)
10803
+ throw new ConnectionError('connection_unavailable');
10804
+ const generation = await getSessionGeneration(false);
10805
+ let token = await getFreshAuthToken(false);
10806
+ if (!token)
10807
+ throw new ConnectionError('connection_sign_in_required');
10808
+ const send = (bearer) => fetch(`${base}${path}`, Object.assign({ method: init.method, headers: Object.assign({ Authorization: `Bearer ${bearer}` }, (init.body === undefined ? {} : { 'Content-Type': 'application/json' })) }, (init.body === undefined ? {} : { body: JSON.stringify(init.body) })));
10809
+ let response = await send(token);
10810
+ if (response.status === 401) {
10811
+ // Retry once with a refreshed token, never under a different login.
10812
+ token = await getFreshAuthToken(false, { force: true });
10813
+ if (!token || await getSessionGeneration(false) !== generation)
10814
+ throw new ConnectionError('connection_sign_in_required');
10815
+ response = await send(token);
10816
+ }
10817
+ const data = await response.json().catch(() => null);
10818
+ if (!response.ok || (data === null || data === void 0 ? void 0 : data.ok) !== true) {
10819
+ throw new ConnectionError(typeof (data === null || data === void 0 ? void 0 : data.error) === 'string' ? data.error : 'connection_unavailable');
10820
+ }
10821
+ return data;
10822
+ }
10823
+ function parseConnection(raw) {
10824
+ if (!raw || typeof raw !== 'object')
10825
+ return null;
10826
+ const value = raw;
10827
+ if (typeof value.id !== 'string' || typeof value.handle !== 'string' || !Number.isSafeInteger(value.linkedAt))
10828
+ return null;
10829
+ return {
10830
+ id: value.id,
10831
+ handle: value.handle,
10832
+ imageUrl: typeof value.imageUrl === 'string' ? value.imageUrl : null,
10833
+ linkedAt: value.linkedAt,
10834
+ };
10835
+ }
10836
+ function assertProvider(provider) {
10837
+ if (provider !== 'x')
10838
+ throw new ConnectionError('connection_provider_unsupported');
10839
+ }
10840
+ /** The signed-in user's linked accounts for this app. */
10841
+ async function getConnections() {
10842
+ var _a;
10843
+ const data = await request('/connections', { method: 'GET' });
10844
+ const connections = ((_a = data.connections) !== null && _a !== void 0 ? _a : {});
10845
+ return { x: parseConnection(connections.x) };
10846
+ }
10847
+ /**
10848
+ * Send the user to the provider's consent screen. They come back to `returnUrl`
10849
+ * (default: this page), where `completeConnection()` finishes the link.
10850
+ */
10851
+ async function connect(provider, options = {}) {
10852
+ var _a;
10853
+ assertProvider(provider);
10854
+ if (typeof window === 'undefined')
10855
+ throw new ConnectionError('connection_requires_browser');
10856
+ const returnUrl = new URL((_a = options.returnUrl) !== null && _a !== void 0 ? _a : window.location.href, window.location.href);
10857
+ for (const key of RETURN_PARAMS)
10858
+ returnUrl.searchParams.delete(key);
10859
+ const data = await request(`/connections/${provider}/start`, { method: 'POST', body: { returnUrl: returnUrl.href } });
10860
+ const target = typeof data.authorizationUrl === 'string' ? new URL(data.authorizationUrl) : null;
10861
+ if (!target || target.origin !== 'https://x.com')
10862
+ throw new ConnectionError('connection_unavailable');
10863
+ window.location.assign(target.href);
10864
+ }
10865
+ /**
10866
+ * Finish a link on the page the provider returned to. Returns null when this page is
10867
+ * not a connection return; throws ConnectionError when the user cancelled or it failed.
10868
+ * Call it once the user is signed in. The return parameters leave the address bar on
10869
+ * success or cancellation; after another failure they stay, so calling again retries.
10870
+ */
10871
+ async function completeConnection() {
10872
+ if (typeof window === 'undefined')
10873
+ return null;
10874
+ const url = new URL(window.location.href);
10875
+ const token = url.searchParams.get('x_link');
10876
+ const error = url.searchParams.get('x_link_error');
10877
+ if (token === null && error === null)
10878
+ return null;
10879
+ const clear = () => {
10880
+ for (const key of RETURN_PARAMS)
10881
+ url.searchParams.delete(key);
10882
+ window.history.replaceState(window.history.state, '', url.href);
10883
+ };
10884
+ if (error !== null || !token) {
10885
+ clear();
10886
+ throw new ConnectionError(error || 'failed');
10887
+ }
10888
+ // Keep the return token in the address bar until the platform accepts it, so a
10889
+ // sign-in still loading or a transient failure can retry by calling this again.
10890
+ const data = await request('/connections/x/complete', { method: 'POST', body: { state: token } });
10891
+ clear();
10892
+ return { provider: 'x', connection: parseConnection(data.connection) };
10893
+ }
10894
+ /** Remove the user's linked account for this app. */
10895
+ async function disconnect(provider) {
10896
+ assertProvider(provider);
10897
+ await request(`/connections/${provider}`, { method: 'DELETE' });
10898
+ }
10899
+
10777
10900
  // venue-escrow.ts - fund and dispute a venue escrow from inside an OpenApps app (VENUE-GRANT-DESIGN.md).
10778
10901
  //
10779
10902
  // An OpenApps app's escrow lives in its venue (`agentescrows/<rootAppId>/e/<escrowId>`), and this
@@ -12128,5 +12251,5 @@ function init(config = {}) {
12128
12251
  return init$1(resolved);
12129
12252
  }
12130
12253
 
12131
- export { onramp as $, logout as A, getAuthProvider as B, signInAnonymously as C, loginWithPrivy as D, loginWithWallet as E, ensureWalletLoginReady as F, ensureSharedWalletLoginReady as G, preloadWalletLogin as H, loginWithRedirect as I, completeLoginFromRedirect as J, getLoginReturnError as K, loginWithPopup as L, openBoundedWidget as M, ensureSignedIn as N, useAuth as O, useQuery as P, useBuildRun as Q, apps as R, SELECTED_WALLET_UNAVAILABLE_ERR as S, signSolanaMessageViaTurnkey as T, getOrCreateTurnkeyWallet as U, openTurnkeyKeyExport as V, WalletConfigError as W, getTurnkeyWalletSessionState as X, getTurnkeyWalletRecoveryUrl as Y, startTurnkeyEmailLogin as Z, getIdToken as _, signMessageWithTurnkey as a, onrampQuote as a0, onrampStatus as a1, fundVenueEscrow as a2, disputeVenueEscrow as a3, getVenueEscrow as a4, VenueEscrowError as a5, setPlatform as a6, OffchainAuthProvider as a7, PrivyExpoProvider as a8, requestEip6963Providers as a9, connectBroadcast as aa, connectServiceSession as ab, builds as ac, BuildsApiError as ad, mediaAgentTools as ae, NON_TERMINAL_STATES as af, TERMINAL_STATES as ag, RUN_STATES as ah, PARK_REASONS as ai, FAILURE_REASONS as aj, BUILD_REVIEW_CAPABILITY_SCHEMA as ak, BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA as al, BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA as am, 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, supportsWalletSignIn as k, bufferExports as l, setStoredAuthMethod as m, normalizeSolanaRpcUrl as n, confirmAndCheckTransaction as o, defaultInjectedEvmProvider as p, init as q, resolveSolanaRpcUrl as r, setCurrentUser as s, transactionHasSignature as t, getCurrentUser as u, onAuthStateChanged as v, onAuthLoadingChanged as w, getAuthLoading as x, waitForAuthReady as y, login as z };
12132
- //# sourceMappingURL=index-BmBLsYn2.mjs.map
12254
+ export { onramp as $, logout as A, getAuthProvider as B, signInAnonymously as C, loginWithPrivy as D, loginWithWallet as E, ensureWalletLoginReady as F, ensureSharedWalletLoginReady as G, preloadWalletLogin as H, loginWithRedirect as I, completeLoginFromRedirect as J, getLoginReturnError as K, loginWithPopup as L, openBoundedWidget as M, ensureSignedIn as N, useAuth as O, useQuery as P, useBuildRun as Q, apps as R, SELECTED_WALLET_UNAVAILABLE_ERR as S, signSolanaMessageViaTurnkey as T, getOrCreateTurnkeyWallet as U, openTurnkeyKeyExport as V, WalletConfigError as W, getTurnkeyWalletSessionState as X, getTurnkeyWalletRecoveryUrl as Y, startTurnkeyEmailLogin as Z, getIdToken as _, signMessageWithTurnkey as a, onrampQuote as a0, onrampStatus as a1, connect as a2, completeConnection as a3, getConnections as a4, disconnect as a5, ConnectionError as a6, fundVenueEscrow as a7, disputeVenueEscrow as a8, getVenueEscrow as a9, VenueEscrowError as aa, setPlatform as ab, OffchainAuthProvider as ac, PrivyExpoProvider as ad, requestEip6963Providers as ae, connectBroadcast as af, connectServiceSession as ag, builds as ah, BuildsApiError as ai, mediaAgentTools as aj, NON_TERMINAL_STATES as ak, TERMINAL_STATES as al, RUN_STATES as am, PARK_REASONS as an, FAILURE_REASONS as ao, BUILD_REVIEW_CAPABILITY_SCHEMA as ap, BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA as aq, BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA as ar, 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, supportsWalletSignIn as k, bufferExports as l, setStoredAuthMethod as m, normalizeSolanaRpcUrl as n, confirmAndCheckTransaction as o, defaultInjectedEvmProvider as p, init as q, resolveSolanaRpcUrl as r, setCurrentUser as s, transactionHasSignature as t, getCurrentUser as u, onAuthStateChanged as v, onAuthLoadingChanged as w, getAuthLoading as x, waitForAuthReady as y, login as z };
12255
+ //# sourceMappingURL=index-Sx-Caknc.mjs.map