@bounded-sh/client 0.0.48 → 0.0.50

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 (67) hide show
  1. package/README.md +21 -0
  2. package/dist/auth/providers/guest-auth-provider.d.ts +7 -0
  3. package/dist/auth/providers/guest-keystore.d.ts +2 -0
  4. package/dist/builds/apps.d.ts +32 -0
  5. package/dist/builds/client.d.ts +74 -0
  6. package/dist/builds/index.d.ts +20 -0
  7. package/dist/builds/types.d.ts +121 -0
  8. package/dist/builds/watch.d.ts +20 -0
  9. package/dist/{email-auth-provider-GRj8IOg2.mjs → email-auth-provider-B7czfBEU.mjs} +2 -2
  10. package/dist/{email-auth-provider-GRj8IOg2.mjs.map → email-auth-provider-B7czfBEU.mjs.map} +1 -1
  11. package/dist/{email-auth-provider-CmunfauO.js → email-auth-provider-CmYs6Dcm.js} +2 -2
  12. package/dist/{email-auth-provider-CmunfauO.js.map → email-auth-provider-CmYs6Dcm.js.map} +1 -1
  13. package/dist/{email-auth-provider-CTyjwhLb.mjs → email-auth-provider-DIZAETBC.mjs} +2 -2
  14. package/dist/{email-auth-provider-CTyjwhLb.mjs.map → email-auth-provider-DIZAETBC.mjs.map} +1 -1
  15. package/dist/{email-auth-provider-DyxZTpx6.js → email-auth-provider-Dj66AuH0.js} +2 -2
  16. package/dist/{email-auth-provider-DyxZTpx6.js.map → email-auth-provider-Dj66AuH0.js.map} +1 -1
  17. package/dist/global.d.ts +3 -1
  18. package/dist/{guest-auth-provider-D54uHbov.js → guest-auth-provider-B5sgg-q5.js} +98 -14
  19. package/dist/guest-auth-provider-B5sgg-q5.js.map +1 -0
  20. package/dist/{guest-auth-provider-Dk_km5tF.mjs → guest-auth-provider-BR0_YL8z.mjs} +98 -14
  21. package/dist/guest-auth-provider-BR0_YL8z.mjs.map +1 -0
  22. package/dist/{guest-auth-provider-C4BuTNIa.mjs → guest-auth-provider-CCpNvX3j.mjs} +98 -14
  23. package/dist/guest-auth-provider-CCpNvX3j.mjs.map +1 -0
  24. package/dist/{guest-auth-provider-B68XT2lU.js → guest-auth-provider-CxsLCznO.js} +98 -14
  25. package/dist/guest-auth-provider-CxsLCznO.js.map +1 -0
  26. package/dist/hooks/useBuildRun.d.ts +13 -0
  27. package/dist/{index.native-CytJPNQV.mjs → index-BYy1tSkr.mjs} +850 -26
  28. package/dist/index-BYy1tSkr.mjs.map +1 -0
  29. package/dist/{index.native-BZCc0gO-.js → index-m42Be5Oj.js} +861 -24
  30. package/dist/index-m42Be5Oj.js.map +1 -0
  31. package/dist/index.d.ts +5 -0
  32. package/dist/index.js +10 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +1 -1
  35. package/dist/{index-C0pR5b7j.mjs → index.native-B-ldAbu2.mjs} +668 -146
  36. package/dist/index.native-B-ldAbu2.mjs.map +1 -0
  37. package/dist/{index-JBeYYsGm.js → index.native-BfoLJCZg.js} +675 -148
  38. package/dist/index.native-BfoLJCZg.js.map +1 -0
  39. package/dist/index.native.d.ts +5 -0
  40. package/dist/index.native.js +10 -1
  41. package/dist/index.native.js.map +1 -1
  42. package/dist/index.native.mjs +1 -1
  43. package/dist/{injected-evm-wallet-provider-_eeYB1ww.js → injected-evm-wallet-provider-BLQzWiBP.js} +2 -2
  44. package/dist/{injected-evm-wallet-provider-_eeYB1ww.js.map → injected-evm-wallet-provider-BLQzWiBP.js.map} +1 -1
  45. package/dist/{injected-evm-wallet-provider-T-EF9C3W.js → injected-evm-wallet-provider-BXj1YFaZ.js} +2 -2
  46. package/dist/{injected-evm-wallet-provider-T-EF9C3W.js.map → injected-evm-wallet-provider-BXj1YFaZ.js.map} +1 -1
  47. package/dist/{injected-evm-wallet-provider-CxAiNN7R.mjs → injected-evm-wallet-provider-sBCSkksr.mjs} +2 -2
  48. package/dist/{injected-evm-wallet-provider-CxAiNN7R.mjs.map → injected-evm-wallet-provider-sBCSkksr.mjs.map} +1 -1
  49. package/dist/{injected-evm-wallet-provider-BOMLGGHM.mjs → injected-evm-wallet-provider-ubsHX217.mjs} +2 -2
  50. package/dist/{injected-evm-wallet-provider-BOMLGGHM.mjs.map → injected-evm-wallet-provider-ubsHX217.mjs.map} +1 -1
  51. package/dist/{injected-wallet-provider-B1uq3r4r.mjs → injected-wallet-provider-BfzoheDy.mjs} +2 -2
  52. package/dist/{injected-wallet-provider-B1uq3r4r.mjs.map → injected-wallet-provider-BfzoheDy.mjs.map} +1 -1
  53. package/dist/{injected-wallet-provider-B2T7JEvn.js → injected-wallet-provider-Cml9TkyV.js} +2 -2
  54. package/dist/{injected-wallet-provider-B2T7JEvn.js.map → injected-wallet-provider-Cml9TkyV.js.map} +1 -1
  55. package/dist/{injected-wallet-provider-DCwygA3j.mjs → injected-wallet-provider-DG87X6AQ.mjs} +2 -2
  56. package/dist/{injected-wallet-provider-DCwygA3j.mjs.map → injected-wallet-provider-DG87X6AQ.mjs.map} +1 -1
  57. package/dist/{injected-wallet-provider-BBZym7YQ.js → injected-wallet-provider-PYcvLO2Z.js} +2 -2
  58. package/dist/{injected-wallet-provider-BBZym7YQ.js.map → injected-wallet-provider-PYcvLO2Z.js.map} +1 -1
  59. package/package.json +2 -2
  60. package/dist/guest-auth-provider-B68XT2lU.js.map +0 -1
  61. package/dist/guest-auth-provider-C4BuTNIa.mjs.map +0 -1
  62. package/dist/guest-auth-provider-D54uHbov.js.map +0 -1
  63. package/dist/guest-auth-provider-Dk_km5tF.mjs.map +0 -1
  64. package/dist/index-C0pR5b7j.mjs.map +0 -1
  65. package/dist/index-JBeYYsGm.js.map +0 -1
  66. package/dist/index.native-BZCc0gO-.js.map +0 -1
  67. package/dist/index.native-CytJPNQV.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { assertCanonicalBoundedRuntimeWriteCalldata, getActiveSessionManager, getConfig, WebSessionManager, ReactNativeSessionManager, revokeSession, init as init$1, reconnectWithNewAuth, deriveUserIdentityFromIdToken, subscribe, getIdToken as getIdToken$1, convertRemainingAccounts, buildSetDocumentsTransaction, genAuthNonce, genSolanaMessage, createSessionWithSignature } from '@bounded-sh/core';
