@quatronic/sdk 0.10.0-test.c3cd35d → 0.10.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.
Files changed (75) hide show
  1. package/README.md +0 -6
  2. package/dist/{chunk-VQKYPW5V.js → chunk-IFESUTF2.js} +3 -7
  3. package/dist/chunk-IFESUTF2.js.map +1 -0
  4. package/dist/{chunk-WOFBDOMY.js → chunk-POZI4OKJ.js} +2 -2
  5. package/dist/{chunk-YCKDMG4B.js → chunk-TPBRMW5N.js} +1 -30
  6. package/dist/chunk-TPBRMW5N.js.map +1 -0
  7. package/dist/{chunk-P5GBQVO7.js → chunk-YFZB5EW6.js} +2 -2
  8. package/dist/cli/skills-postinstall.js +6 -13
  9. package/dist/cli/skills.js +5 -11
  10. package/dist/eslint/index.d.ts +1 -11
  11. package/dist/eslint/index.js +4 -123
  12. package/dist/eslint/index.js.map +1 -1
  13. package/dist/next/auth/index.d.ts +0 -50
  14. package/dist/next/auth/index.js +101 -504
  15. package/dist/next/auth/index.js.map +1 -1
  16. package/dist/next/boot/index.js +3 -3
  17. package/dist/next/db/index.js +1 -1
  18. package/dist/next/sentry/client.js +3 -3
  19. package/dist/next/sentry/client.js.map +1 -1
  20. package/dist/next/sentry/index.js +1 -1
  21. package/dist/next/sentry/register.js +3 -3
  22. package/dist/node/sentry/index.js +1 -1
  23. package/dist/node/sentry/register.js +2 -2
  24. package/package.json +2 -75
  25. package/skills/catalog.json +0 -3
  26. package/skills/qore-add-api-route/SKILL.md +1 -1
  27. package/skills/qore-add-connection/SKILL.next.md +1 -3
  28. package/skills/qore-add-connection/SKILL.node.md +1 -3
  29. package/skills/qore-add-env-key/SKILL.md +9 -174
  30. package/skills/qore-add-feature/SKILL.md +1 -1
  31. package/skills/qore-add-integration/SKILL.next.md +2 -4
  32. package/skills/qore-add-integration/SKILL.node.md +6 -6
  33. package/skills/qore-add-page/SKILL.md +1 -1
  34. package/skills/qore-author-skill/SKILL.md +1 -1
  35. package/skills/qore-debug-issue/SKILL.md +0 -10
  36. package/skills/qore-observability/SKILL.md +0 -17
  37. package/skills/qore-secure-io/SKILL.md +0 -15
  38. package/skills/qore-ship-checklist/SKILL.md +0 -10
  39. package/skills/qore-translate-strings/SKILL.md +0 -10
  40. package/skills/qore-use-addons/SKILL.md +0 -2
  41. package/skills/qore-use-database/SKILL.md +0 -2
  42. package/skills/qore-use-design-system/SKILL.md +1 -1
  43. package/skills/qore-use-mail-domain/SKILL.next.md +1 -1
  44. package/skills/qore-use-mail-domain/SKILL.node.md +2 -2
  45. package/skills/qore-use-permissions/SKILL.md +0 -10
  46. package/dist/chunk-7XIDABOQ.js +0 -83
  47. package/dist/chunk-7XIDABOQ.js.map +0 -1
  48. package/dist/chunk-VQKYPW5V.js.map +0 -1
  49. package/dist/chunk-YCKDMG4B.js.map +0 -1
  50. package/dist/chunk-YXIYI7R2.js +0 -23
  51. package/dist/chunk-YXIYI7R2.js.map +0 -1
  52. package/dist/context-B_u-vpkw.d.ts +0 -111
  53. package/dist/expo/auth/index.d.ts +0 -8
  54. package/dist/expo/auth/index.js +0 -177
  55. package/dist/expo/auth/index.js.map +0 -1
  56. package/dist/expo/config/index.d.ts +0 -16
  57. package/dist/expo/config/index.js +0 -17
  58. package/dist/expo/config/index.js.map +0 -1
  59. package/dist/expo/log/index.d.ts +0 -9
  60. package/dist/expo/log/index.js +0 -16
  61. package/dist/expo/log/index.js.map +0 -1
  62. package/dist/expo/query/index.d.ts +0 -15
  63. package/dist/expo/query/index.js +0 -52
  64. package/dist/expo/query/index.js.map +0 -1
  65. package/dist/expo/sentry/index.d.ts +0 -29
  66. package/dist/expo/sentry/index.js +0 -93
  67. package/dist/expo/sentry/index.js.map +0 -1
  68. package/dist/expo/testing/index.d.ts +0 -32
  69. package/dist/expo/testing/index.js +0 -57
  70. package/dist/expo/testing/index.js.map +0 -1
  71. package/skills/qore-mobile-add-screen/SKILL.md +0 -58
  72. package/skills/qore-mobile-call-server/SKILL.md +0 -74
  73. package/skills/qore-mobile-run-on-device/SKILL.md +0 -41
  74. /package/dist/{chunk-WOFBDOMY.js.map → chunk-POZI4OKJ.js.map} +0 -0
  75. /package/dist/{chunk-P5GBQVO7.js.map → chunk-YFZB5EW6.js.map} +0 -0
package/README.md CHANGED
@@ -23,12 +23,6 @@ app runs against its own proxy, and `@quatronic/sdk/eslint` for the fourteen
23
23
  `qdc/*` lint rules —
24
24
  [`docs/security-rules.md`](docs/security-rules.md).
25
25
 
26
- ## Web and mobile
27
-
28
- A module can carry a phone app (`mobile/`, Expo) beside its Next app. Which
29
- entry runs where, what it may import and its counterpart on the other side:
30
- [`docs/surfaces.md`](docs/surfaces.md).
31
-
32
26
  ## Claude Code skills
