mcp-scraper 0.43.4 → 0.43.5
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/README.md +1 -1
- package/dist/bin/api-server.cjs +79 -25
- package/dist/bin/api-server.cjs.map +1 -1
- package/dist/bin/api-server.js +3 -3
- package/dist/bin/mcp-scraper-cli.cjs +1 -1
- package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
- package/dist/bin/mcp-scraper-cli.js +1 -1
- package/dist/bin/mcp-scraper-install.cjs +1 -1
- package/dist/bin/mcp-scraper-install.cjs.map +1 -1
- package/dist/bin/mcp-scraper-install.js +1 -1
- package/dist/bin/mcp-stdio-server.cjs +1 -1
- package/dist/bin/mcp-stdio-server.cjs.map +1 -1
- package/dist/bin/mcp-stdio-server.js +4 -4
- package/dist/bin/paa-harvest.cjs.map +1 -1
- package/dist/bin/paa-harvest.js +3 -3
- package/dist/{chunk-FCFQ634B.js → chunk-5X7CJEK3.js} +25 -8
- package/dist/chunk-5X7CJEK3.js.map +1 -0
- package/dist/chunk-H4RPUFRR.js +7 -0
- package/dist/chunk-H4RPUFRR.js.map +1 -0
- package/dist/{chunk-ZBQ6EXZW.js → chunk-OVD4E4AP.js} +2 -2
- package/dist/{chunk-6TAQ2MXK.js → chunk-RJMOOII7.js} +2 -2
- package/dist/{chunk-SXLQZKWC.js → chunk-RSGUS5V6.js} +3 -3
- package/dist/{chunk-ZDVQARDQ.js → chunk-T5AFM4G5.js} +2 -2
- package/dist/{chunk-QOWBJ4YY.js → chunk-WT2UHDSE.js} +2 -2
- package/dist/{chunk-GUI33Q27.js → chunk-WWIJ2NID.js} +2 -2
- package/dist/{db-C5ELI55I.js → db-4ABEYNDM.js} +4 -2
- package/dist/{extract-bundle-IOM45SFL.js → extract-bundle-ITPFWRNI.js} +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -3
- package/dist/{location-data-repository-SHEOIBTL.js → location-data-repository-HDNCU4Z4.js} +3 -3
- package/dist/{server-K76DL4S7.js → server-BTDXZA5U.js} +68 -31
- package/dist/{server-K76DL4S7.js.map → server-BTDXZA5U.js.map} +1 -1
- package/dist/{site-extract-repository-XNI4ZK2M.js → site-extract-repository-CKCJDP7N.js} +3 -3
- package/dist/{worker-OB6WSWOD.js → worker-73AYU4IK.js} +5 -5
- package/package.json +2 -1
- package/dist/chunk-FCFQ634B.js.map +0 -1
- package/dist/chunk-XQIVXIAL.js +0 -7
- package/dist/chunk-XQIVXIAL.js.map +0 -1
- /package/dist/{chunk-ZBQ6EXZW.js.map → chunk-OVD4E4AP.js.map} +0 -0
- /package/dist/{chunk-6TAQ2MXK.js.map → chunk-RJMOOII7.js.map} +0 -0
- /package/dist/{chunk-SXLQZKWC.js.map → chunk-RSGUS5V6.js.map} +0 -0
- /package/dist/{chunk-ZDVQARDQ.js.map → chunk-T5AFM4G5.js.map} +0 -0
- /package/dist/{chunk-QOWBJ4YY.js.map → chunk-WT2UHDSE.js.map} +0 -0
- /package/dist/{chunk-GUI33Q27.js.map → chunk-WWIJ2NID.js.map} +0 -0
- /package/dist/{db-C5ELI55I.js.map → db-4ABEYNDM.js.map} +0 -0
- /package/dist/{extract-bundle-IOM45SFL.js.map → extract-bundle-ITPFWRNI.js.map} +0 -0
- /package/dist/{location-data-repository-SHEOIBTL.js.map → location-data-repository-HDNCU4Z4.js.map} +0 -0
- /package/dist/{site-extract-repository-XNI4ZK2M.js.map → site-extract-repository-CKCJDP7N.js.map} +0 -0
- /package/dist/{worker-OB6WSWOD.js.map → worker-73AYU4IK.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
harvest
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RJMOOII7.js";
|
|
4
4
|
import {
|
|
5
5
|
recordVendorUsage
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-T5AFM4G5.js";
|
|
7
7
|
import "./chunk-3ZUBQQPQ.js";
|
|
8
8
|
import "./chunk-5UN33CGU.js";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-5X7CJEK3.js";
|
|
10
10
|
|
|
11
11
|
// src/video/VideoGenerator.ts
|
|
12
12
|
import { execSync as execSync2 } from "child_process";
|
|
@@ -13,9 +13,9 @@ import {
|
|
|
13
13
|
parseHostedCensusPlacesCsv,
|
|
14
14
|
parseHostedZipGroupsCsv,
|
|
15
15
|
queryHostedLocationMarkets
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-WT2UHDSE.js";
|
|
17
17
|
import "./chunk-G3P3ZDB4.js";
|
|
18
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-5X7CJEK3.js";
|
|
19
19
|
export {
|
|
20
20
|
HOSTED_CENSUS_DATASET_PREFIX,
|
|
21
21
|
HOSTED_ZIP_DATASET_KIND,
|
|
@@ -32,4 +32,4 @@ export {
|
|
|
32
32
|
parseHostedZipGroupsCsv,
|
|
33
33
|
queryHostedLocationMarkets
|
|
34
34
|
};
|
|
35
|
-
//# sourceMappingURL=location-data-repository-
|
|
35
|
+
//# sourceMappingURL=location-data-repository-HDNCU4Z4.js.map
|
|
@@ -10,14 +10,14 @@ import {
|
|
|
10
10
|
importHostedCensusPlacesCsv,
|
|
11
11
|
importHostedZipGroupsCsv,
|
|
12
12
|
listActiveHostedLocationDatasets
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WT2UHDSE.js";
|
|
14
14
|
import {
|
|
15
15
|
classifyHarvestProblem,
|
|
16
16
|
createHarvestAttemptRecorder,
|
|
17
17
|
deliverWebhook,
|
|
18
18
|
harvestProblemResponse,
|
|
19
19
|
serializeHarvestProblem
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-OVD4E4AP.js";
|
|
21
21
|
import {
|
|
22
22
|
AIModeSelectors,
|
|
23
23
|
AIOverviewSelectors,
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
resolveKernelProxyId,
|
|
45
45
|
serpArrivalUrl,
|
|
46
46
|
withRuntimeUserAgent
|
|
47
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-RJMOOII7.js";
|
|
48
48
|
import {
|
|
49
49
|
ApiErrorResponseSchema,
|
|
50
50
|
ArtifactTemplateConfigSchema,
|
|
@@ -86,7 +86,7 @@ import {
|
|
|
86
86
|
renewDirectoryArtifactDownload,
|
|
87
87
|
resolveDeploymentProfile,
|
|
88
88
|
transcribeMediaUrl
|
|
89
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-RSGUS5V6.js";
|
|
90
90
|
import {
|
|
91
91
|
auditImageUrls,
|
|
92
92
|
auditImages,
|
|
@@ -114,7 +114,7 @@ import {
|
|
|
114
114
|
recordKernelSession,
|
|
115
115
|
recordVendorUsage,
|
|
116
116
|
runWithCostContext
|
|
117
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-T5AFM4G5.js";
|
|
118
118
|
import {
|
|
119
119
|
listWorkflowDefinitions,
|
|
120
120
|
runWorkflow,
|
|
@@ -142,7 +142,7 @@ import {
|
|
|
142
142
|
} from "./chunk-3ZUBQQPQ.js";
|
|
143
143
|
import {
|
|
144
144
|
PACKAGE_VERSION
|
|
145
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-H4RPUFRR.js";
|
|
146
146
|
import {
|
|
147
147
|
abandonExtractSettlement,
|
|
148
148
|
countSuccessfulPages,
|
|
@@ -165,7 +165,7 @@ import {
|
|
|
165
165
|
setExtractJobTotal,
|
|
166
166
|
settleExtractJob,
|
|
167
167
|
terminalExtractJobStatus
|
|
168
|
-
} from "./chunk-
|
|
168
|
+
} from "./chunk-WWIJ2NID.js";
|
|
169
169
|
import {
|
|
170
170
|
BROWSER_OPEN_MIN_BALANCE_MC,
|
|
171
171
|
CONCURRENCY_PRICE_ID,
|
|
@@ -321,7 +321,7 @@ import {
|
|
|
321
321
|
startHarvestAttempt,
|
|
322
322
|
upsertPageSnapshot,
|
|
323
323
|
verifyPassword
|
|
324
|
-
} from "./chunk-
|
|
324
|
+
} from "./chunk-5X7CJEK3.js";
|
|
325
325
|
|
|
326
326
|
// src/blog/registry.ts
|
|
327
327
|
var posts = [
|
|
@@ -8666,7 +8666,7 @@ var siteExtractFn = inngest.createFunction(
|
|
|
8666
8666
|
});
|
|
8667
8667
|
}) : null;
|
|
8668
8668
|
const finalized = await step.run("finalize", async () => {
|
|
8669
|
-
const { assembleExtractArtifacts } = await import("./extract-bundle-
|
|
8669
|
+
const { assembleExtractArtifacts } = await import("./extract-bundle-ITPFWRNI.js");
|
|
8670
8670
|
const current = await getExtractJob(jobId2);
|
|
8671
8671
|
if (!current) throw new Error("extract job disappeared before finalization");
|
|
8672
8672
|
const stored = await assembleExtractArtifacts(current, { branding, imageAudit });
|
|
@@ -9608,7 +9608,7 @@ async function resolveUsZipsPath(requestedPath) {
|
|
|
9608
9608
|
async function loadZipGroups(stateAbbr, requestedPath, warnings, sourceMode) {
|
|
9609
9609
|
const mode = resolvedLocationDataMode({ zipSource: sourceMode });
|
|
9610
9610
|
if (mode === "hosted") {
|
|
9611
|
-
const { getHostedZipGroups } = await import("./location-data-repository-
|
|
9611
|
+
const { getHostedZipGroups } = await import("./location-data-repository-HDNCU4Z4.js");
|
|
9612
9612
|
const hosted = await getHostedZipGroups(stateAbbr);
|
|
9613
9613
|
if (!hosted.dataset) {
|
|
9614
9614
|
throw new DirectoryLocationError(
|
|
@@ -9671,7 +9671,7 @@ async function resolveDirectoryMarkets(options, config = {}) {
|
|
|
9671
9671
|
const sourceUrl = censusStateUrl(state.fips);
|
|
9672
9672
|
const warnings = [];
|
|
9673
9673
|
if (resolvedLocationDataMode(config) === "hosted") {
|
|
9674
|
-
const { queryHostedLocationMarkets } = await import("./location-data-repository-
|
|
9674
|
+
const { queryHostedLocationMarkets } = await import("./location-data-repository-HDNCU4Z4.js");
|
|
9675
9675
|
const hosted = await queryHostedLocationMarkets({
|
|
9676
9676
|
state: state.abbr,
|
|
9677
9677
|
minPopulation: options.minPopulation,
|
|
@@ -25549,6 +25549,31 @@ var ACCESS_TTL_SECONDS = 3600;
|
|
|
25549
25549
|
var REFRESH_TTL_SECONDS = 60 * 60 * 24 * 30;
|
|
25550
25550
|
var CODE_TTL_SECONDS = 60;
|
|
25551
25551
|
var ROTATION_GRACE_SECONDS = 120;
|
|
25552
|
+
var OAUTH_DATABASE_TIMEOUT_MS = 5e3;
|
|
25553
|
+
var OAuthDatabaseUnavailableError = class extends Error {
|
|
25554
|
+
stage;
|
|
25555
|
+
constructor(stage) {
|
|
25556
|
+
super("The authorization service database is temporarily unavailable.");
|
|
25557
|
+
this.name = "OAuthDatabaseUnavailableError";
|
|
25558
|
+
this.stage = stage;
|
|
25559
|
+
}
|
|
25560
|
+
};
|
|
25561
|
+
async function withOAuthDatabaseDeadline(stage, operation, timeoutMs = OAUTH_DATABASE_TIMEOUT_MS) {
|
|
25562
|
+
const startedAt = Date.now();
|
|
25563
|
+
let timeout;
|
|
25564
|
+
try {
|
|
25565
|
+
const value = await Promise.race([
|
|
25566
|
+
operation,
|
|
25567
|
+
new Promise((_, reject) => {
|
|
25568
|
+
timeout = setTimeout(() => reject(new OAuthDatabaseUnavailableError(stage)), timeoutMs);
|
|
25569
|
+
})
|
|
25570
|
+
]);
|
|
25571
|
+
console.log("[oauth-db] stage=%s status=ok duration_ms=%d", stage, Date.now() - startedAt);
|
|
25572
|
+
return value;
|
|
25573
|
+
} finally {
|
|
25574
|
+
if (timeout) clearTimeout(timeout);
|
|
25575
|
+
}
|
|
25576
|
+
}
|
|
25552
25577
|
var secureCookies = process.env.NODE_ENV === "production" || process.env.VERCEL === "1";
|
|
25553
25578
|
var sessionCookieOptions = {
|
|
25554
25579
|
httpOnly: true,
|
|
@@ -25611,7 +25636,7 @@ async function sessionUser(token4) {
|
|
|
25611
25636
|
if (!token4) return null;
|
|
25612
25637
|
const userId = verifySession(token4);
|
|
25613
25638
|
if (!userId) return null;
|
|
25614
|
-
const user = await getUserById(userId);
|
|
25639
|
+
const user = await withOAuthDatabaseDeadline("session-user", getUserById(userId));
|
|
25615
25640
|
return user ?? null;
|
|
25616
25641
|
}
|
|
25617
25642
|
function escapeHtml(value) {
|
|
@@ -25701,6 +25726,18 @@ function redirectWithError(redirectUri, state, error) {
|
|
|
25701
25726
|
return new Response(null, { status: 302, headers: { Location: u.toString() } });
|
|
25702
25727
|
}
|
|
25703
25728
|
var oauthApp = new Hono23();
|
|
25729
|
+
oauthApp.onError((error, c) => {
|
|
25730
|
+
if (error instanceof OAuthDatabaseUnavailableError) {
|
|
25731
|
+
console.error("[oauth-db] stage=%s status=timeout timeout_ms=%d", error.stage, OAUTH_DATABASE_TIMEOUT_MS);
|
|
25732
|
+
c.header("Retry-After", "5");
|
|
25733
|
+
return c.json({
|
|
25734
|
+
error: "temporarily_unavailable",
|
|
25735
|
+
error_description: "Authorization is temporarily unavailable. Please retry shortly."
|
|
25736
|
+
}, 503);
|
|
25737
|
+
}
|
|
25738
|
+
console.error("[oauth] unhandled error:", error);
|
|
25739
|
+
return c.json({ error: "server_error", error_description: "Authorization could not be completed." }, 500);
|
|
25740
|
+
});
|
|
25704
25741
|
oauthApp.use("*", async (c, next) => {
|
|
25705
25742
|
c.header("Access-Control-Allow-Origin", "*");
|
|
25706
25743
|
c.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
@@ -25783,7 +25820,7 @@ oauthApp.post("/oauth/register", async (c) => {
|
|
|
25783
25820
|
}
|
|
25784
25821
|
const clientName = typeof body.client_name === "string" ? body.client_name : null;
|
|
25785
25822
|
const clientId = `client_${randomBytes2(16).toString("hex")}`;
|
|
25786
|
-
await registerClient(clientId, redirectUris, clientName);
|
|
25823
|
+
await withOAuthDatabaseDeadline("register-client", registerClient(clientId, redirectUris, clientName));
|
|
25787
25824
|
console.log("[oauth-dcr] register OK client_id=%s redirect_uris=%s", clientId, JSON.stringify(redirectUris));
|
|
25788
25825
|
return c.json({
|
|
25789
25826
|
client_id: clientId,
|
|
@@ -25810,7 +25847,7 @@ function parseAuthParams(get) {
|
|
|
25810
25847
|
async function validateAuthRequest(p) {
|
|
25811
25848
|
if (p.response_type !== "code") return { ok: false, status: 400, message: "response_type must be code" };
|
|
25812
25849
|
if (!p.client_id) return { ok: false, status: 400, message: "client_id is required" };
|
|
25813
|
-
const client2 = await getClient(p.client_id);
|
|
25850
|
+
const client2 = await withOAuthDatabaseDeadline("get-client", getClient(p.client_id));
|
|
25814
25851
|
if (!client2) return { ok: false, status: 400, message: "unknown client_id" };
|
|
25815
25852
|
if (!p.redirect_uri || !client2.redirect_uris.includes(p.redirect_uri)) return { ok: false, status: 400, message: "redirect_uri does not match the registered set" };
|
|
25816
25853
|
if (!isAllowedRedirect(p.redirect_uri)) return { ok: false, status: 400, message: "redirect_uri host not allowed" };
|
|
@@ -25843,7 +25880,7 @@ oauthApp.post("/oauth/authorize", async (c) => {
|
|
|
25843
25880
|
if (action === "login") {
|
|
25844
25881
|
const email = (get("email") ?? "").trim().toLowerCase();
|
|
25845
25882
|
const password = get("password") ?? "";
|
|
25846
|
-
const user2 = email ? await getUserByEmail(email) : void 0;
|
|
25883
|
+
const user2 = email ? await withOAuthDatabaseDeadline("login-user", getUserByEmail(email)) : void 0;
|
|
25847
25884
|
const okPw = !!(user2 && user2.password_hash && verifyPassword(password, user2.password_hash));
|
|
25848
25885
|
console.log("[oauth-dcr] LOGIN email=%s found=%s hasHash=%s pwLen=%d ok=%s", email, !!user2, !!(user2 && user2.password_hash), password.length, okPw);
|
|
25849
25886
|
if (!okPw) {
|
|
@@ -25859,7 +25896,7 @@ oauthApp.post("/oauth/authorize", async (c) => {
|
|
|
25859
25896
|
const scope = negotiateScope(p.scope, user, p.resource);
|
|
25860
25897
|
const code = `code_${randomBytes2(32).toString("base64url")}`;
|
|
25861
25898
|
const expiresAt = new Date(Date.now() + CODE_TTL_SECONDS * 1e3).toISOString();
|
|
25862
|
-
await putCode({
|
|
25899
|
+
await withOAuthDatabaseDeadline("put-authorization-code", putCode({
|
|
25863
25900
|
code,
|
|
25864
25901
|
client_id: p.client_id,
|
|
25865
25902
|
redirect_uri: p.redirect_uri,
|
|
@@ -25868,7 +25905,7 @@ oauthApp.post("/oauth/authorize", async (c) => {
|
|
|
25868
25905
|
scope,
|
|
25869
25906
|
resource: p.resource || RESOURCE(),
|
|
25870
25907
|
expires_at: expiresAt
|
|
25871
|
-
});
|
|
25908
|
+
}));
|
|
25872
25909
|
const u = new URL(p.redirect_uri);
|
|
25873
25910
|
u.searchParams.set("code", code);
|
|
25874
25911
|
if (p.state) u.searchParams.set("state", p.state);
|
|
@@ -25898,18 +25935,18 @@ oauthApp.post("/oauth/token", async (c) => {
|
|
|
25898
25935
|
const clientId = get("client_id") ?? "";
|
|
25899
25936
|
const redirectUri = get("redirect_uri") ?? "";
|
|
25900
25937
|
const verifier = get("code_verifier") ?? "";
|
|
25901
|
-
const record = await consumeCode(code);
|
|
25938
|
+
const record = await withOAuthDatabaseDeadline("consume-authorization-code", consumeCode(code));
|
|
25902
25939
|
if (!record) return tokenErrorResponse(c, "invalid_grant", "Authorization code is invalid or already used", 400);
|
|
25903
25940
|
if (new Date(record.expires_at).getTime() < Date.now()) return tokenErrorResponse(c, "invalid_grant", "Authorization code has expired", 400);
|
|
25904
25941
|
if (record.client_id !== clientId) return tokenErrorResponse(c, "invalid_grant", "client_id mismatch", 400);
|
|
25905
25942
|
if (record.redirect_uri !== redirectUri) return tokenErrorResponse(c, "invalid_grant", "redirect_uri mismatch", 400);
|
|
25906
25943
|
if (!pkceMatches(verifier, record.code_challenge)) return tokenErrorResponse(c, "invalid_grant", "PKCE verification failed", 400);
|
|
25907
|
-
const user = await getUserByEmail(record.identity);
|
|
25944
|
+
const user = await withOAuthDatabaseDeadline("token-user", getUserByEmail(record.identity));
|
|
25908
25945
|
const plan = user ? resolvePlan(user) : "free";
|
|
25909
25946
|
const audience = record.resource ?? RESOURCE();
|
|
25910
25947
|
const accessToken = await mintAccessToken(record.identity, record.scope, plan, audience);
|
|
25911
25948
|
const refreshToken = `rt_${randomBytes2(40).toString("base64url")}`;
|
|
25912
|
-
await putRefresh({
|
|
25949
|
+
await withOAuthDatabaseDeadline("put-refresh-token", putRefresh({
|
|
25913
25950
|
refresh_token: refreshToken,
|
|
25914
25951
|
client_id: clientId,
|
|
25915
25952
|
identity: record.identity,
|
|
@@ -25917,15 +25954,15 @@ oauthApp.post("/oauth/token", async (c) => {
|
|
|
25917
25954
|
resource: audience,
|
|
25918
25955
|
expires_at: new Date(Date.now() + REFRESH_TTL_SECONDS * 1e3).toISOString(),
|
|
25919
25956
|
revoked: 0
|
|
25920
|
-
});
|
|
25957
|
+
}));
|
|
25921
25958
|
return c.json({ access_token: accessToken, token_type: "Bearer", expires_in: ACCESS_TTL_SECONDS, refresh_token: refreshToken, scope: record.scope });
|
|
25922
25959
|
}
|
|
25923
25960
|
if (grantType === "refresh_token") {
|
|
25924
25961
|
const refreshToken = get("refresh_token") ?? "";
|
|
25925
25962
|
const clientId = get("client_id") ?? "";
|
|
25926
|
-
const record = await getRefresh(refreshToken);
|
|
25963
|
+
const record = await withOAuthDatabaseDeadline("get-refresh-token", getRefresh(refreshToken));
|
|
25927
25964
|
if (record && record.revoked && record.replaced_by && record.rotated_at && Date.now() - new Date(record.rotated_at).getTime() < ROTATION_GRACE_SECONDS * 1e3 && (!clientId || record.client_id === clientId)) {
|
|
25928
|
-
const graceUser = await getUserByEmail(record.identity);
|
|
25965
|
+
const graceUser = await withOAuthDatabaseDeadline("refresh-grace-user", getUserByEmail(record.identity));
|
|
25929
25966
|
const gracePlan = graceUser ? resolvePlan(graceUser) : "free";
|
|
25930
25967
|
const graceAudience = record.resource ?? RESOURCE();
|
|
25931
25968
|
const graceAccess = await mintAccessToken(record.identity, record.scope, gracePlan, graceAudience);
|
|
@@ -25934,12 +25971,12 @@ oauthApp.post("/oauth/token", async (c) => {
|
|
|
25934
25971
|
if (!record || record.revoked) return tokenErrorResponse(c, "invalid_grant", "Refresh token is invalid or revoked", 400);
|
|
25935
25972
|
if (new Date(record.expires_at).getTime() < Date.now()) return tokenErrorResponse(c, "invalid_grant", "Refresh token has expired", 400);
|
|
25936
25973
|
if (clientId && record.client_id !== clientId) return tokenErrorResponse(c, "invalid_grant", "client_id mismatch", 400);
|
|
25937
|
-
const user = await getUserByEmail(record.identity);
|
|
25974
|
+
const user = await withOAuthDatabaseDeadline("refresh-user", getUserByEmail(record.identity));
|
|
25938
25975
|
const plan = user ? resolvePlan(user) : "free";
|
|
25939
25976
|
const audience = record.resource ?? RESOURCE();
|
|
25940
25977
|
const accessToken = await mintAccessToken(record.identity, record.scope, plan, audience);
|
|
25941
25978
|
const nextRefresh = `rt_${randomBytes2(40).toString("base64url")}`;
|
|
25942
|
-
await rotateRefresh(refreshToken, {
|
|
25979
|
+
await withOAuthDatabaseDeadline("rotate-refresh-token", rotateRefresh(refreshToken, {
|
|
25943
25980
|
refresh_token: nextRefresh,
|
|
25944
25981
|
client_id: record.client_id,
|
|
25945
25982
|
identity: record.identity,
|
|
@@ -25947,7 +25984,7 @@ oauthApp.post("/oauth/token", async (c) => {
|
|
|
25947
25984
|
resource: audience,
|
|
25948
25985
|
expires_at: new Date(Date.now() + REFRESH_TTL_SECONDS * 1e3).toISOString(),
|
|
25949
25986
|
revoked: 0
|
|
25950
|
-
});
|
|
25987
|
+
}));
|
|
25951
25988
|
return c.json({ access_token: accessToken, token_type: "Bearer", expires_in: ACCESS_TTL_SECONDS, refresh_token: nextRefresh, scope: record.scope });
|
|
25952
25989
|
}
|
|
25953
25990
|
return tokenErrorResponse(c, "unsupported_grant_type", "grant_type must be authorization_code or refresh_token", 400);
|
|
@@ -37172,7 +37209,7 @@ app.get("/cron/tick", async (c) => {
|
|
|
37172
37209
|
if (!process.env.CRON_SECRET || secret2 !== `Bearer ${process.env.CRON_SECRET}`) {
|
|
37173
37210
|
return c.json({ error: "Unauthorized" }, 401);
|
|
37174
37211
|
}
|
|
37175
|
-
const { drainQueue } = await import("./worker-
|
|
37212
|
+
const { drainQueue } = await import("./worker-73AYU4IK.js");
|
|
37176
37213
|
const budget = { maxJobs: 10, deadlineMs: Date.now() + 28e4 };
|
|
37177
37214
|
const workflowDispatchResult = await dispatchDueWorkflowSchedules(`${new URL(c.req.url).protocol}//${new URL(c.req.url).host}`);
|
|
37178
37215
|
const [results, sweepResult, reapResult, expiredResult, blobCleanup, connectedDataArtifactCleanup, connectedAccountBilling, directoryWorkflowDispatch, directoryWorkflowReconciliation, directoryArtifactCleanup, siteExtractArtifactCleanup, siteExtractRedispatch, siteExtractReconciliation, paaHarvestRedispatch, paaHarvestReconciliation] = await Promise.all([
|
|
@@ -37225,8 +37262,8 @@ app.post("/api/internal/extract-refinalize/:id", async (c) => {
|
|
|
37225
37262
|
finishExtractJob: finishExtractJob2,
|
|
37226
37263
|
terminalExtractJobStatus: terminalExtractJobStatus2,
|
|
37227
37264
|
extractJobLimitInfo: extractJobLimitInfo2
|
|
37228
|
-
} = await import("./site-extract-repository-
|
|
37229
|
-
const { assembleExtractArtifacts } = await import("./extract-bundle-
|
|
37265
|
+
} = await import("./site-extract-repository-CKCJDP7N.js");
|
|
37266
|
+
const { assembleExtractArtifacts } = await import("./extract-bundle-ITPFWRNI.js");
|
|
37230
37267
|
const existing = await getExtractJob2(jobId2);
|
|
37231
37268
|
if (!existing) return c.json({ error: "job not found" }, 404);
|
|
37232
37269
|
if (existing.status !== "failed") {
|
|
@@ -37253,7 +37290,7 @@ app.post("/api/internal/extract-refinalize/:id", async (c) => {
|
|
|
37253
37290
|
if (!updated) return c.json({ error: "job state changed during re-finalization" }, 409);
|
|
37254
37291
|
let settlement = "already_settled_or_refunded";
|
|
37255
37292
|
if (job.billedMc == null && job.userId != null) {
|
|
37256
|
-
const { settleExtractJob: settleExtractJob3, countSuccessfulPages: countSuccessfulPages2 } = await import("./site-extract-repository-
|
|
37293
|
+
const { settleExtractJob: settleExtractJob3, countSuccessfulPages: countSuccessfulPages2 } = await import("./site-extract-repository-CKCJDP7N.js");
|
|
37257
37294
|
const heldMc = Number(job.options.heldMc ?? 0);
|
|
37258
37295
|
const successful = await countSuccessfulPages2(jobId2);
|
|
37259
37296
|
const usedMc = Math.min(successful * MC_COSTS.page_scrape, heldMc);
|
|
@@ -37432,4 +37469,4 @@ app.get("/blog/:slug/", (c) => {
|
|
|
37432
37469
|
export {
|
|
37433
37470
|
app
|
|
37434
37471
|
};
|
|
37435
|
-
//# sourceMappingURL=server-
|
|
37472
|
+
//# sourceMappingURL=server-BTDXZA5U.js.map
|