@bounded-sh/client 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/auth/providers/offchain-auth-provider.d.ts +7 -13
  2. package/dist/index.js +226 -285
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +226 -285
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/{index.native-BYEVhmbt.mjs → index.native-CAygEkU7.mjs} +229 -288
  7. package/dist/index.native-CAygEkU7.mjs.map +1 -0
  8. package/dist/{index.native-CcBTbnBg.js → index.native-zD2ZzCLO.js} +229 -288
  9. package/dist/index.native-zD2ZzCLO.js.map +1 -0
  10. package/dist/index.native.js +1 -1
  11. package/dist/index.native.mjs +1 -1
  12. package/dist/{phantom-wallet-provider-D_AzfLq0.mjs → phantom-wallet-provider-DU4WPFPM.mjs} +2 -2
  13. package/dist/{phantom-wallet-provider-D_AzfLq0.mjs.map → phantom-wallet-provider-DU4WPFPM.mjs.map} +1 -1
  14. package/dist/{phantom-wallet-provider-Cn6MzUUo.js → phantom-wallet-provider-MW2H0SFY.js} +2 -2
  15. package/dist/{phantom-wallet-provider-Cn6MzUUo.js.map → phantom-wallet-provider-MW2H0SFY.js.map} +1 -1
  16. package/dist/{privy-wallet-provider-AC4xL6bN.mjs → privy-wallet-provider-D5Kdp3Qp.mjs} +3 -3
  17. package/dist/{privy-wallet-provider-AC4xL6bN.mjs.map → privy-wallet-provider-D5Kdp3Qp.mjs.map} +1 -1
  18. package/dist/{privy-wallet-provider-DtWAtbUl.js → privy-wallet-provider-dFxuvDf4.js} +3 -3
  19. package/dist/{privy-wallet-provider-DtWAtbUl.js.map → privy-wallet-provider-dFxuvDf4.js.map} +1 -1
  20. package/dist/{solana-mobile-wallet-provider-X6BM07gm.mjs → solana-mobile-wallet-provider-CLiflgPj.mjs} +3 -3
  21. package/dist/solana-mobile-wallet-provider-CLiflgPj.mjs.map +1 -0
  22. package/dist/{solana-mobile-wallet-provider-Cos9gu7k.js → solana-mobile-wallet-provider-DAR0BLTQ.js} +3 -3
  23. package/dist/solana-mobile-wallet-provider-DAR0BLTQ.js.map +1 -0
  24. package/package.json +2 -2
  25. package/dist/index.native-BYEVhmbt.mjs.map +0 -1
  26. package/dist/index.native-CcBTbnBg.js.map +0 -1
  27. package/dist/solana-mobile-wallet-provider-Cos9gu7k.js.map +0 -1
  28. package/dist/solana-mobile-wallet-provider-X6BM07gm.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -10154,24 +10154,19 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
10154
10154
  /* ------------------------------------------------------------------ */
10155
10155
  /* ENV helpers */
10156
10156
  /* ------------------------------------------------------------------ */