33
27
 
34
28
  The SDK ships the app's managed Claude Code skills (`skills/`, one entry per
@@ -5,8 +5,7 @@ var URL_USERINFO = /\b([a-z][a-z0-9+.-]{0,31}:\/\/)[^/\s:@]+(?::[^/\s@]*)?@/gi;
5
5
  var JWT = /eyJ[\w-]+\.[\w-]+\.[\w-]+/g;
6
6
  var AUTH_SCHEME = /\b(Bearer|Basic)\s+\S+/gi;
7
7
  var PARAMS_TAIL = /\bparams:\s.*$/s;
8
- var TEXT_QUERY_PARAM = /([?&])([A-Za-z_]{1,32})=([^&\s#"']+)/g;
9
- var SECRET_PARAMS = /* @__PURE__ */ new Set(["token", "code", "state", "password", "secret", "key", "session", "access_token", "refresh_token", "id_token", "verifier", "code_verifier"]);
8
+ var SECRET_PARAMS = /* @__PURE__ */ new Set(["token", "code", "state", "password", "secret", "key", "session", "access_token", "refresh_token", "id_token"]);
10
9
  var SECRET_HEADERS = /* @__PURE__ */ new Set([
11
10
  "authorization",
12
11
  "cookie",
@@ -37,10 +36,7 @@ function maskSecretValues(s) {
37
36
  return secretState().longestFirst.reduce((acc, v) => acc.replaceAll(v, REDACTED), s);
38
37
  }
39
38
  function redactText(s) {
40
- return maskSecretValues(s).replace(URL_USERINFO, `$1${REDACTED}@`).replace(PARAMS_TAIL, "params: [redacted]").replace(
41
- TEXT_QUERY_PARAM,
42
- (m, sep, k) => SECRET_PARAMS.has(k.toLowerCase()) ? `${sep}${k}=[redacted]` : m
43
- ).replace(AUTH_SCHEME, "$1 [redacted]").replace(JWT, "[jwt]").replace(EMAIL, "[email]");
39
+ return maskSecretValues(s).replace(URL_USERINFO, `$1${REDACTED}@`).replace(PARAMS_TAIL, "params: [redacted]").replace(AUTH_SCHEME, "$1 [redacted]").replace(JWT, "[jwt]").replace(EMAIL, "[email]");
44
40
  }
45
41
  function redactQuery(query) {
46
42
  return query.split("&").map((pair) => {
@@ -112,4 +108,4 @@ export {
112
108
  scrubLog,
113
109
  scrubSpan
114
110
  };
115
- //# sourceMappingURL=chunk-VQKYPW5V.js.map
111
+ //# sourceMappingURL=chunk-IFESUTF2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sentry-core/scrub.ts"],"sourcesContent":["export const REDACTED = \"●●●\"\n\n// Bounded and anchored (`(?<![...])` + `{1,64}` local part, no `.` in the\n// domain-char class) so it cannot backtrack catastrophically on long runs of\n// email-charset bytes — see the fix-round-1 report for the O(n²) it replaced.\nconst EMAIL = /(?<![A-Z0-9._%+-])[A-Z0-9._%+-]{1,64}@[A-Z0-9-]+(?:\\.[A-Z0-9-]+)*\\.[A-Z]{2,}/gi\nconst URL_USERINFO = /\\b([a-z][a-z0-9+.-]{0,31}:\\/\\/)[^/\\s:@]+(?::[^/\\s@]*)?@/gi\nconst JWT = /eyJ[\\w-]+\\.[\\w-]+\\.[\\w-]+/g\nconst AUTH_SCHEME = /\\b(Bearer|Basic)\\s+\\S+/gi\nconst PARAMS_TAIL = /\\bparams:\\s.*$/s\nexport const SECRET_PARAMS: ReadonlySet<string> = new Set([\"token\", \"code\", \"state\", \"password\", \"secret\", \"key\", \"session\", \"access_token\", \"refresh_token\", \"id_token\"])\nconst SECRET_HEADERS = new Set([\n \"authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-qdc-connection-token\",\n \"x-forwarded-for\",\n \"x-real-ip\",\n \"forwarded\",\n \"user-agent\",\n])\nconst DROP_LOG_ATTRS = new Set([\"ip\", \"ip_address\", \"user_agent\", \"email\", \"user_email\", \"server.address\"])\nconst REDACT_KEYS = new Set([\"db.connection_string\", \"db.user\"])\nconst REDACT_PREFIXES = [\"net.peer.\", \"net.sock.\", \"net.host.\", \"network.peer.\", \"network.local.\"]\nconst DROP_SPAN_KEYS = new Set([\"user_agent.original\", \"http.user_agent\", \"client.address\", \"http.client_ip\"])\nconst DROP_SPAN_PREFIXES = [\"http.request.header.\", \"http.response.header.\"]\nconst URL_SPAN_KEYS = new Set([\"url.full\", \"http.url\", \"url\", \"http.target\", \"url.query\", \"http.query\"])\n\nconst SECRETS = Symbol.for(\"@quatronic/sdk.sentry-secret-values\")\ntype SecretHolder = { [SECRETS]?: { values: Set<string>; longestFirst: string[] } }\nconst secretHolder = globalThis as SecretHolder\n\n// On globalThis because a Next app can bundle this module twice: the copy\n// serverEnv() registers into is not necessarily the one beforeSend reads.\nfunction secretState(): NonNullable<SecretHolder[typeof SECRETS]> {\n return (secretHolder[SECRETS] ??= { values: new Set(), longestFirst: [] })\n}\n\nexport function registerSecretValues(values: Iterable<unknown>): void {\n const state = secretState()\n for (const v of values) if (typeof v === \"string\" && v.length >= 8) state.values.add(v)\n state.longestFirst = [...state.values].sort((a, b) => b.length - a.length)\n}\n\nfunction maskSecretValues(s: string): string {\n return secretState().longestFirst.reduce((acc, v) => acc.replaceAll(v, REDACTED), s)\n}\n\nexport function redactText(s: string): string {\n return maskSecretValues(s)\n .replace(URL_USERINFO, `$1${REDACTED}@`)\n .replace(PARAMS_TAIL, \"params: [redacted]\")\n .replace(AUTH_SCHEME, \"$1 [redacted]\")\n .replace(JWT, \"[jwt]\")\n .replace(EMAIL, \"[email]\")\n}\n\nfunction redactQuery(query: string): string {\n return query\n .split(\"&\")\n .map((pair) => {\n const [k, v] = pair.split(\"=\", 2)\n return v !== undefined && SECRET_PARAMS.has(k!.toLowerCase()) ? `${k}=[redacted]` : pair\n })\n .join(\"&\")\n}\n\nfunction redactUrl(url: string): string {\n const i = url.indexOf(\"?\")\n return i < 0 ? url : url.slice(0, i + 1) + redactQuery(url.slice(i + 1))\n}\n\n// For values that are either a URL/path or a bare query string (no `?`).\nfunction redactUrlOrQuery(v: string): string {\n return v.includes(\"?\") ? redactUrl(v) : redactQuery(v)\n}\n\ntype Dict = Record<string, unknown>\n\nexport interface SentryEventLike {\n server_name?: string\n user?: Dict\n request?: { url?: string; query_string?: unknown; cookies?: unknown; headers?: Record<string, string>; data?: unknown }\n message?: string\n exception?: { values?: Array<{ type?: string; value?: string }> }\n breadcrumbs?: Array<{ message?: string; data?: Dict }>\n contexts?: { nextjs?: Dict } & Dict\n}\n\nexport function scrubEvent<E extends SentryEventLike>(e: E): E {\n delete e.server_name\n if (e.user) e.user = e.user.id ? { id: e.user.id } : {}\n if (e.request) {\n delete e.request.cookies\n delete e.request.data\n if (e.request.url) e.request.url = redactUrl(e.request.url)\n if (typeof e.request.query_string === \"string\") e.request.query_string = redactQuery(e.request.query_string)\n if (e.request.headers) {\n e.request.headers = Object.fromEntries(\n Object.entries(e.request.headers).filter(([k]) => !SECRET_HEADERS.has(k.toLowerCase())),\n )\n }\n }\n const nextjs = e.contexts?.nextjs\n if (typeof nextjs?.request_path === \"string\") nextjs.request_path = redactUrl(nextjs.request_path)\n if (e.message) e.message = redactText(e.message)\n for (const v of e.exception?.values ?? []) if (v.value) v.value = redactText(v.value)\n for (const b of e.breadcrumbs ?? []) {\n if (b.message) b.message = redactText(b.message)\n const d = b.data\n if (!d) continue\n for (const k of [\"url\", \"from\", \"to\"]) if (typeof d[k] === \"string\") d[k] = redactUrl(d[k])\n if (typeof d[\"http.query\"] === \"string\") d[\"http.query\"] = redactUrlOrQuery(d[\"http.query\"])\n if (Array.isArray(d.arguments)) d.arguments = d.arguments.map((a) => (typeof a === \"string\" ? redactText(a) : a))\n }\n return e\n}\n\nexport interface SentryLogLike {\n message: string\n attributes?: Dict\n}\n\nexport function scrubLog<L extends SentryLogLike>(l: L): L {\n l.message = redactText(l.message)\n if (l.attributes) {\n const out: Dict = {}\n for (const [k, v] of Object.entries(l.attributes)) {\n if (DROP_LOG_ATTRS.has(k)) continue\n out[k] = typeof v === \"string\" ? redactText(v) : v\n }\n l.attributes = out\n }\n return l\n}\n\nexport interface SentrySpanLike {\n description?: string\n data?: Dict\n}\n\nexport function scrubSpan<S extends SentrySpanLike>(s: S): S {\n // Browser page-metric spans are described by the full page URL.\n if (typeof s.description === \"string\") s.description = redactUrl(s.description)\n for (const [k, v] of Object.entries(s.data ?? {})) {\n if (DROP_SPAN_KEYS.has(k) || DROP_SPAN_PREFIXES.some((p) => k.startsWith(p))) delete s.data![k]\n else if (REDACT_KEYS.has(k) || REDACT_PREFIXES.some((p) => k.startsWith(p))) s.data![k] = REDACTED\n else if (typeof v === \"string\" && URL_SPAN_KEYS.has(k)) s.data![k] = redactUrlOrQuery(v)\n }\n return s\n}\n"],"mappings":";AAAO,IAAM,WAAW;AAKxB,IAAM,QAAQ;AACd,IAAM,eAAe;AACrB,IAAM,MAAM;AACZ,IAAM,cAAc;AACpB,IAAM,cAAc;AACb,IAAM,gBAAqC,oBAAI,IAAI,CAAC,SAAS,QAAQ,SAAS,YAAY,UAAU,OAAO,WAAW,gBAAgB,iBAAiB,UAAU,CAAC;AACzK,IAAM,iBAAiB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AACD,IAAM,iBAAiB,oBAAI,IAAI,CAAC,MAAM,cAAc,cAAc,SAAS,cAAc,gBAAgB,CAAC;AAC1G,IAAM,cAAc,oBAAI,IAAI,CAAC,wBAAwB,SAAS,CAAC;AAC/D,IAAM,kBAAkB,CAAC,aAAa,aAAa,aAAa,iBAAiB,gBAAgB;AACjG,IAAM,iBAAiB,oBAAI,IAAI,CAAC,u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6 @@
1
1
  import {
2
2
  initSentry
3
- } from "./chunk-P5GBQVO7.js";
3
+ } from "./chunk-YFZB5EW6.js";
4
4
  import {
5
5
  readSentryConfig
6
6
  } from "./chunk-7ASQHY7O.js";
@@ -17,4 +17,4 @@ export {
17
17
  register,
18
18
  onRequestError
19
19
  };
20
- //# sourceMappingURL=chunk-WOFBDOMY.js.map
20
+ //# sourceMappingURL=chunk-POZI4OKJ.js.map
@@ -94,22 +94,6 @@ var MIGRATION_0007_EXPECTED_IDENTITY = `
94
94
  ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS expected_sub varchar(64);
95
95
  ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS expected_email varchar(320);
96
96
  `;
97
- var MIGRATION_0008_MOBILE = `
98
- ALTER TABLE auth.sessions ADD COLUMN IF NOT EXISTS kind varchar(16) NOT NULL DEFAULT 'web';
99
- ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS mobile_challenge varchar(64);
100
- ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS mobile_redirect text;
101
- ALTER TABLE auth.login_state ADD COLUMN IF NOT EXISTS ui_locales varchar(16);
102
-
103
- CREATE TABLE IF NOT EXISTS auth.mobile_handoff_codes (
104
- code_hash varchar(64) PRIMARY KEY,
105
- session_id uuid NOT NULL,
106
- challenge varchar(64) NOT NULL,
107
- expires_at timestamptz NOT NULL
108
- );
109
-
110
- CREATE INDEX IF NOT EXISTS ix_auth_mobile_handoff_expires
111
- ON auth.mobile_handoff_codes(expires_at);
112
- `;
113
97
  async function probe(db, expression) {
114
98
  const result = await db.execute(
115
99
  sql2.raw(`SELECT (${expression}) AS "applied"`)
@@ -185,19 +169,6 @@ var MIGRATIONS = [
185
169
  ["auth", "login_state", "expected_sub"],
186
170
  ["auth", "login_state", "expected_email"]
187
171
  )
188
- },
189
- {
190
- name: "0008_mobile",
191
- sql: MIGRATION_0008_MOBILE,
192
- isApplied: async (db) => await columnsExist(
193
- ["auth", "sessions", "kind"],
194
- ["auth", "login_state", "mobile_challenge"],
195
- ["auth", "login_state", "mobile_redirect"],
196
- ["auth", "login_state", "ui_locales"]
197
- )(db) && await relationsExist(
198
- ["auth", "mobile_handoff_codes"],
199
- ["auth", "ix_auth_mobile_handoff_expires"]
200
- )(db)
201
172
  }
202
173
  ];
203
174
  async function runAuthMigrations(db, opts = {}) {
@@ -223,4 +194,4 @@ export {
223
194
  grantRuntimeDefaultPrivileges,
224
195
  runAuthMigrations
225
196
  };
226
- //# sourceMappingURL=chunk-YCKDMG4B.js.map
197
+ //# sourceMappingURL=chunk-TPBRMW5N.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/db-core/migration-db.ts","../src/auth-core/migrate.ts"],"sourcesContent":["import { Pool } from \"pg\"\nimport { drizzle, type NodePgDatabase } from \"drizzle-orm/node-postgres\"\nimport { sql } from \"drizzle-orm\"\nimport { resolvePostgresConfig } from \"./postgres-config\"\n\nexport interface MigrationDb {\n readonly db: NodePgDatabase\n readonly close: () => Promise<void>\n}\n\n// Migrations get their own short-lived pool, separate from the app's\n// long-lived runtime pool — it exists only for the duration of the boot-time\n// migration call and is torn down immediately after.\nexport function createMigrationDb(databaseUrl: string): MigrationDb {\n const pool = new Pool(resolvePostgresConfig(databaseUrl))\n return { db: drizzle(pool), close: () => pool.end() }\n}\n\n// The addon's regular/admin credentials are both delivered as full DSNs\n// (POSTGRES_URI / POSTGRES_URI_ADMIN — see the templates SecretGroup\n// addonDependencies mapping), not as separate username/password fields, so\n// callers that need the runtime role's name for a GRANT statement parse it\n// out of the runtime connection string instead of reading it separately.\nexport function parseRoleFromUrl(databaseUrl: string): string {\n return decodeURIComponent(new URL(databaseUrl).username)\n}\n\n// `current_user` is compared as the server reports it, so the comparison holds\n// for a role whose name needed quoting in the DSN.\nasync function isCurrentUser(db: NodePgDatabase, role: string): Promise<boolean> {\n const result = await db.execute<{ current_user: string }>(\n sql.raw(`SELECT current_user AS \"current_user\"`),\n )\n return result.rows[0]?.current_user === role\n}\n\n// Safe to call on every boot, whether or not the migrator and runtime roles\n// are the same (the fallback case for environments that haven't opted into a\n// separate migration role yet — see MIGRATION_DATABASE_URL fallback in\n// portal-api/portal-web). ALTER DEFAULT PRIVILEGES only binds objects created\n// after it runs, so this also explicitly grants on ALL TABLES to cover\n// whatever this same run just created.\n//\n// The fallback case is skipped outright rather than issued anyway: granting a\n// role privileges to itself is either redundant (it owns the objects, so it\n// already holds everything) or impossible (it does not, so GRANT raises `must\n// be owner of table …` / `permission denied for schema …`). Issuing it made\n// that second case a boot-time failure on an environment where there was\n// nothing whatsoever to grant.\nexport async function grantRuntimeDefaultPrivileges(\n db: NodePgDatabase,\n schema: string,\n runtimeRole: string,\n): Promise<void> {\n if (await isCurrentUser(db, runtimeRole)) {\n return\n }\n await db.execute(\n sql.raw(`GRANT USAGE ON SCHEMA \"${schema}\" TO \"${runtimeRole}\"`),\n )\n await db.execute(\n sql.raw(\n `ALTER DEFAULT PRIVILEGES IN SCHEMA \"${schema}\" GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO \"${runtimeRole}\"`,\n ),\n )\n await db.execute(\n sql.raw(\n `GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA \"${schema}\" TO \"${runtimeRole}\"`,\n ),\n )\n}\n","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,YAAY;AACrB,SAAS,eAAoC;AAC7C,SAAS,WAAW;AAWb,SAAS,kBAAkB,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IACE,MAAM;AAAA,IACN,KAAK;AAAA,IACL,WAAW,aAAa,CAAC,QAAQ,eAAe,eAAe,CAAC;AAAA,EAClE;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,KAAK;AAAA,IACL,WAAW,aAAa,CAAC,QAAQ,eAAe,OAAO,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,KAAK;AAAA,IACL,WAAW,aAAa,CAAC,QAAQ,eAAe,SAAS,CAAC;AAAA,EAC5D;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,KAAK;AAAA,IACL,WAAW,aAAa,CAAC,QAAQ,YAAY,0BAA0B,CAAC;AAAA,EAC1E;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,KAAK;AAAA,IACL,WAAW;AAAA,MACT,CAAC,QAAQ,eAAe,cAAc;AAAA,MACtC,CAAC,QAAQ,eAAe,gBAAgB;AAAA,IAC1C;AAAA,EACF;AACF;AAYA,eAAsB,kBACpB,IACA,OAAiC,CAAC,GACnB;AACf,aAAW,aAAa,YAAY;AAClC,QAAI;AACF,UAAI,MAAM,UAAU,UAAU,EAAE,GAAG;AAIjC;AAAA,MACF;AACA,YAAM,GAAG,QAAQA,KAAI,IAAI,UAAU,GAAG,CAAC;AAAA,IACzC,SAAS,KAAK;AAKZ,YAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,YAAM,IAAI,MAAM,mBAAmB,UAAU,IAAI,aAAa,OAAO,IAAI,EAAE,OAAO,IAAI,CAAC;AAAA,IACzF;AAAA,EACF;AAEA,MAAI,KAAK,aAAa;AACpB,UAAM,8BAA8B,IAAI,QAAQ,KAAK,WAAW;AAAA,EAClE;AACF;","names":["sql","sql"]}
@@ -9,7 +9,7 @@ import {
9
9
  scrubEvent,
10
10
  scrubLog,
11
11
  scrubSpan
12
- } from "./chunk-VQKYPW5V.js";
12
+ } from "./chunk-IFESUTF2.js";
13
13
 
14
14
  // src/sentry-core/noise.ts
15
15
  var NOISE_EXACT = /* @__PURE__ */ new Set(["/favicon.ico", "/api/auth/me"]);
@@ -104,4 +104,4 @@ function initSentry(sentry, runtime, cfg, extra = {}) {
104
104
  export {
105
105
  initSentry
106
106
  };
107
- //# sourceMappingURL=chunk-P5GBQVO7.js.map
107
+ //# sourceMappingURL=chunk-YFZB5EW6.js.map
@@ -3,7 +3,7 @@
3
3
  // src/cli/skills-postinstall.ts
4
4
  import { execFileSync } from "child_process";
5
5
  import { existsSync as existsSync2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "fs";
6
- import { basename, dirname as dirname2, join as join2, resolve as resolve2, sep } from "path";
6
+ import { dirname as dirname2, join as join2, resolve as resolve2, sep } from "path";
7
7
  import { fileURLToPath as fileURLToPath2 } from "url";
8
8
 
9
9
  // src/cli/skills-core.ts
@@ -20,17 +20,14 @@ function parseFeatures(raw) {
20
20
  if (!RUNTIMES.includes(o.runtime)) throw new Error(`features.runtime must be one of ${RUNTIMES.join("|")}`);
21
21
  if (!AUTHS.includes(o.auth)) throw new Error(`features.auth must be one of ${AUTHS.join("|")}`);
22
22
  if (typeof o.db !== "boolean") throw new Error("features.db must be a boolean");
23
- if (o.mobile !== void 0 && typeof o.mobile !== "boolean") throw new Error("features.mobile must be a boolean");
24
- if (o.mobile === true && o.runtime !== "next") throw new Error("features.mobile needs runtime next");
25
- return { runtime: o.runtime, auth: o.auth, db: o.db, mobile: o.mobile === true };
23
+ return { runtime: o.runtime, auth: o.auth, db: o.db };
26
24
  }
27
25
  function inferFeatures(pkg, exists) {
28
26
  const deps = { ...pkg.devDependencies, ...pkg.dependencies };
29
27
  const runtime = "next" in deps ? "next" : "node";
30
28
  const auth = "better-auth" in deps ? "betterauth" : exists("src/lib/permissions.ts") ? "keycloak" : "none";
31
29
  const db = "drizzle-orm" in deps || Boolean(pkg.scripts?.["db:up"]) || exists("docker-compose.yml");
32
- const mobile = runtime === "next" && exists("mobile/package.json");
33
- return { runtime, auth, db, mobile };
30
+ return { runtime, auth, db };
34
31
  }
35
32
  function evalCondition(expr, f) {
36
33
  const e = expr.trim();
@@ -46,9 +43,6 @@ function evalCondition(expr, f) {
46
43
  case "db":
47
44
  if (options) throw new Error(`condition "${e}" takes no value`);
48
45
  return f.db;
49
- case "mobile":
50
- if (options) throw new Error(`condition "${e}" takes no value`);
51
- return f.mobile;
52
46
  default:
53
47
  throw new Error(`unknown condition "${e}"`);
54
48
  }
@@ -72,7 +66,7 @@ function renderTemplate(src, f) {
72
66
  const tag = m[1];
73
67
  if (tag.startsWith("#if ")) {
74
68
  const cond = tag.slice(4).trim();
75
- evalCondition(cond, { runtime: "next", auth: "none", db: false, mobile: false });
69
+ evalCondition(cond, { runtime: "next", auth: "none", db: false });
76
70
  const node = { cond, then: [], else: [] };
77
71
  push(node);
78
72
  stack.push({ node, inElse: false });
@@ -171,7 +165,7 @@ extension file.
171
165
 
172
166
  \`qore-add-env-key\`, \`qore-add-integration\`, \`qore-add-connection\`,
173
167
  \`qore-use-permissions\`, \`qore-observability\` and \`qore-use-database\`
174
- produce code the portal reads: the Variables tab, the Integrations tab,
168
+ produce code the portal reads: the Secrets tab, the Integrations tab,
175
169
  connections, roles, Monitoring, the local database. An
176
170
  extension may add to them but not relax them, and turning one off does not turn
177
171
  off the SDK's lint rules that check the same things.
@@ -417,7 +411,7 @@ function renderReport(p, opts) {
417
411
  const lines = [
418
412
  "### Qore skills",
419
413
  "",
420
- `${opts.check ? "Out of date: `qore-skills sync` would update" : "Synced"} the managed skills for \`@quatronic/sdk@${p.manifest.sdkVersion}\` (runtime \`${f.runtime}\`, auth \`${f.auth}\`, database \`${f.db ? "yes" : "no"}\`${f.mobile ? ", mobile app `yes`" : ""}${opts.inferred ? ", inferred from the app \u2014 pin with `qore-skills sync --features`" : ", pinned in the manifest"}).`
414
+ `${opts.check ? "Out of date: `qore-skills sync` would update" : "Synced"} the managed skills for \`@quatronic/sdk@${p.manifest.sdkVersion}\` (runtime \`${f.runtime}\`, auth \`${f.auth}\`, database \`${f.db ? "yes" : "no"}\`${opts.inferred ? ", inferred from the app \u2014 pin with `qore-skills sync --features`" : ", pinned in the manifest"}).`
421
415
  ];
422
416
  const managedWrites = [...p.writes.keys()].filter((r) => r !== MANIFEST_PATH);
423
417
  if (!managedWrites.length && !p.deletes.length && p.claudeMd === void 0) {
@@ -667,7 +661,6 @@ function runPostinstall(e) {
667
661
  if (!e.self.split(sep).includes("node_modules")) return { kind: "not-installed" };
668
662
  const app = findApp(e.env.INIT_CWD ?? process.cwd());
669
663
  if (!app) return { kind: "no-app" };
670
- if (basename(app) === "mobile" && dependsOnSdk(dirname2(app))) return { kind: "mobile-project" };
671
664
  if (!existsSync2(join2(app, ".git"))) return { kind: "not-a-checkout" };
672
665
  const manifestPath = join2(app, ".claude", MANIFEST_PATH);
673
666
  const manifest = existsSync2(manifestPath) ? parseManifest(readFileSync2(manifestPath, "utf8")) : null;
@@ -19,17 +19,14 @@ function parseFeatures(raw) {
19
19
  if (!RUNTIMES.includes(o.runtime)) throw new Error(`features.runtime must be one of ${RUNTIMES.join("|")}`);
20
20
  if (!AUTHS.includes(o.auth)) throw new Error(`features.auth must be one of ${AUTHS.join("|")}`);
21
21
  if (typeof o.db !== "boolean") throw new Error("features.db must be a boolean");
22
- if (o.mobile !== void 0 && typeof o.mobile !== "boolean") throw new Error("features.mobile must be a boolean");
23
- if (o.mobile === true && o.runtime !== "next") throw new Error("features.mobile needs runtime next");
24
- return { runtime: o.runtime, auth: o.auth, db: o.db, mobile: o.mobile === true };
22
+ return { runtime: o.runtime, auth: o.auth, db: o.db };
25
23
  }
26
24
  function inferFeatures(pkg, exists) {
27
25
  const deps = { ...pkg.devDependencies, ...pkg.dependencies };
28
26
  const runtime = "next" in deps ? "next" : "node";
29
27
  const auth = "better-auth" in deps ? "betterauth" : exists("src/lib/permissions.ts") ? "keycloak" : "none";
30
28
  const db = "drizzle-orm" in deps || Boolean(pkg.scripts?.["db:up"]) || exists("docker-compose.yml");
31
- const mobile = runtime === "next" && exists("mobile/package.json");
32
- return { runtime, auth, db, mobile };
29
+ return { runtime, auth, db };
33
30
  }
34
31
  function evalCondition(expr, f) {
35
32
  const e = expr.trim();
@@ -45,9 +42,6 @@ function evalCondition(expr, f) {
45
42
  case "db":
46
43
  if (options) throw new Error(`condition "${e}" takes no value`);
47
44
  return f.db;
48
- case "mobile":
49
- if (options) throw new Error(`condition "${e}" takes no value`);
50
- return f.mobile;
51
45
  default:
52
46
  throw new Error(`unknown condition "${e}"`);
53
47
  }
@@ -71,7 +65,7 @@ function renderTemplate(src, f) {
71
65
  const tag = m[1];
72
66
  if (tag.startsWith("#if ")) {
73
67
  const cond = tag.slice(4).trim();
74
- evalCondition(cond, { runtime: "next", auth: "none", db: false, mobile: false });
68
+ evalCondition(cond, { runtime: "next", auth: "none", db: false });
75
69
  const node = { cond, then: [], else: [] };
76
70
  push(node);
77
71
  stack.push({ node, inElse: false });
@@ -170,7 +164,7 @@ extension file.
170
164
 
171
165
  \`qore-add-env-key\`, \`qore-add-integration\`, \`qore-add-connection\`,
172
166
  \`qore-use-permissions\`, \`qore-observability\` and \`qore-use-database\`
173
- produce code the portal reads: the Variables tab, the Integrations tab,
167
+ produce code the portal reads: the Secrets tab, the Integrations tab,
174
168
  connections, roles, Monitoring, the local database. An
175
169
  extension may add to them but not relax them, and turning one off does not turn
176
170
  off the SDK's lint rules that check the same things.
@@ -416,7 +410,7 @@ function renderReport(p, opts) {
416
410
  const lines = [
417
411
  "### Qore skills",
418
412
  "",
419
- `${opts.check ? "Out of date: `qore-skills sync` would update" : "Synced"} the managed skills for \`@quatronic/sdk@${p.manifest.sdkVersion}\` (runtime \`${f.runtime}\`, auth \`${f.auth}\`, database \`${f.db ? "yes" : "no"}\`${f.mobile ? ", mobile app `yes`" : ""}${opts.inferred ? ", inferred from the app \u2014 pin with `qore-skills sync --features`" : ", pinned in the manifest"}).`
413
+ `${opts.check ? "Out of date: `qore-skills sync` would update" : "Synced"} the managed skills for \`@quatronic/sdk@${p.manifest.sdkVersion}\` (runtime \`${f.runtime}\`, auth \`${f.auth}\`, database \`${f.db ? "yes" : "no"}\`${opts.inferred ? ", inferred from the app \u2014 pin with `qore-skills sync --features`" : ", pinned in the manifest"}).`
420
414
  ];
421
415
  const managedWrites = [...p.writes.keys()].filter((r) => r !== MANIFEST_PATH);
422
416
  if (!managedWrites.length && !p.deletes.length && p.claudeMd === void 0) {
@@ -1,8 +1,5 @@
1
1
  import { Rule, Linter } from 'eslint';
2
2
 
3
- declare const mobileRules: Record<string, Rule.RuleModule>;
4
- declare const MOBILE_RULE_IDS: Record<string, string>;
5
-
6
3
  declare const observabilityRules: Record<string, Rule.RuleModule>;
7
4
  declare const OBSERVABILITY_RULE_IDS: Record<string, string>;
8
5
 
@@ -34,13 +31,6 @@ interface QdcSecurityConfigs {
34
31
  * Separate from `recommended` so a bump does not turn an older app's lint red.
35
32
  */
36
33
  observability: Linter.Config[];
37
- /**
38
- * For the Expo app in a module's `mobile/` directory, spread from
39
- * `mobile/eslint.config.js`. Its `src/` is the phone's code: no server
40
- * imports, no secrets or server variables, and every request through
41
- * `apiFetch`. The web counterpart is `qdc/no-mobile-import` in `recommended`.
42
- */
43
- expo: Linter.Config[];
44
34
  }
45
35
  /**
46
36
  * The plugin object, typed explicitly: an inferred type here reaches into
@@ -57,4 +47,4 @@ interface QdcSecurityPlugin {
57
47
  declare const configs: QdcSecurityConfigs;
58
48
  declare const qdcSecurity: QdcSecurityPlugin;
59
49
 
60
- export { MOBILE_RULE_IDS, OBSERVABILITY_RULE_IDS, type QdcSecurityConfigs, type QdcSecurityPlugin, RULE_IDS, configs, qdcSecurity as default, mobileRules, observabilityRules, rules };
50
+ export { OBSERVABILITY_RULE_IDS, type QdcSecurityConfigs, type QdcSecurityPlugin, RULE_IDS, configs, qdcSecurity as default, observabilityRules, rules };
@@ -334,101 +334,6 @@ var RULE_IDS = {
334
334
  "integration-static-call": "QDC-NET-003"
335
335
  };
336
336
 
337
- // src/eslint/mobile.ts
338
- var WEB_ONLY = ["@quatronic/sdk/next/", "@quatronic/sdk/node/", "react-dom", "next", "next/"];
339
- var DEVICE_ONLY = ["@quatronic/sdk/expo/", "react-native", "react-native/", "expo-", "@react-native/", "@react-native-community/"];
340
- var matches = (source, prefixes) => prefixes.some((p) => p.endsWith("/") || p.endsWith("-") ? source.startsWith(p) : source === p || source.startsWith(`${p}/`));
341
- function banPrefixes(id, message, prefixes) {
342
- const text = `${id} - ${message}`;
343
- return {
344
- meta: meta(text, "problem"),
345
- create(context) {
346
- const report = reporter(context, text);
347
- const flag = (node) => {
348
- const source = node.source;
349
- if (source?.type === "Literal" && typeof source.value === "string" && matches(source.value, prefixes)) report(node);
350
- };
351
- return listener({ ImportDeclaration: flag, ImportExpression: flag, ExportAllDeclaration: flag, ExportNamedDeclaration: flag });
352
- }
353
- };
354
- }
355
- function envName(node) {
356
- const object = node.object;
357
- if (object?.type !== "MemberExpression") return null;
358
- if (object.object?.type !== "Identifier" || object.object.name !== "process") return null;
359
- if (object.property?.type !== "Identifier" || object.property.name !== "env") return null;
360
- if (node.property?.type === "Identifier" && !node.computed) return node.property.name ?? null;
361
- if (node.property?.type === "Literal" && typeof node.property.value === "string") return node.property.value;
362
- return null;
363
- }
364
- var SECRET_WORD = /SECRET|TOKEN|PASSWORD|PRIVATE|(^|_)KEY($|_)/;
365
- var PUBLIC_ALLOWED = /* @__PURE__ */ new Set(["EXPO_PUBLIC_SENTRY_DSN"]);
366
- var noSecretPublicEnv = {
367
- meta: meta("QDC-MOB-002 - no secret in an EXPO_PUBLIC_* variable", "problem"),
368
- create(context) {
369
- const report = reporter(
370
- context,
371
- "QDC-MOB-002 - every EXPO_PUBLIC_* value is compiled into the app and readable by anyone who installs it. A secret belongs on the app's server; call it through apiFetch."
372
- );
373
- return listener({
374
- MemberExpression: (node) => {
375
- const name = envName(node);
376
- if (name?.startsWith("EXPO_PUBLIC_") && !PUBLIC_ALLOWED.has(name) && SECRET_WORD.test(name.slice(12))) report(node);
377
- }
378
- });
379
- }
380
- };
381
- var noPrivateEnv = {
382
- meta: meta("QDC-MOB-003 - the phone only has EXPO_PUBLIC_* variables", "problem"),
383
- create(context) {
384
- const report = reporter(
385
- context,
386
- "QDC-MOB-003 - only EXPO_PUBLIC_* variables reach the phone; anything else is undefined at runtime. Server configuration stays on the server."
387
- );
388
- return listener({
389
- MemberExpression: (node) => {
390
- const name = envName(node);
391
- if (name && !name.startsWith("EXPO_PUBLIC_") && name !== "NODE_ENV") report(node);
392
- }
393
- });
394
- }
395
- };
396
- var noRawFetch = {
397
- meta: meta("QDC-MOB-004 - the phone calls its server through apiFetch", "problem"),
398
- create(context) {
399
- const report = reporter(
400
- context,
401
- "QDC-MOB-004 - call the app's own server through apiFetch from @quatronic/sdk/expo/auth: it adds the session, the app version and the trace, and refuses any other host. A third-party API is called from the server."
402
- );
403
- return listener({
404
- "CallExpression[callee.name='fetch']": report,
405
- "CallExpression[callee.type='MemberExpression'][callee.property.name='fetch'][callee.object.name=/^(globalThis|window|global)$/]": report
406
- });
407
- }
408
- };
409
- var mobileRules = {
410
- "no-web-import": banPrefixes(
411
- "QDC-MOB-001",
412
- "This is the phone app. Server and web entries (@quatronic/sdk/next/*, node/*, react-dom, next) do not run in React Native; use @quatronic/sdk/expo/*.",
413
- WEB_ONLY
414
- ),
415
- "no-secret-public-env": noSecretPublicEnv,
416
- "no-private-env": noPrivateEnv,
417
- "no-raw-fetch": noRawFetch,
418
- "no-mobile-import": banPrefixes(
419
- "QDC-MOB-005",
420
- "This is the Next app. @quatronic/sdk/expo/*, react-native and expo-* run on the phone only and belong in mobile/.",
421
- DEVICE_ONLY
422
- )
423
- };
424
- var MOBILE_RULE_IDS = {
425
- "no-web-import": "QDC-MOB-001",
426
- "no-secret-public-env": "QDC-MOB-002",
427
- "no-private-env": "QDC-MOB-003",
428
- "no-raw-fetch": "QDC-MOB-004",
429
- "no-mobile-import": "QDC-MOB-005"
430
- };
431
-
432
337
  // src/eslint/observability.ts
433
338
  var SENTRY_MODULE = /^@sentry\//;
434
339
  var BANNED = /* @__PURE__ */ new Set(["init", "withSentryConfig"]);
@@ -562,7 +467,7 @@ var OBSERVABILITY_RULE_IDS = {
562
467
  // src/eslint/index.ts
563
468
  var plugin = {
564
469
  meta: { name: "@quatronic/sdk/eslint" },
565
- rules: { ...rules, ...observabilityRules, ...mobileRules }
470
+ rules: { ...rules, ...observabilityRules }
566
471
  };
567
472
  var SRC_FILES = ["src/**/*.{ts,tsx}"];
568
473
  var TEST_FILES = ["**/*.test.{ts,tsx}", "**/*.spec.{ts,tsx}"];
@@ -590,9 +495,7 @@ var recommended = [
590
495
  "qdc/safe-fetch": "warn",
591
496
  "qdc/no-undeclared-external-call": "warn",
592
497
  // Advisory too: the call works either way, the portal just cannot list it.
593
- "qdc/integration-static-call": "warn",
594
- // The web half of the web/mobile boundary; `configs.expo` holds the other.
595
- "qdc/no-mobile-import": "error"
498
+ "qdc/integration-static-call": "warn"
596
499
  }
597
500
  },
598
501
  {
@@ -653,36 +556,14 @@ var observability = [
653
556
  rules: { "no-console": "off" }
654
557
  }
655
558
  ];
656
- var expo = [
657
- {
658
- files: SRC_FILES,
659
- plugins: { qdc: plugin },
660
- rules: {
661
- "qdc/no-web-import": "error",
662
- "qdc/no-secret-public-env": "error",
663
- "qdc/no-private-env": "error",
664
- "qdc/no-raw-fetch": "error",
665
- "qdc/no-string-eval": "error",
666
- // Phone logs go through `log` from @quatronic/sdk/expo/log, which reaches Sentry.
667
- "no-console": "error"
668
- }
669
- },
670
- {
671
- // Tests stub fetch and print on purpose; the jest setup reads its own env.
672
- files: [...TEST_FILES, "**/__tests__/**"],
673
- rules: { "qdc/no-raw-fetch": "off", "qdc/no-private-env": "off", "no-console": "off" }
674
- }
675
- ];
676
- var configs = { recommended, warn, observability, expo };
677
- var qdcSecurity = { ...plugin, configs, RULE_IDS: { ...RULE_IDS, ...MOBILE_RULE_IDS } };
559
+ var configs = { recommended, warn, observability };
560
+ var qdcSecurity = { ...plugin, configs, RULE_IDS };
678
561
  var eslint_default = qdcSecurity;
679
562
  export {
680
- MOBILE_RULE_IDS,
681
563
  OBSERVABILITY_RULE_IDS,
682
564
  RULE_IDS,
683
565
  configs,
684
566
  eslint_default as default,
685
- mobileRules,
686
567
  observabilityRules,
687
568
  rules
688
569
  };