1
+ import { assertCanonicalBoundedRuntimeWriteCalldata, getActiveSessionManager, getConfig, WebSessionManager, ReactNativeSessionManager, revokeSession, init as init$1, reconnectWithNewAuth, deriveUserIdentityFromIdToken, getIdToken as getIdToken$1, convertRemainingAccounts, buildSetDocumentsTransaction, genAuthNonce, genSolanaMessage, createSessionWithSignature } from '@bounded-sh/core';
2
2
  import * as React from 'react';
3
3
 
4
4
  /**
@@ -4226,6 +4226,41 @@ function setStoredAuthMethod(method) {
4226
4226
  // storage might not be available
4227
4227
  }
4228
4228
  }
4229
+ function getStoredIdToken() {
4230
+ try {
4231
+ return getActiveSessionManager().getIdToken();
4232
+ }
4233
+ catch (_a) {
4234
+ return null;
4235
+ }
4236
+ }
4237
+ function idTokenIsGuest(idToken, expectedAddress) {
4238
+ var _a;
4239
+ try {
4240
+ if (!idToken)
4241
+ return false;
4242
+ let b64 = (_a = idToken.split('.')[1]) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '+').replace(/_/g, '/');
4243
+ if (!b64)
4244
+ return false;
4245
+ const pad = b64.length % 4;
4246
+ if (pad === 2)
4247
+ b64 += '==';
4248
+ else if (pad === 3)
4249
+ b64 += '=';
4250
+ const claims = JSON.parse(getPlatform().atob(b64));
4251
+ if ((claims === null || claims === void 0 ? void 0 : claims.is_anonymous) !== true)
4252
+ return false;
4253
+ if (expectedAddress && (claims === null || claims === void 0 ? void 0 : claims['custom:walletAddress']) !== expectedAddress)
4254
+ return false;
4255
+ return true;
4256
+ }
4257
+ catch (_b) {
4258
+ return false;
4259
+ }
4260
+ }
4261
+ function storedSessionIsGuest() {
4262
+ return idTokenIsGuest(getStoredIdToken());
4263
+ }
4229
4264
  /**
4230
4265
  * Pick the provider used for an ordinary `init({ appId })` restore.
4231
4266
  *
@@ -4236,7 +4271,16 @@ function setStoredAuthMethod(method) {
4236
4271
  function authMethodForInit(config) {
4237
4272
  if (config.authMethod != null)
4238
4273
  return config.authMethod;
4239
- return getStoredAuthMethod() === 'guest' ? 'guest' : 'email';
4274
+ if (getStoredAuthMethod() !== 'guest')
4275
+ return 'email';
4276
+ if (storedSessionIsGuest())
4277
+ return 'guest';
4278
+ // A marker is only a restore hint; the bearer is authoritative. Repair a
4279
+ // stale marker (for example, a crash/failed switch while a human session was
4280
+ // still active) instead of relabelling that human bearer as a guest.
4281
+ const hasSession = !!getStoredIdToken();
4282
+ setStoredAuthMethod(hasSession ? 'email' : null);
4283
+ return 'email';
4240
4284
  }
4241
4285
  function objectIdentityKey(value) {
4242
4286
  if (!value || (typeof value !== 'object' && typeof value !== 'function'))
@@ -4401,7 +4445,7 @@ async function getAuthProvider(config) {
4401
4445
  // manager as legacy email sessions. Human login should be started
4402
4446
  // with loginWithRedirect(); this provider is kept as the restore and
4403
4447
  // logout surface for those sessions.
4404
- currentAuthProvider = new (await import('./email-auth-provider-CTyjwhLb.mjs')).EmailAuthProvider();
4448
+ currentAuthProvider = new (await import('./email-auth-provider-B7czfBEU.mjs')).EmailAuthProvider();
4405
4449
  break;
4406
4450
  case "wallet":
4407
4451
  case "phantom": {
@@ -4420,7 +4464,7 @@ async function getAuthProvider(config) {
4420
4464
  if (!isWalletLoginEnabled(config)) {
4421
4465
  throw walletLoginNotEnabledError(authMethod);
4422
4466
  }
4423
- const { InjectedWalletProvider } = await import('./injected-wallet-provider-B1uq3r4r.mjs');
4467
+ const { InjectedWalletProvider } = await import('./injected-wallet-provider-DG87X6AQ.mjs');
4424
4468
  currentAuthProvider = new InjectedWalletProvider(resolveInjectedWalletConfig(config), rpcUrl, configuredNetwork);
4425
4469
  break;
4426
4470
  }
@@ -4433,7 +4477,7 @@ async function getAuthProvider(config) {
4433
4477
  // Selecting authMethod:'evm-wallet' IS the opt-in — pass evmWalletConfig
4434
4478
  // to point at a specific wallet or set chainId/domain.
4435
4479
  const evmWalletConfig = ((_a = config.evmWalletConfig) !== null && _a !== void 0 ? _a : {});
4436
- const { InjectedEvmWalletProvider } = await import('./injected-evm-wallet-provider-CxAiNN7R.mjs');
4480
+ const { InjectedEvmWalletProvider } = await import('./injected-evm-wallet-provider-ubsHX217.mjs');
4437
4481
  currentAuthProvider = new InjectedEvmWalletProvider(evmWalletConfig);
4438
4482
  break;
4439
4483
  }
@@ -4461,7 +4505,7 @@ async function getAuthProvider(config) {
4461
4505
  break;
4462
4506
  case "guest":
4463
4507
  // Anonymous auth: a device-local ed25519 keypair signs the challenge.
4464
- currentAuthProvider = new (await import('./guest-auth-provider-Dk_km5tF.mjs')).GuestAuthProvider();
4508
+ currentAuthProvider = new (await import('./guest-auth-provider-CCpNvX3j.mjs')).GuestAuthProvider();
4465
4509
  break;
4466
4510
  }
4467
4511
  if (!currentAuthProvider) {
@@ -4498,19 +4542,108 @@ function assertBrowserAuthEnv(method) {
4498
4542
  * ownership-as-data pattern. `init()` must have run first. Browser/RN only.
4499
4543
  */