10157
- // Canonical `BOUNDED_PRIVATE_KEY` (matches the CLI); legacy
10158
- // `BOUNDED_SOLANA_KEYPAIR` still honored. Only consulted when no explicit
10159
- // keypair was provided (createWalletClient passes one).
10160
- const ENV_KEYPAIRS = ["BOUNDED_PRIVATE_KEY", "BOUNDED_SOLANA_KEYPAIR"];
10157
+ // Canonical `BOUNDED_PRIVATE_KEY` (matches the CLI). Only consulted when no
10158
+ // explicit keypair was provided (createWalletClient passes one).
10159
+ const ENV_KEYPAIR = "BOUNDED_PRIVATE_KEY";
10160
+ const LEGACY_ENV_KEYPAIR = "BOUNDED_SOLANA_KEYPAIR";
10161
10161
  function loadKeypairFromEnv() {
10162
- let secret;
10163
- let found;
10164
- for (const name of ENV_KEYPAIRS) {
10165
- const v = process.env[name];
10166
- if (v) {
10167
- secret = v;
10168
- found = name;
10169
- break;
10170
- }
10162
+ if (process.env[LEGACY_ENV_KEYPAIR]) {
10163
+ throw new Error(`${LEGACY_ENV_KEYPAIR} is no longer supported. Set ${ENV_KEYPAIR} instead, ` +
10164
+ `or pass an explicit keypair via createWalletClient({ keypair }).`);
10171
10165
  }
10166
+ const secret = process.env[ENV_KEYPAIR];
10172
10167
  if (!secret) {
10173
10168
  throw new Error(`No server keypair for this top-level call. The top-level get/set/subscribe/etc. use an ` +
10174
- `AMBIENT session — set ${ENV_KEYPAIRS[0]} to a base-58 secret key (or JSON array) to provide one. ` +
10169
+ `AMBIENT session — set ${ENV_KEYPAIR} to a base-58 secret key (or JSON array) to provide one. ` +
10175
10170
  `If you already created a wallet with createWalletClient({ keypair }), call ITS methods instead ` +
10176
10171
  `(client.subscribe / client.set / client.get): that client is self-contained and deliberately does ` +
10177
10172
  `not set the ambient session, so the top-level functions can't see it.`);
@@ -10183,7 +10178,7 @@ function loadKeypairFromEnv() {
10183
10178
  return Keypair.fromSecretKey(secretKey);
10184
10179
  }
10185
10180
  catch (err) {
10186
- throw new Error(`Unable to parse ${found}. Ensure it is valid base-58 or JSON.`);
10181
+ throw new Error(`Unable to parse ${ENV_KEYPAIR}. Ensure it is valid base-58 or JSON.`);
10187
10182
  }
10188
10183
  }
10189
10184
  /* ------------------------------------------------------------------ */
@@ -10250,7 +10245,7 @@ class ServerSessionManager {
10250
10245
  this.session = session;
10251
10246
  }
10252
10247
  /* ---------------------------------------------- *
10253
- * CLEAR (e.g. after logout or 401 retry)
10248
+ * CLEAR (e.g. after explicit logout)
10254
10249
  * ---------------------------------------------- */
10255
10250
  clearSession() {
10256
10251
  this.session = null;
@@ -10274,11 +10269,6 @@ class ServerSessionManager {
10274
10269
  /* The default singleton instance (reads keypair from env) */
10275
10270
  ServerSessionManager.instance = new ServerSessionManager();
10276
10271
 
10277
- var serverSessionManager = /*#__PURE__*/Object.freeze({
10278
- __proto__: null,
10279
- ServerSessionManager: ServerSessionManager
10280
- });
10281
-
10282
10272
  /**
10283
10273
  * Safe base64 helpers for bounded-core.
10284
10274
  *
@@ -10503,13 +10493,6 @@ async function refreshAuthSessionOnce(appId, isServer) {
10503
10493
  async function makeApiRequest(method, urlPath, data, _overrides) {
10504
10494
  var _a, _b, _c, _d, _e, _f, _g, _h;
10505
10495
  const config = await getConfig();
10506
- let hasRetriedAfterServerSessionReset = false;
10507
- const clearServerSession = async () => {
10508
- if (!config.isServer)
10509
- return;
10510
- const { ServerSessionManager } = await Promise.resolve().then(function () { return serverSessionManager; });
10511
- ServerSessionManager.instance.clearSession();
10512
- };
10513
10496
  async function executeRequest() {
10514
10497
  var _a;
10515
10498
  // When _getAuthHeaders is provided (wallet client), use it as the sole auth source.
@@ -10559,13 +10542,7 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
10559
10542
  }
10560
10543
  return await executeRequest();
10561
10544
  }
10562
- catch (_refreshError) {
10563
- // Server-side fallback: clear global session and retry once
10564
- if (config.isServer && !hasRetriedAfterServerSessionReset) {
10565
- hasRetriedAfterServerSessionReset = true;
10566
- await clearServerSession();
10567
- return await executeRequest();
10568
- }
10545
+ catch (_j) {
10569
10546
  throw error;
10570
10547
  }
10571
10548
  }
@@ -11125,39 +11102,8 @@ async function get(path, opts = {}) {
11125
11102
  }
11126
11103
  // Create a new request promise and store it
11127
11104
  const requestPromise = (async () => {
11128
- var _a;
11129
11105
  try {
11130
- // For realtime chains, prefer WebSocket reads (lower latency, already connected)
11131
- const config = await getConfig();
11132
11106
  const pathIsDocument = normalizedPath.split("/").length % 2 === 0;
11133
- if (((_a = config.chain) === null || _a === void 0 ? void 0 : _a.startsWith('realtime_')) && !config.isServer && !opts.prompt && !opts.shape && !opts.cursor && !opts.includeSubPaths && !opts.filter && !opts.sort) {
11134
- try {
11135
- const { wsGet, wsQuery, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
11136
- if (hasActiveConnection()) {
11137
- if (pathIsDocument) {
11138
- const wsResult = await wsGet(normalizedPath);
11139
- const responseData = normalizeReadResult(wsResult, true);
11140
- if (!opts.bypassCache) {
11141
- getCache[cacheKey] = { data: responseData, expiresAt: now + GET_CACHE_TTL };
11142
- }
11143
- return responseData;
11144
- }
11145
- else if (!opts.limit) {
11146
- const wsResult = await wsQuery(normalizedPath, {
11147
- filter: undefined,
11148
- sort: undefined,
11149
- includeSubPaths: opts.includeSubPaths,
11150
- });
11151
- const responseData = normalizeReadResult(wsResult, false);
11152
- if (!opts.bypassCache) {
11153
- getCache[cacheKey] = { data: responseData, expiresAt: now + GET_CACHE_TTL };
11154
- }
11155
- return responseData;
11156
- }
11157
- }
11158
- }
11159
- catch ( /* fall through to HTTP */_b) { /* fall through to HTTP */ }
11160
- }
11161
11107
  // Cache miss or bypass - proceed with HTTP API request
11162
11108
  let response;
11163
11109
  // Build common query params
@@ -11410,7 +11356,7 @@ async function set(path, document, options) {
11410
11356
  return result;
11411
11357
  }
11412
11358
  async function setMany(many, options) {
11413
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
11359
+ var _a, _b, _c, _d, _e, _f, _g;
11414
11360
  // Returns the data that was set, or undefined if the document was already set.
11415
11361
  try {
11416
11362
  const config = await getConfig();
@@ -11447,40 +11393,13 @@ async function setMany(many, options) {
11447
11393
  }
11448
11394
  let setResponse;
11449
11395
  try {
11450
- // For realtime chains, prefer WebSocket if a connection is active (lower latency)
11451
- const useWs = ((_c = config.chain) === null || _c === void 0 ? void 0 : _c.startsWith('realtime_')) && !config.isServer;
11452
- if (useWs) {
11453
- try {
11454
- const { wsSet, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
11455
- if (hasActiveConnection()) {
11456
- // Connection is active — send via WS. If this throws, the write
11457
- // may have been applied server-side (ack lost). Do NOT fall through
11458
- // to HTTP, as that would double-apply non-idempotent ops (Increment).
11459
- const wsResult = await wsSet(documents);
11460
- setResponse = { data: wsResult, status: 200 };
11461
- }
11462
- }
11463
- catch (wsError) {
11464
- // Only fall through to HTTP if the request was never sent (connection not available).
11465
- // If the request was sent and ack was lost (timeout), the server may have
11466
- // applied it — re-sending via HTTP risks double-write for non-idempotent ops.
11467
- const msg = (_d = wsError === null || wsError === void 0 ? void 0 : wsError.message) !== null && _d !== void 0 ? _d : '';
11468
- const neverSent = msg.includes('not available') || msg.includes('connection timeout');
11469
- if (!neverSent) {
11470
- throw wsError;
11471
- }
11472
- // Safe to retry via HTTP — request was never sent
11473
- }
11474
- }
11475
- if (!setResponse) {
11476
- setResponse = await makeApiRequest('PUT', `items`, { documents }, options === null || options === void 0 ? void 0 : options._overrides);
11477
- }
11396
+ setResponse = await makeApiRequest('PUT', `items`, { documents }, options === null || options === void 0 ? void 0 : options._overrides);
11478
11397
  }
11479
11398
  catch (error) {
11480
11399
  if ((error === null || error === void 0 ? void 0 : error.statusCode) === 402 && (error === null || error === void 0 ? void 0 : error.error) === 'INSUFFICIENT_BALANCE') {
11481
- const deficitLamports = Number((_e = error.deficitLamports) !== null && _e !== void 0 ? _e : 0);
11482
- const deficitSol = Number((_f = error.deficitSol) !== null && _f !== void 0 ? _f : deficitLamports / 1000000000);
11483
- throw new InsufficientBalanceError(String((_g = error.address) !== null && _g !== void 0 ? _g : ''), Number((_h = error.balanceLamports) !== null && _h !== void 0 ? _h : 0), Number((_j = error.estimatedCostLamports) !== null && _j !== void 0 ? _j : 0), deficitLamports, deficitSol);
11400
+ const deficitLamports = Number((_c = error.deficitLamports) !== null && _c !== void 0 ? _c : 0);
11401
+ const deficitSol = Number((_d = error.deficitSol) !== null && _d !== void 0 ? _d : deficitLamports / 1000000000);
11402
+ throw new InsufficientBalanceError(String((_e = error.address) !== null && _e !== void 0 ? _e : ''), Number((_f = error.balanceLamports) !== null && _f !== void 0 ? _f : 0), Number((_g = error.estimatedCostLamports) !== null && _g !== void 0 ? _g : 0), deficitLamports, deficitSol);
11484
11403
  }
11485
11404
  throw error;
11486
11405
  }
@@ -11527,7 +11446,7 @@ async function setMany(many, options) {
11527
11446
  else if (setResponse.data &&
11528
11447
  typeof setResponse.data === 'object' &&
11529
11448
  setResponse.data.success === true) {
11530
- const _k = setResponse.data, { success: _success } = _k, rest = __rest$1(_k, ["success"]);
11449
+ const _h = setResponse.data, { success: _success } = _h, rest = __rest$1(_h, ["success"]);
11531
11450
  return Object.assign(Object.assign(Object.assign({}, documents.map(d => d.document)), rest), { transactionId: null });
11532
11451
  }
11533
11452
  else {
@@ -13055,23 +12974,6 @@ async function wsGetMany(paths) {
13055
12974
  }));
13056
12975
  }
13057
12976
 
13058
- var subscriptionV2 = /*#__PURE__*/Object.freeze({
13059
- __proto__: null,
13060
- clearCacheV2: clearCacheV2,
13061
- closeAllSubscriptionsV2: closeAllSubscriptionsV2,
13062
- getCachedDataV2: getCachedDataV2,
13063
- hasActiveConnection: hasActiveConnection,
13064
- reconnectWithNewAuthV2: reconnectWithNewAuthV2,
13065
- subscribeV2: subscribeV2,
13066
- wsDelete: wsDelete,
13067
- wsGet: wsGet,
13068
- wsGetMany: wsGetMany,
13069
- wsIntent: wsIntent,
13070
- wsIntentReliable: wsIntentReliable,
13071
- wsQuery: wsQuery,
13072
- wsSet: wsSet
13073
- });
13074
-
13075
12977
  /**
13076
12978
  * WebSocket Subscription Module
13077
12979
  *
@@ -14882,7 +14784,7 @@ class OffchainAuthProvider {
14882
14784
  // Create modal container
14883
14785
  this.modalContainer = document.createElement("div");
14884
14786
  this.modalContainer.id = "poofnet-unsupported-modal";
14885
- this.modalContainer.innerHTML = this.getUnsupportedModalHTML();
14787
+ this.modalContainer.appendChild(this.buildUnsupportedModalContent());
14886
14788
  document.body.appendChild(this.modalContainer);
14887
14789
  // Add styles
14888
14790
  const style = document.createElement("style");
@@ -14938,38 +14840,6 @@ class OffchainAuthProvider {
14938
14840
  document.addEventListener("keydown", escHandler);
14939
14841
  });
14940
14842
  }
14941
- getUnsupportedModalHTML() {
14942
- return `
14943
- <div class="poofnet-modal-overlay">
14944
- <div class="poofnet-modal-content">
14945
- <button id="poofnet-close-btn" class="poofnet-close-btn" aria-label="Close">
14946
- <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
14947
- <path d="M1 1L13 13M1 13L13 1" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
14948
- </svg>
14949
- </button>
14950
- <div class="poofnet-modal-header">
14951
- <div class="poofnet-modal-icon">⚠️</div>
14952
- <h2 class="poofnet-modal-title">Transaction Not Supported</h2>
14953
- <p class="poofnet-modal-subtitle">Poofnet Simulated Blockchain</p>
14954
- </div>
14955
-
14956
- <div class="poofnet-modal-body">
14957
- <div class="poofnet-info-box" style="background: #fef3c7;">
14958
- <span class="poofnet-info-icon">ℹ️</span>
14959
- <span class="poofnet-info-text" style="color: #92400e;">
14960
- Poofnet is a simulated blockchain and does not support real Solana transactions.
14961
- Deploy your project to mainnet to test real transactions.
14962
- </span>
14963
- </div>
14964
- </div>
14965
-
14966
- <div class="poofnet-modal-footer">
14967
- <button id="poofnet-cancel-btn" class="poofnet-btn poofnet-btn-cancel" style="flex: 1;">Close</button>
14968
- </div>
14969
- </div>
14970
- </div>
14971
- `;
14972
- }
14973
14843
  async showTransactionModal(message) {
14974
14844
  return new Promise((resolve) => {
14975
14845
  // Parse the transaction message for display
@@ -14983,7 +14853,7 @@ class OffchainAuthProvider {
14983
14853
  // Create modal container
14984
14854
  this.modalContainer = document.createElement("div");
14985
14855
  this.modalContainer.id = "poofnet-tx-modal";
14986
- this.modalContainer.innerHTML = this.getModalHTML(parsed, message);
14856
+ this.modalContainer.appendChild(this.buildTransactionModalContent(parsed, message));
14987
14857
  document.body.appendChild(this.modalContainer);
14988
14858
  // Add styles
14989
14859
  const style = document.createElement("style");
@@ -15066,24 +14936,59 @@ class OffchainAuthProvider {
15066
14936
  }, 200);
15067
14937
  }
15068
14938
  }
15069
- /**
15070
- * Escape a value for safe interpolation into an HTML string.
15071
- *
15072
- * Transaction messages are attacker-influenceable (they originate from
15073
- * server responses / app-supplied data), so every value derived from them
15074
- * MUST be escaped before being placed into innerHTML. Without this, a field
15075
- * key/value, path segment, document id, or raw message containing markup
15076
- * such as `<img src=x onerror=...>` would execute in the dApp origin and
15077
- * could exfiltrate the stored session (idToken/refreshToken).
15078
- */
15079
- escapeHtml(value) {
15080
- const str = value === null || value === undefined ? "" : String(value);
15081
- return str
15082
- .replace(/&/g, "&amp;")
15083
- .replace(/</g, "&lt;")
15084
- .replace(/>/g, "&gt;")
15085
- .replace(/"/g, "&quot;")
15086
- .replace(/'/g, "&#39;");
14939
+ createElement(tag, className, text) {
14940
+ const el = document.createElement(tag);
14941
+ if (className)
14942
+ el.className = className;
14943
+ if (text !== undefined)
14944
+ el.textContent = text;
14945
+ return el;
14946
+ }
14947
+ appendTextElement(parent, tag, className, text) {
14948
+ const el = this.createElement(tag, className, text);
14949
+ parent.appendChild(el);
14950
+ return el;
14951
+ }
14952
+ buildModalShell(icon, title) {
14953
+ const overlay = this.createElement("div", "poofnet-modal-overlay");
14954
+ const content = this.createElement("div", "poofnet-modal-content");
14955
+ overlay.appendChild(content);
14956
+ const close = this.createElement("button", "poofnet-close-btn", "×");
14957
+ close.id = "poofnet-close-btn";
14958
+ close.setAttribute("aria-label", "Close");
14959
+ close.type = "button";
14960
+ content.appendChild(close);
14961
+ const header = this.createElement("div", "poofnet-modal-header");
14962
+ this.appendTextElement(header, "div", "poofnet-modal-icon", icon);
14963
+ this.appendTextElement(header, "h2", "poofnet-modal-title", title);
14964
+ this.appendTextElement(header, "p", "poofnet-modal-subtitle", "Poofnet Simulated Blockchain");
14965
+ content.appendChild(header);
14966
+ const body = this.createElement("div", "poofnet-modal-body");
14967
+ content.appendChild(body);
14968
+ const footer = this.createElement("div", "poofnet-modal-footer");
14969
+ content.appendChild(footer);
14970
+ return { overlay, body, footer };
14971
+ }
14972
+ buildInfoBox(text, warning = false) {
14973
+ const info = this.createElement("div", "poofnet-info-box");
14974
+ if (warning)
14975
+ info.style.background = "#fef3c7";
14976
+ this.appendTextElement(info, "span", "poofnet-info-icon", "ℹ️");
14977
+ const infoText = this.createElement("span", "poofnet-info-text", text);
14978
+ if (warning)
14979
+ infoText.style.color = "#92400e";
14980
+ info.appendChild(infoText);
14981
+ return info;
14982
+ }
14983
+ buildUnsupportedModalContent() {
14984
+ const { overlay, body, footer } = this.buildModalShell("⚠️", "Transaction Not Supported");
14985
+ body.appendChild(this.buildInfoBox("Poofnet is a simulated blockchain and does not support real Solana transactions. Deploy your project to mainnet to test real transactions.", true));
14986
+ const close = this.createElement("button", "poofnet-btn poofnet-btn-cancel", "Close");
14987
+ close.id = "poofnet-cancel-btn";
14988
+ close.type = "button";
14989
+ close.style.flex = "1";
14990
+ footer.appendChild(close);
14991
+ return overlay;
15087
14992
  }
15088
14993
  formatPath(path) {
15089
14994
  const parts = path.split("/").filter(Boolean);
@@ -15116,59 +15021,11 @@ class OffchainAuthProvider {
15116
15021
  return `Delete from ${collection}`;
15117
15022
  return isNew ? `Create in ${collection}` : `Update ${collection}`;
15118
15023
  }
15119
- getModalHTML(parsed, rawMessage) {
15024
+ buildTransactionModalContent(parsed, rawMessage) {
15120
15025
  const instructions = parsed.instructions || [];
15121
15026
  // Group instructions by type for summary
15122
15027
  const sets = instructions.filter((i) => i.type === "set");
15123
15028
  const deletes = instructions.filter((i) => i.type === "delete");
15124
- const instructionsList = instructions
15125
- .map((inst) => {
15126
- const { collection, documentId } = this.formatPath(inst.path);
15127
- const isDelete = inst.type === "delete";
15128
- const icon = isDelete ? "🗑️" : "✏️";
15129
- const actionClass = isDelete
15130
- ? "poofnet-action-delete"
15131
- : "poofnet-action-set";
15132
- // Format data fields for display
15133
- let fieldsHtml = "";
15134
- if (inst.data && !isDelete) {
15135
- const fields = Object.entries(inst.data)
15136
- .filter(([key]) => !key.startsWith("_")) // Hide internal fields
15137
- .slice(0, 4);
15138
- if (fields.length > 0) {
15139
- fieldsHtml = `
15140
- <div class="poofnet-fields">
15141
- ${fields
15142
- .map(([key, value]) => `
15143
- <div class="poofnet-field">
15144
- <span class="poofnet-field-key">${this.escapeHtml(key)}:</span>
15145
- <span class="poofnet-field-value">${this.escapeHtml(this.formatFieldValue(value))}</span>
15146
- </div>
15147
- `)
15148
- .join("")}
15149
- ${Object.keys(inst.data).filter((k) => !k.startsWith("_"))
15150
- .length > 4
15151
- ? `<div class="poofnet-field-more">+${Object.keys(inst.data).filter((k) => !k.startsWith("_")).length - 4} more fields</div>`
15152
- : ""}
15153
- </div>
15154
- `;
15155
- }
15156
- }
15157
- return `
15158
- <div class="poofnet-instruction ${actionClass}">
15159
- <div class="poofnet-instruction-header">
15160
- <span class="poofnet-instruction-icon">${icon}</span>
15161
- <span class="poofnet-instruction-action">${isDelete ? "Delete" : "Save"}</span>
15162
- <span class="poofnet-instruction-collection">${this.escapeHtml(collection)}</span>
15163
- </div>
15164
- ${documentId
15165
- ? `<div class="poofnet-instruction-id">ID: ${this.escapeHtml(documentId)}</div>`
15166
- : ""}
15167
- ${fieldsHtml}
15168
- </div>
15169
- `;
15170
- })
15171
- .join("");
15172
15029
  // Create summary text
15173
15030
  let summaryText = "";
15174
15031
  if (sets.length > 0 && deletes.length > 0) {
@@ -15180,50 +15037,65 @@ class OffchainAuthProvider {
15180
15037
  else if (deletes.length > 0) {
15181
15038
  summaryText = `${deletes.length} delete${deletes.length > 1 ? "s" : ""}`;
15182
15039
  }
15183
- return `
15184
- <div class="poofnet-modal-overlay">
15185
- <div class="poofnet-modal-content">
15186
- <button id="poofnet-close-btn" class="poofnet-close-btn" aria-label="Close">
15187
- <svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
15188
- <path d="M1 1L13 13M1 13L13 1" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
15189
- </svg>
15190
- </button>
15191
- <div class="poofnet-modal-header">
15192
- <div class="poofnet-modal-icon">🔐</div>
15193
- <h2 class="poofnet-modal-title">Confirm Transaction</h2>
15194
- <p class="poofnet-modal-subtitle">Poofnet Simulated Blockchain</p>
15195
- </div>
15196
-
15197
- <div class="poofnet-modal-body">
15198
- ${instructions.length > 0
15199
- ? `
15200
- ${summaryText
15201
- ? `<div class="poofnet-summary">${summaryText}</div>`
15202
- : ""}
15203
- <div class="poofnet-instructions-list">
15204
- ${instructionsList}
15205
- </div>
15206
- `
15207
- : `
15208
- <div class="poofnet-section">
15209
- <h3 class="poofnet-section-title">Message</h3>
15210
- <pre class="poofnet-raw-message">${this.escapeHtml(rawMessage.slice(0, 200))}${rawMessage.length > 200 ? "..." : ""}</pre>
15211
- </div>
15212
- `}
15213
-
15214
- <div class="poofnet-info-box">
15215
- <span class="poofnet-info-icon">ℹ️</span>
15216
- <span class="poofnet-info-text">This is a simulated transaction. No real fees will be charged.</span>
15217
- </div>
15218
- </div>
15219
-
15220
- <div class="poofnet-modal-footer">
15221
- <button id="poofnet-cancel-btn" class="poofnet-btn poofnet-btn-cancel">Cancel</button>
15222
- <button id="poofnet-confirm-btn" class="poofnet-btn poofnet-btn-confirm">Confirm</button>
15223
- </div>
15224
- </div>
15225
- </div>
15226
- `;
15040
+ const { overlay, body, footer } = this.buildModalShell("🔐", "Confirm Transaction");
15041
+ if (instructions.length > 0) {
15042
+ if (summaryText) {
15043
+ this.appendTextElement(body, "div", "poofnet-summary", summaryText);
15044
+ }
15045
+ const list = this.createElement("div", "poofnet-instructions-list");
15046
+ for (const inst of instructions) {
15047
+ list.appendChild(this.buildInstructionElement(inst));
15048
+ }
15049
+ body.appendChild(list);
15050
+ }
15051
+ else {
15052
+ const section = this.createElement("div", "poofnet-section");
15053
+ this.appendTextElement(section, "h3", "poofnet-section-title", "Message");
15054
+ const raw = this.createElement("pre", "poofnet-raw-message", rawMessage.slice(0, 200) + (rawMessage.length > 200 ? "..." : ""));
15055
+ section.appendChild(raw);
15056
+ body.appendChild(section);
15057
+ }
15058
+ body.appendChild(this.buildInfoBox("This is a simulated transaction. No real fees will be charged."));
15059
+ const cancel = this.createElement("button", "poofnet-btn poofnet-btn-cancel", "Cancel");
15060
+ cancel.id = "poofnet-cancel-btn";
15061
+ cancel.type = "button";
15062
+ footer.appendChild(cancel);
15063
+ const confirm = this.createElement("button", "poofnet-btn poofnet-btn-confirm", "Confirm");
15064
+ confirm.id = "poofnet-confirm-btn";
15065
+ confirm.type = "button";
15066
+ footer.appendChild(confirm);
15067
+ return overlay;
15068
+ }
15069
+ buildInstructionElement(inst) {
15070
+ const { collection, documentId } = this.formatPath(inst.path);
15071
+ const isDelete = inst.type === "delete";
15072
+ const card = this.createElement("div", `poofnet-instruction ${isDelete ? "poofnet-action-delete" : "poofnet-action-set"}`);
15073
+ const header = this.createElement("div", "poofnet-instruction-header");
15074
+ this.appendTextElement(header, "span", "poofnet-instruction-icon", isDelete ? "🗑️" : "✏️");
15075
+ this.appendTextElement(header, "span", "poofnet-instruction-action", isDelete ? "Delete" : "Save");
15076
+ this.appendTextElement(header, "span", "poofnet-instruction-collection", collection);
15077
+ card.appendChild(header);
15078
+ if (documentId) {
15079
+ this.appendTextElement(card, "div", "poofnet-instruction-id", `ID: ${documentId}`);
15080
+ }
15081
+ if (inst.data && !isDelete) {
15082
+ const fieldKeys = Object.keys(inst.data).filter((key) => !key.startsWith("_"));
15083
+ const visibleFields = fieldKeys.slice(0, 4);
15084
+ if (visibleFields.length > 0) {
15085
+ const fields = this.createElement("div", "poofnet-fields");
15086
+ for (const key of visibleFields) {
15087
+ const row = this.createElement("div", "poofnet-field");
15088
+ this.appendTextElement(row, "span", "poofnet-field-key", `${key}:`);
15089
+ this.appendTextElement(row, "span", "poofnet-field-value", this.formatFieldValue(inst.data[key]));
15090
+ fields.appendChild(row);
15091
+ }
15092
+ if (fieldKeys.length > 4) {
15093
+ this.appendTextElement(fields, "div", "poofnet-field-more", `+${fieldKeys.length - 4} more fields`);
15094
+ }
15095
+ card.appendChild(fields);
15096
+ }
15097
+ }
15098
+ return card;
15227
15099
  }
15228
15100
  getModalStyles() {
15229
15101
  return `
@@ -18559,9 +18431,7 @@ const emailProviderSingleton = new EmailAuthProvider();
18559
18431
  function openEmailModal() {
18560
18432
  return new Promise((resolve) => {
18561
18433
  var _a;
18562
- const root = document.createElement('div');
18563
- root.id = 'bounded-auth-modal';
18564
- root.innerHTML = MODAL_HTML;
18434
+ const root = createEmailModalTree();
18565
18435
  const style = document.createElement('style');
18566
18436
  style.textContent = MODAL_CSS;
18567
18437
  root.appendChild(style);
@@ -18649,26 +18519,97 @@ function openEmailModal() {
18649
18519
  });
18650
18520
  });
18651
18521
  }
18652
- const MODAL_HTML = `
18653
- <div class="ba-overlay">
18654
- <div class="ba-card" role="dialog" aria-modal="true" aria-label="Sign in">
18655
- <button id="ba-close" class="ba-x" aria-label="Close">&times;</button>
18656
- <div class="ba-brand"><span class="ba-dot"></span> Sign in</div>
18657
- <div id="ba-email-step">
18658
- <label class="ba-label" for="ba-email">Email</label>
18659
- <input id="ba-email" class="ba-input" type="email" inputmode="email" autocomplete="email" placeholder="you@example.com" />
18660
- <button id="ba-email-btn" class="ba-btn">Continue</button>
18661
- </div>
18662
- <div id="ba-otp-step" class="hidden">
18663
- <label class="ba-label" for="ba-otp">Enter the code sent to <span id="ba-sent-to" class="ba-em"></span></label>
18664
- <input id="ba-otp" class="ba-input ba-code" inputmode="numeric" autocomplete="one-time-code" maxlength="8" placeholder="······" />
18665
- <button id="ba-otp-btn" class="ba-btn">Verify &amp; continue</button>
18666
- <button id="ba-back" class="ba-link">Use a different email</button>
18667
- </div>
18668
- <div id="ba-msg" class="ba-msg"></div>
18669
- <div class="ba-foot">Secured by Bounded</div>
18670
- </div>
18671
- </div>`;
18522
+ function createEmailModalTree() {
18523
+ const root = document.createElement('div');
18524
+ root.id = 'bounded-auth-modal';
18525
+ const overlay = document.createElement('div');
18526
+ overlay.className = 'ba-overlay';
18527
+ root.appendChild(overlay);
18528
+ const card = document.createElement('div');
18529
+ card.className = 'ba-card';
18530
+ card.setAttribute('role', 'dialog');
18531
+ card.setAttribute('aria-modal', 'true');
18532
+ card.setAttribute('aria-label', 'Sign in');
18533
+ overlay.appendChild(card);
18534
+ const close = document.createElement('button');
18535
+ close.id = 'ba-close';
18536
+ close.className = 'ba-x';
18537
+ close.setAttribute('aria-label', 'Close');
18538
+ close.type = 'button';
18539
+ close.textContent = '×';
18540
+ card.appendChild(close);
18541
+ const brand = document.createElement('div');
18542
+ brand.className = 'ba-brand';
18543
+ const dot = document.createElement('span');
18544
+ dot.className = 'ba-dot';
18545
+ brand.appendChild(dot);
18546
+ brand.appendChild(document.createTextNode(' Sign in'));
18547
+ card.appendChild(brand);
18548
+ const emailStep = document.createElement('div');
18549
+ emailStep.id = 'ba-email-step';
18550
+ card.appendChild(emailStep);
18551
+ const emailLabel = document.createElement('label');
18552
+ emailLabel.className = 'ba-label';
18553
+ emailLabel.htmlFor = 'ba-email';
18554
+ emailLabel.textContent = 'Email';
18555
+ emailStep.appendChild(emailLabel);
18556
+ const emailInput = document.createElement('input');
18557
+ emailInput.id = 'ba-email';
18558
+ emailInput.className = 'ba-input';
18559
+ emailInput.type = 'email';
18560
+ emailInput.inputMode = 'email';
18561
+ emailInput.autocomplete = 'email';
18562
+ emailInput.placeholder = 'you@example.com';
18563
+ emailStep.appendChild(emailInput);
18564
+ const emailButton = document.createElement('button');
18565
+ emailButton.id = 'ba-email-btn';
18566
+ emailButton.className = 'ba-btn';
18567
+ emailButton.type = 'button';
18568
+ emailButton.textContent = 'Continue';
18569
+ emailStep.appendChild(emailButton);
18570
+ const otpStep = document.createElement('div');
18571
+ otpStep.id = 'ba-otp-step';
18572
+ otpStep.className = 'hidden';
18573
+ card.appendChild(otpStep);
18574
+ const otpLabel = document.createElement('label');
18575
+ otpLabel.className = 'ba-label';
18576
+ otpLabel.htmlFor = 'ba-otp';
18577
+ otpLabel.appendChild(document.createTextNode('Enter the code sent to '));
18578
+ const sentTo = document.createElement('span');
18579
+ sentTo.id = 'ba-sent-to';
18580
+ sentTo.className = 'ba-em';
18581
+ otpLabel.appendChild(sentTo);
18582
+ otpStep.appendChild(otpLabel);
18583
+ const otpInput = document.createElement('input');
18584
+ otpInput.id = 'ba-otp';
18585
+ otpInput.className = 'ba-input ba-code';
18586
+ otpInput.inputMode = 'numeric';
18587
+ otpInput.autocomplete = 'one-time-code';
18588
+ otpInput.maxLength = 8;
18589
+ otpInput.placeholder = '······';
18590
+ otpStep.appendChild(otpInput);
18591
+ const otpButton = document.createElement('button');
18592
+ otpButton.id = 'ba-otp-btn';
18593
+ otpButton.className = 'ba-btn';
18594
+ otpButton.type = 'button';
18595
+ otpButton.textContent = 'Verify & continue';
18596
+ otpStep.appendChild(otpButton);
18597
+ const backButton = document.createElement('button');
18598
+ backButton.id = 'ba-back';
18599
+ backButton.className = 'ba-link';
18600
+ backButton.type = 'button';
18601
+ backButton.textContent = 'Use a different email';
18602
+ otpStep.appendChild(backButton);
18603
+ const msg = document.createElement('div');
18604
+ msg.id = 'ba-msg';
18605
+ msg.className = 'ba-msg';
18606
+ card.appendChild(msg);
18607
+ const foot = document.createElement('div');
18608
+ foot.className = 'ba-foot';
18609
+ foot.textContent = 'Secured by Bounded';
18610
+ card.appendChild(foot);
18611
+ return root;
18612
+ }
18672
18613
  const MODAL_CSS = `
18673
18614
  #bounded-auth-modal .ba-overlay{position:fixed;inset:0;background:rgba(8,10,18,.62);backdrop-filter:blur(4px);
18674
18615
  display:flex;align-items:center;justify-content:center;z-index:2147483000;opacity:1;transition:opacity .16s ease;
@@ -21406,7 +21347,7 @@ async function awaitSignInGestureAndSign(theme, signFn, noResultError = 'MWA ret
21406
21347
  ].join('; ');
21407
21348
  const closeBtn = document.createElement('button');
21408
21349
  closeBtn.setAttribute('aria-label', 'Close');
21409
- closeBtn.textContent = '×'; // × (multiplication sign), set via textContent to avoid any innerHTML usage
21350
+ closeBtn.textContent = '×';
21410
21351
  closeBtn.style.cssText = [
21411
21352
  'position: absolute',
21412
21353
  'top: 12px',