@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.js
CHANGED
|
@@ -108,7 +108,6 @@ class WebSessionManager {
|
|
|
108
108
|
/* ---------- validate app-id ---------- */
|
|
109
109
|
const config = await getConfig();
|
|
110
110
|
if (sessionObj.appId && sessionObj.appId !== config.appId) {
|
|
111
|
-
console.warn("Session appId mismatch. Stored session belongs to a different app. Logging out.");
|
|
112
111
|
this.clearSession();
|
|
113
112
|
return null;
|
|
114
113
|
}
|
|
@@ -133,7 +132,6 @@ class WebSessionManager {
|
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
catch (err) {
|
|
136
|
-
console.error("Error decoding access token:", err);
|
|
137
135
|
return null;
|
|
138
136
|
}
|
|
139
137
|
return { address: sessionObj.address, session: sessionObj };
|
|
@@ -184,7 +182,6 @@ class WebSessionManager {
|
|
|
184
182
|
/* ---------- app-id guard ---------- */
|
|
185
183
|
const config = await getConfig();
|
|
186
184
|
if (sessionObj.appId && sessionObj.appId !== config.appId) {
|
|
187
|
-
console.warn("Session appId mismatch during token refresh. Logging out.");
|
|
188
185
|
this.clearSession();
|
|
189
186
|
return;
|
|
190
187
|
}
|
|
@@ -6277,7 +6274,8 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
6277
6274
|
const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash("confirmed");
|
|
6278
6275
|
tx.recentBlockhash = blockhash;
|
|
6279
6276
|
if (lutKey == null) {
|
|
6280
|
-
const
|
|
6277
|
+
const isSurfnet = anchorProvider.connection.rpcEndpoint == "https://surfpool.fly.dev";
|
|
6278
|
+
const computeUnits = isSurfnet ? 1400000 : await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, []);
|
|
6281
6279
|
const computeBudgetIxOptimized = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
6282
6280
|
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
6283
6281
|
}); // 20% buffer
|
|
@@ -6287,7 +6285,8 @@ async function buildSetDocumentsTransaction(connection, idl, anchorProvider, pay
|
|
|
6287
6285
|
const { value: table } = await connection.getAddressLookupTable(new web3_js.PublicKey(lutKey));
|
|
6288
6286
|
if (!table)
|
|
6289
6287
|
throw new Error('LUT not found after creation/extend');
|
|
6290
|
-
const
|
|
6288
|
+
const isSurfnet = anchorProvider.connection.rpcEndpoint == "https://surfpool.fly.dev";
|
|
6289
|
+
const computeUnits = isSurfnet ? 1400000 : await getSimulationComputeUnits(connection, tx.instructions, payerPublicKey, [table]);
|
|
6291
6290
|
const computeBudgetIxOptimized = web3_js.ComputeBudgetProgram.setComputeUnitLimit({
|
|
6292
6291
|
units: computeUnits ? computeUnits * 1.2 : 1400000,
|
|
6293
6292
|
}); // 20% buffer
|
|
@@ -6424,7 +6423,7 @@ function updateIdTokenAndAccessToken(idToken, accessToken) {
|
|
|
6424
6423
|
}
|
|
6425
6424
|
|
|
6426
6425
|
async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
6427
|
-
var _a, _b, _c, _d, _e, _f
|
|
6426
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6428
6427
|
const config = await getConfig();
|
|
6429
6428
|
async function executeRequest() {
|
|
6430
6429
|
const authHeader = await createAuthHeader(config.isServer);
|
|
@@ -6474,8 +6473,7 @@ async function makeApiRequest(method, urlPath, data, _overrides) {
|
|
|
6474
6473
|
return { data: null, status: 404 };
|
|
6475
6474
|
}
|
|
6476
6475
|
if ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.message) {
|
|
6477
|
-
|
|
6478
|
-
throw new Error((_j = (_h = error.response) === null || _h === void 0 ? void 0 : _h.data) === null || _j === void 0 ? void 0 : _j.message);
|
|
6476
|
+
throw new Error((_f = (_e = error.response) === null || _e === void 0 ? void 0 : _e.data) === null || _f === void 0 ? void 0 : _f.message);
|
|
6479
6477
|
}
|
|
6480
6478
|
throw error;
|
|
6481
6479
|
}
|
|
@@ -6516,8 +6514,6 @@ function init(newConfig) {
|
|
|
6516
6514
|
isInitialized = true;
|
|
6517
6515
|
resolve();
|
|
6518
6516
|
}).catch((error) => {
|
|
6519
|
-
console.error('Failed to authenticate with API key or fetch config for this app:', error);
|
|
6520
|
-
console.error('Please check your API key and try again.');
|
|
6521
6517
|
reject(new Error("Failed to initialize Tarobase app."));
|
|
6522
6518
|
});
|
|
6523
6519
|
});
|
|
@@ -6621,16 +6617,11 @@ async function get(path, opts = {}) {
|
|
|
6621
6617
|
// Helper to clean up expired cache entries
|
|
6622
6618
|
function cleanupExpiredCache() {
|
|
6623
6619
|
const now = Date.now();
|
|
6624
|
-
let removedCount = 0;
|
|
6625
6620
|
Object.keys(getCache).forEach(key => {
|
|
6626
6621
|
if (getCache[key] && getCache[key].expiresAt < now) {
|
|
6627
6622
|
delete getCache[key];
|
|
6628
|
-
removedCount++;
|
|
6629
6623
|
}
|
|
6630
6624
|
});
|
|
6631
|
-
if (removedCount > 0) {
|
|
6632
|
-
console.debug(`Cleaned up ${removedCount} expired cache entries`);
|
|
6633
|
-
}
|
|
6634
6625
|
lastCacheCleanup = now;
|
|
6635
6626
|
}
|
|
6636
6627
|
async function runQuery(absolutePath, queryName, queryArgs) {
|
|
@@ -6764,7 +6755,6 @@ async function setMany(many, options) {
|
|
|
6764
6755
|
}
|
|
6765
6756
|
}
|
|
6766
6757
|
catch (error) {
|
|
6767
|
-
console.error("Error setting data", error);
|
|
6768
6758
|
throw error;
|
|
6769
6759
|
}
|
|
6770
6760
|
async function handleSolanaTransaction(tx, authProvider, options) {
|
|
@@ -6881,9 +6871,7 @@ async function setFile(path, file) {
|
|
|
6881
6871
|
});
|
|
6882
6872
|
// 3) Check if the upload was successful
|
|
6883
6873
|
if (!uploadResponse.ok) {
|
|
6884
|
-
|
|
6885
|
-
const errorText = await uploadResponse.text();
|
|
6886
|
-
console.error('S3 Error Body:', errorText);
|
|
6874
|
+
await uploadResponse.text();
|
|
6887
6875
|
throw new Error(`Upload failed with status: ${uploadResponse.status}`);
|
|
6888
6876
|
}
|
|
6889
6877
|
// Optionally return the file's public URL or some confirmation
|
|
@@ -7571,10 +7559,9 @@ async function subscribe(path, subscriptionOptions) {
|
|
|
7571
7559
|
}
|
|
7572
7560
|
});
|
|
7573
7561
|
ws.addEventListener('error', (event) => {
|
|
7574
|
-
console.error(`WebSocket error for path: ${connectionKey}`, event);
|
|
7575
7562
|
notifyError(connectionKey, event);
|
|
7576
7563
|
});
|
|
7577
|
-
ws.addEventListener('close', (
|
|
7564
|
+
ws.addEventListener('close', () => {
|
|
7578
7565
|
// Connection will be recreated on next subscription if needed
|
|
7579
7566
|
});
|
|
7580
7567
|
return async () => await removeSubscription(connectionKey, subscriptionOptions);
|
|
@@ -7615,8 +7602,7 @@ async function removeSubscription(connectionKey, subscription) {
|
|
|
7615
7602
|
ws.addEventListener('close', () => {
|
|
7616
7603
|
resolve();
|
|
7617
7604
|
});
|
|
7618
|
-
ws.addEventListener('error', (
|
|
7619
|
-
console.error(`WebSocket closure error for connection: ${connectionKey}`, err);
|
|
7605
|
+
ws.addEventListener('error', () => {
|
|
7620
7606
|
resolve(); // Resolve even on error to avoid hanging
|
|
7621
7607
|
});
|
|
7622
7608
|
ws.close();
|