4500
4544
  async function signInAnonymously() {
4545
+ var _a;
4501
4546
  assertBrowserAuthEnv('signInAnonymously');
4502
- const provider = new (await import('./guest-auth-provider-Dk_km5tF.mjs')).GuestAuthProvider();
4503
- currentAuthProvider = provider;
4504
- currentAuthMethod = 'guest';
4505
- currentAuthProviderConfigKey = 'direct:guest';
4547
+ // Resolve configuration before taking the transaction snapshot. Although
4548
+ // getConfig is normally already resolved after init(), it is asynchronous;
4549
+ // another login that finishes during that await must be part of the prior
4550
+ // state we preserve, not accidentally split across old/new snapshots.
4506
4551
  const coreConfig = await getConfig();
4507
- coreConfig.authProvider = provider;
4508
- coreConfig.authMethod = 'guest';
4509
- setAuthProviderInstance(provider);
4510
- setStoredAuthMethod('guest');
4552
+ const previousAuthProvider = currentAuthProvider;
4553
+ const previousAuthMethod = currentAuthMethod;
4554
+ const previousProviderConfigKey = currentAuthProviderConfigKey;
4555
+ const previousStoredAuthMethod = getStoredAuthMethod();
4556
+ const previousGlobalProvider = getAuthProviderInstance();
4557
+ const previousUser = getCurrentUser();
4558
+ const previousCoreProvider = coreConfig.authProvider;
4559
+ const previousCoreAuthMethod = coreConfig.authMethod;
4560
+ const previousIdToken = getStoredIdToken();
4561
+ // Lazy-load the guest provider so its ed25519/web3 dependencies stay out of
4562
+ // the main bundle for data-only apps. Specifier is a static string literal
4563
+ // so bundle-splitting can see it.
4564
+ const provider = new (await import('./guest-auth-provider-CCpNvX3j.mjs')).GuestAuthProvider();
4511
4565
  setAuthLoading(true); // reflect "signing in…" while the guest keypair session is minted
4566
+ const commit = (user) => {
4567
+ // No await/interleaving inside this block: provider/method/config/marker
4568
+ // become guest before the user notification fires, so listeners and
4569
+ // concurrent imperative calls can never observe a mixed identity.
4570
+ currentAuthProvider = provider;
4571
+ currentAuthMethod = 'guest';
4572
+ currentAuthProviderConfigKey = 'direct:guest';
4573
+ coreConfig.authProvider = provider;
4574
+ coreConfig.authMethod = 'guest';
4575
+ setAuthProviderInstance(provider);
4576
+ setStoredAuthMethod('guest');
4577
+ setCurrentUser(user);
4578
+ };
4512
4579
  try {
4513
- return await provider.login();
4580
+ // Mint/store first while every shared provider surface remains on the
4581
+ // previous identity. The provider also withholds setCurrentUser here.
4582
+ const user = await provider.loginForProviderSwitch();
4583
+ if (!user)
4584
+ return null;
4585
+ // A human login may have completed after the guest request persisted but
4586
+ // before its promise resumed here. Re-check the live bearer immediately
4587
+ // before commit so a late guest result cannot overwrite that newer user.
4588
+ if (!user.address || !idTokenIsGuest(getStoredIdToken(), user.address)) {
4589
+ throw new Error('Anonymous sign-in was superseded by another session.');
4590
+ }
4591
+ commit(user);
4592
+ return user;
4593
+ }
4594
+ catch (error) {
4595
+ const currentIdToken = getStoredIdToken();
4596
+ if (currentIdToken !== previousIdToken && idTokenIsGuest(currentIdToken)) {
4597
+ // Defensive applied-yet-error reconciliation: if storage contains a
4598
+ // valid guest bearer/key despite the thrown write, commit that truth
4599
+ // instead of restoring a human UI over a guest token.
4600
+ let recovered = null;
4601
+ try {
4602
+ recovered = await provider.restoreSessionForProviderSwitch();
4603
+ }
4604
+ catch (_b) {
4605
+ try {
4606
+ getActiveSessionManager().clearSession();
4607
+ }
4608
+ catch ( /* fail closed below */_c) { /* fail closed below */ }
4609
+ }
4610
+ if (recovered) {
4611
+ commit(recovered);
4612
+ return recovered;
4613
+ }
4614
+ // restoreSessionForProviderSwitch fails closed and clears a split
4615
+ // bearer. Do not resurrect a user object that no longer has its token.
4616
+ setCurrentUser(null);
4617
+ }
4618
+ else if (currentIdToken === previousIdToken) {
4619
+ // The staged attempt never changed the bearer; every shared provider
4620
+ // surface stayed untouched, so restore the exact prior user/marker.
4621
+ currentAuthProvider = previousAuthProvider;
4622
+ currentAuthMethod = previousAuthMethod;
4623
+ currentAuthProviderConfigKey = previousProviderConfigKey;
4624
+ coreConfig.authProvider = previousCoreProvider;
4625
+ coreConfig.authMethod = previousCoreAuthMethod;
4626
+ setAuthProviderInstance(previousGlobalProvider);
4627
+ setStoredAuthMethod(previousStoredAuthMethod);
4628
+ if (getCurrentUser() !== previousUser)
4629
+ setCurrentUser(previousUser);
4630
+ }
4631
+ else {
4632
+ // A different non-guest token won while this staged guest mint was in
4633
+ // flight (another tab/popup/login). The guest attempt never mutated
4634
+ // shared provider state, so preserve that winner exactly. Align only
4635
+ // this module's private registry to the provider the winner installed;
4636
+ // never overwrite its core/global provider, marker, or user snapshot.
4637
+ const concurrentProvider = (_a = getAuthProviderInstance()) !== null && _a !== void 0 ? _a : coreConfig.authProvider;
4638
+ if (concurrentProvider)
4639
+ currentAuthProvider = concurrentProvider;
4640
+ const concurrentStoredMethod = getStoredAuthMethod();
4641
+ currentAuthMethod = concurrentStoredMethod && concurrentStoredMethod !== 'guest'
4642
+ ? concurrentStoredMethod
4643
+ : (previousAuthMethod && previousAuthMethod !== 'guest' ? previousAuthMethod : 'email');
4644
+ currentAuthProviderConfigKey = previousProviderConfigKey;
4645
+ }
4646
+ throw error;
4514
4647
  }
4515
4648
  finally {
4516
4649
  setAuthLoading(false);
@@ -4807,6 +4940,10 @@ function setCurrentUser(user) {
4807
4940
  function getCurrentUser() {
4808
4941
  return currentUser;
4809
4942
  }
4943
+ /** @internal Snapshot/restore surface for transactional auth-provider switches. */
4944
+ function getAuthProviderInstance() {
4945
+ return authProviderInstance;
4946
+ }
4810
4947
  function setAuthProviderInstance(provider) {
4811
4948
  authProviderInstance = provider;
4812
4949
  }
@@ -4883,6 +5020,438 @@ function useAuth() {
4883
5020
  };
4884
5021
  }
4885
5022
 
5023
+ // Wrapper for getIdToken - passes isServer=false for client-side usage
5024
+ async function getIdToken() {
5025
+ return getIdToken$1(false);
5026
+ }
5027
+
5028
+ var __rest = (undefined && undefined.__rest) || function (s, e) {
5029
+ var t = {};
5030
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5031
+ t[p] = s[p];
5032
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
5033
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
5034
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
5035
+ t[p[i]] = s[p[i]];
5036
+ }
5037
+ return t;
5038
+ };
5039
+ /** A structured non-2xx response from the developer API. */
5040
+ class BuildsApiError extends Error {
5041
+ constructor(init) {
5042
+ super(init.message);
5043
+ this.name = 'BuildsApiError';
5044
+ this.code = init.code;
5045
+ this.retryable = init.retryable;
5046
+ this.status = init.status;
5047
+ this.details = init.details;
5048
+ this.retryAfterMs = init.retryAfterMs;
5049
+ }
5050
+ }
5051
+ const memoryIdempotencyKeys = new Map();
5052
+ const IDEMPOTENCY_STORAGE_PREFIX = 'bounded:build:idempotency:';
5053
+ function retryAfterMs(response) {
5054
+ var _a, _b;
5055
+ const value = (_b = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get) === null || _b === void 0 ? void 0 : _b.call(_a, 'Retry-After');
5056
+ if (!value)
5057
+ return undefined;
5058
+ const seconds = Number(value);
5059
+ if (Number.isFinite(seconds) && seconds >= 0)
5060
+ return Math.ceil(seconds * 1000);
5061
+ const at = Date.parse(value);
5062
+ if (!Number.isFinite(at))
5063
+ return undefined;
5064
+ return Math.max(0, at - Date.now());
5065
+ }
5066
+ async function responseBody(response) {
5067
+ const text = await response.text();
5068
+ if (!text)
5069
+ return {};
5070
+ try {
5071
+ return JSON.parse(text);
5072
+ }
5073
+ catch (_a) {
5074
+ return { raw: text };
5075
+ }
5076
+ }
5077
+ function apiError(response, body) {
5078
+ const envelope = body;
5079
+ const nested = (envelope === null || envelope === void 0 ? void 0 : envelope.error) && typeof envelope.error === 'object'
5080
+ ? envelope.error
5081
+ : undefined;
5082
+ const hasNestedDetails = !!nested && Object.prototype.hasOwnProperty.call(nested, 'details');
5083
+ const hasTopLevelDetails = !!body
5084
+ && typeof body === 'object'
5085
+ && Object.prototype.hasOwnProperty.call(body, 'details');
5086
+ const legacyCode = typeof (body === null || body === void 0 ? void 0 : body.error) === 'string' ? body.error : undefined;
5087
+ const code = typeof (nested === null || nested === void 0 ? void 0 : nested.code) === 'string'
5088
+ ? nested.code
5089
+ : legacyCode !== null && legacyCode !== void 0 ? legacyCode : `http_${response.status}`;
5090
+ const message = typeof (nested === null || nested === void 0 ? void 0 : nested.message) === 'string'
5091
+ ? nested.message
5092
+ : typeof (body === null || body === void 0 ? void 0 : body.message) === 'string'
5093
+ ? body.message
5094
+ : `Developer API request failed with HTTP ${response.status}`;
5095
+ const retryable = typeof (nested === null || nested === void 0 ? void 0 : nested.retryable) === 'boolean'
5096
+ ? nested.retryable
5097
+ : response.status === 429 || response.status >= 500;
5098
+ return new BuildsApiError(Object.assign(Object.assign({ code,
5099
+ message,
5100
+ retryable, status: response.status }, (hasNestedDetails
5101
+ ? { details: nested === null || nested === void 0 ? void 0 : nested.details }
5102
+ : hasTopLevelDetails
5103
+ ? { details: body.details }
5104
+ : {})), (response.status === 429 ? { retryAfterMs: retryAfterMs(response) } : {})));
5105
+ }
5106
+ /** @internal Shared authenticated developer-api transport for builds and apps. */
5107
+ async function requestDevApi(path, request = {}) {
5108
+ var _a, _b;
5109
+ const config = await getConfig();
5110
+ const base = (_a = config.devApiUrl) === null || _a === void 0 ? void 0 : _a.replace(/\/$/, '');
5111
+ if (!base) {
5112
+ throw new Error('Bounded developer API is not configured. Pass devApiUrl or a Bounded network to init().');
5113
+ }
5114
+ // Reuse the exact accessor exposed publicly as getIdToken().
5115
+ const token = await getIdToken();
5116
+ if (!token) {
5117
+ throw new BuildsApiError({
5118
+ code: 'auth_required',
5119
+ message: 'Sign in before calling the Bounded developer API.',
5120
+ retryable: false,
5121
+ status: 401,
5122
+ });
5123
+ }
5124
+ const hasBody = request.body !== undefined;
5125
+ const response = await fetch(`${base}${path}`, Object.assign({ method: (_b = request.method) !== null && _b !== void 0 ? _b : 'GET', headers: Object.assign({ Authorization: `Bearer ${token}` }, (hasBody ? { 'Content-Type': 'application/json' } : {})) }, (hasBody ? { body: JSON.stringify(request.body) } : {})));
5126
+ const body = await responseBody(response);
5127
+ if (!response.ok)
5128
+ throw apiError(response, body);
5129
+ return body;
5130
+ }
5131
+ function intentStorageKey(intentKey) {
5132
+ return `${IDEMPOTENCY_STORAGE_PREFIX}${intentKey}`;
5133
+ }
5134
+ function isValidIdempotencyKey(value) {
5135
+ return typeof value === 'string' && value.length > 0 && value.length <= 256;
5136
+ }
5137
+ function readPersistedIdempotencyKey(intentKey) {
5138
+ var _a;
5139
+ const storageKey = intentStorageKey(intentKey);
5140
+ try {
5141
+ const stored = (_a = globalThis.sessionStorage) === null || _a === void 0 ? void 0 : _a.getItem(storageKey);
5142
+ if (isValidIdempotencyKey(stored))
5143
+ return stored;
5144
+ }
5145
+ catch (_b) {
5146
+ // Storage can be disabled by browser privacy policy; use module memory.
5147
+ }
5148
+ const inMemory = memoryIdempotencyKeys.get(storageKey);
5149
+ return isValidIdempotencyKey(inMemory) ? inMemory : undefined;
5150
+ }
5151
+ function persistIdempotencyKey(intentKey, idempotencyKey) {
5152
+ var _a;
5153
+ const storageKey = intentStorageKey(intentKey);
5154
+ memoryIdempotencyKeys.set(storageKey, idempotencyKey);
5155
+ try {
5156
+ (_a = globalThis.sessionStorage) === null || _a === void 0 ? void 0 : _a.setItem(storageKey, idempotencyKey);
5157
+ }
5158
+ catch (_b) {
5159
+ // The in-memory write above is the React Native / disabled-storage fallback.
5160
+ }
5161
+ }
5162
+ function randomHex(bytes) {
5163
+ const cryptoObject = globalThis.crypto;
5164
+ if (cryptoObject === null || cryptoObject === void 0 ? void 0 : cryptoObject.getRandomValues) {
5165
+ const values = new Uint8Array(bytes);
5166
+ cryptoObject.getRandomValues(values);
5167
+ return Array.from(values, (value) => value.toString(16).padStart(2, '0')).join('');
5168
+ }
5169
+ let value = '';
5170
+ for (let index = 0; index < bytes; index += 1) {
5171
+ value += Math.floor(Math.random() * 256).toString(16).padStart(2, '0');
5172
+ }
5173
+ return value;
5174
+ }
5175
+ function mintIdempotencyKey() {
5176
+ const cryptoObject = globalThis.crypto;
5177
+ if (typeof (cryptoObject === null || cryptoObject === void 0 ? void 0 : cryptoObject.randomUUID) === 'function') {
5178
+ return `build_${cryptoObject.randomUUID()}`;
5179
+ }
5180
+ return `build_${Date.now().toString(36)}_${randomHex(16)}`;
5181
+ }
5182
+ function actionIdempotencyKey(options, action) {
5183
+ const supplied = options.idempotencyKey;
5184
+ if (supplied !== undefined) {
5185
+ if (!isValidIdempotencyKey(supplied)) {
5186
+ throw new TypeError('idempotencyKey must be between 1 and 256 characters.');
5187
+ }
5188
+ if (options.intentKey)
5189
+ persistIdempotencyKey(options.intentKey, supplied);
5190
+ return supplied;
5191
+ }
5192
+ if (!options.intentKey) {
5193
+ throw new TypeError(`intentKey is required when ${action} auto-mints an idempotency key.`);
5194
+ }
5195
+ const existing = readPersistedIdempotencyKey(options.intentKey);
5196
+ if (existing)
5197
+ return existing;
5198
+ const minted = mintIdempotencyKey();
5199
+ // This is deliberately synchronous and happens before requestDevApi can fetch.
5200
+ persistIdempotencyKey(options.intentKey, minted);
5201
+ return minted;
5202
+ }
5203
+ function appPath(appId) {
5204
+ return `/app/${encodeURIComponent(appId)}/builds`;
5205
+ }
5206
+ async function submit(appId, options) {
5207
+ const idempotencyKey = actionIdempotencyKey(options, 'submit()');
5208
+ const { intentKey: _intentKey, idempotencyKey: _suppliedKey } = options, submission = __rest(options, ["intentKey", "idempotencyKey"]);
5209
+ return requestDevApi(appPath(appId), {
5210
+ method: 'POST',
5211
+ body: Object.assign(Object.assign({}, submission), { idempotencyKey }),
5212
+ });
5213
+ }
5214
+ async function get(appId, runId) {
5215
+ return requestDevApi(`${appPath(appId)}/${encodeURIComponent(runId)}`);
5216
+ }
5217
+ async function events(appId, runId, after = 0) {
5218
+ const cursor = Number.isFinite(after) ? Math.max(0, Math.floor(after)) : 0;
5219
+ return requestDevApi(`${appPath(appId)}/${encodeURIComponent(runId)}/events?after=${cursor}`);
5220
+ }
5221
+ async function cancel(appId, runId) {
5222
+ return requestDevApi(`${appPath(appId)}/${encodeURIComponent(runId)}/cancel`, { method: 'POST' });
5223
+ }
5224
+ async function decideGate(appId, runId, gateId, options) {
5225
+ const idempotencyKey = actionIdempotencyKey(options, 'decideGate()');
5226
+ const { intentKey: _intentKey, idempotencyKey: _suppliedKey } = options, decision = __rest(options, ["intentKey", "idempotencyKey"]);
5227
+ return requestDevApi(`${appPath(appId)}/${encodeURIComponent(runId)}/gates/${encodeURIComponent(gateId)}/decision`, { method: 'POST', body: Object.assign(Object.assign({}, decision), { idempotencyKey }) });
5228
+ }
5229
+ async function topup(appId, runId, options) {
5230
+ return requestDevApi(`${appPath(appId)}/${encodeURIComponent(runId)}/topup`, { method: 'POST', body: options });
5231
+ }
5232
+ async function list$1(appId, limit = 20) {
5233
+ const requestedLimit = Number.isFinite(limit) ? Math.max(1, Math.floor(limit)) : 20;
5234
+ return requestDevApi(`${appPath(appId)}?limit=${requestedLimit}`);
5235
+ }
5236
+
5237
+ // Source of truth for these strings:
5238
+ // packages/cdk/cloudflare/bounded-build/src/types.ts. Keep them string-pinned;
5239
+ // wire:1 remains additive and callers must tolerate unknown response strings.
5240
+ const NON_TERMINAL_STATES = [
5241
+ 'queued',
5242
+ 'admitted',
5243
+ 'executing',
5244
+ 'preview_ready',
5245
+ 'parked',
5246
+ 'resuming',
5247
+ 'promoting',
5248
+ 'quarantined',
5249
+ ];
5250
+ const TERMINAL_STATES = [
5251
+ 'promoted',
5252
+ 'failed',
5253
+ 'canceled',
5254
+ 'rejected',
5255
+ 'expired',
5256
+ 'rebase_required',
5257
+ 'reported',
5258
+ ];
5259
+ const RUN_STATES = [
5260
+ ...NON_TERMINAL_STATES,
5261
+ ...TERMINAL_STATES,
5262
+ ];
5263
+ const PARK_REASONS = ['gate', 'funding'];
5264
+ const FAILURE_REASONS = [
5265
+ 'admission_rejected',
5266
+ 'dispatch_timeout',
5267
+ 'auth_revoked',
5268
+ 'owner_changed',
5269
+ 'policy_changed',
5270
+ 'quarantine_forced',
5271
+ 'bind_failed',
5272
+ 'internal_error',
5273
+ ];
5274
+
5275
+ const NORMAL_POLL_MS = 2000;
5276
+ const PARKED_POLL_MS = 5000;
5277
+ const LONG_RUNNING_POLL_MS = 10000;
5278
+ const TWO_MINUTES_MS = 2 * 60000;
5279
+ const TEN_MINUTES_MS = 10 * 60000;
5280
+ const terminalStates = new Set(TERMINAL_STATES);
5281
+ function pollCadence(state, elapsedMs) {
5282
+ if (elapsedMs >= TEN_MINUTES_MS)
5283
+ return LONG_RUNNING_POLL_MS;
5284
+ if ((state === null || state === void 0 ? void 0 : state.startsWith('parked')) || elapsedMs >= TWO_MINUTES_MS)
5285
+ return PARKED_POLL_MS;
5286
+ return NORMAL_POLL_MS;
5287
+ }
5288
+ function retryCadence(error, state, elapsedMs) {
5289
+ const cadence = pollCadence(state, elapsedMs);
5290
+ if (error instanceof BuildsApiError && error.status === 429 && error.retryAfterMs !== undefined) {
5291
+ return Math.max(cadence, error.retryAfterMs);
5292
+ }
5293
+ return cadence;
5294
+ }
5295
+ function hasRetryAfter(error) {
5296
+ return error instanceof BuildsApiError
5297
+ && error.status === 429
5298
+ && error.retryAfterMs !== undefined;
5299
+ }
5300
+ // A permanent API refusal (expired session, revoked access, unknown run) will
5301
+ // never heal by re-polling; the loop must stop and surface it instead of
5302
+ // retrying forever. 429 stays retryable regardless of the server envelope.
5303
+ function isPermanentError(error) {
5304
+ return error instanceof BuildsApiError
5305
+ && error.status !== 429
5306
+ && error.retryable === false;
5307
+ }
5308
+ function newEvents(rows, lastSeq, seen) {
5309
+ const cursorBeforePoll = lastSeq;
5310
+ const fresh = [];
5311
+ let nextCursor = lastSeq;
5312
+ for (const event of rows) {
5313
+ if (!Number.isFinite(event === null || event === void 0 ? void 0 : event.seq))
5314
+ continue;
5315
+ nextCursor = Math.max(nextCursor, event.seq);
5316
+ if (event.seq <= cursorBeforePoll || seen.has(event.seq))
5317
+ continue;
5318
+ seen.add(event.seq);
5319
+ fresh.push(event);
5320
+ }
5321
+ return { events: fresh, lastSeq: nextCursor };
5322
+ }
5323
+ /**
5324
+ * Poll a build view and its event cursor until stopped or the run reaches a
5325
+ * known terminal state. Unknown state strings remain untouched and nonterminal.
5326
+ */
5327
+ function watch(appId, runId, onUpdate, options = {}) {
5328
+ const startedAt = Date.now();
5329
+ const seenSeqs = new Set();
5330
+ let lastSeq = Number.isFinite(options.after)
5331
+ ? Math.max(0, Math.floor(options.after))
5332
+ : 0;
5333
+ let timer;
5334
+ let active = true;
5335
+ let lastState;
5336
+ const stop = () => {
5337
+ active = false;
5338
+ if (timer !== undefined) {
5339
+ clearTimeout(timer);
5340
+ timer = undefined;
5341
+ }
5342
+ };
5343
+ const schedule = (delayMs) => {
5344
+ if (!active)
5345
+ return;
5346
+ timer = setTimeout(() => {
5347
+ timer = undefined;
5348
+ void poll();
5349
+ }, delayMs);
5350
+ };
5351
+ const reportError = (error) => {
5352
+ var _a;
5353
+ try {
5354
+ (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error);
5355
+ }
5356
+ catch (_b) {
5357
+ // A consumer error callback must not break the transport loop.
5358
+ }
5359
+ };
5360
+ const publish = (run, events) => {
5361
+ try {
5362
+ onUpdate({ run, events });
5363
+ }
5364
+ catch (_a) {
5365
+ // Polling is transport state; consumer render errors must not strand it.
5366
+ }
5367
+ };
5368
+ const poll = async () => {
5369
+ if (!active)
5370
+ return;
5371
+ let run;
5372
+ try {
5373
+ const view = await get(appId, runId);
5374
+ if (!active)
5375
+ return;
5376
+ run = view.run;
5377
+ lastState = run.state;
5378
+ }
5379
+ catch (error) {
5380
+ if (!active)
5381
+ return;
5382
+ reportError(error);
5383
+ if (isPermanentError(error)) {
5384
+ stop();
5385
+ return;
5386
+ }
5387
+ schedule(retryCadence(error, lastState, Date.now() - startedAt));
5388
+ return;
5389
+ }
5390
+ try {
5391
+ const response = await events(appId, runId, lastSeq);
5392
+ if (!active)
5393
+ return;
5394
+ const deduped = newEvents(Array.isArray(response.events) ? response.events : [], lastSeq, seenSeqs);
5395
+ lastSeq = deduped.lastSeq;
5396
+ publish(run, deduped.events);
5397
+ }
5398
+ catch (error) {
5399
+ if (!active)
5400
+ return;
5401
+ // The view still advances UI state even when event replay is rate-limited.
5402
+ publish(run, []);
5403
+ reportError(error);
5404
+ if (terminalStates.has(run.state)) {
5405
+ // The run itself is done, but a rate-limited final event replay still
5406
+ // owes the caller its unseen seq rows. Honor Retry-After, retry the
5407
+ // piggyback once the limiter permits it, then stop after a successful
5408
+ // replay. Other terminal replay failures stop normally.
5409
+ if (hasRetryAfter(error)) {
5410
+ schedule(retryCadence(error, run.state, Date.now() - startedAt));
5411
+ return;
5412
+ }
5413
+ stop();
5414
+ return;
5415
+ }
5416
+ if (isPermanentError(error)) {
5417
+ stop();
5418
+ return;
5419
+ }
5420
+ schedule(retryCadence(error, run.state, Date.now() - startedAt));
5421
+ return;
5422
+ }
5423
+ if (!active)
5424
+ return;
5425
+ if (terminalStates.has(run.state)) {
5426
+ // Drain the remaining event pages before stopping: a resumed terminal
5427
+ // watch may owe the caller more rows than one page returns. Each page
5428
+ // advances the cursor, so the loop terminates; the cap is a backstop.
5429
+ for (let page = 0; page < 50 && active; page += 1) {
5430
+ let drained;
5431
+ try {
5432
+ const response = await events(appId, runId, lastSeq);
5433
+ if (!active)
5434
+ return;
5435
+ drained = newEvents(Array.isArray(response.events) ? response.events : [], lastSeq, seenSeqs);
5436
+ }
5437
+ catch (error) {
5438
+ reportError(error);
5439
+ break;
5440
+ }
5441
+ if (drained.events.length === 0)
5442
+ break;
5443
+ lastSeq = drained.lastSeq;
5444
+ publish(run, drained.events);
5445
+ }
5446
+ stop();
5447
+ return;
5448
+ }
5449
+ schedule(pollCadence(run.state, Date.now() - startedAt));
5450
+ };
5451
+ void poll();
5452
+ return { stop };
5453
+ }
5454
+
4886
5455
  var _a;
4887
5456
  // SSR guard (mirrors useAuth): no hooks/subscriptions during Node server render.
4888
5457
  // React Native has no `window` but DOES support hooks, so detect Node SSR
@@ -4890,65 +5459,108 @@ var _a;
4890
5459
  const isSSR = typeof window === 'undefined'
4891
5460
  && typeof process !== 'undefined'
4892
5461
  && !!((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node);
4893
- function useQuery(path, options) {
5462
+ function useBuildRun(appId, runId, options) {
4894
5463
  if (isSSR) {
4895
- return { data: undefined, loading: true, error: null };
5464
+ return { run: null, events: [], loading: true, error: null };
4896
5465
  }
4897
- const [data, setData] = React.useState(undefined);
5466
+ const [run, setRun] = React.useState(null);
5467
+ const [events, setEvents] = React.useState([]);
4898
5468
  const [loading, setLoading] = React.useState(true);
4899
5469
  const [error, setError] = React.useState(null);
4900
- // Re-subscribe only when the query actually changes (not on every render).
4901
5470
  const optionsKey = options ? JSON.stringify(options) : '';
4902
5471
  React.useEffect(() => {
4903
- if (!path) {
4904
- setData(undefined);
5472
+ setRun(null);
5473
+ setEvents([]);
5474
+ setError(null);
5475
+ if (!appId || !runId) {
4905
5476
  setLoading(false);
4906
- setError(null);
4907
5477
  return;
4908
5478
  }
4909
5479
  let active = true;
4910
- let unsubscribe;
4911
5480
  setLoading(true);
4912
- setError(null);
4913
- subscribe(path, Object.assign(Object.assign({}, options), { onData: (d) => {
4914
- if (!active)
4915
- return;
4916
- // A reconnect can legitimately surface a transport error before the
4917
- // socket re-authenticates and sends a new authorized snapshot. That
4918
- // fresh snapshot is the recovery boundary: keep the error visible
4919
- // until data arrives, then clear it so React does not remain stuck on
4920
- // a failure page after realtime has recovered.
4921
- setError(null);
4922
- setData(d);
4923
- setLoading(false);
4924
- }, onError: (e) => {
4925
- if (!active)
4926
- return;
4927
- setError(e instanceof Error ? e : new Error(String(e)));
4928
- setLoading(false);
4929
- } }))
4930
- .then((unsub) => {
4931
- if (active)
4932
- unsubscribe = unsub;
4933
- else
4934
- void unsub(); // unmounted before subscribe resolved
4935
- })
4936
- .catch((e) => {
5481
+ const handle = watch(appId, runId, ({ run: nextRun, events: nextEvents }) => {
4937
5482
  if (!active)
4938
5483
  return;
4939
- setError(e instanceof Error ? e : new Error(String(e)));
5484
+ setRun(nextRun);
5485
+ if (nextEvents.length > 0) {
5486
+ setEvents((current) => {
5487
+ const seen = new Set(current.map((event) => event.seq));
5488
+ return [...current, ...nextEvents.filter((event) => !seen.has(event.seq))];
5489
+ });
5490
+ }
5491
+ setError(null);
4940
5492
  setLoading(false);
4941
- });
5493
+ }, Object.assign(Object.assign({}, options), { onError: (value) => {
5494
+ if (!active)
5495
+ return;
5496
+ setError(value instanceof Error ? value : new Error(String(value)));
5497
+ setLoading(false);
5498
+ } }));
4942
5499
  return () => {
4943
5500
  active = false;
4944
- void (unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe());
5501
+ handle.stop();
4945
5502
  };
4946
- // optionsKey captures the option object's contents; path is the other input.
5503
+ // optionsKey captures the option object's contents; ids are the other inputs.
4947
5504
  // eslint-disable-next-line react-hooks/exhaustive-deps
4948
- }, [path, optionsKey]);
4949
- return { data, loading, error };
5505
+ }, [appId, runId, optionsKey]);
5506
+ return { run, events, loading, error };
4950
5507
  }
4951
5508
 
5509
+ /**
5510
+ * Platform first-party surfaces only (bounded.sh, oapps.fun, localhost) —
5511
+ * dev-api CORS blocks calls from generated-app origins. Server-side callers unaffected.
5512
+ */
5513
+ const builds = {
5514
+ submit,
5515
+ get,
5516
+ events,
5517
+ cancel,
5518
+ decideGate,
5519
+ topup,
5520
+ list: list$1,
5521
+ watch,
5522
+ };
5523
+
5524
+ async function create(options = {}) {
5525
+ const body = Object.assign(Object.assign(Object.assign(Object.assign({}, (options.name !== undefined ? { name: options.name } : {})), (options.prompt !== undefined ? { prompt: options.prompt } : {})), (options.clientToken !== undefined ? { clientToken: options.clientToken } : {})), (options.intent !== undefined ? { intent: options.intent } : {}));
5526
+ const app = await requestDevApi('/apps/new', {
5527
+ method: 'POST',
5528
+ body,
5529
+ });
5530
+ return Object.assign(Object.assign({ appId: app.appId }, (typeof app.slug === 'string' && app.slug ? { slug: app.slug } : {})), { url: app.url,
5531
+ // Fail closed against an older server response that omitted this field.
5532
+ policySeeded: app.policySeeded === true });
5533
+ }
5534
+ async function list() {
5535
+ // This legacy-compatible action shape is also used by oapps.fun listMyApps.
5536
+ const response = await requestDevApi('/', {
5537
+ method: 'POST',
5538
+ body: { action: 'listApps' },
5539
+ });
5540
+ const rows = Array.isArray(response.apps) ? response.apps : [];
5541
+ return rows
5542
+ .map((value) => {
5543
+ var _a, _b, _c, _d;
5544
+ const row = value && typeof value === 'object'
5545
+ ? value
5546
+ : {};
5547
+ const appId = String((_c = (_b = (_a = row._id) !== null && _a !== void 0 ? _a : row.id) !== null && _b !== void 0 ? _b : row.appId) !== null && _c !== void 0 ? _c : '');
5548
+ if (!/^[a-f0-9]{24}$/i.test(appId))
5549
+ return null;
5550
+ const name = String((_d = row.name) !== null && _d !== void 0 ? _d : '').trim() || '(unnamed app)';
5551
+ const slug = typeof row.slug === 'string' && row.slug ? row.slug : undefined;
5552
+ const url = typeof row.url === 'string' && row.url.trim() ? row.url.trim() : undefined;
5553
+ return Object.assign(Object.assign({ appId,
5554
+ name }, (slug ? { slug } : {})), (url ? { url } : {}));
5555
+ })
5556
+ .filter((app) => app !== null);
5557
+ }
5558
+ /**
5559
+ * Platform first-party surfaces only (bounded.sh, oapps.fun, localhost) —
5560
+ * dev-api CORS blocks calls from generated-app origins. Server-side callers unaffected.
5561
+ */
5562
+ const apps = { create, list };
5563
+
4952
5564
  async function deserializeTransaction(tx) {
4953
5565
  // Literal specifier so bundlers can code-split the lazy chunk.
4954
5566
  const { Transaction, VersionedTransaction } = await import('@solana/web3.js');
@@ -4961,11 +5573,6 @@ async function deserializeTransaction(tx) {
4961
5573
  }
4962
5574
  }
4963
5575
 
4964
- // Wrapper for getIdToken - passes isServer=false for client-side usage
4965
- async function getIdToken() {
4966
- return getIdToken$1(false);
4967
- }
4968
-
4969
5576
  /**
4970
5577
  * Extracts a human-readable error message from Solana transaction logs.
4971
5578
  */
@@ -5361,90 +5968,5 @@ class PrivyExpoProvider {
5361
5968
  }
5362
5969
  }
5363
5970
 
5364
- /**
5365
- * Default provider discovery: Phantom-first, then any Wallet-Standard
5366
- * `window.solana`. Kept tiny + synchronous (no heavy imports) so it works inside
5367
- * a user gesture and can be eagerly exported from the SDK entry.
5368
- */
5369
- function defaultInjectedProvider() {
5370
- var _a;
5371
- if (typeof window === 'undefined')
5372
- return null;
5373
- const w = window;
5374
- const phantom = (_a = w === null || w === void 0 ? void 0 : w.phantom) === null || _a === void 0 ? void 0 : _a.solana;
5375
- if (phantom && typeof phantom.signMessage === 'function')
5376
- return phantom;
5377
- const generic = w === null || w === void 0 ? void 0 : w.solana;
5378
- if (generic && typeof generic.signMessage === 'function')
5379
- return generic;
5380
- return null;
5381
- }
5382
-
5383
- // injected-evm-wallet-types.ts — tiny, dependency-free surface for the EVM
5384
- // WALLET LOGIN path (BYO wallet via SIWE). The EVM twin of
5385
- // injected-wallet-types.ts: kept separate from injected-evm-wallet-provider.ts
5386
- // so the SDK entry can eagerly export the type surface + the provider-discovery
5387
- // helper WITHOUT dragging the provider class into the default bundle. The
5388
- // provider is lazy-loaded by getAuthProvider() when an app opts into
5389
- // authMethod:'evm-wallet'.
5390
- //
5391
- // It rides the standard EIP-1193 injected provider a browser wallet exposes
5392
- // (MetaMask / Rabby / Coinbase Wallet / any window.ethereum), discovered via
5393
- // EIP-6963 (multi-wallet, collision-free) with a window.ethereum fallback. It
5394
- // needs NO viem/ethers and NO React — EIP-1193 request() + hex strings suffice.
5395
- // EIP-6963 is announcement-based: wallets add an `eip6963:requestProvider`
5396
- // listener and synchronously dispatch `eip6963:announceProvider` in response. We
5397
- // keep a persistent collector so announcements (including late ones) are
5398
- // captured, and re-request on demand.
5399
- const announcedProviders = [];
5400
- let announceListenerAttached = false;
5401
- function attachAnnounceListener() {
5402
- if (announceListenerAttached || typeof window === 'undefined')
5403
- return;
5404
- announceListenerAttached = true;
5405
- window.addEventListener('eip6963:announceProvider', (event) => {
5406
- const detail = event === null || event === void 0 ? void 0 : event.detail;
5407
- if (detail &&
5408
- detail.provider &&
5409
- typeof detail.provider.request === 'function' &&
5410
- !announcedProviders.some((d) => { var _a, _b; return ((_a = d.info) === null || _a === void 0 ? void 0 : _a.uuid) === ((_b = detail.info) === null || _b === void 0 ? void 0 : _b.uuid); })) {
5411
- announcedProviders.push(detail);
5412
- }
5413
- });
5414
- }
5415
- /**
5416
- * Request + collect EIP-6963 providers. Dispatches `eip6963:requestProvider`
5417
- * (synchronous — already-loaded wallets announce in the same tick) and returns
5418
- * every wallet announced so far. Kept synchronous so it works inside a user
5419
- * gesture and can be eagerly exported from the SDK entry.
5420
- */
5421
- function requestEip6963Providers() {
5422
- if (typeof window === 'undefined')
5423
- return [];
5424
- attachAnnounceListener();
5425
- try {
5426
- window.dispatchEvent(new Event('eip6963:requestProvider'));
5427
- }
5428
- catch (_a) {
5429
- /* older browsers without Event constructor — fall through to window.ethereum */
5430
- }
5431
- return announcedProviders.slice();
5432
- }
5433
- /**
5434
- * Default EVM provider discovery: EIP-6963 first (multi-wallet, collision-free),
5435
- * then legacy `window.ethereum`. Returns null when no injected wallet is present.
5436
- */
5437
- function defaultInjectedEvmProvider() {
5438
- if (typeof window === 'undefined')
5439
- return null;
5440
- const details = requestEip6963Providers();
5441
- if (details.length > 0)
5442
- return details[0].provider;
5443
- const eth = window.ethereum;
5444
- if (eth && typeof eth.request === 'function')
5445
- return eth;
5446
- return null;
5447
- }
5448
-
5449
- export { loginWithPopup as A, completeLoginInPopup as B, useAuth as C, useQuery as D, EMBEDDED_WALLET_UNSUPPORTED as E, deserializeTransaction as F, getIdToken as G, setPlatform as H, requestEip6963Providers as I, OffchainAuthProvider as O, PrivyExpoProvider as P, SURFNET_RPC_URL as S, hasEmbeddedEvmWallet as a, embeddedSignAndSubmit as b, setAuthLoading as c, defaultInjectedProvider as d, embeddedRunEvmTransaction as e, bufferExports as f, getPlatform as g, hasEmbeddedWallet as h, bs58 as i, confirmAndCheckTransaction as j, defaultInjectedEvmProvider as k, init as l, getCurrentUser as m, normalizeSolanaRpcUrl as n, onAuthStateChanged as o, onAuthLoadingChanged as p, getAuthLoading as q, resolveSolanaRpcUrl as r, setCurrentUser as s, login as t, logout as u, getAuthProvider as v, signInAnonymously as w, loginWithPrivy as x, loginWithRedirect as y, completeLoginFromRedirect as z };
5450
- //# sourceMappingURL=index-C0pR5b7j.mjs.map
5971
+ export { useAuth as A, useBuildRun as B, apps as C, deserializeTransaction as D, EMBEDDED_WALLET_UNSUPPORTED as E, getIdToken as F, setPlatform as G, builds as H, BuildsApiError as I, PARK_REASONS as J, FAILURE_REASONS as K, NON_TERMINAL_STATES as N, OffchainAuthProvider as O, PrivyExpoProvider as P, RUN_STATES as R, SURFNET_RPC_URL as S, TERMINAL_STATES as T, 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 };
5972
+ //# sourceMappingURL=index.native-B-ldAbu2.mjs.map