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

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 (29) hide show
  1. package/dist/auth/bounded-login-widget.d.ts +5 -0
  2. package/dist/connections.d.ts +44 -0
  3. package/dist/{email-auth-provider-CmbRj-_I.mjs → email-auth-provider-C-SGTRZe.mjs} +2 -2
  4. package/dist/{email-auth-provider-CmbRj-_I.mjs.map → email-auth-provider-C-SGTRZe.mjs.map} +1 -1
  5. package/dist/{email-auth-provider-BFOw9iI9.js → email-auth-provider-CjbJ8wK1.js} +2 -2
  6. package/dist/{email-auth-provider-BFOw9iI9.js.map → email-auth-provider-CjbJ8wK1.js.map} +1 -1
  7. package/dist/{guest-auth-provider-Bvoaq-zC.mjs → guest-auth-provider-BwEXKnNK.mjs} +2 -2
  8. package/dist/{guest-auth-provider-Bvoaq-zC.mjs.map → guest-auth-provider-BwEXKnNK.mjs.map} +1 -1
  9. package/dist/{guest-auth-provider-DJD3zkBU.js → guest-auth-provider-ClCOa69H.js} +2 -2
  10. package/dist/{guest-auth-provider-DJD3zkBU.js.map → guest-auth-provider-ClCOa69H.js.map} +1 -1
  11. package/dist/{index-C2xAP67N.js → index-B2HWEA13.js} +170 -22
  12. package/dist/index-B2HWEA13.js.map +1 -0
  13. package/dist/{index-BmBLsYn2.mjs → index-q9BHoxbM.mjs} +166 -23
  14. package/dist/index-q9BHoxbM.mjs.map +1 -0
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.js +6 -1
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +1 -1
  19. package/dist/{injected-evm-wallet-provider-B2xteR2I.mjs → injected-evm-wallet-provider-AXc7Lmzk.mjs} +2 -2
  20. package/dist/{injected-evm-wallet-provider-B2xteR2I.mjs.map → injected-evm-wallet-provider-AXc7Lmzk.mjs.map} +1 -1
  21. package/dist/{injected-evm-wallet-provider-CL_FBjLe.js → injected-evm-wallet-provider-qB_GQ9ih.js} +2 -2
  22. package/dist/{injected-evm-wallet-provider-CL_FBjLe.js.map → injected-evm-wallet-provider-qB_GQ9ih.js.map} +1 -1
  23. package/dist/{injected-wallet-provider-Bc_xtyRd.js → injected-wallet-provider-BEaDBzcd.js} +2 -2
  24. package/dist/{injected-wallet-provider-Bc_xtyRd.js.map → injected-wallet-provider-BEaDBzcd.js.map} +1 -1
  25. package/dist/{injected-wallet-provider-DwozZ926.mjs → injected-wallet-provider-gmGZ254w.mjs} +2 -2
  26. package/dist/{injected-wallet-provider-DwozZ926.mjs.map → injected-wallet-provider-gmGZ254w.mjs.map} +1 -1
  27. package/package.json +2 -2
  28. package/dist/index-BmBLsYn2.mjs.map +0 -1
  29. package/dist/index-C2xAP67N.js.map +0 -1
