@carrierllc/mcp 0.2.14 → 0.2.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/index.js +25 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5390,8 +5390,20 @@ import {
|
|
|
5390
5390
|
function sessionKey(sub, wizardId) {
|
|
5391
5391
|
return `app-session:${sub}:${wizardId}`;
|
|
5392
5392
|
}
|
|
5393
|
+
var inMemorySessions = /* @__PURE__ */ new Map();
|
|
5394
|
+
function pruneExpired() {
|
|
5395
|
+
const now = Date.now();
|
|
5396
|
+
for (const [key, val] of inMemorySessions.entries()) {
|
|
5397
|
+
if (val.expiresAt < now) inMemorySessions.delete(key);
|
|
5398
|
+
}
|
|
5399
|
+
}
|
|
5393
5400
|
async function loadWizardSession(env, sub, wizardId) {
|
|
5394
|
-
const
|
|
5401
|
+
const key = sessionKey(sub, wizardId);
|
|
5402
|
+
if (!env.CARRIER_USERS) {
|
|
5403
|
+
pruneExpired();
|
|
5404
|
+
return inMemorySessions.get(key)?.session ?? null;
|
|
5405
|
+
}
|
|
5406
|
+
const raw = await env.CARRIER_USERS.get(key);
|
|
5395
5407
|
if (!raw) return null;
|
|
5396
5408
|
try {
|
|
5397
5409
|
return JSON.parse(raw);
|
|
@@ -5400,14 +5412,20 @@ async function loadWizardSession(env, sub, wizardId) {
|
|
|
5400
5412
|
}
|
|
5401
5413
|
}
|
|
5402
5414
|
async function saveWizardSession(env, sub, wizardId, session) {
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5415
|
+
const key = sessionKey(sub, wizardId);
|
|
5416
|
+
if (!env.CARRIER_USERS) {
|
|
5417
|
+
inMemorySessions.set(key, { session, expiresAt: Date.now() + 6e5 });
|
|
5418
|
+
return;
|
|
5419
|
+
}
|
|
5420
|
+
await env.CARRIER_USERS.put(key, JSON.stringify(session), { expirationTtl: 600 });
|
|
5408
5421
|
}
|
|
5409
5422
|
async function deleteWizardSession(env, sub, wizardId) {
|
|
5410
|
-
|
|
5423
|
+
const key = sessionKey(sub, wizardId);
|
|
5424
|
+
if (!env.CARRIER_USERS) {
|
|
5425
|
+
inMemorySessions.delete(key);
|
|
5426
|
+
return;
|
|
5427
|
+
}
|
|
5428
|
+
await env.CARRIER_USERS.delete(key);
|
|
5411
5429
|
}
|
|
5412
5430
|
|
|
5413
5431
|
// src/apps/provisioning-wizard.ts
|