@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.
- package/dist/auth/providers/offchain-auth-provider.d.ts +7 -13
- package/dist/index.js +226 -285
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +226 -285
- package/dist/index.mjs.map +1 -1
- package/dist/{index.native-BYEVhmbt.mjs → index.native-CAygEkU7.mjs} +229 -288
- package/dist/index.native-CAygEkU7.mjs.map +1 -0
- package/dist/{index.native-CcBTbnBg.js → index.native-zD2ZzCLO.js} +229 -288
- package/dist/index.native-zD2ZzCLO.js.map +1 -0
- package/dist/index.native.js +1 -1
- package/dist/index.native.mjs +1 -1
- package/dist/{phantom-wallet-provider-D_AzfLq0.mjs → phantom-wallet-provider-DU4WPFPM.mjs} +2 -2
- package/dist/{phantom-wallet-provider-D_AzfLq0.mjs.map → phantom-wallet-provider-DU4WPFPM.mjs.map} +1 -1
- package/dist/{phantom-wallet-provider-Cn6MzUUo.js → phantom-wallet-provider-MW2H0SFY.js} +2 -2
- package/dist/{phantom-wallet-provider-Cn6MzUUo.js.map → phantom-wallet-provider-MW2H0SFY.js.map} +1 -1
- package/dist/{privy-wallet-provider-AC4xL6bN.mjs → privy-wallet-provider-D5Kdp3Qp.mjs} +3 -3
- package/dist/{privy-wallet-provider-AC4xL6bN.mjs.map → privy-wallet-provider-D5Kdp3Qp.mjs.map} +1 -1
- package/dist/{privy-wallet-provider-DtWAtbUl.js → privy-wallet-provider-dFxuvDf4.js} +3 -3
- package/dist/{privy-wallet-provider-DtWAtbUl.js.map → privy-wallet-provider-dFxuvDf4.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-X6BM07gm.mjs → solana-mobile-wallet-provider-CLiflgPj.mjs} +3 -3
- package/dist/solana-mobile-wallet-provider-CLiflgPj.mjs.map +1 -0
- package/dist/{solana-mobile-wallet-provider-Cos9gu7k.js → solana-mobile-wallet-provider-DAR0BLTQ.js} +3 -3
- package/dist/solana-mobile-wallet-provider-DAR0BLTQ.js.map +1 -0
- package/package.json +2 -2
- package/dist/index.native-BYEVhmbt.mjs.map +0 -1
- package/dist/index.native-CcBTbnBg.js.map +0 -1
- package/dist/solana-mobile-wallet-provider-Cos9gu7k.js.map +0 -1
- package/dist/solana-mobile-wallet-provider-X6BM07gm.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -10176,24 +10176,19 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
10176
10176
|
/* ------------------------------------------------------------------ */
|
|
10177
10177
|
/* ENV helpers */
|
|
10178
10178
|
/* ------------------------------------------------------------------ */
|
|
10179
|
-
// Canonical `BOUNDED_PRIVATE_KEY` (matches the CLI)
|
|
10180
|
-
//
|
|
10181
|
-
|
|
10182
|
-
const
|
|
10179
|
+
// Canonical `BOUNDED_PRIVATE_KEY` (matches the CLI). Only consulted when no
|
|
10180
|
+
// explicit keypair was provided (createWalletClient passes one).
|
|
10181
|
+
const ENV_KEYPAIR = "BOUNDED_PRIVATE_KEY";
|
|
10182
|
+
const LEGACY_ENV_KEYPAIR = "BOUNDED_SOLANA_KEYPAIR";
|
|
10183
10183
|
function loadKeypairFromEnv() {
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
|
|
10187
|
-
const v = process.env[name];
|
|
10188
|
-
if (v) {
|
|
10189
|
-
secret = v;
|
|
10190
|
-
found = name;
|
|
10191
|
-
break;
|
|
10192
|
-
}
|
|
10184
|
+
if (process.env[LEGACY_ENV_KEYPAIR]) {
|
|
10185
|
+
throw new Error(`${LEGACY_ENV_KEYPAIR} is no longer supported. Set ${ENV_KEYPAIR} instead, ` +
|
|
10186
|
+
`or pass an explicit keypair via createWalletClient({ keypair }).`);
|
|
10193
10187
|
}
|
|
10188
|
+
const secret = process.env[ENV_KEYPAIR];
|
|
10194
10189
|
if (!secret) {
|
|
10195
10190
|
throw new Error(`No server keypair for this top-level call. The top-level get/set/subscribe/etc. use an ` +
|
|
10196
|
-
`AMBIENT session — set ${
|
|
10191
|
+
`AMBIENT session — set ${ENV_KEYPAIR} to a base-58 secret key (or JSON array) to provide one. ` +
|
|
10197
10192
|
`If you already created a wallet with createWalletClient({ keypair }), call ITS methods instead ` +
|
|
10198
10193
|
`(client.subscribe / client.set / client.get): that client is self-contained and deliberately does ` +
|
|
10199
10194
|
`not set the ambient session, so the top-level functions can't see it.`);
|
|
@@ -10205,7 +10200,7 @@ function loadKeypairFromEnv() {
|
|
|
10205
10200
|
return web3_js.Keypair.fromSecretKey(secretKey);
|
|
10206
10201
|
}
|
|
10207
10202
|
catch (err) {
|
|
10208
|
-
throw new Error(`Unable to parse ${
|
|
10203
|
+
throw new Error(`Unable to parse ${ENV_KEYPAIR}. Ensure it is valid base-58 or JSON.`);
|
|
10209
10204
|
}
|
|
10210
10205
|
}
|
|
10211
10206
|
/* ------------------------------------------------------------------ */
|
|
@@ -10272,7 +10267,7 @@ class ServerSessionManager {
|
|
|
10272
10267
|
this.session = session;
|
|
10273
10268
|
}
|
|
10274
10269
|
/* ---------------------------------------------- *
|
|
10275
|
-
* CLEAR (e.g. after logout
|
|
10270
|
+
* CLEAR (e.g. after explicit logout)
|
|
10276
10271
|
* ---------------------------------------------- */
|
|
10277
10272
|
clearSession() {
|
|
10278
10273
|
this.session = null;
|
|
@@ -10296,11 +10291,6 @@ class ServerSessionManager {
|
|
|
10296
10291
|
/* The default singleton instance (reads keypair from env) */
|
|
10297
10292
|
ServerSessionManager.instance = new ServerSessionManager();
|
|
10298
10293
|
|
|
10299
|
-
var serverSessionManager = /*#__PURE__*/Object.freeze({
|
|
10300
|
-
__proto__: null,
|
|
10301
|
-
ServerSessionManager: ServerSessionManager
|
|
10302
|
-
});
|
|
10303
|
-
|
|
10304
10294
|
/**
|
|
10305
10295
|
* Safe base64 helpers for bounded-core.
|
|
10306
10296
|
*
|
|
@@ -10525,13 +10515,6 @@ async function refreshAuthSessionOnce(appId, isServer) {
|
|
|
10525
10515
|
async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
10526
10516
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
10527
10517
|
const config = await getConfig();
|
|
10528
|
-
let hasRetriedAfterServerSessionReset = false;
|
|
10529
|
-
const clearServerSession = async () => {
|
|
10530
|
-
if (!config.isServer)
|
|
10531
|
-
return;
|
|
10532
|
-
const { ServerSessionManager } = await Promise.resolve().then(function () { return serverSessionManager; });
|
|
10533
|
-
ServerSessionManager.instance.clearSession();
|
|
10534
|
-
};
|
|
10535
10518
|
async function executeRequest() {
|
|
10536
10519
|
var _a;
|
|
10537
10520
|
// When _getAuthHeaders is provided (wallet client), use it as the sole auth source.
|
|
@@ -10581,13 +10564,7 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
10581
10564
|
}
|
|
10582
10565
|
return await executeRequest();
|
|
10583
10566
|
}
|
|
10584
|
-
catch (
|
|
10585
|
-
// Server-side fallback: clear global session and retry once
|
|
10586
|
-
if (config.isServer && !hasRetriedAfterServerSessionReset) {
|
|
10587
|
-
hasRetriedAfterServerSessionReset = true;
|
|
10588
|
-
await clearServerSession();
|
|
10589
|
-
return await executeRequest();
|
|
10590
|
-
}
|
|
10567
|
+
catch (_j) {
|
|
10591
10568
|
throw error;
|
|
10592
10569
|
}
|
|
10593
10570
|
}
|
|
@@ -11147,39 +11124,8 @@ async function get(path, opts = {}) {
|
|
|
11147
11124
|
}
|
|
11148
11125
|
// Create a new request promise and store it
|
|
11149
11126
|
const requestPromise = (async () => {
|
|
11150
|
-
var _a;
|
|
11151
11127
|
try {
|
|
11152
|
-
// For realtime chains, prefer WebSocket reads (lower latency, already connected)
|
|
11153
|
-
const config = await getConfig();
|
|
11154
11128
|
const pathIsDocument = normalizedPath.split("/").length % 2 === 0;
|
|
11155
|
-
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) {
|
|
11156
|
-
try {
|
|
11157
|
-
const { wsGet, wsQuery, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
|
|
11158
|
-
if (hasActiveConnection()) {
|
|
11159
|
-
if (pathIsDocument) {
|
|
11160
|
-
const wsResult = await wsGet(normalizedPath);
|
|
11161
|
-
const responseData = normalizeReadResult(wsResult, true);
|
|
11162
|
-
if (!opts.bypassCache) {
|
|
11163
|
-
getCache[cacheKey] = { data: responseData, expiresAt: now + GET_CACHE_TTL };
|
|
11164
|
-
}
|
|
11165
|
-
return responseData;
|
|
11166
|
-
}
|
|
11167
|
-
else if (!opts.limit) {
|
|
11168
|
-
const wsResult = await wsQuery(normalizedPath, {
|
|
11169
|
-
filter: undefined,
|
|
11170
|
-
sort: undefined,
|
|
11171
|
-
includeSubPaths: opts.includeSubPaths,
|
|
11172
|
-
});
|
|
11173
|
-
const responseData = normalizeReadResult(wsResult, false);
|
|
11174
|
-
if (!opts.bypassCache) {
|
|
11175
|
-
getCache[cacheKey] = { data: responseData, expiresAt: now + GET_CACHE_TTL };
|
|
11176
|
-
}
|
|
11177
|
-
return responseData;
|
|
11178
|
-
}
|
|
11179
|
-
}
|
|
11180
|
-
}
|
|
11181
|
-
catch ( /* fall through to HTTP */_b) { /* fall through to HTTP */ }
|
|
11182
|
-
}
|
|
11183
11129
|
// Cache miss or bypass - proceed with HTTP API request
|
|
11184
11130
|
let response;
|
|
11185
11131
|
// Build common query params
|
|
@@ -11432,7 +11378,7 @@ async function set(path, document, options) {
|
|
|
11432
11378
|
return result;
|
|
11433
11379
|
}
|
|
11434
11380
|
async function setMany(many, options) {
|
|
11435
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
11381
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
11436
11382
|
// Returns the data that was set, or undefined if the document was already set.
|
|
11437
11383
|
try {
|
|
11438
11384
|
const config = await getConfig();
|
|
@@ -11469,40 +11415,13 @@ async function setMany(many, options) {
|
|
|
11469
11415
|
}
|
|
11470
11416
|
let setResponse;
|
|
11471
11417
|
try {
|
|
11472
|
-
|
|
11473
|
-
const useWs = ((_c = config.chain) === null || _c === void 0 ? void 0 : _c.startsWith('realtime_')) && !config.isServer;
|
|
11474
|
-
if (useWs) {
|
|
11475
|
-
try {
|
|
11476
|
-
const { wsSet, hasActiveConnection } = await Promise.resolve().then(function () { return subscriptionV2; });
|
|
11477
|
-
if (hasActiveConnection()) {
|
|
11478
|
-
// Connection is active — send via WS. If this throws, the write
|
|
11479
|
-
// may have been applied server-side (ack lost). Do NOT fall through
|
|
11480
|
-
// to HTTP, as that would double-apply non-idempotent ops (Increment).
|
|
11481
|
-
const wsResult = await wsSet(documents);
|
|
11482
|
-
setResponse = { data: wsResult, status: 200 };
|
|
11483
|
-
}
|
|
11484
|
-
}
|
|
11485
|
-
catch (wsError) {
|
|
11486
|
-
// Only fall through to HTTP if the request was never sent (connection not available).
|
|
11487
|
-
// If the request was sent and ack was lost (timeout), the server may have
|
|
11488
|
-
// applied it — re-sending via HTTP risks double-write for non-idempotent ops.
|
|
11489
|
-
const msg = (_d = wsError === null || wsError === void 0 ? void 0 : wsError.message) !== null && _d !== void 0 ? _d : '';
|
|
11490
|
-
const neverSent = msg.includes('not available') || msg.includes('connection timeout');
|
|
11491
|
-
if (!neverSent) {
|
|
11492
|
-
throw wsError;
|
|
11493
|
-
}
|
|
11494
|
-
// Safe to retry via HTTP — request was never sent
|
|
11495
|
-
}
|
|
11496
|
-
}
|
|
11497
|
-
if (!setResponse) {
|
|
11498
|
-
setResponse = await makeApiRequest('PUT', `items`, { documents }, options === null || options === void 0 ? void 0 : options._overrides);
|
|
11499
|
-
}
|
|
11418
|
+
setResponse = await makeApiRequest('PUT', `items`, { documents }, options === null || options === void 0 ? void 0 : options._overrides);
|
|
11500
11419
|
}
|
|
11501
11420
|
catch (error) {
|
|
11502
11421
|
if ((error === null || error === void 0 ? void 0 : error.statusCode) === 402 && (error === null || error === void 0 ? void 0 : error.error) === 'INSUFFICIENT_BALANCE') {
|
|
11503
|
-
const deficitLamports = Number((
|
|
11504
|
-
const deficitSol = Number((
|
|
11505
|
-
throw new InsufficientBalanceError(String((
|
|
11422
|
+
const deficitLamports = Number((_c = error.deficitLamports) !== null && _c !== void 0 ? _c : 0);
|
|
11423
|
+
const deficitSol = Number((_d = error.deficitSol) !== null && _d !== void 0 ? _d : deficitLamports / 1000000000);
|
|
11424
|
+
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);
|
|
11506
11425
|
}
|
|
11507
11426
|
throw error;
|
|
11508
11427
|
}
|
|
@@ -11549,7 +11468,7 @@ async function setMany(many, options) {
|
|
|
11549
11468
|
else if (setResponse.data &&
|
|
11550
11469
|
typeof setResponse.data === 'object' &&
|
|
11551
11470
|
setResponse.data.success === true) {
|
|
11552
|
-
const
|
|
11471
|
+
const _h = setResponse.data, { success: _success } = _h, rest = __rest$1(_h, ["success"]);
|
|
11553
11472
|
return Object.assign(Object.assign(Object.assign({}, documents.map(d => d.document)), rest), { transactionId: null });
|
|
11554
11473
|
}
|
|
11555
11474
|
else {
|
|
@@ -13077,23 +12996,6 @@ async function wsGetMany(paths) {
|
|
|
13077
12996
|
}));
|
|
13078
12997
|
}
|
|
13079
12998
|
|
|
13080
|
-
var subscriptionV2 = /*#__PURE__*/Object.freeze({
|
|
13081
|
-
__proto__: null,
|
|
13082
|
-
clearCacheV2: clearCacheV2,
|
|
13083
|
-
closeAllSubscriptionsV2: closeAllSubscriptionsV2,
|
|
13084
|
-
getCachedDataV2: getCachedDataV2,
|
|
13085
|
-
hasActiveConnection: hasActiveConnection,
|
|
13086
|
-
reconnectWithNewAuthV2: reconnectWithNewAuthV2,
|
|
13087
|
-
subscribeV2: subscribeV2,
|
|
13088
|
-
wsDelete: wsDelete,
|
|
13089
|
-
wsGet: wsGet,
|
|
13090
|
-
wsGetMany: wsGetMany,
|
|
13091
|
-
wsIntent: wsIntent,
|
|
13092
|
-
wsIntentReliable: wsIntentReliable,
|
|
13093
|
-
wsQuery: wsQuery,
|
|
13094
|
-
wsSet: wsSet
|
|
13095
|
-
});
|
|
13096
|
-
|
|
13097
12999
|
/**
|
|
13098
13000
|
* WebSocket Subscription Module
|
|
13099
13001
|
*
|
|
@@ -14904,7 +14806,7 @@ class OffchainAuthProvider {
|
|
|
14904
14806
|
// Create modal container
|
|
14905
14807
|
this.modalContainer = document.createElement("div");
|
|
14906
14808
|
this.modalContainer.id = "poofnet-unsupported-modal";
|
|
14907
|
-
this.modalContainer.
|
|
14809
|
+
this.modalContainer.appendChild(this.buildUnsupportedModalContent());
|
|
14908
14810
|
document.body.appendChild(this.modalContainer);
|
|
14909
14811
|
// Add styles
|
|
14910
14812
|
const style = document.createElement("style");
|
|
@@ -14960,38 +14862,6 @@ class OffchainAuthProvider {
|
|
|
14960
14862
|
document.addEventListener("keydown", escHandler);
|
|
14961
14863
|
});
|
|
14962
14864
|
}
|
|
14963
|
-
getUnsupportedModalHTML() {
|
|
14964
|
-
return `
|
|
14965
|
-
<div class="poofnet-modal-overlay">
|
|
14966
|
-
<div class="poofnet-modal-content">
|
|
14967
|
-
<button id="poofnet-close-btn" class="poofnet-close-btn" aria-label="Close">
|
|
14968
|
-
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
14969
|
-
<path d="M1 1L13 13M1 13L13 1" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
14970
|
-
</svg>
|
|
14971
|
-
</button>
|
|
14972
|
-
<div class="poofnet-modal-header">
|
|
14973
|
-
<div class="poofnet-modal-icon">⚠️</div>
|
|
14974
|
-
<h2 class="poofnet-modal-title">Transaction Not Supported</h2>
|
|
14975
|
-
<p class="poofnet-modal-subtitle">Poofnet Simulated Blockchain</p>
|
|
14976
|
-
</div>
|
|
14977
|
-
|
|
14978
|
-
<div class="poofnet-modal-body">
|
|
14979
|
-
<div class="poofnet-info-box" style="background: #fef3c7;">
|
|
14980
|
-
<span class="poofnet-info-icon">ℹ️</span>
|
|
14981
|
-
<span class="poofnet-info-text" style="color: #92400e;">
|
|
14982
|
-
Poofnet is a simulated blockchain and does not support real Solana transactions.
|
|
14983
|
-
Deploy your project to mainnet to test real transactions.
|
|
14984
|
-
</span>
|
|
14985
|
-
</div>
|
|
14986
|
-
</div>
|
|
14987
|
-
|
|
14988
|
-
<div class="poofnet-modal-footer">
|
|
14989
|
-
<button id="poofnet-cancel-btn" class="poofnet-btn poofnet-btn-cancel" style="flex: 1;">Close</button>
|
|
14990
|
-
</div>
|
|
14991
|
-
</div>
|
|
14992
|
-
</div>
|
|
14993
|
-
`;
|
|
14994
|
-
}
|
|
14995
14865
|
async showTransactionModal(message) {
|
|
14996
14866
|
return new Promise((resolve) => {
|
|
14997
14867
|
// Parse the transaction message for display
|
|
@@ -15005,7 +14875,7 @@ class OffchainAuthProvider {
|
|
|
15005
14875
|
// Create modal container
|
|
15006
14876
|
this.modalContainer = document.createElement("div");
|
|
15007
14877
|
this.modalContainer.id = "poofnet-tx-modal";
|
|
15008
|
-
this.modalContainer.
|
|
14878
|
+
this.modalContainer.appendChild(this.buildTransactionModalContent(parsed, message));
|
|
15009
14879
|
document.body.appendChild(this.modalContainer);
|
|
15010
14880
|
// Add styles
|
|
15011
14881
|
const style = document.createElement("style");
|
|
@@ -15088,24 +14958,59 @@ class OffchainAuthProvider {
|
|
|
15088
14958
|
}, 200);
|
|
15089
14959
|
}
|
|
15090
14960
|
}
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15097
|
-
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
|
|
14961
|
+
createElement(tag, className, text) {
|
|
14962
|
+
const el = document.createElement(tag);
|
|
14963
|
+
if (className)
|
|
14964
|
+
el.className = className;
|
|
14965
|
+
if (text !== undefined)
|
|
14966
|
+
el.textContent = text;
|
|
14967
|
+
return el;
|
|
14968
|
+
}
|
|
14969
|
+
appendTextElement(parent, tag, className, text) {
|
|
14970
|
+
const el = this.createElement(tag, className, text);
|
|
14971
|
+
parent.appendChild(el);
|
|
14972
|
+
return el;
|
|
14973
|
+
}
|
|
14974
|
+
buildModalShell(icon, title) {
|
|
14975
|
+
const overlay = this.createElement("div", "poofnet-modal-overlay");
|
|
14976
|
+
const content = this.createElement("div", "poofnet-modal-content");
|
|
14977
|
+
overlay.appendChild(content);
|
|
14978
|
+
const close = this.createElement("button", "poofnet-close-btn", "×");
|
|
14979
|
+
close.id = "poofnet-close-btn";
|
|
14980
|
+
close.setAttribute("aria-label", "Close");
|
|
14981
|
+
close.type = "button";
|
|
14982
|
+
content.appendChild(close);
|
|
14983
|
+
const header = this.createElement("div", "poofnet-modal-header");
|
|
14984
|
+
this.appendTextElement(header, "div", "poofnet-modal-icon", icon);
|
|
14985
|
+
this.appendTextElement(header, "h2", "poofnet-modal-title", title);
|
|
14986
|
+
this.appendTextElement(header, "p", "poofnet-modal-subtitle", "Poofnet Simulated Blockchain");
|
|
14987
|
+
content.appendChild(header);
|
|
14988
|
+
const body = this.createElement("div", "poofnet-modal-body");
|
|
14989
|
+
content.appendChild(body);
|
|
14990
|
+
const footer = this.createElement("div", "poofnet-modal-footer");
|
|
14991
|
+
content.appendChild(footer);
|
|
14992
|
+
return { overlay, body, footer };
|
|
14993
|
+
}
|
|
14994
|
+
buildInfoBox(text, warning = false) {
|
|
14995
|
+
const info = this.createElement("div", "poofnet-info-box");
|
|
14996
|
+
if (warning)
|
|
14997
|
+
info.style.background = "#fef3c7";
|
|
14998
|
+
this.appendTextElement(info, "span", "poofnet-info-icon", "ℹ️");
|
|
14999
|
+
const infoText = this.createElement("span", "poofnet-info-text", text);
|
|
15000
|
+
if (warning)
|
|
15001
|
+
infoText.style.color = "#92400e";
|
|
15002
|
+
info.appendChild(infoText);
|
|
15003
|
+
return info;
|
|
15004
|
+
}
|
|
15005
|
+
buildUnsupportedModalContent() {
|
|
15006
|
+
const { overlay, body, footer } = this.buildModalShell("⚠️", "Transaction Not Supported");
|
|
15007
|
+
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));
|
|
15008
|
+
const close = this.createElement("button", "poofnet-btn poofnet-btn-cancel", "Close");
|
|
15009
|
+
close.id = "poofnet-cancel-btn";
|
|
15010
|
+
close.type = "button";
|
|
15011
|
+
close.style.flex = "1";
|
|
15012
|
+
footer.appendChild(close);
|
|
15013
|
+
return overlay;
|
|
15109
15014
|
}
|
|
15110
15015
|
formatPath(path) {
|
|
15111
15016
|
const parts = path.split("/").filter(Boolean);
|
|
@@ -15138,59 +15043,11 @@ class OffchainAuthProvider {
|
|
|
15138
15043
|
return `Delete from ${collection}`;
|
|
15139
15044
|
return isNew ? `Create in ${collection}` : `Update ${collection}`;
|
|
15140
15045
|
}
|
|
15141
|
-
|
|
15046
|
+
buildTransactionModalContent(parsed, rawMessage) {
|
|
15142
15047
|
const instructions = parsed.instructions || [];
|
|
15143
15048
|
// Group instructions by type for summary
|
|
15144
15049
|
const sets = instructions.filter((i) => i.type === "set");
|
|
15145
15050
|
const deletes = instructions.filter((i) => i.type === "delete");
|
|
15146
|
-
const instructionsList = instructions
|
|
15147
|
-
.map((inst) => {
|
|
15148
|
-
const { collection, documentId } = this.formatPath(inst.path);
|
|
15149
|
-
const isDelete = inst.type === "delete";
|
|
15150
|
-
const icon = isDelete ? "🗑️" : "✏️";
|
|
15151
|
-
const actionClass = isDelete
|
|
15152
|
-
? "poofnet-action-delete"
|
|
15153
|
-
: "poofnet-action-set";
|
|
15154
|
-
// Format data fields for display
|
|
15155
|
-
let fieldsHtml = "";
|
|
15156
|
-
if (inst.data && !isDelete) {
|
|
15157
|
-
const fields = Object.entries(inst.data)
|
|
15158
|
-
.filter(([key]) => !key.startsWith("_")) // Hide internal fields
|
|
15159
|
-
.slice(0, 4);
|
|
15160
|
-
if (fields.length > 0) {
|
|
15161
|
-
fieldsHtml = `
|
|
15162
|
-
<div class="poofnet-fields">
|
|
15163
|
-
${fields
|
|
15164
|
-
.map(([key, value]) => `
|
|
15165
|
-
<div class="poofnet-field">
|
|
15166
|
-
<span class="poofnet-field-key">${this.escapeHtml(key)}:</span>
|
|
15167
|
-
<span class="poofnet-field-value">${this.escapeHtml(this.formatFieldValue(value))}</span>
|
|
15168
|
-
</div>
|
|
15169
|
-
`)
|
|
15170
|
-
.join("")}
|
|
15171
|
-
${Object.keys(inst.data).filter((k) => !k.startsWith("_"))
|
|
15172
|
-
.length > 4
|
|
15173
|
-
? `<div class="poofnet-field-more">+${Object.keys(inst.data).filter((k) => !k.startsWith("_")).length - 4} more fields</div>`
|
|
15174
|
-
: ""}
|
|
15175
|
-
</div>
|
|
15176
|
-
`;
|
|
15177
|
-
}
|
|
15178
|
-
}
|
|
15179
|
-
return `
|
|
15180
|
-
<div class="poofnet-instruction ${actionClass}">
|
|
15181
|
-
<div class="poofnet-instruction-header">
|
|
15182
|
-
<span class="poofnet-instruction-icon">${icon}</span>
|
|
15183
|
-
<span class="poofnet-instruction-action">${isDelete ? "Delete" : "Save"}</span>
|
|
15184
|
-
<span class="poofnet-instruction-collection">${this.escapeHtml(collection)}</span>
|
|
15185
|
-
</div>
|
|
15186
|
-
${documentId
|
|
15187
|
-
? `<div class="poofnet-instruction-id">ID: ${this.escapeHtml(documentId)}</div>`
|
|
15188
|
-
: ""}
|
|
15189
|
-
${fieldsHtml}
|
|
15190
|
-
</div>
|
|
15191
|
-
`;
|
|
15192
|
-
})
|
|
15193
|
-
.join("");
|
|
15194
15051
|
// Create summary text
|
|
15195
15052
|
let summaryText = "";
|
|
15196
15053
|
if (sets.length > 0 && deletes.length > 0) {
|
|
@@ -15202,50 +15059,65 @@ class OffchainAuthProvider {
|
|
|
15202
15059
|
else if (deletes.length > 0) {
|
|
15203
15060
|
summaryText = `${deletes.length} delete${deletes.length > 1 ? "s" : ""}`;
|
|
15204
15061
|
}
|
|
15205
|
-
|
|
15206
|
-
|
|
15207
|
-
|
|
15208
|
-
|
|
15209
|
-
|
|
15210
|
-
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
-
|
|
15220
|
-
|
|
15221
|
-
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
|
|
15225
|
-
|
|
15226
|
-
|
|
15227
|
-
|
|
15228
|
-
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
|
|
15243
|
-
|
|
15244
|
-
|
|
15245
|
-
|
|
15246
|
-
|
|
15247
|
-
|
|
15248
|
-
|
|
15062
|
+
const { overlay, body, footer } = this.buildModalShell("🔐", "Confirm Transaction");
|
|
15063
|
+
if (instructions.length > 0) {
|
|
15064
|
+
if (summaryText) {
|
|
15065
|
+
this.appendTextElement(body, "div", "poofnet-summary", summaryText);
|
|
15066
|
+
}
|
|
15067
|
+
const list = this.createElement("div", "poofnet-instructions-list");
|
|
15068
|
+
for (const inst of instructions) {
|
|
15069
|
+
list.appendChild(this.buildInstructionElement(inst));
|
|
15070
|
+
}
|
|
15071
|
+
body.appendChild(list);
|
|
15072
|
+
}
|
|
15073
|
+
else {
|
|
15074
|
+
const section = this.createElement("div", "poofnet-section");
|
|
15075
|
+
this.appendTextElement(section, "h3", "poofnet-section-title", "Message");
|
|
15076
|
+
const raw = this.createElement("pre", "poofnet-raw-message", rawMessage.slice(0, 200) + (rawMessage.length > 200 ? "..." : ""));
|
|
15077
|
+
section.appendChild(raw);
|
|
15078
|
+
body.appendChild(section);
|
|
15079
|
+
}
|
|
15080
|
+
body.appendChild(this.buildInfoBox("This is a simulated transaction. No real fees will be charged."));
|
|
15081
|
+
const cancel = this.createElement("button", "poofnet-btn poofnet-btn-cancel", "Cancel");
|
|
15082
|
+
cancel.id = "poofnet-cancel-btn";
|
|
15083
|
+
cancel.type = "button";
|
|
15084
|
+
footer.appendChild(cancel);
|
|
15085
|
+
const confirm = this.createElement("button", "poofnet-btn poofnet-btn-confirm", "Confirm");
|
|
15086
|
+
confirm.id = "poofnet-confirm-btn";
|
|
15087
|
+
confirm.type = "button";
|
|
15088
|
+
footer.appendChild(confirm);
|
|
15089
|
+
return overlay;
|
|
15090
|
+
}
|
|
15091
|
+
buildInstructionElement(inst) {
|
|
15092
|
+
const { collection, documentId } = this.formatPath(inst.path);
|
|
15093
|
+
const isDelete = inst.type === "delete";
|
|
15094
|
+
const card = this.createElement("div", `poofnet-instruction ${isDelete ? "poofnet-action-delete" : "poofnet-action-set"}`);
|
|
15095
|
+
const header = this.createElement("div", "poofnet-instruction-header");
|
|
15096
|
+
this.appendTextElement(header, "span", "poofnet-instruction-icon", isDelete ? "🗑️" : "✏️");
|
|
15097
|
+
this.appendTextElement(header, "span", "poofnet-instruction-action", isDelete ? "Delete" : "Save");
|
|
15098
|
+
this.appendTextElement(header, "span", "poofnet-instruction-collection", collection);
|
|
15099
|
+
card.appendChild(header);
|
|
15100
|
+
if (documentId) {
|
|
15101
|
+
this.appendTextElement(card, "div", "poofnet-instruction-id", `ID: ${documentId}`);
|
|
15102
|
+
}
|
|
15103
|
+
if (inst.data && !isDelete) {
|
|
15104
|
+
const fieldKeys = Object.keys(inst.data).filter((key) => !key.startsWith("_"));
|
|
15105
|
+
const visibleFields = fieldKeys.slice(0, 4);
|
|
15106
|
+
if (visibleFields.length > 0) {
|
|
15107
|
+
const fields = this.createElement("div", "poofnet-fields");
|
|
15108
|
+
for (const key of visibleFields) {
|
|
15109
|
+
const row = this.createElement("div", "poofnet-field");
|
|
15110
|
+
this.appendTextElement(row, "span", "poofnet-field-key", `${key}:`);
|
|
15111
|
+
this.appendTextElement(row, "span", "poofnet-field-value", this.formatFieldValue(inst.data[key]));
|
|
15112
|
+
fields.appendChild(row);
|
|
15113
|
+
}
|
|
15114
|
+
if (fieldKeys.length > 4) {
|
|
15115
|
+
this.appendTextElement(fields, "div", "poofnet-field-more", `+${fieldKeys.length - 4} more fields`);
|
|
15116
|
+
}
|
|
15117
|
+
card.appendChild(fields);
|
|
15118
|
+
}
|
|
15119
|
+
}
|
|
15120
|
+
return card;
|
|
15249
15121
|
}
|
|
15250
15122
|
getModalStyles() {
|
|
15251
15123
|
return `
|
|
@@ -18581,9 +18453,7 @@ const emailProviderSingleton = new EmailAuthProvider();
|
|
|
18581
18453
|
function openEmailModal() {
|
|
18582
18454
|
return new Promise((resolve) => {
|
|
18583
18455
|
var _a;
|
|
18584
|
-
const root =
|
|
18585
|
-
root.id = 'bounded-auth-modal';
|
|
18586
|
-
root.innerHTML = MODAL_HTML;
|
|
18456
|
+
const root = createEmailModalTree();
|
|
18587
18457
|
const style = document.createElement('style');
|
|
18588
18458
|
style.textContent = MODAL_CSS;
|
|
18589
18459
|
root.appendChild(style);
|
|
@@ -18671,26 +18541,97 @@ function openEmailModal() {
|
|
|
18671
18541
|
});
|
|
18672
18542
|
});
|
|
18673
18543
|
}
|
|
18674
|
-
|
|
18675
|
-
|
|
18676
|
-
|
|
18677
|
-
|
|
18678
|
-
|
|
18679
|
-
|
|
18680
|
-
|
|
18681
|
-
|
|
18682
|
-
|
|
18683
|
-
|
|
18684
|
-
|
|
18685
|
-
|
|
18686
|
-
|
|
18687
|
-
|
|
18688
|
-
|
|
18689
|
-
|
|
18690
|
-
|
|
18691
|
-
|
|
18692
|
-
|
|
18693
|
-
|
|
18544
|
+
function createEmailModalTree() {
|
|
18545
|
+
const root = document.createElement('div');
|
|
18546
|
+
root.id = 'bounded-auth-modal';
|
|
18547
|
+
const overlay = document.createElement('div');
|
|
18548
|
+
overlay.className = 'ba-overlay';
|
|
18549
|
+
root.appendChild(overlay);
|
|
18550
|
+
const card = document.createElement('div');
|
|
18551
|
+
card.className = 'ba-card';
|
|
18552
|
+
card.setAttribute('role', 'dialog');
|
|
18553
|
+
card.setAttribute('aria-modal', 'true');
|
|
18554
|
+
card.setAttribute('aria-label', 'Sign in');
|
|
18555
|
+
overlay.appendChild(card);
|
|
18556
|
+
const close = document.createElement('button');
|
|
18557
|
+
close.id = 'ba-close';
|
|
18558
|
+
close.className = 'ba-x';
|
|
18559
|
+
close.setAttribute('aria-label', 'Close');
|
|
18560
|
+
close.type = 'button';
|
|
18561
|
+
close.textContent = '×';
|
|
18562
|
+
card.appendChild(close);
|
|
18563
|
+
const brand = document.createElement('div');
|
|
18564
|
+
brand.className = 'ba-brand';
|
|
18565
|
+
const dot = document.createElement('span');
|
|
18566
|
+
dot.className = 'ba-dot';
|
|
18567
|
+
brand.appendChild(dot);
|
|
18568
|
+
brand.appendChild(document.createTextNode(' Sign in'));
|
|
18569
|
+
card.appendChild(brand);
|
|
18570
|
+
const emailStep = document.createElement('div');
|
|
18571
|
+
emailStep.id = 'ba-email-step';
|
|
18572
|
+
card.appendChild(emailStep);
|
|
18573
|
+
const emailLabel = document.createElement('label');
|
|
18574
|
+
emailLabel.className = 'ba-label';
|
|
18575
|
+
emailLabel.htmlFor = 'ba-email';
|
|
18576
|
+
emailLabel.textContent = 'Email';
|
|
18577
|
+
emailStep.appendChild(emailLabel);
|
|
18578
|
+
const emailInput = document.createElement('input');
|
|
18579
|
+
emailInput.id = 'ba-email';
|
|
18580
|
+
emailInput.className = 'ba-input';
|
|
18581
|
+
emailInput.type = 'email';
|
|
18582
|
+
emailInput.inputMode = 'email';
|
|
18583
|
+
emailInput.autocomplete = 'email';
|
|
18584
|
+
emailInput.placeholder = 'you@example.com';
|
|
18585
|
+
emailStep.appendChild(emailInput);
|
|
18586
|
+
const emailButton = document.createElement('button');
|
|
18587
|
+
emailButton.id = 'ba-email-btn';
|
|
18588
|
+
emailButton.className = 'ba-btn';
|
|
18589
|
+
emailButton.type = 'button';
|
|
18590
|
+
emailButton.textContent = 'Continue';
|
|
18591
|
+
emailStep.appendChild(emailButton);
|
|
18592
|
+
const otpStep = document.createElement('div');
|
|
18593
|
+
otpStep.id = 'ba-otp-step';
|
|
18594
|
+
otpStep.className = 'hidden';
|
|
18595
|
+
card.appendChild(otpStep);
|
|
18596
|
+
const otpLabel = document.createElement('label');
|
|
18597
|
+
otpLabel.className = 'ba-label';
|
|
18598
|
+
otpLabel.htmlFor = 'ba-otp';
|
|
18599
|
+
otpLabel.appendChild(document.createTextNode('Enter the code sent to '));
|
|
18600
|
+
const sentTo = document.createElement('span');
|
|
18601
|
+
sentTo.id = 'ba-sent-to';
|
|
18602
|
+
sentTo.className = 'ba-em';
|
|
18603
|
+
otpLabel.appendChild(sentTo);
|
|
18604
|
+
otpStep.appendChild(otpLabel);
|
|
18605
|
+
const otpInput = document.createElement('input');
|
|
18606
|
+
otpInput.id = 'ba-otp';
|
|
18607
|
+
otpInput.className = 'ba-input ba-code';
|
|
18608
|
+
otpInput.inputMode = 'numeric';
|
|
18609
|
+
otpInput.autocomplete = 'one-time-code';
|
|
18610
|
+
otpInput.maxLength = 8;
|
|
18611
|
+
otpInput.placeholder = '······';
|
|
18612
|
+
otpStep.appendChild(otpInput);
|
|
18613
|
+
const otpButton = document.createElement('button');
|
|
18614
|
+
otpButton.id = 'ba-otp-btn';
|
|
18615
|
+
otpButton.className = 'ba-btn';
|
|
18616
|
+
otpButton.type = 'button';
|
|
18617
|
+
otpButton.textContent = 'Verify & continue';
|
|
18618
|
+
otpStep.appendChild(otpButton);
|
|
18619
|
+
const backButton = document.createElement('button');
|
|
18620
|
+
backButton.id = 'ba-back';
|
|
18621
|
+
backButton.className = 'ba-link';
|
|
18622
|
+
backButton.type = 'button';
|
|
18623
|
+
backButton.textContent = 'Use a different email';
|
|
18624
|
+
otpStep.appendChild(backButton);
|
|
18625
|
+
const msg = document.createElement('div');
|
|
18626
|
+
msg.id = 'ba-msg';
|
|
18627
|
+
msg.className = 'ba-msg';
|
|
18628
|
+
card.appendChild(msg);
|
|
18629
|
+
const foot = document.createElement('div');
|
|
18630
|
+
foot.className = 'ba-foot';
|
|
18631
|
+
foot.textContent = 'Secured by Bounded';
|
|
18632
|
+
card.appendChild(foot);
|
|
18633
|
+
return root;
|
|
18634
|
+
}
|
|
18694
18635
|
const MODAL_CSS = `
|
|
18695
18636
|
#bounded-auth-modal .ba-overlay{position:fixed;inset:0;background:rgba(8,10,18,.62);backdrop-filter:blur(4px);
|
|
18696
18637
|
display:flex;align-items:center;justify-content:center;z-index:2147483000;opacity:1;transition:opacity .16s ease;
|
|
@@ -21428,7 +21369,7 @@ async function awaitSignInGestureAndSign(theme, signFn, noResultError = 'MWA ret
|
|
|
21428
21369
|
].join('; ');
|
|
21429
21370
|
const closeBtn = document.createElement('button');
|
|
21430
21371
|
closeBtn.setAttribute('aria-label', 'Close');
|
|
21431
|
-
closeBtn.textContent = '×';
|
|
21372
|
+
closeBtn.textContent = '×';
|
|
21432
21373
|
closeBtn.style.cssText = [
|
|
21433
21374
|
'position: absolute',
|
|
21434
21375
|
'top: 12px',
|