@@ -6496,7 +6496,7 @@ async function getAuthProvider(config, fromStorage = false) {
6496
6496
  // manager as legacy email sessions. Human login should be started
6497
6497
  // with loginWithRedirect(); this provider is kept as the restore and
6498
6498
  // logout surface for those sessions.
6499
- currentAuthProvider = new (await Promise.resolve().then(function () { return require('./email-auth-provider-BFOw9iI9.js'); })).EmailAuthProvider();
6499
+ currentAuthProvider = new (await Promise.resolve().then(function () { return require('./email-auth-provider-CjbJ8wK1.js'); })).EmailAuthProvider();
6500
6500
  break;
6501
6501
  case "phantom": {
6502
6502
  // First-class Solana WALLET LOGIN (the poof/TaroBase-style "connect
@@ -6538,7 +6538,7 @@ async function getAuthProvider(config, fromStorage = false) {
6538
6538
  // (bounded-login-widget.ts), so registration never counts as
6539
6539
  // evidence the user has a wallet.
6540
6540
  await ensureSolanaMobileWalletRegistered(config, configuredNetwork);
6541
- const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-Bc_xtyRd.js'); });
6541
+ const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-BEaDBzcd.js'); });
6542
6542
  currentAuthProvider = new InjectedWalletProvider(resolveInjectedWalletConfig(config), rpcUrl, configuredNetwork);
6543
6543
  break;
6544
6544
  }
@@ -6551,7 +6551,7 @@ async function getAuthProvider(config, fromStorage = false) {
6551
6551
  // Selecting authMethod:'evm-wallet' IS the opt-in — pass evmWalletConfig
6552
6552
  // to point at a specific wallet or set chainId/domain.
6553
6553
  const evmWalletConfig = ((_a = config.evmWalletConfig) !== null && _a !== void 0 ? _a : {});
6554
- const { InjectedEvmWalletProvider } = await Promise.resolve().then(function () { return require('./injected-evm-wallet-provider-CL_FBjLe.js'); });
6554
+ const { InjectedEvmWalletProvider } = await Promise.resolve().then(function () { return require('./injected-evm-wallet-provider-qB_GQ9ih.js'); });
6555
6555
  currentAuthProvider = new InjectedEvmWalletProvider(evmWalletConfig);
6556
6556
  break;
6557
6557
  }
@@ -6576,7 +6576,7 @@ async function getAuthProvider(config, fromStorage = false) {
6576
6576
  break;
6577
6577
  case "guest":
6578
6578
  // Anonymous auth: a device-local ed25519 keypair signs the challenge.
6579
- currentAuthProvider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-DJD3zkBU.js'); })).GuestAuthProvider();
6579
+ currentAuthProvider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-ClCOa69H.js'); })).GuestAuthProvider();
6580
6580
  break;
6581
6581
  }
6582
6582
  if (!currentAuthProvider) {
@@ -6638,7 +6638,7 @@ async function signInAnonymously() {
6638
6638
  // Lazy-load the guest provider so its ed25519/web3 dependencies stay out of
6639
6639
  // the main bundle for data-only apps. Specifier is a static string literal
6640
6640
  // so bundle-splitting can see it.
6641
- const provider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-DJD3zkBU.js'); })).GuestAuthProvider();
6641
+ const provider = new (await Promise.resolve().then(function () { return require('./guest-auth-provider-ClCOa69H.js'); })).GuestAuthProvider();
6642
6642
  setAuthLoading(true); // reflect "signing in…" while the guest keypair session is minted
6643
6643
  // adoptSessionProvider awaits only getConfig() (already resolved here) and then
6644
6644
  // runs every write - provider/method/config/marker/user - in one synchronous
@@ -6809,7 +6809,7 @@ function ensureSharedWalletLoginReady() {
6809
6809
  if (!sharedWalletReady) {
6810
6810
  sharedWalletReady = (async () => {
6811
6811
  await core.getConfig();
6812
- await Promise.resolve().then(function () { return require('./injected-wallet-provider-Bc_xtyRd.js'); });
6812
+ await Promise.resolve().then(function () { return require('./injected-wallet-provider-BEaDBzcd.js'); });
6813
6813
  })().catch((error) => {
6814
6814
  sharedWalletReady = null;
6815
6815
  throw error;
@@ -6914,7 +6914,7 @@ async function loginWithWallet(options) {
6914
6914
  await ensureSharedWalletLoginReady();
6915
6915
  else
6916
6916
  await ensureWalletLoginReady();
6917
- const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-Bc_xtyRd.js'); });
6917
+ const { InjectedWalletProvider } = await Promise.resolve().then(function () { return require('./injected-wallet-provider-BEaDBzcd.js'); });
6918
6918
  // Keep the RAW wallet provider: the offchain wrapper forwards only a fixed
6919
6919
  // set of methods, so cleanup below must speak to the provider that actually
6920
6920
  // holds the config rather than to whatever is wrapping it.
@@ -8452,6 +8452,18 @@ function walletGlyph() {
8452
8452
  svg.append(rect, dot);
8453
8453
  return svg;
8454
8454
  }
8455
+ /** Whether the card shows "Powered by Bounded": the caller decides, else it is off on OpenApps pages. */
8456
+ function showsAttribution(opts) {
8457
+ if (typeof opts.attribution === "boolean")
8458
+ return opts.attribution;
8459
+ try {
8460
+ const host = location.hostname.toLowerCase();
8461
+ return !(host === "openapps.xyz" || host.endsWith(".openapps.xyz"));
8462
+ }
8463
+ catch (_a) {
8464
+ return true;
8465
+ }
8466
+ }
8455
8467
  function isInjectedProvider(v) {
8456
8468
  return supportsWalletSignIn(v);
8457
8469
  }
@@ -9091,13 +9103,15 @@ async function prepareAndOpen(opts, pending) {
9091
9103
  : "Add a method, or make sure wallet login is enabled and the mobile adapter is installed."));
9092
9104
  }
9093
9105
  card.appendChild(status);
9094
- const foot = el("div", "foot");
9095
- const poweredBy = el("a", undefined, "Powered by Bounded");
9096
- poweredBy.href = "https://bounded.sh";
9097
- poweredBy.target = "_blank";
9098
- poweredBy.rel = "noopener";
9099
- foot.appendChild(poweredBy);
9100
- card.appendChild(foot);
9106
+ if (showsAttribution(opts)) {
9107
+ const foot = el("div", "foot");
9108
+ const poweredBy = el("a", undefined, "Powered by Bounded");
9109
+ poweredBy.href = "https://bounded.sh";
9110
+ poweredBy.target = "_blank";
9111
+ poweredBy.rel = "noopener";
9112
+ foot.appendChild(poweredBy);
9113
+ card.appendChild(foot);
9114
+ }
9101
9115
  return card;
9102
9116
  };
9103
9117
  // Solana Mobile leaves the page to sign in: the nonce fetch that precedes
@@ -9250,13 +9264,15 @@ async function prepareAndOpen(opts, pending) {
9250
9264
  frame.style.cssText = "width:100%;height:210px;border:0;background:transparent;color-scheme:dark";
9251
9265
  card.appendChild(frame);
9252
9266
  card.appendChild(status);
9253
- const foot = el("div", "foot");
9254
- const poweredBy = el("a", undefined, "Powered by Bounded");
9255
- poweredBy.href = "https://bounded.sh";
9256
- poweredBy.target = "_blank";
9257
- poweredBy.rel = "noopener";
9258
- foot.appendChild(poweredBy);
9259
- card.appendChild(foot);
9267
+ if (showsAttribution(opts)) {
9268
+ const foot = el("div", "foot");
9269
+ const poweredBy = el("a", undefined, "Powered by Bounded");
9270
+ poweredBy.href = "https://bounded.sh";
9271
+ poweredBy.target = "_blank";
9272
+ poweredBy.rel = "noopener";
9273
+ foot.appendChild(poweredBy);
9274
+ card.appendChild(foot);
9275
+ }
9260
9276
  // Running the frame MINTS a session, so it takes the lock like every other lane. Abandoning
9261
9277
  // via Back settles it so the next lane the user picks is not refused by a claim nobody owns.
9262
9278
  const attempt = beginAttempt();
@@ -10795,6 +10811,133 @@ async function onramp(options = {}) {
10795
10811
  return Object.assign(Object.assign({}, base), { status: 'closed' });
10796
10812
  }
10797
10813
 
10814
+ // Connections: the signed-in user proves they own an account on another service
10815
+ // (X today) and Bounded records it for THIS app at `__connections__/<userId>`.
10816
+ // Policy rules read it, e.g. `get(/__connections__/@user.id).xHandle`; only the
10817
+ // platform can write it, and only after the provider's own consent screen.
10818
+ //
10819
+ // await connect('x') // leaves the page for X's consent screen
10820
+ // const done = await completeConnection() // on the page X sent the user back to
10821
+ // const { x } = await getConnections() // { id, handle, imageUrl, linkedAt } | null
10822
+ // await disconnect('x')
10823
+ //
10824
+ // Only identity is kept: the provider token is discarded after one profile read.
10825
+ // The return page must be on an origin that serves this app (its bounded.page or
10826
+ // custom domain, or an origin the owner registered, such as localhost).
10827
+ /**
10828
+ * `code` is the platform's error code, e.g. `cancelled`, `x_link_expired`, `connection_return_origin_not_allowed`,
10829
+ * or `x_account_linked_elsewhere` when the app's policy sets `auth.connections.x.unique` and another user
10830
+ * of the app already linked that X account.
10831
+ */
10832
+ class ConnectionError extends Error {
10833
+ constructor(code) {
10834
+ super(`Connection failed: ${code}`);
10835
+ this.code = code;
10836
+ this.name = 'ConnectionError';
10837
+ }
10838
+ }
10839
+ const RETURN_PARAMS = ['x_link', 'x_link_error'];
10840
+ async function request(path, init) {
10841
+ var _a;
10842
+ const base = (_a = (await core.getConfig()).devApiUrl) === null || _a === void 0 ? void 0 : _a.replace(/\/$/, '');
10843
+ if (!base)
10844
+ throw new ConnectionError('connection_unavailable');
10845
+ const generation = await core.getSessionGeneration(false);
10846
+ let token = await core.getFreshAuthToken(false);
10847
+ if (!token)
10848
+ throw new ConnectionError('connection_sign_in_required');
10849
+ 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) })));
10850
+ let response = await send(token);
10851
+ if (response.status === 401) {
10852
+ // Retry once with a refreshed token, never under a different login.
10853
+ token = await core.getFreshAuthToken(false, { force: true });
10854
+ if (!token || await core.getSessionGeneration(false) !== generation)
10855
+ throw new ConnectionError('connection_sign_in_required');
10856
+ response = await send(token);
10857
+ }
10858
+ const data = await response.json().catch(() => null);
10859
+ if (!response.ok || (data === null || data === void 0 ? void 0 : data.ok) !== true) {
10860
+ throw new ConnectionError(typeof (data === null || data === void 0 ? void 0 : data.error) === 'string' ? data.error : 'connection_unavailable');
10861
+ }
10862
+ return data;
10863
+ }
10864
+ function parseConnection(raw) {
10865
+ if (!raw || typeof raw !== 'object')
10866
+ return null;
10867
+ const value = raw;
10868
+ if (typeof value.id !== 'string' || typeof value.handle !== 'string' || !Number.isSafeInteger(value.linkedAt))
10869
+ return null;
10870
+ return {
10871
+ id: value.id,
10872
+ handle: value.handle,
10873
+ imageUrl: typeof value.imageUrl === 'string' ? value.imageUrl : null,
10874
+ linkedAt: value.linkedAt,
10875
+ };
10876
+ }
10877
+ function assertProvider(provider) {
10878
+ if (provider !== 'x')
10879
+ throw new ConnectionError('connection_provider_unsupported');
10880
+ }
10881
+ /** The signed-in user's linked accounts for this app. */
10882
+ async function getConnections() {
10883
+ var _a;
10884
+ const data = await request('/connections', { method: 'GET' });
10885
+ const connections = ((_a = data.connections) !== null && _a !== void 0 ? _a : {});
10886
+ return { x: parseConnection(connections.x) };
10887
+ }
10888
+ /**
10889
+ * Send the user to the provider's consent screen. They come back to `returnUrl`
10890
+ * (default: this page), where `completeConnection()` finishes the link.
10891
+ */
10892
+ async function connect(provider, options = {}) {
10893
+ var _a;
10894
+ assertProvider(provider);
10895
+ if (typeof window === 'undefined')
10896
+ throw new ConnectionError('connection_requires_browser');
10897
+ const returnUrl = new URL((_a = options.returnUrl) !== null && _a !== void 0 ? _a : window.location.href, window.location.href);
10898
+ for (const key of RETURN_PARAMS)
10899
+ returnUrl.searchParams.delete(key);
10900
+ const data = await request(`/connections/${provider}/start`, { method: 'POST', body: { returnUrl: returnUrl.href } });
10901
+ const target = typeof data.authorizationUrl === 'string' ? new URL(data.authorizationUrl) : null;
10902
+ if (!target || target.origin !== 'https://x.com')
10903
+ throw new ConnectionError('connection_unavailable');
10904
+ window.location.assign(target.href);
10905
+ }
10906
+ /**
10907
+ * Finish a link on the page the provider returned to. Returns null when this page is
10908
+ * not a connection return; throws ConnectionError when the user cancelled or it failed.
10909
+ * Call it once the user is signed in. The return parameters leave the address bar on
10910
+ * success or cancellation; after another failure they stay, so calling again retries.
10911
+ */
10912
+ async function completeConnection() {
10913
+ if (typeof window === 'undefined')
10914
+ return null;
10915
+ const url = new URL(window.location.href);
10916
+ const token = url.searchParams.get('x_link');
10917
+ const error = url.searchParams.get('x_link_error');
10918
+ if (token === null && error === null)
10919
+ return null;
10920
+ const clear = () => {
10921
+ for (const key of RETURN_PARAMS)
10922
+ url.searchParams.delete(key);
10923
+ window.history.replaceState(window.history.state, '', url.href);
10924
+ };
10925
+ if (error !== null || !token) {
10926
+ clear();
10927
+ throw new ConnectionError(error || 'failed');
10928
+ }
10929
+ // Keep the return token in the address bar until the platform accepts it, so a
10930
+ // sign-in still loading or a transient failure can retry by calling this again.
10931
+ const data = await request('/connections/x/complete', { method: 'POST', body: { state: token } });
10932
+ clear();
10933
+ return { provider: 'x', connection: parseConnection(data.connection) };
10934
+ }
10935
+ /** Remove the user's linked account for this app. */
10936
+ async function disconnect(provider) {
10937
+ assertProvider(provider);
10938
+ await request(`/connections/${provider}`, { method: 'DELETE' });
10939
+ }
10940
+
10798
10941
  // venue-escrow.ts - fund and dispute a venue escrow from inside an OpenApps app (VENUE-GRANT-DESIGN.md).
10799
10942
  //
10800
10943
  // An OpenApps app's escrow lives in its venue (`agentescrows/<rootAppId>/e/<escrowId>`), and this
@@ -12153,6 +12296,7 @@ exports.BUILD_DELEGATED_REVIEW_CAPABILITY_SCHEMA = BUILD_DELEGATED_REVIEW_CAPABI
12153
12296
  exports.BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA = BUILD_REVIEW_CAPABILITY_REFRESH_SCHEMA;
12154
12297
  exports.BUILD_REVIEW_CAPABILITY_SCHEMA = BUILD_REVIEW_CAPABILITY_SCHEMA;
12155
12298
  exports.BuildsApiError = BuildsApiError;
12299
+ exports.ConnectionError = ConnectionError;
12156
12300
  exports.FAILURE_REASONS = FAILURE_REASONS;
12157
12301
  exports.NON_TERMINAL_STATES = NON_TERMINAL_STATES;
12158
12302
  exports.OffchainAuthProvider = OffchainAuthProvider;
@@ -12167,12 +12311,15 @@ exports.apps = apps;
12167
12311
  exports.bs58 = bs58;
12168
12312
  exports.bufferExports = bufferExports;
12169
12313
  exports.builds = builds;
12314
+ exports.completeConnection = completeConnection;
12170
12315
  exports.completeLoginFromRedirect = completeLoginFromRedirect;
12171
12316
  exports.confirmAndCheckTransaction = confirmAndCheckTransaction;
12317
+ exports.connect = connect;
12172
12318
  exports.connectBroadcast = connectBroadcast;
12173
12319
  exports.connectServiceSession = connectServiceSession;
12174
12320
  exports.defaultInjectedEvmProvider = defaultInjectedEvmProvider;
12175
12321
  exports.defaultInjectedProvider = defaultInjectedProvider;
12322
+ exports.disconnect = disconnect;
12176
12323
  exports.disputeVenueEscrow = disputeVenueEscrow;
12177
12324
  exports.ensureSharedWalletLoginReady = ensureSharedWalletLoginReady;
12178
12325
  exports.ensureSignedIn = ensureSignedIn;
@@ -12181,6 +12328,7 @@ exports.firstStandardWalletProvider = firstStandardWalletProvider;
12181
12328
  exports.fundVenueEscrow = fundVenueEscrow;
12182
12329
  exports.getAuthLoading = getAuthLoading;
12183
12330
  exports.getAuthProvider = getAuthProvider;
12331
+ exports.getConnections = getConnections;
12184
12332
  exports.getCurrentUser = getCurrentUser;
12185
12333
  exports.getIdToken = getIdToken;
12186
12334
  exports.getLoginReturnError = getLoginReturnError;
@@ -12226,4 +12374,4 @@ exports.useAuth = useAuth;
12226
12374
  exports.useBuildRun = useBuildRun;
12227
12375
  exports.useQuery = useQuery;
12228
12376
  exports.waitForAuthReady = waitForAuthReady;
12229
- //# sourceMappingURL=index-C2xAP67N.js.map
12377
+ //# sourceMappingURL=index-B2HWEA13.js.map