@bounded-sh/core 0.0.120 → 0.0.121-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 (30) hide show
  1. package/dist/client/openapps-hosts.d.ts +9 -0
  2. package/dist/{index-D7-5ecyu.js → index-CanW0BzM.js} +47 -13
  3. package/dist/index-CanW0BzM.js.map +1 -0
  4. package/dist/{index-D93TEYGf.mjs → index-YTbWpM1m.mjs} +47 -13
  5. package/dist/index-YTbWpM1m.mjs.map +1 -0
  6. package/dist/index.js +1 -1
  7. package/dist/index.mjs +1 -1
  8. package/dist/{mirror-sync-DzbDh6G_.js → mirror-sync-DHyXt6zH.js} +2 -2
  9. package/dist/{mirror-sync-DzbDh6G_.js.map → mirror-sync-DHyXt6zH.js.map} +1 -1
  10. package/dist/{mirror-sync-DPMtQC3A.mjs → mirror-sync-T_kCyCI2.mjs} +2 -2
  11. package/dist/{mirror-sync-DPMtQC3A.mjs.map → mirror-sync-T_kCyCI2.mjs.map} +1 -1
  12. package/dist/{realtime-store-FObAdw-J.mjs → realtime-store-BCi4-Yi2.mjs} +2 -2
  13. package/dist/{realtime-store-FObAdw-J.mjs.map → realtime-store-BCi4-Yi2.mjs.map} +1 -1
  14. package/dist/{realtime-store-C2Jz8YM0.js → realtime-store-DSJXTRaT.js} +2 -2
  15. package/dist/{realtime-store-C2Jz8YM0.js.map → realtime-store-DSJXTRaT.js.map} +1 -1
  16. package/dist/{solana-message-CPotom18.js → solana-message-7ppe_p4J.js} +2 -2
  17. package/dist/{solana-message-CPotom18.js.map → solana-message-7ppe_p4J.js.map} +1 -1
  18. package/dist/{solana-message-DqKp-y53.mjs → solana-message-Bv2o7Vm3.mjs} +2 -2
  19. package/dist/{solana-message-DqKp-y53.mjs.map → solana-message-Bv2o7Vm3.mjs.map} +1 -1
  20. package/dist/{solana-operations-cwcuTNyk.mjs → solana-operations-CBRlxkRp.mjs} +3 -3
  21. package/dist/{solana-operations-cwcuTNyk.mjs.map → solana-operations-CBRlxkRp.mjs.map} +1 -1
  22. package/dist/{solana-operations-DsT1303T.js → solana-operations-DBAQEi1q.js} +3 -3
  23. package/dist/{solana-operations-DsT1303T.js.map → solana-operations-DBAQEi1q.js.map} +1 -1
  24. package/dist/{solana-v1-operations-Jzg3uAot.mjs → solana-v1-operations-DKnuNHNM.mjs} +3 -3
  25. package/dist/{solana-v1-operations-Jzg3uAot.mjs.map → solana-v1-operations-DKnuNHNM.mjs.map} +1 -1
  26. package/dist/{solana-v1-operations-qj0WA2tF.js → solana-v1-operations-k1kalkhI.js} +3 -3
  27. package/dist/{solana-v1-operations-qj0WA2tF.js.map → solana-v1-operations-k1kalkhI.js.map} +1 -1
  28. package/package.json +1 -1
  29. package/dist/index-D7-5ecyu.js.map +0 -1
  30. package/dist/index-D93TEYGf.mjs.map +0 -1
@@ -2,6 +2,30 @@ import axios from 'axios';
2
2
  import nacl from 'tweetnacl';
3
3
  import ReconnectingWebSocket from 'reconnecting-websocket';
4
4
 
