@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
@@ -0,0 +1,9 @@
1
+ /** True in a browser page served on openapps.xyz or one of its subdomains. */
2
+ export declare function onOpenAppsPage(): boolean;
3
+ /** The openapps.xyz name of a platform URL, or the URL unchanged. */
4
+ export declare function openAppsTwinUrl(url: string): string;
5
+ /**
6
+ * The issuer a token from this auth base carries: the bounded.sh name for an
7
+ * openapps.xyz auth host, else the base itself. Without a trailing slash.
8
+ */
9
+ export declare function canonicalIssuer(url: string): string;
@@ -4,6 +4,30 @@ var axios = require('axios');
4
4
  var nacl = require('tweetnacl');
5
5
  var ReconnectingWebSocket = require('reconnecting-websocket');
6
6
 
7
+ // Each shared platform host's openapps.xyz name (the monorepo's
8
+ // packages/cdk/cloudflare/shared/openapps-twin-hosts.ts): the same name on
9
+ // openapps.xyz, with dev-api (an alias of platform) answering as platform. Both names reach the same
10
+ // service, users and signing keys. A page served on openapps.xyz talks to the
11
+ // openapps.xyz names; tokens keep the bounded.sh issuer either way.
12
+ const BOUNDED_HOST = /^(wss?|https):\/\/(auth|wallet-auth|realtime|functions|dev-api|platform)(-staging)?\.bounded\.sh(\/?)$/;
13
+ const TWIN_HOST = /^(https):\/\/(auth|wallet-auth)(-staging)?\.openapps\.xyz\/?$/;
14
+ /** True in a browser page served on openapps.xyz or one of its subdomains. */
15
+ function onOpenAppsPage() {
16
+ const host = typeof location !== 'undefined' && typeof location.hostname === 'string' ? location.hostname : '';
17
+ return host === 'openapps.xyz' || host.endsWith('.openapps.xyz');
18
+ }
19
+ /** The openapps.xyz name of a platform URL, or the URL unchanged. */
20
+ function openAppsTwinUrl(url) {
21
+ return url.replace(BOUNDED_HOST, (_, scheme, name, staging = '', slash) => `${scheme}://${name === 'dev-api' ? 'platform' : name}${staging}.openapps.xyz${slash}`);
22
+ }
23
+ /**
24
+ * The issuer a token from this auth base carries: the bounded.sh name for an
25
+ * openapps.xyz auth host, else the base itself. Without a trailing slash.
26
+ */
27
+ function canonicalIssuer(url) {
28
+ return url.replace(TWIN_HOST, '$1://$2$3.bounded.sh').replace(/\/+$/, '');
29
+ }
30
+
7
31
  // The pristine default config. `clientConfig` (the module global) starts as a
8
32
  // copy of this and is mutated by init(); createClient() resolves fresh scoped
9
33
  // configs from this pristine template so a scoped instance never inherits a
@@ -90,7 +114,8 @@ function getWebhookKeysUrl() {
90
114
  * app's shared-key-signed delivery.
91
115
  */
92
116
  function getConfiguredSessionNamespace() {
93
- return JSON.stringify([(clientConfig.humanAuthApiUrl || "https://auth.bounded.sh").replace(/\/$/, ""), clientConfig.appId]);
117
+ // Keyed by the issuer, not the host, so a session survives a page moving to the openapps.xyz names.
118
+ return JSON.stringify([canonicalIssuer(clientConfig.humanAuthApiUrl || "https://auth.bounded.sh"), clientConfig.appId]);
94
119
  }
95
120
  function getConfiguredAppId() {
96
121
  return clientConfig.appId || undefined;
@@ -126,7 +151,13 @@ function resolveClientConfig(base, newConfig) {
126
151
  throw new Error(`Unsupported Bounded network "${String(newConfig.network)}". Expected bounded, bounded-staging, or bounded-production.`);
127
152
  }
128
153
  const preset = newConfig.network ? BOUNDED_NETWORKS[newConfig.network] : {};
129
- return Object.assign(Object.assign(Object.assign({}, base), preset), newConfig);
154
+ const resolved = Object.assign(Object.assign(Object.assign({}, base), preset), newConfig);
155
+ return onOpenAppsPage() ? withOpenAppsHosts(resolved) : resolved;
156
+ }
157
+ // A page on openapps.xyz reaches every platform service through its openapps.xyz name, so the
158
+ // browser never talks to a bounded.sh host there. Same services, users and keys.
159
+ function withOpenAppsHosts(config) {
160
+ 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) });
130
161
  }
