@pooflabs/core 0.0.2 → 0.0.3
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/index.js +9 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -23
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +2 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -88,7 +88,6 @@ class WebSessionManager {
|
|
|
88
88
|
/* ---------- validate app-id ---------- */
|
|
89
89
|
const config = await getConfig();
|
|
90
90
|
if (sessionObj.appId && sessionObj.appId !== config.appId) {
|
|
91
|
-
console.warn("Session appId mismatch. Stored session belongs to a different app. Logging out.");
|
|
92
91
|
this.clearSession();
|
|
93
92
|
return null;
|
|
94
93
|
}
|
|
@@ -113,7 +112,6 @@ class WebSessionManager {
|
|
|
113
112
|
}
|
|
114
113
|
}
|
|
115
114
|
catch (err) {
|
|
116
|
-
console.error("Error decoding access token:", err);
|
|
117
115
|
return null;
|
|
118
116
|
}
|
|
119
117
|
return { address: sessionObj.address, session: sessionObj };
|
|
@@ -164,7 +162,6 @@ class WebSessionManager {
|
|
|
164
162
|
/* ---------- app-id guard ---------- */
|
|
165
163
|
const config = await getConfig();
|
|
166
164
|
if (sessionObj.appId && sessionObj.appId !== config.appId) {
|
|
167
|
-
console.warn("Session appId mismatch during token refresh. Logging out.");
|
|
168
165
|
this.clearSession();
|
|
169
166
|
return;
|
|
170
167
|
}
|
|
@@ -6257,7 +6254,8 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
6257
6254
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
6258
6255
|
tx.recentBlockhash = blockhash;
|
|
6259
6256
|
if (lutKey == null) {
|
|
6260
|
-
const
|
|
6257
|
+
const isSurfnet = anchorProvider.connection.rpcEndpoint == "https://surfpool.fly.dev";
|
|
6258
|
+
const computeUnits = isSurfnet ? 1400000 : await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, []);
|
|
6261
6259
|
const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({
|
|
6262
6260
|
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
6263
6261
|
}); // 20% buffer
|
|
@@ -6267,7 +6265,8 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
6267
6265
|
const { value: table } = await connection.getAddressLookupTable(new PublicKey(lutKey));
|
|
6268
6266
|
if (!table)
|
|
6269
6267
|
throw new Error('LUT not found after creation/extend');
|
|
6270
|
-
const
|
|
6268
|
+
const isSurfnet = anchorProvider.connection.rpcEndpoint == "https://surfpool.fly.dev";
|
|
6269
|
+
const computeUnits = isSurfnet ? 1400000 : await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, [table]);
|
|
6271
6270
|
const computeBudgetIxOptimized = ComputeBudgetProgram.setComputeUnitLimit({
|
|
6272
6271
|
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
6273
6272
|
}); // 20% buffer
|
|
@@ -6404,7 +6403,7 @@ function updateIdTokenAndAccessToken(idToken, accessToken) {
|
|
|
6404
6403
|
}
|
|
6405
6404
|
|
|
6406
6405
|
async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
6407
|
-
var _a, _b, _c, _d, _e, _f
|
|
6406
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6408
6407
|
const config = await getConfig();
|
|
6409
6408
|
async function executeRequest() {
|
|
6410
6409
|
const authHeader = await createAuthHeader(config.isServer);
|
|
@@ -6454,8 +6453,7 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
6454
6453
|
return { data: null, status: 404 };
|
|
6455
6454
|
}
|
|
6456
6455
|
if ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message) {
|
|
6457
|
-
|
|
6458
|
-
throw new Error((_j = (_h = error.response) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.message);
|
|
6456
|
+
throw new Error((_f = (_e = error.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.message);
|
|
6459
6457
|
}
|
|
6460
6458
|
throw error;
|
|
6461
6459
|
}
|
|
@@ -6496,8 +6494,6 @@ function init(newConfig) {
|
|
|
6496
6494
|
isInitialized = true;
|
|
6497
6495
|
resolve();
|
|
6498
6496
|
}).catch((error) => {
|
|
6499
|
-
console.error('Failed to authenticate with API key or fetch config for this app:', error);
|
|
6500
|
-
console.error('Please check your API key and try again.');
|
|
6501
6497
|
reject(new Error("Failed to initialize Tarobase app."));
|
|
6502
6498
|
});
|
|
6503
6499
|
});
|
|
@@ -6601,16 +6597,11 @@ async function get(path, opts = {}) {
|
|
|
6601
6597
|
// Helper to clean up expired cache entries
|
|
6602
6598
|
function cleanupExpiredCache() {
|
|
6603
6599
|
const now = Date.now();
|
|
6604
|
-
let removedCount = 0;
|
|
6605
6600
|
Object.keys(getCache).forEach(key => {
|
|
6606
6601
|
if (getCache[key] && getCache[key].expiresAt < now) {
|
|
6607
6602
|
delete getCache[key];
|
|
6608
|
-
removedCount++;
|
|
6609
6603
|
}
|
|
6610
6604
|
});
|
|
6611
|
-
if (removedCount > 0) {
|
|
6612
|
-
console.debug(`Cleaned up ${removedCount} expired cache entries`);
|
|
6613
|
-
}
|
|
6614
6605
|
lastCacheCleanup = now;
|
|
6615
6606
|
}
|
|
6616
6607
|
async function runQuery(absolutePath, queryName, queryArgs) {
|
|
@@ -6744,7 +6735,6 @@ async function setMany(many, options) {
|
|
|
6744
6735
|
}
|
|
6745
6736
|
}
|
|
6746
6737
|
catch (error) {
|
|
6747
|
-
console.error("Error setting data", error);
|
|
6748
6738
|
throw error;
|
|
6749
6739
|
}
|
|
6750
6740
|
async function handleSolanaTransaction(tx, authProvider, options) {
|
|
@@ -6861,9 +6851,7 @@ async function setFile(path, file) {
|
|
|
6861
6851
|
});
|
|
6862
6852
|
// 3) Check if the upload was successful
|
|
6863
6853
|
if (!uploadResponse.ok) {
|
|
6864
|
-
|
|
6865
|
-
const errorText = await uploadResponse.text();
|
|
6866
|
-
console.error('S3 Error Body:', errorText);
|
|
6854
|
+
await uploadResponse.text();
|
|
6867
6855
|
throw new Error(`Upload failed with status: ${uploadResponse.status}`);
|
|
6868
6856
|
}
|
|
6869
6857
|
// Optionally return the file's public URL or some confirmation
|
|
@@ -7551,10 +7539,9 @@ async function subscribe(path, subscriptionOptions) {
|
|
|
7551
7539
|
}
|
|
7552
7540
|
});
|
|
7553
7541
|
ws.addEventListener('error', (event) => {
|
|
7554
|
-
console.error(`WebSocket error for path: ${connectionKey}`, event);
|
|
7555
7542
|
notifyError(connectionKey, event);
|
|
7556
7543
|
});
|
|
7557
|
-
ws.addEventListener('close', (
|
|
7544
|
+
ws.addEventListener('close', () => {
|
|
7558
7545
|
// Connection will be recreated on next subscription if needed
|
|
7559
7546
|
});
|
|
7560
7547
|
return async () => await removeSubscription(connectionKey, subscriptionOptions);
|
|
@@ -7595,8 +7582,7 @@ async function removeSubscription(connectionKey, subscription) {
|
|
|
7595
7582
|
ws.addEventListener('close', () => {
|
|
7596
7583
|
resolve();
|
|
7597
7584
|
});
|
|
7598
|
-
ws.addEventListener('error', (
|
|
7599
|
-
console.error(`WebSocket closure error for connection: ${connectionKey}`, err);
|
|
7585
|
+
ws.addEventListener('error', () => {
|
|
7600
7586
|
resolve(); // Resolve even on error to avoid hanging
|
|
7601
7587
|
});
|
|
7602
7588
|
ws.close();
|