@quatronic/sdk 0.7.0-test.3603305 → 0.7.1-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-F3NHTHFO.js → chunk-2AYDFLKR.js} +104 -6
- package/dist/chunk-2AYDFLKR.js.map +1 -0
- package/dist/cli/legacy/qdc-sourcemaps.js +6 -16
- package/dist/cli/sourcemaps.js +6 -16
- package/dist/integrations/index.d.ts +75 -3
- package/dist/integrations/index.js +4 -6
- package/dist/next/auth/index.js +152 -3
- package/dist/next/auth/index.js.map +1 -1
- package/dist/next/db/index.d.ts +1 -18
- package/dist/next/db/index.js +0 -25
- package/dist/next/db/index.js.map +1 -1
- package/dist/next/integrations/index.d.ts +1 -2
- package/dist/next/integrations/index.js +4 -6
- package/dist/next/security/index.d.ts +1 -23
- package/dist/next/security/index.js +55 -38
- package/dist/next/security/index.js.map +1 -1
- package/dist/next/sentry/register.js +13 -5
- package/dist/next/sentry/register.js.map +1 -1
- package/dist/node/integrations/index.d.ts +1 -2
- package/dist/node/integrations/index.js +4 -6
- package/package.json +4 -26
- package/dist/chunk-F3NHTHFO.js.map +0 -1
- package/dist/chunk-P7HNHLW7.js +0 -65
- package/dist/chunk-P7HNHLW7.js.map +0 -1
- package/dist/chunk-QMOZDE3U.js +0 -158
- package/dist/chunk-QMOZDE3U.js.map +0 -1
- package/dist/chunk-TOBGX4CZ.js +0 -109
- package/dist/chunk-TOBGX4CZ.js.map +0 -1
- package/dist/chunk-WU7N4PET.js +0 -20
- package/dist/chunk-WU7N4PET.js.map +0 -1
- package/dist/mail/index.d.ts +0 -9
- package/dist/mail/index.js +0 -26
- package/dist/mail/index.js.map +0 -1
- package/dist/next/boot/index.d.ts +0 -33
- package/dist/next/boot/index.js +0 -21
- package/dist/next/boot/index.js.map +0 -1
- package/dist/next/global-error/index.d.ts +0 -9
- package/dist/next/global-error/index.js +0 -17
- package/dist/next/global-error/index.js.map +0 -1
- package/dist/next/platform/index.d.ts +0 -19
- package/dist/next/platform/index.js +0 -44
- package/dist/next/platform/index.js.map +0 -1
- package/dist/node/boot/index.d.ts +0 -9
- package/dist/node/boot/index.js +0 -13
- package/dist/node/boot/index.js.map +0 -1
- package/dist/node-Z7ERWJDZ.js +0 -46
- package/dist/node-Z7ERWJDZ.js.map +0 -1
- package/dist/types-CAwj03sM.d.ts +0 -75
- package/migrations/bootstrap-qore-env/codemod.mjs +0 -77
- package/migrations/bootstrap-qore-env/instructions.md +0 -28
- package/migrations/bootstrap-qore-env/meta.json +0 -7
- package/migrations/global-error/codemod.mjs +0 -28
- package/migrations/global-error/instructions.md +0 -26
- package/migrations/global-error/meta.json +0 -7
- package/migrations/local-db-port/codemod.mjs +0 -61
- package/migrations/local-db-port/instructions.md +0 -35
- package/migrations/local-db-port/meta.json +0 -7
- package/migrations/mail-reexport/codemod.mjs +0 -64
- package/migrations/mail-reexport/instructions.md +0 -27
- package/migrations/mail-reexport/meta.json +0 -7
- package/migrations/platform-routes/codemod.mjs +0 -45
- package/migrations/platform-routes/instructions.md +0 -30
- package/migrations/platform-routes/meta.json +0 -7
- package/migrations/qore-boot/codemod.mjs +0 -261
- package/migrations/qore-boot/instructions.md +0 -74
- package/migrations/qore-boot/meta.json +0 -7
- package/migrations/qore-proxy/codemod.mjs +0 -88
- package/migrations/qore-proxy/instructions.md +0 -56
- package/migrations/qore-proxy/meta.json +0 -7
- package/migrations/run.mjs +0 -322
- package/migrations/sourcemaps-finalize/codemod.mjs +0 -63
- package/migrations/sourcemaps-finalize/instructions.md +0 -56
- package/migrations/sourcemaps-finalize/meta.json +0 -7
- package/workspace-requirements.json +0 -4
package/dist/chunk-P7HNHLW7.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
parseJsonBounded
|
|
3
|
-
} from "./chunk-FUPTRHT7.js";
|
|
4
|
-
|
|
5
|
-
// src/security-core/cspReport.ts
|
|
6
|
-
var DEFAULT_MAX_BYTES = 16 * 1024;
|
|
7
|
-
function asRecord(value) {
|
|
8
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
9
|
-
}
|
|
10
|
-
function asString(value) {
|
|
11
|
-
return typeof value === "string" && value.length > 0 ? value.slice(0, 500) : void 0;
|
|
12
|
-
}
|
|
13
|
-
function collectReports(payload) {
|
|
14
|
-
const single = asRecord(payload);
|
|
15
|
-
if (single) {
|
|
16
|
-
const nested = asRecord(single["csp-report"]);
|
|
17
|
-
return nested ? [nested] : [single];
|
|
18
|
-
}
|
|
19
|
-
if (Array.isArray(payload)) {
|
|
20
|
-
return payload.map((entry) => asRecord(asRecord(entry)?.["body"])).filter((report) => report !== void 0);
|
|
21
|
-
}
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
function readCspReport(report) {
|
|
25
|
-
return {
|
|
26
|
-
documentUri: asString(report["document-uri"] ?? report["documentURL"]),
|
|
27
|
-
blockedUri: asString(report["blocked-uri"] ?? report["blockedURL"]),
|
|
28
|
-
effectiveDirective: asString(report["effective-directive"] ?? report["effectiveDirective"]),
|
|
29
|
-
disposition: asString(report["disposition"])
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
var QORE_CSP_REPORT_URI = "/api/qore/csp-report";
|
|
33
|
-
function createCspReportRoute(options) {
|
|
34
|
-
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
35
|
-
const log = options.log;
|
|
36
|
-
return async function POST(request) {
|
|
37
|
-
const noContent = () => new Response(null, { status: 204 });
|
|
38
|
-
let body;
|
|
39
|
-
try {
|
|
40
|
-
body = await request.text();
|
|
41
|
-
} catch {
|
|
42
|
-
return noContent();
|
|
43
|
-
}
|
|
44
|
-
if (body.length === 0 || body.length > maxBytes) {
|
|
45
|
-
return noContent();
|
|
46
|
-
}
|
|
47
|
-
let payload;
|
|
48
|
-
try {
|
|
49
|
-
payload = parseJsonBounded(body, { maxBytes, maxDepth: 8 });
|
|
50
|
-
} catch {
|
|
51
|
-
return noContent();
|
|
52
|
-
}
|
|
53
|
-
for (const report of collectReports(payload)) {
|
|
54
|
-
log.warn({ event: "csp.violation", ...readCspReport(report) });
|
|
55
|
-
}
|
|
56
|
-
return noContent();
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
readCspReport,
|
|
62
|
-
QORE_CSP_REPORT_URI,
|
|
63
|
-
createCspReportRoute
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=chunk-P7HNHLW7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/security-core/cspReport.ts"],"sourcesContent":["import { parseJsonBounded } from \"./parse\"\n\n/**\n * The `report-uri` endpoint for the QDC Content-Security-Policy.\n *\n * The policy ships report-only for its first release, so this endpoint is the\n * evidence: it records what the policy *would* have blocked, so the policy can\n * be corrected before it enforces. It collects and nothing else — one log line\n * per report, forwarded nowhere.\n *\n * It is unauthenticated by necessity: a browser posts a report with no session\n * and no CSRF token. So it reads a small bounded body and logs a fixed set of\n * fields rather than whatever the report happens to contain, and it answers 204\n * whatever happens — an error status only teaches a caller that the endpoint is\n * worth probing.\n */\n\n/** A report is a few hundred bytes. Anything near this is not a browser. */\nconst DEFAULT_MAX_BYTES = 16 * 1024\n\n/** Just enough of a logger. `@/lib/log` in a generated app satisfies it. */\nexport interface CspReportLogger {\n warn(fields: Record<string, unknown>): void\n}\n\n/** The fields read off a violation report, whichever wire format it arrived in. */\nexport interface CspReportFields {\n documentUri?: string\n blockedUri?: string\n effectiveDirective?: string\n disposition?: string\n}\n\nexport interface CspReportRouteOptions {\n /** Where the violations go. One `warn` per report, `event: \"csp.violation\"`. */\n log: CspReportLogger\n /** Request bodies above this are dropped unread. Default: 16 KiB. */\n maxBytes?: number\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : undefined\n}\n\nfunction asString(value: unknown): string | undefined {\n return typeof value === \"string\" && value.length > 0 ? value.slice(0, 500) : undefined\n}\n\n/** Both wire formats: `report-uri`'s `{\"csp-report\": {…}}` and `report-to`'s array. */\nfunction collectReports(payload: unknown): Record<string, unknown>[] {\n const single = asRecord(payload)\n if (single) {\n const nested = asRecord(single[\"csp-report\"])\n return nested ? [nested] : [single]\n }\n if (Array.isArray(payload)) {\n return payload\n .map((entry) => asRecord(asRecord(entry)?.[\"body\"]))\n .filter((report): report is Record<string, unknown> => report !== undefined)\n }\n return []\n}\n\n/** The two field namings, hyphenated (`report-uri`) and camel (`report-to`). */\nexport function readCspReport(report: Record<string, unknown>): CspReportFields {\n return {\n documentUri: asString(report[\"document-uri\"] ?? report[\"documentURL\"]),\n blockedUri: asString(report[\"blocked-uri\"] ?? report[\"blockedURL\"]),\n effectiveDirective: asString(report[\"effective-directive\"] ?? report[\"effectiveDirective\"]),\n disposition: asString(report[\"disposition\"]),\n }\n}\n\n/** Where the platform's catch-all route (`@quatronic/sdk/next/platform`) receives CSP reports. */\nexport const QORE_CSP_REPORT_URI = \"/api/qore/csp-report\"\n\n/**\n * Build the `POST` handler for `src/app/api/csp-report/route.ts`.\n *\n * The route file still declares `runtime` and `dynamic` itself: Next reads\n * those two exports statically, off the route module, and does not follow them\n * through a package boundary.\n */\nexport function createCspReportRoute(\n options: CspReportRouteOptions,\n): (request: Request) => Promise<Response> {\n const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES\n const log = options.log\n\n return async function POST(request: Request): Promise<Response> {\n const noContent = () => new Response(null, { status: 204 })\n\n let body: string\n try {\n body = await request.text()\n } catch {\n return noContent()\n }\n if (body.length === 0 || body.length > maxBytes) {\n return noContent()\n }\n\n let payload: unknown\n try {\n payload = parseJsonBounded(body, { maxBytes, maxDepth: 8 })\n } catch {\n return noContent()\n }\n\n for (const report of collectReports(payload)) {\n log.warn({ event: \"csp.violation\", ...readCspReport(report) })\n }\n return noContent()\n }\n}\n"],"mappings":";;;;;AA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AAK,KAAK,SAAS,UAAU;AAC/C,aAAO,UAAU;AAAA,IACnB;AAEA,QAAI;AACJ,QAAI;AACF,gBAAU,iBAAiB,MAAM,EAAE,UAAU,UAAU,EAAE,CAAC;AAAA,IAC5D,QAAQ;AACN,aAAO,UAAU;AAAA,IACnB;AAEA,eAAW,UAAU,eAAe,OAAO,GAAG;AAC5C,UAAI,KAAK,EAAE,OAAO,iBAAiB,GAAG,cAAc,MAAM,EAAE,CAAC;AAAA,IAC/D;AACA,WAAO,UAAU;AAAA,EACnB;AACF;","names":[]}
|
package/dist/chunk-QMOZDE3U.js
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
grantRuntimeDefaultPrivileges
|
|
3
|
-
} from "./chunk-BJN7YE63.js";
|
|
4
|
-
|
|
5
|
-
// src/auth-core/migrate.ts
|
|
6
|
-
import { sql } from "drizzle-orm";
|
|
7
|
-
var MIGRATION_0001_SCHEMA = `
|
|
8
|
-
CREATE SCHEMA IF NOT EXISTS auth;
|
|
9
|
-
`;
|
|
10
|
-
var MIGRATION_0001_TABLES = `
|
|
11
|
-
CREATE TABLE IF NOT EXISTS auth.sessions (
|
|
12
|
-
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
13
|
-
user_sub varchar(64) NOT NULL,
|
|
14
|
-
user_email varchar(320),
|
|
15
|
-
organization_id varchar(64),
|
|
16
|
-
organization_alias varchar(255),
|
|
17
|
-
access_token text NOT NULL,
|
|
18
|
-
access_expires_at timestamptz NOT NULL,
|
|
19
|
-
refresh_ct bytea NOT NULL,
|
|
20
|
-
refresh_iv bytea NOT NULL,
|
|
21
|
-
refresh_expires_at timestamptz NOT NULL,
|
|
22
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
23
|
-
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
24
|
-
revoked_at timestamptz
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
CREATE INDEX IF NOT EXISTS ix_auth_sessions_user_sub
|
|
28
|
-
ON auth.sessions(user_sub) WHERE revoked_at IS NULL;
|
|
29
|
-
|
|
30
|
-
CREATE TABLE IF NOT EXISTS auth.login_state (
|
|
31
|
-
state varchar(128) PRIMARY KEY,
|
|
32
|
-
code_verifier varchar(255) NOT NULL,
|
|
33
|
-
redirect_path text NOT NULL DEFAULT '/',
|
|
34
|
-
created_at timestamptz NOT NULL DEFAULT now(),
|
|
35
|
-
expires_at timestamptz NOT NULL
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
CREATE INDEX IF NOT EXISTS ix_auth_login_state_expires
|
|
39
|
-
ON auth.login_state(expires_at);
|
|
40
|
-
`;
|
|
41
|
-
var MIGRATION_0002_ID_TOKEN = `
|
|
42
|
-
ALTER TABLE auth.sessions ADD COLUMN IF NOT EXISTS id_token text;
|
|
43
|
-
`;
|
|
44
|
-
var MIGRATION_0003_FORCED_REAUTH = `
|
|
45
|
-
ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS forced_reauth boolean NOT NULL DEFAULT false;
|
|
46
|
-
`;
|
|
47
|
-
var MIGRATION_0004_NONCE = `
|
|
48
|
-
ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS nonce varchar(128);
|
|
49
|
-
`;
|
|
50
|
-
var MIGRATION_0005_RETRIED = `
|
|
51
|
-
ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS retried boolean NOT NULL DEFAULT false;
|
|
52
|
-
`;
|
|
53
|
-
var MIGRATION_0006_PENDING_CONFIRM = `
|
|
54
|
-
ALTER TABLE auth.sessions
|
|
55
|
-
ADD COLUMN IF NOT EXISTS pending_identity_confirm boolean NOT NULL DEFAULT false;
|
|
56
|
-
`;
|
|
57
|
-
var MIGRATION_0007_EXPECTED_IDENTITY = `
|
|
58
|
-
ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS expected_sub varchar(64);
|
|
59
|
-
ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS expected_email varchar(320);
|
|
60
|
-
`;
|
|
61
|
-
async function probe(db, expression) {
|
|
62
|
-
const result = await db.execute(
|
|
63
|
-
sql.raw(`SELECT (${expression}) AS "applied"`)
|
|
64
|
-
);
|
|
65
|
-
return result.rows[0]?.applied === true;
|
|
66
|
-
}
|
|
67
|
-
var schemaExists = (schema) => (db) => probe(db, `EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = '${schema}')`);
|
|
68
|
-
var relationsExist = (...relations) => (db) => {
|
|
69
|
-
const tuples = relations.map(([schema, name]) => `('${schema}','${name}')`).join(", ");
|
|
70
|
-
return probe(
|
|
71
|
-
db,
|
|
72
|
-
`(SELECT count(*) FROM pg_class c
|
|
73
|
-
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
74
|
-
WHERE (n.nspname, c.relname) IN (${tuples})) = ${relations.length}`
|
|
75
|
-
);
|
|
76
|
-
};
|
|
77
|
-
var columnsExist = (...columns) => (db) => {
|
|
78
|
-
const tuples = columns.map(([schema, table, column]) => `('${schema}','${table}','${column}')`).join(", ");
|
|
79
|
-
return probe(
|
|
80
|
-
db,
|
|
81
|
-
`(SELECT count(*) FROM pg_attribute a
|
|
82
|
-
JOIN pg_class c ON c.oid = a.attrelid
|
|
83
|
-
JOIN pg_namespace n ON n.oid = c.relnamespace
|
|
84
|
-
WHERE a.attnum > 0 AND NOT a.attisdropped
|
|
85
|
-
AND (n.nspname, c.relname, a.attname) IN (${tuples})) = ${columns.length}`
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
var MIGRATIONS = [
|
|
89
|
-
{
|
|
90
|
-
name: "0001_init:schema",
|
|
91
|
-
sql: MIGRATION_0001_SCHEMA,
|
|
92
|
-
isApplied: schemaExists("auth")
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: "0001_init:tables",
|
|
96
|
-
sql: MIGRATION_0001_TABLES,
|
|
97
|
-
isApplied: relationsExist(
|
|
98
|
-
["auth", "sessions"],
|
|
99
|
-
["auth", "ix_auth_sessions_user_sub"],
|
|
100
|
-
["auth", "login_state"],
|
|
101
|
-
["auth", "ix_auth_login_state_expires"]
|
|
102
|
-
)
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: "0002_id_token",
|
|
106
|
-
sql: MIGRATION_0002_ID_TOKEN,
|
|
107
|
-
isApplied: columnsExist(["auth", "sessions", "id_token"])
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: "0003_forced_reauth",
|
|
111
|
-
sql: MIGRATION_0003_FORCED_REAUTH,
|
|
112
|
-
isApplied: columnsExist(["auth", "login_state", "forced_reauth"])
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
name: "0004_nonce",
|
|
116
|
-
sql: MIGRATION_0004_NONCE,
|
|
117
|
-
isApplied: columnsExist(["auth", "login_state", "nonce"])
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: "0005_retried",
|
|
121
|
-
sql: MIGRATION_0005_RETRIED,
|
|
122
|
-
isApplied: columnsExist(["auth", "login_state", "retried"])
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
name: "0006_pending_confirm",
|
|
126
|
-
sql: MIGRATION_0006_PENDING_CONFIRM,
|
|
127
|
-
isApplied: columnsExist(["auth", "sessions", "pending_identity_confirm"])
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: "0007_expected_identity",
|
|
131
|
-
sql: MIGRATION_0007_EXPECTED_IDENTITY,
|
|
132
|
-
isApplied: columnsExist(
|
|
133
|
-
["auth", "login_state", "expected_sub"],
|
|
134
|
-
["auth", "login_state", "expected_email"]
|
|
135
|
-
)
|
|
136
|
-
}
|
|
137
|
-
];
|
|
138
|
-
async function runAuthMigrations(db, opts = {}) {
|
|
139
|
-
for (const migration of MIGRATIONS) {
|
|
140
|
-
try {
|
|
141
|
-
if (await migration.isApplied(db)) {
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
await db.execute(sql.raw(migration.sql));
|
|
145
|
-
} catch (err) {
|
|
146
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
147
|
-
throw new Error(`auth migration "${migration.name}" failed: ${message}`, { cause: err });
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (opts.runtimeRole) {
|
|
151
|
-
await grantRuntimeDefaultPrivileges(db, "auth", opts.runtimeRole);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export {
|
|
156
|
-
runAuthMigrations
|
|
157
|
-
};
|
|
158
|
-
//# sourceMappingURL=chunk-QMOZDE3U.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auth-core/migrate.ts"],"sourcesContent":["import { sql } from \"drizzle-orm\"\nimport type { NodePgDatabase } from \"drizzle-orm/node-postgres\"\nimport { grantRuntimeDefaultPrivileges } from \"../db-core/migration-db\"\n\n// Migrations are inlined as string constants rather than read from .sql files\n// at runtime. A runtime `readFile` does not survive bundlers that only trace\n// JS — notably Next.js standalone output, where the .sql is omitted and the\n// read ENOENTs, crashing the instrumentation hook and 500-ing the whole app.\n// Inlining keeps the SQL in the bundled JS so it works in every consumer.\n\n// Split out of what used to be a single MIGRATION_0001_INIT on purpose, and\n// the reason generalises to every statement below it: **Postgres checks the\n// connecting role's privileges before it evaluates `IF NOT EXISTS`.** So an\n// already-applied statement is not a no-op for a role that lacks the right —\n// it is an error:\n//\n// - `CREATE SCHEMA IF NOT EXISTS auth` needs CREATE on the *database* →\n// `permission denied for database <db>` (SQLSTATE 42501)\n// - `CREATE INDEX IF NOT EXISTS` and `ALTER TABLE ... ADD COLUMN IF NOT\n// EXISTS` need *ownership* of the table → `must be owner of table\n// sessions` (also 42501)\n//\n// That is the normal shape of a least-privileged runtime role against an\n// already-provisioned database, and because migrations run in order one such\n// error aborts every statement after it. It has now bitten staging twice: the\n// first time `login_state.forced_reauth` never landed and every\n// `/api/auth/login` 500'd; the second time `0001_init:tables` failed on its\n// `CREATE INDEX` with `must be owner of table sessions`, again blocking every\n// later ALTER even though there was nothing at all to do.\n//\n// So each migration below carries an `isApplied` catalog probe and the runner\n// skips it when its effect is already present. Catalog lookups need nothing\n// beyond CONNECT, so a role with only DML inside an up-to-date `auth` schema\n// gets through cleanly, while a migration that genuinely still has work to do\n// is attempted and — if the role cannot do it — fails loudly, by name.\nconst MIGRATION_0001_SCHEMA = `\nCREATE SCHEMA IF NOT EXISTS auth;\n`\n\nconst MIGRATION_0001_TABLES = `\nCREATE TABLE IF NOT EXISTS auth.sessions (\n id uuid PRIMARY KEY DEFAULT gen_random_uuid(),\n user_sub varchar(64) NOT NULL,\n user_email varchar(320),\n organization_id varchar(64),\n organization_alias varchar(255),\n access_token text NOT NULL,\n access_expires_at timestamptz NOT NULL,\n refresh_ct bytea NOT NULL,\n refresh_iv bytea NOT NULL,\n refresh_expires_at timestamptz NOT NULL,\n created_at timestamptz NOT NULL DEFAULT now(),\n updated_at timestamptz NOT NULL DEFAULT now(),\n revoked_at timestamptz\n);\n\nCREATE INDEX IF NOT EXISTS ix_auth_sessions_user_sub\n ON auth.sessions(user_sub) WHERE revoked_at IS NULL;\n\nCREATE TABLE IF NOT EXISTS auth.login_state (\n state varchar(128) PRIMARY KEY,\n code_verifier varchar(255) NOT NULL,\n redirect_path text NOT NULL DEFAULT '/',\n created_at timestamptz NOT NULL DEFAULT now(),\n expires_at timestamptz NOT NULL\n);\n\nCREATE INDEX IF NOT EXISTS ix_auth_login_state_expires\n ON auth.login_state(expires_at);\n`\n\n// The KC ID token, so RP-initiated logout can pass it as `id_token_hint` —\n// without it, Keycloak's end-session endpoint falls back to showing a logout\n// confirmation page. Nullable: existing sessions predate this column until\n// their next login or token refresh backfills it.\nconst MIGRATION_0002_ID_TOKEN = `\nALTER TABLE auth.sessions ADD COLUMN IF NOT EXISTS id_token text;\n`\n\n// Records that this login asked Keycloak to re-authenticate (prompt=login +\n// max_age=0). The callback needs it to know whether the ID token's auth_time\n// MUST prove a fresh authentication (OIDC 3.1.2.1) — without the flag it cannot\n// tell a forced login from an ordinary SSO continuation.\nconst MIGRATION_0003_FORCED_REAUTH = `\nALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS forced_reauth boolean NOT NULL DEFAULT false;\n`\n\n// OIDC 3.1.3.7 (11): the nonce sent on the authorization request must be\n// checked against the ID token's claim. Nullable because rows written by an\n// older build have none; the callback treats a null nonce on the row as\n// \"nothing to check\" so an in-flight login survives the deploy.\nconst MIGRATION_0004_NONCE = `\nALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS nonce varchar(128);\n`\n\n// Bounds the one-and-only restart the callback grants on Keycloak's explicit\n// \"start over\" signals (authentication_expired / login_required). The\n// callback URL is Keycloak's fixed redirect_uri, so Keycloak never echoes our\n// own query parameters back to it — a guard read off the callback's query\n// string can never fire in production. The restarted login (our own request\n// to /api/auth/login?retried=1) stamps this column on the NEW row instead, so\n// the second callback can see it on the row rather than in a URL Keycloak\n// controls. NOT NULL DEFAULT false: every row, old or new, starts un-retried.\nconst MIGRATION_0005_RETRIED = `\nALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS retried boolean NOT NULL DEFAULT false;\n`\n\n// A session created for an identity that did not match what the login expected\n// exists, holds real tokens, and grants nothing until a human confirms it.\n//\n// DELIBERATELY `DEFAULT false` rather than a nullable column with a backfill:\n// these migrations re-run on every app start, so an `UPDATE ... WHERE\n// pending_identity_confirm IS NULL` would confirm every row still awaiting a\n// human on the next deploy — silently adopting exactly the identity this\n// mechanism exists to stop. A default means pre-existing rows are already\n// confirmed, which is correct: they were issued under the old rules.\nconst MIGRATION_0006_PENDING_CONFIRM = `\nALTER TABLE auth.sessions\n ADD COLUMN IF NOT EXISTS pending_identity_confirm boolean NOT NULL DEFAULT false;\n`\n\n// Who this login was supposed to end up as: the subject of the session being\n// replaced, and/or the address the user typed. The callback compares Keycloak's\n// answer against these instead of adopting whatever comes back. Nullable: a\n// clean first login on a fresh browser expects nobody in particular.\nconst MIGRATION_0007_EXPECTED_IDENTITY = `\nALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS expected_sub varchar(64);\nALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS expected_email varchar(320);\n`\n\ninterface Migration {\n // Named so a failure can say *which* statement broke — see the catch below.\n readonly name: string\n readonly sql: string\n // \"Is this migration's effect already present?\" Answered from the catalogs\n // only, so it never needs a privilege the migration itself would need. A\n // partially-applied migration must answer `false` (the SQL is written to be\n // idempotent, so re-running the applied half is harmless).\n readonly isApplied: (db: NodePgDatabase) => Promise<boolean>\n // A migration may only add to the schema: a prod rollback keeps the\n // database, and the previous release must still work on it\n // (scripts/migration-lint.mjs refuses anything else). `true` marks the rare\n // migration that removes or tightens something on purpose; ship it only once\n // no prod still runs a version that reads the old shape.\n readonly contract?: boolean\n}\n\n// All probes funnel through here: one boolean expression, evaluated by the\n// server. Every one of them reads `pg_catalog` directly rather than going\n// through `to_regclass`/`to_regnamespace` or `information_schema`, both of\n// which are privilege-sensitive in ways that defeat the purpose: `to_regclass`\n// resolves the name and so raises `permission denied for schema auth` for a\n// role without USAGE, and `information_schema.columns` silently hides columns\n// the role holds no privilege on — reporting an applied migration as missing\n// and sending us straight into the ALTER we were trying to avoid. The catalogs\n// themselves are world-readable.\nasync function probe(db: NodePgDatabase, expression: string): Promise<boolean> {\n const result = await db.execute<{ applied: boolean }>(\n sql.raw(`SELECT (${expression}) AS \"applied\"`),\n )\n return result.rows[0]?.applied === true\n}\n\nconst schemaExists = (schema: string) => (db: NodePgDatabase) =>\n probe(db, `EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = '${schema}')`)\n\n// Tables and indexes alike — both live in `pg_class`.\nconst relationsExist =\n (...relations: readonly (readonly [schema: string, name: string])[]) =>\n (db: NodePgDatabase) => {\n const tuples = relations.map(([schema, name]) => `('${schema}','${name}')`).join(\", \")\n return probe(\n db,\n `(SELECT count(*) FROM pg_class c\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE (n.nspname, c.relname) IN (${tuples})) = ${relations.length}`,\n )\n }\n\nconst columnsExist =\n (...columns: readonly (readonly [schema: string, table: string, column: string])[]) =>\n (db: NodePgDatabase) => {\n const tuples = columns\n .map(([schema, table, column]) => `('${schema}','${table}','${column}')`)\n .join(\", \")\n return probe(\n db,\n `(SELECT count(*) FROM pg_attribute a\n JOIN pg_class c ON c.oid = a.attrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE a.attnum > 0 AND NOT a.attisdropped\n AND (n.nspname, c.relname, a.attname) IN (${tuples})) = ${columns.length}`,\n )\n }\n\nconst MIGRATIONS: readonly Migration[] = [\n {\n name: \"0001_init:schema\",\n sql: MIGRATION_0001_SCHEMA,\n isApplied: schemaExists(\"auth\"),\n },\n {\n name: \"0001_init:tables\",\n sql: MIGRATION_0001_TABLES,\n isApplied: relationsExist(\n [\"auth\", \"sessions\"],\n [\"auth\", \"ix_auth_sessions_user_sub\"],\n [\"auth\", \"login_state\"],\n [\"auth\", \"ix_auth_login_state_expires\"],\n ),\n },\n {\n name: \"0002_id_token\",\n sql: MIGRATION_0002_ID_TOKEN,\n isApplied: columnsExist([\"auth\", \"sessions\", \"id_token\"]),\n },\n {\n name: \"0003_forced_reauth\",\n sql: MIGRATION_0003_FORCED_REAUTH,\n isApplied: columnsExist([\"auth\", \"login_state\", \"forced_reauth\"]),\n },\n {\n name: \"0004_nonce\",\n sql: MIGRATION_0004_NONCE,\n isApplied: columnsExist([\"auth\", \"login_state\", \"nonce\"]),\n },\n {\n name: \"0005_retried\",\n sql: MIGRATION_0005_RETRIED,\n isApplied: columnsExist([\"auth\", \"login_state\", \"retried\"]),\n },\n {\n name: \"0006_pending_confirm\",\n sql: MIGRATION_0006_PENDING_CONFIRM,\n isApplied: columnsExist([\"auth\", \"sessions\", \"pending_identity_confirm\"]),\n },\n {\n name: \"0007_expected_identity\",\n sql: MIGRATION_0007_EXPECTED_IDENTITY,\n isApplied: columnsExist(\n [\"auth\", \"login_state\", \"expected_sub\"],\n [\"auth\", \"login_state\", \"expected_email\"],\n ),\n },\n]\n\nexport interface RunAuthMigrationsOptions {\n // When provided, grants this role SELECT/INSERT/UPDATE/DELETE on every\n // table in the `auth` schema — both ones this call just created and ones a\n // future boot's migrations will create. Omit for a single-role setup (the\n // fallback state of an environment that hasn't opted into a separate\n // migration role yet); passing it is what makes it safe for `db` to\n // connect as an admin/owner role while the app itself never does.\n readonly runtimeRole?: string\n}\n\nexport async function runAuthMigrations(\n db: NodePgDatabase,\n opts: RunAuthMigrationsOptions = {},\n): Promise<void> {\n for (const migration of MIGRATIONS) {\n try {\n if (await migration.isApplied(db)) {\n // Already there — do not issue the statement at all. See the comment\n // above MIGRATION_0001_SCHEMA for why relying on `IF NOT EXISTS` to make\n // it a no-op is not safe under every role.\n continue\n }\n await db.execute(sql.raw(migration.sql))\n } catch (err) {\n // Re-thrown, not swallowed: the caller decides what to do with a failed\n // migration. Naming the statement is what turns a bare \"permission\n // denied for database x\" into something you can actually act on; the\n // `cause` keeps the original Postgres error (code, detail, etc.) intact.\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(`auth migration \"${migration.name}\" failed: ${message}`, { cause: err })\n }\n }\n\n if (opts.runtimeRole) {\n await grantRuntimeDefaultPrivileges(db, \"auth\", opts.runtimeRole)\n }\n}\n"],"mappings":";;;;;AAAA,SAAS,WAAW;AAmCpB,IAAM,wBAAwB;AAAA;AAAA;AAI9B,IAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAoC9B,IAAM,0BAA0B;AAAA;AAAA;AAQhC,IAAM,+BAA+B;AAAA;AAAA;AAQrC,IAAM,uBAAuB;AAAA;AAAA;AAY7B,IAAM,yBAAyB;AAAA;AAAA;AAa/B,IAAM,iCAAiC;AAAA;AAAA;AAAA;AASvC,IAAM,mCAAmC;AAAA;AAAA;AAAA;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|
-
|
|
6
|
-
// src/integrations-core/types.ts
|
|
7
|
-
function defineIntegrations(map) {
|
|
8
|
-
return map;
|
|
9
|
-
}
|
|
10
|
-
var AUTH_ENV_FIELDS = {
|
|
11
|
-
none: [],
|
|
12
|
-
api_key_header: ["apiKey"],
|
|
13
|
-
bearer_static: ["token"],
|
|
14
|
-
basic: ["username", "password"],
|
|
15
|
-
oauth2_client_credentials: ["tokenUrl", "clientId", "clientSecret", "scope", "audience"]
|
|
16
|
-
};
|
|
17
|
-
var AUTH_SECRET_FIELDS = ["apiKey", "token", "password", "clientSecret"];
|
|
18
|
-
var RESERVED_KEY_PREFIX = "QORE_INTEGRATION_";
|
|
19
|
-
|
|
20
|
-
// src/integrations-core/env.ts
|
|
21
|
-
function refKey(ref) {
|
|
22
|
-
return typeof ref === "string" ? ref : ref.key;
|
|
23
|
-
}
|
|
24
|
-
function refOptional(ref) {
|
|
25
|
-
return typeof ref !== "string" && (ref.optional === true || ref.default !== void 0);
|
|
26
|
-
}
|
|
27
|
-
function authKeys(def) {
|
|
28
|
-
const auth = def.auth;
|
|
29
|
-
return AUTH_ENV_FIELDS[def.auth.kind].map((field) => auth[field]).filter((key) => typeof key === "string" && key !== "");
|
|
30
|
-
}
|
|
31
|
-
function requiredKeys(def) {
|
|
32
|
-
const keys = [def.baseUrl, ...authKeys(def)];
|
|
33
|
-
for (const ref of Object.values(def.config ?? {})) {
|
|
34
|
-
if (!refOptional(ref)) keys.push(refKey(ref));
|
|
35
|
-
}
|
|
36
|
-
return [...new Set(keys)];
|
|
37
|
-
}
|
|
38
|
-
function allKeys(def) {
|
|
39
|
-
const keys = [def.baseUrl, ...authKeys(def)];
|
|
40
|
-
for (const ref of Object.values(def.config ?? {})) keys.push(refKey(ref));
|
|
41
|
-
return [...new Set(keys)];
|
|
42
|
-
}
|
|
43
|
-
function readRef(env, ref) {
|
|
44
|
-
const value = env[refKey(ref)];
|
|
45
|
-
if (value !== void 0 && value !== "") return value;
|
|
46
|
-
return typeof ref === "string" ? void 0 : ref.default;
|
|
47
|
-
}
|
|
48
|
-
function loggingKey(alias) {
|
|
49
|
-
return `${RESERVED_KEY_PREFIX}${normalizeAlias(alias)}_LOGGING`;
|
|
50
|
-
}
|
|
51
|
-
function loggingEnabled(env, alias) {
|
|
52
|
-
const value = env[loggingKey(alias)];
|
|
53
|
-
return value === "1" || value?.toLowerCase() === "true";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// src/integrations-core/assertIntegrations.ts
|
|
57
|
-
var ENV_KEY_RE = /^[A-Z][A-Z0-9_]*$/;
|
|
58
|
-
function assertIntegrations(map, opts = {}) {
|
|
59
|
-
const env = opts.env ?? defaultEnv();
|
|
60
|
-
const warn = opts.warn ?? ((message) => console.warn(message));
|
|
61
|
-
const problems = [];
|
|
62
|
-
for (const [alias, def] of Object.entries(map)) {
|
|
63
|
-
for (const key of allKeys(def)) {
|
|
64
|
-
let why;
|
|
65
|
-
if (key.startsWith(RESERVED_KEY_PREFIX)) {
|
|
66
|
-
why = `${RESERVED_KEY_PREFIX}* keys are reserved by the platform`;
|
|
67
|
-
} else if (key.startsWith("CONN_")) {
|
|
68
|
-
why = "CONN_* keys belong to module connections, not integrations";
|
|
69
|
-
} else if (!ENV_KEY_RE.test(key)) {
|
|
70
|
-
why = "an env key is uppercase letters, digits and underscores";
|
|
71
|
-
}
|
|
72
|
-
if (why) {
|
|
73
|
-
problems.push({
|
|
74
|
-
alias,
|
|
75
|
-
key,
|
|
76
|
-
code: "reserved_key",
|
|
77
|
-
message: `Integration "${alias}" declares env key "${key}": ${why}`
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
for (const key of requiredKeys(def)) {
|
|
82
|
-
const value = env[key];
|
|
83
|
-
if (value === void 0 || value === "") {
|
|
84
|
-
problems.push({
|
|
85
|
-
alias,
|
|
86
|
-
key,
|
|
87
|
-
code: "missing_env",
|
|
88
|
-
message: `Integration "${alias}" is missing env key "${key}"; calls to it will fail until it is set`
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
for (const p of problems) warn(`[integrations] ${p.message}`);
|
|
94
|
-
return problems;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export {
|
|
98
|
-
defineIntegrations,
|
|
99
|
-
AUTH_ENV_FIELDS,
|
|
100
|
-
AUTH_SECRET_FIELDS,
|
|
101
|
-
RESERVED_KEY_PREFIX,
|
|
102
|
-
requiredKeys,
|
|
103
|
-
allKeys,
|
|
104
|
-
readRef,
|
|
105
|
-
loggingKey,
|
|
106
|
-
loggingEnabled,
|
|
107
|
-
assertIntegrations
|
|
108
|
-
};
|
|
109
|
-
//# sourceMappingURL=chunk-TOBGX4CZ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/integrations-core/types.ts","../src/integrations-core/env.ts","../src/integrations-core/assertIntegrations.ts"],"sourcesContent":["/**\n * How an integration authenticates. Every field except `header` and\n * `credentialsIn` names an **env key** — the SDK reads the value from the\n * environment at call time, never from the declaration — so a declaration can\n * sit in source control and carry no secret.\n */\nexport type AuthKind =\n | \"none\"\n | \"api_key_header\"\n | \"bearer_static\"\n | \"basic\"\n | \"oauth2_client_credentials\"\n\n/** What the API speaks. Informational for the portal; the client sends bytes either way. */\nexport type Protocol = \"rest\" | \"odata\" | \"soap\" | \"graphql\"\n\n/** The name of an env var, e.g. `SAP_BASE_URL`. */\nexport type EnvKey = string\n\n/**\n * A reference to an env var. The short form is required; the object form can\n * be optional and carry a default the app falls back on when the key is unset.\n */\nexport type EnvRef =\n | EnvKey\n | { key: EnvKey; optional?: boolean; default?: string | number | boolean }\n\nexport type IntegrationAuth =\n | { kind: \"none\" }\n | { kind: \"api_key_header\"; header: string; apiKey: EnvKey }\n | { kind: \"bearer_static\"; token: EnvKey }\n | { kind: \"basic\"; username: EnvKey; password: EnvKey }\n | {\n kind: \"oauth2_client_credentials\"\n tokenUrl: EnvKey\n clientId: EnvKey\n clientSecret: EnvKey\n scope?: EnvKey\n audience?: EnvKey\n /** Where the client credentials go on the token request. Default `\"header\"`. */\n credentialsIn?: \"header\" | \"body\"\n }\n\nexport interface IntegrationDefinition {\n /** Human name shown in the portal, e.g. \"SAP S/4HANA Cloud\". */\n label: string\n protocol: Protocol\n /** Env key holding the base URL for this environment. */\n baseUrl: EnvKey\n auth: IntegrationAuth\n /** Further env the app reads for this integration, by logical name. */\n config?: Record<string, EnvRef>\n}\n\nexport type IntegrationMap = Record<string, IntegrationDefinition>\n\n/**\n * Identity function that pins the literal types of the map, so an alias typo\n * at a call site is a compile error (`keyof M`) rather than a runtime\n * `not_declared`. Same shape as `definePermissions` in `auth-core`.\n */\nexport function defineIntegrations<const M extends IntegrationMap>(map: M): M {\n return map\n}\n\n/**\n * Which fields of each auth kind name an env key. Shared with the manifest\n * extractor and the portal, which derive the required-env list from a\n * declaration without evaluating app code.\n */\nexport const AUTH_ENV_FIELDS: Record<AuthKind, readonly string[]> = {\n none: [],\n api_key_header: [\"apiKey\"],\n bearer_static: [\"token\"],\n basic: [\"username\", \"password\"],\n oauth2_client_credentials: [\"tokenUrl\", \"clientId\", \"clientSecret\", \"scope\", \"audience\"],\n}\n\n/** Auth fields whose env value is a secret, so the portal masks it. */\nexport const AUTH_SECRET_FIELDS = [\"apiKey\", \"token\", \"password\", \"clientSecret\"] as const\n\n/**\n * Env keys under this prefix belong to the platform\n * (`QORE_INTEGRATION_<ALIAS>_LOGGING` today). A declaration may not claim one.\n */\nexport const RESERVED_KEY_PREFIX = \"QORE_INTEGRATION_\"\n","import { normalizeAlias, type Env } from \"../connections-core/env\"\nimport {\n AUTH_ENV_FIELDS,\n RESERVED_KEY_PREFIX,\n type EnvRef,\n type IntegrationDefinition,\n} from \"./types\"\n\nexport type { Env }\n\nexport function refKey(ref: EnvRef): string {\n return typeof ref === \"string\" ? ref : ref.key\n}\n\nfunction refOptional(ref: EnvRef): boolean {\n return typeof ref !== \"string\" && (ref.optional === true || ref.default !== undefined)\n}\n\n/** The auth fields of `def` that are set, as env keys. */\nfunction authKeys(def: IntegrationDefinition): string[] {\n const auth = def.auth as unknown as Record<string, unknown>\n return AUTH_ENV_FIELDS[def.auth.kind]\n .map((field) => auth[field])\n .filter((key): key is string => typeof key === \"string\" && key !== \"\")\n}\n\n/**\n * Every env key the integration cannot run without: the base URL, every auth\n * field that is set, and every config ref that is neither optional nor\n * defaulted. Order is stable so an error message reads the same twice.\n */\nexport function requiredKeys(def: IntegrationDefinition): string[] {\n const keys = [def.baseUrl, ...authKeys(def)]\n for (const ref of Object.values(def.config ?? {})) {\n if (!refOptional(ref)) keys.push(refKey(ref))\n }\n return [...new Set(keys)]\n}\n\n/** Every env key the declaration names, required or not. */\nexport function allKeys(def: IntegrationDefinition): string[] {\n const keys = [def.baseUrl, ...authKeys(def)]\n for (const ref of Object.values(def.config ?? {})) keys.push(refKey(ref))\n return [...new Set(keys)]\n}\n\n/**\n * Read one ref from `env`, applying its default when the key is unset or\n * empty. A default comes back as declared (a number or boolean stays typed);\n * an env value is always a string.\n */\nexport function readRef(env: Env, ref: EnvRef): string | number | boolean | undefined {\n const value = env[refKey(ref)]\n if (value !== undefined && value !== \"\") return value\n return typeof ref === \"string\" ? undefined : ref.default\n}\n\n/** `QORE_INTEGRATION_<ALIAS>_LOGGING` — the one reserved key v1 reads. */\nexport function loggingKey(alias: string): string {\n return `${RESERVED_KEY_PREFIX}${normalizeAlias(alias)}_LOGGING`\n}\n\n/** Whether the per-call JSON log line is switched on for this alias (\"1\" or \"true\"). */\nexport function loggingEnabled(env: Env, alias: string): boolean {\n const value = env[loggingKey(alias)]\n return value === \"1\" || value?.toLowerCase() === \"true\"\n}\n","import { defaultEnv, type Env } from \"../connections-core/env\"\nimport { allKeys, requiredKeys } from \"./env\"\nimport { RESERVED_KEY_PREFIX, type IntegrationMap } from \"./types\"\n\nconst ENV_KEY_RE = /^[A-Z][A-Z0-9_]*$/\n\nexport interface IntegrationProblem {\n alias: string\n key: string\n /** `missing_env`: a required key is unset or empty. `reserved_key`: the declaration claims a key it may not. */\n code: \"missing_env\" | \"reserved_key\"\n message: string\n}\n\n/**\n * Report, at app startup, what is wrong with the declared integrations: a\n * required env key that is unset, or a key the declaration may not claim.\n * **It never throws.** Integrations are a visibility tool: an API key that is\n * not set (an obsolete integration, a vendor not contracted in this\n * environment) must cost the calls to that one integration — they fail with\n * `missing_env` — never the boot of the whole app. Each problem is logged as\n * one warning and returned, so a caller may act on them if it chooses.\n */\nexport function assertIntegrations(\n map: IntegrationMap,\n opts: { env?: Env; warn?: (message: string) => void } = {},\n): IntegrationProblem[] {\n const env = opts.env ?? defaultEnv()\n const warn = opts.warn ?? ((message: string) => console.warn(message))\n const problems: IntegrationProblem[] = []\n\n for (const [alias, def] of Object.entries(map)) {\n for (const key of allKeys(def)) {\n let why: string | undefined\n if (key.startsWith(RESERVED_KEY_PREFIX)) {\n why = `${RESERVED_KEY_PREFIX}* keys are reserved by the platform`\n } else if (key.startsWith(\"CONN_\")) {\n why = \"CONN_* keys belong to module connections, not integrations\"\n } else if (!ENV_KEY_RE.test(key)) {\n why = \"an env key is uppercase letters, digits and underscores\"\n }\n if (why) {\n problems.push({\n alias,\n key,\n code: \"reserved_key\",\n message: `Integration \"${alias}\" declares env key \"${key}\": ${why}`,\n })\n }\n }\n for (const key of requiredKeys(def)) {\n const value = env[key]\n if (value === undefined || value === \"\") {\n problems.push({\n alias,\n key,\n code: \"missing_env\",\n message: `Integration \"${alias}\" is missing env key \"${key}\"; calls to it will fail until it is set`,\n })\n }\n }\n }\n\n for (const p of problems) warn(`[integrations] ${p.message}`)\n return problems\n}\n"],"mappings":";;;;;;AA6DO,SAAS,mBAAmD,KAAW;AAC5E,SAAO;AACT;AAOO,IAAM,kBAAuD;AAAA,EAClE,MAAM,CAAC;AAAA,EACP,gBAAgB,CAAC,QAAQ;AAAA,EACzB,eAAe,CAAC,OAAO;AAAA,EACvB,OAAO,CAAC,YAAY,UAAU;AAAA,EAC9B,2B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|
2
|
-
initSentry
|
|
3
|
-
} from "./chunk-G7VPNC6M.js";
|
|
4
|
-
import {
|
|
5
|
-
readSentryConfig
|
|
6
|
-
} from "./chunk-7ASQHY7O.js";
|
|
7
|
-
|
|
8
|
-
// src/next/sentry/register.ts
|
|
9
|
-
import * as Sentry from "@sentry/nextjs";
|
|
10
|
-
async function register() {
|
|
11
|
-
const runtime = process.env.NEXT_RUNTIME === "edge" ? "edge" : "node";
|
|
12
|
-
initSentry(Sentry, runtime, readSentryConfig(process.env, { frontend: true }));
|
|
13
|
-
}
|
|
14
|
-
var onRequestError = Sentry.captureRequestError;
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
register,
|
|
18
|
-
onRequestError
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=chunk-WU7N4PET.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/next/sentry/register.ts"],"sourcesContent":["import * as Sentry from \"@sentry/nextjs\"\nimport { readSentryConfig } from \"../../sentry-core/env\"\nimport { initSentry } from \"../../sentry-core/init\"\n\nexport async function register(): Promise<void> {\n const runtime = process.env.NEXT_RUNTIME === \"edge\" ? \"edge\" : \"node\"\n initSentry(Sentry, runtime, readSentryConfig(process.env, { frontend: true }))\n}\n\nexport const onRequestError = Sentry.captureRequestError\n"],"mappings":";;;;;;;;AAAA,YAAY,YAAY;AAIxB,eAAsB,WAA0B;AAC9C,QAAM,UAAU,QAAQ,IAAI,iBAAiB,SAAS,SAAS;AAC/D,aAAW,QAAQ,SAAS,iBAAiB,QAAQ,KAAK,EAAE,UAAU,KAAK,CAAC,CAAC;AAC/E;AAEO,IAAM,iBAAwB;","names":[]}
|
package/dist/mail/index.d.ts
DELETED
package/dist/mail/index.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getLogger
|
|
3
|
-
} from "../chunk-MET4SIMB.js";
|
|
4
|
-
|
|
5
|
-
// src/mail/index.ts
|
|
6
|
-
async function sendMail(mail) {
|
|
7
|
-
const apiKey = process.env.MAIL_API_KEY;
|
|
8
|
-
if (!apiKey) {
|
|
9
|
-
getLogger().warn({}, "mail skipped: no MAIL_API_KEY");
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const from = process.env.MAIL_FROM;
|
|
13
|
-
if (!from) {
|
|
14
|
-
throw new Error("sendMail: MAIL_API_KEY is set but MAIL_FROM is missing");
|
|
15
|
-
}
|
|
16
|
-
const res = await fetch("https://api.resend.com/emails", {
|
|
17
|
-
method: "POST",
|
|
18
|
-
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
19
|
-
body: JSON.stringify({ from, to: mail.to, subject: mail.subject, html: mail.html, text: mail.text })
|
|
20
|
-
});
|
|
21
|
-
if (!res.ok) throw new Error(`sendMail failed: ${res.status} ${await res.text()}`);
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
sendMail
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
package/dist/mail/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mail/index.ts"],"sourcesContent":["// Mail transport for Next and Node apps alike. Sends over Resend when\n// MAIL_API_KEY is set, otherwise skips with a warning, so an app without a mail\n// provider still runs. Runtime-neutral and Sentry-free: the warning goes through\n// the SDK log.\nimport { getLogger } from \"../telemetry-hooks\"\n\nexport type Mail = { to: string; subject: string; html: string; text: string }\n\nexport async function sendMail(mail: Mail): Promise<void> {\n const apiKey = process.env.MAIL_API_KEY\n if (!apiKey) {\n getLogger().warn({}, \"mail skipped: no MAIL_API_KEY\")\n return\n }\n const from = process.env.MAIL_FROM\n if (!from) {\n throw new Error(\"sendMail: MAIL_API_KEY is set but MAIL_FROM is missing\")\n }\n const res = await fetch(\"https://api.resend.com/emails\", {\n method: \"POST\",\n headers: { Authorization: `Bearer ${apiKey}`, \"Content-Type\": \"application/json\" },\n body: JSON.stringify({ from, to: mail.to, subject: mail.subject, html: mail.html, text: mail.text }),\n })\n if (!res.ok) throw new Error(`sendMail failed: ${res.status} ${await res.text()}`)\n}\n"],"mappings":";;;;;AAQA,eAAsB,SAAS,MAA2B;AACxD,QAAM,SAAS,QAAQ,IAAI;AAC3B,MAAI,CAAC,QAAQ;AACX,cAAU,EAAE,KAAK,CAAC,GAAG,+BAA+B;AACpD;AAAA,EACF;AACA,QAAM,OAAO,QAAQ,IAAI;AACzB,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC1E;AACA,QAAM,MAAM,MAAM,MAAM,iCAAiC;AAAA,IACvD,QAAQ;AAAA,IACR,SAAS,EAAE,eAAe,UAAU,MAAM,IAAI,gBAAgB,mBAAmB;AAAA,IACjF,MAAM,KAAK,UAAU,EAAE,MAAM,IAAI,KAAK,IAAI,SAAS,KAAK,SAAS,MAAM,KAAK,MAAM,MAAM,KAAK,KAAK,CAAC;AAAA,EACrG,CAAC;AACD,MAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,oBAAoB,IAAI,MAAM,IAAI,MAAM,IAAI,KAAK,CAAC,EAAE;AACnF;","names":[]}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { I as IntegrationMap } from '../../types-CAwj03sM.js';
|
|
2
|
-
export { onRequestError } from '../sentry/register.js';
|
|
3
|
-
import '@sentry/nextjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* The app-specific parts of boot. Each is a loader (`() => import(...)`), so
|
|
7
|
-
* nothing is imported until the Node runtime asks for it, in this order:
|
|
8
|
-
* integrations, env, auth migrations, app migrations, seed.
|
|
9
|
-
*/
|
|
10
|
-
interface NodeBoot {
|
|
11
|
-
/** `() => import("@/config/integrations")` */
|
|
12
|
-
integrations?: () => Promise<{
|
|
13
|
-
integrations: IntegrationMap;
|
|
14
|
-
}>;
|
|
15
|
-
/** `() => import("@/config/env")`; validated before anything touches the database. */
|
|
16
|
-
env?: () => Promise<{
|
|
17
|
-
serverEnv: () => unknown;
|
|
18
|
-
}>;
|
|
19
|
-
/** Run the SDK's own auth-schema migrations (Keycloak apps). */
|
|
20
|
-
authMigrations?: boolean;
|
|
21
|
-
/** `() => import("./lib/migrate")` */
|
|
22
|
-
migrations?: () => Promise<{
|
|
23
|
-
runAppMigrations: () => Promise<void>;
|
|
24
|
-
}>;
|
|
25
|
-
/** `() => import("./scripts/seed")`; runs only when `QORE_RUN_SEED=true` (previews). */
|
|
26
|
-
seed?: () => Promise<{
|
|
27
|
-
default: () => Promise<void>;
|
|
28
|
-
}>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
declare function qoreRegister(node?: NodeBoot): Promise<void>;
|
|
32
|
-
|
|
33
|
-
export { type NodeBoot, qoreRegister };
|
package/dist/next/boot/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
onRequestError,
|
|
3
|
-
register
|
|
4
|
-
} from "../../chunk-WU7N4PET.js";
|
|
5
|
-
import "../../chunk-G7VPNC6M.js";
|
|
6
|
-
import "../../chunk-MET4SIMB.js";
|
|
7
|
-
import "../../chunk-7ASQHY7O.js";
|
|
8
|
-
|
|
9
|
-
// src/next/boot/index.ts
|
|
10
|
-
async function qoreRegister(node) {
|
|
11
|
-
await register();
|
|
12
|
-
if (process.env.NEXT_RUNTIME === "nodejs" && node) {
|
|
13
|
-
const { bootNode } = await import("../../node-Z7ERWJDZ.js");
|
|
14
|
-
await bootNode(node);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export {
|
|
18
|
-
onRequestError,
|
|
19
|
-
qoreRegister
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/boot/index.ts"],"sourcesContent":["// The body of a Next app's `src/instrumentation.ts`. The app passes what only\n// it can name (its env, migrations, seed); the platform's own boot steps live\n// here, so a new one reaches every app as an SDK release.\n//\n// export async function register() {\n// await qoreRegister(process.env.NEXT_RUNTIME === \"nodejs\" ? { ...loaders } : undefined)\n// // the app's own boot code, after migrations\n// }\n//\n// The ternary in the app file, and the `if` below, are what keep the Node-only\n// loaders out of the edge bundle: Next replaces NEXT_RUNTIME at build time and\n// the bundler drops the dead branch with its imports.\nimport { register as registerSentry } from \"../sentry/register\"\nimport type { NodeBoot } from \"./types\"\n\nexport { onRequestError } from \"../sentry/register\"\nexport type { NodeBoot } from \"./types\"\n\nexport async function qoreRegister(node?: NodeBoot): Promise<void> {\n await registerSentry()\n if (process.env.NEXT_RUNTIME === \"nodejs\" && node) {\n const { bootNode } = await import(\"./node\")\n await bootNode(node)\n }\n}\n"],"mappings":";;;;;;;;;AAkBA,eAAsB,aAAa,MAAgC;AACjE,QAAM,SAAe;AACrB,MAAI,QAAQ,IAAI,iBAAiB,YAAY,MAAM;AACjD,UAAM,EAAE,SAAS,IAAI,MAAM,OAAO,wBAAQ;AAC1C,UAAM,SAAS,IAAI;AAAA,EACrB;AACF;","names":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
// src/next/global-error/index.tsx
|
|
4
|
-
import { useEffect } from "react";
|
|
5
|
-
import NextError from "next/error";
|
|
6
|
-
import * as Sentry from "@sentry/nextjs";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
function GlobalError({ error }) {
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
Sentry.captureException(error);
|
|
11
|
-
}, [error]);
|
|
12
|
-
return /* @__PURE__ */ jsx("html", { lang: "en", children: /* @__PURE__ */ jsx("body", { children: /* @__PURE__ */ jsx(NextError, { statusCode: 0 }) }) });
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
GlobalError as default
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/global-error/index.tsx"],"sourcesContent":["\"use client\"\n// The page Next renders when the root layout itself throws. The app's\n// `src/app/global-error.tsx` re-exports this under its own \"use client\"\n// (bundling drops the directive here), so how a crash is reported and shown\n// changes with an SDK release.\nimport { useEffect } from \"react\"\nimport NextError from \"next/error\"\nimport * as Sentry from \"@sentry/nextjs\"\n\nexport default function GlobalError({ error }: { error: Error & { digest?: string } }) {\n useEffect(() => {\n Sentry.captureException(error)\n }, [error])\n\n return (\n <html lang=\"en\">\n <body>\n <NextError statusCode={0} />\n </body>\n </html>\n )\n}\n"],"mappings":";;;AAKA,SAAS,iBAAiB;AAC1B,OAAO,eAAe;AACtB,YAAY,YAAY;AAUhB;AARO,SAAR,YAA6B,EAAE,MAAM,GAA2C;AACrF,YAAU,MAAM;AACd,IAAO,wBAAiB,KAAK;AAAA,EAC/B,GAAG,CAAC,KAAK,CAAC;AAEV,SACE,oBAAC,UAAK,MAAK,MACT,8BAAC,UACC,8BAAC,aAAU,YAAY,GAAG,GAC5B,GACF;AAEJ;","names":[]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Routes the platform serves inside every app, under `/api/qore/*`.
|
|
3
|
-
*
|
|
4
|
-
* The app holds one file, `src/app/api/qore/[...path]/route.ts`:
|
|
5
|
-
*
|
|
6
|
-
* export const runtime = "nodejs"
|
|
7
|
-
* export const dynamic = "force-dynamic"
|
|
8
|
-
* export { GET, POST } from "@quatronic/sdk/next/platform"
|
|
9
|
-
*
|
|
10
|
-
* so a new platform route arrives with an SDK release. `runtime` and `dynamic`
|
|
11
|
-
* stay literals in the app: Next reads them off the route module and does not
|
|
12
|
-
* follow them into a package. `/api/healthz` is not here, because the portal's
|
|
13
|
-
* monitor calls it at that path.
|
|
14
|
-
*/
|
|
15
|
-
type Handler = (request: Request) => Promise<Response>;
|
|
16
|
-
declare const GET: Handler;
|
|
17
|
-
declare const POST: Handler;
|
|
18
|
-
|
|
19
|
-
export { GET, POST };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
QORE_CSP_REPORT_URI,
|
|
3
|
-
createCspReportRoute
|
|
4
|
-
} from "../../chunk-P7HNHLW7.js";
|
|
5
|
-
import "../../chunk-FUPTRHT7.js";
|
|
6
|
-
import {
|
|
7
|
-
getLogger
|
|
8
|
-
} from "../../chunk-MET4SIMB.js";
|
|
9
|
-
|
|
10
|
-
// src/next/platform/index.ts
|
|
11
|
-
var PREFIX = "/api/qore/";
|
|
12
|
-
var cspReport = createCspReportRoute({
|
|
13
|
-
log: {
|
|
14
|
-
warn: ({ event, ...fields }) => getLogger().warn(
|
|
15
|
-
{
|
|
16
|
-
"qore.audit.event": String(event),
|
|
17
|
-
...Object.fromEntries(
|
|
18
|
-
Object.entries(fields).filter(([, value]) => value !== void 0).map(([key, value]) => [`qore.csp.${key}`, String(value)])
|
|
19
|
-
)
|
|
20
|
-
},
|
|
21
|
-
String(event)
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
var ROUTES = {
|
|
26
|
-
[QORE_CSP_REPORT_URI.slice(PREFIX.length)]: { POST: cspReport }
|
|
27
|
-
};
|
|
28
|
-
function dispatch(method) {
|
|
29
|
-
return async (request) => {
|
|
30
|
-
const path = new URL(request.url).pathname;
|
|
31
|
-
const route = path.startsWith(PREFIX) ? ROUTES[path.slice(PREFIX.length).replace(/\/$/, "")] : void 0;
|
|
32
|
-
if (!route) return new Response(null, { status: 404 });
|
|
33
|
-
const handler = route[method];
|
|
34
|
-
if (!handler) return new Response(null, { status: 405, headers: { allow: Object.keys(route).join(", ") } });
|
|
35
|
-
return handler(request);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
var GET = dispatch("GET");
|
|
39
|
-
var POST = dispatch("POST");
|
|
40
|
-
export {
|
|
41
|
-
GET,
|
|
42
|
-
POST
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/platform/index.ts"],"sourcesContent":["import { getLogger } from \"../../telemetry-hooks\"\nimport { createCspReportRoute, QORE_CSP_REPORT_URI } from \"../../security-core/cspReport\"\n\n/**\n * Routes the platform serves inside every app, under `/api/qore/*`.\n *\n * The app holds one file, `src/app/api/qore/[...path]/route.ts`:\n *\n * export const runtime = \"nodejs\"\n * export const dynamic = \"force-dynamic\"\n * export { GET, POST } from \"@quatronic/sdk/next/platform\"\n *\n * so a new platform route arrives with an SDK release. `runtime` and `dynamic`\n * stay literals in the app: Next reads them off the route module and does not\n * follow them into a package. `/api/healthz` is not here, because the portal's\n * monitor calls it at that path.\n */\n\ntype Handler = (request: Request) => Promise<Response>\n\nconst PREFIX = \"/api/qore/\"\n\nconst cspReport = createCspReportRoute({\n log: {\n warn: ({ event, ...fields }) =>\n getLogger().warn(\n {\n \"qore.audit.event\": String(event),\n ...Object.fromEntries(\n Object.entries(fields)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => [`qore.csp.${key}`, String(value)]),\n ),\n },\n String(event),\n ),\n },\n})\n\nconst ROUTES: Record<string, Partial<Record<\"GET\" | \"POST\", Handler>>> = {\n [QORE_CSP_REPORT_URI.slice(PREFIX.length)]: { POST: cspReport },\n}\n\nfunction dispatch(method: \"GET\" | \"POST\"): Handler {\n return async (request) => {\n const path = new URL(request.url).pathname\n const route = path.startsWith(PREFIX) ? ROUTES[path.slice(PREFIX.length).replace(/\\/$/, \"\")] : undefined\n if (!route) return new Response(null, { status: 404 })\n const handler = route[method]\n if (!handler) return new Response(null, { status: 405, headers: { allow: Object.keys(route).join(\", \") } })\n return handler(request)\n }\n}\n\nexport const GET = dispatch(\"GET\")\nexport const POST = dispatch(\"POST\")\n"],"mappings":";;;;;;;;;;AAoBA,IAAM,SAAS;AAEf,IAAM,YAAY,qBAAqB;AAAA,EACrC,KAAK;AAAA,IACH,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,MACxB,UAAU,EAAE;AAAA,MACV;AAAA,QACE,oBAAoB,OAAO,KAAK;AAAA,QAChC,GAAG,OAAO;AAAA,UACR,OAAO,QAAQ,MAAM,EAClB,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,EACzC,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,YAAY,GAAG,IAAI,OAAO,KAAK,CAAC,CAAC;AAAA,QAC7D;AAAA,MACF;AAAA,MACA,OAAO,KAAK;AAAA,IACd;AAAA,EACJ;AACF,CAAC;AAED,IAAM,SAAmE;AAAA,EACvE,CAAC,oBAAoB,MAAM,OAAO,MAAM,CAAC,GAAG,EAAE,MAAM,UAAU;AAChE;AAEA,SAAS,SAAS,QAAiC;AACjD,SAAO,OAAO,YAAY;AACxB,UAAM,OAAO,IAAI,IAAI,QAAQ,GAAG,EAAE;AAClC,UAAM,QAAQ,KAAK,WAAW,MAAM,IAAI,OAAO,KAAK,MAAM,OAAO,MAAM,EAAE,QAAQ,OAAO,EAAE,CAAC,IAAI;AAC/F,QAAI,CAAC,MAAO,QAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,IAAI,CAAC;AACrD,UAAM,UAAU,MAAM,MAAM;AAC5B,QAAI,CAAC,QAAS,QAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,KAAK,SAAS,EAAE,OAAO,OAAO,KAAK,KAAK,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;AAC1G,WAAO,QAAQ,OAAO;AAAA,EACxB;AACF;AAEO,IAAM,MAAM,SAAS,KAAK;AAC1B,IAAM,OAAO,SAAS,MAAM;","names":[]}
|