5
+ // Each shared platform host's openapps.xyz name (the monorepo's
6
+ // packages/cdk/cloudflare/shared/openapps-twin-hosts.ts): the same name on
7
+ // openapps.xyz, with dev-api (an alias of platform) answering as platform. Both names reach the same
8
+ // service, users and signing keys. A page served on openapps.xyz talks to the
9
+ // openapps.xyz names; tokens keep the bounded.sh issuer either way.
10
+ const BOUNDED_HOST = /^(wss?|https):\/\/(auth|wallet-auth|realtime|functions|dev-api|platform)(-staging)?\.bounded\.sh(\/?)$/;
11
+ const TWIN_HOST = /^(https):\/\/(auth|wallet-auth)(-staging)?\.openapps\.xyz\/?$/;
12
+ /** True in a browser page served on openapps.xyz or one of its subdomains. */
13
+ function onOpenAppsPage() {
14
+ const host = typeof location !== 'undefined' && typeof location.hostname === 'string' ? location.hostname : '';
15
+ return host === 'openapps.xyz' || host.endsWith('.openapps.xyz');
16
+ }
17
+ /** The openapps.xyz name of a platform URL, or the URL unchanged. */
18
+ function openAppsTwinUrl(url) {
19
+ return url.replace(BOUNDED_HOST, (_, scheme, name, staging = '', slash) => `${scheme}://${name === 'dev-api' ? 'platform' : name}${staging}.openapps.xyz${slash}`);
20
+ }
21
+ /**
22
+ * The issuer a token from this auth base carries: the bounded.sh name for an
23
+ * openapps.xyz auth host, else the base itself. Without a trailing slash.
24
+ */
25
+ function canonicalIssuer(url) {
26
+ return url.replace(TWIN_HOST, '$1://$2$3.bounded.sh').replace(/\/+$/, '');
27
+ }
28
+
5
29
  // The pristine default config. `clientConfig` (the module global) starts as a
6
30
  // copy of this and is mutated by init(); createClient() resolves fresh scoped
7
31
  // configs from this pristine template so a scoped instance never inherits a
