@warlock.js/devtools 5.58.0 → 5.59.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 +15 -0
- package/cjs/{ai-source-DTpxumMA.cjs → ai-source-BdvMfyKw.cjs} +84 -17
- package/cjs/ai-source-BdvMfyKw.cjs.map +1 -0
- package/cjs/app-versions-DfpPZOI2.cjs +253 -0
- package/cjs/app-versions-DfpPZOI2.cjs.map +1 -0
- package/cjs/{auth-DV2GA1A9.cjs → auth-B3wyjJnQ.cjs} +20 -13
- package/cjs/auth-B3wyjJnQ.cjs.map +1 -0
- package/cjs/{boot-CyeHPFtk.cjs → boot-nczSvJ_F.cjs} +11 -10
- package/cjs/boot-nczSvJ_F.cjs.map +1 -0
- package/cjs/{capture-DcyBhdqw.cjs → capture-CuyT8Vab.cjs} +4 -4
- package/cjs/{capture-DcyBhdqw.cjs.map → capture-CuyT8Vab.cjs.map} +1 -1
- package/cjs/{cascade-store-DEGxAFDI.cjs → cascade-store-CuRRYzt_.cjs} +3 -3
- package/cjs/cascade-store-CuRRYzt_.cjs.map +1 -0
- package/cjs/{current-request-id-BoJJb3y7.cjs → current-request-id-CeQhRz9Q.cjs} +3 -3
- package/cjs/{current-request-id-BoJJb3y7.cjs.map → current-request-id-CeQhRz9Q.cjs.map} +1 -1
- package/cjs/{errors-DEqdWaqm.cjs → errors-BadbSDX8.cjs} +4 -4
- package/cjs/errors-BadbSDX8.cjs.map +1 -0
- package/cjs/{helpers-7k_Q-abk.cjs → helpers-BcMBFy9v.cjs} +9 -6
- package/cjs/{helpers-7k_Q-abk.cjs.map → helpers-BcMBFy9v.cjs.map} +1 -1
- package/cjs/{histogram-BRV5eHcp.cjs → histogram-DTOGnNBW.cjs} +6 -6
- package/cjs/{histogram-BRV5eHcp.cjs.map → histogram-DTOGnNBW.cjs.map} +1 -1
- package/cjs/{http-XNLYU2vS.cjs → http-Biauhqi0.cjs} +7 -7
- package/cjs/http-Biauhqi0.cjs.map +1 -0
- package/cjs/index.cjs +1 -1
- package/cjs/{insights-BBZnUpWO.cjs → insights-BjJA6Ret.cjs} +6 -6
- package/cjs/{insights-BBZnUpWO.cjs.map → insights-BjJA6Ret.cjs.map} +1 -1
- package/cjs/{migrations-DTTzCNpR.cjs → migrations-BP4cYTGo.cjs} +3 -3
- package/cjs/{migrations-DTTzCNpR.cjs.map → migrations-BP4cYTGo.cjs.map} +1 -1
- package/cjs/{options-CHhmQJic.cjs → options-B9FHbRAJ.cjs} +15 -3
- package/cjs/options-B9FHbRAJ.cjs.map +1 -0
- package/cjs/{panels-CHd20RK5.cjs → panels-D1ITm-jc.cjs} +5 -6
- package/cjs/{panels-CHd20RK5.cjs.map → panels-D1ITm-jc.cjs.map} +1 -1
- package/cjs/{process-panel-DEOnLxoT.cjs → process-panel-DskSA7Cm.cjs} +4 -4
- package/cjs/{process-panel-DEOnLxoT.cjs.map → process-panel-DskSA7Cm.cjs.map} +1 -1
- package/cjs/production/index.cjs +4 -4
- package/cjs/{server-C8JfggQU.cjs → server-D3XRbSSb.cjs} +7 -5
- package/cjs/server-D3XRbSSb.cjs.map +1 -0
- package/cjs/{src-DjOUdhKc.cjs → src-QcNghoYN.cjs} +12 -12
- package/cjs/{src-DjOUdhKc.cjs.map → src-QcNghoYN.cjs.map} +1 -1
- package/cjs/{store-C06KO_A1.cjs → store-CNFv3wVp.cjs} +2 -2
- package/cjs/{stream-route-D4k-sJvW.cjs → stream-route-BqyAlfxQ.cjs} +25 -11
- package/cjs/stream-route-BqyAlfxQ.cjs.map +1 -0
- package/esm/app-versions.mjs +74 -0
- package/esm/app-versions.mjs.map +1 -0
- package/esm/production/auth/helpers.mjs +8 -5
- package/esm/production/auth/helpers.mjs.map +1 -1
- package/esm/production/auth/service.mjs +14 -6
- package/esm/production/auth/service.mjs.map +1 -1
- package/esm/production/boot.mjs +1 -0
- package/esm/production/boot.mjs.map +1 -1
- package/esm/production/contracts.d.mts +7 -0
- package/esm/production/contracts.d.mts.map +1 -1
- package/esm/production/contracts.mjs.map +1 -1
- package/esm/production/errors.d.mts +1 -1
- package/esm/production/errors.mjs +3 -3
- package/esm/production/errors.mjs.map +1 -1
- package/esm/production/http/share-session.mjs.map +1 -1
- package/esm/production/insights/writer.mjs.map +1 -1
- package/esm/production/options.d.mts +5 -1
- package/esm/production/options.d.mts.map +1 -1
- package/esm/production/options.mjs +13 -1
- package/esm/production/options.mjs.map +1 -1
- package/esm/production/store/memory-store.mjs.map +1 -1
- package/esm/server/ai-routes.mjs +20 -6
- package/esm/server/ai-routes.mjs.map +1 -1
- package/esm/server/session-routes.mjs +3 -1
- package/esm/server/session-routes.mjs.map +1 -1
- package/esm/sources/ai-source.d.mts.map +1 -1
- package/esm/sources/ai-source.mjs +75 -7
- package/esm/sources/ai-source.mjs.map +1 -1
- package/esm/types.d.mts +10 -1
- package/esm/types.d.mts.map +1 -1
- package/llms-full.txt +25 -17
- package/package.json +8 -8
- package/skills/SKILL.md +25 -17
- package/ui/dashboard/assets/app.css +1 -1
- package/ui/dashboard/assets/app.js +16 -16
- package/ui/dashboard/build-info.json +7 -7
- package/cjs/ai-source-DTpxumMA.cjs.map +0 -1
- package/cjs/auth-DV2GA1A9.cjs.map +0 -1
- package/cjs/boot-CyeHPFtk.cjs.map +0 -1
- package/cjs/cascade-store-DEGxAFDI.cjs.map +0 -1
- package/cjs/contracts-CDuY-ahl.cjs +0 -116
- package/cjs/contracts-CDuY-ahl.cjs.map +0 -1
- package/cjs/errors-DEqdWaqm.cjs.map +0 -1
- package/cjs/http-XNLYU2vS.cjs.map +0 -1
- package/cjs/options-CHhmQJic.cjs.map +0 -1
- package/cjs/rolldown-runtime-Zuuoy_Rh.cjs +0 -52
- package/cjs/server-C8JfggQU.cjs.map +0 -1
- package/cjs/stream-route-D4k-sJvW.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cascade-store-CuRRYzt_.cjs","names":["rateLimitClient","DevtoolsStoreConflictError","randomUUID","rateLimitClient","DevtoolsProductionConfigError","randomUUID","DevtoolsStoreConflictError","rateLimitClient"],"sources":["../../../../../../../packages/devtools/src/production/store/mapping.ts","../../../../../../../packages/devtools/src/production/store/memory-store.ts","../../../../../../../packages/devtools/src/production/store/cascade-store.ts"],"sourcesContent":["import type { DevtoolsAuditEntry, DevtoolsInstanceReport } from \"../contracts\";\nimport { rateLimitClient } from \"../http/ip\";\nimport type {\n DevtoolsAccountPatch,\n DevtoolsAccountRecord,\n DevtoolsInviteRecord,\n DevtoolsPasskeyRecord,\n DevtoolsSessionPatch,\n DevtoolsSessionRecord,\n DevtoolsShareRecord,\n DevtoolsStatePatch,\n DevtoolsStateRecord,\n DevtoolsStoredSample,\n} from \"./types\";\n\n/**\n * The record <-> row mapping of the cascade store. Rows use snake_case column\n * names; times are epoch milliseconds in integer columns on every driver.\n * Pure functions, so they are tested without a database.\n */\nexport type Row = Record<string, unknown>;\n\n/** A number from a column that a driver may return as a string (PostgreSQL `bigint`). */\nexport function toNumber(value: unknown): number {\n if (typeof value === \"number\") return value;\n\n const parsed = Number(value);\n\n return Number.isFinite(parsed) ? parsed : 0;\n}\n\n/** Like `toNumber`, keeping `null` for a missing value. */\nexport function toNumberOrNull(value: unknown): number | null {\n return value === null || value === undefined ? null : toNumber(value);\n}\n\nexport function toStringOrNull(value: unknown): string | null {\n return typeof value === \"string\" ? value : null;\n}\n\nexport function toBoolean(value: unknown): boolean {\n return value === true || value === 1 || value === \"true\" || value === \"t\";\n}\n\n/** Parses JSON text; a value a driver already parsed passes through. */\nexport function parseJson<T>(value: unknown, fallback: T): T {\n if (typeof value === \"string\") {\n try {\n return JSON.parse(value) as T;\n } catch {\n return fallback;\n }\n }\n\n return value === null || value === undefined ? fallback : (value as T);\n}\n\nfunction toArray<T>(value: unknown): T[] {\n const parsed = parseJson<unknown>(value, []);\n\n return Array.isArray(parsed) ? (parsed as T[]) : [];\n}\n\n// ---------------------------------------------------------------------------\n// Accounts\n// ---------------------------------------------------------------------------\n\nconst ACCOUNT_COLUMNS = {\n email: \"email\",\n role: \"role\",\n passwordHash: \"password_hash\",\n passwordSource: \"password_source\",\n mustChangePassword: \"must_change_password\",\n totpSecret: \"totp_secret\",\n totpEnabledAt: \"totp_enabled_at\",\n totpLastStep: \"totp_last_step\",\n recoveryCodes: \"recovery_codes\",\n passkeys: \"passkeys\",\n failuresResetAt: \"failures_reset_at\",\n createdAt: \"created_at\",\n updatedAt: \"updated_at\",\n lastLoginAt: \"last_login_at\",\n createdBy: \"created_by\",\n version: \"version\",\n} as const satisfies Record<keyof Omit<DevtoolsAccountRecord, \"id\">, string>;\n\nexport function accountToRow(record: DevtoolsAccountRecord): Row {\n return { id: record.id, ...fieldsToRow(ACCOUNT_COLUMNS, record) };\n}\n\nexport function accountPatchToRow(patch: DevtoolsAccountPatch): Row {\n return fieldsToRow(ACCOUNT_COLUMNS, patch);\n}\n\nexport function rowToAccount(row: Row): DevtoolsAccountRecord {\n return {\n id: String(row.id),\n email: String(row.email),\n role: row.role as DevtoolsAccountRecord[\"role\"],\n passwordHash: String(row.password_hash),\n passwordSource: row.password_source as DevtoolsAccountRecord[\"passwordSource\"],\n mustChangePassword: toBoolean(row.must_change_password),\n totpSecret: toStringOrNull(row.totp_secret),\n totpEnabledAt: toNumberOrNull(row.totp_enabled_at),\n totpLastStep: toNumberOrNull(row.totp_last_step),\n recoveryCodes: toArray<string>(row.recovery_codes),\n passkeys: toArray<DevtoolsPasskeyRecord>(row.passkeys),\n failuresResetAt: toNumberOrNull(row.failures_reset_at),\n createdAt: toNumber(row.created_at),\n updatedAt: toNumber(row.updated_at),\n lastLoginAt: toNumberOrNull(row.last_login_at),\n createdBy: toStringOrNull(row.created_by),\n version: toNumber(row.version),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Sessions\n// ---------------------------------------------------------------------------\n\nconst SESSION_COLUMNS = {\n tokenHash: \"token_hash\",\n accountId: \"account_id\",\n stage: \"stage\",\n csrfSecret: \"csrf_secret\",\n createdAt: \"created_at\",\n lastSeenAt: \"last_seen_at\",\n expiresAt: \"expires_at\",\n ip: \"ip\",\n userAgent: \"user_agent\",\n pendingTotpSecret: \"pending_totp_secret\",\n challenge: \"challenge\",\n challengeExpiresAt: \"challenge_expires_at\",\n version: \"version\",\n} as const satisfies Record<keyof Omit<DevtoolsSessionRecord, \"id\">, string>;\n\nexport function sessionToRow(record: DevtoolsSessionRecord): Row {\n return { id: record.id, ...fieldsToRow(SESSION_COLUMNS, record) };\n}\n\nexport function sessionPatchToRow(patch: DevtoolsSessionPatch): Row {\n return fieldsToRow(SESSION_COLUMNS, patch);\n}\n\nexport function rowToSession(row: Row): DevtoolsSessionRecord {\n return {\n id: String(row.id),\n tokenHash: String(row.token_hash),\n accountId: String(row.account_id),\n stage: row.stage as DevtoolsSessionRecord[\"stage\"],\n csrfSecret: String(row.csrf_secret),\n createdAt: toNumber(row.created_at),\n lastSeenAt: toNumber(row.last_seen_at),\n expiresAt: toNumber(row.expires_at),\n ip: toStringOrNull(row.ip),\n userAgent: toStringOrNull(row.user_agent),\n pendingTotpSecret: toStringOrNull(row.pending_totp_secret),\n challenge: toStringOrNull(row.challenge),\n challengeExpiresAt: toNumberOrNull(row.challenge_expires_at),\n version: toNumber(row.version),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Invites\n// ---------------------------------------------------------------------------\n\nexport function inviteToRow(record: DevtoolsInviteRecord): Row {\n return {\n id: record.id,\n token_hash: record.tokenHash,\n email: record.email,\n role: record.role,\n created_by: record.createdBy,\n created_at: record.createdAt,\n expires_at: record.expiresAt,\n used_at: record.usedAt,\n account_id: record.accountId,\n };\n}\n\nexport function rowToInvite(row: Row): DevtoolsInviteRecord {\n return {\n id: String(row.id),\n tokenHash: String(row.token_hash),\n email: String(row.email),\n role: row.role as DevtoolsInviteRecord[\"role\"],\n createdBy: toStringOrNull(row.created_by),\n createdAt: toNumber(row.created_at),\n expiresAt: toNumber(row.expires_at),\n usedAt: toNumberOrNull(row.used_at),\n accountId: toStringOrNull(row.account_id),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Share links\n// ---------------------------------------------------------------------------\n\nexport function shareToRow(record: DevtoolsShareRecord): Row {\n return {\n id: record.id,\n token_hash: record.tokenHash,\n panel: record.panel,\n label: record.label,\n created_by: record.createdBy,\n created_at: record.createdAt,\n expires_at: record.expiresAt,\n revoked_at: record.revokedAt,\n last_used_at: record.lastUsedAt,\n uses: record.uses,\n };\n}\n\nexport function rowToShare(row: Row): DevtoolsShareRecord {\n return {\n id: String(row.id),\n tokenHash: String(row.token_hash),\n panel: String(row.panel),\n label: String(row.label),\n createdBy: toStringOrNull(row.created_by),\n createdAt: toNumber(row.created_at),\n expiresAt: toNumber(row.expires_at),\n revokedAt: toNumberOrNull(row.revoked_at),\n lastUsedAt: toNumberOrNull(row.last_used_at),\n uses: toNumber(row.uses),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Audit\n// ---------------------------------------------------------------------------\n\nexport function auditToRow(entry: DevtoolsAuditEntry): Row {\n return {\n id: entry.id,\n type: entry.type,\n occurred_at: entry.at,\n account_id: entry.accountId,\n email: entry.email,\n ip: entry.ip,\n // What the per-IP limit counts by: the address, or its /64 for IPv6.\n ip_bucket: entry.ip === null ? null : rateLimitClient(entry.ip),\n user_agent: entry.userAgent,\n detail: entry.detail,\n ref: entry.ref,\n };\n}\n\nexport function rowToAudit(row: Row): DevtoolsAuditEntry {\n return {\n id: String(row.id),\n at: toNumber(row.occurred_at),\n type: row.type as DevtoolsAuditEntry[\"type\"],\n accountId: toStringOrNull(row.account_id),\n email: toStringOrNull(row.email),\n ip: toStringOrNull(row.ip),\n userAgent: toStringOrNull(row.user_agent),\n detail: parseJson<DevtoolsAuditEntry[\"detail\"]>(row.detail, {}),\n ref: String(row.ref),\n };\n}\n\n// ---------------------------------------------------------------------------\n// State\n// ---------------------------------------------------------------------------\n\nconst STATE_COLUMNS = {\n disabled: \"disabled\",\n disabledPathHash: \"disabled_path_hash\",\n disabledAt: \"disabled_at\",\n disabledBy: \"disabled_by\",\n lockedUntil: \"locked_until\",\n failuresResetAt: \"failures_reset_at\",\n updatedAt: \"updated_at\",\n version: \"version\",\n} as const satisfies Record<keyof DevtoolsStateRecord, string>;\n\nexport function stateToRow(record: DevtoolsStateRecord): Row {\n return fieldsToRow(STATE_COLUMNS, record);\n}\n\nexport function statePatchToRow(patch: DevtoolsStatePatch): Row {\n return fieldsToRow(STATE_COLUMNS, patch);\n}\n\nexport function rowToState(row: Row): DevtoolsStateRecord {\n return {\n disabled: toBoolean(row.disabled),\n disabledPathHash: toStringOrNull(row.disabled_path_hash),\n disabledAt: toNumberOrNull(row.disabled_at),\n disabledBy: toStringOrNull(row.disabled_by),\n lockedUntil: toNumberOrNull(row.locked_until),\n failuresResetAt: toNumberOrNull(row.failures_reset_at),\n updatedAt: toNumber(row.updated_at),\n version: toNumber(row.version),\n };\n}\n\n// ---------------------------------------------------------------------------\n// Samples and reports\n// ---------------------------------------------------------------------------\n\n/**\n * `detail` is JSON text, not a JSON column: a sample holds keys from request\n * data (headers, query names) and MongoDB rejects or misreads field names\n * that start with `$` or contain dots.\n */\nexport function sampleToRow(sample: DevtoolsStoredSample): Row {\n return {\n id: sample.id,\n instance: sample.instance,\n started_at: sample.startedAt,\n status: sample.summary.status ?? null,\n method: sample.summary.method.toUpperCase(),\n path: sample.summary.path,\n summary: sample.summary,\n detail: sample.detail === null ? null : JSON.stringify(sample.detail),\n };\n}\n\nexport function rowToSampleSummary(row: Row): DevtoolsStoredSample[\"summary\"] {\n return parseJson<DevtoolsStoredSample[\"summary\"]>(row.summary, {} as never);\n}\n\nexport function rowToSample(row: Row): DevtoolsStoredSample {\n const detail = row.detail;\n\n return {\n id: String(row.id),\n instance: String(row.instance),\n startedAt: toNumber(row.started_at),\n summary: parseJson<DevtoolsStoredSample[\"summary\"]>(row.summary, {} as never),\n detail:\n detail === null || detail === undefined\n ? null\n : parseJson<DevtoolsStoredSample[\"detail\"]>(detail, null),\n };\n}\n\n/** `data` is JSON text for the same reason as a sample's `detail`. */\nexport function reportToRow(report: DevtoolsInstanceReport): Row {\n return {\n id: report.instance.id,\n seen_at: report.at,\n data: JSON.stringify(report),\n };\n}\n\nexport function rowToReport(row: Row): DevtoolsInstanceReport {\n return parseJson<DevtoolsInstanceReport>(row.data, {} as never);\n}\n\n// ---------------------------------------------------------------------------\n\n/** Maps the defined fields of `source` to their columns. */\nfunction fieldsToRow(columns: Record<string, string>, source: object): Row {\n const row: Row = {};\n const values = source as Record<string, unknown>;\n\n for (const [field, column] of Object.entries(columns)) {\n const value = values[field];\n\n if (value !== undefined) row[column] = value;\n }\n\n return row;\n}\n","import { randomUUID } from \"node:crypto\";\nimport type {\n DevtoolsAuditEntry,\n DevtoolsInstanceReport,\n DevtoolsSampleSummary,\n} from \"../contracts\";\nimport { DevtoolsStoreConflictError } from \"../errors\";\nimport { rateLimitClient } from \"../http/ip\";\nimport type {\n DevtoolsAccountRecord,\n DevtoolsInviteRecord,\n DevtoolsSampleFilter,\n DevtoolsSessionRecord,\n DevtoolsShareRecord,\n DevtoolsStateRecord,\n DevtoolsStore,\n DevtoolsStoredSample,\n} from \"./types\";\n\n/** A structural copy, so callers never hold the store's own objects. */\nfunction copy<T>(value: T): T {\n return structuredClone(value);\n}\n\n/** The state row before anything was written. */\nexport function defaultStateRecord(now = 0): DevtoolsStateRecord {\n return {\n disabled: false,\n disabledPathHash: null,\n disabledAt: null,\n disabledBy: null,\n lockedUntil: null,\n failuresResetAt: null,\n updatedAt: now,\n version: 0,\n };\n}\n\n/** Whether `status` matches a sample filter value: `\"5xx\"`, `\"4xx\"`, `\"404\"`. */\nexport function sampleStatusMatches(filter: string, status: number | undefined): boolean {\n if (status === undefined) return false;\n\n const value = filter.trim().toLowerCase();\n\n if (/^[1-5]xx$/.test(value)) return Math.floor(status / 100) === Number(value[0]);\n\n return String(status) === value;\n}\n\n/** Whether a sample summary passes `filter` (everything but `limit`). */\nexport function sampleMatches(\n summary: DevtoolsSampleSummary,\n filter: DevtoolsSampleFilter,\n): boolean {\n if (filter.status !== undefined && !sampleStatusMatches(filter.status, summary.status))\n return false;\n if (filter.method !== undefined && summary.method.toUpperCase() !== filter.method.toUpperCase()) {\n return false;\n }\n\n if (filter.route !== undefined) {\n const needle = filter.route.toLowerCase();\n const haystack = `${summary.route ?? \"\"} ${summary.path}`.toLowerCase();\n\n if (!haystack.includes(needle)) return false;\n }\n\n if (filter.q !== undefined && !summary.path.toLowerCase().includes(filter.q.toLowerCase())) {\n return false;\n }\n\n if (filter.since !== undefined && summary.startedAt < filter.since) return false;\n if (filter.until !== undefined && summary.startedAt > filter.until) return false;\n if (filter.instance !== undefined && summary.instance !== filter.instance) return false;\n\n return true;\n}\n\n/**\n * An in-process `DevtoolsStore` for specs (and nothing else: it is neither\n * shared between processes nor kept across restarts). It follows the store\n * contract exactly, compare-and-set included, so a spec written against it\n * holds for the database store too.\n *\n * `now` is read for `updatedAt` stamps; pass a fake clock in specs.\n */\nexport function createMemoryStore(options: { now?: () => number } = {}): DevtoolsStore {\n const now = options.now ?? Date.now;\n const accounts = new Map<string, DevtoolsAccountRecord>();\n const sessions = new Map<string, DevtoolsSessionRecord>();\n const invites = new Map<string, DevtoolsInviteRecord>();\n const shares = new Map<string, DevtoolsShareRecord>();\n const audit: DevtoolsAuditEntry[] = [];\n const samples = new Map<string, DevtoolsStoredSample>();\n const reports = new Map<string, DevtoolsInstanceReport>();\n let state: DevtoolsStateRecord | null = null;\n\n return {\n async verify() {},\n\n accounts: {\n async findByEmail(email) {\n for (const account of accounts.values()) {\n if (account.email === email) return copy(account);\n }\n\n return null;\n },\n async findById(id) {\n const account = accounts.get(id);\n\n return account ? copy(account) : null;\n },\n async list() {\n return [...accounts.values()].sort((a, b) => a.createdAt - b.createdAt).map(copy);\n },\n async countAdmins() {\n return [...accounts.values()].filter((account) => account.role === \"admin\").length;\n },\n async create(input) {\n for (const account of accounts.values()) {\n if (account.email === input.email) throw new DevtoolsStoreConflictError(\"email\");\n }\n\n const at = now();\n const record: DevtoolsAccountRecord = {\n ...copy(input),\n id: randomUUID(),\n createdAt: at,\n updatedAt: at,\n version: 1,\n };\n\n accounts.set(record.id, record);\n\n return copy(record);\n },\n async update(id, expectedVersion, patch) {\n const current = accounts.get(id);\n\n if (!current || current.version !== expectedVersion) return null;\n\n if (patch.email !== undefined && patch.email !== current.email) {\n for (const account of accounts.values()) {\n if (account.email === patch.email) throw new DevtoolsStoreConflictError(\"email\");\n }\n }\n\n const next: DevtoolsAccountRecord = {\n ...current,\n ...copy(patch),\n id,\n createdAt: current.createdAt,\n updatedAt: now(),\n version: current.version + 1,\n };\n\n accounts.set(id, next);\n\n return copy(next);\n },\n async remove(id) {\n return accounts.delete(id);\n },\n },\n\n sessions: {\n async create(input) {\n const record: DevtoolsSessionRecord = { ...copy(input), id: randomUUID(), version: 1 };\n\n sessions.set(record.id, record);\n\n return copy(record);\n },\n async findByTokenHash(tokenHash) {\n for (const session of sessions.values()) {\n if (session.tokenHash === tokenHash) return copy(session);\n }\n\n return null;\n },\n async listForAccount(accountId) {\n return [...sessions.values()]\n .filter((session) => session.accountId === accountId)\n .sort((a, b) => b.createdAt - a.createdAt)\n .map(copy);\n },\n async update(id, expectedVersion, patch) {\n const current = sessions.get(id);\n\n if (!current || current.version !== expectedVersion) return null;\n\n const next: DevtoolsSessionRecord = {\n ...current,\n ...copy(patch),\n id,\n accountId: current.accountId,\n version: current.version + 1,\n };\n\n sessions.set(id, next);\n\n return copy(next);\n },\n async remove(id) {\n return sessions.delete(id);\n },\n async removeForAccount(accountId, exceptId) {\n let removed = 0;\n\n for (const session of [...sessions.values()]) {\n if (session.accountId === accountId && session.id !== exceptId) {\n sessions.delete(session.id);\n removed++;\n }\n }\n\n return removed;\n },\n async removeExpired(at) {\n let removed = 0;\n\n for (const session of [...sessions.values()]) {\n if (session.expiresAt < at) {\n sessions.delete(session.id);\n removed++;\n }\n }\n\n return removed;\n },\n },\n\n invites: {\n async create(input) {\n const record: DevtoolsInviteRecord = {\n ...copy(input),\n id: randomUUID(),\n usedAt: null,\n accountId: null,\n };\n\n invites.set(record.id, record);\n\n return copy(record);\n },\n async findByTokenHash(tokenHash) {\n for (const invite of invites.values()) {\n if (invite.tokenHash === tokenHash) return copy(invite);\n }\n\n return null;\n },\n async list(listOptions = {}) {\n return [...invites.values()]\n .filter((invite) => listOptions.includeUsed === true || invite.usedAt === null)\n .sort((a, b) => b.createdAt - a.createdAt)\n .map(copy);\n },\n async markUsed(id, at, accountId) {\n const invite = invites.get(id);\n\n if (!invite || invite.usedAt !== null || at >= invite.expiresAt) return false;\n\n invites.set(id, { ...invite, usedAt: at, accountId });\n\n return true;\n },\n async remove(id) {\n return invites.delete(id);\n },\n async removeExpired(at) {\n let removed = 0;\n\n for (const invite of [...invites.values()]) {\n if (invite.usedAt === null && invite.expiresAt < at) {\n invites.delete(invite.id);\n removed++;\n }\n }\n\n return removed;\n },\n },\n\n audit: {\n async append(entry) {\n const record: DevtoolsAuditEntry = { ...copy(entry), id: randomUUID() };\n\n audit.push(record);\n\n return copy(record);\n },\n async list(filter) {\n const limit = Math.max(1, Math.min(500, filter.limit));\n\n return audit\n .filter(\n (entry) =>\n (filter.types === undefined || filter.types.includes(entry.type)) &&\n (filter.accountId === undefined || entry.accountId === filter.accountId) &&\n (filter.before === undefined || entry.at < filter.before),\n )\n .sort((a, b) => b.at - a.at)\n .slice(0, limit)\n .map(copy);\n },\n async count(filter) {\n return audit.filter(\n (entry) =>\n filter.types.includes(entry.type) &&\n entry.at >= filter.since &&\n (filter.accountId === undefined || entry.accountId === filter.accountId) &&\n (filter.ip === undefined ||\n (entry.ip !== null && rateLimitClient(entry.ip) === rateLimitClient(filter.ip))),\n ).length;\n },\n async prune(before) {\n const kept = audit.filter((entry) => entry.at >= before);\n const removed = audit.length - kept.length;\n\n audit.splice(0, audit.length, ...kept);\n\n return removed;\n },\n },\n\n state: {\n async read() {\n return copy(state ?? defaultStateRecord(now()));\n },\n async update(expectedVersion, patch) {\n const current = state ?? defaultStateRecord(now());\n\n if (current.version !== expectedVersion) return null;\n\n state = { ...current, ...copy(patch), updatedAt: now(), version: current.version + 1 };\n\n return copy(state);\n },\n },\n\n samples: {\n async insert(list) {\n for (const sample of list) samples.set(sample.id, copy(sample));\n },\n async list(filter) {\n const limit = Math.max(1, Math.min(1000, filter.limit));\n\n return [...samples.values()]\n .map((sample) => sample.summary)\n .filter((summary) => sampleMatches(summary, filter))\n .sort((a, b) => b.startedAt - a.startedAt)\n .slice(0, limit)\n .map(copy);\n },\n async get(id) {\n const sample = samples.get(id);\n\n return sample ? copy(sample) : null;\n },\n async prune(before) {\n let removed = 0;\n\n for (const sample of [...samples.values()]) {\n if (sample.startedAt < before) {\n samples.delete(sample.id);\n removed++;\n }\n }\n\n return removed;\n },\n async clear() {\n const removed = samples.size;\n\n samples.clear();\n\n return removed;\n },\n },\n\n reports: {\n async write(report) {\n reports.set(report.instance.id, copy(report));\n },\n async list(seenSince) {\n return [...reports.values()]\n .filter((report) => report.at >= seenSince)\n .sort((a, b) => b.at - a.at)\n .map(copy);\n },\n async prune(seenBefore) {\n let removed = 0;\n\n for (const report of [...reports.values()]) {\n if (report.at < seenBefore) {\n reports.delete(report.instance.id);\n removed++;\n }\n }\n\n return removed;\n },\n async remove(instanceId) {\n return reports.delete(instanceId);\n },\n },\n\n shares: {\n async create(input) {\n for (const share of shares.values()) {\n if (share.tokenHash === input.tokenHash)\n throw new DevtoolsStoreConflictError(\"tokenHash\");\n }\n\n const record: DevtoolsShareRecord = {\n ...copy(input),\n id: randomUUID(),\n revokedAt: null,\n lastUsedAt: null,\n uses: 0,\n };\n\n shares.set(record.id, record);\n\n return copy(record);\n },\n async findByTokenHash(tokenHash) {\n for (const share of shares.values()) {\n if (share.tokenHash === tokenHash) return copy(share);\n }\n\n return null;\n },\n async get(id) {\n const share = shares.get(id);\n\n return share ? copy(share) : null;\n },\n async list() {\n return [...shares.values()].sort((a, b) => b.createdAt - a.createdAt).map(copy);\n },\n async revoke(id, at) {\n const share = shares.get(id);\n\n if (!share || share.revokedAt !== null) return false;\n\n shares.set(id, { ...share, revokedAt: at });\n\n return true;\n },\n async revokeAll(at) {\n let revoked = 0;\n\n for (const share of [...shares.values()]) {\n if (share.revokedAt === null && share.expiresAt > at) {\n shares.set(share.id, { ...share, revokedAt: at });\n revoked++;\n }\n }\n\n return revoked;\n },\n async touch(id, at) {\n const share = shares.get(id);\n\n if (share) shares.set(id, { ...share, lastUsedAt: at, uses: share.uses + 1 });\n },\n async removeOld(before) {\n let removed = 0;\n\n for (const share of [...shares.values()]) {\n if (share.expiresAt < before || (share.revokedAt !== null && share.revokedAt < before)) {\n shares.delete(share.id);\n removed++;\n }\n }\n\n return removed;\n },\n },\n };\n}\n","import { randomUUID } from \"node:crypto\";\nimport type { DevtoolsAuditEntry, DevtoolsInstanceReport } from \"../contracts\";\nimport { DevtoolsProductionConfigError, DevtoolsStoreConflictError } from \"../errors\";\nimport { rateLimitClient } from \"../http/ip\";\nimport {\n accountPatchToRow,\n accountToRow,\n auditToRow,\n inviteToRow,\n reportToRow,\n rowToAccount,\n rowToAudit,\n rowToInvite,\n rowToReport,\n rowToSample,\n rowToSampleSummary,\n rowToSession,\n rowToShare,\n rowToState,\n sampleToRow,\n sessionPatchToRow,\n sessionToRow,\n shareToRow,\n statePatchToRow,\n stateToRow,\n type Row,\n} from \"./mapping\";\nimport { defaultStateRecord, sampleMatches } from \"./memory-store\";\nimport type {\n DevtoolsAccountRecord,\n DevtoolsInviteRecord,\n DevtoolsSessionRecord,\n DevtoolsShareRecord,\n DevtoolsStore,\n} from \"./types\";\n\ntype ModelsModule = typeof import(\"./models\");\n\n/** The part of cascade's query builder this store uses. */\ninterface RowQuery {\n where(field: string, operator: string, value: unknown): RowQuery;\n whereIn(field: string, values: unknown[]): RowQuery;\n whereNull(field: string): RowQuery;\n orderBy(field: string, direction: \"asc\" | \"desc\"): RowQuery;\n limit(value: number): RowQuery;\n select(fields: string[]): RowQuery;\n get(): Promise<Row[]>;\n first(): Promise<Row | null>;\n delete(): Promise<number>;\n count(): Promise<number>;\n}\n\n/** The part of a cascade model class this store uses (every table class has this shape). */\ntype RowClass = ModelsModule[\"DevtoolsAccountRow\"];\n\nexport type CascadeStoreOptions = {\n /** The clock for `updatedAt` stamps; defaults to `Date.now`. */\n now?: () => number;\n /**\n * Whether `verify()` also checks the `devtools_shares` table. Set it when\n * `production.share.enabled` is on; apps that do not share links need no\n * migration for it.\n */\n shares?: boolean;\n};\n\n/** The most rows scanned for a sample filter the database cannot apply (route, text). */\nconst SAMPLE_SCAN_LIMIT = 5000;\n\n/** A plain-row query (no model instances). */\nfunction rows(table: RowClass): RowQuery {\n return table.query().lean() as unknown as RowQuery;\n}\n\n/** A query for counting and deleting. */\nfunction query(table: RowClass): RowQuery {\n return table.query() as unknown as RowQuery;\n}\n\nfunction byId(table: RowClass, id: string): Promise<Row | null> {\n return rows(table).where(\"id\", \"=\", id).first();\n}\n\nasync function insert(table: RowClass, row: Row): Promise<void> {\n await table.create(row as never);\n}\n\nasync function removeWhere(table: RowClass, field: string, value: unknown): Promise<boolean> {\n return (await query(table).where(field, \"=\", value).delete()) > 0;\n}\n\n/** Applies `$set` to the row only while its `version` still equals `expected`. */\nasync function compareAndSet(\n table: RowClass,\n id: string,\n expected: number,\n set: Row,\n): Promise<boolean> {\n const updated = await table.atomic({ id, version: expected }, { $set: set });\n\n return updated > 0;\n}\n\n/**\n * The production `DevtoolsStore`: the app's database through\n * `@warlock.js/cascade` (MongoDB or SQL), using the models in `./models` and\n * the tables `devtoolsMigrations` creates. Imports cascade lazily so loading\n * this module never requires it.\n *\n * Throws `DevtoolsProductionConfigError(\"DT005\")` when cascade is not\n * installed or has no connection.\n */\nexport async function createCascadeStore(\n options: CascadeStoreOptions = {},\n): Promise<DevtoolsStore> {\n const now = options.now ?? Date.now;\n let models: ModelsModule;\n\n try {\n models = await import(\"./models\");\n // Throws when the app has no data source.\n models.DevtoolsAccountRow.getDataSource();\n } catch (error) {\n throw new DevtoolsProductionConfigError(\n \"DT005\",\n error instanceof Error ? `(${error.message})` : undefined,\n );\n }\n\n const {\n DevtoolsAccountRow: Accounts,\n DevtoolsSessionRow: Sessions,\n DevtoolsInviteRow: Invites,\n DevtoolsAuditRow: Audit,\n DevtoolsStateRow: State,\n DevtoolsSampleRow: Samples,\n DevtoolsReportRow: Reports,\n DevtoolsShareRow: Shares,\n } = models;\n const tables: RowClass[] = [Accounts, Sessions, Invites, Audit, State, Samples, Reports];\n\n if (options.shares === true) tables.push(Shares);\n\n const accountById = async (id: string): Promise<DevtoolsAccountRecord | null> => {\n const row = await byId(Accounts, id);\n\n return row ? rowToAccount(row) : null;\n };\n const shareById = async (id: string): Promise<DevtoolsShareRecord | null> => {\n const row = await byId(Shares, id);\n\n return row ? rowToShare(row) : null;\n };\n const sessionById = async (id: string): Promise<DevtoolsSessionRecord | null> => {\n const row = await byId(Sessions, id);\n\n return row ? rowToSession(row) : null;\n };\n\n return {\n async verify() {\n const blueprint = Accounts.getDriver().blueprint;\n const missing: string[] = [];\n\n for (const table of tables) {\n if (!(await blueprint.tableExists(table.table))) missing.push(table.table);\n }\n\n if (missing.length > 0) {\n throw new DevtoolsProductionConfigError(\"DT008\", `(missing: ${missing.join(\", \")})`);\n }\n },\n\n accounts: {\n async findByEmail(email) {\n const row = await rows(Accounts).where(\"email\", \"=\", email).first();\n\n return row ? rowToAccount(row) : null;\n },\n findById: accountById,\n async list() {\n const found = await rows(Accounts).orderBy(\"created_at\", \"asc\").get();\n\n return found.map(rowToAccount);\n },\n async countAdmins() {\n return query(Accounts).where(\"role\", \"=\", \"admin\").count();\n },\n async create(input) {\n const at = now();\n const record: DevtoolsAccountRecord = {\n ...structuredClone(input),\n id: randomUUID(),\n createdAt: at,\n updatedAt: at,\n version: 1,\n };\n\n if (await rows(Accounts).where(\"email\", \"=\", record.email).first()) {\n throw new DevtoolsStoreConflictError(\"email\");\n }\n\n try {\n await insert(Accounts, accountToRow(record));\n } catch (error) {\n // A concurrent request took the email between the check and the insert.\n if (await rows(Accounts).where(\"email\", \"=\", record.email).first()) {\n throw new DevtoolsStoreConflictError(\"email\");\n }\n\n throw error;\n }\n\n return record;\n },\n async update(id, expectedVersion, patch) {\n const current = await accountById(id);\n\n if (!current || current.version !== expectedVersion) return null;\n\n if (patch.email !== undefined && patch.email !== current.email) {\n if (await rows(Accounts).where(\"email\", \"=\", patch.email).first()) {\n throw new DevtoolsStoreConflictError(\"email\");\n }\n }\n\n const set = {\n ...accountPatchToRow(structuredClone(patch)),\n updated_at: now(),\n version: expectedVersion + 1,\n };\n let won: boolean;\n\n try {\n won = await compareAndSet(Accounts, id, expectedVersion, set);\n } catch (error) {\n if (\n patch.email !== undefined &&\n (await rows(Accounts).where(\"email\", \"=\", patch.email).first())\n ) {\n throw new DevtoolsStoreConflictError(\"email\");\n }\n\n throw error;\n }\n\n return won ? accountById(id) : null;\n },\n async remove(id) {\n return removeWhere(Accounts, \"id\", id);\n },\n },\n\n sessions: {\n async create(input) {\n const record: DevtoolsSessionRecord = {\n ...structuredClone(input),\n id: randomUUID(),\n version: 1,\n };\n\n await insert(Sessions, sessionToRow(record));\n\n return record;\n },\n async findByTokenHash(tokenHash) {\n const row = await rows(Sessions).where(\"token_hash\", \"=\", tokenHash).first();\n\n return row ? rowToSession(row) : null;\n },\n async listForAccount(accountId) {\n const found = await rows(Sessions)\n .where(\"account_id\", \"=\", accountId)\n .orderBy(\"created_at\", \"desc\")\n .get();\n\n return found.map(rowToSession);\n },\n async update(id, expectedVersion, patch) {\n const set = { ...sessionPatchToRow(structuredClone(patch)), version: expectedVersion + 1 };\n\n if (!(await compareAndSet(Sessions, id, expectedVersion, set))) return null;\n\n return sessionById(id);\n },\n async remove(id) {\n return removeWhere(Sessions, \"id\", id);\n },\n async removeForAccount(accountId, exceptId) {\n const target = query(Sessions).where(\"account_id\", \"=\", accountId);\n\n if (exceptId !== undefined) target.where(\"id\", \"!=\", exceptId);\n\n return target.delete();\n },\n async removeExpired(at) {\n return query(Sessions).where(\"expires_at\", \"<\", at).delete();\n },\n },\n\n invites: {\n async create(input) {\n const record: DevtoolsInviteRecord = {\n ...structuredClone(input),\n id: randomUUID(),\n usedAt: null,\n accountId: null,\n };\n\n await insert(Invites, inviteToRow(record));\n\n return record;\n },\n async findByTokenHash(tokenHash) {\n const row = await rows(Invites).where(\"token_hash\", \"=\", tokenHash).first();\n\n return row ? rowToInvite(row) : null;\n },\n async list(listOptions = {}) {\n const target = rows(Invites);\n\n if (listOptions.includeUsed !== true) target.whereNull(\"used_at\");\n\n return (await target.orderBy(\"created_at\", \"desc\").get()).map(rowToInvite);\n },\n async markUsed(id, at, accountId) {\n const updated = await Invites.atomic(\n { id, used_at: null, expires_at: { $gt: at } },\n { $set: { used_at: at, account_id: accountId } },\n // Code-authored filter; nothing here comes from a request.\n { trustedFilter: true },\n );\n\n return updated > 0;\n },\n async remove(id) {\n return removeWhere(Invites, \"id\", id);\n },\n async removeExpired(at) {\n return query(Invites).whereNull(\"used_at\").where(\"expires_at\", \"<\", at).delete();\n },\n },\n\n audit: {\n async append(entry) {\n const record: DevtoolsAuditEntry = { ...structuredClone(entry), id: randomUUID() };\n\n await insert(Audit, auditToRow(record));\n\n return record;\n },\n async list(filter) {\n const limit = Math.max(1, Math.min(500, filter.limit));\n const target = rows(Audit);\n\n if (filter.types !== undefined) target.whereIn(\"type\", [...filter.types]);\n if (filter.accountId !== undefined) target.where(\"account_id\", \"=\", filter.accountId);\n if (filter.before !== undefined) target.where(\"occurred_at\", \"<\", filter.before);\n\n const found = await target.orderBy(\"occurred_at\", \"desc\").limit(limit).get();\n\n return found.map(rowToAudit);\n },\n async count(filter) {\n const target = query(Audit)\n .whereIn(\"type\", [...filter.types])\n .where(\"occurred_at\", \">=\", filter.since);\n\n if (filter.accountId !== undefined) target.where(\"account_id\", \"=\", filter.accountId);\n if (filter.ip !== undefined) target.where(\"ip_bucket\", \"=\", rateLimitClient(filter.ip));\n\n return target.count();\n },\n async prune(before) {\n return query(Audit).where(\"occurred_at\", \"<\", before).delete();\n },\n },\n\n state: {\n async read() {\n const row = await byId(State, \"state\");\n\n return row ? rowToState(row) : defaultStateRecord(now());\n },\n async update(expectedVersion, patch) {\n const row = await byId(State, \"state\");\n\n if (!row) {\n if (expectedVersion !== 0) return null;\n\n const record = {\n ...defaultStateRecord(now()),\n ...structuredClone(patch),\n updatedAt: now(),\n version: 1,\n };\n\n try {\n await insert(State, { id: \"state\", ...stateToRow(record) });\n } catch {\n // Another process wrote the first row; this write lost the race.\n return null;\n }\n\n return record;\n }\n\n const set = {\n ...statePatchToRow(structuredClone(patch)),\n updated_at: now(),\n version: expectedVersion + 1,\n };\n\n if (!(await compareAndSet(State, \"state\", expectedVersion, set))) return null;\n\n const next = await byId(State, \"state\");\n\n return next ? rowToState(next) : null;\n },\n },\n\n samples: {\n async insert(list) {\n for (const sample of list) {\n const { id, ...data } = sampleToRow(structuredClone(sample));\n\n await Samples.upsert({ id } as never, data as never);\n }\n },\n async list(filter) {\n const limit = Math.max(1, Math.min(1000, filter.limit));\n const target = rows(Samples).select([\"summary\"]);\n const exact = !(filter.route !== undefined || filter.q !== undefined);\n\n if (filter.status !== undefined) {\n const status = filter.status.trim().toLowerCase();\n\n if (/^[1-5]xx$/.test(status)) {\n const base = Number(status[0]) * 100;\n\n target.where(\"status\", \">=\", base).where(\"status\", \"<\", base + 100);\n } else if (/^\\d+$/.test(status) && String(Number(status)) === status) {\n target.where(\"status\", \"=\", Number(status));\n } else {\n return [];\n }\n }\n\n if (filter.method !== undefined) target.where(\"method\", \"=\", filter.method.toUpperCase());\n if (filter.since !== undefined) target.where(\"started_at\", \">=\", filter.since);\n if (filter.until !== undefined) target.where(\"started_at\", \"<=\", filter.until);\n if (filter.instance !== undefined) target.where(\"instance\", \"=\", filter.instance);\n\n const found = await target\n .orderBy(\"started_at\", \"desc\")\n .limit(exact ? limit : SAMPLE_SCAN_LIMIT)\n .get();\n\n // Route and text filters are substring matches the databases do not\n // share, so they run here, with the same rules as the memory store.\n return found\n .map(rowToSampleSummary)\n .filter((summary) => sampleMatches(summary, filter))\n .slice(0, limit);\n },\n async get(id) {\n const row = await byId(Samples, id);\n\n return row ? rowToSample(row) : null;\n },\n async prune(before) {\n return query(Samples).where(\"started_at\", \"<\", before).delete();\n },\n async clear() {\n return query(Samples).where(\"started_at\", \">=\", 0).delete();\n },\n },\n\n reports: {\n async write(report: DevtoolsInstanceReport) {\n const { id, ...data } = reportToRow(report);\n\n await Reports.upsert({ id } as never, data as never);\n },\n async list(seenSince) {\n const found = await rows(Reports)\n .where(\"seen_at\", \">=\", seenSince)\n .orderBy(\"seen_at\", \"desc\")\n .get();\n\n return found.map(rowToReport);\n },\n async prune(seenBefore) {\n return query(Reports).where(\"seen_at\", \"<\", seenBefore).delete();\n },\n async remove(instanceId) {\n return removeWhere(Reports, \"id\", instanceId);\n },\n },\n\n shares: {\n async create(input) {\n const record: DevtoolsShareRecord = {\n ...structuredClone(input),\n id: randomUUID(),\n revokedAt: null,\n lastUsedAt: null,\n uses: 0,\n };\n\n await insert(Shares, shareToRow(record));\n\n return record;\n },\n async findByTokenHash(tokenHash) {\n const row = await rows(Shares).where(\"token_hash\", \"=\", tokenHash).first();\n\n return row ? rowToShare(row) : null;\n },\n get: shareById,\n async list() {\n return (await rows(Shares).orderBy(\"created_at\", \"desc\").get()).map(rowToShare);\n },\n async revoke(id, at) {\n const updated = await Shares.atomic(\n { id, revoked_at: null },\n { $set: { revoked_at: at } },\n // Code-authored filter: `id` is a string the route checked, never an operator object.\n { trustedFilter: true },\n );\n\n return updated > 0;\n },\n async revokeAll(at) {\n return Shares.atomic(\n { revoked_at: null, expires_at: { $gt: at } },\n { $set: { revoked_at: at } },\n { trustedFilter: true },\n );\n },\n async touch(id, at) {\n await Shares.atomic(\n { id },\n { $set: { last_used_at: at }, $inc: { uses: 1 } },\n { trustedFilter: true },\n );\n },\n async removeOld(before) {\n const expired = await query(Shares).where(\"expires_at\", \"<\", before).delete();\n const revoked = await query(Shares).where(\"rev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AAK,MAAM,CAAC,CAAC,OAAO,IAG3D,MAFK,MAAM,MAAM,CAAC,CAAC,MAAM,cAAc,KAAK,MAAM,CAAC,CAAC,OAAO;GAG9E;EACF;CACF;AACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_app_versions = require("./app-versions-DfpPZOI2.cjs");
|
|
2
2
|
let _warlock_js_core = require("@warlock.js/core");
|
|
3
3
|
|
|
4
4
|
//#region ../../packages/devtools/src/current-request-id.ts
|
|
5
|
-
var current_request_id_exports = /* @__PURE__ */
|
|
5
|
+
var current_request_id_exports = /* @__PURE__ */ require_app_versions.__exportAll({ currentRequestId: () => currentRequestId });
|
|
6
6
|
/**
|
|
7
7
|
* The current request's id (core's `request.id`, threaded through
|
|
8
8
|
* `AsyncLocalStorage`), or `undefined` outside a request — sources feed
|
|
@@ -34,4 +34,4 @@ Object.defineProperty(exports, "current_request_id_exports", {
|
|
|
34
34
|
return current_request_id_exports;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
|
-
//# sourceMappingURL=current-request-id-
|
|
37
|
+
//# sourceMappingURL=current-request-id-CeQhRz9Q.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current-request-id-
|
|
1
|
+
{"version":3,"file":"current-request-id-CeQhRz9Q.cjs","names":["requestContext"],"sources":["../../../../../../../packages/devtools/src/current-request-id.ts"],"sourcesContent":["import { requestContext } from \"@warlock.js/core\";\n\n/**\n * The current request's id (core's `request.id`, threaded through\n * `AsyncLocalStorage`), or `undefined` outside a request — sources feed\n * devtools' background bucket in that case.\n *\n * Only ever reached through `./sources/*`, which the connector imports\n * dynamically inside `boot()` — by then core is already running, so this\n * static import never drags core's runtime graph into config-load time (see\n * `devtools-connector.ts`).\n */\nexport function currentRequestId(): string | undefined {\n try {\n return requestContext.getRequest()?.id;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAgB,mBAAuC;CACrD,IAAI;EACF,OAAOA,gCAAe,WAAW,CAAC,EAAE;CACtC,QAAQ;EACN;CACF;AACF"}
|
|
@@ -9,7 +9,7 @@ const DEVTOOLS_CONFIG_CODES = {
|
|
|
9
9
|
DT001: "Devtools production mode needs a dashboard path. Set DEVTOOLS_PATH (for example /ops-7f3k2q) or devtools.production.path.",
|
|
10
10
|
DT002: "The devtools dashboard path must start with \"/\", be at least 8 characters, use only letters, digits, \"-\", \"_\", \".\", \"~\" and \"/\", and not be \"/__warlock\".",
|
|
11
11
|
DT003: "Devtools production mode has no admin yet. Set DEVTOOLS_ADMIN_EMAIL with DEVTOOLS_ADMIN_PASSWORD or DEVTOOLS_SETUP_TOKEN, or run `warlock devtools:reset-admin --email <email>`.",
|
|
12
|
-
DT004: "DEVTOOLS_ADMIN_PASSWORD does not meet the password rules (
|
|
12
|
+
DT004: "DEVTOOLS_ADMIN_PASSWORD does not meet the password rules (the minimum length, at most 72 bytes, not a common password unless `passwords.rejectCommon` is false, not the email). Choose another one.",
|
|
13
13
|
DT005: "Devtools production mode stores its accounts in the database. Install @warlock.js/cascade and configure a database connection.",
|
|
14
14
|
DT006: "Devtools production mode encrypts two-factor secrets with the app key. Set encryption.key (64 hex characters) in src/config/encryption.ts.",
|
|
15
15
|
DT007: "A devtools production option has an invalid value. The message names the option and the accepted values.",
|
|
@@ -35,7 +35,7 @@ const DEVTOOLS_ERROR_MESSAGES = {
|
|
|
35
35
|
"auth.invalid-credentials": "The email or password is not correct. Check both and try again; after several failed tries, wait 15 minutes.",
|
|
36
36
|
"auth.invalid-code": "The code is not correct or has expired. Enter the current 6-digit code from your authenticator app, or a recovery code.",
|
|
37
37
|
"auth.invalid-setup-token": "This setup link is not valid. Use the link built from DEVTOOLS_SETUP_TOKEN, or run `warlock devtools:reset-admin`.",
|
|
38
|
-
"auth.password-too-short": "Use a password
|
|
38
|
+
"auth.password-too-short": "Use a longer password. The minimum length is set by passwords.minLength (8 characters by default).",
|
|
39
39
|
"auth.password-too-long": "Use a password of at most 72 bytes (about 72 letters).",
|
|
40
40
|
"auth.password-common": "This password is too common. Choose one that is harder to guess.",
|
|
41
41
|
"auth.password-same-as-email": "The password must not be your email address. Choose another one.",
|
|
@@ -110,7 +110,7 @@ function createErrorRef() {
|
|
|
110
110
|
*/
|
|
111
111
|
var DevtoolsApiError = class extends Error {
|
|
112
112
|
constructor(code, options = {}) {
|
|
113
|
-
super(DEVTOOLS_ERROR_MESSAGES[code], options.cause === void 0 ? {} : { cause: options.cause });
|
|
113
|
+
super(options.message ?? DEVTOOLS_ERROR_MESSAGES[code], options.cause === void 0 ? {} : { cause: options.cause });
|
|
114
114
|
this.name = "DevtoolsApiError";
|
|
115
115
|
this.code = code;
|
|
116
116
|
this.statusCode = DEVTOOLS_ERROR_STATUS[code];
|
|
@@ -176,4 +176,4 @@ Object.defineProperty(exports, "createErrorRef", {
|
|
|
176
176
|
return createErrorRef;
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
|
-
//# sourceMappingURL=errors-
|
|
179
|
+
//# sourceMappingURL=errors-BadbSDX8.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors-BadbSDX8.cjs","names":["randomBytes"],"sources":["../../../../../../../packages/devtools/src/production/errors.ts"],"sourcesContent":["import { randomBytes } from \"node:crypto\";\nimport type { DevtoolsApiErrorBody, DevtoolsErrorCode } from \"./contracts\";\n\n/**\n * Why production mode refused to start. Each code names one missing or\n * invalid setting; the message says which and how to fix it.\n */\nexport const DEVTOOLS_CONFIG_CODES = {\n DT001:\n \"Devtools production mode needs a dashboard path. Set DEVTOOLS_PATH (for example /ops-7f3k2q) or devtools.production.path.\",\n DT002:\n 'The devtools dashboard path must start with \"/\", be at least 8 characters, use only letters, digits, \"-\", \"_\", \".\", \"~\" and \"/\", and not be \"/__warlock\".',\n DT003:\n \"Devtools production mode has no admin yet. Set DEVTOOLS_ADMIN_EMAIL with DEVTOOLS_ADMIN_PASSWORD or DEVTOOLS_SETUP_TOKEN, or run `warlock devtools:reset-admin --email <email>`.\",\n DT004:\n \"DEVTOOLS_ADMIN_PASSWORD does not meet the password rules (the minimum length, at most 72 bytes, not a common password unless `passwords.rejectCommon` is false, not the email). Choose another one.\",\n DT005:\n \"Devtools production mode stores its accounts in the database. Install @warlock.js/cascade and configure a database connection.\",\n DT006:\n \"Devtools production mode encrypts two-factor secrets with the app key. Set encryption.key (64 hex characters) in src/config/encryption.ts.\",\n DT007:\n \"A devtools production option has an invalid value. The message names the option and the accepted values.\",\n DT008:\n \"The devtools tables are missing. Add devtoolsMigrations from @warlock.js/devtools/production to database.migrations in warlock.config.ts and run `warlock migrate`.\",\n DT009: \"Set either DEVTOOLS_ADMIN_PASSWORD or DEVTOOLS_SETUP_TOKEN, not both.\",\n DT010:\n \"DEVTOOLS_SETUP_TOKEN must be at least 32 characters. Generate one with: openssl rand -base64 32\",\n} as const;\n\n/** A production configuration error code (`DT001`–`DT010`). */\nexport type DevtoolsConfigCode = keyof typeof DEVTOOLS_CONFIG_CODES;\n\n/**\n * Thrown while the devtools connector boots in production when the monitor is\n * enabled but cannot start safely. It stops the app from booting, so a\n * misconfigured deploy fails at once instead of serving an unprotected\n * dashboard.\n */\nexport class DevtoolsProductionConfigError extends Error {\n public readonly code: DevtoolsConfigCode;\n\n public constructor(code: DevtoolsConfigCode, detail?: string) {\n super(`[${code}] ${detail ? `${detail} ` : \"\"}${DEVTOOLS_CONFIG_CODES[code]}`);\n this.name = \"DevtoolsProductionConfigError\";\n this.code = code;\n }\n}\n\n/** The message every API error code answers with: what failed and what to do next. */\nexport const DEVTOOLS_ERROR_MESSAGES: Record<DevtoolsErrorCode, string> = {\n \"auth.invalid-credentials\":\n \"The email or password is not correct. Check both and try again; after several failed tries, wait 15 minutes.\",\n \"auth.invalid-code\":\n \"The code is not correct or has expired. Enter the current 6-digit code from your authenticator app, or a recovery code.\",\n \"auth.invalid-setup-token\":\n \"This setup link is not valid. Use the link built from DEVTOOLS_SETUP_TOKEN, or run `warlock devtools:reset-admin`.\",\n \"auth.password-too-short\":\n \"Use a longer password. The minimum length is set by passwords.minLength (8 characters by default).\",\n \"auth.password-too-long\": \"Use a password of at most 72 bytes (about 72 letters).\",\n \"auth.password-common\": \"This password is too common. Choose one that is harder to guess.\",\n \"auth.password-same-as-email\": \"The password must not be your email address. Choose another one.\",\n \"auth.password-unchanged\": \"Choose a new password that differs from the current one.\",\n \"auth.wrong-current-password\": \"The current password is not correct. Enter it again.\",\n \"auth.busy\": \"The server is busy checking other sign-ins. Wait a few seconds and try again.\",\n \"invite.invalid\":\n \"This invite link is not valid, was already used, or has expired. Ask an admin for a new one.\",\n \"invite.email-taken\": \"An account with this email already exists. Sign in instead.\",\n \"account.not-found\": \"This account no longer exists. Reload the list.\",\n \"account.last-admin\": \"This is the last admin. Make another account an admin first.\",\n \"account.self\": \"You cannot do this to your own account. Ask another admin.\",\n \"account.last-factor\":\n \"This is your only second factor. Add another one (an authenticator app or a passkey) before removing it.\",\n \"role.forbidden\": \"Only admins can do this. Ask an admin.\",\n \"csrf.invalid\": \"This page is out of date. Reload the dashboard and try again.\",\n \"passkey.unavailable\":\n \"Passkeys are not available on this server (the @simplewebauthn/server package is not installed). Use an authenticator app instead.\",\n \"passkey.failed\": \"The passkey could not be verified. Try again, or use your authenticator app.\",\n \"explain.not-allowed\": \"Only admins can run EXPLAIN. Ask an admin.\",\n \"explain.unsupported\":\n \"This query cannot be explained: only PostgreSQL SELECT/WITH queries and MongoDB find, aggregate and count commands can.\",\n \"explain.elsewhere\":\n \"Only the instance that ran this query can explain it, and this request reached another one. Try again later or from that instance.\",\n \"explain.failed\":\n \"The database could not explain this query. The reference is in the server log.\",\n \"request.not-found\":\n \"This request is no longer stored. Requests are kept for a limited time (24 hours by default).\",\n \"request.invalid-filter\": \"A filter value is not valid. Check the status, method and dates.\",\n \"share.not-found\": \"This share link no longer exists or is already revoked. Reload the list.\",\n \"stream.too-many\":\n \"Too many live views are open for this session. Close another dashboard tab and reload.\",\n \"input.invalid\": \"Some fields are missing or not valid. Check the form and try again.\",\n \"server.error\":\n \"The dashboard could not complete this action. Try again; if it keeps failing, give your admin the reference shown.\",\n};\n\n/** The HTTP status each code answers with. */\nexport const DEVTOOLS_ERROR_STATUS: Record<DevtoolsErrorCode, number> = {\n \"auth.invalid-credentials\": 401,\n \"auth.invalid-code\": 401,\n \"auth.invalid-setup-token\": 401,\n \"auth.password-too-short\": 422,\n \"auth.password-too-long\": 422,\n \"auth.password-common\": 422,\n \"auth.password-same-as-email\": 422,\n \"auth.password-unchanged\": 422,\n \"auth.wrong-current-password\": 401,\n \"auth.busy\": 503,\n \"invite.invalid\": 410,\n \"invite.email-taken\": 409,\n \"account.not-found\": 404,\n \"account.last-admin\": 409,\n \"account.self\": 409,\n \"account.last-factor\": 409,\n \"role.forbidden\": 403,\n \"csrf.invalid\": 403,\n \"passkey.unavailable\": 501,\n \"passkey.failed\": 401,\n \"explain.not-allowed\": 403,\n \"explain.unsupported\": 400,\n \"explain.elsewhere\": 409,\n \"explain.failed\": 502,\n \"request.not-found\": 404,\n \"request.invalid-filter\": 400,\n \"share.not-found\": 404,\n \"stream.too-many\": 429,\n \"input.invalid\": 422,\n \"server.error\": 500,\n};\n\n/** A short reference id (8 characters, base32 alphabet) to quote to support. */\nexport function createErrorRef(): string {\n const alphabet = \"ABCDEFGHJKMNPQRSTUVWXYZ23456789\";\n const bytes = randomBytes(8);\n let ref = \"\";\n\n for (const byte of bytes) ref += alphabet[byte % alphabet.length];\n\n return ref;\n}\n\n/**\n * An error a dashboard route answers with. The production error handler turns\n * it into `{ error, code, ref?, instance? }` with `statusCode`.\n */\nexport class DevtoolsApiError extends Error {\n public readonly code: DevtoolsErrorCode;\n public readonly statusCode: number;\n public readonly ref: string | undefined;\n public readonly instance: string | undefined;\n\n public constructor(\n code: DevtoolsErrorCode,\n options: { ref?: string; instance?: string; cause?: unknown; message?: string } = {},\n ) {\n super(\n options.message ?? DEVTOOLS_ERROR_MESSAGES[code],\n options.cause === undefined ? {} : { cause: options.cause },\n );\n this.name = \"DevtoolsApiError\";\n this.code = code;\n this.statusCode = DEVTOOLS_ERROR_STATUS[code];\n this.ref = options.ref;\n this.instance = options.instance;\n }\n\n /** The JSON body this error answers with. */\n public toBody(): DevtoolsApiErrorBody {\n return {\n error: this.message,\n code: this.code,\n ...(this.ref === undefined ? {} : { ref: this.ref }),\n ...(this.instance === undefined ? {} : { instance: this.instance }),\n };\n }\n}\n\n/**\n * Raised by a store when a unique value is taken (an email) so callers can\n * answer with their own error code.\n */\nexport class DevtoolsStoreConflictError extends Error {\n public constructor(public readonly field: string) {\n super(`A devtools record with this ${field} already exists.`);\n this.name = \"DevtoolsStoreConflictError\";\n }\n}\n"],"mappings":";;;;;;;AAOA,MAAa,wBAAwB;CACnC,OACE;CACF,OACE;CACF,OACE;CACF,OACE;CACF,OACE;CACF,OACE;CACF,OACE;CACF,OACE;CACF,OAAO;CACP,OACE;AACJ;;;;;;;AAWA,IAAa,gCAAb,cAAmD,MAAM;CAGvD,AAAO,YAAY,MAA0B,QAAiB;EAC5D,MAAM,IAAI,KAAK,IAAI,SAAS,GAAG,OAAO,KAAK,KAAK,sBAAsB,OAAO;EAC7E,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;AAGA,MAAa,0BAA6D;CACxE,4BACE;CACF,qBACE;CACF,4BACE;CACF,2BACE;CACF,0BAA0B;CAC1B,wBAAwB;CACxB,+BAA+B;CAC/B,2BAA2B;CAC3B,+BAA+B;CAC/B,aAAa;CACb,kBACE;CACF,sBAAsB;CACtB,qBAAqB;CACrB,sBAAsB;CACtB,gBAAgB;CAChB,uBACE;CACF,kBAAkB;CAClB,gBAAgB;CAChB,uBACE;CACF,kBAAkB;CAClB,uBAAuB;CACvB,uBACE;CACF,qBACE;CACF,kBACE;CACF,qBACE;CACF,0BAA0B;CAC1B,mBAAmB;CACnB,mBACE;CACF,iBAAiB;CACjB,gBACE;AACJ;;AAGA,MAAa,wBAA2D;CACtE,4BAA4B;CAC5B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ACd;AACF"}
|
|
@@ -302,6 +302,7 @@ const COMMON_PASSWORDS = /* @__PURE__ */ new Set([
|
|
|
302
302
|
|
|
303
303
|
//#endregion
|
|
304
304
|
//#region ../../packages/devtools/src/production/auth/helpers.ts
|
|
305
|
+
/** The lowest `passwords.minLength` the options accept, and its default. */
|
|
305
306
|
const MIN_PASSWORD_LENGTH = 8;
|
|
306
307
|
const MAX_PASSWORD_BYTES = 72;
|
|
307
308
|
/** The alphabet of recovery codes and references: no 0, 1, 8, 9, I, L, O. */
|
|
@@ -309,15 +310,17 @@ const CODE_ALPHABET = "ABCDEFGHJKMNPQRSTUVWXYZ23456789";
|
|
|
309
310
|
/** Letters and digits that cannot be mistaken for each other. */
|
|
310
311
|
const TEMPORARY_ALPHABET = "ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
|
|
311
312
|
/**
|
|
312
|
-
* The password rules: at least
|
|
313
|
-
*
|
|
313
|
+
* The password rules: at least `rules.minLength` characters (default 8), at
|
|
314
|
+
* most 72 bytes (UTF-8), not in the built-in common list unless
|
|
315
|
+
* `rules.rejectCommon` is false (compared lower-cased), not equal to the email
|
|
314
316
|
* (lower-cased). Returns the failing rule's error code, or `null`.
|
|
315
317
|
*/
|
|
316
|
-
function checkPasswordPolicy(password, email) {
|
|
317
|
-
|
|
318
|
+
function checkPasswordPolicy(password, email, rules = {}) {
|
|
319
|
+
const minLength = rules.minLength ?? 8;
|
|
320
|
+
if (typeof password !== "string" || [...password].length < minLength) return "auth.password-too-short";
|
|
318
321
|
if (Buffer.byteLength(password, "utf8") > MAX_PASSWORD_BYTES) return "auth.password-too-long";
|
|
319
322
|
const lower = password.toLowerCase();
|
|
320
|
-
if (COMMON_PASSWORDS.has(lower)) return "auth.password-common";
|
|
323
|
+
if (rules.rejectCommon !== false && COMMON_PASSWORDS.has(lower)) return "auth.password-common";
|
|
321
324
|
if (email !== null && lower === email.trim().toLowerCase()) return "auth.password-same-as-email";
|
|
322
325
|
return null;
|
|
323
326
|
}
|
|
@@ -433,4 +436,4 @@ Object.defineProperty(exports, "safeEqual", {
|
|
|
433
436
|
return safeEqual;
|
|
434
437
|
}
|
|
435
438
|
});
|
|
436
|
-
//# sourceMappingURL=helpers-
|
|
439
|
+
//# sourceMappingURL=helpers-BcMBFy9v.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-7k_Q-abk.cjs","names":["randomBytes","createHash","randomInt","timingSafeEqual"],"sources":["../../../../../../../packages/devtools/src/production/auth/common-passwords.ts","../../../../../../../packages/devtools/src/production/auth/helpers.ts"],"sourcesContent":["/**\n * Passwords the monitor refuses (compared lower-cased). Short entries are\n * left out: the length rule already refuses them.\n */\nexport const COMMON_PASSWORDS: ReadonlySet<string> = new Set([\n \"password\",\n \"password1\",\n \"password12\",\n \"password123\",\n \"password1234\",\n \"passw0rd\",\n \"p@ssw0rd\",\n \"p@ssword\",\n \"password!\",\n \"password1!\",\n \"password2\",\n \"password3\",\n \"password01\",\n \"password11\",\n \"password99\",\n \"pa55word\",\n \"pa$$word\",\n \"12345678\",\n \"123456789\",\n \"1234567890\",\n \"12345678910\",\n \"123123123\",\n \"1234qwer\",\n \"1q2w3e4r\",\n \"1q2w3e4r5t\",\n \"1q2w3e4r5t6y\",\n \"1qaz2wsx\",\n \"1qaz2wsx3edc\",\n \"1qazxsw2\",\n \"qwertyui\",\n \"qwertyuiop\",\n \"qwerty123\",\n \"qwerty1234\",\n \"qwerty12\",\n \"qwertyuio\",\n \"qwerty123456\",\n \"qwerty12345\",\n \"asdfghjk\",\n \"asdfghjkl\",\n \"asdfgh123\",\n \"zxcvbnm1\",\n \"zxcvbnmasd\",\n \"zxcvbnm123\",\n \"abcd1234\",\n \"abcd12345\",\n \"abc12345\",\n \"abc123456\",\n \"abcdefgh\",\n \"abcdefg1\",\n \"abcdefgh1\",\n \"abcdefghi\",\n \"iloveyou\",\n \"iloveyou1\",\n \"iloveyou2\",\n \"iloveyou123\",\n \"letmein1\",\n \"letmein123\",\n \"letmein12\",\n \"welcome1\",\n \"welcome12\",\n \"welcome123\",\n \"welcome01\",\n \"welcome2\",\n \"monkey123\",\n \"monkey12\",\n \"dragon123\",\n \"dragon12\",\n \"master123\",\n \"master12\",\n \"shadow123\",\n \"shadow12\",\n \"sunshine\",\n \"sunshine1\",\n \"sunshine123\",\n \"princess\",\n \"princess1\",\n \"princess123\",\n \"football\",\n \"football1\",\n \"football123\",\n \"baseball\",\n \"baseball1\",\n \"baseball123\",\n \"basketball\",\n \"soccer123\",\n \"hockey123\",\n \"superman\",\n \"superman1\",\n \"superman123\",\n \"batman123\",\n \"batman12\",\n \"spiderman\",\n \"spiderman1\",\n \"trustno1\",\n \"trustno123\",\n \"trustnoone\",\n \"whatever\",\n \"whatever1\",\n \"whatever123\",\n \"freedom1\",\n \"freedom123\",\n \"starwars\",\n \"starwars1\",\n \"starwars123\",\n \"pokemon1\",\n \"pokemon123\",\n \"charlie1\",\n \"charlie123\",\n \"michael1\",\n \"michael123\",\n \"jessica1\",\n \"jessica123\",\n \"jennifer\",\n \"jennifer1\",\n \"daniel123\",\n \"daniel12\",\n \"thomas123\",\n \"hunter123\",\n \"hunter12\",\n \"hunter2hunter2\",\n \"hello123\",\n \"hello1234\",\n \"hello12345\",\n \"helloworld\",\n \"helloworld1\",\n \"hello@123\",\n \"admin123\",\n \"admin1234\",\n \"admin12345\",\n \"admin@123\",\n \"admin@1234\",\n \"administrator\",\n \"administrator1\",\n \"adminadmin\",\n \"adminadmin1\",\n \"admin2020\",\n \"admin2021\",\n \"admin2022\",\n \"admin2023\",\n \"admin2024\",\n \"admin2025\",\n \"admin2026\",\n \"root1234\",\n \"root12345\",\n \"toor1234\",\n \"test1234\",\n \"test12345\",\n \"test123456\",\n \"testtest\",\n \"testing123\",\n \"testing1\",\n \"guest123\",\n \"guest1234\",\n \"changeme\",\n \"changeme1\",\n \"changeme123\",\n \"change123\",\n \"default1\",\n \"default123\",\n \"secret123\",\n \"secret1234\",\n \"secretpassword\",\n \"mypassword\",\n \"mypassword1\",\n \"mypassword123\",\n \"mypass123\",\n \"mysecret1\",\n \"login123\",\n \"login1234\",\n \"access123\",\n \"access14\",\n \"qazwsxedc\",\n \"qazwsx123\",\n \"qazxswedc\",\n \"qweasdzxc\",\n \"qweasd123\",\n \"qweqweqwe\",\n \"asdasdasd\",\n \"asdasd123\",\n \"zaq12wsx\",\n \"zaq1zaq1\",\n \"zaq1xsw2\",\n \"aaaaaaaa\",\n \"aaaaaaa1\",\n \"11111111\",\n \"111111111\",\n \"1111111111\",\n \"00000000\",\n \"000000000\",\n \"0000000000\",\n \"12341234\",\n \"12121212\",\n \"11223344\",\n \"1122334455\",\n \"123321123\",\n \"12344321\",\n \"123456789a\",\n \"123456abc\",\n \"1234567a\",\n \"1234abcd\",\n \"987654321\",\n \"9876543210\",\n \"98765432\",\n \"88888888\",\n \"66666666\",\n \"55555555\",\n \"77777777\",\n \"99999999\",\n \"22222222\",\n \"33333333\",\n \"44444444\",\n \"pass1234\",\n \"pass12345\",\n \"pass123456\",\n \"passpass\",\n \"passpass1\",\n \"pass@123\",\n \"pass@1234\",\n \"mustang1\",\n \"mustang123\",\n \"ranger123\",\n \"harley123\",\n \"ferrari1\",\n \"porsche1\",\n \"computer\",\n \"computer1\",\n \"computer123\",\n \"internet\",\n \"internet1\",\n \"internet123\",\n \"windows1\",\n \"windows123\",\n \"microsoft\",\n \"linux123\",\n \"ubuntu123\",\n \"google123\",\n \"google12\",\n \"facebook\",\n \"facebook1\",\n \"facebook123\",\n \"twitter1\",\n \"youtube1\",\n \"instagram\",\n \"samsung1\",\n \"samsung123\",\n \"iphone123\",\n \"android1\",\n \"android123\",\n \"liverpool\",\n \"liverpool1\",\n \"manchester\",\n \"chelsea1\",\n \"arsenal1\",\n \"barcelona\",\n \"realmadrid1\",\n \"cheese123\",\n \"chocolate\",\n \"chocolate1\",\n \"cookie123\",\n \"banana123\",\n \"butterfly\",\n \"butterfly1\",\n \"flower123\",\n \"rainbow1\",\n \"rainbow123\",\n \"summer123\",\n \"summer2024\",\n \"summer2025\",\n \"winter123\",\n \"winter2024\",\n \"winter2025\",\n \"spring123\",\n \"autumn123\",\n \"january1\",\n \"february1\",\n \"december1\",\n \"qwerty@123\",\n \"abc@12345\",\n \"p@55w0rd\",\n \"p@$$w0rd\",\n \"passw0rd1\",\n \"passw0rd!\",\n \"warlock123\",\n \"warlock1\",\n \"devtools\",\n \"devtools1\",\n \"devtools123\",\n \"monitor123\",\n \"monitor1\",\n \"dashboard\",\n \"dashboard1\",\n \"dashboard123\",\n]);\n","import { createHash, randomBytes, randomInt, timingSafeEqual } from \"node:crypto\";\nimport type { DevtoolsErrorCode } from \"../contracts\";\nimport { COMMON_PASSWORDS } from \"./common-passwords\";\n\nconst MIN_PASSWORD_LENGTH = 8;\nconst MAX_PASSWORD_BYTES = 72;\n\n/** The alphabet of recovery codes and references: no 0, 1, 8, 9, I, L, O. */\nconst CODE_ALPHABET = \"ABCDEFGHJKMNPQRSTUVWXYZ23456789\";\n\n/** Letters and digits that cannot be mistaken for each other. */\nconst TEMPORARY_ALPHABET = \"ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789\";\n\n/**\n * The password rules: at least 8 characters, at most 72 bytes (UTF-8), not in\n * the built-in common list (compared lower-cased), not equal to the email\n * (lower-cased). Returns the failing rule's error code, or `null`.\n */\nexport function checkPasswordPolicy(\n password: string,\n email: string | null,\n): DevtoolsErrorCode | null {\n if (typeof password !== \"string\" || [...password].length < MIN_PASSWORD_LENGTH) {\n return \"auth.password-too-short\";\n }\n\n if (Buffer.byteLength(password, \"utf8\") > MAX_PASSWORD_BYTES) return \"auth.password-too-long\";\n\n const lower = password.toLowerCase();\n\n if (COMMON_PASSWORDS.has(lower)) return \"auth.password-common\";\n\n if (email !== null && lower === email.trim().toLowerCase()) return \"auth.password-same-as-email\";\n\n return null;\n}\n\n/** 32 random bytes, base64url (43 characters): session, CSRF and invite tokens. */\nexport function generateToken(): string {\n return randomBytes(32).toString(\"base64url\");\n}\n\n/** SHA-256 hex of a token: what the store keeps. */\nexport function hashToken(token: string): string {\n return createHash(\"sha256\").update(token).digest(\"hex\");\n}\n\n/**\n * A random temporary password for `warlock devtools:reset-admin`: 20\n * characters from an unambiguous alphabet, passes `checkPasswordPolicy`.\n */\nexport function generateTemporaryPassword(): string {\n for (;;) {\n let password = \"\";\n\n for (let index = 0; index < 20; index++) {\n password += TEMPORARY_ALPHABET[randomInt(TEMPORARY_ALPHABET.length)];\n }\n\n if (checkPasswordPolicy(password, null) === null) return password;\n }\n}\n\n/** Compares two strings in constant time (both are hashed first, so lengths do not leak). */\nexport function safeEqual(a: string, b: string): boolean {\n const left = createHash(\"sha256\").update(String(a)).digest();\n const right = createHash(\"sha256\").update(String(b)).digest();\n\n return timingSafeEqual(left, right);\n}\n\n/** Emails are compared trimmed and lower-cased. */\nexport function normalizeEmail(email: unknown): string {\n return typeof email === \"string\" ? email.trim().toLowerCase() : \"\";\n}\n\n/** A deliberately plain shape check; the invite flow is the real proof of ownership. */\nexport function isPlausibleEmail(email: string): boolean {\n return email.length <= 254 && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);\n}\n\n/** One recovery code, `xxxxx-xxxxx` from the unambiguous alphabet. */\nexport function generateRecoveryCode(): string {\n let code = \"\";\n\n for (let index = 0; index < 10; index++) {\n if (index === 5) code += \"-\";\n\n code += CODE_ALPHABET[randomInt(CODE_ALPHABET.length)];\n }\n\n return code;\n}\n\n/** The form a recovery code is hashed in: upper case, letters and digits only. */\nexport function normalizeRecoveryCode(code: string): string {\n return String(code)\n .toUpperCase()\n .replace(/[^A-Z0-9]/g, \"\");\n}\n\n/** SHA-256 hex of a normalized recovery code. */\nexport function hashRecoveryCode(code: string): string {\n return hashToken(normalizeRecoveryCode(code));\n}\n"],"mappings":";;;;;;;AAIA,MAAa,mCAAwC,IAAI,IAAI;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA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AAgB,eAAe,OAAwB;CACrD,OAAO,OAAO,UAAU,WAAW,MAAM,KAAK,CAAC,CAAC,YAAY,IAAI;AAClE;;AAGA,SAAgB,iBAAiB,OAAwB;CACvD,OAAO,MAAM,UAAU,OAAO,6BAA6B,KAAK,KAAK;AACvE;;AAGA,SAAgB,uBAA+B;CAC7C,IAAI,OAAO;CAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,IAAI,SAAS;EACvC,IAAI,UAAU,GAAG,QAAQ;EAEzB,QAAQ,kBAAcD,uBAAU,EAAoB;CACtD;CAEA,OAAO;AACT;;AAGA,SAAgB,sBAAsB,MAAsB;CAC1D,OAAO,OAAO,IAAI,CAAC,CAChB,YAAY,CAAC,CACb,QAAQ,cAAc,EAAE;AAC7B;;AAGA,SAAgB,iBAAiB,MAAsB;CACrD,OAAO,UAAU,sBAAsB,IAAI,CAAC;AAC9C"}
|
|
1
|
+
{"version":3,"file":"helpers-BcMBFy9v.cjs","names":["randomBytes","createHash","randomInt","timingSafeEqual"],"sources":["../../../../../../../packages/devtools/src/production/auth/common-passwords.ts","../../../../../../../packages/devtools/src/production/auth/helpers.ts"],"sourcesContent":["/**\n * Passwords the monitor refuses (compared lower-cased). Short entries are\n * left out: the length rule already refuses them.\n */\nexport const COMMON_PASSWORDS: ReadonlySet<string> = new Set([\n \"password\",\n \"password1\",\n \"password12\",\n \"password123\",\n \"password1234\",\n \"passw0rd\",\n \"p@ssw0rd\",\n \"p@ssword\",\n \"password!\",\n \"password1!\",\n \"password2\",\n \"password3\",\n \"password01\",\n \"password11\",\n \"password99\",\n \"pa55word\",\n \"pa$$word\",\n \"12345678\",\n \"123456789\",\n \"1234567890\",\n \"12345678910\",\n \"123123123\",\n \"1234qwer\",\n \"1q2w3e4r\",\n \"1q2w3e4r5t\",\n \"1q2w3e4r5t6y\",\n \"1qaz2wsx\",\n \"1qaz2wsx3edc\",\n \"1qazxsw2\",\n \"qwertyui\",\n \"qwertyuiop\",\n \"qwerty123\",\n \"qwerty1234\",\n \"qwerty12\",\n \"qwertyuio\",\n \"qwerty123456\",\n \"qwerty12345\",\n \"asdfghjk\",\n \"asdfghjkl\",\n \"asdfgh123\",\n \"zxcvbnm1\",\n \"zxcvbnmasd\",\n \"zxcvbnm123\",\n \"abcd1234\",\n \"abcd12345\",\n \"abc12345\",\n \"abc123456\",\n \"abcdefgh\",\n \"abcdefg1\",\n \"abcdefgh1\",\n \"abcdefghi\",\n \"iloveyou\",\n \"iloveyou1\",\n \"iloveyou2\",\n \"iloveyou123\",\n \"letmein1\",\n \"letmein123\",\n \"letmein12\",\n \"welcome1\",\n \"welcome12\",\n \"welcome123\",\n \"welcome01\",\n \"welcome2\",\n \"monkey123\",\n \"monkey12\",\n \"dragon123\",\n \"dragon12\",\n \"master123\",\n \"master12\",\n \"shadow123\",\n \"shadow12\",\n \"sunshine\",\n \"sunshine1\",\n \"sunshine123\",\n \"princess\",\n \"princess1\",\n \"princess123\",\n \"football\",\n \"football1\",\n \"football123\",\n \"baseball\",\n \"baseball1\",\n \"baseball123\",\n \"basketball\",\n \"soccer123\",\n \"hockey123\",\n \"superman\",\n \"superman1\",\n \"superman123\",\n \"batman123\",\n \"batman12\",\n \"spiderman\",\n \"spiderman1\",\n \"trustno1\",\n \"trustno123\",\n \"trustnoone\",\n \"whatever\",\n \"whatever1\",\n \"whatever123\",\n \"freedom1\",\n \"freedom123\",\n \"starwars\",\n \"starwars1\",\n \"starwars123\",\n \"pokemon1\",\n \"pokemon123\",\n \"charlie1\",\n \"charlie123\",\n \"michael1\",\n \"michael123\",\n \"jessica1\",\n \"jessica123\",\n \"jennifer\",\n \"jennifer1\",\n \"daniel123\",\n \"daniel12\",\n \"thomas123\",\n \"hunter123\",\n \"hunter12\",\n \"hunter2hunter2\",\n \"hello123\",\n \"hello1234\",\n \"hello12345\",\n \"helloworld\",\n \"helloworld1\",\n \"hello@123\",\n \"admin123\",\n \"admin1234\",\n \"admin12345\",\n \"admin@123\",\n \"admin@1234\",\n \"administrator\",\n \"administrator1\",\n \"adminadmin\",\n \"adminadmin1\",\n \"admin2020\",\n \"admin2021\",\n \"admin2022\",\n \"admin2023\",\n \"admin2024\",\n \"admin2025\",\n \"admin2026\",\n \"root1234\",\n \"root12345\",\n \"toor1234\",\n \"test1234\",\n \"test12345\",\n \"test123456\",\n \"testtest\",\n \"testing123\",\n \"testing1\",\n \"guest123\",\n \"guest1234\",\n \"changeme\",\n \"changeme1\",\n \"changeme123\",\n \"change123\",\n \"default1\",\n \"default123\",\n \"secret123\",\n \"secret1234\",\n \"secretpassword\",\n \"mypassword\",\n \"mypassword1\",\n \"mypassword123\",\n \"mypass123\",\n \"mysecret1\",\n \"login123\",\n \"login1234\",\n \"access123\",\n \"access14\",\n \"qazwsxedc\",\n \"qazwsx123\",\n \"qazxswedc\",\n \"qweasdzxc\",\n \"qweasd123\",\n \"qweqweqwe\",\n \"asdasdasd\",\n \"asdasd123\",\n \"zaq12wsx\",\n \"zaq1zaq1\",\n \"zaq1xsw2\",\n \"aaaaaaaa\",\n \"aaaaaaa1\",\n \"11111111\",\n \"111111111\",\n \"1111111111\",\n \"00000000\",\n \"000000000\",\n \"0000000000\",\n \"12341234\",\n \"12121212\",\n \"11223344\",\n \"1122334455\",\n \"123321123\",\n \"12344321\",\n \"123456789a\",\n \"123456abc\",\n \"1234567a\",\n \"1234abcd\",\n \"987654321\",\n \"9876543210\",\n \"98765432\",\n \"88888888\",\n \"66666666\",\n \"55555555\",\n \"77777777\",\n \"99999999\",\n \"22222222\",\n \"33333333\",\n \"44444444\",\n \"pass1234\",\n \"pass12345\",\n \"pass123456\",\n \"passpass\",\n \"passpass1\",\n \"pass@123\",\n \"pass@1234\",\n \"mustang1\",\n \"mustang123\",\n \"ranger123\",\n \"harley123\",\n \"ferrari1\",\n \"porsche1\",\n \"computer\",\n \"computer1\",\n \"computer123\",\n \"internet\",\n \"internet1\",\n \"internet123\",\n \"windows1\",\n \"windows123\",\n \"microsoft\",\n \"linux123\",\n \"ubuntu123\",\n \"google123\",\n \"google12\",\n \"facebook\",\n \"facebook1\",\n \"facebook123\",\n \"twitter1\",\n \"youtube1\",\n \"instagram\",\n \"samsung1\",\n \"samsung123\",\n \"iphone123\",\n \"android1\",\n \"android123\",\n \"liverpool\",\n \"liverpool1\",\n \"manchester\",\n \"chelsea1\",\n \"arsenal1\",\n \"barcelona\",\n \"realmadrid1\",\n \"cheese123\",\n \"chocolate\",\n \"chocolate1\",\n \"cookie123\",\n \"banana123\",\n \"butterfly\",\n \"butterfly1\",\n \"flower123\",\n \"rainbow1\",\n \"rainbow123\",\n \"summer123\",\n \"summer2024\",\n \"summer2025\",\n \"winter123\",\n \"winter2024\",\n \"winter2025\",\n \"spring123\",\n \"autumn123\",\n \"january1\",\n \"february1\",\n \"december1\",\n \"qwerty@123\",\n \"abc@12345\",\n \"p@55w0rd\",\n \"p@$$w0rd\",\n \"passw0rd1\",\n \"passw0rd!\",\n \"warlock123\",\n \"warlock1\",\n \"devtools\",\n \"devtools1\",\n \"devtools123\",\n \"monitor123\",\n \"monitor1\",\n \"dashboard\",\n \"dashboard1\",\n \"dashboard123\",\n]);\n","import { createHash, randomBytes, randomInt, timingSafeEqual } from \"node:crypto\";\nimport type { DevtoolsErrorCode } from \"../contracts\";\nimport { COMMON_PASSWORDS } from \"./common-passwords\";\n\n/** The lowest `passwords.minLength` the options accept, and its default. */\nexport const MIN_PASSWORD_LENGTH = 8;\nconst MAX_PASSWORD_BYTES = 72;\n\n/** The alphabet of recovery codes and references: no 0, 1, 8, 9, I, L, O. */\nconst CODE_ALPHABET = \"ABCDEFGHJKMNPQRSTUVWXYZ23456789\";\n\n/** Letters and digits that cannot be mistaken for each other. */\nconst TEMPORARY_ALPHABET = \"ABCDEFGHJKMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789\";\n\n/**\n * The password rules: at least `rules.minLength` characters (default 8), at\n * most 72 bytes (UTF-8), not in the built-in common list unless\n * `rules.rejectCommon` is false (compared lower-cased), not equal to the email\n * (lower-cased). Returns the failing rule's error code, or `null`.\n */\nexport function checkPasswordPolicy(\n password: string,\n email: string | null,\n rules: { minLength?: number; rejectCommon?: boolean } = {},\n): DevtoolsErrorCode | null {\n const minLength = rules.minLength ?? MIN_PASSWORD_LENGTH;\n\n if (typeof password !== \"string\" || [...password].length < minLength) {\n return \"auth.password-too-short\";\n }\n\n if (Buffer.byteLength(password, \"utf8\") > MAX_PASSWORD_BYTES) return \"auth.password-too-long\";\n\n const lower = password.toLowerCase();\n\n if (rules.rejectCommon !== false && COMMON_PASSWORDS.has(lower)) return \"auth.password-common\";\n\n if (email !== null && lower === email.trim().toLowerCase()) return \"auth.password-same-as-email\";\n\n return null;\n}\n\n/** 32 random bytes, base64url (43 characters): session, CSRF and invite tokens. */\nexport function generateToken(): string {\n return randomBytes(32).toString(\"base64url\");\n}\n\n/** SHA-256 hex of a token: what the store keeps. */\nexport function hashToken(token: string): string {\n return createHash(\"sha256\").update(token).digest(\"hex\");\n}\n\n/**\n * A random temporary password for `warlock devtools:reset-admin`: 20\n * characters from an unambiguous alphabet, passes `checkPasswordPolicy`.\n */\nexport function generateTemporaryPassword(): string {\n for (;;) {\n let password = \"\";\n\n for (let index = 0; index < 20; index++) {\n password += TEMPORARY_ALPHABET[randomInt(TEMPORARY_ALPHABET.length)];\n }\n\n if (checkPasswordPolicy(password, null) === null) return password;\n }\n}\n\n/** Compares two strings in constant time (both are hashed first, so lengths do not leak). */\nexport function safeEqual(a: string, b: string): boolean {\n const left = createHash(\"sha256\").update(String(a)).digest();\n const right = createHash(\"sha256\").update(String(b)).digest();\n\n return timingSafeEqual(left, right);\n}\n\n/** Emails are compared trimmed and lower-cased. */\nexport function normalizeEmail(email: unknown): string {\n return typeof email === \"string\" ? email.trim().toLowerCase() : \"\";\n}\n\n/** A deliberately plain shape check; the invite flow is the real proof of ownership. */\nexport function isPlausibleEmail(email: string): boolean {\n return email.length <= 254 && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);\n}\n\n/** One recovery code, `xxxxx-xxxxx` from the unambiguous alphabet. */\nexport function generateRecoveryCode(): string {\n let code = \"\";\n\n for (let index = 0; index < 10; index++) {\n if (index === 5) code += \"-\";\n\n code += CODE_ALPHABET[randomInt(CODE_ALPHABET.length)];\n }\n\n return code;\n}\n\n/** The form a recovery code is hashed in: upper case, letters and digits only. */\nexport function normalizeRecoveryCode(code: string): string {\n return String(code)\n .toUpperCase()\n .replace(/[^A-Z0-9]/g, \"\");\n}\n\n/** SHA-256 hex of a normalized recovery code. */\nexport function hashRecoveryCode(code: string): string {\n return hashToken(normalizeRecoveryCode(code));\n}\n"],"mappings":";;;;;;;AAIA,MAAa,mCAAwC,IAAI,IAAI;CAC3D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;ACpSD,MAAa,sBAAsB;AACnC,MAAM,qBAAqB;;AAG3B,MAAM,gBAAgB;;AAGtB,MAAM,qBAAqB;;;;;;;AAQ3B,SAAgB,oBACd,UACA,OACA,QAAwD,CAAC,GAC/B;CAC1B,MAAM,YAAY,MAAM;CAExB,IAAI,OAAO,aAAa,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAC,SAAS,WACzD,OAAO;CAGT,IAAI,OAAO,WAAW,UAAU,MAAM,IAAI,oBAAoB,OAAO;CAErE,MAAM,QAAQ,SAAS,YAAY;CAEnC,IAAI,MAAM,iBAAiB,SAAS,iBAAiB,IAAI,KAAK,GAAG,OAAO;CAExE,IAAI,UAAU,QAAQ,UAAU,MAAM,KAAK,CAAC,CAAC,YAAY,GAAG,OAAO;CAEnE,OAAO;AACT;;AAGA,SAAgB,gBAAwB;CACtC,WAAOA,yBAAY,EAAE,CAAC,CAAC,SAAS,WAAW;AAC7C;;AAGA,SAAgB,UAAU,OAAuB;CAC/C,W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#region ../../packages/devtools/src/production/stats/histogram.ts
|
|
5
5
|
/** An empty histogram over `DEVTOOLS_LATENCY_BUCKETS_MS`. */
|
|
6
6
|
function createHistogram() {
|
|
7
7
|
return {
|
|
8
|
-
counts: new Array(
|
|
8
|
+
counts: new Array(require_app_versions.DEVTOOLS_LATENCY_BUCKETS_MS.length + 1).fill(0),
|
|
9
9
|
count: 0,
|
|
10
10
|
sumMs: 0,
|
|
11
11
|
maxMs: 0
|
|
@@ -13,8 +13,8 @@ function createHistogram() {
|
|
|
13
13
|
}
|
|
14
14
|
/** The bucket index a duration falls in. */
|
|
15
15
|
function bucketIndex(durationMs) {
|
|
16
|
-
for (let index = 0; index <
|
|
17
|
-
return
|
|
16
|
+
for (let index = 0; index < require_app_versions.DEVTOOLS_LATENCY_BUCKETS_MS.length; index++) if (durationMs <= require_app_versions.DEVTOOLS_LATENCY_BUCKETS_MS[index]) return index;
|
|
17
|
+
return require_app_versions.DEVTOOLS_LATENCY_BUCKETS_MS.length;
|
|
18
18
|
}
|
|
19
19
|
/** Adds one duration to `histogram` in place. A negative or non-finite value counts as 0. */
|
|
20
20
|
function recordDuration(histogram, durationMs) {
|
|
@@ -47,7 +47,7 @@ function histogramQuantile(histogram, q) {
|
|
|
47
47
|
for (let index = 0; index < histogram.counts.length; index++) {
|
|
48
48
|
seen += histogram.counts[index] ?? 0;
|
|
49
49
|
if (seen >= rank) {
|
|
50
|
-
const bound =
|
|
50
|
+
const bound = require_app_versions.DEVTOOLS_LATENCY_BUCKETS_MS[index];
|
|
51
51
|
return bound === void 0 ? histogram.maxMs : Math.min(bound, histogram.maxMs);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -99,4 +99,4 @@ Object.defineProperty(exports, "shortId", {
|
|
|
99
99
|
return shortId;
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
|
-
//# sourceMappingURL=histogram-
|
|
102
|
+
//# sourceMappingURL=histogram-DTOGnNBW.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"histogram-
|
|
1
|
+
{"version":3,"file":"histogram-DTOGnNBW.cjs","names":["DEVTOOLS_LATENCY_BUCKETS_MS","createHash"],"sources":["../../../../../../../packages/devtools/src/production/stats/histogram.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { DEVTOOLS_LATENCY_BUCKETS_MS, type DevtoolsHistogram } from \"../contracts\";\n\n/** An empty histogram over `DEVTOOLS_LATENCY_BUCKETS_MS`. */\nexport function createHistogram(): DevtoolsHistogram {\n return {\n counts: new Array<number>(DEVTOOLS_LATENCY_BUCKETS_MS.length + 1).fill(0),\n count: 0,\n sumMs: 0,\n maxMs: 0,\n };\n}\n\n/** The bucket index a duration falls in. */\nexport function bucketIndex(durationMs: number): number {\n for (let index = 0; index < DEVTOOLS_LATENCY_BUCKETS_MS.length; index++) {\n if (durationMs <= (DEVTOOLS_LATENCY_BUCKETS_MS[index] as number)) return index;\n }\n\n return DEVTOOLS_LATENCY_BUCKETS_MS.length;\n}\n\n/** Adds one duration to `histogram` in place. A negative or non-finite value counts as 0. */\nexport function recordDuration(histogram: DevtoolsHistogram, durationMs: number): void {\n const value = Number.isFinite(durationMs) && durationMs > 0 ? durationMs : 0;\n const index = bucketIndex(value);\n\n histogram.counts[index] = (histogram.counts[index] ?? 0) + 1;\n histogram.count += 1;\n histogram.sumMs += value;\n\n if (value > histogram.maxMs) histogram.maxMs = value;\n}\n\n/** The sum of several histograms (exact: they share the bucket bounds). */\nexport function mergeHistograms(histograms: readonly DevtoolsHistogram[]): DevtoolsHistogram {\n const merged = createHistogram();\n\n for (const histogram of histograms) {\n for (let index = 0; index < merged.counts.length; index++) {\n merged.counts[index] = (merged.counts[index] ?? 0) + (histogram.counts[index] ?? 0);\n }\n\n merged.count += histogram.count;\n merged.sumMs += histogram.sumMs;\n\n if (histogram.maxMs > merged.maxMs) merged.maxMs = histogram.maxMs;\n }\n\n return merged;\n}\n\n/**\n * The `q` quantile (0–1) of a histogram: the upper bound of the bucket that\n * holds it, capped at the largest value seen. 0 for an empty histogram.\n */\nexport function histogramQuantile(histogram: DevtoolsHistogram, q: number): number {\n if (histogram.count === 0) return 0;\n\n const rank = Math.max(1, Math.ceil(Math.min(Math.max(q, 0), 1) * histogram.count));\n let seen = 0;\n\n for (let index = 0; index < histogram.counts.length; index++) {\n seen += histogram.counts[index] ?? 0;\n\n if (seen >= rank) {\n const bound = DEVTOOLS_LATENCY_BUCKETS_MS[index];\n\n return bound === undefined ? histogram.maxMs : Math.min(bound, histogram.maxMs);\n }\n }\n\n return histogram.maxMs;\n}\n\n/** The mean duration, 0 for an empty histogram. */\nexport function histogramMean(histogram: DevtoolsHistogram): number {\n return histogram.count === 0 ? 0 : histogram.sumMs / histogram.count;\n}\n\n/** The first 16 hex characters of SHA-256: the id of a query shape or an error fingerprint. */\nexport function shortId(value: string): string {\n return createHash(\"sha256\").update(value).digest(\"hex\").slice(0, 16);\n}\n"],"mappings":";;;;;AAIA,SAAgB,kBAAqC;CACnD,OAAO;EACL,QAAQ,IAAI,MAAcA,iDAA4B,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;EACxE,OAAO;EACP,OAAO;EACP,OAAO;CACT;AACF;;AAGA,SAAgB,YAAY,YAA4B;CACtD,KAAK,IAAI,QAAQ,GAAG,QAAQA,iDAA4B,QAAQ,SAC9D,IAAI,cAAeA,iDAA4B,QAAmB,OAAO;CAG3E,OAAOA,iDAA4B;AACrC;;AAGA,SAAgB,eAAe,WAA8B,YAA0B;CACrF,MAAM,QAAQ,OAAO,SAAS,UAAU,KAAK,aAAa,IAAI,aAAa;CAC3E,MAAM,QAAQ,YAAY,KAAK;CAE/B,UAAU,OAAO,UAAU,UAAU,OAAO,UAAU,KAAK;CAC3D,UAAU,SAAS;CACnB,UAAU,SAAS;CAEnB,IAAI,QAAQ,UAAU,OAAO,UAAU,QAAQ;AACjD;;AAGA,SAAgB,gBAAgB,YAA6D;CAC3F,MAAM,SAAS,gBAAgB;CAE/B,KAAK,MAAM,aAAa,YAAY;EAClC,KAAK,IAAI,QAAQ,GAAG,QAAQ,OAAO,OAAO,QAAQ,SAChD,OAAO,OAAO,UAAU,OAAO,OAAO,UAAU,MAAM,UAAU,OAAO,UAAU;EAGnF,OAAO,SAAS,UAAU;EAC1B,OAAO,SAAS,UAAU;EAE1B,IAAI,UAAU,QAAQ,OAAO,OAAO,OAAO,QAAQ,UAAU;CAC/D;CAEA,OAAO;AACT;;;;;AAMA,SAAgB,kBAAkB,WAA8B,GAAmB;CACjF,IAAI,UAAU,UAAU,GAAG,OAAO;CAElC,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,KAAK,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,UAAU,KAAK,CAAC;CACjF,IAAI,OAAO;CAEX,KAAK,IAAI,QAAQ,GAAG,QAAQ,UAAU,OAAO,QAAQ,SAAS;EAC5D,QAAQ,UAAU,OAAO,UAAU;EAEnC,IAAI,QAAQ,MAAM;GAChB,MAAM,QAAQA,iDAA4B;GAE1C,OAAO,UAAU,SAAY,UAAU,QAAQ,KAAK,IAAI,OAAO,UAAU,KAAK;EAChF;CACF;CAEA,OAAO,UAAU;AACnB;;AAGA,SAAgB,cAAc,WAAsC;CAClE,OAAO,UAAU,UAAU,IAAI,IAAI,UAAU,QAAQ,UAAU;AACjE;;AAGA,SAAgB,QAAQ,OAAuB;CAC7C,WAAOC,wBAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;AACrE"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_panels = require("./panels-
|
|
3
|
-
const require_errors = require("./errors-
|
|
1
|
+
const require_app_versions = require("./app-versions-DfpPZOI2.cjs");
|
|
2
|
+
const require_panels = require("./panels-D1ITm-jc.cjs");
|
|
3
|
+
const require_errors = require("./errors-BadbSDX8.cjs");
|
|
4
4
|
const require_ip = require("./ip-DbNhPOzi.cjs");
|
|
5
|
-
const require_helpers = require("./helpers-
|
|
6
|
-
const require_stream_route = require("./stream-route-
|
|
5
|
+
const require_helpers = require("./helpers-BcMBFy9v.cjs");
|
|
6
|
+
const require_stream_route = require("./stream-route-BqyAlfxQ.cjs");
|
|
7
7
|
let node_crypto = require("node:crypto");
|
|
8
8
|
let node_net = require("node:net");
|
|
9
9
|
|
|
@@ -768,7 +768,7 @@ function createDevtoolsShare(deps) {
|
|
|
768
768
|
const state = await store.state.read();
|
|
769
769
|
const since = Math.max(at - windowMs, state.failuresResetAt ?? 0);
|
|
770
770
|
const count = await store.audit.count({
|
|
771
|
-
types:
|
|
771
|
+
types: require_app_versions.DEVTOOLS_FAILURE_AUDIT_TYPES,
|
|
772
772
|
since,
|
|
773
773
|
ip
|
|
774
774
|
});
|
|
@@ -1356,4 +1356,4 @@ exports.mountProductionDevtools = mountProductionDevtools;
|
|
|
1356
1356
|
exports.productionRouteAccess = productionRouteAccess;
|
|
1357
1357
|
exports.resolveClient = resolveClient;
|
|
1358
1358
|
exports.sessionCookie = sessionCookie;
|
|
1359
|
-
//# sourceMappingURL=http-
|
|
1359
|
+
//# sourceMappingURL=http-Biauhqi0.cjs.map
|