131
162
  function init(newConfig) {
132
163
  return new Promise((resolve, reject) => {
@@ -523,9 +554,12 @@ function recordRefreshOutcome(key, err, now = Date.now()) {
523
554
  function resolveIssuerBase(issuer, cfg) {
524
555
  const norm = (u) => (u || '').replace(/\/$/, '');
525
556
  const allow = [norm(cfg.authApiUrl), norm(cfg.humanAuthApiUrl)].filter(Boolean);
526
- const want = norm(issuer);
527
- if (want && allow.includes(want))
528
- return want;
557
+ // Matched by issuer, so a session minted on a bounded.sh name refreshes through the
558
+ // configured openapps.xyz name of the same issuer (and the other way round).
559
+ const want = issuer ? canonicalIssuer(issuer) : '';
560
+ const match = want && allow.find((base) => canonicalIssuer(base) === want);
561
+ if (match)
562
+ return match;
529
563
  return norm(cfg.authApiUrl);
530
564
  }
531
565
  // #062: key the auth client by its baseURL. The old single memoized client froze the FIRST
@@ -4307,7 +4341,7 @@ class ServerSessionManager {
4307
4341
  const sessionConfig = (_a = this.sessionConfig) !== null && _a !== void 0 ? _a : undefined;
4308
4342
  /* fetch nonce from auth API (bound to the snapshotted app+issuer) */
4309
4343
  const nonce = await genAuthNonce(sessionConfig);
4310
- const { genSolanaMessage } = await Promise.resolve().then(function () { return require('./solana-message-CPotom18.js'); });
4344
+ const { genSolanaMessage } = await Promise.resolve().then(function () { return require('./solana-message-7ppe_p4J.js'); });
4311
4345
  const message = await genSolanaMessage(address, nonce, sessionConfig === null || sessionConfig === void 0 ? void 0 : sessionConfig.appId);
4312
4346
  /* sign the message */
4313
4347
  const sigBytes = nacl.sign.detached(new TextEncoder().encode(message), kp.secretKey);
@@ -7679,7 +7713,7 @@ async function doReconnectWithNewAuth() {
7679
7713
  console.warn('[WS v2] Failed to clear HTTP read cache on auth change:', error);
7680
7714
  }
7681
7715
  try {
7682
- const { reconnectRealtimeStoreWithNewAuth } = await Promise.resolve().then(function () { return require('./realtime-store-C2Jz8YM0.js'); });
7716
+ const { reconnectRealtimeStoreWithNewAuth } = await Promise.resolve().then(function () { return require('./realtime-store-DSJXTRaT.js'); });
7683
7717
  await reconnectRealtimeStoreWithNewAuth();
7684
7718
  }
7685
7719
  catch (error) {
@@ -8898,7 +8932,7 @@ function buildRequestedDocuments(documents) {
8898
8932
  /** Best-effort readback, including a failure to load its lazy implementation. */
8899
8933
  async function attemptMirrorSync(paths, options, transactionSignature) {
8900
8934
  try {
8901
- const mirror = await Promise.resolve().then(function () { return require('./mirror-sync-DzbDh6G_.js'); });
8935
+ const mirror = await Promise.resolve().then(function () { return require('./mirror-sync-DHyXt6zH.js'); });
8902
8936
  return await mirror.attemptMirrorSync(paths, options, transactionSignature);
8903
8937
  }
8904
8938
  catch (error) {
@@ -9168,7 +9202,7 @@ async function completePreparedWrite(setResponse, documents, config, authProvide
9168
9202
  if (typeof curTx.serializedTransaction !== 'string' || typeof curTx.poofnetIntentId !== 'string') {
9169
9203
  throw new Error('Unsupported 202 transaction shape: a poofnet write needs serializedTransaction and poofnetIntentId');
9170
9204
  }
9171
- const { signPoofnetTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-DsT1303T.js'); });
9205
+ const { signPoofnetTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-DBAQEi1q.js'); });
9172
9206
  const signedTransaction = await signPoofnetTransaction(curTx.serializedTransaction, authProvider, options, buildExpectedWriteIntent(documents));
9173
9207
  // Signing-only, exactly as on a real chain: signed and NOT committed.
9174
9208
  if ((options === null || options === void 0 ? void 0 : options.shouldSubmitTx) === false) {
@@ -9206,7 +9240,7 @@ async function completePreparedWrite(setResponse, documents, config, authProvide
9206
9240
  'Nothing was signed or submitted.');
9207
9241
  }
9208
9242
  const solanaChain = workerChain;
9209
- const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-DsT1303T.js'); });
9243
+ const { handlePreBuiltTransaction, buildExpectedWriteIntent } = await Promise.resolve().then(function () { return require('./solana-operations-DBAQEi1q.js'); });
9210
9244
  // OA-0001: derive the expected intent from OUR OWN request (the one
9211
9245
  // ground truth a tampered builder response cannot change) so the
9212
9246
  // validator can reject any transaction whose operation semantics
@@ -9264,7 +9298,7 @@ async function completePreparedWrite(setResponse, documents, config, authProvide
9264
9298
  catch (error) {
9265
9299
  // The blockhash died before the send: the RPC refused the bytes in preflight, so nothing
9266
9300
  // entered the network. The worker builds a fresh one and the wallet signs it again.
9267
- if (rebuilds.expiry && (await Promise.resolve().then(function () { return require('./solana-operations-DsT1303T.js'); })).isExpiredBlockhashRejection(error))
9301
+ if (rebuilds.expiry && (await Promise.resolve().then(function () { return require('./solana-operations-DBAQEi1q.js'); })).isExpiredBlockhashRejection(error))
9268
9302
  return { rebuild: 'expiry' };
9269
9303
  // The Solana lane tags its own broadcast and on-chain failures; anything
9270
9304
  // untagged from it, and every poofnet step before the commit PUT, failed
@@ -11105,7 +11139,7 @@ function toMillis(seconds) {
11105
11139
 
11106
11140
  /** SIWS message creation is async already, so its onchain module can be lazy. */
11107
11141
  async function genSolanaMessage(address, nonce) {
11108
- const implementation = await Promise.resolve().then(function () { return require('./solana-message-CPotom18.js'); });
11142
+ const implementation = await Promise.resolve().then(function () { return require('./solana-message-7ppe_p4J.js'); });
11109
11143
  return implementation.genSolanaMessage(address, nonce);
11110
11144
  }
11111
11145
 
@@ -11761,4 +11795,4 @@ exports.toSeconds = toSeconds;
11761
11795
  exports.waitForSetResult = waitForSetResult;
11762
11796
  exports.withEffects = withEffects;
11763
11797
  exports.writeNotAppliedPhase = writeNotAppliedPhase;
11764
- //# sourceMappingURL=index-D7-5ecyu.js.map
11798
+ //# sourceMappingURL=index-CanW0BzM.js.map