@@ -88,7 +112,8 @@ function getWebhookKeysUrl() {
88
112
  * app's shared-key-signed delivery.
89
113
  */
90
114
  function getConfiguredSessionNamespace() {
91
- return JSON.stringify([(clientConfig.humanAuthApiUrl || "https://auth.bounded.sh").replace(/\/$/, ""), clientConfig.appId]);
115
+ // Keyed by the issuer, not the host, so a session survives a page moving to the openapps.xyz names.
116
+ return JSON.stringify([canonicalIssuer(clientConfig.humanAuthApiUrl || "https://auth.bounded.sh"), clientConfig.appId]);
92
117
  }
93
118
  function getConfiguredAppId() {
94
119
  return clientConfig.appId || undefined;
@@ -124,7 +149,13 @@ function resolveClientConfig(base, newConfig) {
124
149
  throw new Error(`Unsupported Bounded network "${String(newConfig.network)}". Expected bounded, bounded-staging, or bounded-production.`);
125
150
  }
126
151
  const preset = newConfig.network ? BOUNDED_NETWORKS[newConfig.network] : {};
127
- return Object.assign(Object.assign(Object.assign({}, base), preset), newConfig);
152
+ const resolved = Object.assign(Object.assign(Object.assign({}, base), preset), newConfig);
153
+ return onOpenAppsPage() ? withOpenAppsHosts(resolved) : resolved;
154
+ }
155
+ // A page on openapps.xyz reaches every platform service through its openapps.xyz name, so the
156
+ // browser never talks to a bounded.sh host there. Same services, users and keys.
157
+ function withOpenAppsHosts(config) {
158
+ return Object.assign(Object.assign({}, config), { wsApiUrl: openAppsTwinUrl(config.wsApiUrl), apiUrl: openAppsTwinUrl(config.apiUrl), authApiUrl: openAppsTwinUrl(config.authApiUrl), humanAuthApiUrl: config.humanAuthApiUrl && openAppsTwinUrl(config.humanAuthApiUrl), functionsUrl: config.functionsUrl && openAppsTwinUrl(config.functionsUrl), devApiUrl: config.devApiUrl && openAppsTwinUrl(config.devApiUrl) });
128
159
  }
129
160
  function init(newConfig) {
130
161
  return new Promise((resolve, reject) => {
@@ -521,9 +552,12 @@ function recordRefreshOutcome(key, err, now = Date.now()) {
521
552
  function resolveIssuerBase(issuer, cfg) {
522
553
  const norm = (u) => (u || '').replace(/\/$/, '');
523
554
  const allow = [norm(cfg.authApiUrl), norm(cfg.humanAuthApiUrl)].filter(Boolean);
524
- const want = norm(issuer);
525
- if (want && allow.includes(want))
526
- return want;
555
+ // Matched by issuer, so a session minted on a bounded.sh name refreshes through the
556
+ // configured openapps.xyz name of the same issuer (and the other way round).
557
+ const want = issuer ? canonicalIssuer(issuer) : '';
558
+ const match = want && allow.find((base) => canonicalIssuer(base) === want);
559
+ if (match)
560
+ return match;
527
561
  return norm(cfg.authApiUrl);
528
562
  }
529
563
  // #062: key the auth client by its baseURL. The old single memoized client froze the FIRST
@@ -4305,7 +4339,7 @@ class ServerSessionManager {
4305
4339
  const sessionConfig = (_a = this.sessionConfig) !== null && _a !== void 0 ? _a : undefined;
4306
4340
  /* fetch nonce from auth API (bound to the snapshotted app+issuer) */
4307
4341
  const nonce = await genAuthNonce(sessionConfig);
4308
- const { genSolanaMessage } = await import('./solana-message-DqKp-y53.mjs');
4342
+ const { genSolanaMessage } = await import('./solana-message-Bv2o7Vm3.mjs');
4309
4343
  const message = await genSolanaMessage(address, nonce, sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.appId);
4310
4344
  /* sign the message */
4311
4345
  const sigBytes = nacl.sign.detached(new TextEncoder().encode(message), kp.secretKey);
@@ -7677,7 +7711,7 @@ async function doReconnectWithNewAuth() {
7677
7711
  console.warn('[WS v2] Failed to clear HTTP read cache on auth change:', error);
7678
7712
  }
7679
7713
  try {
7680
- const { reconnectRealtimeStoreWithNewAuth } = await import('./realtime-store-FObAdw-J.mjs');
7714
+ const { reconnectRealtimeStoreWithNewAuth } = await import('./realtime-store-BCi4-Yi2.mjs');
7681
7715
  await reconnectRealtimeStoreWithNewAuth();
7682
7716
  }
7683
7717
  catch (error) {
@@ -8896,7 +8930,7 @@ function buildRequestedDocuments(documents) {
8896
8930
  /** Best-effort readback, including a failure to load its lazy implementation. */
8897
8931
  async function attemptMirrorSync(paths, options, transactionSignature) {
8898
8932
  try {
8899
- const mirror = await import('./mirror-sync-DPMtQC3A.mjs');
8933
+ const mirror = await import('./mirror-sync-T_kCyCI2.mjs');
8900
8934
  return await mirror.attemptMirrorSync(paths, options, transactionSignature);
8901
8935
  }
8902
8936
  catch (error) {
@@ -9166,7 +9200,7 @@ async function completePreparedWrite(setResponse, documents, config, authProvide
9166
9200
  if (typeof curTx.serializedTransaction !== 'string' || typeof curTx.poofnetIntentId !== 'string') {
9167
9201
  throw new Error('Unsupported 202 transaction shape: a poofnet write needs serializedTransaction and poofnetIntentId');
9168
9202
  }
9169
- const { signPoofnetTransaction, buildExpectedWriteIntent } = await import('./solana-operations-cwcuTNyk.mjs');
9203
+ const { signPoofnetTransaction, buildExpectedWriteIntent } = await import('./solana-operations-CBRlxkRp.mjs');
9170
9204
  const signedTransaction = await signPoofnetTransaction(curTx.serializedTransaction, authProvider, options, buildExpectedWriteIntent(documents));
9171
9205
  // Signing-only, exactly as on a real chain: signed and NOT committed.
9172
9206
  if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
@@ -9204,7 +9238,7 @@ async function completePreparedWrite(setResponse, documents, config, authProvide
9204
9238
  'Nothing was signed or submitted.');
9205
9239
  }
9206
9240
  const solanaChain = workerChain;
9207
- const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await import('./solana-operations-cwcuTNyk.mjs');
9241
+ const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await import('./solana-operations-CBRlxkRp.mjs');
9208
9242
  // OA-0001: derive the expected intent from OUR OWN request (the one
9209
9243
  // ground truth a tampered builder response cannot change) so the
9210
9244
  // validator can reject any transaction whose operation semantics
@@ -9262,7 +9296,7 @@ async function completePreparedWrite(setResponse, documents, config, authProvide
9262
9296
  catch (error) {
9263
9297
  // The blockhash died before the send: the RPC refused the bytes in preflight, so nothing
9264
9298
  // entered the network. The worker builds a fresh one and the wallet signs it again.
9265
- if (rebuilds.expiry && (await import('./solana-operations-cwcuTNyk.mjs')).isExpiredBlockhashRejection(error))
9299
+ if (rebuilds.expiry && (await import('./solana-operations-CBRlxkRp.mjs')).isExpiredBlockhashRejection(error))
9266
9300
  return { rebuild: 'expiry' };
9267
9301
  // The Solana lane tags its own broadcast and on-chain failures; anything
9268
9302
  // untagged from it, and every poofnet step before the commit PUT, failed
@@ -11103,7 +11137,7 @@ function toMillis(seconds) {
11103
11137
 
11104
11138
  /** SIWS message creation is async already, so its onchain module can be lazy. */
11105
11139
  async function genSolanaMessage(address, nonce) {
11106
- const implementation = await import('./solana-message-DqKp-y53.mjs');
11140
+ const implementation = await import('./solana-message-Bv2o7Vm3.mjs');
11107
11141
  return implementation.genSolanaMessage(address, nonce);
11108
11142
  }
11109
11143
 
@@ -11653,4 +11687,4 @@ function defineLiveModule(mod) {
11653
11687
  }
11654
11688
 
11655
11689
  export { dispatchDeclineEvent as $, aggregate as A, reconcileSetResult as B, waitForSetResult as C, isWriteNotApplied as D, writeNotAppliedPhase as E, subscribe as F, closeAllSubscriptions as G, clearCache as H, InsufficientBalanceError as I, getCachedData as J, reconnectWithNewAuth as K, createClient as L, exchangeAppToken as M, clearAppTokenCache as N, createAppTokenAuthHeaders as O, AppTokenExchangeError as P, setWithVenueGrant as Q, resolveVenueRpcUrl as R, ScopedClientReadOnlyError as S, subscribeQuery as T, closeAllQuerySubscriptions as U, canonicalizeArgs as V, canonicalizeResult as W, DEFAULT_QUERY_POLL_INTERVAL_MS as X, MIN_QUERY_POLL_INTERVAL_MS as Y, BoundedDeclineError as Z, deriveDecline as _, markWriteNotApplied as a, DECLINE_EVENT_NAME as a0, dispatchRateLimitEvent as a1, RATE_LIMIT_EVENT_NAME as a2, hasActiveConnection as a3, increment as a4, serverTimestamp as a5, now as a6, toSeconds as a7, toMillis as a8, getIdToken as a9, browserSignInDomain as aA, SOLANA_SIGN_IN_STATEMENT as aB, genSiweMessage as aC, normalizeEvmAddress as aD, toLowerEvmAddress as aE, functions as aF, invoke as aG, FunctionInvokeError as aH, live as aI, intent as aJ, status as aK, subscribeView as aL, LiveIntentError as aM, withEffects as aN, isEffectResult as aO, defineLiveModule as aP, EFFECT_INTENT_ADDRESS as aQ, deriveUserIdentityFromIdToken as aa, getSessionGeneration as ab, WebSessionManager as ac, ReactNativeSessionManager as ad, getActiveSessionManager as ae, onSessionCleared as af, announceSessionChange as ag, onSessionChange as ah, SESSION_SIGNAL_CHANNEL as ai, SessionEnvironmentError as aj, UNSUPPORTED_ENVIRONMENT_CODE as ak, AUTH_CHANGED_CODE as al, AUTH_EXPIRED_CODE as am, isAuthExpiredError as an, getFreshAuthToken as ao, ServerSessionManager as ap, createSessionWithSignature as aq, refreshSession as ar, revokeSession as as, signSessionCreateMessage as at, genAuthNonce as au, genSolanaMessage as av, createSolanaSignInRequest as aw, createSolanaSignInMessageText as ax, genSolanaSignInRequest as ay, genSolanaSignInMessage as az, bufferExports as b, confirmSignature as c, getWebhookKeysUrl as d, getConfiguredAppId as e, get as f, getConfig as g, getMany as h, init as i, docId as j, setMany as k, setFile as l, makeApiRequest as m, getFiles as n, search as o, runQueryMany as p, queryAggregate as q, runQuery as r, set as s, runExpression as t, runExpressionMany as u, signMessage as v, signTransaction as w, signAndSubmitTransaction as x, prepareToSign as y, count as z };
11656
- //# sourceMappingURL=index-D93TEYGf.mjs.map
11690
+ //# sourceMappingURL=index-YTbWpM1m.mjs.map