mcp-scraper 0.87.0 → 0.88.0
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/CHANGELOG.md +14 -1
- package/README.md +3 -3
- package/dist/bin/api-server.js +2 -2
- package/dist/bin/mcp-scraper-cli.js +3 -3
- package/dist/bin/mcp-scraper-core.js +5 -5
- package/dist/bin/mcp-scraper-install.js +2 -2
- package/dist/bin/mcp-stdio-server.js +5 -5
- package/dist/bin/paa-harvest.js +2 -2
- package/dist/{chunk-XX6XUZQM.js → chunk-2JVZQGSN.js} +7 -3
- package/dist/{chunk-NKRO2SUO.js → chunk-4QMUF6XM.js} +2 -2
- package/dist/{chunk-UDLPENTY.js → chunk-ABF2CGOZ.js} +1 -1
- package/dist/{chunk-OWF2JJKN.js → chunk-GXBZXWXB.js} +8 -8
- package/dist/{chunk-KQWVJOVR.js → chunk-IHXAXYIS.js} +1 -1
- package/dist/{chunk-WFGAR4BZ.js → chunk-MZDNZQWT.js} +1 -1
- package/dist/{chunk-6XDNIYGP.js → chunk-P5FPC54B.js} +3 -3
- package/dist/{chunk-R2HRN2FW.js → chunk-S24LFPL7.js} +1 -1
- package/dist/{chunk-6IOGTFNS.js → chunk-UZPTGUDV.js} +1 -1
- package/dist/{chunk-Y3AIFO7C.js → chunk-XIJI34RM.js} +1 -1
- package/dist/{extract-bundle-FALNLKYY.js → extract-bundle-565SBZCR.js} +2 -2
- package/dist/{gmail-service-BUSU4BVX.js → gmail-service-E6ALS7JG.js} +2 -2
- package/dist/index.cjs +8 -8
- package/dist/index.js +2 -2
- package/dist/{server-4QWARJET.js → server-PD3TDL6Q.js} +434 -425
- package/dist/{site-extract-repository-S5FYNFDY.js → site-extract-repository-VYFZASPU.js} +2 -2
- package/dist/{worker-DAVCZ3FP.js → worker-LDCAULWL.js} +3 -3
- package/package.json +1 -1
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
setExtractJobTotal,
|
|
44
44
|
settleExtractJob,
|
|
45
45
|
terminalExtractJobStatus
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-IHXAXYIS.js";
|
|
47
47
|
import {
|
|
48
48
|
REQUIRED_LOCATION_STATE_CODES,
|
|
49
49
|
importHostedCensusPlacesCsv,
|
|
@@ -105,7 +105,7 @@ import {
|
|
|
105
105
|
probeNangoConnectionDirect,
|
|
106
106
|
recordNangoConnectionCost,
|
|
107
107
|
settleConnectedUsage
|
|
108
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-MZDNZQWT.js";
|
|
109
109
|
import {
|
|
110
110
|
ANALYTICS_ATTRIBUTION_MODELS,
|
|
111
111
|
ANALYTICS_CONTENT_SORTS,
|
|
@@ -240,7 +240,7 @@ import {
|
|
|
240
240
|
serpArrivalUrl,
|
|
241
241
|
validateProviderSessionId,
|
|
242
242
|
withRuntimeUserAgent
|
|
243
|
-
} from "./chunk-
|
|
243
|
+
} from "./chunk-S24LFPL7.js";
|
|
244
244
|
import {
|
|
245
245
|
ANALYTICS_REST_GENERIC_EXEMPTIONS,
|
|
246
246
|
ASSISTANT_COMMAND_SCHEMA_VERSION,
|
|
@@ -388,7 +388,7 @@ import {
|
|
|
388
388
|
transcribeMediaUrl,
|
|
389
389
|
transitionAnalyticsExperiment,
|
|
390
390
|
validateAnalyticsRestResponseForRequest
|
|
391
|
-
} from "./chunk-
|
|
391
|
+
} from "./chunk-2JVZQGSN.js";
|
|
392
392
|
import {
|
|
393
393
|
auditImageUrls,
|
|
394
394
|
auditImages,
|
|
@@ -459,7 +459,7 @@ import {
|
|
|
459
459
|
tierChangeLeavesPrivateOffer,
|
|
460
460
|
tierCreditsPerInterval,
|
|
461
461
|
vendorCostUsdToMc
|
|
462
|
-
} from "./chunk-
|
|
462
|
+
} from "./chunk-4QMUF6XM.js";
|
|
463
463
|
import {
|
|
464
464
|
browserServiceApiKey,
|
|
465
465
|
browserServiceProfileName,
|
|
@@ -483,7 +483,7 @@ import {
|
|
|
483
483
|
workflowOutputBaseDir,
|
|
484
484
|
workflowStepCount,
|
|
485
485
|
workflowSupportsSteps
|
|
486
|
-
} from "./chunk-
|
|
486
|
+
} from "./chunk-UZPTGUDV.js";
|
|
487
487
|
import {
|
|
488
488
|
csvRecords,
|
|
489
489
|
parseCsv,
|
|
@@ -498,7 +498,7 @@ import {
|
|
|
498
498
|
RawMapsHoursRowSchema,
|
|
499
499
|
RawMapsOverviewSchema,
|
|
500
500
|
RawMapsReviewStatsSchema
|
|
501
|
-
} from "./chunk-
|
|
501
|
+
} from "./chunk-GXBZXWXB.js";
|
|
502
502
|
import {
|
|
503
503
|
extractContactEvidence
|
|
504
504
|
} from "./chunk-P7FWOMU7.js";
|
|
@@ -509,7 +509,7 @@ import {
|
|
|
509
509
|
} from "./chunk-GGZEC22A.js";
|
|
510
510
|
import {
|
|
511
511
|
PACKAGE_VERSION
|
|
512
|
-
} from "./chunk-
|
|
512
|
+
} from "./chunk-XIJI34RM.js";
|
|
513
513
|
import {
|
|
514
514
|
CaptchaError,
|
|
515
515
|
MapsSearchIncompletePageError,
|
|
@@ -557,7 +557,6 @@ import {
|
|
|
557
557
|
getInboxMessage,
|
|
558
558
|
getJob,
|
|
559
559
|
getLedger,
|
|
560
|
-
getMemoryPlan,
|
|
561
560
|
getMemoryProvisioned,
|
|
562
561
|
getOrCreateRunningJob,
|
|
563
562
|
getPageSnapshot,
|
|
@@ -566,7 +565,6 @@ import {
|
|
|
566
565
|
getUserByEmail,
|
|
567
566
|
getUserById,
|
|
568
567
|
getUserByStripeCustomerId,
|
|
569
|
-
getUserMemoryCreds,
|
|
570
568
|
getUserStats,
|
|
571
569
|
getWorkflowArtifact,
|
|
572
570
|
getWorkflowRun,
|
|
@@ -615,7 +613,6 @@ import {
|
|
|
615
613
|
setPassword,
|
|
616
614
|
setStripeCustomerId,
|
|
617
615
|
setSubscriptionTier,
|
|
618
|
-
setUserMemoryCreds,
|
|
619
616
|
settleDebitMcIdempotent,
|
|
620
617
|
softDeleteInboxMessage,
|
|
621
618
|
updateHarvestAttemptProviderTelemetry,
|
|
@@ -3972,7 +3969,7 @@ async function generateOgImage(post) {
|
|
|
3972
3969
|
|
|
3973
3970
|
// src/api/server.ts
|
|
3974
3971
|
import { Resend as Resend3 } from "resend";
|
|
3975
|
-
import { createHash as
|
|
3972
|
+
import { createHash as createHash105, randomUUID as randomUUID69 } from "crypto";
|
|
3976
3973
|
|
|
3977
3974
|
// src/api/kpo-extractor.ts
|
|
3978
3975
|
import TurndownService from "turndown";
|
|
@@ -9764,7 +9761,7 @@ var siteExtractFn = inngest.createFunction(
|
|
|
9764
9761
|
});
|
|
9765
9762
|
}) : null;
|
|
9766
9763
|
const finalized = await step.run("finalize", async () => {
|
|
9767
|
-
const { assembleExtractArtifacts } = await import("./extract-bundle-
|
|
9764
|
+
const { assembleExtractArtifacts } = await import("./extract-bundle-565SBZCR.js");
|
|
9768
9765
|
const current = await getExtractJob(jobId2);
|
|
9769
9766
|
if (!current) throw new Error("extract job disappeared before finalization");
|
|
9770
9767
|
const stored = await assembleExtractArtifacts(current, { branding, imageAudit });
|
|
@@ -15864,10 +15861,41 @@ async function voidScheduledRunAuthorization(args) {
|
|
|
15864
15861
|
|
|
15865
15862
|
// src/api/memory.ts
|
|
15866
15863
|
import { createCipheriv, createDecipheriv, randomBytes, scryptSync } from "crypto";
|
|
15867
|
-
import { provisionDefaultsTool } from "mcpscraper-memory-tools/tools/vaults/provision-defaults";
|
|
15868
15864
|
import { setScheduleEntitlementTool } from "mcpscraper-memory-tools/tools/schedule/set-schedule-entitlement";
|
|
15865
|
+
|
|
15866
|
+
// src/api/oauth-signing.ts
|
|
15867
|
+
import { createHash as createHash5, randomUUID as randomUUID5 } from "crypto";
|
|
15868
|
+
import { exportJWK, importPKCS8, SignJWT } from "jose";
|
|
15869
|
+
var OAUTH_ISSUER = "https://mcpscraper.dev";
|
|
15870
|
+
var cachedKeys = null;
|
|
15871
|
+
async function getKeys() {
|
|
15872
|
+
if (cachedKeys) return cachedKeys;
|
|
15873
|
+
const raw = process.env.OAUTH_SIGNING_KEY;
|
|
15874
|
+
if (!raw?.trim()) throw new Error("OAUTH_SIGNING_KEY is not set");
|
|
15875
|
+
const pem = raw.includes("BEGIN") ? raw : Buffer.from(raw, "base64").toString("utf8");
|
|
15876
|
+
const privateKey = await importPKCS8(pem, "RS256", { extractable: true });
|
|
15877
|
+
const full = await exportJWK(privateKey);
|
|
15878
|
+
const publicJwk = { kty: full.kty, n: full.n, e: full.e };
|
|
15879
|
+
const kid = createHash5("sha256").update(JSON.stringify({ e: publicJwk.e, kty: publicJwk.kty, n: publicJwk.n })).digest("base64url").slice(0, 16);
|
|
15880
|
+
publicJwk.kid = kid;
|
|
15881
|
+
publicJwk.alg = "RS256";
|
|
15882
|
+
publicJwk.use = "sig";
|
|
15883
|
+
cachedKeys = { privateKey, publicJwk, kid };
|
|
15884
|
+
return cachedKeys;
|
|
15885
|
+
}
|
|
15886
|
+
async function getOAuthPublicJwk() {
|
|
15887
|
+
return (await getKeys()).publicJwk;
|
|
15888
|
+
}
|
|
15889
|
+
async function mintOAuthAccessToken(args) {
|
|
15890
|
+
const { privateKey, kid } = await getKeys();
|
|
15891
|
+
return new SignJWT({ scope: args.scope, plan: args.plan }).setProtectedHeader({ alg: "RS256", kid }).setIssuer(OAUTH_ISSUER).setSubject(args.identity).setAudience(args.audience).setIssuedAt().setJti(randomUUID5()).setExpirationTime(`${args.ttlSeconds}s`).sign(privateKey);
|
|
15892
|
+
}
|
|
15893
|
+
|
|
15894
|
+
// src/api/memory.ts
|
|
15869
15895
|
var MEMORY_BASE_URL = () => (process.env.MCP_MEMORY_BASE_URL ?? "https://memory.mcpscraper.dev").replace(/\/$/, "");
|
|
15896
|
+
var MEMORY_RESOURCE_URL = () => (process.env.MCP_MEMORY_RESOURCE_URL ?? "https://memory.mcpscraper.dev/mcp").replace(/\/$/, "");
|
|
15870
15897
|
var ADMIN_KEY = () => process.env.MCP_MEMORY_ADMIN_KEY?.trim() ?? "";
|
|
15898
|
+
var MEMORY_SERVICE_TOKEN_TTL_SECONDS = 300;
|
|
15871
15899
|
function parseMemoryRpcBody(text3) {
|
|
15872
15900
|
const dataLine = text3.split("\n").find((line) => line.startsWith("data:"));
|
|
15873
15901
|
const payload = dataLine ? dataLine.slice(5).trim() : text3;
|
|
@@ -15945,8 +15973,10 @@ function memoryPlanForReads(user) {
|
|
|
15945
15973
|
}
|
|
15946
15974
|
async function provisionMemoryForUser(user) {
|
|
15947
15975
|
try {
|
|
15948
|
-
const { key: key3 } = await
|
|
15949
|
-
if (key3)
|
|
15976
|
+
const { key: key3 } = await getMemoryServiceToken(user);
|
|
15977
|
+
if (!key3) return;
|
|
15978
|
+
const result3 = await memoryCall("listVaultsTool", {}, key3);
|
|
15979
|
+
if (result3.ok) await setMemoryProvisioned(user.id, true);
|
|
15950
15980
|
} catch {
|
|
15951
15981
|
}
|
|
15952
15982
|
}
|
|
@@ -15959,40 +15989,32 @@ function resolveEffectiveMemoryPlan(user) {
|
|
|
15959
15989
|
if (tierIncludesMemory(user.subscription_tier)) return "pro";
|
|
15960
15990
|
return user.memory_plan === "pro" ? "pro" : "free";
|
|
15961
15991
|
}
|
|
15962
|
-
async function
|
|
15963
|
-
|
|
15964
|
-
|
|
15965
|
-
const
|
|
15966
|
-
|
|
15967
|
-
|
|
15968
|
-
|
|
15969
|
-
|
|
15970
|
-
|
|
15971
|
-
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
{}
|
|
15975
|
-
)
|
|
15976
|
-
|
|
15977
|
-
|
|
15992
|
+
async function getMemoryServiceToken(user, planOverride) {
|
|
15993
|
+
try {
|
|
15994
|
+
const operator = isMemoryOperator(user.email);
|
|
15995
|
+
const plan = operator ? "unlimited" : planOverride ?? resolveEffectiveMemoryPlan(user);
|
|
15996
|
+
const scope = operator ? "memory.read memory.write memory.admin" : "memory.read memory.write";
|
|
15997
|
+
const key3 = await mintOAuthAccessToken({
|
|
15998
|
+
identity: memoryIdentity(user),
|
|
15999
|
+
scope,
|
|
16000
|
+
plan,
|
|
16001
|
+
audience: MEMORY_RESOURCE_URL(),
|
|
16002
|
+
ttlSeconds: MEMORY_SERVICE_TOKEN_TTL_SECONDS
|
|
16003
|
+
});
|
|
16004
|
+
return { key: key3 };
|
|
16005
|
+
} catch (error) {
|
|
16006
|
+
return {
|
|
16007
|
+
key: null,
|
|
16008
|
+
error: error instanceof Error ? error.message : "memory service authorization unavailable"
|
|
16009
|
+
};
|
|
15978
16010
|
}
|
|
15979
|
-
await setUserMemoryCreds(user.id, encryptMemoryKey(provisioned.secret), identity);
|
|
15980
|
-
return { key: provisioned.secret };
|
|
15981
16011
|
}
|
|
15982
16012
|
async function syncMemoryKeyPlan(user, plan) {
|
|
15983
16013
|
const effectivePlan = isMemoryOperator(user.email) ? "unlimited" : plan;
|
|
15984
|
-
const { key: key3, error } = await
|
|
16014
|
+
const { key: key3, error } = await getMemoryServiceToken(user, effectivePlan);
|
|
15985
16015
|
if (!key3) return { ok: false, error: error ?? "memory unavailable" };
|
|
15986
|
-
const listed = await memoryCall(
|
|
15987
|
-
|
|
15988
|
-
{},
|
|
15989
|
-
key3
|
|
15990
|
-
);
|
|
15991
|
-
if (!listed.ok || !listed.keys?.length) return { ok: false, error: listed.error ?? "no memory keys found" };
|
|
15992
|
-
const target = listed.keys[0];
|
|
15993
|
-
if (target.plan === effectivePlan) return { ok: true };
|
|
15994
|
-
const res = await memoryCall("setScopeTool", { keyId: target.keyId, plan: effectivePlan }, key3);
|
|
15995
|
-
return { ok: res.ok, error: res.error };
|
|
16016
|
+
const listed = await memoryCall("listVaultsTool", {}, key3);
|
|
16017
|
+
return { ok: listed.ok, error: listed.error };
|
|
15996
16018
|
}
|
|
15997
16019
|
async function syncScheduledActionCredentials(user) {
|
|
15998
16020
|
const admin = ADMIN_KEY();
|
|
@@ -19616,7 +19638,7 @@ var adminAuth = createMiddleware3(async (c, next) => {
|
|
|
19616
19638
|
import { Hono as Hono9 } from "hono";
|
|
19617
19639
|
|
|
19618
19640
|
// src/api/admin-credits.ts
|
|
19619
|
-
import { randomUUID as
|
|
19641
|
+
import { randomUUID as randomUUID6 } from "crypto";
|
|
19620
19642
|
var MIN_ADJUSTMENT_CREDITS = 1;
|
|
19621
19643
|
var LARGE_ADJUSTMENT_CREDITS = 1e5;
|
|
19622
19644
|
var MAX_ADJUSTMENT_CREDITS = 1e7;
|
|
@@ -19766,7 +19788,7 @@ async function applyAdjustment(input) {
|
|
|
19766
19788
|
const credits = validateCredits(input.credits, input.confirmLarge === true);
|
|
19767
19789
|
const reason = validateReason(input.reason);
|
|
19768
19790
|
const actor = validateActor(input.actor);
|
|
19769
|
-
const reference2 = input.reference?.trim() || `adj_${
|
|
19791
|
+
const reference2 = input.reference?.trim() || `adj_${randomUUID6()}`;
|
|
19770
19792
|
if (reference2.length > 120) throw new AdminCreditError(400, "reference must be at most 120 characters");
|
|
19771
19793
|
const db = getDb();
|
|
19772
19794
|
const existing = await db.execute({
|
|
@@ -21336,11 +21358,11 @@ async function runKernelRedditPipeline(apiKey, input, hooks) {
|
|
|
21336
21358
|
}
|
|
21337
21359
|
|
|
21338
21360
|
// src/reddit/bright-data-thread-backup.ts
|
|
21339
|
-
import { createHash as
|
|
21361
|
+
import { createHash as createHash7 } from "crypto";
|
|
21340
21362
|
import { chromium as chromium5 } from "playwright";
|
|
21341
21363
|
|
|
21342
21364
|
// src/api/brightdata-session-telemetry.ts
|
|
21343
|
-
import { createHash as
|
|
21365
|
+
import { createHash as createHash6 } from "crypto";
|
|
21344
21366
|
var DEFAULT_SESSION_API_BASE_URL = "https://api.brightdata.com";
|
|
21345
21367
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
21346
21368
|
var MAX_PROVIDER_TEXT = 320;
|
|
@@ -21517,7 +21539,7 @@ async function enrichPendingBrightDataAttempts(limit = 25, options = {}) {
|
|
|
21517
21539
|
return summary;
|
|
21518
21540
|
}
|
|
21519
21541
|
function providerSessionHash(sessionId) {
|
|
21520
|
-
return
|
|
21542
|
+
return createHash6("sha256").update(sessionId).digest("hex").slice(0, 16);
|
|
21521
21543
|
}
|
|
21522
21544
|
async function recordPendingBrightDataRedditUsage(providerSessionId, telemetry) {
|
|
21523
21545
|
return recordVendorUsage({
|
|
@@ -21691,7 +21713,7 @@ function isAcceptedRedditThread(thread, requestedComments) {
|
|
|
21691
21713
|
return Boolean(thread.title?.trim()) && thread.comments.length >= redditThreadAcceptanceTarget(thread, requestedComments);
|
|
21692
21714
|
}
|
|
21693
21715
|
function hashSessionId(sessionId) {
|
|
21694
|
-
return sessionId ?
|
|
21716
|
+
return sessionId ? createHash7("sha256").update(sessionId).digest("hex").slice(0, 16) : null;
|
|
21695
21717
|
}
|
|
21696
21718
|
async function reconcileSession(sessionId) {
|
|
21697
21719
|
if (!sessionId) return null;
|
|
@@ -22288,11 +22310,11 @@ configurePostRoute({
|
|
|
22288
22310
|
});
|
|
22289
22311
|
|
|
22290
22312
|
// src/api/gmail-routes.ts
|
|
22291
|
-
import { createHash as
|
|
22313
|
+
import { createHash as createHash10, timingSafeEqual as timingSafeEqual3 } from "crypto";
|
|
22292
22314
|
import { Hono as Hono13 } from "hono";
|
|
22293
22315
|
|
|
22294
22316
|
// src/api/gmail-memory-ingest-repository.ts
|
|
22295
|
-
import { randomUUID as
|
|
22317
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
22296
22318
|
var GmailImportRepositoryError = class extends Error {
|
|
22297
22319
|
constructor(code, message, status = 400) {
|
|
22298
22320
|
super(message);
|
|
@@ -22363,7 +22385,7 @@ async function createOrGetGmailImportPlan(ownerId3, data, now = /* @__PURE__ */
|
|
|
22363
22385
|
const planFingerprint = gmailFingerprint(data);
|
|
22364
22386
|
const existing = await getDb().execute({ sql: `SELECT * FROM gmail_import_plans WHERE owner_identity = ? AND plan_fingerprint = ? AND expires_at > ? LIMIT 1`, args: [ownerId3, planFingerprint, now.toISOString()] });
|
|
22365
22387
|
if (existing.rows[0]) return planFromRow(existing.rows[0]);
|
|
22366
|
-
const plan = { ...data, importPlanId: `gplan_${
|
|
22388
|
+
const plan = { ...data, importPlanId: `gplan_${randomUUID7().replace(/-/g, "")}`, ownerId: ownerId3, planFingerprint, createdAt: now.toISOString(), expiresAt: new Date(now.getTime() + 24 * 60 * 60 * 1e3).toISOString() };
|
|
22367
22389
|
await getDb().execute({ sql: `INSERT INTO gmail_import_plans (import_plan_id, owner_identity, plan_fingerprint, plan_json, created_at, expires_at) VALUES (?, ?, ?, ?, ?, ?)`, args: [plan.importPlanId, ownerId3, plan.planFingerprint, JSON.stringify(data), plan.createdAt, plan.expiresAt] });
|
|
22368
22390
|
return plan;
|
|
22369
22391
|
}
|
|
@@ -22393,7 +22415,7 @@ async function beginOrResumeGmailImport(args) {
|
|
|
22393
22415
|
}
|
|
22394
22416
|
const now = args.now ?? /* @__PURE__ */ new Date();
|
|
22395
22417
|
const leaseExpiresAt = new Date(now.getTime() + (args.leaseMs ?? 45e3)).toISOString();
|
|
22396
|
-
const job = { ingestId: `ging_${
|
|
22418
|
+
const job = { ingestId: `ging_${randomUUID7().replace(/-/g, "")}`, ownerId: args.ownerId, importPlanId: args.plan.importPlanId, idempotencyKey: key3, fingerprint: fingerprint5, status: "running", attempts: 0, leaseExpiresAt, progress: { messagesStored: 0, attachmentsStored: 0, attachmentsIndexed: 0, skipped: 0, errors: [], checkpoints: {} }, createdAt: now.toISOString(), updatedAt: now.toISOString() };
|
|
22397
22419
|
await getDb().execute({ sql: `INSERT INTO gmail_import_jobs (ingest_id, owner_identity, import_plan_id, idempotency_key, fingerprint, status, attempts, lease_expires_at, progress_json, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, args: [job.ingestId, job.ownerId, job.importPlanId, job.idempotencyKey, job.fingerprint, job.status, job.attempts, job.leaseExpiresAt, JSON.stringify(job.progress), job.createdAt, job.updatedAt] });
|
|
22398
22420
|
return { job, acquired: true };
|
|
22399
22421
|
}
|
|
@@ -22425,7 +22447,7 @@ async function getGmailImportStatus(ownerId3, ingestId) {
|
|
|
22425
22447
|
}
|
|
22426
22448
|
|
|
22427
22449
|
// src/api/gmail-memory-ingest.ts
|
|
22428
|
-
import { createHash as
|
|
22450
|
+
import { createHash as createHash8 } from "crypto";
|
|
22429
22451
|
var GMAIL_IMPORT_MAX_ATTACHMENTS = 1e4;
|
|
22430
22452
|
var GMAIL_IMPORT_MAX_ATTACHMENT_BYTES = 25 * 1024 * 1024;
|
|
22431
22453
|
var GMAIL_IMPORT_MAX_TOTAL_ATTACHMENT_BYTES = 250 * 1024 * 1024;
|
|
@@ -22584,7 +22606,7 @@ var GmailMemoryIngestService = class {
|
|
|
22584
22606
|
}
|
|
22585
22607
|
};
|
|
22586
22608
|
function canonicalMessageDigest(message) {
|
|
22587
|
-
return
|
|
22609
|
+
return createHash8("sha256").update(JSON.stringify({ messageId: message.messageId, threadId: message.threadId, internalDate: message.internalDate, headers: message.headers, labels: message.labels, plainText: message.plainText, sanitizedHtml: message.sanitizedHtml, attachments: message.attachments.map((item) => ({ filename: item.filename, mime: item.declaredMime, size: item.size, partId: item.partId })) })).digest("hex");
|
|
22588
22610
|
}
|
|
22589
22611
|
function renderMessageNote(message, attachmentPolicy) {
|
|
22590
22612
|
const addresses = (values) => values.map((item) => item.name ? `${item.name} <${item.email}>` : item.email).join(", ");
|
|
@@ -22611,11 +22633,11 @@ function gmailAttachmentSourceIdentity(messageId, messageDigest, partId, attachm
|
|
|
22611
22633
|
return `gmail:${messageId}:${messageDigest}:${partId}:${attachmentDigest}`;
|
|
22612
22634
|
}
|
|
22613
22635
|
function gmailAttachmentSaveIdempotencyKey(messageId, messageDigest, partId, attachmentDigest) {
|
|
22614
|
-
return `gmail-attachment:${
|
|
22636
|
+
return `gmail-attachment:${createHash8("sha256").update(gmailAttachmentSourceIdentity(messageId, messageDigest, partId, attachmentDigest)).digest("hex")}`;
|
|
22615
22637
|
}
|
|
22616
22638
|
|
|
22617
22639
|
// src/api/scheduler-integration-auth.ts
|
|
22618
|
-
import { createHash as
|
|
22640
|
+
import { createHash as createHash9, createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
22619
22641
|
var MAX_CLOCK_SKEW_MS = 5 * 60 * 1e3;
|
|
22620
22642
|
var SchedulerIntegrationAuthError = class extends Error {
|
|
22621
22643
|
code;
|
|
@@ -22631,7 +22653,7 @@ function signingSecret() {
|
|
|
22631
22653
|
return secret;
|
|
22632
22654
|
}
|
|
22633
22655
|
function schedulerIntegrationSignature(args) {
|
|
22634
|
-
const bodyHash =
|
|
22656
|
+
const bodyHash = createHash9("sha256").update(args.body).digest("hex");
|
|
22635
22657
|
return createHmac2("sha256", args.secret).update(`${args.method.toUpperCase()}
|
|
22636
22658
|
${args.path}
|
|
22637
22659
|
${args.timestamp}
|
|
@@ -22691,7 +22713,7 @@ var gmailApp = new Hono13();
|
|
|
22691
22713
|
var auth = createApiKeyAuth();
|
|
22692
22714
|
var gmail = new GmailService();
|
|
22693
22715
|
function ownerId(apiKey) {
|
|
22694
|
-
return
|
|
22716
|
+
return createHash10("sha256").update(apiKey).digest("hex").slice(0, 24);
|
|
22695
22717
|
}
|
|
22696
22718
|
function caller(c) {
|
|
22697
22719
|
const user = c.get("user");
|
|
@@ -22899,7 +22921,7 @@ function gmailMemoryAssetToolsForMime(mimeType) {
|
|
|
22899
22921
|
}
|
|
22900
22922
|
async function memoryPort(c) {
|
|
22901
22923
|
const user = c.get("user");
|
|
22902
|
-
const { key: key3, error } = await
|
|
22924
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
22903
22925
|
if (!key3) throw new GmailMemoryIngestError("memory_unavailable", error ?? "Memory is unavailable.", 503, true);
|
|
22904
22926
|
return {
|
|
22905
22927
|
async validateVault(vault) {
|
|
@@ -22931,7 +22953,7 @@ async function memoryPort(c) {
|
|
|
22931
22953
|
return { status: "unmatched" };
|
|
22932
22954
|
},
|
|
22933
22955
|
async saveNote(args) {
|
|
22934
|
-
const path5 = `gmail/${
|
|
22956
|
+
const path5 = `gmail/${createHash10("sha256").update(args.sourceKey).digest("hex")}.md`;
|
|
22935
22957
|
const result3 = await memoryCall("putTool", gmailMemoryNoteArguments({ ...args, path: path5 }), key3);
|
|
22936
22958
|
if (!result3.ok) throw new GmailMemoryIngestError("memory_note_failed", String(result3.error ?? "Memory note write failed."), 503, true);
|
|
22937
22959
|
return { ...result3, path: path5 };
|
|
@@ -23112,7 +23134,7 @@ gmailApp.post("/api/internal/integrations/:connectionId/gmail/selections/prepare
|
|
|
23112
23134
|
if (!providerIdentity || body3.purpose !== "scheduled_export") throw new GmailServiceError("invalid_request", "identity and scheduled_export purpose are required.");
|
|
23113
23135
|
const parsedSource = selectionSource(source);
|
|
23114
23136
|
if (!parsedSource) throw new GmailServiceError("invalid_request", "A valid Gmail selection source is required.");
|
|
23115
|
-
const internalOwnerId =
|
|
23137
|
+
const internalOwnerId = createHash10("sha256").update(providerIdentity.toLowerCase()).digest("hex").slice(0, 24);
|
|
23116
23138
|
const exactRange = string(range.from) && string(range.to) ? { from: String(range.from), to: String(range.to) } : void 0;
|
|
23117
23139
|
const selection = await gmail.prepareSelection({ ownerId: internalOwnerId, providerIdentity, connectionId: c.req.param("connectionId"), purpose: "scheduled_export", source: parsedSource, ...exactRange ? { exactRange } : {} });
|
|
23118
23140
|
return c.json({ ok: true, contract: { version: GMAIL_MAIN_CONTRACT_VERSION, hash: GMAIL_MAIN_CONTRACT_HASH }, selection: await selectionReceipt(selection, providerIdentity, true), untrustedContent: true });
|
|
@@ -23129,7 +23151,7 @@ gmailApp.post("/api/internal/integrations/:connectionId/gmail/selections/:select
|
|
|
23129
23151
|
const selectionSha256 = string(body3.selectionSha256);
|
|
23130
23152
|
const expectedCount = integer(body3.expectedCount);
|
|
23131
23153
|
if (!providerIdentity || !selectionSha256 || expectedCount === null) throw new GmailServiceError("invalid_request", "identity and the exact selection receipt are required.");
|
|
23132
|
-
const internalOwnerId =
|
|
23154
|
+
const internalOwnerId = createHash10("sha256").update(providerIdentity.toLowerCase()).digest("hex").slice(0, 24);
|
|
23133
23155
|
const exported = await gmail.exportSelection({ ownerId: internalOwnerId, providerIdentity, connectionId: c.req.param("connectionId"), selectionId: c.req.param("selectionId"), selectionSha256, expectedCount });
|
|
23134
23156
|
return c.json({ ok: true, contract: { version: GMAIL_MAIN_CONTRACT_VERSION, hash: GMAIL_MAIN_CONTRACT_HASH }, export: exported, untrustedContent: true });
|
|
23135
23157
|
} catch (error) {
|
|
@@ -23193,7 +23215,7 @@ function gmailResolvedArtifactHeaders(artifactId, bytes2) {
|
|
|
23193
23215
|
decoded = "artifact.bin";
|
|
23194
23216
|
}
|
|
23195
23217
|
const filename2 = decoded.replace(/[\r\n]/g, "").slice(0, 500) || "artifact.bin";
|
|
23196
|
-
return { filename: filename2, contentType: sniffResolvedArtifactMime(bytes2, filename2), sha256:
|
|
23218
|
+
return { filename: filename2, contentType: sniffResolvedArtifactMime(bytes2, filename2), sha256: createHash10("sha256").update(bytes2).digest("hex") };
|
|
23197
23219
|
}
|
|
23198
23220
|
|
|
23199
23221
|
// src/api/video-routes.ts
|
|
@@ -23218,7 +23240,7 @@ videoApp.post("/analyze", createApiKeyAuth(), async (c) => {
|
|
|
23218
23240
|
if (!parsed.success) return c.json(invalidRequest6(parsed.error.issues[0]?.message ?? "invalid request"), 400);
|
|
23219
23241
|
const body3 = parsed.data;
|
|
23220
23242
|
const user = c.get("user");
|
|
23221
|
-
const { key: memKey, error: memErr } = await
|
|
23243
|
+
const { key: memKey, error: memErr } = await getMemoryServiceToken(user);
|
|
23222
23244
|
if (!memKey) return c.json({ error_code: "memory_unavailable", message: memErr ?? "memory unavailable" }, 502);
|
|
23223
23245
|
const requestedFrames = Math.min(Math.max(body3.maxFrames ?? 120, 1), 480);
|
|
23224
23246
|
const tiers = tiersFor(requestedFrames);
|
|
@@ -23252,7 +23274,7 @@ videoApp.post("/status", createApiKeyAuth(), async (c) => {
|
|
|
23252
23274
|
const runId = rawBody.runId?.trim();
|
|
23253
23275
|
if (!runId) return c.json(invalidRequest6("runId is required"), 400);
|
|
23254
23276
|
const user = c.get("user");
|
|
23255
|
-
const { key: memKey, error: memErr } = await
|
|
23277
|
+
const { key: memKey, error: memErr } = await getMemoryServiceToken(user);
|
|
23256
23278
|
if (!memKey) return c.json({ error_code: "memory_unavailable", message: memErr ?? "memory unavailable" }, 502);
|
|
23257
23279
|
const st = await memoryCall("videoAnalyzeStatusTool", { runId }, memKey);
|
|
23258
23280
|
if (!st.ok) return c.json({ error_code: "not_found", message: st.error ?? "run not found" }, 404);
|
|
@@ -24071,17 +24093,17 @@ g2App.post("/reviews", createApiKeyAuth(), async (c) => {
|
|
|
24071
24093
|
});
|
|
24072
24094
|
|
|
24073
24095
|
// src/api/directory-routes.ts
|
|
24074
|
-
import { createHash as
|
|
24096
|
+
import { createHash as createHash11, randomUUID as randomUUID9 } from "crypto";
|
|
24075
24097
|
import { Hono as Hono18 } from "hono";
|
|
24076
24098
|
|
|
24077
24099
|
// src/api/directory-workflow-dispatch.ts
|
|
24078
|
-
import { randomUUID as
|
|
24100
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
24079
24101
|
function retryDelaySeconds(attempts) {
|
|
24080
24102
|
return Math.min(60 * 60, Math.max(15, 15 * 2 ** Math.min(8, Math.max(0, attempts - 1))));
|
|
24081
24103
|
}
|
|
24082
24104
|
async function dispatchPendingDirectoryWorkflows(limit = 25) {
|
|
24083
24105
|
const rows = await claimDirectoryWorkflowOutbox({
|
|
24084
|
-
workerId: `directory-dispatch-${process.pid}-${
|
|
24106
|
+
workerId: `directory-dispatch-${process.pid}-${randomUUID8().slice(0, 8)}`,
|
|
24085
24107
|
limit
|
|
24086
24108
|
});
|
|
24087
24109
|
const result3 = { claimed: rows.length, dispatched: 0, failed: 0 };
|
|
@@ -24111,7 +24133,7 @@ function safeOptions(options) {
|
|
|
24111
24133
|
return safe;
|
|
24112
24134
|
}
|
|
24113
24135
|
function requestFingerprint(options) {
|
|
24114
|
-
return
|
|
24136
|
+
return createHash11("sha256").update(JSON.stringify(safeOptions(options))).digest("hex");
|
|
24115
24137
|
}
|
|
24116
24138
|
function idempotencyKey(raw) {
|
|
24117
24139
|
if (raw !== void 0) {
|
|
@@ -24120,14 +24142,14 @@ function idempotencyKey(raw) {
|
|
|
24120
24142
|
if (trimmed.length > 500) return { ok: false, message: "Idempotency-Key must be 500 characters or fewer." };
|
|
24121
24143
|
return { ok: true, key: trimmed };
|
|
24122
24144
|
}
|
|
24123
|
-
return { ok: true, key: `directory-${
|
|
24145
|
+
return { ok: true, key: `directory-${randomUUID9()}` };
|
|
24124
24146
|
}
|
|
24125
24147
|
function debitKeyFor(userId, responseKey) {
|
|
24126
|
-
const digest23 =
|
|
24148
|
+
const digest23 = createHash11("sha256").update(String(userId)).update("\0").update(responseKey).digest("hex");
|
|
24127
24149
|
return `directory-workflow:${userId}:${digest23}`;
|
|
24128
24150
|
}
|
|
24129
24151
|
function jobId() {
|
|
24130
|
-
return `dir_${
|
|
24152
|
+
return `dir_${randomUUID9().replace(/-/g, "")}`;
|
|
24131
24153
|
}
|
|
24132
24154
|
function publicStatus(job, result3) {
|
|
24133
24155
|
if (job.status === "failed") return "failed";
|
|
@@ -24236,7 +24258,7 @@ async function runSynchronously(c, user, options, plan, responseKey) {
|
|
|
24236
24258
|
const csv2 = renderDirectoryWorkflowCsv(result3);
|
|
24237
24259
|
const artifact = await createDirectoryCsvArtifact({
|
|
24238
24260
|
ownerId: String(user.id),
|
|
24239
|
-
jobId:
|
|
24261
|
+
jobId: createHash11("sha256").update(debitKey).digest("hex").slice(0, 32),
|
|
24240
24262
|
createdAt: result3.extractedAt,
|
|
24241
24263
|
filename: `${options.state}-${options.query}-directory.csv`,
|
|
24242
24264
|
csv: csv2,
|
|
@@ -24431,17 +24453,17 @@ directoryApp.get("/jobs/:id", createApiKeyAuth(), async (c) => {
|
|
|
24431
24453
|
});
|
|
24432
24454
|
|
|
24433
24455
|
// src/api/lead-list-input-routes.ts
|
|
24434
|
-
import { createHash as
|
|
24456
|
+
import { createHash as createHash13 } from "crypto";
|
|
24435
24457
|
import { Hono as Hono19 } from "hono";
|
|
24436
24458
|
|
|
24437
24459
|
// src/api/lead-list-input-artifacts.ts
|
|
24438
|
-
import { createHash as
|
|
24460
|
+
import { createHash as createHash12 } from "crypto";
|
|
24439
24461
|
import { rm } from "fs/promises";
|
|
24440
24462
|
import { homedir as homedir3 } from "os";
|
|
24441
24463
|
import { join as join7 } from "path";
|
|
24442
24464
|
|
|
24443
24465
|
// src/api/lead-list-import-repository.ts
|
|
24444
|
-
import { randomUUID as
|
|
24466
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
24445
24467
|
var schemaDb4 = null;
|
|
24446
24468
|
var schemaPromise3 = null;
|
|
24447
24469
|
function parseJson3(value, fallback) {
|
|
@@ -24507,10 +24529,10 @@ function bounded(value, field, min, max) {
|
|
|
24507
24529
|
return normalized;
|
|
24508
24530
|
}
|
|
24509
24531
|
function newLeadListUploadId() {
|
|
24510
|
-
return `upl_${
|
|
24532
|
+
return `upl_${randomUUID10().replace(/-/g, "")}`;
|
|
24511
24533
|
}
|
|
24512
24534
|
function newImportedLeadListId() {
|
|
24513
|
-
return `lst_${
|
|
24535
|
+
return `lst_${randomUUID10().replace(/-/g, "")}`;
|
|
24514
24536
|
}
|
|
24515
24537
|
async function ensureLeadListImportRepositorySchema() {
|
|
24516
24538
|
const db = getDb();
|
|
@@ -24758,7 +24780,7 @@ function safeFilenameHint(value) {
|
|
|
24758
24780
|
return cleaned || null;
|
|
24759
24781
|
}
|
|
24760
24782
|
function requestFingerprint2(filenameHint) {
|
|
24761
|
-
return
|
|
24783
|
+
return createHash12("sha256").update(JSON.stringify({ filenameHint })).digest("hex");
|
|
24762
24784
|
}
|
|
24763
24785
|
function publicBaseUrl() {
|
|
24764
24786
|
const configured3 = process.env.MCP_SCRAPER_PUBLIC_BASE_URL?.trim() || process.env.PUBLIC_BASE_URL?.trim() || (process.env.VERCEL_PROJECT_PRODUCTION_URL ? `https://${process.env.VERCEL_PROJECT_PRODUCTION_URL}` : "") || "https://mcpscraper.dev";
|
|
@@ -24914,7 +24936,7 @@ async function inspectLeadListUpload(uploadId, ownerId3) {
|
|
|
24914
24936
|
maxBytes: LEAD_LIST_UPLOAD_MAX_BYTES
|
|
24915
24937
|
});
|
|
24916
24938
|
if (!buffer) return null;
|
|
24917
|
-
const sha2564 =
|
|
24939
|
+
const sha2564 = createHash12("sha256").update(buffer).digest("hex");
|
|
24918
24940
|
const completed = await completeLeadListUpload({
|
|
24919
24941
|
id: record7.id,
|
|
24920
24942
|
ownerId: record7.ownerId,
|
|
@@ -25397,7 +25419,7 @@ function canonicalize(value) {
|
|
|
25397
25419
|
return `{${Object.keys(object2).sort().map((key3) => `${JSON.stringify(key3)}:${canonicalize(object2[key3])}`).join(",")}}`;
|
|
25398
25420
|
}
|
|
25399
25421
|
function fingerprint(value) {
|
|
25400
|
-
return
|
|
25422
|
+
return createHash13("sha256").update(canonicalize(value)).digest("hex");
|
|
25401
25423
|
}
|
|
25402
25424
|
async function safeJson(c) {
|
|
25403
25425
|
try {
|
|
@@ -25652,17 +25674,17 @@ leadListInputApp.post("/imports", async (c) => {
|
|
|
25652
25674
|
});
|
|
25653
25675
|
|
|
25654
25676
|
// src/api/lead-list-enrichment-routes.ts
|
|
25655
|
-
import { createHash as
|
|
25677
|
+
import { createHash as createHash14, randomUUID as randomUUID12 } from "crypto";
|
|
25656
25678
|
import { Hono as Hono20 } from "hono";
|
|
25657
25679
|
import { z as z25 } from "zod";
|
|
25658
25680
|
|
|
25659
25681
|
// src/api/lead-list-enrichment-dispatch.ts
|
|
25660
|
-
import { randomUUID as
|
|
25682
|
+
import { randomUUID as randomUUID11 } from "crypto";
|
|
25661
25683
|
function retryDelaySeconds2(attempts) {
|
|
25662
25684
|
return Math.min(3600, Math.max(15, 15 * 2 ** Math.min(8, Math.max(0, attempts - 1))));
|
|
25663
25685
|
}
|
|
25664
25686
|
async function dispatchPendingLeadListEnrichments(limit = 25) {
|
|
25665
|
-
const rows = await claimLeadListEnrichmentOutbox({ workerId: `lead-list-dispatch-${process.pid}-${
|
|
25687
|
+
const rows = await claimLeadListEnrichmentOutbox({ workerId: `lead-list-dispatch-${process.pid}-${randomUUID11().slice(0, 8)}`, limit });
|
|
25666
25688
|
const result3 = { claimed: rows.length, dispatched: 0, failed: 0 };
|
|
25667
25689
|
for (const row of rows) {
|
|
25668
25690
|
if (!row.claimToken) continue;
|
|
@@ -25710,15 +25732,15 @@ function idempotencyKey2(raw) {
|
|
|
25710
25732
|
return { ok: true, value };
|
|
25711
25733
|
}
|
|
25712
25734
|
function newJobId() {
|
|
25713
|
-
return `lle_${
|
|
25735
|
+
return `lle_${randomUUID12().replace(/-/g, "")}`;
|
|
25714
25736
|
}
|
|
25715
25737
|
function debitKeyFor2(userId, key3) {
|
|
25716
|
-
const digest23 =
|
|
25738
|
+
const digest23 = createHash14("sha256").update(String(userId)).update("\0").update(key3).digest("hex");
|
|
25717
25739
|
return `lead-list-enrichment:${userId}:${digest23}`;
|
|
25718
25740
|
}
|
|
25719
25741
|
function inlineSourceDigest(headers, rows) {
|
|
25720
25742
|
const values = rows.map((row) => headers.map((header) => row[header] ?? null));
|
|
25721
|
-
return
|
|
25743
|
+
return createHash14("sha256").update(stableCanonicalJson({ headers, values })).digest("hex");
|
|
25722
25744
|
}
|
|
25723
25745
|
function issueMessage(error) {
|
|
25724
25746
|
const issue = error.issues[0];
|
|
@@ -28381,17 +28403,17 @@ workflowApp.post("/cron/dispatch", async (c) => {
|
|
|
28381
28403
|
|
|
28382
28404
|
// src/api/serp-intelligence-routes.ts
|
|
28383
28405
|
import { Hono as Hono24 } from "hono";
|
|
28384
|
-
import { createHash as
|
|
28406
|
+
import { createHash as createHash16, randomUUID as randomUUID13 } from "crypto";
|
|
28385
28407
|
|
|
28386
28408
|
// src/serp-intelligence/page-snapshot-extractor.ts
|
|
28387
|
-
import { createHash as
|
|
28409
|
+
import { createHash as createHash15 } from "crypto";
|
|
28388
28410
|
import pLimit5 from "p-limit";
|
|
28389
28411
|
var DEFAULT_TIMEOUT_MS2 = 15e3;
|
|
28390
28412
|
var DEFAULT_MAX_CONCURRENCY = 2;
|
|
28391
28413
|
var DEFAULT_MAX_CONTENT_CHARS = 25e4;
|
|
28392
28414
|
function sha256(value) {
|
|
28393
28415
|
if (!value) return null;
|
|
28394
|
-
return
|
|
28416
|
+
return createHash15("sha256").update(value).digest("hex");
|
|
28395
28417
|
}
|
|
28396
28418
|
function countWords(markdown) {
|
|
28397
28419
|
const matches = markdown.trim().match(/\b[\p{L}\p{N}][\p{L}\p{N}'-]*\b/gu);
|
|
@@ -29167,9 +29189,9 @@ async function logRequestEventBestEffort(input) {
|
|
|
29167
29189
|
}
|
|
29168
29190
|
}
|
|
29169
29191
|
function captureBillingKeys(userId, suppliedKey, body3) {
|
|
29170
|
-
const responseKey = suppliedKey?.trim() ||
|
|
29171
|
-
const requestFingerprint3 =
|
|
29172
|
-
const keyDigest =
|
|
29192
|
+
const responseKey = suppliedKey?.trim() || randomUUID13();
|
|
29193
|
+
const requestFingerprint3 = createHash16("sha256").update(JSON.stringify(body3)).digest("hex");
|
|
29194
|
+
const keyDigest = createHash16("sha256").update(String(userId)).update("\0").update(responseKey).digest("hex");
|
|
29173
29195
|
return {
|
|
29174
29196
|
responseKey,
|
|
29175
29197
|
debitKey: `serp-capture:${userId}:${keyDigest}`,
|
|
@@ -29497,7 +29519,7 @@ var MemoryMcpToolExecutor = class {
|
|
|
29497
29519
|
};
|
|
29498
29520
|
|
|
29499
29521
|
// src/api/image-source-artifacts.ts
|
|
29500
|
-
import { randomUUID as
|
|
29522
|
+
import { randomUUID as randomUUID14 } from "crypto";
|
|
29501
29523
|
var IMAGE_SOURCE_ARTIFACT_PREFIX = "image-sources/";
|
|
29502
29524
|
var IMAGE_SOURCE_ARTIFACT_TTL_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
29503
29525
|
var IMAGE_SOURCE_DOWNLOAD_TTL_MS = 15 * 60 * 1e3;
|
|
@@ -29528,7 +29550,7 @@ async function createImageSourceArtifact(args) {
|
|
|
29528
29550
|
if (args.content.length === 0 || args.content.length > IMAGE_SOURCE_MAX_BYTES) {
|
|
29529
29551
|
throw new Error("image_source_size_invalid");
|
|
29530
29552
|
}
|
|
29531
|
-
const id2 =
|
|
29553
|
+
const id2 = randomUUID14().replaceAll("-", "");
|
|
29532
29554
|
return createPrivateArtifact({
|
|
29533
29555
|
policy: policy3(),
|
|
29534
29556
|
ownerId: args.ownerId,
|
|
@@ -29560,12 +29582,12 @@ var HybridMemoryToolExecutor = class {
|
|
|
29560
29582
|
}
|
|
29561
29583
|
httpExecutor;
|
|
29562
29584
|
user;
|
|
29563
|
-
|
|
29564
|
-
async
|
|
29565
|
-
if (!this.
|
|
29566
|
-
this.
|
|
29585
|
+
serviceTokenPromise = null;
|
|
29586
|
+
async resolveServiceToken() {
|
|
29587
|
+
if (!this.serviceTokenPromise) {
|
|
29588
|
+
this.serviceTokenPromise = getMemoryServiceToken(this.user).then((r) => r.key);
|
|
29567
29589
|
}
|
|
29568
|
-
return this.
|
|
29590
|
+
return this.serviceTokenPromise;
|
|
29569
29591
|
}
|
|
29570
29592
|
async callMemoryTool(upstreamName, args) {
|
|
29571
29593
|
const accessDenied = memoryScheduleAccessPayload(upstreamName, this.user);
|
|
@@ -29619,10 +29641,10 @@ var HybridMemoryToolExecutor = class {
|
|
|
29619
29641
|
}
|
|
29620
29642
|
const handler = CUTOVER.get(upstreamName);
|
|
29621
29643
|
if (!handler) return this.httpExecutor.callMemoryTool(upstreamName, args);
|
|
29622
|
-
const
|
|
29623
|
-
if (!
|
|
29644
|
+
const serviceToken = await this.resolveServiceToken();
|
|
29645
|
+
if (!serviceToken) return { content: [{ type: "text", text: "memory unavailable" }], isError: true };
|
|
29624
29646
|
try {
|
|
29625
|
-
return await handler(args,
|
|
29647
|
+
return await handler(args, serviceToken);
|
|
29626
29648
|
} catch (err) {
|
|
29627
29649
|
const message = err instanceof Error ? err.message : `memory ${upstreamName} failed in-process`;
|
|
29628
29650
|
return { content: [{ type: "text", text: message }], isError: true };
|
|
@@ -29995,7 +30017,7 @@ import { getChatLinkTool } from "mcpscraper-memory-tools/tools/access/get-chat-l
|
|
|
29995
30017
|
import { revokeChatLinkTool } from "mcpscraper-memory-tools/tools/access/revoke-chat-link";
|
|
29996
30018
|
import { getVaultAppLinkTool } from "mcpscraper-memory-tools/tools/access/get-vault-app-link";
|
|
29997
30019
|
import { revokeVaultAppLinkTool } from "mcpscraper-memory-tools/tools/access/revoke-vault-app-link";
|
|
29998
|
-
import { provisionDefaultsTool
|
|
30020
|
+
import { provisionDefaultsTool } from "mcpscraper-memory-tools/tools/vaults/provision-defaults";
|
|
29999
30021
|
import { createSecureVaultTool } from "mcpscraper-memory-tools/tools/vaults/create-secure-vault";
|
|
30000
30022
|
import { createScheduledActionTool } from "mcpscraper-memory-tools/tools/schedule/create-scheduled-action";
|
|
30001
30023
|
import { getScheduleStatusTool } from "mcpscraper-memory-tools/tools/schedule/get-schedule-status";
|
|
@@ -30045,7 +30067,7 @@ function registerBillingCutovers() {
|
|
|
30045
30067
|
return { content: [{ type: "text", text: JSON.stringify(result3 ?? {}) }], structuredContent: result3 ?? {}, isError: false };
|
|
30046
30068
|
});
|
|
30047
30069
|
registerCutover("provisionDefaultsTool", async (input, apiKey) => {
|
|
30048
|
-
const result3 = await
|
|
30070
|
+
const result3 = await provisionDefaultsTool.execute({ ...input, apiKey }, {});
|
|
30049
30071
|
return { content: [{ type: "text", text: JSON.stringify(result3 ?? {}) }], structuredContent: result3 ?? {}, isError: false };
|
|
30050
30072
|
});
|
|
30051
30073
|
registerCutover("createSecureVaultTool", async (input, apiKey) => {
|
|
@@ -30273,11 +30295,11 @@ mcpApp.all("/", async (c) => {
|
|
|
30273
30295
|
});
|
|
30274
30296
|
|
|
30275
30297
|
// src/api/browser-agent-routes.ts
|
|
30276
|
-
import { randomUUID as
|
|
30298
|
+
import { randomUUID as randomUUID19 } from "crypto";
|
|
30277
30299
|
import { Hono as Hono26 } from "hono";
|
|
30278
30300
|
|
|
30279
30301
|
// src/api/browser-agent-db.ts
|
|
30280
|
-
import { randomUUID as
|
|
30302
|
+
import { randomUUID as randomUUID15 } from "crypto";
|
|
30281
30303
|
var _ready = false;
|
|
30282
30304
|
var _migrationPromise = null;
|
|
30283
30305
|
async function migrateBrowserAgent() {
|
|
@@ -30456,7 +30478,7 @@ async function runBrowserAgentMigration() {
|
|
|
30456
30478
|
}
|
|
30457
30479
|
async function createExtensionRow(input) {
|
|
30458
30480
|
const db = getDb();
|
|
30459
|
-
const id2 = `bext_${
|
|
30481
|
+
const id2 = `bext_${randomUUID15().replace(/-/g, "").slice(0, 20)}`;
|
|
30460
30482
|
await db.execute({
|
|
30461
30483
|
sql: `INSERT INTO browser_agent_extensions (id, user_id, name, backend_id, backend_name, source, source_url, size_bytes)
|
|
30462
30484
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
@@ -30491,7 +30513,7 @@ async function deleteExtensionRow(userId, name) {
|
|
|
30491
30513
|
}
|
|
30492
30514
|
async function createAuthConnectionRow(input) {
|
|
30493
30515
|
const db = getDb();
|
|
30494
|
-
const connectionId = `authc_${
|
|
30516
|
+
const connectionId = `authc_${randomUUID15().replace(/-/g, "").slice(0, 20)}`;
|
|
30495
30517
|
await db.execute({
|
|
30496
30518
|
sql: `INSERT INTO browser_auth_connections (connection_id, user_id, domain, profile, account_email, note, status, browser_agent_session_id)
|
|
30497
30519
|
VALUES (?, ?, ?, ?, ?, ?, 'NEEDS_AUTH', ?)`,
|
|
@@ -30574,7 +30596,7 @@ async function deleteProfileLabel(userId, profile) {
|
|
|
30574
30596
|
}
|
|
30575
30597
|
async function createSessionRow(input) {
|
|
30576
30598
|
const db = getDb();
|
|
30577
|
-
const id2 = `bas_${
|
|
30599
|
+
const id2 = `bas_${randomUUID15().replace(/-/g, "").slice(0, 20)}`;
|
|
30578
30600
|
await db.execute({
|
|
30579
30601
|
sql: `INSERT INTO browser_agent_sessions (id, runtime_session_id, live_view_url, cdp_ws_url, status, label, user_id, concurrency_lock_id, last_action_at)
|
|
30580
30602
|
VALUES (?, ?, ?, ?, 'open', ?, ?, ?, datetime('now'))`,
|
|
@@ -30652,7 +30674,7 @@ async function recordAction(input) {
|
|
|
30652
30674
|
sql: `INSERT INTO browser_agent_actions (id, session_id, type, params_json, ok, error)
|
|
30653
30675
|
VALUES (?, ?, ?, ?, ?, ?)`,
|
|
30654
30676
|
args: [
|
|
30655
|
-
`baa_${
|
|
30677
|
+
`baa_${randomUUID15().replace(/-/g, "").slice(0, 20)}`,
|
|
30656
30678
|
input.sessionId,
|
|
30657
30679
|
input.type,
|
|
30658
30680
|
input.params == null ? null : JSON.stringify(input.params),
|
|
@@ -31391,7 +31413,7 @@ async function runFanoutCapture(page3, input) {
|
|
|
31391
31413
|
}
|
|
31392
31414
|
|
|
31393
31415
|
// src/services/browser-agent/kernel-browser-runtime.ts
|
|
31394
|
-
import { createHmac as createHmac4, randomUUID as
|
|
31416
|
+
import { createHmac as createHmac4, randomUUID as randomUUID16 } from "crypto";
|
|
31395
31417
|
import Kernel5 from "@onkernel/sdk";
|
|
31396
31418
|
import { chromium as playwrightChromium } from "playwright";
|
|
31397
31419
|
|
|
@@ -31537,7 +31559,7 @@ var KernelBrowserRuntime = class {
|
|
|
31537
31559
|
await this.client.browsers.update(browser.session_id, { viewport: input.viewport }).catch(() => void 0);
|
|
31538
31560
|
}
|
|
31539
31561
|
const createdAtMs = this.now();
|
|
31540
|
-
const sessionRef = `brs_${
|
|
31562
|
+
const sessionRef = `brs_${randomUUID16()}`;
|
|
31541
31563
|
const session = {
|
|
31542
31564
|
ownerRef,
|
|
31543
31565
|
profileRef,
|
|
@@ -32113,9 +32135,9 @@ async function replayList(runtimeSessionId) {
|
|
|
32113
32135
|
}
|
|
32114
32136
|
|
|
32115
32137
|
// src/api/serp-identity-db.ts
|
|
32116
|
-
import { randomUUID as
|
|
32138
|
+
import { randomUUID as randomUUID17 } from "crypto";
|
|
32117
32139
|
async function createSerpIdentityRow(input) {
|
|
32118
|
-
const id2 = `serpi_${
|
|
32140
|
+
const id2 = `serpi_${randomUUID17().replace(/-/g, "").slice(0, 20)}`;
|
|
32119
32141
|
await getDb().execute({
|
|
32120
32142
|
sql: `INSERT INTO serp_identities
|
|
32121
32143
|
(id, user_id, name, kernel_profile_name, kernel_proxy_id, proxy_type, country, status)
|
|
@@ -32162,7 +32184,7 @@ async function deleteSerpIdentityRow(userId, name) {
|
|
|
32162
32184
|
}
|
|
32163
32185
|
|
|
32164
32186
|
// src/api/serp-identity-service.ts
|
|
32165
|
-
import { createHash as
|
|
32187
|
+
import { createHash as createHash17, randomUUID as randomUUID18 } from "crypto";
|
|
32166
32188
|
import Kernel7 from "@onkernel/sdk";
|
|
32167
32189
|
var MAX_SERP_IDENTITIES_PER_USER = 3;
|
|
32168
32190
|
function kernelClient() {
|
|
@@ -32171,8 +32193,8 @@ function kernelClient() {
|
|
|
32171
32193
|
return new Kernel7({ apiKey });
|
|
32172
32194
|
}
|
|
32173
32195
|
function backendName(userId, name, resource) {
|
|
32174
|
-
const digest23 =
|
|
32175
|
-
const nonce =
|
|
32196
|
+
const digest23 = createHash17("sha256").update(`${userId}:${name}`).digest("hex").slice(0, 16);
|
|
32197
|
+
const nonce = randomUUID18().replace(/-/g, "").slice(0, 8);
|
|
32176
32198
|
return `mcp-serp-${resource}-${digest23}-${nonce}`;
|
|
32177
32199
|
}
|
|
32178
32200
|
function isNotFound3(error) {
|
|
@@ -32965,7 +32987,7 @@ function buildBrowserAgentRoutes() {
|
|
|
32965
32987
|
}
|
|
32966
32988
|
const existing = await getExtensionRow(user.id, name);
|
|
32967
32989
|
if (existing) return c.json({ error: `an extension named "${name}" already exists \u2014 delete it first or pick another name` }, 409);
|
|
32968
|
-
const backendName2 = `u${user.id}_${
|
|
32990
|
+
const backendName2 = `u${user.id}_${randomUUID19().replace(/-/g, "")}`;
|
|
32969
32991
|
try {
|
|
32970
32992
|
const imported = await importExtensionFromStore(storeUrl, backendName2);
|
|
32971
32993
|
const row = await createExtensionRow({
|
|
@@ -33305,7 +33327,7 @@ function shouldGrantScraperSubscriptionCredits(invoiceHasTierLine, invoiceTotal)
|
|
|
33305
33327
|
}
|
|
33306
33328
|
|
|
33307
33329
|
// src/api/analytics-journey.ts
|
|
33308
|
-
import { createHash as
|
|
33330
|
+
import { createHash as createHash24, createHmac as createHmac8, generateKeyPairSync, randomUUID as randomUUID24, sign } from "crypto";
|
|
33309
33331
|
import twilio2 from "twilio";
|
|
33310
33332
|
|
|
33311
33333
|
// src/api/analytics-contracts.ts
|
|
@@ -33866,11 +33888,11 @@ var AnalyticsEventDefinitionSchema = z32.object({
|
|
|
33866
33888
|
});
|
|
33867
33889
|
|
|
33868
33890
|
// src/api/analytics-candidate-associations.ts
|
|
33869
|
-
import { createHmac as createHmac5, randomUUID as
|
|
33891
|
+
import { createHmac as createHmac5, randomUUID as randomUUID21 } from "crypto";
|
|
33870
33892
|
import ipaddr from "ipaddr.js";
|
|
33871
33893
|
|
|
33872
33894
|
// src/api/analytics-identity-namespace.ts
|
|
33873
|
-
import { randomUUID as
|
|
33895
|
+
import { randomUUID as randomUUID20 } from "crypto";
|
|
33874
33896
|
async function listAnalyticsIdentityNamespaces(input) {
|
|
33875
33897
|
const result3 = await getAnalyticsPool().query(
|
|
33876
33898
|
`SELECT id, site_id, name, status, version, approved_at
|
|
@@ -33949,7 +33971,7 @@ async function createAnalyticsIdentityNamespace(input) {
|
|
|
33949
33971
|
id, site_id, name, status, approved_hosts, approved_sources, version, approved_by_user_id
|
|
33950
33972
|
) VALUES ($1,$2,$3,'draft','[]'::jsonb,'[]'::jsonb,1,$4)
|
|
33951
33973
|
RETURNING id, site_id, name, status, version, approved_at`,
|
|
33952
|
-
[
|
|
33974
|
+
[randomUUID20(), input.siteId, name, input.createdByUserId]
|
|
33953
33975
|
);
|
|
33954
33976
|
const saved = created.rows[0];
|
|
33955
33977
|
await client2.query("COMMIT");
|
|
@@ -33989,7 +34011,7 @@ async function approveAnalyticsNamespaceSource(input) {
|
|
|
33989
34011
|
ON CONFLICT(namespace_id, source_kind, source_ref) DO UPDATE
|
|
33990
34012
|
SET status='approved', revoked_at=NULL
|
|
33991
34013
|
RETURNING id, namespace_id, site_id, source_kind, source_ref, status, created_at, revoked_at`,
|
|
33992
|
-
[
|
|
34014
|
+
[randomUUID20(), input.namespaceId, input.siteId, storedKind, sourceRef]
|
|
33993
34015
|
);
|
|
33994
34016
|
await client2.query(
|
|
33995
34017
|
`UPDATE analytics_identity_namespaces
|
|
@@ -34150,7 +34172,7 @@ async function promoteAnalyticsCandidateWithDeterministicEvidence(input) {
|
|
|
34150
34172
|
) VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10)
|
|
34151
34173
|
ON CONFLICT(association_id, person_id) DO NOTHING`,
|
|
34152
34174
|
[
|
|
34153
|
-
|
|
34175
|
+
randomUUID21(),
|
|
34154
34176
|
input.siteId,
|
|
34155
34177
|
input.namespaceId,
|
|
34156
34178
|
input.associationId,
|
|
@@ -34169,7 +34191,7 @@ async function promoteAnalyticsCandidateWithDeterministicEvidence(input) {
|
|
|
34169
34191
|
) VALUES ($1,$2,$3,$4,'candidate_promoted',$5,$6,'promoted',$7::jsonb,$8)
|
|
34170
34192
|
ON CONFLICT(site_id, idempotency_key) DO NOTHING`,
|
|
34171
34193
|
[
|
|
34172
|
-
|
|
34194
|
+
randomUUID21(),
|
|
34173
34195
|
input.siteId,
|
|
34174
34196
|
input.namespaceId,
|
|
34175
34197
|
input.associationId,
|
|
@@ -34188,7 +34210,7 @@ async function promoteAnalyticsCandidateWithDeterministicEvidence(input) {
|
|
|
34188
34210
|
'xray.identity-promotion.v1',$11,$12)
|
|
34189
34211
|
ON CONFLICT(site_id,idempotency_key) DO NOTHING`,
|
|
34190
34212
|
[
|
|
34191
|
-
|
|
34213
|
+
randomUUID21(),
|
|
34192
34214
|
input.siteId,
|
|
34193
34215
|
input.namespaceId,
|
|
34194
34216
|
input.personId,
|
|
@@ -34218,16 +34240,16 @@ async function promoteAnalyticsCandidateWithDeterministicEvidence(input) {
|
|
|
34218
34240
|
}
|
|
34219
34241
|
|
|
34220
34242
|
// src/api/analytics-crm-outbound.ts
|
|
34221
|
-
import { createHash as
|
|
34243
|
+
import { createHash as createHash20 } from "crypto";
|
|
34222
34244
|
import { z as z33 } from "zod";
|
|
34223
34245
|
|
|
34224
34246
|
// src/api/analytics-crm-repository.ts
|
|
34225
|
-
import { createHash as
|
|
34247
|
+
import { createHash as createHash18, randomUUID as randomUUID22 } from "crypto";
|
|
34226
34248
|
function dbOrDefault(db) {
|
|
34227
34249
|
return db ?? getAnalyticsPool();
|
|
34228
34250
|
}
|
|
34229
34251
|
function analyticsCrmRequestFingerprint(input) {
|
|
34230
|
-
return
|
|
34252
|
+
return createHash18("sha256").update(JSON.stringify(input)).digest("hex");
|
|
34231
34253
|
}
|
|
34232
34254
|
async function requireConnection(input) {
|
|
34233
34255
|
const result3 = await dbOrDefault(input.db).query(
|
|
@@ -34283,7 +34305,7 @@ async function persistAnalyticsCrmProvisioningPlan(input) {
|
|
|
34283
34305
|
created_by_user_id,public_plan_id,schema_fingerprint,request_fingerprint,created_at,updated_at
|
|
34284
34306
|
) VALUES($1,$2,$3,$4,1,$5,$6::jsonb,'preview',$7,$8,$9,$10,$11,$11)`,
|
|
34285
34307
|
[
|
|
34286
|
-
|
|
34308
|
+
randomUUID22(),
|
|
34287
34309
|
input.siteId,
|
|
34288
34310
|
connectionId,
|
|
34289
34311
|
plan.provider,
|
|
@@ -34337,7 +34359,7 @@ async function persistAnalyticsCrmProvisioningReceipt(input) {
|
|
|
34337
34359
|
) VALUES($1,$2,$3,$4,$5,'[]'::jsonb,$6,$7,$8::jsonb)
|
|
34338
34360
|
ON CONFLICT (public_receipt_id) WHERE public_receipt_id IS NOT NULL
|
|
34339
34361
|
DO UPDATE SET operation=EXCLUDED.operation,status=EXCLUDED.status,safe_error_code=EXCLUDED.safe_error_code,receipt=EXCLUDED.receipt`,
|
|
34340
|
-
[
|
|
34362
|
+
[randomUUID22(), plan.rows[0].id, operation, status, receipt4.errorCode ?? null, receipt4.occurredAt, receipt4.receiptId, JSON.stringify(receipt4)]
|
|
34341
34363
|
);
|
|
34342
34364
|
await db.query(
|
|
34343
34365
|
`UPDATE analytics_crm_provisioning_plans
|
|
@@ -34463,7 +34485,7 @@ async function scheduleAnalyticsCrmSyncRun(input) {
|
|
|
34463
34485
|
next_attempt_at=CASE WHEN analytics_reconciliation_jobs.status='leased'
|
|
34464
34486
|
THEN analytics_reconciliation_jobs.next_attempt_at ELSE EXCLUDED.next_attempt_at END,
|
|
34465
34487
|
updated_at=now()`,
|
|
34466
|
-
[
|
|
34488
|
+
[randomUUID22(), input.connectionId, input.nextRunAt]
|
|
34467
34489
|
);
|
|
34468
34490
|
}
|
|
34469
34491
|
return true;
|
|
@@ -34535,7 +34557,7 @@ async function completeAnalyticsCrmInboundPage(input) {
|
|
|
34535
34557
|
`INSERT INTO analytics_crm_sync_receipts(
|
|
34536
34558
|
id,site_id,connection_id,direction,operation,subject_ref,external_receipt_id,status,occurred_at
|
|
34537
34559
|
) VALUES($1,$2,$3,'inbound','historical_pull',NULL,$4,'accepted',now())`,
|
|
34538
|
-
[
|
|
34560
|
+
[randomUUID22(), input.siteId, input.connectionId, input.receiptFingerprint]
|
|
34539
34561
|
);
|
|
34540
34562
|
}
|
|
34541
34563
|
async function deferAnalyticsCrmInboundPage(input) {
|
|
@@ -34563,7 +34585,7 @@ async function deferAnalyticsCrmInboundPage(input) {
|
|
|
34563
34585
|
`INSERT INTO analytics_crm_sync_receipts(
|
|
34564
34586
|
id,site_id,connection_id,direction,operation,subject_ref,external_receipt_id,status,safe_error_code,occurred_at
|
|
34565
34587
|
) VALUES($1,$2,$3,'inbound','historical_pull',NULL,$4,$5,$6,now())`,
|
|
34566
|
-
[
|
|
34588
|
+
[randomUUID22(), input.siteId, input.connectionId, input.receiptFingerprint, status, input.safeErrorCode]
|
|
34567
34589
|
);
|
|
34568
34590
|
}
|
|
34569
34591
|
function projectOutboundPolicy(row) {
|
|
@@ -34735,7 +34757,7 @@ async function claimAnalyticsCrmOutboundJobs(input) {
|
|
|
34735
34757
|
await dbOrDefault(input.db).query(
|
|
34736
34758
|
`INSERT INTO analytics_crm_outbound_attempts(id,job_id,attempt,status,started_at)
|
|
34737
34759
|
VALUES($1,$2,$3,'started',now()) ON CONFLICT(job_id,attempt) DO NOTHING`,
|
|
34738
|
-
[
|
|
34760
|
+
[randomUUID22(), row.job_id, Number(row.attempts)]
|
|
34739
34761
|
);
|
|
34740
34762
|
}
|
|
34741
34763
|
return result3.rows.map((row) => ({
|
|
@@ -34838,7 +34860,7 @@ async function settleAnalyticsCrmOutboundJob(input) {
|
|
|
34838
34860
|
await db.query(
|
|
34839
34861
|
`INSERT INTO analytics_crm_outbound_attempts(id,job_id,attempt,status,safe_error_code,completed_at)
|
|
34840
34862
|
VALUES($1,$2,$3,$4,$5,now()) ON CONFLICT(job_id,attempt) DO UPDATE SET status=EXCLUDED.status,safe_error_code=EXCLUDED.safe_error_code,completed_at=now()`,
|
|
34841
|
-
[
|
|
34863
|
+
[randomUUID22(), input.jobId, attempt, input.status === "accepted" ? "accepted" : state2 === "retrying" ? "retrying" : "failed", input.safeErrorCode ?? null]
|
|
34842
34864
|
);
|
|
34843
34865
|
await db.query(
|
|
34844
34866
|
`INSERT INTO analytics_crm_outbound_receipts(receipt_id,job_id,status,external_receipt_id,safe_error_code)
|
|
@@ -34874,7 +34896,7 @@ async function listAnalyticsCrmOutboundReceipts(input) {
|
|
|
34874
34896
|
}
|
|
34875
34897
|
|
|
34876
34898
|
// src/api/analytics-crm-provisioning.ts
|
|
34877
|
-
import { createHash as
|
|
34899
|
+
import { createHash as createHash19 } from "crypto";
|
|
34878
34900
|
|
|
34879
34901
|
// src/api/analytics-crm-provider-contract.ts
|
|
34880
34902
|
var ANALYTICS_CRM_PROVIDER_IDS = [
|
|
@@ -35245,10 +35267,10 @@ var XRAY_FIELDS = [
|
|
|
35245
35267
|
{ internalName: "xray_consent_receipt_ref", label: "X-Ray Consent Receipt", type: "string", writable: true }
|
|
35246
35268
|
];
|
|
35247
35269
|
function stableId(prefix, input) {
|
|
35248
|
-
return `${prefix}_${
|
|
35270
|
+
return `${prefix}_${createHash19("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24)}`;
|
|
35249
35271
|
}
|
|
35250
35272
|
function fingerprint2(input) {
|
|
35251
|
-
return
|
|
35273
|
+
return createHash19("sha256").update(JSON.stringify(input)).digest("hex");
|
|
35252
35274
|
}
|
|
35253
35275
|
function analyticsCrmSchemaFingerprint(fields) {
|
|
35254
35276
|
return fingerprint2([...fields].sort(
|
|
@@ -35655,7 +35677,7 @@ var OutboundPayloadSchema = z33.object({
|
|
|
35655
35677
|
}).strict().nullable()
|
|
35656
35678
|
}).strict();
|
|
35657
35679
|
function id(prefix, input) {
|
|
35658
|
-
return `${prefix}_${
|
|
35680
|
+
return `${prefix}_${createHash20("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24)}`;
|
|
35659
35681
|
}
|
|
35660
35682
|
function pathOnly(value) {
|
|
35661
35683
|
const normalized = normalizeAnalyticsUrl(value);
|
|
@@ -35863,7 +35885,7 @@ async function drainAnalyticsCrmOutbound(limit = 10, deadlineMs = Date.now() + D
|
|
|
35863
35885
|
}
|
|
35864
35886
|
|
|
35865
35887
|
// src/api/analytics-lead-scoring.ts
|
|
35866
|
-
import { createHash as
|
|
35888
|
+
import { createHash as createHash21, randomUUID as randomUUID23 } from "crypto";
|
|
35867
35889
|
import { z as z34 } from "zod";
|
|
35868
35890
|
var SafeIdentifierSchema = z34.string().trim().min(1).max(160).regex(/^[a-zA-Z0-9_.:-]+$/);
|
|
35869
35891
|
var PropertyNameSchema = z34.string().trim().min(1).max(160).regex(/^[a-zA-Z][a-zA-Z0-9_.:-]*$/);
|
|
@@ -35981,11 +36003,11 @@ function predicateEvidence(predicate, facts, evaluatedAt) {
|
|
|
35981
36003
|
}
|
|
35982
36004
|
function stableFingerprint(value) {
|
|
35983
36005
|
const normalize = (input) => Array.isArray(input) ? input.map(normalize) : input && typeof input === "object" ? Object.fromEntries(Object.entries(input).sort(([a], [b]) => a.localeCompare(b)).map(([property, nested]) => [property, normalize(nested)])) : input;
|
|
35984
|
-
return
|
|
36006
|
+
return createHash21("sha256").update(JSON.stringify(normalize(value))).digest("hex");
|
|
35985
36007
|
}
|
|
35986
36008
|
function createAnalyticsLeadScore(input) {
|
|
35987
36009
|
const parsed = ScoreDefinitionInputSchema.parse(input.definition);
|
|
35988
|
-
const id2 = input.id ??
|
|
36010
|
+
const id2 = input.id ?? randomUUID23();
|
|
35989
36011
|
if (input.tables.definitions.has(key(parsed.namespaceId, id2))) throw new AnalyticsLeadScoringError("analytics_score_exists", "A lead score with this ID already exists.");
|
|
35990
36012
|
const timestamp5 = nowIso(input.now);
|
|
35991
36013
|
const definition = { id: id2, ...parsed, groups: parsed.groups.map((group) => ({ ...group, predicates: group.predicates.map((predicate) => ({ ...predicate })) })), version: 1, createdAt: timestamp5, updatedAt: timestamp5 };
|
|
@@ -36021,7 +36043,7 @@ function evaluateAnalyticsLeadScore(input) {
|
|
|
36021
36043
|
const idempotencyKey4 = stableFingerprint({ namespaceId: input.namespaceId, scoreId: input.scoreId, version: definition.version, subjectRef: input.subjectRef, identityTier: input.identityTier, components, value });
|
|
36022
36044
|
const existing = input.tables.evaluations.get(idempotencyKey4);
|
|
36023
36045
|
if (existing) return { ...existing, components: existing.components.map((component) => ({ ...component, evidenceRefs: [...component.evidenceRefs] })), evidenceRefs: [...existing.evidenceRefs] };
|
|
36024
|
-
const evaluation = { id:
|
|
36046
|
+
const evaluation = { id: randomUUID23(), namespaceId: input.namespaceId, subjectRef: input.subjectRef, identityTier: input.identityTier, scoreId: definition.id, scoreVersion: definition.version, scoreKind: definition.kind, value, components, evidenceRefs, evaluatedAt, idempotencyKey: idempotencyKey4, providerEligible: input.identityTier === "confirmed" };
|
|
36025
36047
|
input.tables.evaluations.set(idempotencyKey4, evaluation);
|
|
36026
36048
|
input.tables.evaluationHistory.push(evaluation);
|
|
36027
36049
|
return { ...evaluation, components: evaluation.components.map((component) => ({ ...component, evidenceRefs: [...component.evidenceRefs] })), evidenceRefs: [...evaluation.evidenceRefs] };
|
|
@@ -36253,7 +36275,7 @@ function normalizeTwilioWebhook(input) {
|
|
|
36253
36275
|
}
|
|
36254
36276
|
|
|
36255
36277
|
// src/api/analytics-session-reports.ts
|
|
36256
|
-
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, createHash as
|
|
36278
|
+
import { createCipheriv as createCipheriv2, createDecipheriv as createDecipheriv2, createHash as createHash22, createHmac as createHmac7 } from "crypto";
|
|
36257
36279
|
var prefixes = {
|
|
36258
36280
|
session: "xrs_",
|
|
36259
36281
|
visitor: "xrv_",
|
|
@@ -36262,7 +36284,7 @@ var prefixes = {
|
|
|
36262
36284
|
candidate: "xri_"
|
|
36263
36285
|
};
|
|
36264
36286
|
function reportKey(purpose) {
|
|
36265
|
-
return
|
|
36287
|
+
return createHash22("sha256").update(`xray-report:${purpose}:`).update(getSessionSecret()).digest();
|
|
36266
36288
|
}
|
|
36267
36289
|
function createAnalyticsReportReference(kind, siteId, value) {
|
|
36268
36290
|
const key3 = reportKey("reference");
|
|
@@ -36969,7 +36991,7 @@ async function analyticsInferenceReview(input, db = getAnalyticsPool()) {
|
|
|
36969
36991
|
}
|
|
36970
36992
|
|
|
36971
36993
|
// src/api/analytics-providers/crm.ts
|
|
36972
|
-
import { createHash as
|
|
36994
|
+
import { createHash as createHash23, createVerify, verify } from "crypto";
|
|
36973
36995
|
function verifyHubSpotWebhook(input) {
|
|
36974
36996
|
if (!webhookTimestampFresh(input.timestamp, input.now)) return false;
|
|
36975
36997
|
const source = `${input.method.toUpperCase()}${input.url}${input.rawBody}${input.timestamp}`;
|
|
@@ -37008,7 +37030,7 @@ function verifyHighLevelWebhook(input) {
|
|
|
37008
37030
|
function crmStageToExternalEvent(event2) {
|
|
37009
37031
|
return {
|
|
37010
37032
|
schemaVersion: 1,
|
|
37011
|
-
eventId: `crm_${
|
|
37033
|
+
eventId: `crm_${createHash23("sha256").update(`${event2.source}:${event2.sourceEventId}`).digest("hex").slice(0, 24)}`,
|
|
37012
37034
|
sourceEventId: event2.sourceEventId,
|
|
37013
37035
|
source: event2.source,
|
|
37014
37036
|
sourceAccountRef: event2.sourceAccountRef,
|
|
@@ -37247,7 +37269,7 @@ async function createAnalyticsEventDefinition(input) {
|
|
|
37247
37269
|
status=EXCLUDED.status, version=analytics_event_definitions.version+1, updated_at=now()
|
|
37248
37270
|
RETURNING id, name, event_name, trigger_kind, definition, version, status, created_at, updated_at`,
|
|
37249
37271
|
[
|
|
37250
|
-
|
|
37272
|
+
randomUUID24(),
|
|
37251
37273
|
input.siteId,
|
|
37252
37274
|
definition.name,
|
|
37253
37275
|
definition.eventName,
|
|
@@ -37429,7 +37451,7 @@ async function createAnalyticsConnection(input) {
|
|
|
37429
37451
|
(secret_ciphertext IS NOT NULL) AS webhook_secret_configured,
|
|
37430
37452
|
created_at, updated_at`,
|
|
37431
37453
|
[
|
|
37432
|
-
|
|
37454
|
+
randomUUID24(),
|
|
37433
37455
|
input.siteId,
|
|
37434
37456
|
input.provider.trim().toLowerCase().slice(0, 80),
|
|
37435
37457
|
input.name.trim().slice(0, 120),
|
|
@@ -37643,7 +37665,7 @@ async function describeAnalyticsConnectionReconciliation(input) {
|
|
|
37643
37665
|
};
|
|
37644
37666
|
}
|
|
37645
37667
|
async function recordAnalyticsWebhookReceipt(input) {
|
|
37646
|
-
const id2 =
|
|
37668
|
+
const id2 = randomUUID24();
|
|
37647
37669
|
const payloadCiphertext = input.rawBody ? encryptAnalyticsRestricted(input.rawBody, "webhook-payload") : null;
|
|
37648
37670
|
const result3 = await getAnalyticsPool().query(
|
|
37649
37671
|
`INSERT INTO analytics_webhook_receipts(
|
|
@@ -37731,7 +37753,7 @@ async function createAnalyticsConversionRule(input) {
|
|
|
37731
37753
|
updated_at = now()
|
|
37732
37754
|
RETURNING *`,
|
|
37733
37755
|
[
|
|
37734
|
-
|
|
37756
|
+
randomUUID24(),
|
|
37735
37757
|
input.siteId,
|
|
37736
37758
|
parsed.name,
|
|
37737
37759
|
parsed.conversionKind,
|
|
@@ -38117,7 +38139,7 @@ async function recordAnalyticsExternalEvent(input) {
|
|
|
38117
38139
|
ON CONFLICT(site_id, source, source_account_ref, source_event_id) DO NOTHING
|
|
38118
38140
|
RETURNING id`,
|
|
38119
38141
|
[
|
|
38120
|
-
|
|
38142
|
+
randomUUID24(),
|
|
38121
38143
|
input.siteId,
|
|
38122
38144
|
// This FK targets analytics_webhook_receipts. Consent receipts are
|
|
38123
38145
|
// separate evidence and remain in eligibility/activation payloads.
|
|
@@ -38190,7 +38212,7 @@ async function recordAnalyticsExternalEvent(input) {
|
|
|
38190
38212
|
const storedValueMinor = resolvedValue.valueMinor ?? 0;
|
|
38191
38213
|
const storedCurrency = (resolvedValue.currency || rule.default_currency || "USD").toUpperCase();
|
|
38192
38214
|
const valueSource = resolvedValue.provenance.resolution === "absent" ? "absent" : resolvedValue.provenance.resolution === "fallback" ? "dynamic" : resolvedValue.provenance.resolution;
|
|
38193
|
-
const conversionId =
|
|
38215
|
+
const conversionId = randomUUID24();
|
|
38194
38216
|
const result3 = await client2.query(
|
|
38195
38217
|
`INSERT INTO analytics_conversions(
|
|
38196
38218
|
id, source_event_id, site_id, session_id, conversion_kind,
|
|
@@ -38262,7 +38284,7 @@ async function recordAnalyticsExternalEvent(input) {
|
|
|
38262
38284
|
id, destination_id, conversion_id, person_id, payload_ciphertext
|
|
38263
38285
|
) VALUES ($1,$2,$3,$4,$5)
|
|
38264
38286
|
ON CONFLICT(destination_id, conversion_id) DO NOTHING`,
|
|
38265
|
-
[
|
|
38287
|
+
[randomUUID24(), destination.id, result3.rows[0].id, personId, payload]
|
|
38266
38288
|
);
|
|
38267
38289
|
}
|
|
38268
38290
|
}
|
|
@@ -38831,9 +38853,8 @@ async function resolveUser2(customerId, emailFallback) {
|
|
|
38831
38853
|
// src/api/oauth-routes.ts
|
|
38832
38854
|
import { Hono as Hono28 } from "hono";
|
|
38833
38855
|
import { getCookie, setCookie } from "hono/cookie";
|
|
38834
|
-
import { createHash as
|
|
38835
|
-
|
|
38836
|
-
var ISSUER = "https://mcpscraper.dev";
|
|
38856
|
+
import { createHash as createHash25, randomBytes as randomBytes3 } from "crypto";
|
|
38857
|
+
var ISSUER = OAUTH_ISSUER;
|
|
38837
38858
|
var RESOURCE = () => process.env.MCP_MEMORY_RESOURCE_URL ?? "https://memory.mcpscraper.dev/mcp";
|
|
38838
38859
|
var SCRAPER_RESOURCE = () => (process.env.MCP_SCRAPER_RESOURCE_URL ?? "https://mcpscraper.dev/mcp").replace(/\/$/, "");
|
|
38839
38860
|
var MEMORY_SCOPES = ["memory.read", "memory.write", "memory.admin"];
|
|
@@ -38880,22 +38901,6 @@ var sessionCookieOptions = {
|
|
|
38880
38901
|
maxAge: 60 * 60 * 24 * 30,
|
|
38881
38902
|
sameSite: "Lax"
|
|
38882
38903
|
};
|
|
38883
|
-
var cachedKeys = null;
|
|
38884
|
-
async function getKeys() {
|
|
38885
|
-
if (cachedKeys) return cachedKeys;
|
|
38886
|
-
const raw = process.env.OAUTH_SIGNING_KEY;
|
|
38887
|
-
if (!raw?.trim()) throw new Error("OAUTH_SIGNING_KEY is not set");
|
|
38888
|
-
const pem = raw.includes("BEGIN") ? raw : Buffer.from(raw, "base64").toString("utf8");
|
|
38889
|
-
const privateKey = await importPKCS8(pem, "RS256", { extractable: true });
|
|
38890
|
-
const full = await exportJWK(privateKey);
|
|
38891
|
-
const publicJwk = { kty: full.kty, n: full.n, e: full.e };
|
|
38892
|
-
const kid = createHash24("sha256").update(JSON.stringify({ e: publicJwk.e, kty: publicJwk.kty, n: publicJwk.n })).digest("base64url").slice(0, 16);
|
|
38893
|
-
publicJwk.kid = kid;
|
|
38894
|
-
publicJwk.alg = "RS256";
|
|
38895
|
-
publicJwk.use = "sig";
|
|
38896
|
-
cachedKeys = { privateKey, publicJwk, kid };
|
|
38897
|
-
return cachedKeys;
|
|
38898
|
-
}
|
|
38899
38904
|
function isAllowedRedirect(uri) {
|
|
38900
38905
|
let u;
|
|
38901
38906
|
try {
|
|
@@ -39081,7 +39086,7 @@ oauthApp.get("/.well-known/openid-configuration/*", (c) => {
|
|
|
39081
39086
|
return c.json(openidConfiguration());
|
|
39082
39087
|
});
|
|
39083
39088
|
oauthApp.get("/.well-known/jwks.json", async (c) => {
|
|
39084
|
-
const
|
|
39089
|
+
const publicJwk = await getOAuthPublicJwk();
|
|
39085
39090
|
c.header("Cache-Control", "public, max-age=3600");
|
|
39086
39091
|
return c.json({ keys: [publicJwk] });
|
|
39087
39092
|
});
|
|
@@ -39211,12 +39216,11 @@ oauthApp.post("/oauth/authorize", async (c) => {
|
|
|
39211
39216
|
});
|
|
39212
39217
|
function pkceMatches(verifier, challenge) {
|
|
39213
39218
|
if (!verifier) return false;
|
|
39214
|
-
const computed =
|
|
39219
|
+
const computed = createHash25("sha256").update(verifier).digest("base64url");
|
|
39215
39220
|
return computed === challenge;
|
|
39216
39221
|
}
|
|
39217
39222
|
async function mintAccessToken(identity, scope, plan, audience) {
|
|
39218
|
-
|
|
39219
|
-
return new SignJWT({ scope, plan }).setProtectedHeader({ alg: "RS256", kid }).setIssuer(ISSUER).setSubject(identity).setAudience(audience).setIssuedAt().setJti(randomUUID24()).setExpirationTime(`${ACCESS_TTL_SECONDS}s`).sign(privateKey);
|
|
39223
|
+
return mintOAuthAccessToken({ identity, scope, plan, audience, ttlSeconds: ACCESS_TTL_SECONDS });
|
|
39220
39224
|
}
|
|
39221
39225
|
function tokenErrorResponse(c, error, description, status) {
|
|
39222
39226
|
return c.json({ error, error_description: description }, status);
|
|
@@ -40691,7 +40695,7 @@ import { Hono as Hono32 } from "hono";
|
|
|
40691
40695
|
import { Resend } from "resend";
|
|
40692
40696
|
|
|
40693
40697
|
// src/api/resend-support-thread.ts
|
|
40694
|
-
import { createHash as
|
|
40698
|
+
import { createHash as createHash26 } from "crypto";
|
|
40695
40699
|
var SUPPORT_TAGS = [
|
|
40696
40700
|
{
|
|
40697
40701
|
tag: "support",
|
|
@@ -40731,7 +40735,7 @@ function quoteUntrusted(value) {
|
|
|
40731
40735
|
return clean3.split("\n").map((line) => `> ${line}`).join("\n");
|
|
40732
40736
|
}
|
|
40733
40737
|
function shortHash(value, length = 24) {
|
|
40734
|
-
return
|
|
40738
|
+
return createHash26("sha256").update(value).digest("hex").slice(0, length);
|
|
40735
40739
|
}
|
|
40736
40740
|
function safePathPart(value) {
|
|
40737
40741
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48) || "contact";
|
|
@@ -42230,7 +42234,7 @@ import { Hono as Hono34 } from "hono";
|
|
|
42230
42234
|
import { z as z36 } from "zod";
|
|
42231
42235
|
|
|
42232
42236
|
// src/editorial-reading-room/render.ts
|
|
42233
|
-
import { createHash as
|
|
42237
|
+
import { createHash as createHash27 } from "crypto";
|
|
42234
42238
|
import { readFileSync as readFileSync3 } from "fs";
|
|
42235
42239
|
import { dirname as dirname3, join as join8, resolve } from "path";
|
|
42236
42240
|
import { Marked, Renderer } from "marked";
|
|
@@ -42391,7 +42395,7 @@ function renderEditorialReadingRoom(input, now = /* @__PURE__ */ new Date()) {
|
|
|
42391
42395
|
articleCount: articles.length,
|
|
42392
42396
|
wordCount: totalWordCount,
|
|
42393
42397
|
bytes: bytes2,
|
|
42394
|
-
sha256:
|
|
42398
|
+
sha256: createHash27("sha256").update(html).digest("hex"),
|
|
42395
42399
|
warnings
|
|
42396
42400
|
};
|
|
42397
42401
|
}
|
|
@@ -42474,7 +42478,7 @@ ${provenance}`;
|
|
|
42474
42478
|
...rendered,
|
|
42475
42479
|
html,
|
|
42476
42480
|
bytes: Buffer.byteLength(html),
|
|
42477
|
-
sha256:
|
|
42481
|
+
sha256: createHash27("sha256").update(html).digest("hex")
|
|
42478
42482
|
};
|
|
42479
42483
|
}
|
|
42480
42484
|
|
|
@@ -42597,10 +42601,10 @@ import { Hono as Hono35 } from "hono";
|
|
|
42597
42601
|
import { z as z37 } from "zod";
|
|
42598
42602
|
|
|
42599
42603
|
// src/api/commons-repository.ts
|
|
42600
|
-
import { createHash as
|
|
42604
|
+
import { createHash as createHash30, randomUUID as randomUUID26 } from "crypto";
|
|
42601
42605
|
|
|
42602
42606
|
// src/api/commons-image-store.ts
|
|
42603
|
-
import { createHash as
|
|
42607
|
+
import { createHash as createHash28 } from "crypto";
|
|
42604
42608
|
import { lookup as dnsLookup } from "dns/promises";
|
|
42605
42609
|
import { isIP } from "net";
|
|
42606
42610
|
var COMMONS_IMAGE_MAX_BYTES = 10 * 1024 * 1024;
|
|
@@ -42930,7 +42934,7 @@ async function hostCommonsImage(input) {
|
|
|
42930
42934
|
415
|
|
42931
42935
|
);
|
|
42932
42936
|
}
|
|
42933
|
-
const digest23 =
|
|
42937
|
+
const digest23 = createHash28("sha256").update(bytes2).digest("hex");
|
|
42934
42938
|
const existing = await getDb().execute({
|
|
42935
42939
|
sql: "SELECT id, url, content_type, bytes, source_url FROM commons_images WHERE digest = ? LIMIT 1",
|
|
42936
42940
|
args: [digest23]
|
|
@@ -43062,7 +43066,7 @@ async function schemaObjectsPresent(names) {
|
|
|
43062
43066
|
}
|
|
43063
43067
|
|
|
43064
43068
|
// src/api/commons-linksets.ts
|
|
43065
|
-
import { createHash as
|
|
43069
|
+
import { createHash as createHash29 } from "crypto";
|
|
43066
43070
|
var COMMONS_LINKSET_MEDIA_TYPE = "application/linkset+json";
|
|
43067
43071
|
var COMMONS_RELATIONSHIP_PROFILE = "https://mcpscraper.dev/commons/profiles/relationships/v1";
|
|
43068
43072
|
var REGISTERED_RELATIONS = /* @__PURE__ */ new Set([
|
|
@@ -43169,7 +43173,7 @@ function buildCommonsLinkset(entity, claims) {
|
|
|
43169
43173
|
context[claim.predicate] = targets;
|
|
43170
43174
|
}
|
|
43171
43175
|
const document2 = { linkset: [context] };
|
|
43172
|
-
const etag = `"${
|
|
43176
|
+
const etag = `"${createHash29("sha256").update(JSON.stringify(document2)).digest("hex")}"`;
|
|
43173
43177
|
return { document: document2, etag, publicUrl, linksetUrl, profile: COMMONS_RELATIONSHIP_PROFILE };
|
|
43174
43178
|
}
|
|
43175
43179
|
function commonsLinksetDiscoveryHeader(idOrSlug) {
|
|
@@ -44982,7 +44986,7 @@ function commonsIndexDocuments(entity, now) {
|
|
|
44982
44986
|
return documents;
|
|
44983
44987
|
}
|
|
44984
44988
|
function commonsIndexDocumentId(entityId, documentType, documentKey) {
|
|
44985
|
-
return `commons-index-${
|
|
44989
|
+
return `commons-index-${createHash30("sha256").update(`${entityId}
|
|
44986
44990
|
${documentType}
|
|
44987
44991
|
${documentKey}`).digest("hex").slice(0, 32)}`;
|
|
44988
44992
|
}
|
|
@@ -45560,7 +45564,7 @@ var CommonsRepositoryError = class extends Error {
|
|
|
45560
45564
|
};
|
|
45561
45565
|
|
|
45562
45566
|
// src/api/commons-publication-repository.ts
|
|
45563
|
-
import { createHash as
|
|
45567
|
+
import { createHash as createHash31, randomUUID as randomUUID27 } from "crypto";
|
|
45564
45568
|
|
|
45565
45569
|
// src/editorial-reading-room/article-page.ts
|
|
45566
45570
|
function escapeHtml6(value) {
|
|
@@ -45849,7 +45853,7 @@ async function publishCommonsEditorial(input, user) {
|
|
|
45849
45853
|
JSON.stringify(editionInput.articles),
|
|
45850
45854
|
html,
|
|
45851
45855
|
rendered.filename,
|
|
45852
|
-
|
|
45856
|
+
createHash31("sha256").update(html).digest("hex"),
|
|
45853
45857
|
rendered.articleCount,
|
|
45854
45858
|
rendered.wordCount,
|
|
45855
45859
|
Buffer.byteLength(html),
|
|
@@ -45931,7 +45935,7 @@ async function updateCommonsEditorialArticle(input, user) {
|
|
|
45931
45935
|
JSON.stringify(nextArticles),
|
|
45932
45936
|
html,
|
|
45933
45937
|
rendered.filename,
|
|
45934
|
-
|
|
45938
|
+
createHash31("sha256").update(html).digest("hex"),
|
|
45935
45939
|
rendered.articleCount,
|
|
45936
45940
|
rendered.wordCount,
|
|
45937
45941
|
Buffer.byteLength(html),
|
|
@@ -46754,11 +46758,11 @@ function xmlEscape(value) {
|
|
|
46754
46758
|
import { Hono as Hono36 } from "hono";
|
|
46755
46759
|
import { createMiddleware as createMiddleware4 } from "hono/factory";
|
|
46756
46760
|
import { z as z43 } from "zod";
|
|
46757
|
-
import { createHash as
|
|
46761
|
+
import { createHash as createHash44, randomUUID as randomUUID38 } from "crypto";
|
|
46758
46762
|
import Papa5 from "papaparse";
|
|
46759
46763
|
|
|
46760
46764
|
// src/api/analytics-manual-imports.ts
|
|
46761
|
-
import { createHash as
|
|
46765
|
+
import { createHash as createHash32 } from "crypto";
|
|
46762
46766
|
import Papa4 from "papaparse";
|
|
46763
46767
|
import { z as z38 } from "zod";
|
|
46764
46768
|
var AnalyticsManualImportMappingSchema = z38.object({
|
|
@@ -46853,7 +46857,7 @@ function previewAnalyticsManualImport(input) {
|
|
|
46853
46857
|
continue;
|
|
46854
46858
|
}
|
|
46855
46859
|
identities.add(identityKey2);
|
|
46856
|
-
const digest23 =
|
|
46860
|
+
const digest23 = createHash32("sha256").update(`${parsedInput.sourceSystem}:${stableIdentity}`).digest("hex");
|
|
46857
46861
|
const crmEntityId = `${digest23.slice(0, 8)}-${digest23.slice(8, 12)}-5${digest23.slice(13, 16)}-${(Number.parseInt(digest23.slice(16, 18), 16) & 63 | 128).toString(16)}${digest23.slice(18, 20)}-${digest23.slice(20, 32)}`;
|
|
46858
46862
|
rows.push({
|
|
46859
46863
|
row: rowNumber,
|
|
@@ -46875,7 +46879,7 @@ function previewAnalyticsManualImport(input) {
|
|
|
46875
46879
|
});
|
|
46876
46880
|
}
|
|
46877
46881
|
const headers = parsed.meta.fields ?? [];
|
|
46878
|
-
const fingerprint5 =
|
|
46882
|
+
const fingerprint5 = createHash32("sha256").update(canonical({ sourceSystem: parsedInput.sourceSystem, filename: parsedInput.filename, mapping: parsedInput.mapping, rows })).digest("hex");
|
|
46879
46883
|
return {
|
|
46880
46884
|
schemaVersion: 1,
|
|
46881
46885
|
fingerprint: fingerprint5,
|
|
@@ -46890,7 +46894,7 @@ function previewAnalyticsManualImport(input) {
|
|
|
46890
46894
|
};
|
|
46891
46895
|
}
|
|
46892
46896
|
function deterministicAnalyticsManualImportId(input) {
|
|
46893
|
-
const hex =
|
|
46897
|
+
const hex = createHash32("sha256").update(`${input.siteId}:${input.userId}:${input.idempotencyKey}:${input.fingerprint}`).digest("hex");
|
|
46894
46898
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-4${hex.slice(13, 16)}-a${hex.slice(17, 20)}-${hex.slice(20, 32)}`;
|
|
46895
46899
|
}
|
|
46896
46900
|
|
|
@@ -47060,7 +47064,7 @@ function consumeAnalyticsLinkerToken(input) {
|
|
|
47060
47064
|
}
|
|
47061
47065
|
|
|
47062
47066
|
// src/api/nango-control.ts
|
|
47063
|
-
import { createHash as
|
|
47067
|
+
import { createHash as createHash33, randomUUID as randomUUID29 } from "crypto";
|
|
47064
47068
|
|
|
47065
47069
|
// src/api/connected-data-export.ts
|
|
47066
47070
|
import { randomUUID as randomUUID28 } from "crypto";
|
|
@@ -48441,8 +48445,8 @@ async function setScheduleConnectionActionsEnabled(identity, connectionId, enabl
|
|
|
48441
48445
|
return data.connection.actionsEnabled === true;
|
|
48442
48446
|
}
|
|
48443
48447
|
async function callScheduleConnectionAction(identity, connectionId, input, tool, idempotencyKey4) {
|
|
48444
|
-
const requestId = `main-connected-action:${
|
|
48445
|
-
const requestDigest2 =
|
|
48448
|
+
const requestId = `main-connected-action:${createHash33("sha256").update(identity).update("\0").update(idempotencyKey4?.trim() || randomUUID29()).digest("hex")}`;
|
|
48449
|
+
const requestDigest2 = createHash33("sha256").update(connectionId).update("\0").update(tool?.trim() ?? "").update("\0").update(canonicalJson(input)).digest("hex");
|
|
48446
48450
|
if (mainOwnsIntegrations()) {
|
|
48447
48451
|
const selectedTool = tool?.trim();
|
|
48448
48452
|
if (!selectedTool) throw new NangoControlError("An action tool is required.", 400, "invalid_request", false);
|
|
@@ -48593,7 +48597,7 @@ function canonicalJson(value) {
|
|
|
48593
48597
|
return JSON.stringify(value);
|
|
48594
48598
|
}
|
|
48595
48599
|
function projectedToolSchemaHash(tool) {
|
|
48596
|
-
return
|
|
48600
|
+
return createHash33("sha256").update(canonicalJson(tool)).digest("hex");
|
|
48597
48601
|
}
|
|
48598
48602
|
async function describeNangoTool(identity, connectionId, tool, fresh) {
|
|
48599
48603
|
if (mainOwnsIntegrations()) {
|
|
@@ -48784,9 +48788,9 @@ async function callMainOwnedExportPage(identity, input) {
|
|
|
48784
48788
|
});
|
|
48785
48789
|
}
|
|
48786
48790
|
if (connection.providerConfigKey === "google-mail" && input.dataset === "emails") {
|
|
48787
|
-
const { GmailService: GmailService2 } = await import("./gmail-service-
|
|
48791
|
+
const { GmailService: GmailService2 } = await import("./gmail-service-E6ALS7JG.js");
|
|
48788
48792
|
const service = new GmailService2();
|
|
48789
|
-
const ownerId3 =
|
|
48793
|
+
const ownerId3 = createHash33("sha256").update(identity.toLowerCase()).digest("hex").slice(0, 24);
|
|
48790
48794
|
const after = Math.floor(Date.parse(input.from) / 1e3);
|
|
48791
48795
|
const before = Math.ceil(Date.parse(input.to) / 1e3);
|
|
48792
48796
|
if (!Number.isFinite(after) || !Number.isFinite(before) || after >= before) throw new NangoControlError("Gmail export range is invalid.", 400, "invalid_request", false);
|
|
@@ -49027,7 +49031,7 @@ async function discoverAnalyticsActivationAssets(input) {
|
|
|
49027
49031
|
|
|
49028
49032
|
// src/api/analytics-entitlement.ts
|
|
49029
49033
|
import {
|
|
49030
|
-
createHash as
|
|
49034
|
+
createHash as createHash34,
|
|
49031
49035
|
createHmac as createHmac10,
|
|
49032
49036
|
randomBytes as randomBytes4,
|
|
49033
49037
|
timingSafeEqual as timingSafeEqual6
|
|
@@ -49242,7 +49246,7 @@ function dashboardCallbackUrl() {
|
|
|
49242
49246
|
async function createThorbitConnectUrl(userId) {
|
|
49243
49247
|
if (!bridgeConfigured()) throw new Error("Thorbit X-Ray account bridge is not configured");
|
|
49244
49248
|
const state2 = randomBytes4(32).toString("base64url");
|
|
49245
|
-
const stateHash =
|
|
49249
|
+
const stateHash = createHash34("sha256").update(state2).digest("hex");
|
|
49246
49250
|
await getAnalyticsPool().query(
|
|
49247
49251
|
`INSERT INTO analytics_thorbit_connect_states(state_hash,user_id,expires_at)
|
|
49248
49252
|
VALUES ($1,$2,now()+interval '10 minutes')
|
|
@@ -49271,7 +49275,7 @@ function verifyThorbitAssertion(token7) {
|
|
|
49271
49275
|
return parsed.data.entitlement;
|
|
49272
49276
|
}
|
|
49273
49277
|
async function consumeThorbitConnectCallback(input) {
|
|
49274
|
-
const stateHash =
|
|
49278
|
+
const stateHash = createHash34("sha256").update(input.state).digest("hex");
|
|
49275
49279
|
const client2 = await getAnalyticsPool().connect();
|
|
49276
49280
|
try {
|
|
49277
49281
|
await client2.query("BEGIN");
|
|
@@ -49313,7 +49317,7 @@ async function disconnectAnalyticsEntitlement(userId) {
|
|
|
49313
49317
|
}
|
|
49314
49318
|
|
|
49315
49319
|
// src/api/analytics-onboarding.ts
|
|
49316
|
-
import { createHash as
|
|
49320
|
+
import { createHash as createHash35 } from "crypto";
|
|
49317
49321
|
var MINIMUM = "minimum_setup";
|
|
49318
49322
|
var PRODUCTION = "production_readiness";
|
|
49319
49323
|
var ADVANCED = "advanced_optimization";
|
|
@@ -49514,7 +49518,7 @@ var DEFAULT_PRESENTATION = {
|
|
|
49514
49518
|
};
|
|
49515
49519
|
function safeRef(kind, value) {
|
|
49516
49520
|
if (typeof value !== "string" || !value) return null;
|
|
49517
|
-
return `${kind}:${
|
|
49521
|
+
return `${kind}:${createHash35("sha256").update(value).digest("hex").slice(0, 16)}`;
|
|
49518
49522
|
}
|
|
49519
49523
|
function asIso(value) {
|
|
49520
49524
|
if (!value) return null;
|
|
@@ -50100,11 +50104,11 @@ async function analyticsFunnel(input) {
|
|
|
50100
50104
|
}
|
|
50101
50105
|
|
|
50102
50106
|
// src/api/analytics-site-setup.ts
|
|
50103
|
-
import { createHash as
|
|
50107
|
+
import { createHash as createHash39, randomUUID as randomUUID31 } from "crypto";
|
|
50104
50108
|
import { load } from "cheerio";
|
|
50105
50109
|
|
|
50106
50110
|
// src/services/analytics-site-setup/action-candidates.ts
|
|
50107
|
-
import { createHash as
|
|
50111
|
+
import { createHash as createHash36 } from "crypto";
|
|
50108
50112
|
var FORBIDDEN_KEYS = /email|phone|name|address|message|query|token|secret|password|visitor|session|person|ip/i;
|
|
50109
50113
|
var SENSITIVE_VALUE = /@|\b(?:\+?\d[\d\s().-]{7,}\d)\b|bearer\s|api[_-]?key/i;
|
|
50110
50114
|
function slug3(value) {
|
|
@@ -50140,7 +50144,7 @@ function buildAnalyticsActionCandidates(inputs) {
|
|
|
50140
50144
|
const exclusionReason = context.rejected ? "sensitive_context" : occurrenceOnly ? "occurrence_only" : input.confidence < 0.7 ? "low_confidence" : void 0;
|
|
50141
50145
|
return {
|
|
50142
50146
|
...input,
|
|
50143
|
-
candidateId: `candidate_${
|
|
50147
|
+
candidateId: `candidate_${createHash36("sha256").update(stableKey).digest("hex").slice(0, 20)}`,
|
|
50144
50148
|
eventName: slug3(`${input.action}_${input.destination ?? input.label}`),
|
|
50145
50149
|
disposition: exclusionReason ? exclusionReason === "occurrence_only" ? "proposed" : "excluded" : "recommended",
|
|
50146
50150
|
rationale: input.sourceComponent ? `Instrument the shared ${input.sourceComponent} component instead of repeated route instances.` : `Instrument the meaningful ${input.action} action at its owned source boundary.`,
|
|
@@ -50193,10 +50197,10 @@ function buildAnalyticsFirstAnswers(evidence, readiness2, thresholds = DEFAULT_F
|
|
|
50193
50197
|
}
|
|
50194
50198
|
|
|
50195
50199
|
// src/services/analytics-site-setup/improvement-loop.ts
|
|
50196
|
-
import { createHash as
|
|
50200
|
+
import { createHash as createHash37 } from "crypto";
|
|
50197
50201
|
function nextAnalyticsImprovement(input) {
|
|
50198
50202
|
const eligible = input.backlog.filter((item) => item.revision === input.revision && !item.applied && !item.skipped).sort((a, b) => a.rank - b.rank || a.id.localeCompare(b.id))[0] ?? null;
|
|
50199
|
-
const proposalId = `improve_${
|
|
50203
|
+
const proposalId = `improve_${createHash37("sha256").update(`${input.setupId}:${input.revision}:${eligible?.id ?? "none"}`).digest("hex").slice(0, 20)}`;
|
|
50200
50204
|
if (!eligible) return { proposalId, revision: input.revision, action: "none", item: null, confirmationRequired: false, nextAction: "No eligible improvement remains on the active revision." };
|
|
50201
50205
|
if (eligible.kind === "runtime_rule") return { proposalId, revision: input.revision, action: "publish_runtime_rule", item: eligible, confirmationRequired: true, nextAction: `Approve one bounded runtime-rule change for ${eligible.surfaceId ?? "the measured surface"}, then verify manifest convergence.` };
|
|
50202
50206
|
if (eligible.kind === "selector_repair") return { proposalId, revision: input.revision, action: "repair_selector", item: eligible, confirmationRequired: true, nextAction: "Confirm the repaired selector, publish one manifest revision, then verify its bounded match count." };
|
|
@@ -50351,9 +50355,9 @@ function recommendAnalyticsOutcomePlan(evidence, preferred) {
|
|
|
50351
50355
|
}
|
|
50352
50356
|
|
|
50353
50357
|
// src/services/analytics-site-setup/site-inventory.ts
|
|
50354
|
-
import { createHash as
|
|
50358
|
+
import { createHash as createHash38 } from "crypto";
|
|
50355
50359
|
function stableFingerprint2(value) {
|
|
50356
|
-
return
|
|
50360
|
+
return createHash38("sha256").update(JSON.stringify(value)).digest("hex");
|
|
50357
50361
|
}
|
|
50358
50362
|
function buildAnalyticsSiteInventory(input) {
|
|
50359
50363
|
const diagnoses = [];
|
|
@@ -50461,7 +50465,7 @@ async function captureAnalyticsSiteSetupEvidence(input) {
|
|
|
50461
50465
|
const requestedUrl = urls[index];
|
|
50462
50466
|
const parsed = new URL(result3.finalUrl || requestedUrl, root);
|
|
50463
50467
|
const path5 = parsed.pathname || "/";
|
|
50464
|
-
const evidenceId = `live:${
|
|
50468
|
+
const evidenceId = `live:${createHash39("sha256").update(`${requestedUrl}:${result3.status ?? "unreachable"}:${result3.html ? createHash39("sha256").update(result3.html).digest("hex") : "none"}`).digest("hex").slice(0, 24)}`;
|
|
50465
50469
|
if (result3.via === "browser") browserFallbacks += 1;
|
|
50466
50470
|
if (!result3.html) {
|
|
50467
50471
|
routes.push({ path: path5, canonicalUrl: parsed.href, surfaceId: "primary-unknown", reachable: false, pixelScripts: 0, pageViewsOnFirstLoad: 0, semanticTags: 0, evidenceIds: [evidenceId], pixelPublicIds: [], duplicatePageViewSource: false, consentMode: "unknown" });
|
|
@@ -50553,7 +50557,7 @@ async function captureAnalyticsSiteSetupEvidence(input) {
|
|
|
50553
50557
|
}
|
|
50554
50558
|
var ZERO_BILLING = { billingClass: "xray_entitlement", mcpScraperCreditsCharged: 0, providerCosts: [] };
|
|
50555
50559
|
function fingerprint3(value) {
|
|
50556
|
-
return
|
|
50560
|
+
return createHash39("sha256").update(JSON.stringify(value)).digest("hex");
|
|
50557
50561
|
}
|
|
50558
50562
|
function receipt(record7, operation, occurredAt, providerCosts = [], externalRef) {
|
|
50559
50563
|
return {
|
|
@@ -50764,7 +50768,7 @@ var AnalyticsSiteSetupService = class {
|
|
|
50764
50768
|
};
|
|
50765
50769
|
|
|
50766
50770
|
// src/api/analytics-survey-attribution.ts
|
|
50767
|
-
import { createHash as
|
|
50771
|
+
import { createHash as createHash40, randomBytes as randomBytes5, randomUUID as randomUUID32 } from "crypto";
|
|
50768
50772
|
var CREDIT_SCALE = 1e6;
|
|
50769
50773
|
var REPORTED_IMPACT_METHODOLOGY_VERSION = "xray_observed_plus_reported_equal_selected_v1";
|
|
50770
50774
|
var TOKEN_BYTES = 32;
|
|
@@ -50831,10 +50835,10 @@ function stable(value) {
|
|
|
50831
50835
|
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key3, item]) => [key3, stable(item)]));
|
|
50832
50836
|
}
|
|
50833
50837
|
function fingerprint4(value) {
|
|
50834
|
-
return
|
|
50838
|
+
return createHash40("sha256").update(JSON.stringify(stable(value))).digest("hex");
|
|
50835
50839
|
}
|
|
50836
50840
|
function tokenDigest(value) {
|
|
50837
|
-
return
|
|
50841
|
+
return createHash40("sha256").update(value).digest("hex");
|
|
50838
50842
|
}
|
|
50839
50843
|
function opaqueToken(prefix) {
|
|
50840
50844
|
return `${prefix}_${randomBytes5(TOKEN_BYTES).toString("base64url")}`;
|
|
@@ -51363,7 +51367,7 @@ function buildObservedPlusReportedImpact(input) {
|
|
|
51363
51367
|
}
|
|
51364
51368
|
|
|
51365
51369
|
// src/api/analytics-provider-view-evidence.ts
|
|
51366
|
-
import { createHash as
|
|
51370
|
+
import { createHash as createHash41, randomUUID as randomUUID33 } from "crypto";
|
|
51367
51371
|
var ANALYTICS_VIEW_EVIDENCE_RESEARCH_DATE = "2026-09-01";
|
|
51368
51372
|
var ANALYTICS_VIEW_EVIDENCE_PROVIDERS = [
|
|
51369
51373
|
"meta",
|
|
@@ -51537,7 +51541,7 @@ var PostgresAnalyticsSiteSetupStore = class {
|
|
|
51537
51541
|
};
|
|
51538
51542
|
|
|
51539
51543
|
// src/api/analytics-product-health.ts
|
|
51540
|
-
import { createHash as
|
|
51544
|
+
import { createHash as createHash42, randomUUID as randomUUID34 } from "crypto";
|
|
51541
51545
|
var ANALYTICS_PRODUCT_MILESTONES = [
|
|
51542
51546
|
"xray_opened",
|
|
51543
51547
|
"setup_started",
|
|
@@ -51564,7 +51568,7 @@ function asIso2(value) {
|
|
|
51564
51568
|
}
|
|
51565
51569
|
function safeReference(kind, value) {
|
|
51566
51570
|
if (!value) return null;
|
|
51567
|
-
return `${kind}:${
|
|
51571
|
+
return `${kind}:${createHash42("sha256").update(value).digest("hex").slice(0, 16)}`;
|
|
51568
51572
|
}
|
|
51569
51573
|
function numberValue(value) {
|
|
51570
51574
|
const number = Number(value ?? 0);
|
|
@@ -52833,7 +52837,7 @@ async function drainAnalyticsPrivacyLifecycle(input = {}) {
|
|
|
52833
52837
|
}
|
|
52834
52838
|
|
|
52835
52839
|
// src/api/analytics-crm-sync.ts
|
|
52836
|
-
import { createHash as
|
|
52840
|
+
import { createHash as createHash43 } from "crypto";
|
|
52837
52841
|
var VERIFIED_READ_SCOPES = Object.freeze({
|
|
52838
52842
|
hubspot: ["crm.objects.deals.read"],
|
|
52839
52843
|
salesforce: ["api"],
|
|
@@ -52899,7 +52903,7 @@ async function previewAnalyticsCrmSync(input) {
|
|
|
52899
52903
|
};
|
|
52900
52904
|
}
|
|
52901
52905
|
function stableId2(prefix, input) {
|
|
52902
|
-
return `${prefix}_${
|
|
52906
|
+
return `${prefix}_${createHash43("sha256").update(JSON.stringify(input)).digest("hex").slice(0, 24)}`;
|
|
52903
52907
|
}
|
|
52904
52908
|
function isRecord5(value) {
|
|
52905
52909
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -53264,7 +53268,7 @@ function analyticsSiteSetupService() {
|
|
|
53264
53268
|
publishManifest: async ({ record: record7, idempotencyKey: idempotencyKey4 }) => {
|
|
53265
53269
|
const hostname = new URL(record7.startUrl).hostname.toLowerCase().replace(/\.$/, "");
|
|
53266
53270
|
const uuidFor = (value) => {
|
|
53267
|
-
const hex =
|
|
53271
|
+
const hex = createHash44("sha256").update(`${record7.siteId}:${value}`).digest("hex").slice(0, 32).split("");
|
|
53268
53272
|
hex[12] = "4";
|
|
53269
53273
|
hex[16] = ["8", "9", "a", "b"][Number.parseInt(hex[16], 16) % 4];
|
|
53270
53274
|
return `${hex.slice(0, 8).join("")}-${hex.slice(8, 12).join("")}-${hex.slice(12, 16).join("")}-${hex.slice(16, 20).join("")}-${hex.slice(20).join("")}`;
|
|
@@ -53403,7 +53407,7 @@ function isRecord6(value) {
|
|
|
53403
53407
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
53404
53408
|
}
|
|
53405
53409
|
function analyticsPrivacyRequestFingerprint(siteId, operation, body3) {
|
|
53406
|
-
return
|
|
53410
|
+
return createHash44("sha256").update(canonicalRequest({ siteId, operation, body: { ...body3, idempotencyKey: void 0 } })).digest("hex");
|
|
53407
53411
|
}
|
|
53408
53412
|
function privacyIdempotency(c, body3, siteId, operation) {
|
|
53409
53413
|
const header = c.req.header("Idempotency-Key")?.trim();
|
|
@@ -54211,7 +54215,7 @@ analyticsApp.get("/v1/pixels/:publicPixelId/event-definitions", async (c) => {
|
|
|
54211
54215
|
});
|
|
54212
54216
|
});
|
|
54213
54217
|
function deterministicRuntimeManifestId(siteId) {
|
|
54214
|
-
const hex =
|
|
54218
|
+
const hex = createHash44("sha256").update(`xray-runtime-manifest:${siteId}`).digest("hex").slice(0, 32).split("");
|
|
54215
54219
|
hex[12] = "4";
|
|
54216
54220
|
hex[16] = ["8", "9", "a", "b"][Number.parseInt(hex[16], 16) % 4];
|
|
54217
54221
|
return `${hex.slice(0, 8).join("")}-${hex.slice(8, 12).join("")}-${hex.slice(12, 16).join("")}-${hex.slice(16, 20).join("")}-${hex.slice(20).join("")}`;
|
|
@@ -54589,7 +54593,7 @@ analyticsApp.post("/v1/events", async (c) => {
|
|
|
54589
54593
|
if (rule.condition.eventName && rule.condition.eventName !== event2.eventName) continue;
|
|
54590
54594
|
const tags = Array.isArray(event2.properties?.tags) ? event2.properties.tags.map(String) : [];
|
|
54591
54595
|
if ((rule.condition.excludedTags ?? []).some((tag) => tags.includes(tag))) continue;
|
|
54592
|
-
const sourceEventId = `browser-rule:${rule.id}:${
|
|
54596
|
+
const sourceEventId = `browser-rule:${rule.id}:${createHash44("sha256").update(event2.eventId).digest("hex").slice(0, 32)}`;
|
|
54593
54597
|
const valueMinor = Number(rule.default_value_minor ?? 0);
|
|
54594
54598
|
await createAnalyticsConversion({
|
|
54595
54599
|
userId: ownerUserId2,
|
|
@@ -54748,7 +54752,7 @@ analyticsApp.post("/v1/webhooks/:provider/:connectionId", async (c) => {
|
|
|
54748
54752
|
connectionId: connection.id,
|
|
54749
54753
|
provider,
|
|
54750
54754
|
sourceAccountRef: connection.sourceAccountRef,
|
|
54751
|
-
sourceEventId: `invalid:${
|
|
54755
|
+
sourceEventId: `invalid:${createHash44("sha256").update(rawBody).digest("hex")}`,
|
|
54752
54756
|
signatureStatus: "invalid"
|
|
54753
54757
|
});
|
|
54754
54758
|
await setAnalyticsConnectionReadiness({
|
|
@@ -55111,7 +55115,7 @@ function surveyPublicHeaders(c) {
|
|
|
55111
55115
|
}
|
|
55112
55116
|
function surveyRateLimit(c) {
|
|
55113
55117
|
const networkRef = c.req.header("cf-connecting-ip") ?? c.req.header("x-forwarded-for")?.split(",")[0]?.trim() ?? "unknown";
|
|
55114
|
-
const key3 =
|
|
55118
|
+
const key3 = createHash44("sha256").update(`survey-exchange:${networkRef}`).digest("hex");
|
|
55115
55119
|
const now = Date.now();
|
|
55116
55120
|
const window2 = surveyExchangeRateWindows.get(key3);
|
|
55117
55121
|
if (!window2 || now - window2.startedAt >= 6e4) {
|
|
@@ -55134,7 +55138,7 @@ function surveyCookie(c) {
|
|
|
55134
55138
|
return { siteId, sessionToken };
|
|
55135
55139
|
}
|
|
55136
55140
|
async function approvedSurveyExchangeSite(exchangeCode, origin) {
|
|
55137
|
-
const digest23 =
|
|
55141
|
+
const digest23 = createHash44("sha256").update(exchangeCode).digest("hex");
|
|
55138
55142
|
const hostname = normalizeAnalyticsHostname(new URL(origin).hostname);
|
|
55139
55143
|
const result3 = await getAnalyticsPool().query(
|
|
55140
55144
|
`SELECT invite.site_id
|
|
@@ -55173,7 +55177,7 @@ analyticsApp.post("/survey/exchange", async (c) => {
|
|
|
55173
55177
|
return c.redirect("/analytics/survey/session", 303);
|
|
55174
55178
|
});
|
|
55175
55179
|
async function readPublicSurveySession(siteId, sessionToken) {
|
|
55176
|
-
const digest23 =
|
|
55180
|
+
const digest23 = createHash44("sha256").update(sessionToken).digest("hex");
|
|
55177
55181
|
const session = await getAnalyticsPool().query(
|
|
55178
55182
|
`SELECT invite.survey_id,invite.survey_revision,invite.conversion_id,invite.session_expires_at,
|
|
55179
55183
|
survey.state,survey.name,survey.question,survey.selection_mode,survey.eligible_outcome_families,
|
|
@@ -55340,10 +55344,10 @@ analyticsApp.post("/v1/conversions", auth4, async (c) => {
|
|
|
55340
55344
|
clickIds: clickIds ?? {},
|
|
55341
55345
|
match: {
|
|
55342
55346
|
...normalizedEmail ? {
|
|
55343
|
-
emailSha256:
|
|
55347
|
+
emailSha256: createHash44("sha256").update(normalizedEmail).digest("hex")
|
|
55344
55348
|
} : {},
|
|
55345
55349
|
...normalizedPhone ? {
|
|
55346
|
-
phoneSha256:
|
|
55350
|
+
phoneSha256: createHash44("sha256").update(normalizedPhone).digest("hex")
|
|
55347
55351
|
} : {}
|
|
55348
55352
|
}
|
|
55349
55353
|
}),
|
|
@@ -55872,7 +55876,7 @@ analyticsApp.post("/sites/:siteId/crm-imports", auth4, async (c) => {
|
|
|
55872
55876
|
rejectedCount += 1;
|
|
55873
55877
|
continue;
|
|
55874
55878
|
}
|
|
55875
|
-
const digest23 =
|
|
55879
|
+
const digest23 = createHash44("sha256").update(
|
|
55876
55880
|
`${parsed.data.sourceSystem}:${externalId || email || phone || `${fullName}:${index}`}`
|
|
55877
55881
|
).digest("hex").slice(0, 16);
|
|
55878
55882
|
const path5 = `Leads/person-${digest23}`;
|
|
@@ -56620,7 +56624,7 @@ analyticsApp.post("/sites/:siteId/consent/withdrawals", auth4, async (c) => {
|
|
|
56620
56624
|
try {
|
|
56621
56625
|
await client2.query("BEGIN");
|
|
56622
56626
|
await client2.query(`INSERT INTO analytics_privacy_audits(id,site_id,subject_ref,action,idempotency_key,request_fingerprint,actor_user_id,result_code)
|
|
56623
|
-
VALUES($1,$2,$3,'withdrawal_applied',$4,$5,$6,'running') ON CONFLICT(site_id,idempotency_key) DO NOTHING`, [randomUUID38(), siteId, `subject:${
|
|
56627
|
+
VALUES($1,$2,$3,'withdrawal_applied',$4,$5,$6,'running') ON CONFLICT(site_id,idempotency_key) DO NOTHING`, [randomUUID38(), siteId, `subject:${createHash44("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, idem.key, idem.fingerprint, userId]);
|
|
56624
56628
|
const claimed = await client2.query("SELECT request_fingerprint,result_code,affected_counts FROM analytics_privacy_audits WHERE site_id=$1 AND idempotency_key=$2 FOR UPDATE", [siteId, idem.key]);
|
|
56625
56629
|
assertAnalyticsPrivacyIdempotencyFingerprint(claimed.rows[0], idem.fingerprint);
|
|
56626
56630
|
if (claimed.rows[0].result_code === "completed") {
|
|
@@ -56878,7 +56882,7 @@ analyticsApp.post("/sites/:siteId/crm/outbound-policies", auth4, async (c) => {
|
|
|
56878
56882
|
selectedEvents: z43.array(z43.string().regex(/^[a-z][a-z0-9_]{1,79}$/)).max(100),
|
|
56879
56883
|
purpose: z43.enum(["necessary_form_fulfillment", "site_analytics", "advertising_measurement"])
|
|
56880
56884
|
}).strict());
|
|
56881
|
-
const policyId = `crmpolicy_${
|
|
56885
|
+
const policyId = `crmpolicy_${createHash44("sha256").update(JSON.stringify({
|
|
56882
56886
|
siteId,
|
|
56883
56887
|
connectionId: body3.connectionId,
|
|
56884
56888
|
kind: body3.kind,
|
|
@@ -57305,7 +57309,7 @@ analyticsApp.post("/sites/:siteId/privacy/subject/export", auth4, async (c) => {
|
|
|
57305
57309
|
await getAnalyticsPool().query(
|
|
57306
57310
|
`INSERT INTO analytics_privacy_audits(id,site_id,subject_ref,action,idempotency_key,request_fingerprint,actor_user_id,result_code,affected_counts,completed_at)
|
|
57307
57311
|
VALUES($1,$2,$3,'export_completed',$4,$5,$6,'completed',$7::jsonb,now()) ON CONFLICT(site_id,idempotency_key) DO NOTHING`,
|
|
57308
|
-
[randomUUID38(), siteId, `person:${
|
|
57312
|
+
[randomUUID38(), siteId, `person:${createHash44("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, idem.key, idem.fingerprint, userId, JSON.stringify({ export: { schemaVersion: 1, subject: person.rows[0], restrictedIdentityExcluded: true } })]
|
|
57309
57313
|
);
|
|
57310
57314
|
const persisted = await getAnalyticsPool().query("SELECT request_fingerprint,affected_counts FROM analytics_privacy_audits WHERE site_id=$1 AND idempotency_key=$2", [siteId, idem.key]);
|
|
57311
57315
|
assertAnalyticsPrivacyIdempotencyFingerprint(persisted.rows[0], idem.fingerprint);
|
|
@@ -57319,7 +57323,7 @@ analyticsApp.post("/sites/:siteId/privacy/subject/delete", auth4, async (c) => {
|
|
|
57319
57323
|
try {
|
|
57320
57324
|
await client2.query("BEGIN");
|
|
57321
57325
|
await client2.query(`INSERT INTO analytics_privacy_audits(id,site_id,subject_ref,action,idempotency_key,request_fingerprint,actor_user_id,result_code)
|
|
57322
|
-
VALUES($1,$2,$3,'deletion_requested',$4,$5,$6,'running') ON CONFLICT(site_id,idempotency_key) DO NOTHING`, [randomUUID38(), siteId, `subject:${
|
|
57326
|
+
VALUES($1,$2,$3,'deletion_requested',$4,$5,$6,'running') ON CONFLICT(site_id,idempotency_key) DO NOTHING`, [randomUUID38(), siteId, `subject:${createHash44("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, idem.key, idem.fingerprint, userId]);
|
|
57323
57327
|
const claim = await client2.query("SELECT request_fingerprint,result_code,affected_counts FROM analytics_privacy_audits WHERE site_id=$1 AND idempotency_key=$2 FOR UPDATE", [siteId, idem.key]);
|
|
57324
57328
|
assertAnalyticsPrivacyIdempotencyFingerprint(claim.rows[0], idem.fingerprint);
|
|
57325
57329
|
if (claim.rows[0].result_code === "deleted") {
|
|
@@ -57337,7 +57341,7 @@ analyticsApp.post("/sites/:siteId/privacy/subject/delete", auth4, async (c) => {
|
|
|
57337
57341
|
db: client2
|
|
57338
57342
|
});
|
|
57339
57343
|
const counts = { ...deletion.affectedCounts };
|
|
57340
|
-
await client2.query(`UPDATE analytics_privacy_audits SET namespace_ref=$3,subject_ref=$4,action='deletion_completed',result_code='deleted',affected_counts=$5::jsonb,completed_at=now() WHERE site_id=$1 AND idempotency_key=$2`, [siteId, idem.key, `namespace:${locked.rows[0].namespace_id}`, `deleted:${
|
|
57344
|
+
await client2.query(`UPDATE analytics_privacy_audits SET namespace_ref=$3,subject_ref=$4,action='deletion_completed',result_code='deleted',affected_counts=$5::jsonb,completed_at=now() WHERE site_id=$1 AND idempotency_key=$2`, [siteId, idem.key, `namespace:${locked.rows[0].namespace_id}`, `deleted:${createHash44("sha256").update(body3.subjectRef).digest("hex").slice(0, 16)}`, JSON.stringify(counts)]);
|
|
57341
57345
|
await client2.query("COMMIT");
|
|
57342
57346
|
return c.json({ ok: true, deleted: true, counts }, 200, noStore);
|
|
57343
57347
|
} catch (error) {
|
|
@@ -57381,7 +57385,7 @@ analyticsApp.post("/sites/:siteId/privacy/namespace/delete", auth4, async (c) =>
|
|
|
57381
57385
|
await client2.query(
|
|
57382
57386
|
`INSERT INTO analytics_privacy_audits(id,site_id,namespace_ref,action,idempotency_key,actor_user_id,result_code,affected_counts,completed_at)
|
|
57383
57387
|
VALUES($1,$2,$3,'deletion_completed',$4,$5,'deleted',$6::jsonb,now()) ON CONFLICT(site_id,idempotency_key) DO NOTHING`,
|
|
57384
|
-
[randomUUID38(), siteId, `deleted:${
|
|
57388
|
+
[randomUUID38(), siteId, `deleted:${createHash44("sha256").update(body3.namespaceId).digest("hex").slice(0, 16)}`, body3.idempotencyKey, userId, JSON.stringify(counts)]
|
|
57385
57389
|
);
|
|
57386
57390
|
await client2.query("COMMIT");
|
|
57387
57391
|
return c.json({ ok: true, deleted: true, counts }, 200, noStore);
|
|
@@ -57848,7 +57852,7 @@ function resultStatus(result3) {
|
|
|
57848
57852
|
return 502;
|
|
57849
57853
|
}
|
|
57850
57854
|
async function keyFor(c) {
|
|
57851
|
-
const { key: key3, error } = await
|
|
57855
|
+
const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
|
|
57852
57856
|
if (!key3) return c.json(safeFailure2(error ?? "Memory is unavailable."), 503);
|
|
57853
57857
|
return key3;
|
|
57854
57858
|
}
|
|
@@ -58201,7 +58205,7 @@ crmApp.post("/deals/:dealId/transitions", async (c) => {
|
|
|
58201
58205
|
});
|
|
58202
58206
|
|
|
58203
58207
|
// src/api/crm-bridge-service.ts
|
|
58204
|
-
import { createHash as
|
|
58208
|
+
import { createHash as createHash45 } from "crypto";
|
|
58205
58209
|
var CrmBridgeError = class extends Error {
|
|
58206
58210
|
constructor(code, message) {
|
|
58207
58211
|
super(message);
|
|
@@ -58211,7 +58215,7 @@ var CrmBridgeError = class extends Error {
|
|
|
58211
58215
|
code;
|
|
58212
58216
|
};
|
|
58213
58217
|
function stableChildId(parentId, suffix2) {
|
|
58214
|
-
const bytes2 = Buffer.from(
|
|
58218
|
+
const bytes2 = Buffer.from(createHash45("sha256").update(`${parentId}:${suffix2}`).digest().subarray(0, 16));
|
|
58215
58219
|
bytes2[6] = bytes2[6] & 15 | 80;
|
|
58216
58220
|
bytes2[8] = bytes2[8] & 63 | 128;
|
|
58217
58221
|
const hex = bytes2.toString("hex");
|
|
@@ -58331,7 +58335,7 @@ async function deliverPendingAnalyticsForms(limit = 10, dependencies = {}) {
|
|
|
58331
58335
|
deferred += 1;
|
|
58332
58336
|
continue;
|
|
58333
58337
|
}
|
|
58334
|
-
const { key: key3, error } = await
|
|
58338
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
58335
58339
|
if (!key3) {
|
|
58336
58340
|
await deferAnalyticsFormDelivery(job.id, job.attempts, safeDeliveryError(error));
|
|
58337
58341
|
deferred += 1;
|
|
@@ -58413,7 +58417,7 @@ async function deliverPendingAnalyticsCrmImports(limit = 10) {
|
|
|
58413
58417
|
deferred += 1;
|
|
58414
58418
|
continue;
|
|
58415
58419
|
}
|
|
58416
|
-
const { key: key3, error } = await
|
|
58420
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
58417
58421
|
const result3 = key3 ? await memoryCall("putTool", payload, key3) : { ok: false, error };
|
|
58418
58422
|
if (result3.ok) {
|
|
58419
58423
|
await completeAnalyticsCrmImportRow(row.id, row.importId);
|
|
@@ -58891,7 +58895,7 @@ async function pollPendingGoogleActivationDiagnostics(limit = 10, deadlineMs = D
|
|
|
58891
58895
|
}
|
|
58892
58896
|
|
|
58893
58897
|
// src/api/analytics-reconciliation.ts
|
|
58894
|
-
import { createHash as
|
|
58898
|
+
import { createHash as createHash46, randomUUID as randomUUID41 } from "crypto";
|
|
58895
58899
|
var RECONCILIATION_INTERVAL_SECONDS = 15 * 60;
|
|
58896
58900
|
var WEBHOOK_ONLY_RECHECK_SECONDS = 24 * 60 * 60;
|
|
58897
58901
|
var LEASE_SECONDS = 90;
|
|
@@ -59018,14 +59022,14 @@ function crmReadInput(provider, sourceAccountRef, cursorValue, now) {
|
|
|
59018
59022
|
}
|
|
59019
59023
|
}
|
|
59020
59024
|
function crmOutcomeSourceEventId(outcome) {
|
|
59021
|
-
const digest23 =
|
|
59025
|
+
const digest23 = createHash46("sha256").update(`${outcome.provider}:${outcome.sourceRecordId}:${outcome.updatedAt}:${outcome.tombstone}`).digest("hex").slice(0, 40);
|
|
59022
59026
|
return `crm:${outcome.provider}:${digest23}`;
|
|
59023
59027
|
}
|
|
59024
59028
|
function analyticsCrmOutcomeToExternalEvent(outcome, sourceAccountRef) {
|
|
59025
59029
|
const sourceEventId = crmOutcomeSourceEventId(outcome);
|
|
59026
59030
|
return {
|
|
59027
59031
|
schemaVersion: 1,
|
|
59028
|
-
eventId: `crm_${
|
|
59032
|
+
eventId: `crm_${createHash46("sha256").update(sourceEventId).digest("hex").slice(0, 24)}`,
|
|
59029
59033
|
sourceEventId,
|
|
59030
59034
|
source: outcome.provider,
|
|
59031
59035
|
sourceAccountRef,
|
|
@@ -59325,7 +59329,7 @@ async function deferAnalyticsReconciliationJob(input) {
|
|
|
59325
59329
|
connectionId: input.connectionId,
|
|
59326
59330
|
safeErrorCode: errorCode2,
|
|
59327
59331
|
nextRunAt: new Date(Date.now() + delaySeconds * 1e3).toISOString(),
|
|
59328
|
-
receiptFingerprint:
|
|
59332
|
+
receiptFingerprint: createHash46("sha256").update(`${input.jobId}:${input.attempts}:${errorCode2}`).digest("hex")
|
|
59329
59333
|
});
|
|
59330
59334
|
}
|
|
59331
59335
|
}
|
|
@@ -59436,7 +59440,7 @@ async function reconcileAnalyticsConnection(job, dependencies = defaultDependenc
|
|
|
59436
59440
|
deduplicated: duplicates,
|
|
59437
59441
|
rejected: page3.rejected,
|
|
59438
59442
|
hasMore: page3.hasMore,
|
|
59439
|
-
receiptFingerprint:
|
|
59443
|
+
receiptFingerprint: createHash46("sha256").update(`${job.id}:${JSON.stringify(page3.nextCursor)}:${replayed}:${duplicates}`).digest("hex"),
|
|
59440
59444
|
scheduleConfigured: Boolean(scope.sync_id),
|
|
59441
59445
|
scheduleIntervalSeconds: scope.sync_interval_seconds ?? null
|
|
59442
59446
|
}
|
|
@@ -59653,13 +59657,13 @@ import { Hono as Hono38 } from "hono";
|
|
|
59653
59657
|
import { z as z46 } from "zod";
|
|
59654
59658
|
|
|
59655
59659
|
// src/api/scheduled-artifact-owner.ts
|
|
59656
|
-
import { createHash as
|
|
59660
|
+
import { createHash as createHash47 } from "crypto";
|
|
59657
59661
|
function scheduledArtifactOwnerIdForApiKey(apiKey) {
|
|
59658
|
-
return
|
|
59662
|
+
return createHash47("sha256").update(apiKey).digest("hex").slice(0, 24);
|
|
59659
59663
|
}
|
|
59660
59664
|
|
|
59661
59665
|
// src/api/scheduled-run-view-links.ts
|
|
59662
|
-
import { createHash as
|
|
59666
|
+
import { createHash as createHash48, randomBytes as randomBytes6, randomUUID as randomUUID43 } from "crypto";
|
|
59663
59667
|
var schemaReady3 = false;
|
|
59664
59668
|
async function ensureScheduledRunViewLinksSchema() {
|
|
59665
59669
|
if (schemaReady3) return;
|
|
@@ -59713,7 +59717,7 @@ async function ensureScheduledRunViewLinksSchema() {
|
|
|
59713
59717
|
schemaReady3 = true;
|
|
59714
59718
|
}
|
|
59715
59719
|
function tokenHash2(token7) {
|
|
59716
|
-
return
|
|
59720
|
+
return createHash48("sha256").update(token7).digest("hex");
|
|
59717
59721
|
}
|
|
59718
59722
|
function mapRow(row) {
|
|
59719
59723
|
return {
|
|
@@ -59800,7 +59804,7 @@ async function revokeScheduledRunViewLink(ownerId3, runId, shareId, now = /* @__
|
|
|
59800
59804
|
}
|
|
59801
59805
|
|
|
59802
59806
|
// src/personal-authority/render.ts
|
|
59803
|
-
import { createHash as
|
|
59807
|
+
import { createHash as createHash49 } from "crypto";
|
|
59804
59808
|
function escapeHtml8(value) {
|
|
59805
59809
|
return value.replace(/[&<>"']/g, (character) => ({
|
|
59806
59810
|
"&": "&",
|
|
@@ -59860,13 +59864,13 @@ ${section(flags.finalCta && Boolean(finalCta), `<section class="section cta" id=
|
|
|
59860
59864
|
html,
|
|
59861
59865
|
filename: `${input.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "personal-authority"}.html`,
|
|
59862
59866
|
bytes: bytes2,
|
|
59863
|
-
sha256:
|
|
59867
|
+
sha256: createHash49("sha256").update(html).digest("hex"),
|
|
59864
59868
|
generatedAt: generatedAtIso
|
|
59865
59869
|
};
|
|
59866
59870
|
}
|
|
59867
59871
|
|
|
59868
59872
|
// src/personal-authority/render-v2.ts
|
|
59869
|
-
import { createHash as
|
|
59873
|
+
import { createHash as createHash50 } from "crypto";
|
|
59870
59874
|
var FONT_STACKS = Object.freeze({
|
|
59871
59875
|
"editorial-serif": "Iowan Old Style, Baskerville, Times New Roman, serif",
|
|
59872
59876
|
"modern-sans": "Avenir Next, Avenir, Helvetica Neue, Arial, sans-serif",
|
|
@@ -59970,13 +59974,13 @@ ${section2(flags.finalCta && Boolean(finalCta), `<section class="section cta" id
|
|
|
59970
59974
|
html,
|
|
59971
59975
|
filename: `${input.name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "personal-authority"}.html`,
|
|
59972
59976
|
bytes: bytes2,
|
|
59973
|
-
sha256:
|
|
59977
|
+
sha256: createHash50("sha256").update(html).digest("hex"),
|
|
59974
59978
|
generatedAt: generatedAtIso
|
|
59975
59979
|
};
|
|
59976
59980
|
}
|
|
59977
59981
|
|
|
59978
59982
|
// src/newsroom-publisher/render.ts
|
|
59979
|
-
import { createHash as
|
|
59983
|
+
import { createHash as createHash51 } from "crypto";
|
|
59980
59984
|
function escapeHtml10(value) {
|
|
59981
59985
|
return value.replace(/[&<>"']/g, (character) => ({
|
|
59982
59986
|
"&": "&",
|
|
@@ -60082,13 +60086,13 @@ body{overflow-x:hidden}.lead-story__body,.lead-support__item,.story-card__body{m
|
|
|
60082
60086
|
@media(max-width:620px){.desk-section__grid--panorama,.desk-section__grid--mosaic,.desk-section__grid--tiles{grid-template-columns:1fr}.story-card--panorama{display:block}.story-card--panorama h3,.story-card--mosaic-lead h3{font-size:34px}.story-card--mosaic-lead{grid-column:auto;grid-row:auto}.desk-section__grid--tiles>.story-card:nth-child(3n+2){margin-top:0}}
|
|
60083
60087
|
</style></head><body data-theme="${escapeHtml10(config.theme)}" id="top" data-scheduled-renderer="newsroom_publisher_v1">${ticker}${masthead}${navigation}<main>${leadGrid}${latest}${sections}${newsletter}${pressRoom}${trustCenter}</main>${trustFooter}</body></html>`;
|
|
60084
60088
|
const bytes2 = Buffer.byteLength(html);
|
|
60085
|
-
const sha2564 =
|
|
60089
|
+
const sha2564 = createHash51("sha256").update(html).digest("hex");
|
|
60086
60090
|
const filename2 = `${brand.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "newsroom"}-news-site.html`;
|
|
60087
60091
|
return { html, filename: filename2, bytes: bytes2, sha256: sha2564, generatedAt: generatedAtIso };
|
|
60088
60092
|
}
|
|
60089
60093
|
|
|
60090
60094
|
// src/blog-article/render.ts
|
|
60091
|
-
import { createHash as
|
|
60095
|
+
import { createHash as createHash52 } from "crypto";
|
|
60092
60096
|
function escapeHtml11(value) {
|
|
60093
60097
|
return value.replace(
|
|
60094
60098
|
/[&<>"']/g,
|
|
@@ -60176,7 +60180,7 @@ function renderBlogArticleV1(input, config, generatedAt) {
|
|
|
60176
60180
|
:root{--ink:#10213d;--ink2:#1c355a;--blue:#2563eb;--blue2:#1749b6;--mint:#45d5aa;--paper:#f7f5f0;--line:#dce4ef;--card:#fff;--body:#475569;--serif:Iowan Old Style,Palatino Linotype,Palatino,Georgia,serif;--sans:Inter,Avenir Next,ui-sans-serif,system-ui,sans-serif}body[data-theme="slate"]{--ink:#1e293b;--ink2:#334155;--blue:#475569;--blue2:#1e293b;--mint:#94a3b8;--paper:#f8fafc}body[data-theme="forest"]{--ink:#12352e;--ink2:#23584c;--blue:#147d64;--blue2:#0c5b48;--mint:#79d8bd;--paper:#f4f8f3}*{box-sizing:border-box}html{scroll-behavior:smooth;background:var(--paper)}body{margin:0;color:#252a33;background:var(--paper);font-family:var(--sans);line-height:1.6}a{color:inherit}button{font:inherit}button:focus-visible,a:focus-visible{outline:3px solid var(--mint);outline-offset:3px}.progress{position:fixed;z-index:50;top:0;left:0;height:4px;width:0;background:var(--mint)}.hero{position:relative;overflow:hidden;color:#fff;background:var(--ink)}.hero:after{position:absolute;right:-110px;top:-150px;width:420px;height:420px;border:1px solid #ffffff1a;border-radius:50%;content:""}.hero-inner{position:relative;z-index:1;max-width:1240px;margin:auto;padding:58px 42px 126px}.breadcrumb{display:flex;gap:8px;margin-bottom:34px;color:#dbeafecc;font-size:14px}.eyebrow{display:block;color:var(--blue);font-size:12px;font-weight:800;letter-spacing:.16em;text-transform:uppercase}.hero .eyebrow{color:var(--mint)}h1,h2,h3,p{margin-top:0}.hero h1{max-width:1000px;margin:14px 0 24px;font:700 clamp(44px,6vw,78px)/.98 var(--serif);letter-spacing:-.035em}.hero .dek{max-width:780px;color:#dbeafe;font-size:20px}.contributors{margin-top:30px;color:#eff6ff;font-size:14px}.contributors a{font-weight:800}.meta{display:flex;flex-wrap:wrap;gap:12px;margin-top:6px;color:#dbeafecc}.layout{position:relative;z-index:2;display:grid;grid-template-columns:minmax(0,760px) 290px;gap:64px;max-width:1240px;margin:-78px auto 0;padding:0 42px 80px}.main{min-width:0}.takeaways{padding:38px 44px;border-radius:24px;background:#fff;box-shadow:0 24px 70px #10213d24}.takeaways h2{margin:5px 0 20px;font:700 32px/1.1 var(--serif);color:var(--ink)}.takeaways ul{display:grid;gap:16px;margin:0;padding:0;list-style:none}.takeaways li{position:relative;padding-left:26px;color:var(--body);font-size:17px}.takeaways li:before{position:absolute;left:2px;top:.7em;width:8px;height:8px;border-radius:50%;background:var(--blue);content:""}.intro{padding:40px 0 4px}.intro p,.article-section>p{margin-bottom:22px;color:var(--body);font:400 18px/1.75 var(--sans)}.article-section{scroll-margin-top:28px;padding-top:45px}.article-section h2,.faq h2{margin:6px 0 20px;color:var(--ink);font:700 38px/1.08 var(--serif);letter-spacing:-.02em}.article-section ul{display:grid;gap:10px;margin:22px 0;padding-left:24px;color:var(--body);font-size:17px}.article-section li::marker{color:var(--blue)}.callout{margin:34px 0;padding:24px 28px;border-left:4px solid var(--blue);border-radius:0 16px 16px 0;background:#fff}.callout span{color:var(--blue);font-size:11px;font-weight:800;letter-spacing:.13em;text-transform:uppercase}.callout h3{margin:5px 0 8px;color:var(--ink);font:700 24px/1.15 var(--serif)}.callout p{margin:0;color:var(--body)}.rail{padding-top:0}.sidebar-media{overflow:hidden;margin:0 0 18px;border:1px solid #dbeafe;border-radius:16px;background:#fff}.sidebar-media img,.sidebar-media svg{display:block;width:100%;aspect-ratio:16/9;object-fit:cover}.sidebar-media figcaption{padding:10px 13px;color:#64748b;font-size:11px}.disclosure{margin-bottom:28px;border-top:1px solid #dbeafe;border-bottom:1px solid #dbeafe}.disclosure button{display:flex;width:100%;align-items:center;justify-content:space-between;gap:14px;padding:15px 0;border:0;color:#64748b;background:transparent;text-align:left;font-size:12px;cursor:pointer}.disclosure button b{color:var(--blue);font-size:18px;transition:transform .2s}.disclosure button[aria-expanded="true"] b{transform:rotate(180deg)}.disclosure p{padding:0 0 16px;margin:0;color:#64748b;font-size:12px}.toc{position:sticky;top:30px;padding:22px;border:1px solid var(--line);border-radius:16px;background:#fff;box-shadow:0 2px 5px #10213d12}.toc header{display:flex;align-items:center;justify-content:space-between}.toc header strong{color:var(--ink);font:700 21px/1 var(--serif)}.toc header button{width:34px;height:34px;border:0;border-radius:50%;color:var(--blue);background:transparent;cursor:pointer}.toc nav{display:grid;margin-top:14px}.toc nav a{display:flex;align-items:flex-start;gap:11px;padding:8px 0;color:#64748b;text-decoration:none;font-size:13px;line-height:1.35}.toc nav i{width:8px;height:8px;margin-top:5px;border:2px solid #bfdbfe;border-radius:50%}.toc nav a[aria-current="location"]{color:var(--ink);font-weight:800}.toc nav a[aria-current="location"] i{border-color:var(--blue);background:var(--blue)}.back-top{width:100%;margin-top:18px;padding:16px 0 0;border:0;border-top:1px solid var(--line);color:var(--blue);background:transparent;text-align:right;font-size:13px;font-weight:800;cursor:pointer}.faq{scroll-margin-top:28px;padding-top:64px}.faq>div{border-top:1px solid var(--line);border-bottom:1px solid var(--line)}.faq article+article{border-top:1px solid var(--line)}.faq h3{margin:0}.faq h3 button{display:flex;width:100%;align-items:center;justify-content:space-between;gap:18px;padding:19px 0;border:0;color:var(--ink);background:transparent;text-align:left;font-weight:800;cursor:pointer}.faq h3 b{color:var(--blue);font-size:22px}.faq article>p{padding:0 0 20px;margin:0;color:var(--body);font-size:16px}.author-card{margin-top:64px;padding:32px 36px;border-radius:18px;background:#fff}.article-actions{display:flex;flex-wrap:wrap;justify-content:space-between;gap:14px}.article-actions button{display:inline-flex;min-height:46px;align-items:center;justify-content:center;gap:8px;padding:8px 18px;border:2px solid var(--blue);border-radius:999px;color:var(--ink);background:#fff;font-weight:800;cursor:pointer}.article-actions button:hover{color:#fff;background:var(--blue)}.action-status{min-height:20px;margin:8px 0 0;color:var(--blue);text-align:right;font-size:13px;font-weight:700}.author-grid{display:grid;grid-template-columns:auto 1fr auto;gap:22px;align-items:center;margin-top:24px}.author-portrait{width:88px;height:88px;border-radius:50%;object-fit:cover}.author-initials{display:grid;place-items:center;color:var(--ink);background:#fecdd3;font-size:22px;font-weight:900}.author-grid span{color:#64748b;font-size:13px}.author-grid h2{margin:2px 0;color:var(--ink);font:700 27px/1 var(--serif)}.author-grid h2 a{text-decoration:none}.author-grid p{margin:8px 0;color:#64748b;font-size:14px}.author-grid nav{display:flex;flex-wrap:wrap;gap:14px}.author-grid nav a{color:#64748b;font-size:12px}.author-more{display:inline-flex;min-height:48px;align-items:center;justify-content:center;padding:10px 24px;border:2px solid var(--blue);color:var(--blue);text-align:center;text-decoration:none;font-size:13px;font-weight:800}.author-bio{margin:24px 0 0!important;padding-top:20px;border-top:1px solid var(--line);color:var(--body);font-size:16px}dialog{width:min(720px,calc(100% - 30px));max-height:calc(100dvh - 30px);padding:0;border:0;border-radius:18px;color:var(--ink);background:#fff;box-shadow:0 24px 70px #10213d38}dialog::backdrop{background:#0f172a7a;backdrop-filter:blur(2px)}dialog>div{position:relative;padding:30px}dialog h2{margin:0 50px 2px 0;font:700 30px/1.1 var(--serif)}dialog>div>p{color:#64748b}.dialog-close{position:absolute;top:13px;right:13px;width:44px;height:44px;border:0;border-radius:50%;color:var(--blue);background:transparent;font-size:29px;cursor:pointer}dialog section{border-top:1px solid var(--line)}dialog section button{display:block;width:100%;padding:17px 5px;border:0;border-bottom:1px solid var(--line);color:var(--body);background:#fff;text-align:left;line-height:1.65;cursor:pointer}.citation-status{min-height:22px;margin:14px 0 0!important;color:var(--blue)!important;font-size:13px;font-weight:800}.generated{max-width:1156px;margin:-52px auto 50px;padding:0 42px;color:#94a3b8;font-size:11px}@media(max-width:900px){.layout{display:block}.rail{display:none}.hero-inner{padding-bottom:116px}}@media(max-width:620px){.hero-inner{padding:36px 20px 104px}.hero h1{font-size:46px}.hero .dek{font-size:17px}.layout{margin-top:-70px;padding:0 16px 54px}.takeaways{padding:28px 24px}.article-section h2,.faq h2{font-size:32px}.author-card{padding:24px}.article-actions{display:grid;justify-content:start}.author-grid{grid-template-columns:1fr;gap:12px}.author-more{width:100%}dialog>div{padding:24px}.generated{padding:0 20px}}
|
|
60177
60181
|
</style></head><body data-theme="${escapeHtml11(config.theme)}" data-scheduled-renderer="blog_article_v1"><div class="progress" aria-hidden="true"></div><header class="hero"><div class="hero-inner"><nav class="breadcrumb" aria-label="Breadcrumb"><a href="${safeHref4(input.canonicalUrl)}">${escapeHtml11(input.category)}</a><span>/</span><span>Article</span></nav><span class="eyebrow">${escapeHtml11(input.eyebrow)}</span><h1>${escapeHtml11(input.title)}</h1>${input.dek ? `<p class="dek">${escapeHtml11(input.dek)}</p>` : ""}<div class="contributors">${contributorText}<div class="meta"><time datetime="${escapeHtml11(articleDate)}">Updated ${formatDate2(articleDate)}</time><span>\u2022</span><span>${input.readTimeMinutes} min read</span>${input.reviewer ? "<span>\u2022</span><strong>Expert reviewed</strong>" : ""}</div></div></div></header><main class="layout"><article class="main"><section class="takeaways"><span class="eyebrow">The short answer</span><h2>Key takeaways</h2><ul>${input.keyTakeaways.map((item) => `<li>${escapeHtml11(item)}</li>`).join("")}</ul></section><section class="intro">${input.introduction.map((paragraph) => `<p>${escapeHtml11(paragraph)}</p>`).join("")}</section>${sections}${faq}${author}</article><div class="rail">${media}${disclosure}${toc}</div></main>${config.showGeneratedAt ? `<p class="generated">Rendered ${formatDate2(generatedAtIso)} by MCP Scraper.</p>` : ""}${citationDialog}<script>(()=>{const citations=${jsonForScript(citationValues)};const canonical=${jsonForScript(input.canonicalUrl)};const title=${jsonForScript(input.title)};const progress=document.querySelector('.progress');const tocLinks=[...document.querySelectorAll('.toc nav a')];const targets=tocLinks.map(link=>document.querySelector(link.hash)).filter(Boolean);const update=()=>{const max=document.documentElement.scrollHeight-innerHeight;if(progress)progress.style.width=(max>0?scrollY/max*100:0)+'%';let active=targets[0]?.id;for(const target of targets){if(target.getBoundingClientRect().top<=innerHeight*.55)active=target.id}tocLinks.forEach(link=>link.toggleAttribute('aria-current',link.hash==='#'+active));tocLinks.forEach(link=>{if(link.hash==='#'+active)link.setAttribute('aria-current','location');else link.removeAttribute('aria-current')})};addEventListener('scroll',update,{passive:true});addEventListener('resize',update);update();document.querySelectorAll('.faq h3 button').forEach(button=>button.addEventListener('click',()=>{const panel=document.getElementById(button.getAttribute('aria-controls'));const open=button.getAttribute('aria-expanded')==='true';button.setAttribute('aria-expanded',String(!open));panel.hidden=open;button.querySelector('b').textContent=open?'+':'\u2212'}));const disclosure=document.querySelector('.disclosure button');disclosure?.addEventListener('click',()=>{const panel=document.getElementById(disclosure.getAttribute('aria-controls'));const open=disclosure.getAttribute('aria-expanded')==='true';disclosure.setAttribute('aria-expanded',String(!open));panel.hidden=open});const tocToggle=document.querySelector('.toc header button');tocToggle?.addEventListener('click',()=>{const nav=document.getElementById('toc-links');const open=tocToggle.getAttribute('aria-expanded')==='true';tocToggle.setAttribute('aria-expanded',String(!open));nav.hidden=open;tocToggle.textContent=open?'\u2304':'\u2303'});document.querySelector('.back-top')?.addEventListener('click',()=>scrollTo({top:0,behavior:'smooth'}));const copy=async text=>{try{await navigator.clipboard.writeText(text)}catch{const area=document.createElement('textarea');area.value=text;area.style.position='fixed';area.style.opacity='0';document.body.append(area);area.select();document.execCommand('copy');area.remove()}};const dialog=document.getElementById('citation-dialog');document.querySelector('[data-cite]')?.addEventListener('click',()=>dialog.showModal());document.querySelector('.dialog-close')?.addEventListener('click',()=>dialog.close());dialog?.addEventListener('click',event=>{if(event.target===dialog)dialog.close()});document.querySelectorAll('[data-citation]').forEach(button=>button.addEventListener('click',async()=>{const style=button.dataset.citation;await copy(citations[style]);document.querySelector('.citation-status').textContent=style+' citation copied to clipboard.'}));document.querySelector('[data-share]')?.addEventListener('click',async()=>{const status=document.querySelector('.action-status');if(navigator.share){try{await navigator.share({title,url:canonical});status.textContent='Sharing options opened.';return}catch(error){if(error.name==='AbortError')return}}await copy(canonical);status.textContent='Article link copied to clipboard.'})})()</script></body></html>`;
|
|
60178
60182
|
const bytes2 = Buffer.byteLength(html);
|
|
60179
|
-
const sha2564 =
|
|
60183
|
+
const sha2564 = createHash52("sha256").update(html).digest("hex");
|
|
60180
60184
|
return {
|
|
60181
60185
|
html,
|
|
60182
60186
|
filename: "blog-article.html",
|
|
@@ -60307,7 +60311,7 @@ function apiError(error, errorCode2 = "invalid_request") {
|
|
|
60307
60311
|
}
|
|
60308
60312
|
async function memoryContext(c) {
|
|
60309
60313
|
const user = c.get("user");
|
|
60310
|
-
const { key: key3, error } = await
|
|
60314
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
60311
60315
|
return { user, key: key3, error };
|
|
60312
60316
|
}
|
|
60313
60317
|
function memoryStatus(result3) {
|
|
@@ -60479,7 +60483,7 @@ scheduledResultApp.delete("/schedule-runs/:runId/view-links/:shareId", async (c)
|
|
|
60479
60483
|
import { Hono as Hono39 } from "hono";
|
|
60480
60484
|
|
|
60481
60485
|
// src/scheduled-artifacts/scheduled-run-artifact-store.ts
|
|
60482
|
-
import { createHash as
|
|
60486
|
+
import { createHash as createHash53 } from "crypto";
|
|
60483
60487
|
var SCHEDULED_RUN_ARTIFACT_PREFIX = "scheduled-run-artifacts/";
|
|
60484
60488
|
var SCHEDULED_RUN_ARTIFACT_DOWNLOAD_TTL_MS = 15 * 60 * 1e3;
|
|
60485
60489
|
var SCHEDULED_RUN_ARTIFACT_MAX_BYTES = 2e6;
|
|
@@ -60495,7 +60499,7 @@ function policy5() {
|
|
|
60495
60499
|
};
|
|
60496
60500
|
}
|
|
60497
60501
|
function runStorageSegment(runId) {
|
|
60498
|
-
return /^[a-zA-Z0-9_-]{1,160}$/.test(runId) ? runId : `run-${
|
|
60502
|
+
return /^[a-zA-Z0-9_-]{1,160}$/.test(runId) ? runId : `run-${createHash53("sha256").update(runId).digest("hex").slice(0, 32)}`;
|
|
60499
60503
|
}
|
|
60500
60504
|
async function createScheduledRunArtifact(args) {
|
|
60501
60505
|
if (args.rendered.bytes > SCHEDULED_RUN_ARTIFACT_MAX_BYTES) {
|
|
@@ -60687,11 +60691,11 @@ scheduledArtifactInternalApp.post("/render", async (c) => {
|
|
|
60687
60691
|
});
|
|
60688
60692
|
|
|
60689
60693
|
// src/api/personal-assistant-routes.ts
|
|
60690
|
-
import { createHash as
|
|
60694
|
+
import { createHash as createHash61, randomUUID as randomUUID45 } from "crypto";
|
|
60691
60695
|
import { Hono as Hono42 } from "hono";
|
|
60692
60696
|
|
|
60693
60697
|
// src/api/personal-assistant-schedule-readiness.ts
|
|
60694
|
-
import { createHash as
|
|
60698
|
+
import { createHash as createHash54 } from "crypto";
|
|
60695
60699
|
import { z as z47 } from "zod";
|
|
60696
60700
|
var opaqueRef = z47.string().trim().regex(/^[a-z][a-z0-9_]*_[A-Za-z0-9_-]{3,128}$/);
|
|
60697
60701
|
var isoTimestamp2 = z47.iso.datetime({ offset: true });
|
|
@@ -60764,7 +60768,7 @@ function canonicalJson2(value) {
|
|
|
60764
60768
|
return JSON.stringify(value);
|
|
60765
60769
|
}
|
|
60766
60770
|
function digest2(value) {
|
|
60767
|
-
return
|
|
60771
|
+
return createHash54("sha256").update(canonicalJson2(value)).digest("hex");
|
|
60768
60772
|
}
|
|
60769
60773
|
function validTimezone2(timezone) {
|
|
60770
60774
|
try {
|
|
@@ -61025,7 +61029,7 @@ async function evaluateScheduleReadiness(rawInput, dependencies) {
|
|
|
61025
61029
|
}
|
|
61026
61030
|
|
|
61027
61031
|
// src/api/personal-assistant-command-builder.ts
|
|
61028
|
-
import { createHash as
|
|
61032
|
+
import { createHash as createHash55 } from "crypto";
|
|
61029
61033
|
function canonicalJson3(value) {
|
|
61030
61034
|
return JSON.stringify(value, (_key, entry) => {
|
|
61031
61035
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
|
|
@@ -61033,7 +61037,7 @@ function canonicalJson3(value) {
|
|
|
61033
61037
|
});
|
|
61034
61038
|
}
|
|
61035
61039
|
function digest3(value) {
|
|
61036
|
-
return
|
|
61040
|
+
return createHash55("sha256").update(canonicalJson3(value)).digest("hex");
|
|
61037
61041
|
}
|
|
61038
61042
|
function explicitControlIntent(text3) {
|
|
61039
61043
|
const normalized = text3.trim().toLowerCase();
|
|
@@ -61082,7 +61086,7 @@ async function buildPersonalAssistantCommand(context, input) {
|
|
|
61082
61086
|
}
|
|
61083
61087
|
|
|
61084
61088
|
// src/api/personal-assistant-consent-content.ts
|
|
61085
|
-
import { createHash as
|
|
61089
|
+
import { createHash as createHash56 } from "crypto";
|
|
61086
61090
|
var SUBMITTED_EVIDENCE = Object.freeze({
|
|
61087
61091
|
evidenceVersion: "twilio-toll-free-submission.2026-08-28.v1",
|
|
61088
61092
|
policyVersion: "2026-08-28.v1",
|
|
@@ -61145,7 +61149,7 @@ var ASSISTANT_ENROLLMENT_DISCLOSURE_TEXT = Object.freeze([
|
|
|
61145
61149
|
ASSISTANT_CONSENT_CONTENT_V1.retentionDisclosure,
|
|
61146
61150
|
ASSISTANT_CONSENT_CONTENT_V1.termsDisclosure
|
|
61147
61151
|
].join("\n\n"));
|
|
61148
|
-
var ASSISTANT_ENROLLMENT_DISCLOSURE_DIGEST =
|
|
61152
|
+
var ASSISTANT_ENROLLMENT_DISCLOSURE_DIGEST = createHash56("sha256").update(`${ASSISTANT_CONSENT_CONTENT_V1.policyVersion}\0${ASSISTANT_ENROLLMENT_DISCLOSURE_TEXT}`).digest("hex");
|
|
61149
61153
|
var ASSISTANT_ENROLLMENT_DISCLOSURE_PROJECTION = Object.freeze({
|
|
61150
61154
|
policyVersion: ASSISTANT_CONSENT_CONTENT_V1.policyVersion,
|
|
61151
61155
|
disclosureDigest: ASSISTANT_ENROLLMENT_DISCLOSURE_DIGEST,
|
|
@@ -61156,11 +61160,11 @@ var ASSISTANT_ENROLLMENT_DISCLOSURE_PROJECTION = Object.freeze({
|
|
|
61156
61160
|
});
|
|
61157
61161
|
|
|
61158
61162
|
// src/api/personal-assistant-lifecycle.ts
|
|
61159
|
-
import { createHash as
|
|
61163
|
+
import { createHash as createHash58, randomUUID as randomUUID44 } from "crypto";
|
|
61160
61164
|
import { z as z48 } from "zod";
|
|
61161
61165
|
|
|
61162
61166
|
// src/api/personal-assistant-db.ts
|
|
61163
|
-
import { createHash as
|
|
61167
|
+
import { createHash as createHash57 } from "crypto";
|
|
61164
61168
|
import { Pool } from "pg";
|
|
61165
61169
|
|
|
61166
61170
|
// src/api/personal-assistant-schema.ts
|
|
@@ -61282,7 +61286,7 @@ function assistantDatabaseBindingFingerprint(value) {
|
|
|
61282
61286
|
if (!database) {
|
|
61283
61287
|
throw new AssistantDatabaseError("assistant_database_binding_invalid", "Personal Assistant database name is missing.");
|
|
61284
61288
|
}
|
|
61285
|
-
return
|
|
61289
|
+
return createHash57("sha256").update(`${normalizedNeonHost(parsed.hostname)}\0${database}`).digest("hex");
|
|
61286
61290
|
}
|
|
61287
61291
|
function assistantDatabaseRole(value) {
|
|
61288
61292
|
const role = decodeURIComponent(parseDatabaseUrl(value).username);
|
|
@@ -61570,7 +61574,7 @@ var AssistantLifecycleError = class extends Error {
|
|
|
61570
61574
|
};
|
|
61571
61575
|
|
|
61572
61576
|
// src/api/personal-assistant-service.ts
|
|
61573
|
-
import { createHash as
|
|
61577
|
+
import { createHash as createHash59 } from "crypto";
|
|
61574
61578
|
var PERSONAL_ASSISTANT_INTENT_ENVELOPE_VERSION = "assistant-intent-envelope.v1";
|
|
61575
61579
|
var CONTROL_INTENTS = /* @__PURE__ */ new Set(["help", "status", "approve", "reject", "cancel"]);
|
|
61576
61580
|
var EXPLICIT_TASK_INTENTS = /* @__PURE__ */ new Set([
|
|
@@ -61736,7 +61740,7 @@ function canonicalServiceJson(value) {
|
|
|
61736
61740
|
});
|
|
61737
61741
|
}
|
|
61738
61742
|
function serviceDigest(value) {
|
|
61739
|
-
return
|
|
61743
|
+
return createHash59("sha256").update(canonicalServiceJson(value)).digest("hex");
|
|
61740
61744
|
}
|
|
61741
61745
|
function serviceReceipt(idempotencyKey4, requestDigest2, occurredAt, state2, result3, error = null) {
|
|
61742
61746
|
const receiptRef = `receipt_${serviceDigest({ idempotencyKey: idempotencyKey4, requestDigest: requestDigest2 }).slice(0, 32)}`;
|
|
@@ -63163,7 +63167,7 @@ import twilio3 from "twilio";
|
|
|
63163
63167
|
import { Hono as Hono41 } from "hono";
|
|
63164
63168
|
|
|
63165
63169
|
// src/api/personal-assistant-observability.ts
|
|
63166
|
-
import { createHash as
|
|
63170
|
+
import { createHash as createHash60 } from "crypto";
|
|
63167
63171
|
var OPAQUE_TRACE_REF = /^trace_[A-Za-z0-9_-]{8,128}$/u;
|
|
63168
63172
|
var KINDS = /* @__PURE__ */ new Set([
|
|
63169
63173
|
"purchase_unknown",
|
|
@@ -63860,7 +63864,7 @@ function payloadWithout(input, ...keys) {
|
|
|
63860
63864
|
return Object.fromEntries(Object.entries(input).filter(([key3, value]) => !omitted.has(key3) && value !== void 0));
|
|
63861
63865
|
}
|
|
63862
63866
|
function personalAssistantMessagingServiceReviewDigest(review) {
|
|
63863
|
-
return
|
|
63867
|
+
return createHash61("sha256").update(JSON.stringify({
|
|
63864
63868
|
schemaVersion: "assistant-messaging-service-review.v1",
|
|
63865
63869
|
numberRef: review.numberRef,
|
|
63866
63870
|
connectionRef: review.connectionRef,
|
|
@@ -63994,7 +63998,7 @@ function ownerCaller(c) {
|
|
|
63994
63998
|
throw new OwnerRouteError("not_authenticated", "Authentication is required.", 401);
|
|
63995
63999
|
}
|
|
63996
64000
|
if (ownerUserId2 <= 0n) throw new OwnerRouteError("not_authenticated", "Authentication is required.", 401);
|
|
63997
|
-
const subjectRef = `owner_${
|
|
64001
|
+
const subjectRef = `owner_${createHash61("sha256").update(ownerUserId2.toString()).digest("hex").slice(0, 24)}`;
|
|
63998
64002
|
return { kind: "owner", surface: "rest", ownerUserId: ownerUserId2, subjectRef };
|
|
63999
64003
|
}
|
|
64000
64004
|
function enrollmentRequesterBinding(c, caller2) {
|
|
@@ -64770,7 +64774,7 @@ function buildPersonalAssistantBrowserProfileRoutes(options) {
|
|
|
64770
64774
|
}
|
|
64771
64775
|
|
|
64772
64776
|
// src/api/personal-assistant-browser-production.ts
|
|
64773
|
-
import { createHash as
|
|
64777
|
+
import { createHash as createHash65, randomUUID as randomUUID52 } from "crypto";
|
|
64774
64778
|
|
|
64775
64779
|
// src/api/personal-assistant-browser-handoff-store.ts
|
|
64776
64780
|
import { createHmac as createHmac12, randomUUID as randomUUID48 } from "crypto";
|
|
@@ -65064,7 +65068,7 @@ function createPostgresPersonalAssistantBrowserHandoffStore(options) {
|
|
|
65064
65068
|
}
|
|
65065
65069
|
|
|
65066
65070
|
// src/api/personal-assistant-browser-profile-store.ts
|
|
65067
|
-
import { createHash as
|
|
65071
|
+
import { createHash as createHash62, createHmac as createHmac13, randomUUID as randomUUID49 } from "crypto";
|
|
65068
65072
|
import { domainToASCII } from "url";
|
|
65069
65073
|
var PersonalAssistantBrowserProfileStoreError = class extends Error {
|
|
65070
65074
|
constructor(code, message = code, status = code.endsWith("revision_conflict") ? 409 : code.endsWith("input_rejected") ? 400 : 404) {
|
|
@@ -65194,7 +65198,7 @@ function deriveBrowserProviderNamespaceDigest(keyInput, ownerUserId2, profileRef
|
|
|
65194
65198
|
}
|
|
65195
65199
|
function digestEvidence(value) {
|
|
65196
65200
|
const canonical3 = JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))) : entry);
|
|
65197
|
-
return
|
|
65201
|
+
return createHash62("sha256").update(canonical3).digest("hex");
|
|
65198
65202
|
}
|
|
65199
65203
|
function exactCapabilityList(value, allowed) {
|
|
65200
65204
|
if (!Array.isArray(value)) return [];
|
|
@@ -65600,7 +65604,7 @@ function createPostgresPersonalAssistantBrowserProfileStore(options) {
|
|
|
65600
65604
|
}
|
|
65601
65605
|
|
|
65602
65606
|
// src/api/personal-assistant-idempotency-store.ts
|
|
65603
|
-
import { createHash as
|
|
65607
|
+
import { createHash as createHash63, randomUUID as randomUUID50 } from "crypto";
|
|
65604
65608
|
var PersonalAssistantIdempotencyConflictError = class extends Error {
|
|
65605
65609
|
code = "idempotency_conflict";
|
|
65606
65610
|
status = 409;
|
|
@@ -65629,7 +65633,7 @@ function jsonValue(value) {
|
|
|
65629
65633
|
return JSON.parse(serialized);
|
|
65630
65634
|
}
|
|
65631
65635
|
function resultDigest(value) {
|
|
65632
|
-
return
|
|
65636
|
+
return createHash63("sha256").update(canonicalJson4(value)).digest("hex");
|
|
65633
65637
|
}
|
|
65634
65638
|
function timestamp3(value) {
|
|
65635
65639
|
return value instanceof Date ? value.toISOString() : new Date(value).toISOString();
|
|
@@ -65712,7 +65716,7 @@ function createPostgresPersonalAssistantIdempotencyStore(options = {}) {
|
|
|
65712
65716
|
}
|
|
65713
65717
|
|
|
65714
65718
|
// src/api/personal-assistant-browser-account-cleanup.ts
|
|
65715
|
-
import { createHash as
|
|
65719
|
+
import { createHash as createHash64, randomUUID as randomUUID51 } from "crypto";
|
|
65716
65720
|
function positiveOwner2(value) {
|
|
65717
65721
|
if (typeof value !== "bigint" || value <= 0n) throw new TypeError("positive ownerUserId is required");
|
|
65718
65722
|
return value.toString();
|
|
@@ -65774,7 +65778,7 @@ function createPersonalAssistantBrowserAccountCleanup(options) {
|
|
|
65774
65778
|
cleanupRef: `cleanup_${randomUUID51().replaceAll("-", "")}`,
|
|
65775
65779
|
state: "confirmed",
|
|
65776
65780
|
...evidence,
|
|
65777
|
-
evidenceDigest:
|
|
65781
|
+
evidenceDigest: createHash64("sha256").update(JSON.stringify(evidence)).digest("hex")
|
|
65778
65782
|
});
|
|
65779
65783
|
};
|
|
65780
65784
|
}
|
|
@@ -65801,7 +65805,7 @@ var VERIFIED_BROWSER_CAPABILITIES = Object.freeze([
|
|
|
65801
65805
|
"download"
|
|
65802
65806
|
]);
|
|
65803
65807
|
function digest5(value) {
|
|
65804
|
-
return
|
|
65808
|
+
return createHash65("sha256").update(JSON.stringify(value, (_key, entry) => {
|
|
65805
65809
|
if (typeof entry === "bigint") return entry.toString();
|
|
65806
65810
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
|
|
65807
65811
|
return Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)));
|
|
@@ -66372,7 +66376,7 @@ var personalAssistantBrowserHandoffApp = buildPersonalAssistantBrowserHandoffRou
|
|
|
66372
66376
|
import { Hono as Hono46 } from "hono";
|
|
66373
66377
|
|
|
66374
66378
|
// src/api/personal-assistant-worker-routes.ts
|
|
66375
|
-
import { createHash as
|
|
66379
|
+
import { createHash as createHash66, createPublicKey, verify as verify2 } from "crypto";
|
|
66376
66380
|
import { Hono as Hono45 } from "hono";
|
|
66377
66381
|
import { z as z49 } from "zod";
|
|
66378
66382
|
var PERSONAL_ASSISTANT_WORKER_API_PREFIX = "/api/private/v1/assistant-worker";
|
|
@@ -66402,11 +66406,11 @@ function canonicalJson5(value) {
|
|
|
66402
66406
|
return JSON.stringify(value);
|
|
66403
66407
|
}
|
|
66404
66408
|
function personalAssistantWorkerBodyDigest(rawBody) {
|
|
66405
|
-
return
|
|
66409
|
+
return createHash66("sha256").update(rawBody, "utf8").digest("hex");
|
|
66406
66410
|
}
|
|
66407
66411
|
function personalAssistantPlanDigest(plan) {
|
|
66408
66412
|
const { planRef: _planRef, planDigest: _planDigest, immutable: _immutable, createdAt: _createdAt, ...proposal } = plan;
|
|
66409
|
-
return
|
|
66413
|
+
return createHash66("sha256").update(canonicalJson5(proposal)).digest("hex");
|
|
66410
66414
|
}
|
|
66411
66415
|
function personalAssistantWorkerSigningPayload(input) {
|
|
66412
66416
|
return [
|
|
@@ -66560,7 +66564,7 @@ function verifyPolicyEnvelope(identity, envelope, at) {
|
|
|
66560
66564
|
if (Date.parse(envelope.expiresAt) <= at.getTime() || Math.abs(at.getTime() - Date.parse(envelope.createdAt)) > 6e4) {
|
|
66561
66565
|
throw new AssistantWorkerRouteError("worker_policy_request_expired", "The policy request has expired.", 401);
|
|
66562
66566
|
}
|
|
66563
|
-
const expectedDigest =
|
|
66567
|
+
const expectedDigest = createHash66("sha256").update(canonicalJson5(envelope.body)).digest("hex");
|
|
66564
66568
|
if (expectedDigest !== envelope.bodyDigest) throw new AssistantWorkerRouteError("worker_policy_digest_mismatch", "The policy request digest does not match.", 401);
|
|
66565
66569
|
const { signature, ...unsigned } = envelope;
|
|
66566
66570
|
let valid = false;
|
|
@@ -66578,7 +66582,7 @@ function verifyClaimEnvelope(identity, envelope, at) {
|
|
|
66578
66582
|
if (Math.abs(at.getTime() - Date.parse(envelope.createdAt)) > PERSONAL_ASSISTANT_WORKER_SIGNATURE_TTL_MS) {
|
|
66579
66583
|
throw new AssistantWorkerRouteError("worker_claim_expired", "The worker claim has expired.", 401);
|
|
66580
66584
|
}
|
|
66581
|
-
const expectedDigest =
|
|
66585
|
+
const expectedDigest = createHash66("sha256").update(canonicalJson5(envelope.body)).digest("hex");
|
|
66582
66586
|
if (expectedDigest !== envelope.bodyDigest) throw new AssistantWorkerRouteError("worker_claim_digest_mismatch", "The claim digest does not match.", 401);
|
|
66583
66587
|
const { signature, ...unsigned } = envelope;
|
|
66584
66588
|
let valid = false;
|
|
@@ -66881,12 +66885,12 @@ var personalAssistantWorkerProductionApp = (() => {
|
|
|
66881
66885
|
})();
|
|
66882
66886
|
|
|
66883
66887
|
// src/api/personal-assistant-admin-routes.ts
|
|
66884
|
-
import { createHash as
|
|
66888
|
+
import { createHash as createHash68, createPublicKey as createPublicKey2 } from "crypto";
|
|
66885
66889
|
import { Hono as Hono47 } from "hono";
|
|
66886
66890
|
import { z as z50 } from "zod";
|
|
66887
66891
|
|
|
66888
66892
|
// src/api/personal-assistant-kill-controls.ts
|
|
66889
|
-
import { createHash as
|
|
66893
|
+
import { createHash as createHash67, randomUUID as randomUUID53 } from "crypto";
|
|
66890
66894
|
var PERSONAL_ASSISTANT_KILL_SCOPES = [
|
|
66891
66895
|
"global",
|
|
66892
66896
|
"outbound",
|
|
@@ -66914,7 +66918,7 @@ function canonicalJson6(value) {
|
|
|
66914
66918
|
return JSON.stringify(value);
|
|
66915
66919
|
}
|
|
66916
66920
|
function digest6(value) {
|
|
66917
|
-
return
|
|
66921
|
+
return createHash67("sha256").update(canonicalJson6(value)).digest("hex");
|
|
66918
66922
|
}
|
|
66919
66923
|
function validateTarget(target) {
|
|
66920
66924
|
if (!PERSONAL_ASSISTANT_KILL_SCOPES.includes(target.scope)) throw new PersonalAssistantKillControlError("invalid_kill_control", "Invalid kill-control scope.", 400);
|
|
@@ -67182,7 +67186,7 @@ async function strictJson2(c, maxBodyBytes) {
|
|
|
67182
67186
|
}
|
|
67183
67187
|
}
|
|
67184
67188
|
function derivedRef(prefix, ...identity) {
|
|
67185
|
-
return `${prefix}_${
|
|
67189
|
+
return `${prefix}_${createHash68("sha256").update(identity.join("\0")).digest("base64url").slice(0, 32)}`;
|
|
67186
67190
|
}
|
|
67187
67191
|
function ownerUserId(target) {
|
|
67188
67192
|
if (!/^[1-9][0-9]{0,18}$/.test(target.targetKey)) {
|
|
@@ -67268,7 +67272,7 @@ function buildPersonalAssistantAdminRoutes(options) {
|
|
|
67268
67272
|
const identity = c.get("assistantAdmin");
|
|
67269
67273
|
requireCapability(identity, "assistant.worker_registration.register");
|
|
67270
67274
|
const parsed = WorkerRegistrationSchema.safeParse(await strictJson2(c, maxBodyBytes));
|
|
67271
|
-
if (!parsed.success || Date.parse(parsed.data.expiresAt) <= now().getTime() || !/^-----BEGIN PUBLIC KEY-----\n[\s\S]+\n-----END PUBLIC KEY-----\n?$/.test(parsed.data.publicKeyPem) || /PRIVATE KEY|ENCRYPTED/.test(parsed.data.publicKeyPem) ||
|
|
67275
|
+
if (!parsed.success || Date.parse(parsed.data.expiresAt) <= now().getTime() || !/^-----BEGIN PUBLIC KEY-----\n[\s\S]+\n-----END PUBLIC KEY-----\n?$/.test(parsed.data.publicKeyPem) || /PRIVATE KEY|ENCRYPTED/.test(parsed.data.publicKeyPem) || createHash68("sha256").update(parsed.success ? parsed.data.publicKeyPem : "").digest("hex") !== (parsed.success ? parsed.data.publicKeySha256 : "")) {
|
|
67272
67276
|
throw new PersonalAssistantAdminRouteError("invalid_worker_registration", "Invalid worker registration request.", 400);
|
|
67273
67277
|
}
|
|
67274
67278
|
try {
|
|
@@ -67394,24 +67398,24 @@ var personalAssistantCronProductionApp = (() => {
|
|
|
67394
67398
|
})();
|
|
67395
67399
|
|
|
67396
67400
|
// src/api/personal-assistant-production.ts
|
|
67397
|
-
import { createHash as
|
|
67401
|
+
import { createHash as createHash98 } from "crypto";
|
|
67398
67402
|
|
|
67399
67403
|
// src/api/personal-assistant-admin-production.ts
|
|
67400
|
-
import { createHash as
|
|
67404
|
+
import { createHash as createHash72 } from "crypto";
|
|
67401
67405
|
|
|
67402
67406
|
// src/api/personal-assistant-worker-store.ts
|
|
67403
|
-
import { createHash as
|
|
67407
|
+
import { createHash as createHash71, randomUUID as randomUUID55 } from "crypto";
|
|
67404
67408
|
|
|
67405
67409
|
// src/api/personal-assistant-repository.ts
|
|
67406
|
-
import { createHash as
|
|
67410
|
+
import { createHash as createHash70, randomBytes as randomBytes7, randomUUID as randomUUID54 } from "crypto";
|
|
67407
67411
|
|
|
67408
67412
|
// src/api/personal-assistant-wake-packet.ts
|
|
67409
|
-
import { createHash as
|
|
67413
|
+
import { createHash as createHash69 } from "crypto";
|
|
67410
67414
|
function stableJson(value) {
|
|
67411
67415
|
return JSON.stringify(value, (_key, entry) => !entry || typeof entry !== "object" || Array.isArray(entry) ? entry : Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))));
|
|
67412
67416
|
}
|
|
67413
67417
|
function stableDigest(value) {
|
|
67414
|
-
return
|
|
67418
|
+
return createHash69("sha256").update(stableJson(value)).digest("hex");
|
|
67415
67419
|
}
|
|
67416
67420
|
function deterministicWakePacketRef(snapshot) {
|
|
67417
67421
|
return `wake_${stableDigest({ assistantRef: snapshot.assistantRef, commandRef: snapshot.commandRef, cycleRef: snapshot.cycleRef, executionRef: snapshot.executionRef, contextVersionRef: snapshot.contextVersion.contextVersionRef }).slice(0, 32)}`;
|
|
@@ -67464,10 +67468,10 @@ function canonicalJson7(value) {
|
|
|
67464
67468
|
});
|
|
67465
67469
|
}
|
|
67466
67470
|
function digest7(value) {
|
|
67467
|
-
return
|
|
67471
|
+
return createHash70("sha256").update(canonicalJson7(value)).digest("hex");
|
|
67468
67472
|
}
|
|
67469
67473
|
function deterministicRef2(prefix, identity) {
|
|
67470
|
-
return `${prefix}_${
|
|
67474
|
+
return `${prefix}_${createHash70("sha256").update(identity).digest("hex").slice(0, 32)}`;
|
|
67471
67475
|
}
|
|
67472
67476
|
function messageCursor(message) {
|
|
67473
67477
|
return Buffer.from(JSON.stringify([message.occurredAt, message.messageRef])).toString("base64url");
|
|
@@ -67963,7 +67967,7 @@ function createPostgresPersonalAssistantRepositoryStore(options = {}) {
|
|
|
67963
67967
|
`, [ownerUserId2.toString(), row.id]);
|
|
67964
67968
|
}
|
|
67965
67969
|
const token7 = randomBytes7(32).toString("base64url");
|
|
67966
|
-
const tokenHash5 =
|
|
67970
|
+
const tokenHash5 = createHash70("sha256").update(token7).digest("hex");
|
|
67967
67971
|
const leaseRef = deterministicRef2("lease", `${input.executionRef}\0${input.workerRef}\0${input.now}`);
|
|
67968
67972
|
const expiresAt = new Date(Date.parse(input.now) + input.leaseSeconds * 1e3).toISOString();
|
|
67969
67973
|
await client2.query(`
|
|
@@ -69501,10 +69505,10 @@ var AssistantWorkerStoreError = class extends Error {
|
|
|
69501
69505
|
};
|
|
69502
69506
|
function hash(value) {
|
|
69503
69507
|
const canonical3 = JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))) : entry);
|
|
69504
|
-
return
|
|
69508
|
+
return createHash71("sha256").update(canonical3).digest("hex");
|
|
69505
69509
|
}
|
|
69506
69510
|
function ref2(prefix, identity) {
|
|
69507
|
-
return `${prefix}_${
|
|
69511
|
+
return `${prefix}_${createHash71("sha256").update(identity).digest("hex").slice(0, 32)}`;
|
|
69508
69512
|
}
|
|
69509
69513
|
function requiredString(input, key3) {
|
|
69510
69514
|
const value = input[key3];
|
|
@@ -69903,7 +69907,7 @@ var INTERNAL_CAPABILITIES = /* @__PURE__ */ new Set([
|
|
|
69903
69907
|
"assistant.worker_registration.revoke"
|
|
69904
69908
|
]);
|
|
69905
69909
|
function actorRef(issuer, subject) {
|
|
69906
|
-
return `admin_actor_${
|
|
69910
|
+
return `admin_actor_${createHash72("sha256").update(`${issuer}\0${subject}`).digest("base64url").slice(0, 32)}`;
|
|
69907
69911
|
}
|
|
69908
69912
|
var VerifiedPersonalAssistantAdminIdentityPort = class {
|
|
69909
69913
|
constructor(verifier, configuration) {
|
|
@@ -70017,7 +70021,7 @@ function createPersonalAssistantAdminProductionDependencies(input) {
|
|
|
70017
70021
|
}
|
|
70018
70022
|
|
|
70019
70023
|
// src/api/personal-assistant-dispatcher.ts
|
|
70020
|
-
import { createHash as
|
|
70024
|
+
import { createHash as createHash73, randomBytes as randomBytes8, randomUUID as randomUUID56 } from "crypto";
|
|
70021
70025
|
var AssistantLeaseFenceError = class extends Error {
|
|
70022
70026
|
code = "assistant_lease_fence_rejected";
|
|
70023
70027
|
constructor() {
|
|
@@ -70031,7 +70035,7 @@ function canonical2(value) {
|
|
|
70031
70035
|
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key3, entry]) => [key3, canonical2(entry)]));
|
|
70032
70036
|
}
|
|
70033
70037
|
function digest8(value) {
|
|
70034
|
-
return
|
|
70038
|
+
return createHash73("sha256").update(JSON.stringify(canonical2(value))).digest("hex");
|
|
70035
70039
|
}
|
|
70036
70040
|
function ref3(prefix, identity) {
|
|
70037
70041
|
return `${prefix}_${digest8(identity).slice(0, 32)}`;
|
|
@@ -70895,10 +70899,10 @@ function createPersonalAssistantReminderRuntime(options) {
|
|
|
70895
70899
|
}
|
|
70896
70900
|
|
|
70897
70901
|
// src/api/personal-assistant-reconcile-cron.ts
|
|
70898
|
-
import { createHash as
|
|
70902
|
+
import { createHash as createHash75, timingSafeEqual as timingSafeEqual8 } from "crypto";
|
|
70899
70903
|
|
|
70900
70904
|
// src/api/personal-assistant-reconcile.ts
|
|
70901
|
-
import { createHash as
|
|
70905
|
+
import { createHash as createHash74 } from "crypto";
|
|
70902
70906
|
var PERSONAL_ASSISTANT_RECONCILIATION_LIMITS = Object.freeze({
|
|
70903
70907
|
defaultBatchSize: 20,
|
|
70904
70908
|
maxBatchSize: 50,
|
|
@@ -70920,7 +70924,7 @@ var PUBLIC_REF = /^[a-z][a-z0-9_]*_[A-Za-z0-9_-]{3,128}$/u;
|
|
|
70920
70924
|
var DIGEST2 = /^[a-f0-9]{64}$/u;
|
|
70921
70925
|
var PROVIDER_REF = /^[A-Za-z0-9:_-]{3,200}$/u;
|
|
70922
70926
|
function hash2(value) {
|
|
70923
|
-
return
|
|
70927
|
+
return createHash74("sha256").update(value).digest("hex");
|
|
70924
70928
|
}
|
|
70925
70929
|
function validateCandidate(candidate) {
|
|
70926
70930
|
if (!/^[1-9]\d*$/u.test(candidate.ownerUserId) || !PUBLIC_REF.test(candidate.candidateRef) || !/^trace_[A-Za-z0-9_-]{8,128}$/u.test(candidate.traceRef) || !PUBLIC_REF.test(candidate.claimToken) || !PROVIDER_REF.test(candidate.providerAccountRef) || !PROVIDER_REF.test(candidate.providerLocatorRef) || !DIGEST2.test(candidate.expectedDigest) || !Number.isFinite(Date.parse(candidate.stuckSince))) {
|
|
@@ -71042,8 +71046,8 @@ async function reconcilePersonalAssistantTransports(dependencies, options = {})
|
|
|
71042
71046
|
// src/api/personal-assistant-reconcile-cron.ts
|
|
71043
71047
|
function authorized(actual, expectedSecret) {
|
|
71044
71048
|
if (!actual?.startsWith("Bearer ")) return false;
|
|
71045
|
-
const actualDigest =
|
|
71046
|
-
const expectedDigest =
|
|
71049
|
+
const actualDigest = createHash75("sha256").update(actual).digest();
|
|
71050
|
+
const expectedDigest = createHash75("sha256").update(`Bearer ${expectedSecret}`).digest();
|
|
71047
71051
|
return timingSafeEqual8(actualDigest, expectedDigest);
|
|
71048
71052
|
}
|
|
71049
71053
|
function createPersonalAssistantReconcileCronHandler(options) {
|
|
@@ -71105,7 +71109,7 @@ function createPersonalAssistantReminderCronHandler(options) {
|
|
|
71105
71109
|
}
|
|
71106
71110
|
|
|
71107
71111
|
// src/api/twilio-inbound-admission.ts
|
|
71108
|
-
import { createHash as
|
|
71112
|
+
import { createHash as createHash76, randomBytes as randomBytes9 } from "crypto";
|
|
71109
71113
|
var ACCOUNT_SID = /^AC[0-9a-f]{32}$/iu;
|
|
71110
71114
|
var MESSAGE_SID = /^(?:SM|MM)[0-9a-f]{32}$/iu;
|
|
71111
71115
|
var MESSAGING_SERVICE_SID = /^MG[0-9a-f]{32}$/iu;
|
|
@@ -71127,10 +71131,10 @@ function canonicalJson8(value) {
|
|
|
71127
71131
|
});
|
|
71128
71132
|
}
|
|
71129
71133
|
function digest9(value) {
|
|
71130
|
-
return
|
|
71134
|
+
return createHash76("sha256").update(canonicalJson8(value)).digest("hex");
|
|
71131
71135
|
}
|
|
71132
71136
|
function stableRef(prefix, value) {
|
|
71133
|
-
return `${prefix}_${
|
|
71137
|
+
return `${prefix}_${createHash76("sha256").update(value).digest("hex").slice(0, 32)}`;
|
|
71134
71138
|
}
|
|
71135
71139
|
function normalizeOptionalSid(value) {
|
|
71136
71140
|
const normalized = value?.trim() || null;
|
|
@@ -71276,8 +71280,8 @@ function createTwilioInboundIngressCronHandler(options) {
|
|
|
71276
71280
|
return async (request) => {
|
|
71277
71281
|
if (request.method !== "GET") return Response.json({ error: "method_not_allowed" }, { status: 405, headers: { Allow: "GET" } });
|
|
71278
71282
|
const actual = request.headers.get("authorization") ?? "";
|
|
71279
|
-
const actualDigest =
|
|
71280
|
-
const expectedDigest =
|
|
71283
|
+
const actualDigest = createHash76("sha256").update(actual).digest();
|
|
71284
|
+
const expectedDigest = createHash76("sha256").update(expectedAuthorization).digest();
|
|
71281
71285
|
if (actualDigest.length !== expectedDigest.length || !actualDigest.equals(expectedDigest)) {
|
|
71282
71286
|
return Response.json({ error: "unauthorized" }, { status: 401 });
|
|
71283
71287
|
}
|
|
@@ -71319,7 +71323,7 @@ function createPersonalAssistantWorkerAndCronProduction(options) {
|
|
|
71319
71323
|
}
|
|
71320
71324
|
|
|
71321
71325
|
// src/api/personal-assistant-control-plane-store.ts
|
|
71322
|
-
import { createHash as
|
|
71326
|
+
import { createHash as createHash77, randomUUID as randomUUID57 } from "crypto";
|
|
71323
71327
|
var REF = /^[a-z][A-Za-z0-9_-]{2,159}$/;
|
|
71324
71328
|
var DIGEST4 = /^[a-f0-9]{64}$/;
|
|
71325
71329
|
function record3(input) {
|
|
@@ -71351,7 +71355,7 @@ function canonicalJson9(value) {
|
|
|
71351
71355
|
});
|
|
71352
71356
|
}
|
|
71353
71357
|
function digest10(value) {
|
|
71354
|
-
return
|
|
71358
|
+
return createHash77("sha256").update(canonicalJson9(value)).digest("hex");
|
|
71355
71359
|
}
|
|
71356
71360
|
function normalizeE164(value) {
|
|
71357
71361
|
const trimmed = value.trim();
|
|
@@ -71780,7 +71784,7 @@ function createPostgresPersonalAssistantNumberPort(options) {
|
|
|
71780
71784
|
}
|
|
71781
71785
|
|
|
71782
71786
|
// src/api/personal-assistant-scheduling-store.ts
|
|
71783
|
-
import { createHash as
|
|
71787
|
+
import { createHash as createHash78, randomUUID as randomUUID58 } from "crypto";
|
|
71784
71788
|
var PersonalAssistantSchedulingStoreError = class extends Error {
|
|
71785
71789
|
constructor(code, message = code, status = code === "schedule_not_found" ? 404 : code === "schedule_activation_unavailable" ? 503 : 409) {
|
|
71786
71790
|
super(message);
|
|
@@ -71807,7 +71811,7 @@ function canonicalJson10(value) {
|
|
|
71807
71811
|
return JSON.stringify(value);
|
|
71808
71812
|
}
|
|
71809
71813
|
function digest11(value) {
|
|
71810
|
-
return
|
|
71814
|
+
return createHash78("sha256").update(canonicalJson10(value)).digest("hex");
|
|
71811
71815
|
}
|
|
71812
71816
|
function authorityClass(value) {
|
|
71813
71817
|
if (value === "observe") return "observe";
|
|
@@ -72251,7 +72255,7 @@ function assertNoRawTwilioSecretEnvironment(environment2 = process.env) {
|
|
|
72251
72255
|
}
|
|
72252
72256
|
|
|
72253
72257
|
// src/api/twilio-messaging-service.ts
|
|
72254
|
-
import { createHash as
|
|
72258
|
+
import { createHash as createHash79 } from "crypto";
|
|
72255
72259
|
|
|
72256
72260
|
// src/api/personal-assistant-policy.ts
|
|
72257
72261
|
var AUTHORITY_RANK = {
|
|
@@ -72551,10 +72555,10 @@ function canonicalJson11(value) {
|
|
|
72551
72555
|
});
|
|
72552
72556
|
}
|
|
72553
72557
|
function digest12(value) {
|
|
72554
|
-
return
|
|
72558
|
+
return createHash79("sha256").update(canonicalJson11(value)).digest("hex");
|
|
72555
72559
|
}
|
|
72556
72560
|
function deterministicRef3(prefix, identity) {
|
|
72557
|
-
return `${prefix}_${
|
|
72561
|
+
return `${prefix}_${createHash79("sha256").update(identity).digest("hex").slice(0, 32)}`;
|
|
72558
72562
|
}
|
|
72559
72563
|
function isBoundedAuthorityRef(value) {
|
|
72560
72564
|
return typeof value === "string" && value.length >= 3 && value.length <= 240 && !value.includes("\0");
|
|
@@ -72726,7 +72730,7 @@ function inboundIdentity(input, route) {
|
|
|
72726
72730
|
};
|
|
72727
72731
|
}
|
|
72728
72732
|
function sha256Bytes(bytes2) {
|
|
72729
|
-
return
|
|
72733
|
+
return createHash79("sha256").update(bytes2).digest("hex");
|
|
72730
72734
|
}
|
|
72731
72735
|
function startsWith(bytes2, signature) {
|
|
72732
72736
|
return signature.every((value, index) => bytes2[index] === value);
|
|
@@ -73905,11 +73909,11 @@ function createTwilioMessagingService(dependencies = {}) {
|
|
|
73905
73909
|
}
|
|
73906
73910
|
|
|
73907
73911
|
// src/api/twilio-memory-media.ts
|
|
73908
|
-
import { createHash as
|
|
73912
|
+
import { createHash as createHash80, randomUUID as randomUUID59 } from "crypto";
|
|
73909
73913
|
var IMAGE_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/png", "image/gif", "image/webp"]);
|
|
73910
73914
|
var FILE_TYPES = /* @__PURE__ */ new Set(["application/pdf", "text/plain"]);
|
|
73911
73915
|
function digestBytes(bytes2) {
|
|
73912
|
-
return
|
|
73916
|
+
return createHash80("sha256").update(bytes2).digest("hex");
|
|
73913
73917
|
}
|
|
73914
73918
|
function publicPointer(pointer) {
|
|
73915
73919
|
return Object.freeze({
|
|
@@ -73993,7 +73997,7 @@ function createTwilioMemoryMedia(options) {
|
|
|
73993
73997
|
return publicPointer(await options.pointers.put({
|
|
73994
73998
|
ownerBindingRef: input.ownerBindingRef,
|
|
73995
73999
|
mediaRef: input.mediaRef,
|
|
73996
|
-
renewablePointerRef: `memory_asset_${
|
|
74000
|
+
renewablePointerRef: `memory_asset_${createHash80("sha256").update(`${input.ownerBindingRef}\0${asset.assetId}`).digest("hex").slice(0, 32)}`,
|
|
73997
74001
|
byteDigest: input.byteDigest,
|
|
73998
74002
|
contentType: input.contentType,
|
|
73999
74003
|
byteSize: input.bytes.byteLength,
|
|
@@ -74026,7 +74030,7 @@ function createTwilioMemoryMedia(options) {
|
|
|
74026
74030
|
}
|
|
74027
74031
|
|
|
74028
74032
|
// src/api/twilio-provider-facade.ts
|
|
74029
|
-
import { createHash as
|
|
74033
|
+
import { createHash as createHash81 } from "crypto";
|
|
74030
74034
|
|
|
74031
74035
|
// src/api/twilio-messaging-client.ts
|
|
74032
74036
|
import twilio4 from "twilio";
|
|
@@ -74361,7 +74365,7 @@ function validAuthority(input) {
|
|
|
74361
74365
|
return /^[1-9]\d*$/u.test(input.ownerUserId) && PUBLIC_REF2.test(input.executionRef) && ACCOUNT_SID3.test(input.providerAccountRef) && PUBLIC_REF2.test(input.connectionRef) && /^[A-Za-z][A-Za-z0-9_.:-]{2,159}$/u.test(input.environmentRef);
|
|
74362
74366
|
}
|
|
74363
74367
|
function digest13(value) {
|
|
74364
|
-
return
|
|
74368
|
+
return createHash81("sha256").update(JSON.stringify(value, (_key, entry) => {
|
|
74365
74369
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
|
|
74366
74370
|
return Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)));
|
|
74367
74371
|
})).digest("hex");
|
|
@@ -74550,7 +74554,7 @@ function createTwilioProduction(options) {
|
|
|
74550
74554
|
}
|
|
74551
74555
|
|
|
74552
74556
|
// src/runtime/personal-assistant-deployment-config.ts
|
|
74553
|
-
import { createHash as
|
|
74557
|
+
import { createHash as createHash82 } from "crypto";
|
|
74554
74558
|
import { readFileSync as readFileSync4 } from "fs";
|
|
74555
74559
|
import { resolve as resolve2 } from "path";
|
|
74556
74560
|
var REF_PATTERN = /^(?:[a-z][a-z0-9+.-]*:\/\/)?[A-Za-z0-9][A-Za-z0-9._:/-]{2,240}$/;
|
|
@@ -74586,7 +74590,7 @@ function databaseBinding(value) {
|
|
|
74586
74590
|
const database = decodeURIComponent(parsed.pathname.replace(/^\//, ""));
|
|
74587
74591
|
const role = decodeURIComponent(parsed.username);
|
|
74588
74592
|
if (!database || !/^[a-z_][a-z0-9_]*$/.test(role)) return null;
|
|
74589
|
-
return { fingerprint:
|
|
74593
|
+
return { fingerprint: createHash82("sha256").update(`${labels.join(".")}\0${database}`).digest("hex"), role };
|
|
74590
74594
|
} catch {
|
|
74591
74595
|
return null;
|
|
74592
74596
|
}
|
|
@@ -75048,7 +75052,7 @@ function createPersonalAssistantHostedConfigurationAdapter(input) {
|
|
|
75048
75052
|
}
|
|
75049
75053
|
|
|
75050
75054
|
// src/api/personal-assistant-authorization.ts
|
|
75051
|
-
import { createHash as
|
|
75055
|
+
import { createHash as createHash83 } from "crypto";
|
|
75052
75056
|
import { z as z51 } from "zod";
|
|
75053
75057
|
var ABUSE_GATED_OPERATIONS = /* @__PURE__ */ new Set(["assistant.message.send", "assistant.bulk.send"]);
|
|
75054
75058
|
var NORMALIZED_RECIPIENT_OPERATIONS = /* @__PURE__ */ new Set([
|
|
@@ -75226,7 +75230,7 @@ function canonicalJson12(value) {
|
|
|
75226
75230
|
return JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b))) : entry);
|
|
75227
75231
|
}
|
|
75228
75232
|
function factDigest(value) {
|
|
75229
|
-
return
|
|
75233
|
+
return createHash83("sha256").update(canonicalJson12(value)).digest("hex");
|
|
75230
75234
|
}
|
|
75231
75235
|
var PostgresPersonalAssistantPolicyFactsRepository = class {
|
|
75232
75236
|
constructor(db, contexts, now = () => /* @__PURE__ */ new Date()) {
|
|
@@ -75416,7 +75420,7 @@ var PostgresPersonalAssistantPolicyFactsRepository = class {
|
|
|
75416
75420
|
};
|
|
75417
75421
|
|
|
75418
75422
|
// src/api/personal-assistant-abuse-controls.ts
|
|
75419
|
-
import { createHash as
|
|
75423
|
+
import { createHash as createHash84 } from "crypto";
|
|
75420
75424
|
var EMPTY_STATE = () => ({
|
|
75421
75425
|
version: 1,
|
|
75422
75426
|
events: [],
|
|
@@ -75427,7 +75431,7 @@ var EMPTY_STATE = () => ({
|
|
|
75427
75431
|
bulkIdentities: {}
|
|
75428
75432
|
});
|
|
75429
75433
|
function digest14(value) {
|
|
75430
|
-
return
|
|
75434
|
+
return createHash84("sha256").update(JSON.stringify(value)).digest("hex");
|
|
75431
75435
|
}
|
|
75432
75436
|
function isDigest(value) {
|
|
75433
75437
|
return typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
|
|
@@ -75687,10 +75691,10 @@ var PostgresPersonalAssistantAbuseStore = class {
|
|
|
75687
75691
|
};
|
|
75688
75692
|
|
|
75689
75693
|
// src/api/twilio-authority-billing-postgres.ts
|
|
75690
|
-
import { createHash as
|
|
75694
|
+
import { createHash as createHash86, randomUUID as randomUUID60 } from "crypto";
|
|
75691
75695
|
|
|
75692
75696
|
// src/api/personal-assistant-billing.ts
|
|
75693
|
-
import { createHash as
|
|
75697
|
+
import { createHash as createHash85 } from "crypto";
|
|
75694
75698
|
var AssistantBillingError = class extends Error {
|
|
75695
75699
|
constructor(code, message) {
|
|
75696
75700
|
super(message);
|
|
@@ -75707,7 +75711,7 @@ function canonicalJson13(value) {
|
|
|
75707
75711
|
});
|
|
75708
75712
|
}
|
|
75709
75713
|
function digest15(value) {
|
|
75710
|
-
return
|
|
75714
|
+
return createHash85("sha256").update(canonicalJson13(value)).digest("hex");
|
|
75711
75715
|
}
|
|
75712
75716
|
function assertMoney(value, field) {
|
|
75713
75717
|
if (!Number.isSafeInteger(value) || value < 0) throw new AssistantBillingError("billing_invalid_input", `${field} must be a non-negative safe integer.`);
|
|
@@ -75752,7 +75756,7 @@ function canonicalJson14(value) {
|
|
|
75752
75756
|
});
|
|
75753
75757
|
}
|
|
75754
75758
|
function digest16(value) {
|
|
75755
|
-
return
|
|
75759
|
+
return createHash86("sha256").update(canonicalJson14(value)).digest("hex");
|
|
75756
75760
|
}
|
|
75757
75761
|
function amountFor2(usage) {
|
|
75758
75762
|
return usage.reduce((sum2, item) => sum2 + item.units * item.rateMinorPerUnit, 0);
|
|
@@ -75987,7 +75991,7 @@ function createPostgresAssistantBillingStore(options = {}) {
|
|
|
75987
75991
|
import {
|
|
75988
75992
|
createCipheriv as createCipheriv3,
|
|
75989
75993
|
createDecipheriv as createDecipheriv3,
|
|
75990
|
-
createHash as
|
|
75994
|
+
createHash as createHash87,
|
|
75991
75995
|
createHmac as createHmac14,
|
|
75992
75996
|
randomBytes as randomBytes10
|
|
75993
75997
|
} from "crypto";
|
|
@@ -76045,7 +76049,7 @@ function canonicalContext(input) {
|
|
|
76045
76049
|
});
|
|
76046
76050
|
}
|
|
76047
76051
|
function contextDigest(context) {
|
|
76048
|
-
return
|
|
76052
|
+
return createHash87("sha256").update(context, "utf8").digest("hex");
|
|
76049
76053
|
}
|
|
76050
76054
|
function decodeBase64Url(value, expectedBytes) {
|
|
76051
76055
|
if (!value || !BASE64URL.test(value)) throw new PersonalAssistantProtectedDataCryptoError("protected_data_envelope_invalid");
|
|
@@ -76234,8 +76238,8 @@ async function resolvePersonalAssistantProtectedDataCryptoFactory(options) {
|
|
|
76234
76238
|
}
|
|
76235
76239
|
|
|
76236
76240
|
// src/api/twilio-first-text-context-postgres.ts
|
|
76237
|
-
import { createHash as
|
|
76238
|
-
var digest17 = (value) =>
|
|
76241
|
+
import { createHash as createHash88 } from "crypto";
|
|
76242
|
+
var digest17 = (value) => createHash88("sha256").update(value).digest("hex");
|
|
76239
76243
|
function createPostgresTwilioFirstTextDiagnosticContextResolver(options = {}) {
|
|
76240
76244
|
const queryable = options.queryable ?? getAssistantPool();
|
|
76241
76245
|
return async (input) => {
|
|
@@ -76280,10 +76284,10 @@ function createPostgresTwilioFirstTextDiagnosticContextResolver(options = {}) {
|
|
|
76280
76284
|
}
|
|
76281
76285
|
|
|
76282
76286
|
// src/api/twilio-first-text-diagnostic-postgres.ts
|
|
76283
|
-
import { createHash as
|
|
76287
|
+
import { createHash as createHash90, randomBytes as randomBytes12, randomUUID as randomUUID61 } from "crypto";
|
|
76284
76288
|
|
|
76285
76289
|
// src/api/twilio-first-text-diagnostic.ts
|
|
76286
|
-
import { createHash as
|
|
76290
|
+
import { createHash as createHash89, randomBytes as randomBytes11 } from "crypto";
|
|
76287
76291
|
var TWILIO_FIRST_TEXT_BODY = ASSISTANT_CONSENT_CONTENT_V1.diagnosticMessage;
|
|
76288
76292
|
var TwilioFirstTextDiagnosticError = class extends Error {
|
|
76289
76293
|
constructor(code) {
|
|
@@ -76294,10 +76298,10 @@ var TwilioFirstTextDiagnosticError = class extends Error {
|
|
|
76294
76298
|
code;
|
|
76295
76299
|
};
|
|
76296
76300
|
function digest18(value) {
|
|
76297
|
-
return
|
|
76301
|
+
return createHash89("sha256").update(JSON.stringify(value)).digest("hex");
|
|
76298
76302
|
}
|
|
76299
76303
|
function stableRef2(prefix, identity) {
|
|
76300
|
-
return `${prefix}_${
|
|
76304
|
+
return `${prefix}_${createHash89("sha256").update(identity).digest("hex").slice(0, 32)}`;
|
|
76301
76305
|
}
|
|
76302
76306
|
function providerSid(result3) {
|
|
76303
76307
|
const value = result3.receipt.providerMessageSid;
|
|
@@ -76409,14 +76413,14 @@ function createTwilioFirstTextDiagnosticService(dependencies) {
|
|
|
76409
76413
|
var COLUMNS = `owner_user_id::text,public_id,idempotency_key,request_digest,policy_version,recipient_ref,sender_ref,
|
|
76410
76414
|
state,mode,stages,provider_message_sid,inbound_event_ref,routing_receipt_ref,acknowledgement_receipt_ref,
|
|
76411
76415
|
retry_eligible,failure_code,execution_token_digest,created_at,updated_at`;
|
|
76412
|
-
var digest19 = (value) =>
|
|
76416
|
+
var digest19 = (value) => createHash90("sha256").update(value).digest("hex");
|
|
76413
76417
|
var iso5 = (value) => new Date(value).toISOString();
|
|
76414
76418
|
function receipt3(row) {
|
|
76415
76419
|
return Object.freeze({
|
|
76416
76420
|
diagnosticRef: row.public_id,
|
|
76417
76421
|
ownerUserId: row.owner_user_id,
|
|
76418
76422
|
idempotencyKey: row.idempotency_key,
|
|
76419
|
-
executionRef: `execution_${
|
|
76423
|
+
executionRef: `execution_${createHash90("sha256").update(row.public_id).digest("hex").slice(0, 32)}`,
|
|
76420
76424
|
requestDigest: row.request_digest,
|
|
76421
76425
|
policyVersion: row.policy_version,
|
|
76422
76426
|
recipientRef: row.recipient_ref,
|
|
@@ -76584,10 +76588,10 @@ function createTwilioInboundQuarantineClaimAuthorizer(options) {
|
|
|
76584
76588
|
}
|
|
76585
76589
|
|
|
76586
76590
|
// src/api/twilio-inbound-claim-control-plane-postgres.ts
|
|
76587
|
-
import { createHash as
|
|
76588
|
-
var stableRef3 = (prefix, value) => `${prefix}_${
|
|
76591
|
+
import { createHash as createHash91, randomUUID as randomUUID62 } from "crypto";
|
|
76592
|
+
var stableRef3 = (prefix, value) => `${prefix}_${createHash91("sha256").update(value).digest("hex").slice(0, 32)}`;
|
|
76589
76593
|
var stableUuid = (value) => {
|
|
76590
|
-
const hex =
|
|
76594
|
+
const hex = createHash91("sha256").update(value).digest("hex").slice(0, 32).split("");
|
|
76591
76595
|
hex[12] = "5";
|
|
76592
76596
|
hex[16] = (Number.parseInt(hex[16], 16) & 3 | 8).toString(16);
|
|
76593
76597
|
return `${hex.slice(0, 8).join("")}-${hex.slice(8, 12).join("")}-${hex.slice(12, 16).join("")}-${hex.slice(16, 20).join("")}-${hex.slice(20).join("")}`;
|
|
@@ -76669,12 +76673,12 @@ function createPostgresTwilioInboundClaimControlPlane(options) {
|
|
|
76669
76673
|
}
|
|
76670
76674
|
|
|
76671
76675
|
// src/api/twilio-inbound-envelope-postgres.ts
|
|
76672
|
-
import { createHash as
|
|
76676
|
+
import { createHash as createHash93 } from "crypto";
|
|
76673
76677
|
|
|
76674
76678
|
// src/api/twilio-inbound-admission-postgres.ts
|
|
76675
|
-
import { createHash as
|
|
76679
|
+
import { createHash as createHash92, randomBytes as randomBytes13, randomUUID as randomUUID63 } from "crypto";
|
|
76676
76680
|
function tokenHash4(value) {
|
|
76677
|
-
return
|
|
76681
|
+
return createHash92("sha256").update(value).digest("hex");
|
|
76678
76682
|
}
|
|
76679
76683
|
function rowToRecord(row) {
|
|
76680
76684
|
return Object.freeze({
|
|
@@ -76843,7 +76847,7 @@ function createPostgresTwilioInboundAdmissionStore(options = {}) {
|
|
|
76843
76847
|
|
|
76844
76848
|
// src/api/twilio-inbound-envelope-postgres.ts
|
|
76845
76849
|
function stableRef4(prefix, identity) {
|
|
76846
|
-
return `${prefix}_${
|
|
76850
|
+
return `${prefix}_${createHash93("sha256").update(identity).digest("hex").slice(0, 32)}`;
|
|
76847
76851
|
}
|
|
76848
76852
|
function parseStoredEnvelope(value) {
|
|
76849
76853
|
let parsed;
|
|
@@ -77205,11 +77209,11 @@ function createPostgresTwilioInboundQuarantineStore(options = {}) {
|
|
|
77205
77209
|
}
|
|
77206
77210
|
|
|
77207
77211
|
// src/api/twilio-inbound-quarantine.ts
|
|
77208
|
-
import { createHash as
|
|
77212
|
+
import { createHash as createHash94, createHmac as createHmac15, timingSafeEqual as timingSafeEqual10 } from "crypto";
|
|
77209
77213
|
var DIGEST7 = /^[a-f0-9]{64}$/u;
|
|
77210
77214
|
var OPAQUE2 = /^[A-Za-z][A-Za-z0-9_.:-]{2,199}$/u;
|
|
77211
77215
|
function digest20(value) {
|
|
77212
|
-
return
|
|
77216
|
+
return createHash94("sha256").update(value).digest("hex");
|
|
77213
77217
|
}
|
|
77214
77218
|
function stableRef5(prefix, identity) {
|
|
77215
77219
|
return `${prefix}_${digest20(identity).slice(0, 32)}`;
|
|
@@ -77524,10 +77528,10 @@ async function createPersonalAssistantTwilioTransportProduction(options) {
|
|
|
77524
77528
|
}
|
|
77525
77529
|
|
|
77526
77530
|
// src/api/twilio-number-production.ts
|
|
77527
|
-
import { createHash as
|
|
77531
|
+
import { createHash as createHash96, randomUUID as randomUUID66 } from "crypto";
|
|
77528
77532
|
|
|
77529
77533
|
// src/api/twilio-number-repository.ts
|
|
77530
|
-
import { createHash as
|
|
77534
|
+
import { createHash as createHash95, randomUUID as randomUUID65 } from "crypto";
|
|
77531
77535
|
var PUBLIC_REF3 = /^[a-z][a-z0-9_]*_[A-Za-z0-9_-]{3,128}$/;
|
|
77532
77536
|
var DIGEST8 = /^[a-f0-9]{64}$/;
|
|
77533
77537
|
var ACCOUNT_SID4 = /^AC[0-9a-f]{32}$/i;
|
|
@@ -77616,7 +77620,7 @@ function priceValue(value) {
|
|
|
77616
77620
|
}), blocker: null });
|
|
77617
77621
|
}
|
|
77618
77622
|
function digest21(value) {
|
|
77619
|
-
return
|
|
77623
|
+
return createHash95("sha256").update(JSON.stringify(value, (_key, entry) => {
|
|
77620
77624
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
|
|
77621
77625
|
return Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)));
|
|
77622
77626
|
})).digest("hex");
|
|
@@ -78403,13 +78407,13 @@ function createPostgresTwilioNumberProductionAdapters(options) {
|
|
|
78403
78407
|
}
|
|
78404
78408
|
function twilioProviderAccountDigest(providerAccountRef) {
|
|
78405
78409
|
if (!ACCOUNT_SID4.test(providerAccountRef)) throw new TwilioNumberRepositoryError("invalid_provider_account", "Twilio account assignment is invalid.", 400);
|
|
78406
|
-
return
|
|
78410
|
+
return createHash95("sha256").update(providerAccountRef).digest("hex");
|
|
78407
78411
|
}
|
|
78408
78412
|
|
|
78409
78413
|
// src/api/twilio-number-production.ts
|
|
78410
78414
|
var DIGEST9 = /^[a-f0-9]{64}$/u;
|
|
78411
78415
|
function hash3(value) {
|
|
78412
|
-
return
|
|
78416
|
+
return createHash96("sha256").update(typeof value === "string" ? value : JSON.stringify(value, (_key, entry) => {
|
|
78413
78417
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) return entry;
|
|
78414
78418
|
return Object.fromEntries(Object.entries(entry).sort(([a], [b]) => a.localeCompare(b)));
|
|
78415
78419
|
})).digest("hex");
|
|
@@ -78822,7 +78826,7 @@ function createTwilioNumberProductionInterfaces(options) {
|
|
|
78822
78826
|
}
|
|
78823
78827
|
|
|
78824
78828
|
// src/api/twilio-number-service.ts
|
|
78825
|
-
import { createHash as
|
|
78829
|
+
import { createHash as createHash97, randomUUID as randomUUID67 } from "crypto";
|
|
78826
78830
|
var DEFAULT_RESERVATION_TTL_MS = 5 * 60 * 1e3;
|
|
78827
78831
|
var MIN_RESERVATION_TTL_MS = 60 * 1e3;
|
|
78828
78832
|
var MAX_RESERVATION_TTL_MS = 10 * 60 * 1e3;
|
|
@@ -78958,7 +78962,7 @@ function canonicalJson15(value) {
|
|
|
78958
78962
|
});
|
|
78959
78963
|
}
|
|
78960
78964
|
function digest22(value) {
|
|
78961
|
-
return
|
|
78965
|
+
return createHash97("sha256").update(canonicalJson15(value)).digest("hex");
|
|
78962
78966
|
}
|
|
78963
78967
|
function requireIdempotencyKey(value) {
|
|
78964
78968
|
if (typeof value !== "string" || !/^[A-Za-z0-9][A-Za-z0-9:._/-]{7,239}$/.test(value)) {
|
|
@@ -80387,7 +80391,7 @@ function presence(env) {
|
|
|
80387
80391
|
}
|
|
80388
80392
|
function fingerprintDigest(env) {
|
|
80389
80393
|
const value = env.PA_NEON_BINDING_FINGERPRINT?.trim();
|
|
80390
|
-
return value ?
|
|
80394
|
+
return value ? createHash98("sha256").update("personal-assistant-binding-v1\0").update(value).digest("hex") : null;
|
|
80391
80395
|
}
|
|
80392
80396
|
function missingHostedBindings(env) {
|
|
80393
80397
|
return Object.entries(REQUIRED_HOSTED_BINDINGS).filter(([, variable]) => !env[variable]?.trim()).map(([name]) => `binding_${name}_missing`);
|
|
@@ -80620,7 +80624,7 @@ function shouldRunSiteExtractInBackground(input) {
|
|
|
80620
80624
|
}
|
|
80621
80625
|
|
|
80622
80626
|
// src/api/page-media-artifacts.ts
|
|
80623
|
-
import { createHash as
|
|
80627
|
+
import { createHash as createHash99, randomBytes as randomBytes14 } from "crypto";
|
|
80624
80628
|
import { homedir as homedir4 } from "os";
|
|
80625
80629
|
import { basename, extname, join as join9 } from "path";
|
|
80626
80630
|
import pLimit6 from "p-limit";
|
|
@@ -80767,7 +80771,7 @@ async function fetchMedia(rawUrl, expectedType) {
|
|
|
80767
80771
|
finalUrl: checked.parsed.href,
|
|
80768
80772
|
width: dimensions?.width ?? null,
|
|
80769
80773
|
height: dimensions?.height ?? null,
|
|
80770
|
-
sha256:
|
|
80774
|
+
sha256: createHash99("sha256").update(bytes2).digest("hex")
|
|
80771
80775
|
};
|
|
80772
80776
|
}
|
|
80773
80777
|
throw new Error("media_redirect_rejected");
|
|
@@ -80973,13 +80977,13 @@ async function reconcileSiteExtractSettlements(limit = 25) {
|
|
|
80973
80977
|
}
|
|
80974
80978
|
|
|
80975
80979
|
// src/api/page-diff.ts
|
|
80976
|
-
import { createHash as
|
|
80980
|
+
import { createHash as createHash100 } from "crypto";
|
|
80977
80981
|
import { diffLines } from "diff";
|
|
80978
80982
|
var MAX_SNAPSHOT_CONTENT_CHARS = 25e4;
|
|
80979
80983
|
var MAX_DIFF_HUNKS = 200;
|
|
80980
80984
|
var MAX_DIFF_LINES_PER_RESPONSE = 2e3;
|
|
80981
80985
|
function sha256Hex(value) {
|
|
80982
|
-
return
|
|
80986
|
+
return createHash100("sha256").update(value).digest("hex");
|
|
80983
80987
|
}
|
|
80984
80988
|
function truncateForStorage(value, maxChars = MAX_SNAPSHOT_CONTENT_CHARS) {
|
|
80985
80989
|
if (value.length <= maxChars) return { value, truncated: false };
|
|
@@ -81046,7 +81050,7 @@ async function depositScrapeToVault(user, opts) {
|
|
|
81046
81050
|
const content = (opts.content ?? "").trim();
|
|
81047
81051
|
if (!content) return { deposited: false, error: "empty content" };
|
|
81048
81052
|
const clipped = content.length > MAX_DEPOSIT_CHARS ? content.slice(0, MAX_DEPOSIT_CHARS) : content;
|
|
81049
|
-
const { key: key3, error } = await
|
|
81053
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
81050
81054
|
if (!key3) return { deposited: false, error: error ?? "memory unavailable" };
|
|
81051
81055
|
const vault = opts.vault?.trim() || "Library";
|
|
81052
81056
|
const title = (opts.title?.trim() || opts.source).slice(0, 200);
|
|
@@ -81093,15 +81097,15 @@ async function persistScrapeBody(user, opts) {
|
|
|
81093
81097
|
}
|
|
81094
81098
|
|
|
81095
81099
|
// src/api/scrape-image-sink.ts
|
|
81096
|
-
import { createHash as
|
|
81100
|
+
import { createHash as createHash101 } from "crypto";
|
|
81097
81101
|
var MAX_IMAGES_PER_SCRAPE = 25;
|
|
81098
81102
|
function idempotencyKey3(userId, vault, input) {
|
|
81099
|
-
return `scrape-image-${
|
|
81103
|
+
return `scrape-image-${createHash101("sha256").update(`${userId}\0${vault}\0${input.sourceKind}\0${input.sourceUrl}\0${input.imageUrl ?? ""}\0${input.imageBase64 ?? ""}`).digest("hex")}`;
|
|
81100
81104
|
}
|
|
81101
81105
|
async function persistScrapeImagesToMemory(user, inputs, vault) {
|
|
81102
81106
|
const selected = inputs.slice(0, MAX_IMAGES_PER_SCRAPE);
|
|
81103
81107
|
if (selected.length === 0) return { requested: 0, saved: 0, skipped: 0, assets: [] };
|
|
81104
|
-
const { key: key3, error } = await
|
|
81108
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
81105
81109
|
if (!key3) {
|
|
81106
81110
|
return { requested: selected.length, saved: 0, skipped: inputs.length - selected.length, assets: [], error: error ?? "memory unavailable" };
|
|
81107
81111
|
}
|
|
@@ -81568,7 +81572,7 @@ function inferredWaybackCapturedAt(content) {
|
|
|
81568
81572
|
}
|
|
81569
81573
|
|
|
81570
81574
|
// src/api/connection-memory-import.ts
|
|
81571
|
-
import { createHash as
|
|
81575
|
+
import { createHash as createHash102 } from "crypto";
|
|
81572
81576
|
var CONNECTION_MEMORY_IMPORT_MAX_ARGS_BYTES = 64 * 1024;
|
|
81573
81577
|
var CONNECTION_MEMORY_IMPORT_MAX_RESULT_BYTES = 1e6;
|
|
81574
81578
|
var CONNECTION_MEMORY_IMPORT_MAX_STRING_CHARS = 256e3;
|
|
@@ -81598,7 +81602,7 @@ function canonicalJson16(value) {
|
|
|
81598
81602
|
return JSON.stringify(value);
|
|
81599
81603
|
}
|
|
81600
81604
|
function sha2562(value) {
|
|
81601
|
-
return
|
|
81605
|
+
return createHash102("sha256").update(value).digest("hex");
|
|
81602
81606
|
}
|
|
81603
81607
|
function sensitiveKey(key3) {
|
|
81604
81608
|
const normalized = key3.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
@@ -81867,7 +81871,7 @@ async function cleanupExpiredScrapeBlobs(maxAgeMs = SCRAPE_BLOB_TTL_MS) {
|
|
|
81867
81871
|
}
|
|
81868
81872
|
|
|
81869
81873
|
// src/api/site-export-reader.ts
|
|
81870
|
-
import { createHash as
|
|
81874
|
+
import { createHash as createHash103 } from "crypto";
|
|
81871
81875
|
var SiteExportFormatUnavailableError = class extends Error {
|
|
81872
81876
|
constructor(format) {
|
|
81873
81877
|
super(`The ${format} representation was not retained for this export page.`);
|
|
@@ -81877,7 +81881,7 @@ var SiteExportFormatUnavailableError = class extends Error {
|
|
|
81877
81881
|
format;
|
|
81878
81882
|
};
|
|
81879
81883
|
function sha2563(value) {
|
|
81880
|
-
return
|
|
81884
|
+
return createHash103("sha256").update(value).digest("hex");
|
|
81881
81885
|
}
|
|
81882
81886
|
function publicPageRecord(page3) {
|
|
81883
81887
|
const { bodyMarkdown: _body, contentRef: _contentRef, discoveryLinks: _discovery, ...metadata } = page3;
|
|
@@ -82442,7 +82446,7 @@ async function dbUsage(identity, plan) {
|
|
|
82442
82446
|
}
|
|
82443
82447
|
|
|
82444
82448
|
// src/api/resend-control.ts
|
|
82445
|
-
import { createHash as
|
|
82449
|
+
import { createHash as createHash104 } from "crypto";
|
|
82446
82450
|
var DEFAULT_CONNECTION_CONTROL_URL = "https://mcp-scraper-scheduler.vercel.app";
|
|
82447
82451
|
var RESEND_PROVIDER_CONFIG_KEY = "resend";
|
|
82448
82452
|
var RESEND_LOGO_URL = "https://cdn.resend.com/brand/resend-icon-black.svg";
|
|
@@ -82701,7 +82705,7 @@ async function callResendRead(identity, connectionId, tool, args) {
|
|
|
82701
82705
|
return isRecord9(data) ? data.result ?? data : data;
|
|
82702
82706
|
}
|
|
82703
82707
|
async function callResendAction(identity, connectionId, tool, input, idempotencyKey4) {
|
|
82704
|
-
const requestId = `main-resend-action:${
|
|
82708
|
+
const requestId = `main-resend-action:${createHash104("sha256").update(identity).update("\0").update(idempotencyKey4.trim()).digest("hex")}`;
|
|
82705
82709
|
const body3 = await controlRequest2("/api/internal/resend/actions/call", {
|
|
82706
82710
|
method: "POST",
|
|
82707
82711
|
headers: { "x-request-id": requestId },
|
|
@@ -83280,19 +83284,19 @@ app.post("/memory/mcp-call", auth5, async (c) => {
|
|
|
83280
83284
|
}, 503);
|
|
83281
83285
|
}
|
|
83282
83286
|
}
|
|
83283
|
-
const { key: key3, error } = await
|
|
83287
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
83284
83288
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 502);
|
|
83285
83289
|
const result3 = await memoryCall(body3.toolName, body3.args ?? {}, key3);
|
|
83286
83290
|
return c.json(result3);
|
|
83287
83291
|
});
|
|
83288
83292
|
app.get("/memory/approved-senders", auth5, async (c) => {
|
|
83289
|
-
const { key: key3, error } = await
|
|
83293
|
+
const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
|
|
83290
83294
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 502);
|
|
83291
83295
|
const r = await memoryCall("listApprovedSendersTool", {}, key3);
|
|
83292
83296
|
return c.json(r);
|
|
83293
83297
|
});
|
|
83294
83298
|
app.post("/memory/approved-senders", auth5, async (c) => {
|
|
83295
|
-
const { key: key3, error } = await
|
|
83299
|
+
const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
|
|
83296
83300
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 502);
|
|
83297
83301
|
const body3 = await c.req.json().catch(() => ({}));
|
|
83298
83302
|
const senderIdentity = body3.senderIdentity?.trim();
|
|
@@ -83301,29 +83305,34 @@ app.post("/memory/approved-senders", auth5, async (c) => {
|
|
|
83301
83305
|
return c.json(r);
|
|
83302
83306
|
});
|
|
83303
83307
|
app.delete("/memory/approved-senders/:identity", auth5, async (c) => {
|
|
83304
|
-
const { key: key3, error } = await
|
|
83308
|
+
const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
|
|
83305
83309
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 502);
|
|
83306
83310
|
const senderIdentity = c.req.param("identity");
|
|
83307
83311
|
const r = await memoryCall("removeApprovedSenderTool", { senderIdentity }, key3);
|
|
83308
83312
|
return c.json(r);
|
|
83309
83313
|
});
|
|
83310
83314
|
app.get("/memory/connect", auth5, async (c) => {
|
|
83311
|
-
const
|
|
83312
|
-
if (!key3) return c.json({ error: error ?? "memory unavailable" }, 502);
|
|
83313
|
-
const url2 = "https://memory.mcpscraper.dev/mcp";
|
|
83315
|
+
const url2 = "https://mcpscraper.dev/mcp";
|
|
83314
83316
|
const config = {
|
|
83315
83317
|
mcpServers: {
|
|
83316
|
-
|
|
83318
|
+
"MCP Scraper": {
|
|
83317
83319
|
url: url2,
|
|
83318
|
-
headers: {
|
|
83320
|
+
headers: { "x-api-key": "${MCP_SCRAPER_API_KEY}" }
|
|
83319
83321
|
}
|
|
83320
83322
|
}
|
|
83321
83323
|
};
|
|
83322
|
-
const codeCommand =
|
|
83323
|
-
return c.json({
|
|
83324
|
+
const codeCommand = 'claude mcp add --transport http mcp-scraper https://mcpscraper.dev/mcp --header "x-api-key: $MCP_SCRAPER_API_KEY"';
|
|
83325
|
+
return c.json({
|
|
83326
|
+
ok: true,
|
|
83327
|
+
url: url2,
|
|
83328
|
+
apiKeyEnvironmentVariable: "MCP_SCRAPER_API_KEY",
|
|
83329
|
+
authModes: ["x-api-key", "oauth"],
|
|
83330
|
+
config,
|
|
83331
|
+
codeCommand
|
|
83332
|
+
});
|
|
83324
83333
|
});
|
|
83325
83334
|
app.post("/memory/vault", auth5, async (c) => {
|
|
83326
|
-
const { key: key3, error } = await
|
|
83335
|
+
const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
|
|
83327
83336
|
if (!key3) return c.json({ error: error ?? "memory unavailable" }, 502);
|
|
83328
83337
|
const body3 = await c.req.json().catch(() => ({}));
|
|
83329
83338
|
const vault = body3.vault?.trim();
|
|
@@ -83372,7 +83381,7 @@ app.get("/memory/universe", auth5, async (c) => {
|
|
|
83372
83381
|
}
|
|
83373
83382
|
});
|
|
83374
83383
|
app.put("/memory/note", auth5, async (c) => {
|
|
83375
|
-
const { key: key3, error } = await
|
|
83384
|
+
const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
|
|
83376
83385
|
if (!key3) return c.json({ error: error ?? "memory unavailable" }, 502);
|
|
83377
83386
|
const body3 = await c.req.json().catch(() => ({}));
|
|
83378
83387
|
if (!body3.path) return c.json({ error: "path required" }, 400);
|
|
@@ -83380,7 +83389,7 @@ app.put("/memory/note", auth5, async (c) => {
|
|
|
83380
83389
|
return c.json(result3, result3.ok ? 200 : 502);
|
|
83381
83390
|
});
|
|
83382
83391
|
app.delete("/memory/note", auth5, async (c) => {
|
|
83383
|
-
const { key: key3, error } = await
|
|
83392
|
+
const { key: key3, error } = await getMemoryServiceToken(c.get("user"));
|
|
83384
83393
|
if (!key3) return c.json({ error: error ?? "memory unavailable" }, 502);
|
|
83385
83394
|
const vault = c.req.query("vault");
|
|
83386
83395
|
const path5 = c.req.query("path");
|
|
@@ -83661,7 +83670,7 @@ function renderResendOAuthResult(ok) {
|
|
|
83661
83670
|
app.get("/schedule-status", auth5, requirePaidSchedulingTier, async (c) => {
|
|
83662
83671
|
try {
|
|
83663
83672
|
const user = c.get("user");
|
|
83664
|
-
const { key: key3, error } = await
|
|
83673
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
83665
83674
|
if (!key3) return c.json({ error: error ?? "memory unavailable" }, 503);
|
|
83666
83675
|
const r = await memoryCall("getScheduleStatusTool", {}, key3);
|
|
83667
83676
|
return c.json({
|
|
@@ -83917,7 +83926,7 @@ app.post("/schedule-connections/actions/gmail/send-message", auth5, requireInteg
|
|
|
83917
83926
|
}
|
|
83918
83927
|
try {
|
|
83919
83928
|
const result3 = await directGmailService.sendMessage({
|
|
83920
|
-
ownerId:
|
|
83929
|
+
ownerId: createHash105("sha256").update(user.api_key).digest("hex").slice(0, 24),
|
|
83921
83930
|
providerIdentity: user.email,
|
|
83922
83931
|
connectionId,
|
|
83923
83932
|
to: body3.to,
|
|
@@ -84106,7 +84115,7 @@ app.post("/schedule-connections/actions/import-memory", auth5, requireIntegratio
|
|
|
84106
84115
|
}, {
|
|
84107
84116
|
listConnections: combinedConnections,
|
|
84108
84117
|
prepareMemory: async (_identity, requestedVault) => {
|
|
84109
|
-
const { key: key3, error } = await
|
|
84118
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84110
84119
|
if (!key3) throw new ConnectionMemoryImportError("memory_unavailable", error || "Memory is unavailable.", 503, true);
|
|
84111
84120
|
const listed = await memoryCall("listVaultsTool", {}, key3);
|
|
84112
84121
|
if (!listed.ok) throw new ConnectionMemoryImportError("memory_unavailable", listed.error || "Memory vaults are unavailable.", 503, true);
|
|
@@ -84239,7 +84248,7 @@ app.post("/schedule-connections/actions/export-search-console-table", auth5, req
|
|
|
84239
84248
|
const body3 = await c.req.json().catch(() => ({}));
|
|
84240
84249
|
try {
|
|
84241
84250
|
const request = validateSearchConsoleTableExportRequest(body3);
|
|
84242
|
-
const { key: key3, error } = await
|
|
84251
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84243
84252
|
if (!key3) return c.json({ ok: false, error: error ?? "Memory table access is unavailable." }, 503);
|
|
84244
84253
|
const result3 = await exportSearchConsoleTableData({
|
|
84245
84254
|
ownerId: sha256Hex(user.api_key).slice(0, 24),
|
|
@@ -84324,7 +84333,7 @@ app.post("/schedule-link", auth5, requirePaidSchedulingTier, async (c) => {
|
|
|
84324
84333
|
if (!credentials.ok) {
|
|
84325
84334
|
return c.json({ ok: false, code: "schedule_credentials_unavailable", error: credentials.error ?? "Scheduled Actions credentials are unavailable." }, 503);
|
|
84326
84335
|
}
|
|
84327
|
-
const { key: key3, error } = await
|
|
84336
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84328
84337
|
if (!key3) return c.json({ error: error ?? "memory unavailable" }, 503);
|
|
84329
84338
|
const r = await memoryCall("getScheduleLinkTool", {}, key3);
|
|
84330
84339
|
return c.json(r);
|
|
@@ -84336,7 +84345,7 @@ app.post("/schedule-link", auth5, requirePaidSchedulingTier, async (c) => {
|
|
|
84336
84345
|
});
|
|
84337
84346
|
app.get("/schedule-actions", auth5, async (c) => {
|
|
84338
84347
|
const user = c.get("user");
|
|
84339
|
-
const { key: key3, error } = await
|
|
84348
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84340
84349
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
84341
84350
|
const r = await memoryCall("listScheduledActionsTool", {}, key3);
|
|
84342
84351
|
if (!r.ok || !Array.isArray(r.actions)) return c.json(r);
|
|
@@ -84367,7 +84376,7 @@ app.post("/schedule-actions", auth5, requirePaidSchedulingTier, async (c) => {
|
|
|
84367
84376
|
if (!credentials.ok) {
|
|
84368
84377
|
return c.json({ ok: false, code: "schedule_credentials_unavailable", error: credentials.error ?? "Scheduled Actions credentials are unavailable." }, 503);
|
|
84369
84378
|
}
|
|
84370
|
-
const { key: key3, error } = await
|
|
84379
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84371
84380
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
84372
84381
|
const body3 = await c.req.json().catch(() => ({}));
|
|
84373
84382
|
const executionMode = body3.executionMode ?? "agent";
|
|
@@ -84408,7 +84417,7 @@ app.post("/schedule-actions", auth5, requirePaidSchedulingTier, async (c) => {
|
|
|
84408
84417
|
});
|
|
84409
84418
|
app.post("/schedule-actions/propose", auth5, async (c) => {
|
|
84410
84419
|
const user = c.get("user");
|
|
84411
|
-
const { key: key3, error } = await
|
|
84420
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84412
84421
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
84413
84422
|
const body3 = await c.req.json().catch(() => ({}));
|
|
84414
84423
|
const r = await memoryCall("proposeScheduledActionTool", body3, key3);
|
|
@@ -84435,7 +84444,7 @@ app.put("/schedule-actions/:id/connections", auth5, requireIntegrationsTier, asy
|
|
|
84435
84444
|
}
|
|
84436
84445
|
try {
|
|
84437
84446
|
const scheduleActionId = c.req.param("id");
|
|
84438
|
-
const { key: key3, error } = await
|
|
84447
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84439
84448
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
84440
84449
|
const schedules = await memoryCall("listScheduledActionsTool", {}, key3);
|
|
84441
84450
|
if (!schedules.ok || !Array.isArray(schedules.actions)) return c.json(schedules, 502);
|
|
@@ -84453,7 +84462,7 @@ app.put("/schedule-actions/:id/connections", auth5, requireIntegrationsTier, asy
|
|
|
84453
84462
|
});
|
|
84454
84463
|
app.get("/schedule-actions/:id/runs", auth5, async (c) => {
|
|
84455
84464
|
const user = c.get("user");
|
|
84456
|
-
const { key: key3, error } = await
|
|
84465
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84457
84466
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
84458
84467
|
const limitRaw = Number(c.req.query("limit") ?? "50");
|
|
84459
84468
|
const limit = Number.isFinite(limitRaw) ? Math.min(Math.max(Math.round(limitRaw), 1), 100) : 50;
|
|
@@ -84462,7 +84471,7 @@ app.get("/schedule-actions/:id/runs", auth5, async (c) => {
|
|
|
84462
84471
|
});
|
|
84463
84472
|
app.put("/schedule-actions/:id", auth5, requirePaidSchedulingTier, async (c) => {
|
|
84464
84473
|
const user = c.get("user");
|
|
84465
|
-
const { key: key3, error } = await
|
|
84474
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84466
84475
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
84467
84476
|
const body3 = await c.req.json().catch(() => ({}));
|
|
84468
84477
|
const updates = {};
|
|
@@ -84477,21 +84486,21 @@ app.put("/schedule-actions/:id", auth5, requirePaidSchedulingTier, async (c) =>
|
|
|
84477
84486
|
});
|
|
84478
84487
|
app.post("/schedule-actions/:id/pause", auth5, async (c) => {
|
|
84479
84488
|
const user = c.get("user");
|
|
84480
|
-
const { key: key3, error } = await
|
|
84489
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84481
84490
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
84482
84491
|
const r = await memoryCall("pauseScheduledActionTool", { id: c.req.param("id") }, key3);
|
|
84483
84492
|
return c.json(r);
|
|
84484
84493
|
});
|
|
84485
84494
|
app.post("/schedule-actions/:id/resume", auth5, requirePaidSchedulingTier, async (c) => {
|
|
84486
84495
|
const user = c.get("user");
|
|
84487
|
-
const { key: key3, error } = await
|
|
84496
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84488
84497
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
84489
84498
|
const r = await memoryCall("resumeScheduledActionTool", { id: c.req.param("id") }, key3);
|
|
84490
84499
|
return c.json(r);
|
|
84491
84500
|
});
|
|
84492
84501
|
app.delete("/schedule-actions/:id", auth5, async (c) => {
|
|
84493
84502
|
const user = c.get("user");
|
|
84494
|
-
const { key: key3, error } = await
|
|
84503
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84495
84504
|
if (!key3) return c.json({ ok: false, error: error ?? "memory unavailable" }, 503);
|
|
84496
84505
|
const scheduleActionId = c.req.param("id");
|
|
84497
84506
|
const r = await memoryCall("deleteScheduledActionTool", { id: scheduleActionId }, key3);
|
|
@@ -84507,7 +84516,7 @@ app.delete("/schedule-actions/:id", auth5, async (c) => {
|
|
|
84507
84516
|
app.post("/schedule-link/revoke", auth5, async (c) => {
|
|
84508
84517
|
try {
|
|
84509
84518
|
const user = c.get("user");
|
|
84510
|
-
const { key: key3, error } = await
|
|
84519
|
+
const { key: key3, error } = await getMemoryServiceToken(user);
|
|
84511
84520
|
if (!key3) return c.json({ error: error ?? "memory unavailable" }, 503);
|
|
84512
84521
|
const r = await memoryCall("revokeScheduleLinkTool", {}, key3);
|
|
84513
84522
|
return c.json(r);
|
|
@@ -86234,7 +86243,7 @@ app.get("/cron/tick", async (c) => {
|
|
|
86234
86243
|
return c.json({ error: "Unauthorized" }, 401);
|
|
86235
86244
|
}
|
|
86236
86245
|
const startedAt = Date.now();
|
|
86237
|
-
const { drainQueue } = await import("./worker-
|
|
86246
|
+
const { drainQueue } = await import("./worker-LDCAULWL.js");
|
|
86238
86247
|
const budget = { maxJobs: 10, deadlineMs: startedAt + CRON_TICK_DRAIN_BUDGET_MS };
|
|
86239
86248
|
const origin = `${new URL(c.req.url).protocol}//${new URL(c.req.url).host}`;
|
|
86240
86249
|
const unfinished = [];
|
|
@@ -86358,8 +86367,8 @@ app.post("/api/internal/extract-refinalize/:id", async (c) => {
|
|
|
86358
86367
|
finishExtractJob: finishExtractJob2,
|
|
86359
86368
|
terminalExtractJobStatus: terminalExtractJobStatus2,
|
|
86360
86369
|
extractJobLimitInfo: extractJobLimitInfo2
|
|
86361
|
-
} = await import("./site-extract-repository-
|
|
86362
|
-
const { assembleExtractArtifacts } = await import("./extract-bundle-
|
|
86370
|
+
} = await import("./site-extract-repository-VYFZASPU.js");
|
|
86371
|
+
const { assembleExtractArtifacts } = await import("./extract-bundle-565SBZCR.js");
|
|
86363
86372
|
const existing = await getExtractJob2(jobId2);
|
|
86364
86373
|
if (!existing) return c.json({ error: "job not found" }, 404);
|
|
86365
86374
|
if (existing.status !== "failed") {
|
|
@@ -86386,7 +86395,7 @@ app.post("/api/internal/extract-refinalize/:id", async (c) => {
|
|
|
86386
86395
|
if (!updated) return c.json({ error: "job state changed during re-finalization" }, 409);
|
|
86387
86396
|
let settlement = "already_settled_or_refunded";
|
|
86388
86397
|
if (job.billedMc == null && job.userId != null) {
|
|
86389
|
-
const { settleExtractJob: settleExtractJob3, countSuccessfulPages: countSuccessfulPages2 } = await import("./site-extract-repository-
|
|
86398
|
+
const { settleExtractJob: settleExtractJob3, countSuccessfulPages: countSuccessfulPages2 } = await import("./site-extract-repository-VYFZASPU.js");
|
|
86390
86399
|
const heldMc = Number(job.options.heldMc ?? 0);
|
|
86391
86400
|
const successful = await countSuccessfulPages2(jobId2);
|
|
86392
86401
|
const usedMc = Math.min(successful * MC_COSTS.page_scrape, heldMc);
|