@quatronic/sdk 0.10.1 → 0.11.0-test.0f51557
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/chunk-JM5LHJUJ.js +32 -0
- package/dist/chunk-JM5LHJUJ.js.map +1 -0
- package/dist/{chunk-YFZB5EW6.js → chunk-P5GBQVO7.js} +2 -2
- package/dist/{chunk-IFESUTF2.js → chunk-VQKYPW5V.js} +7 -3
- package/dist/chunk-VQKYPW5V.js.map +1 -0
- package/dist/{chunk-POZI4OKJ.js → chunk-WOFBDOMY.js} +2 -2
- package/dist/{chunk-TPBRMW5N.js → chunk-YCKDMG4B.js} +30 -1
- package/dist/chunk-YCKDMG4B.js.map +1 -0
- package/dist/chunk-YJZZURE4.js +83 -0
- package/dist/chunk-YJZZURE4.js.map +1 -0
- package/dist/cli/skills-postinstall.js +13 -6
- package/dist/cli/skills.js +11 -5
- package/dist/context-CWvUIBHJ.d.ts +196 -0
- package/dist/eslint/index.d.ts +11 -1
- package/dist/eslint/index.js +123 -4
- package/dist/eslint/index.js.map +1 -1
- package/dist/expo/auth/index.d.ts +14 -0
- package/dist/expo/auth/index.js +324 -0
- package/dist/expo/auth/index.js.map +1 -0
- package/dist/expo/config/index.d.ts +38 -0
- package/dist/expo/config/index.js +35 -0
- package/dist/expo/config/index.js.map +1 -0
- package/dist/expo/log/index.d.ts +9 -0
- package/dist/expo/log/index.js +16 -0
- package/dist/expo/log/index.js.map +1 -0
- package/dist/expo/query/index.d.ts +41 -0
- package/dist/expo/query/index.js +98 -0
- package/dist/expo/query/index.js.map +1 -0
- package/dist/expo/sentry/index.d.ts +33 -0
- package/dist/expo/sentry/index.js +121 -0
- package/dist/expo/sentry/index.js.map +1 -0
- package/dist/expo/testing/index.d.ts +32 -0
- package/dist/expo/testing/index.js +58 -0
- package/dist/expo/testing/index.js.map +1 -0
- package/dist/expo/updates/index.d.ts +51 -0
- package/dist/expo/updates/index.js +163 -0
- package/dist/expo/updates/index.js.map +1 -0
- package/dist/next/auth/index.d.ts +50 -0
- package/dist/next/auth/index.js +523 -101
- package/dist/next/auth/index.js.map +1 -1
- package/dist/next/boot/index.js +3 -3
- package/dist/next/db/index.js +1 -1
- package/dist/next/security/index.d.ts +24 -1
- package/dist/next/security/index.js +29 -0
- package/dist/next/security/index.js.map +1 -1
- package/dist/next/sentry/client.js +3 -3
- package/dist/next/sentry/client.js.map +1 -1
- package/dist/next/sentry/index.js +1 -1
- package/dist/next/sentry/register.js +3 -3
- package/dist/node/sentry/index.js +1 -1
- package/dist/node/sentry/register.js +2 -2
- package/package.json +85 -2
- package/skills/catalog.json +3 -0
- package/skills/qore-add-api-route/SKILL.md +1 -1
- package/skills/qore-add-connection/SKILL.next.md +3 -1
- package/skills/qore-add-connection/SKILL.node.md +3 -1
- package/skills/qore-add-env-key/SKILL.md +174 -9
- package/skills/qore-add-feature/SKILL.md +1 -1
- package/skills/qore-add-integration/SKILL.next.md +4 -2
- package/skills/qore-add-integration/SKILL.node.md +6 -6
- package/skills/qore-add-page/SKILL.md +1 -1
- package/skills/qore-author-skill/SKILL.md +1 -1
- package/skills/qore-debug-issue/SKILL.md +10 -0
- package/skills/qore-mobile-add-screen/SKILL.md +64 -0
- package/skills/qore-mobile-call-server/SKILL.md +75 -0
- package/skills/qore-mobile-run-on-device/SKILL.md +44 -0
- package/skills/qore-observability/SKILL.md +17 -0
- package/skills/qore-secure-io/SKILL.md +15 -0
- package/skills/qore-ship-checklist/SKILL.md +10 -0
- package/skills/qore-translate-strings/SKILL.md +10 -0
- package/skills/qore-use-addons/SKILL.md +2 -0
- package/skills/qore-use-database/SKILL.md +2 -0
- package/skills/qore-use-design-system/SKILL.md +1 -1
- package/skills/qore-use-mail-domain/SKILL.next.md +1 -1
- package/skills/qore-use-mail-domain/SKILL.node.md +2 -2
- package/skills/qore-use-permissions/SKILL.md +10 -0
- package/dist/chunk-IFESUTF2.js.map +0 -1
- package/dist/chunk-TPBRMW5N.js.map +0 -1
- /package/dist/{chunk-YFZB5EW6.js.map → chunk-P5GBQVO7.js.map} +0 -0
- /package/dist/{chunk-POZI4OKJ.js.map → chunk-WOFBDOMY.js.map} +0 -0
package/dist/next/boot/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
onRequestError,
|
|
3
3
|
register
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-WOFBDOMY.js";
|
|
5
|
+
import "../../chunk-P5GBQVO7.js";
|
|
6
6
|
import "../../chunk-MET4SIMB.js";
|
|
7
7
|
import "../../chunk-7ASQHY7O.js";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-VQKYPW5V.js";
|
|
9
9
|
|
|
10
10
|
// src/next/boot/index.ts
|
|
11
11
|
async function qoreRegister(node) {
|
package/dist/next/db/index.js
CHANGED
|
@@ -127,6 +127,29 @@ interface QoreProxyOptions {
|
|
|
127
127
|
*/
|
|
128
128
|
declare function qoreProxy(options?: QoreProxyOptions): SecuredProxy;
|
|
129
129
|
|
|
130
|
+
declare const API_LEVEL_HEADER = "x-qore-api-level";
|
|
131
|
+
interface MobileApiLevels {
|
|
132
|
+
/** The API level this server speaks. */
|
|
133
|
+
apiLevel: number;
|
|
134
|
+
/** The oldest phone build's level this server still serves. */
|
|
135
|
+
minApiLevel: number;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* 426 for a phone build below `minApiLevel`, else `null`. A request without
|
|
139
|
+
* the header passes: the web pages call the same routes, and a build from
|
|
140
|
+
* before the contract cannot be told apart from them. A header that is not an
|
|
141
|
+
* integer counts as level 0.
|
|
142
|
+
*/
|
|
143
|
+
declare function requireMobileApiLevel(req: Request, minApiLevel: number): Response | null;
|
|
144
|
+
/**
|
|
145
|
+
* The app's `src/app/api/qore/app-version/route.ts`: a public GET that tells a
|
|
146
|
+
* phone whether its build is still served. Throws at import when the levels
|
|
147
|
+
* contradict each other, so a bad edit fails the build rather than a device.
|
|
148
|
+
*/
|
|
149
|
+
declare function createAppVersionRoute(levels: MobileApiLevels): {
|
|
150
|
+
GET: () => Response;
|
|
151
|
+
};
|
|
152
|
+
|
|
130
153
|
/**
|
|
131
154
|
* What a Next proxy (formerly "middleware") is allowed to be.
|
|
132
155
|
*
|
|
@@ -173,4 +196,4 @@ declare const NONCE_HEADER = "x-qdc-nonce";
|
|
|
173
196
|
*/
|
|
174
197
|
declare function withSecurityHeaders(handler: ProxyHandlerFn, options?: SecurityHeaderOptions): SecuredProxy;
|
|
175
198
|
|
|
176
|
-
export { type CspReportFields, type CspReportLogger, type CspReportRouteOptions, NONCE_HEADER, type ProxyHandlerFn, QORE_CSP_REPORT_URI, type QoreProxyAuth, type QoreProxyOptions, STATIC_SECURITY_HEADERS, type SecuredProxy, type SecurityHeaderOptions, buildCsp, createCspReportRoute, proxyMatcher, qoreProxy, readCspReport, withSecurityHeaders };
|
|
199
|
+
export { API_LEVEL_HEADER, type CspReportFields, type CspReportLogger, type CspReportRouteOptions, type MobileApiLevels, NONCE_HEADER, type ProxyHandlerFn, QORE_CSP_REPORT_URI, type QoreProxyAuth, type QoreProxyOptions, STATIC_SECURITY_HEADERS, type SecuredProxy, type SecurityHeaderOptions, buildCsp, createAppVersionRoute, createCspReportRoute, proxyMatcher, qoreProxy, readCspReport, requireMobileApiLevel, withSecurityHeaders };
|
|
@@ -99,6 +99,32 @@ function qoreProxy(options = {}) {
|
|
|
99
99
|
);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
// src/next/security/apiLevel.ts
|
|
103
|
+
var API_LEVEL_HEADER = "x-qore-api-level";
|
|
104
|
+
function assertLevels({ apiLevel, minApiLevel }) {
|
|
105
|
+
for (const [name, v] of [["apiLevel", apiLevel], ["minApiLevel", minApiLevel]]) {
|
|
106
|
+
if (!Number.isInteger(v) || v < 0) throw new Error(`${name} must be a non-negative integer, got ${v}`);
|
|
107
|
+
}
|
|
108
|
+
if (minApiLevel > apiLevel) throw new Error(`minApiLevel (${minApiLevel}) is above apiLevel (${apiLevel})`);
|
|
109
|
+
}
|
|
110
|
+
function requireMobileApiLevel(req, minApiLevel) {
|
|
111
|
+
const raw = req.headers.get(API_LEVEL_HEADER);
|
|
112
|
+
if (raw === null) return null;
|
|
113
|
+
const level = /^\d{1,6}$/.test(raw.trim()) ? Number(raw.trim()) : 0;
|
|
114
|
+
if (level >= minApiLevel) return null;
|
|
115
|
+
return Response.json(
|
|
116
|
+
{ error: "upgrade_required", minApiLevel },
|
|
117
|
+
{ status: 426, headers: { "cache-control": "no-store" } }
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
function createAppVersionRoute(levels) {
|
|
121
|
+
assertLevels(levels);
|
|
122
|
+
const body = { apiLevel: levels.apiLevel, minApiLevel: levels.minApiLevel };
|
|
123
|
+
return {
|
|
124
|
+
GET: () => Response.json(body, { headers: { "cache-control": "no-store" } })
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
|
|
102
128
|
// src/next/security/index.ts
|
|
103
129
|
var NONCE_BYTES = 16;
|
|
104
130
|
var NONCE_HEADER = "x-qdc-nonce";
|
|
@@ -151,14 +177,17 @@ function withSecurityHeaders(handler, options = {}) {
|
|
|
151
177
|
};
|
|
152
178
|
}
|
|
153
179
|
export {
|
|
180
|
+
API_LEVEL_HEADER,
|
|
154
181
|
NONCE_HEADER,
|
|
155
182
|
QORE_CSP_REPORT_URI,
|
|
156
183
|
STATIC_SECURITY_HEADERS,
|
|
157
184
|
buildCsp,
|
|
185
|
+
createAppVersionRoute,
|
|
158
186
|
createCspReportRoute,
|
|
159
187
|
proxyMatcher,
|
|
160
188
|
qoreProxy,
|
|
161
189
|
readCspReport,
|
|
190
|
+
requireMobileApiLevel,
|
|
162
191
|
withSecurityHeaders
|
|
163
192
|
};
|
|
164
193
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/security/index.ts","../../../src/security-core/csp.ts","../../../src/next/security/qoreProxy.ts"],"sourcesContent":["import { NextResponse } from \"next/server\"\nimport type { NextFetchEvent, NextRequest } from \"next/server\"\n\nimport { buildCsp, cspHeaderName, type SecurityHeaderOptions } from \"../../security-core/csp\"\nimport { STATIC_SECURITY_HEADERS } from \"../../security-core/headers\"\n\nexport { buildCsp } from \"../../security-core/csp\"\nexport type { SecurityHeaderOptions } from \"../../security-core/csp\"\nexport { STATIC_SECURITY_HEADERS } from \"../../security-core/headers\"\nexport { proxyMatcher } from \"../../security-core/proxy\"\nexport { createCspReportRoute, readCspReport, QORE_CSP_REPORT_URI } from \"../../security-core/cspReport\"\nexport { qoreProxy } from \"./qoreProxy\"\nexport type { QoreProxyAuth, QoreProxyOptions } from \"./qoreProxy\"\nexport type {\n CspReportFields,\n CspReportLogger,\n CspReportRouteOptions,\n} from \"../../security-core/cspReport\"\n\n/**\n * What a Next proxy (formerly \"middleware\") is allowed to be.\n *\n * Named `ProxyHandlerFn` rather than `ProxyHandler` because `ProxyHandler<T>`\n * is a TypeScript lib global — exporting that name would shadow it in every\n * file that imports from this entry point.\n *\n * Returning nothing means \"pass through\", and that is the shape to prefer: it\n * lets `withSecurityHeaders` build the pass-through response itself, which is\n * the only way the nonce reaches the renderer (see below).\n */\nexport type ProxyHandlerFn = (\n request: NextRequest,\n event: NextFetchEvent,\n) => Response | undefined | null | Promise<Response | undefined | null>\n\n/**\n * What `withSecurityHeaders` returns: the full Next proxy signature, rather\n * than the handler's own. The wrapper genuinely accepts both arguments and\n * genuinely always resolves to a `Response` — a handler that returns nothing\n * still comes back as a pass-through. Next accepts this shape as a `proxy`\n * export unchanged.\n *\n * Named because `@quatronic/sdk/next/security/testing` takes one.\n */\nexport type SecuredProxy = (request: NextRequest, event: NextFetchEvent) => Promise<Response>\n\n/** 128 bits, the CSP spec's floor. */\nconst NONCE_BYTES = 16\n\n/** The header app code reads to nonce its own inline script or style. */\nexport const NONCE_HEADER = \"x-qdc-nonce\"\n\nfunction generateNonce(): string {\n // `crypto.getRandomValues`, not `randomUUID()`: a UUID is 122 bits of\n // randomness wearing a fixed-format costume, and `randomUUID` is absent from\n // some edge runtimes. Web Crypto is present in both edge and node.\n const bytes = new Uint8Array(NONCE_BYTES)\n crypto.getRandomValues(bytes)\n let binary = \"\"\n for (const byte of bytes) binary += String.fromCharCode(byte)\n return btoa(binary)\n}\n\nfunction isPassThrough(response: Response): boolean {\n // How `NextResponse.next()` marks itself. Reading it is a dependency on a\n // Next internal, so it is the *fallback* path only — a handler that returns\n // nothing never reaches here. If Next ever renames the marker the cost is a\n // response that carries the headers but not the request-side nonce, which is\n // exactly what we would have had without this branch.\n return response.headers.get(\"x-middleware-next\") === \"1\"\n}\n\nfunction carryOver(from: Response, to: Response): void {\n from.headers.forEach((value, key) => {\n // `x-middleware-*` is Next's own pass-through plumbing, including the\n // encoding of the forwarded request headers. The fresh response regenerates\n // all of it; copying the stale copy over would undo the nonce we just set.\n if (key.toLowerCase().startsWith(\"x-middleware-\")) return\n if (key.toLowerCase() === \"set-cookie\") return\n to.headers.set(key, value)\n })\n // `forEach` folds multiple Set-Cookie headers into one comma-joined string,\n // which no browser parses back into two cookies. `getSetCookie` is the only\n // accessor that keeps them separate.\n for (const cookie of from.headers.getSetCookie?.() ?? []) {\n to.headers.append(\"set-cookie\", cookie)\n }\n}\n\nfunction applySecurityHeaders(response: Response, cspName: string, csp: string): void {\n for (const [name, value] of STATIC_SECURITY_HEADERS) {\n response.headers.set(name, value)\n }\n response.headers.set(cspName, csp)\n}\n\n/**\n * Wrap a Next proxy so every response it produces carries the QDC security\n * headers and a per-response CSP nonce.\n *\n * The nonce goes on the **request** headers under two names: `x-qdc-nonce` for\n * app code, and `Content-Security-Policy` because that is where Next itself\n * looks for it. Next parses the request's CSP header, extracts `nonce-…`, and\n * stamps that nonce onto the bootstrap `<script>` tags it emits. Without it,\n * every generated app breaks the moment `script-src` stops allowing\n * `'unsafe-inline'`.\n *\n * A nonce is per response. Any route whose HTML carries one must render\n * dynamically and must not be cached by a CDN, or every visitor shares a single\n * nonce and the nonce protects nothing.\n *\n * The return type is the full proxy signature rather than the handler's own,\n * because the wrapper genuinely does accept both arguments and genuinely always\n * resolves to a `Response` — a handler that returns nothing still comes back as\n * a pass-through. Next accepts this shape as a `proxy` export unchanged.\n */\nexport function withSecurityHeaders(\n handler: ProxyHandlerFn,\n options: SecurityHeaderOptions = {},\n): SecuredProxy {\n return async (request: NextRequest, event: NextFetchEvent): Promise<Response> => {\n const nonce = generateNonce()\n const csp = buildCsp(nonce, { ...options, sentryDsn: options.sentryDsn ?? process.env.SENTRY_DSN })\n const cspName = cspHeaderName(options)\n\n const requestHeaders = new Headers(request.headers)\n requestHeaders.set(NONCE_HEADER, nonce)\n // Always the enforcing name on the request, even in report-only mode: this\n // copy is how Next finds the nonce, not a policy the browser ever sees.\n requestHeaders.set(\"content-security-policy\", csp)\n\n const handled = await handler(request, event)\n\n let response: Response\n if (!handled) {\n response = NextResponse.next({ request: { headers: requestHeaders } })\n } else if (isPassThrough(handled)) {\n response = NextResponse.next({ request: { headers: requestHeaders } })\n carryOver(handled, response)\n } else {\n // A redirect or an early 401. It never reaches a Next route, so the\n // build-time `headers()` set in `withQdcConfig` would miss it — which is\n // precisely why the headers are applied here too.\n response = handled\n }\n\n applySecurityHeaders(response, cspName, csp)\n return response\n }\n}\n","// Content-Security-Policy assembly. Pure string work, no `next` and no Node\n// built-ins, so the edge proxy can call it.\n\n/** Options for the security headers a QDC app sends on every response. */\nexport interface SecurityHeaderOptions {\n /**\n * Who may frame this app. Defaults to `[\"'none'\"]` — nobody. Values are\n * CSP source expressions, so quoted keywords keep their quotes.\n */\n frameAncestors?: string[]\n /**\n * What this app may frame, on top of `'self'`. Defaults to `[\"'self'\"]`.\n *\n * Without an explicit `frame-src` the directive falls through to\n * `default-src 'self'`, so an app could embed nothing at all — no payment\n * iframe, no map, no video. That was a gap rather than a decision, so the\n * directive is written out and an app widens it here.\n *\n * This is the opposite direction from `frameAncestors`: that one says who may\n * embed us, this one says what we may embed.\n */\n frameSrc?: string[]\n /**\n * Extra origins the browser may open connections to, on top of `'self'`.\n * In a generated app these are the origins behind its `CONN_*` secrets.\n */\n connectSrc?: string[]\n /** Where the browser posts violation reports. Defaults to `/api/csp-report`. */\n reportUri?: string\n /**\n * Send `Content-Security-Policy-Report-Only` instead of the enforcing\n * header. **Defaults to `true`.**\n *\n * `'strict-dynamic'` makes the browser ignore `'self'` and every host\n * allow-list for scripts, so a policy that is slightly wrong is a blank page\n * in production rather than a degraded one. Enforcing before the reports have\n * been read gets the whole policy reverted instead of tightened, so Stage 1\n * collects evidence at `/api/csp-report` first. Pass `false` once those\n * reports are clean for your app.\n */\n reportOnly?: boolean\n /** DSN whose ingest origin the browser may post to. */\n sentryDsn?: string\n}\n\n// Only http(s) has a meaningful `origin` — a DSN with some other scheme (or\n// no scheme at all) gives `URL.origin === \"null\"`, which would otherwise\n// become a literal \"null\" token in connect-src.\nconst HTTP_PROTOCOLS = new Set([\"http:\", \"https:\"])\n\n/** The origin a browser-side Sentry SDK for this DSN posts events to, or `undefined` for an absent/malformed DSN. */\nexport function sentryIngestOrigin(dsn: string | undefined): string | undefined {\n if (!dsn) return undefined\n try {\n const url = new URL(dsn)\n return HTTP_PROTOCOLS.has(url.protocol) ? url.origin : undefined\n } catch {\n return undefined\n }\n}\n\n// A source expression containing \";\" or a newline would end the directive and\n// start a new one — i.e. let caller-supplied config rewrite the whole policy.\n// Reject rather than strip: a silently mangled origin is a connect-src that\n// quietly fails at runtime.\nconst UNSAFE_IN_DIRECTIVE = /[;\\r\\n]/\n\nfunction assertSafe(kind: string, values: readonly string[]): void {\n for (const value of values) {\n if (UNSAFE_IN_DIRECTIVE.test(value)) {\n throw new Error(`Invalid ${kind} for CSP: ${JSON.stringify(value)} contains \";\" or a newline`)\n }\n }\n}\n\n/**\n * Build the Stage-1 QDC policy for one response.\n *\n * `script-src` carries the per-response nonce plus `'strict-dynamic'`, so a\n * script the app itself marked may load further scripts and nothing else runs.\n * `style-src` deliberately keeps `'unsafe-inline'`: HeroUI and Tailwind emit\n * inline styles, and removing it in the same change that introduces the policy\n * would break every generated app — Stage 2 replaces it with the nonce after\n * its own styling audit.\n */\nexport function buildCsp(nonce: string, options: SecurityHeaderOptions = {}): string {\n const frameAncestors = options.frameAncestors ?? [\"'none'\"]\n const frameSrc = options.frameSrc ?? [\"'self'\"]\n const connectSrc = options.connectSrc ?? []\n const reportUri = options.reportUri ?? \"/api/csp-report\"\n const sentryOrigin = sentryIngestOrigin(options.sentryDsn)\n\n assertSafe(\"nonce\", [nonce])\n assertSafe(\"frameAncestors entry\", frameAncestors)\n assertSafe(\"frameSrc entry\", frameSrc)\n assertSafe(\"connectSrc entry\", connectSrc)\n assertSafe(\"reportUri\", [reportUri])\n if (sentryOrigin) assertSafe(\"sentryDsn origin\", [sentryOrigin])\n\n const directives = [\n \"default-src 'self'\",\n `script-src 'self' 'nonce-${nonce}' 'strict-dynamic'`,\n \"style-src 'self' 'unsafe-inline'\",\n \"img-src 'self' data: blob: https:\",\n \"font-src 'self' data:\",\n \"worker-src 'self' blob:\",\n [\"connect-src\", \"'self'\", ...connectSrc, ...(sentryOrigin ? [sentryOrigin] : [])].join(\" \"),\n ...(frameSrc.length > 0 ? [[\"frame-src\", ...frameSrc].join(\" \")] : [\"frame-src 'none'\"]),\n ...(frameAncestors.length > 0 ? [[\"frame-ancestors\", ...frameAncestors].join(\" \")] : []),\n \"base-uri 'self'\",\n \"form-action 'self'\",\n \"object-src 'none'\",\n \"upgrade-insecure-requests\",\n ...(reportUri ? [`report-uri ${reportUri}`] : []),\n ]\n\n return directives.join(\"; \") + \";\"\n}\n\n/** The header name matching `options.reportOnly`. */\nexport function cspHeaderName(options: SecurityHeaderOptions = {}): string {\n return (options.reportOnly ?? true)\n ? \"Content-Security-Policy-Report-Only\"\n : \"Content-Security-Policy\"\n}\n","import { NextResponse } from \"next/server\"\nimport type { NextRequest } from \"next/server\"\n\nimport type { SecurityHeaderOptions } from \"../../security-core/csp\"\nimport { QORE_CSP_REPORT_URI } from \"../../security-core/cspReport\"\nimport { withSecurityHeaders, type ProxyHandlerFn, type SecuredProxy } from \"./index\"\n\nexport type QoreProxyAuth = \"keycloak\" | \"betterauth\" | \"none\"\n\nexport interface QoreProxyOptions {\n /** Which session the proxy pre-checks. Real validation stays server-side. */\n auth?: QoreProxyAuth\n /** Overrides for the security headers and the CSP. */\n security?: SecurityHeaderOptions\n /**\n * The app's own proxy logic. Runs after the session pre-check passes;\n * return nothing to pass through, or a Response to answer early.\n */\n handler?: ProxyHandlerFn\n}\n\n\n// Kept equal to auth-core's COOKIE_NAME by a test; imported from there it would\n// pull the session module into every proxy bundle.\nconst KEYCLOAK_SESSION_COOKIE = \"qdc_session\"\nconst BETTERAUTH_SESSION_SUFFIX = \"better-auth.session_token\"\n\nfunction keycloakGate(req: NextRequest): Response | undefined {\n if (req.cookies.has(KEYCLOAK_SESSION_COOKIE)) return undefined\n const url = req.nextUrl.clone()\n url.pathname = \"/api/auth/login\"\n url.search = \"\"\n url.searchParams.set(\"redirect\", req.nextUrl.pathname + req.nextUrl.search)\n return NextResponse.redirect(url)\n}\n\nfunction betterAuthGate(req: NextRequest): Response | undefined {\n if (req.cookies.getAll().some((c) => c.name.endsWith(BETTERAUTH_SESSION_SUFFIX))) return undefined\n const url = req.nextUrl.clone()\n url.pathname = \"/login\"\n return NextResponse.redirect(url)\n}\n\nconst GATES: Record<QoreProxyAuth, ((req: NextRequest) => Response | undefined) | null> = {\n keycloak: keycloakGate,\n betterauth: betterAuthGate,\n none: null,\n}\n\n/**\n * The body of a Next app's `src/proxy.ts`: security headers and a CSP nonce on\n * every response, a cheap session-cookie pre-check that redirects to login,\n * then the app's own handler. Which paths it covers stays the app's `config`\n * literal, since Next reads that statically.\n */\nexport function qoreProxy(options: QoreProxyOptions = {}): SecuredProxy {\n const gate = GATES[options.auth ?? \"none\"]\n const handler = options.handler\n return withSecurityHeaders(\n async (req, event) => gate?.(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O;AAClD,mBAAe,IAAI,cAAc,KAAK;AAGtC,mBAAe,IAAI,2BAA2B,GAAG;AAEjD,UAAM,UAAU,MAAM,QAAQ,SAAS,KAAK;AAE5C,QAAI;AACJ,QAAI,CAAC,SAAS;AACZ,iBAAWC,cAAa,KAAK,EAAE,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;AAAA,IACvE,WAAW,cAAc,OAAO,GAAG;AACjC,iBAAWA,cAAa,KAAK,EAAE,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;AACrE,gBAAU,SAAS,QAAQ;AAAA,IAC7B,OAAO;AAIL,iBAAW;AAAA,IACb;AAEA,yBAAqB,UAAU,SAAS,GAAG;AAC3C,WAAO;AAAA,EACT;AACF;","names":["NextResponse","NextResponse"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/next/security/index.ts","../../../src/security-core/csp.ts","../../../src/next/security/qoreProxy.ts","../../../src/next/security/apiLevel.ts"],"sourcesContent":["import { NextResponse } from \"next/server\"\nimport type { NextFetchEvent, NextRequest } from \"next/server\"\n\nimport { buildCsp, cspHeaderName, type SecurityHeaderOptions } from \"../../security-core/csp\"\nimport { STATIC_SECURITY_HEADERS } from \"../../security-core/headers\"\n\nexport { buildCsp } from \"../../security-core/csp\"\nexport type { SecurityHeaderOptions } from \"../../security-core/csp\"\nexport { STATIC_SECURITY_HEADERS } from \"../../security-core/headers\"\nexport { proxyMatcher } from \"../../security-core/proxy\"\nexport { createCspReportRoute, readCspReport, QORE_CSP_REPORT_URI } from \"../../security-core/cspReport\"\nexport { qoreProxy } from \"./qoreProxy\"\nexport { API_LEVEL_HEADER, createAppVersionRoute, requireMobileApiLevel } from \"./apiLevel\"\nexport type { MobileApiLevels } from \"./apiLevel\"\nexport type { QoreProxyAuth, QoreProxyOptions } from \"./qoreProxy\"\nexport type {\n CspReportFields,\n CspReportLogger,\n CspReportRouteOptions,\n} from \"../../security-core/cspReport\"\n\n/**\n * What a Next proxy (formerly \"middleware\") is allowed to be.\n *\n * Named `ProxyHandlerFn` rather than `ProxyHandler` because `ProxyHandler<T>`\n * is a TypeScript lib global — exporting that name would shadow it in every\n * file that imports from this entry point.\n *\n * Returning nothing means \"pass through\", and that is the shape to prefer: it\n * lets `withSecurityHeaders` build the pass-through response itself, which is\n * the only way the nonce reaches the renderer (see below).\n */\nexport type ProxyHandlerFn = (\n request: NextRequest,\n event: NextFetchEvent,\n) => Response | undefined | null | Promise<Response | undefined | null>\n\n/**\n * What `withSecurityHeaders` returns: the full Next proxy signature, rather\n * than the handler's own. The wrapper genuinely accepts both arguments and\n * genuinely always resolves to a `Response` — a handler that returns nothing\n * still comes back as a pass-through. Next accepts this shape as a `proxy`\n * export unchanged.\n *\n * Named because `@quatronic/sdk/next/security/testing` takes one.\n */\nexport type SecuredProxy = (request: NextRequest, event: NextFetchEvent) => Promise<Response>\n\n/** 128 bits, the CSP spec's floor. */\nconst NONCE_BYTES = 16\n\n/** The header app code reads to nonce its own inline script or style. */\nexport const NONCE_HEADER = \"x-qdc-nonce\"\n\nfunction generateNonce(): string {\n // `crypto.getRandomValues`, not `randomUUID()`: a UUID is 122 bits of\n // randomness wearing a fixed-format costume, and `randomUUID` is absent from\n // some edge runtimes. Web Crypto is present in both edge and node.\n const bytes = new Uint8Array(NONCE_BYTES)\n crypto.getRandomValues(bytes)\n let binary = \"\"\n for (const byte of bytes) binary += String.fromCharCode(byte)\n return btoa(binary)\n}\n\nfunction isPassThrough(response: Response): boolean {\n // How `NextResponse.next()` marks itself. Reading it is a dependency on a\n // Next internal, so it is the *fallback* path only — a handler that returns\n // nothing never reaches here. If Next ever renames the marker the cost is a\n // response that carries the headers but not the request-side nonce, which is\n // exactly what we would have had without this branch.\n return response.headers.get(\"x-middleware-next\") === \"1\"\n}\n\nfunction carryOver(from: Response, to: Response): void {\n from.headers.forEach((value, key) => {\n // `x-middleware-*` is Next's own pass-through plumbing, including the\n // encoding of the forwarded request headers. The fresh response regenerates\n // all of it; copying the stale copy over would undo the nonce we just set.\n if (key.toLowerCase().startsWith(\"x-middleware-\")) return\n if (key.toLowerCase() === \"set-cookie\") return\n to.headers.set(key, value)\n })\n // `forEach` folds multiple Set-Cookie headers into one comma-joined string,\n // which no browser parses back into two cookies. `getSetCookie` is the only\n // accessor that keeps them separate.\n for (const cookie of from.headers.getSetCookie?.() ?? []) {\n to.headers.append(\"set-cookie\", cookie)\n }\n}\n\nfunction applySecurityHeaders(response: Response, cspName: string, csp: string): void {\n for (const [name, value] of STATIC_SECURITY_HEADERS) {\n response.headers.set(name, value)\n }\n response.headers.set(cspName, csp)\n}\n\n/**\n * Wrap a Next proxy so every response it produces carries the QDC security\n * headers and a per-response CSP nonce.\n *\n * The nonce goes on the **request** headers under two names: `x-qdc-nonce` for\n * app code, and `Content-Security-Policy` because that is where Next itself\n * looks for it. Next parses the request's CSP header, extracts `nonce-…`, and\n * stamps that nonce onto the bootstrap `<script>` tags it emits. Without it,\n * every generated app breaks the moment `script-src` stops allowing\n * `'unsafe-inline'`.\n *\n * A nonce is per response. Any route whose HTML carries one must render\n * dynamically and must not be cached by a CDN, or every visitor shares a single\n * nonce and the nonce protects nothing.\n *\n * The return type is the full proxy signature rather than the handler's own,\n * because the wrapper genuinely does accept both arguments and genuinely always\n * resolves to a `Response` — a handler that returns nothing still comes back as\n * a pass-through. Next accepts this shape as a `proxy` export unchanged.\n */\nexport function withSecurityHeaders(\n handler: ProxyHandlerFn,\n options: SecurityHeaderOptions = {},\n): SecuredProxy {\n return async (request: NextRequest, event: NextFetchEvent): Promise<Response> => {\n const nonce = generateNonce()\n const csp = buildCsp(nonce, { ...options, sentryDsn: options.sentryDsn ?? process.env.SENTRY_DSN })\n const cspName = cspHeaderName(options)\n\n const requestHeaders = new Headers(request.headers)\n requestHeaders.set(NONCE_HEADER, nonce)\n // Always the enforcing name on the request, even in report-only mode: this\n // copy is how Next finds the nonce, not a policy the browser ever sees.\n requestHeaders.set(\"content-security-policy\", csp)\n\n const handled = await handler(request, event)\n\n let response: Response\n if (!handled) {\n response = NextResponse.next({ request: { headers: requestHeaders } })\n } else if (isPassThrough(handled)) {\n response = NextResponse.next({ request: { headers: requestHeaders } })\n carryOver(handled, response)\n } else {\n // A redirect or an early 401. It never reaches a Next route, so the\n // build-time `headers()` set in `withQdcConfig` would miss it — which is\n // precisely why the headers are applied here too.\n response = handled\n }\n\n applySecurityHeaders(response, cspName, csp)\n return response\n }\n}\n","// Content-Security-Policy assembly. Pure string work, no `next` and no Node\n// built-ins, so the edge proxy can call it.\n\n/** Options for the security headers a QDC app sends on every response. */\nexport interface SecurityHeaderOptions {\n /**\n * Who may frame this app. Defaults to `[\"'none'\"]` — nobody. Values are\n * CSP source expressions, so quoted keywords keep their quotes.\n */\n frameAncestors?: string[]\n /**\n * What this app may frame, on top of `'self'`. Defaults to `[\"'self'\"]`.\n *\n * Without an explicit `frame-src` the directive falls through to\n * `default-src 'self'`, so an app could embed nothing at all — no payment\n * iframe, no map, no video. That was a gap rather than a decision, so the\n * directive is written out and an app widens it here.\n *\n * This is the opposite direction from `frameAncestors`: that one says who may\n * embed us, this one says what we may embed.\n */\n frameSrc?: string[]\n /**\n * Extra origins the browser may open connections to, on top of `'self'`.\n * In a generated app these are the origins behind its `CONN_*` secrets.\n */\n connectSrc?: string[]\n /** Where the browser posts violation reports. Defaults to `/api/csp-report`. */\n reportUri?: string\n /**\n * Send `Content-Security-Policy-Report-Only` instead of the enforcing\n * header. **Defaults to `true`.**\n *\n * `'strict-dynamic'` makes the browser ignore `'self'` and every host\n * allow-list for scripts, so a policy that is slightly wrong is a blank page\n * in production rather than a degraded one. Enforcing before the reports have\n * been read gets the whole policy reverted instead of tightened, so Stage 1\n * collects evidence at `/api/csp-report` first. Pass `false` once those\n * reports are clean for your app.\n */\n reportOnly?: boolean\n /** DSN whose ingest origin the browser may post to. */\n sentryDsn?: string\n}\n\n// Only http(s) has a meaningful `origin` — a DSN with some other scheme (or\n// no scheme at all) gives `URL.origin === \"null\"`, which would otherwise\n// become a literal \"null\" token in connect-src.\nconst HTTP_PROTOCOLS = new Set([\"http:\", \"https:\"])\n\n/** The origin a browser-side Sentry SDK for this DSN posts events to, or `undefined` for an absent/malformed DSN. */\nexport function sentryIngestOrigin(dsn: string | undefined): string | undefined {\n if (!dsn) return undefined\n try {\n const url = new URL(dsn)\n return HTTP_PROTOCOLS.has(url.protocol) ? url.origin : undefined\n } catch {\n return undefined\n }\n}\n\n// A source expression containing \";\" or a newline would end the directive and\n// start a new one — i.e. let caller-supplied config rewrite the whole policy.\n// Reject rather than strip: a silently mangled origin is a connect-src that\n// quietly fails at runtime.\nconst UNSAFE_IN_DIRECTIVE = /[;\\r\\n]/\n\nfunction assertSafe(kind: string, values: readonly string[]): void {\n for (const value of values) {\n if (UNSAFE_IN_DIRECTIVE.test(value)) {\n throw new Error(`Invalid ${kind} for CSP: ${JSON.stringify(value)} contains \";\" or a newline`)\n }\n }\n}\n\n/**\n * Build the Stage-1 QDC policy for one response.\n *\n * `script-src` carries the per-response nonce plus `'strict-dynamic'`, so a\n * script the app itself marked may load further scripts and nothing else runs.\n * `style-src` deliberately keeps `'unsafe-inline'`: HeroUI and Tailwind emit\n * inline styles, and removing it in the same change that introduces the policy\n * would break every generated app — Stage 2 replaces it with the nonce after\n * its own styling audit.\n */\nexport function buildCsp(nonce: string, options: SecurityHeaderOptions = {}): string {\n const frameAncestors = options.frameAncestors ?? [\"'none'\"]\n const frameSrc = options.frameSrc ?? [\"'self'\"]\n const connectSrc = options.connectSrc ?? []\n const reportUri = options.reportUri ?? \"/api/csp-report\"\n const sentryOrigin = sentryIngestOrigin(options.sentryDsn)\n\n assertSafe(\"nonce\", [nonce])\n assertSafe(\"frameAncestors entry\", frameAncestors)\n assertSafe(\"frameSrc entry\", frameSrc)\n assertSafe(\"connectSrc entry\", connectSrc)\n assertSafe(\"reportUri\", [reportUri])\n if (sentryOrigin) assertSafe(\"sentryDsn origin\", [sentryOrigin])\n\n const directives = [\n \"default-src 'self'\",\n `script-src 'self' 'nonce-${nonce}' 'strict-dynamic'`,\n \"style-src 'self' 'unsafe-inline'\",\n \"img-src 'self' data: blob: https:\",\n \"font-src 'self' data:\",\n \"worker-src 'self' blob:\",\n [\"connect-src\", \"'self'\", ...connectSrc, ...(sentryOrigin ? [sentryOrigin] : [])].join(\" \"),\n ...(frameSrc.length > 0 ? [[\"frame-src\", ...frameSrc].join(\" \")] : [\"frame-src 'none'\"]),\n ...(frameAncestors.length > 0 ? [[\"frame-ancestors\", ...frameAncestors].join(\" \")] : []),\n \"base-uri 'self'\",\n \"form-action 'self'\",\n \"object-src 'none'\",\n \"upgrade-insecure-requests\",\n ...(reportUri ? [`report-uri ${reportUri}`] : []),\n ]\n\n return directives.join(\"; \") + \";\"\n}\n\n/** The header name matching `options.reportOnly`. */\nexport function cspHeaderName(options: SecurityHeaderOptions = {}): string {\n return (options.reportOnly ?? true)\n ? \"Content-Security-Policy-Report-Only\"\n : \"Content-Security-Policy\"\n}\n","import { NextResponse } from \"next/server\"\nimport type { NextRequest } from \"next/server\"\n\nimport type { SecurityHeaderOptions } from \"../../security-core/csp\"\nimport { QORE_CSP_REPORT_URI } from \"../../security-core/cspReport\"\nimport { withSecurityHeaders, type ProxyHandlerFn, type SecuredProxy } from \"./index\"\n\nexport type QoreProxyAuth = \"keycloak\" | \"betterauth\" | \"none\"\n\nexport interface QoreProxyOptions {\n /** Which session the proxy pre-checks. Real validation stays server-side. */\n auth?: QoreProxyAuth\n /** Overrides for the security headers and the CSP. */\n security?: SecurityHeaderOptions\n /**\n * The app's own proxy logic. Runs after the session pre-check passes;\n * return nothing to pass through, or a Response to answer early.\n */\n handler?: ProxyHandlerFn\n}\n\n\n// Kept equal to auth-core's COOKIE_NAME by a test; imported from there it would\n// pull the session module into every proxy bundle.\nconst KEYCLOAK_SESSION_COOKIE = \"qdc_session\"\nconst BETTERAUTH_SESSION_SUFFIX = \"better-auth.session_token\"\n\nfunction keycloakGate(req: NextRequest): Response | undefined {\n if (req.cookies.has(KEYCLOAK_SESSION_COOKIE)) return undefined\n const url = req.nextUrl.clone()\n url.pathname = \"/api/auth/login\"\n url.search = \"\"\n url.searchParams.set(\"redirect\", req.nextUrl.pathname + req.nextUrl.search)\n return NextResponse.redirect(url)\n}\n\nfunction betterAuthGate(req: NextRequest): Response | undefined {\n if (req.cookies.getAll().some((c) => c.name.endsWith(BETTERAUTH_SESSION_SUFFIX))) return undefined\n const url = req.nextUrl.clone()\n url.pathname = \"/login\"\n return NextResponse.redirect(url)\n}\n\nconst GATES: Record<QoreProxyAuth, ((req: NextRequest) => Response | undefined) | null> = {\n keycloak: keycloakGate,\n betterauth: betterAuthGate,\n none: null,\n}\n\n/**\n * The body of a Next app's `src/proxy.ts`: security headers and a CSP nonce on\n * every response, a cheap session-cookie pre-check that redirects to login,\n * then the app's own handler. Which paths it covers stays the app's `config`\n * literal, since Next reads that statically.\n */\nexport function qoreProxy(options: QoreProxyOptions = {}): SecuredProxy {\n const gate = GATES[options.auth ?? \"none\"]\n const handler = options.handler\n return withSecurityHeaders(\n async (req, event) => gate?.(req) ?? (handler ? handler(req, event) : undefined),\n { reportUri: QORE_CSP_REPORT_URI, ...options.security },\n )\n}\n","// The API level contract, server side. The app's `src/config/mobile.ts` holds\n// `MOBILE_API_LEVEL` (what this server speaks) and `MOBILE_MIN_API_LEVEL` (the\n// oldest phone build it still serves). The portal refuses a promote whose\n// minimum is above what the environment's installed builds speak, so a server\n// never runs ahead of its clients; these helpers are the runtime half.\n// The header name is kept equal to `expo/core/apiLevel.ts` by a test.\n\nexport const API_LEVEL_HEADER = \"x-qore-api-level\"\n\nexport interface MobileApiLevels {\n /** The API level this server speaks. */\n apiLevel: number\n /** The oldest phone build's level this server still serves. */\n minApiLevel: number\n}\n\nfunction assertLevels({ apiLevel, minApiLevel }: MobileApiLevels): void {\n for (const [name, v] of [[\"apiLevel\", apiLevel], [\"minApiLevel\", minApiLevel]] as const) {\n if (!Number.isInteger(v) || v < 0) throw new Error(`${name} must be a non-negative integer, got ${v}`)\n }\n if (minApiLevel > apiLevel) throw new Error(`minApiLevel (${minApiLevel}) is above apiLevel (${apiLevel})`)\n}\n\n/**\n * 426 for a phone build below `minApiLevel`, else `null`. A request without\n * the header passes: the web pages call the same routes, and a build from\n * before the contract cannot be told apart from them. A header that is not an\n * integer counts as level 0.\n */\nexport function requireMobileApiLevel(req: Request, minApiLevel: number): Response | null {\n const raw = req.headers.get(API_LEVEL_HEADER)\n if (raw === null) return null\n const level = /^\\d{1,6}$/.test(raw.trim()) ? Number(raw.trim()) : 0\n if (level >= minApiLevel) return null\n return Response.json(\n { error: \"upgrade_required\", minApiLevel },\n { status: 426, headers: { \"cache-control\": \"no-store\" } },\n )\n}\n\n/**\n * The app's `src/app/api/qore/app-version/route.ts`: a public GET that tells a\n * phone whether its build is still served. Throws at import when the levels\n * contradict each other, so a bad edit fails the build rather than a device.\n */\nexport function createAppVersionRoute(levels: MobileApiLevels): { GET: () => Response } {\n assertLevels(levels)\n const body = { apiLevel: levels.apiLevel, minApiLevel: levels.minApiLevel }\n return {\n GET: () => Response.json(body, { headers: { \"cache-control\": \"no-store\" } }),\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,gBAAAA,qBAAoB;;;ACgD7B,IAAM,iBAAiB,oBAAI,IAAI,CAAC,SAAS,QAAQ,CAAC;AAG3C,SAAS,mBAAmB,KAA6C;AAC9E,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,GAAG;AACvB,WAAO,eAAe,IAAI,IAAI,QAAQ,IAAI,IAAI,SAAS;AAAA,EACzD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAMA,IAAM,sBAAsB;AAE5B,SAAS,WAAW,MAAc,QAAiC;AACjE,aAAW,SAAS,QAAQ;AAC1B,QAAI,oBAAoB,KAAK,KAAK,GAAG;AACnC,YAAM,IAAI,MAAM,WAAW,IAAI,aAAa,KAAK,UAAU,KAAK,CAAC,4BAA4B;AAAA,IAC/F;AAAA,EACF;AACF;AAYO,SA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;AAAA,EAClC;AACA,WAAS,QAAQ,IAAI,SAAS,GAAG;AACnC;AAsBO,SAAS,oBACd,SACA,UAAiC,CAAC,GACpB;AACd,SAAO,OAAO,SAAsB,UAA6C;AAC/E,UAAM,QAAQ,cAAc;AAC5B,UAAM,MAAM,SAAS,OAAO,EAAE,GAAG,SAAS,WAAW,QAAQ,aAAa,QAAQ,IAAI,WAAW,CAAC;AAClG,UAAM,UAAU,cAAc,OAAO;AAErC,UAAM,iBAAiB,IAAI,QAAQ,QAAQ,OAAO;AAClD,mBAAe,IAAI,cAAc,KAAK;AAGtC,mBAAe,IAAI,2BAA2B,GAAG;AAEjD,UAAM,UAAU,MAAM,QAAQ,SAAS,KAAK;AAE5C,QAAI;AACJ,QAAI,CAAC,SAAS;AACZ,iBAAWC,cAAa,KAAK,EAAE,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;AAAA,IACvE,WAAW,cAAc,OAAO,GAAG;AACjC,iBAAWA,cAAa,KAAK,EAAE,SAAS,EAAE,SAAS,eAAe,EAAE,CAAC;AACrE,gBAAU,SAAS,QAAQ;AAAA,IAC7B,OAAO;AAIL,iBAAW;AAAA,IACb;AAEA,yBAAqB,UAAU,SAAS,GAAG;AAC3C,WAAO;AAAA,EACT;AACF;","names":["NextResponse","NextResponse"]}
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "../../chunk-DYOSRJH3.js";
|
|
4
4
|
import {
|
|
5
5
|
initSentry
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-P5GBQVO7.js";
|
|
7
7
|
import "../../chunk-MET4SIMB.js";
|
|
8
8
|
import "../../chunk-7ASQHY7O.js";
|
|
9
|
-
import "../../chunk-
|
|
9
|
+
import "../../chunk-VQKYPW5V.js";
|
|
10
10
|
|
|
11
11
|
// src/next/sentry/client.ts
|
|
12
12
|
import * as Sentry from "@sentry/nextjs";
|
|
@@ -24,7 +24,7 @@ function initBrowser(doc, sentry) {
|
|
|
24
24
|
cfg,
|
|
25
25
|
() => cfg?.local ? {} : {
|
|
26
26
|
integrations: [sentry.replayIntegration(REPLAY_PRIVACY)],
|
|
27
|
-
replaysSessionSampleRate: 0,
|
|
27
|
+
replaysSessionSampleRate: cfg?.environment === "production" ? 0.1 : 1,
|
|
28
28
|
replaysOnErrorSampleRate: 1
|
|
29
29
|
}
|
|
30
30
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/next/sentry/client.ts"],"sourcesContent":["import * as Sentry from \"@sentry/nextjs\"\nimport { initSentry, type SentryLike } from \"../../sentry-core/init\"\nimport { readRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// maskAllInputs skips type=\"hidden\", whose values (CSRF tokens, ids) would otherwise be\n// recorded as-is; blocking them drops the element and its input events.\nconst REPLAY_PRIVACY = {\n maskAllText: true, maskAllInputs: true, blockAllMedia: true, block: ['input[type=\"hidden\"]'],\n}\n\ntype BrowserSentry = SentryLike & { replayIntegration(options: object): unknown }\n\nexport function initBrowser(doc: Document, sentry: BrowserSentry): boolean {\n const cfg = readRuntimeConfig(doc)\n // Locally a replay would only print binary segments; errors and logs are what matter there.\n return initSentry(sentry, \"browser\", cfg, () =>\n cfg?.local\n ? {}\n : {\n integrations: [sentry.replayIntegration(REPLAY_PRIVACY)],\n replaysSessionSampleRate: 0,\n replaysOnErrorSampleRate: 1,\n },\n )\n}\n\nif (typeof document !== \"undefined\") initBrowser(document, Sentry)\n\nexport const onRouterTransitionStart = Sentry.captureRouterTransitionStart\n"],"mappings":";;;;;;;;;;;AAAA,YAAY,YAAY;AAMxB,IAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EAAM,eAAe;AAAA,EAAM,eAAe;AAAA,EAAM,OAAO,CAAC,sBAAsB;AAC7F;AAIO,SAAS,YAAY,KAAe,QAAgC;AACzE,QAAM,MAAM,kBAAkB,GAAG;
|
|
1
|
+
{"version":3,"sources":["../../../src/next/sentry/client.ts"],"sourcesContent":["import * as Sentry from \"@sentry/nextjs\"\nimport { initSentry, type SentryLike } from \"../../sentry-core/init\"\nimport { readRuntimeConfig } from \"../../sentry-core/runtime-config\"\n\n// maskAllInputs skips type=\"hidden\", whose values (CSRF tokens, ids) would otherwise be\n// recorded as-is; blocking them drops the element and its input events.\nconst REPLAY_PRIVACY = {\n maskAllText: true, maskAllInputs: true, blockAllMedia: true, block: ['input[type=\"hidden\"]'],\n}\n\ntype BrowserSentry = SentryLike & { replayIntegration(options: object): unknown }\n\nexport function initBrowser(doc: Document, sentry: BrowserSentry): boolean {\n const cfg = readRuntimeConfig(doc)\n // Locally a replay would only print binary segments; errors and logs are what matter there.\n // Elsewhere every session is recorded (masked) outside production, a tenth in production:\n // a replay is most useful exactly when nobody thought to reproduce the bug.\n return initSentry(sentry, \"browser\", cfg, () =>\n cfg?.local\n ? {}\n : {\n integrations: [sentry.replayIntegration(REPLAY_PRIVACY)],\n replaysSessionSampleRate: cfg?.environment === \"production\" ? 0.1 : 1,\n replaysOnErrorSampleRate: 1,\n },\n )\n}\n\nif (typeof document !== \"undefined\") initBrowser(document, Sentry)\n\nexport const onRouterTransitionStart = Sentry.captureRouterTransitionStart\n"],"mappings":";;;;;;;;;;;AAAA,YAAY,YAAY;AAMxB,IAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EAAM,eAAe;AAAA,EAAM,eAAe;AAAA,EAAM,OAAO,CAAC,sBAAsB;AAC7F;AAIO,SAAS,YAAY,KAAe,QAAgC;AACzE,QAAM,MAAM,kBAAkB,GAAG;AAIjC,SAAO;AAAA,IAAW;AAAA,IAAQ;AAAA,IAAW;AAAA,IAAK,MACxC,KAAK,QACD,CAAC,IACD;AAAA,MACE,cAAc,CAAC,OAAO,kBAAkB,cAAc,CAAC;AAAA,MACvD,0BAA0B,KAAK,gBAAgB,eAAe,MAAM;AAAA,MACpE,0BAA0B;AAAA,IAC5B;AAAA,EACN;AACF;AAEA,IAAI,OAAO,aAAa,YAAa,aAAY,UAAU,MAAM;AAE1D,IAAM,0BAAiC;","names":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
onRequestError,
|
|
3
3
|
register
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
4
|
+
} from "../../chunk-WOFBDOMY.js";
|
|
5
|
+
import "../../chunk-P5GBQVO7.js";
|
|
6
6
|
import "../../chunk-MET4SIMB.js";
|
|
7
7
|
import "../../chunk-7ASQHY7O.js";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-VQKYPW5V.js";
|
|
9
9
|
export {
|
|
10
10
|
onRequestError,
|
|
11
11
|
register
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
initSentry
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-P5GBQVO7.js";
|
|
4
4
|
import "../../chunk-MET4SIMB.js";
|
|
5
5
|
import {
|
|
6
6
|
readSentryConfig
|
|
7
7
|
} from "../../chunk-7ASQHY7O.js";
|
|
8
|
-
import "../../chunk-
|
|
8
|
+
import "../../chunk-VQKYPW5V.js";
|
|
9
9
|
|
|
10
10
|
// src/node/sentry/register.ts
|
|
11
11
|
import * as Sentry from "@sentry/node";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatronic/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0-test.0f51557",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -147,6 +147,48 @@
|
|
|
147
147
|
"./next/platform": {
|
|
148
148
|
"types": "./dist/next/platform/index.d.ts",
|
|
149
149
|
"import": "./dist/next/platform/index.js"
|
|
150
|
+
},
|
|
151
|
+
"./expo/auth": {
|
|
152
|
+
"types": "./dist/expo/auth/index.d.ts",
|
|
153
|
+
"react-native": "./dist/expo/auth/index.js",
|
|
154
|
+
"import": "./dist/expo/auth/index.js",
|
|
155
|
+
"default": "./dist/expo/auth/index.js"
|
|
156
|
+
},
|
|
157
|
+
"./expo/query": {
|
|
158
|
+
"types": "./dist/expo/query/index.d.ts",
|
|
159
|
+
"react-native": "./dist/expo/query/index.js",
|
|
160
|
+
"import": "./dist/expo/query/index.js",
|
|
161
|
+
"default": "./dist/expo/query/index.js"
|
|
162
|
+
},
|
|
163
|
+
"./expo/updates": {
|
|
164
|
+
"types": "./dist/expo/updates/index.d.ts",
|
|
165
|
+
"react-native": "./dist/expo/updates/index.js",
|
|
166
|
+
"import": "./dist/expo/updates/index.js",
|
|
167
|
+
"default": "./dist/expo/updates/index.js"
|
|
168
|
+
},
|
|
169
|
+
"./expo/sentry": {
|
|
170
|
+
"types": "./dist/expo/sentry/index.d.ts",
|
|
171
|
+
"react-native": "./dist/expo/sentry/index.js",
|
|
172
|
+
"import": "./dist/expo/sentry/index.js",
|
|
173
|
+
"default": "./dist/expo/sentry/index.js"
|
|
174
|
+
},
|
|
175
|
+
"./expo/log": {
|
|
176
|
+
"types": "./dist/expo/log/index.d.ts",
|
|
177
|
+
"react-native": "./dist/expo/log/index.js",
|
|
178
|
+
"import": "./dist/expo/log/index.js",
|
|
179
|
+
"default": "./dist/expo/log/index.js"
|
|
180
|
+
},
|
|
181
|
+
"./expo/config": {
|
|
182
|
+
"types": "./dist/expo/config/index.d.ts",
|
|
183
|
+
"react-native": "./dist/expo/config/index.js",
|
|
184
|
+
"import": "./dist/expo/config/index.js",
|
|
185
|
+
"default": "./dist/expo/config/index.js"
|
|
186
|
+
},
|
|
187
|
+
"./expo/testing": {
|
|
188
|
+
"types": "./dist/expo/testing/index.d.ts",
|
|
189
|
+
"react-native": "./dist/expo/testing/index.js",
|
|
190
|
+
"import": "./dist/expo/testing/index.js",
|
|
191
|
+
"default": "./dist/expo/testing/index.js"
|
|
150
192
|
}
|
|
151
193
|
},
|
|
152
194
|
"scripts": {
|
|
@@ -169,15 +211,25 @@
|
|
|
169
211
|
},
|
|
170
212
|
"peerDependencies": {
|
|
171
213
|
"@better-auth/core": ">=1.6",
|
|
214
|
+
"@react-native-community/netinfo": ">=12",
|
|
172
215
|
"@sentry/nextjs": "^10",
|
|
173
216
|
"@sentry/node": "^10",
|
|
217
|
+
"@sentry/react-native": ">=8",
|
|
218
|
+
"@tanstack/react-query": "^5",
|
|
174
219
|
"better-auth": ">=1.6",
|
|
175
220
|
"drizzle-orm": ">=0.36",
|
|
176
221
|
"eslint": ">=9",
|
|
222
|
+
"expo-constants": ">=58",
|
|
223
|
+
"expo-crypto": ">=58",
|
|
224
|
+
"expo-linking": ">=58",
|
|
225
|
+
"expo-secure-store": ">=58",
|
|
226
|
+
"expo-updates": ">=58",
|
|
227
|
+
"expo-web-browser": ">=58",
|
|
177
228
|
"next": ">=15",
|
|
178
229
|
"pg": ">=8.13",
|
|
179
230
|
"react": ">=18",
|
|
180
|
-
"react-dom": ">=18"
|
|
231
|
+
"react-dom": ">=18",
|
|
232
|
+
"react-native": ">=0.88"
|
|
181
233
|
},
|
|
182
234
|
"peerDependenciesMeta": {
|
|
183
235
|
"eslint": {
|
|
@@ -209,6 +261,36 @@
|
|
|
209
261
|
},
|
|
210
262
|
"@sentry/node": {
|
|
211
263
|
"optional": true
|
|
264
|
+
},
|
|
265
|
+
"@react-native-community/netinfo": {
|
|
266
|
+
"optional": true
|
|
267
|
+
},
|
|
268
|
+
"@sentry/react-native": {
|
|
269
|
+
"optional": true
|
|
270
|
+
},
|
|
271
|
+
"@tanstack/react-query": {
|
|
272
|
+
"optional": true
|
|
273
|
+
},
|
|
274
|
+
"expo-constants": {
|
|
275
|
+
"optional": true
|
|
276
|
+
},
|
|
277
|
+
"expo-crypto": {
|
|
278
|
+
"optional": true
|
|
279
|
+
},
|
|
280
|
+
"expo-linking": {
|
|
281
|
+
"optional": true
|
|
282
|
+
},
|
|
283
|
+
"expo-secure-store": {
|
|
284
|
+
"optional": true
|
|
285
|
+
},
|
|
286
|
+
"expo-updates": {
|
|
287
|
+
"optional": true
|
|
288
|
+
},
|
|
289
|
+
"expo-web-browser": {
|
|
290
|
+
"optional": true
|
|
291
|
+
},
|
|
292
|
+
"react-native": {
|
|
293
|
+
"optional": true
|
|
212
294
|
}
|
|
213
295
|
},
|
|
214
296
|
"devDependencies": {
|
|
@@ -217,6 +299,7 @@
|
|
|
217
299
|
"@opentelemetry/sdk-trace-base": "^2.7.0",
|
|
218
300
|
"@sentry/nextjs": "10.75.2",
|
|
219
301
|
"@sentry/node": "10.75.2",
|
|
302
|
+
"@tanstack/react-query": "^5.105.3",
|
|
220
303
|
"@testcontainers/postgresql": "^12.0.0",
|
|
221
304
|
"@testing-library/react": "^16.1.0",
|
|
222
305
|
"@types/jscodeshift": "17.3.0",
|
package/skills/catalog.json
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
{"name": "qore-author-skill", "kind": "convenience", "legacyNames": ["quatronic-author-skill"]},
|
|
11
11
|
{"name": "qore-debug-issue", "kind": "convenience"},
|
|
12
12
|
{"name": "qore-enable-auth-method", "kind": "convenience", "requires": ["auth=betterauth"], "legacyNames": ["quatronic-enable-auth-method"]},
|
|
13
|
+
{"name": "qore-mobile-add-screen", "kind": "convenience", "requires": ["mobile"]},
|
|
14
|
+
{"name": "qore-mobile-call-server", "kind": "convenience", "requires": ["mobile"]},
|
|
15
|
+
{"name": "qore-mobile-run-on-device", "kind": "convenience", "requires": ["mobile"]},
|
|
13
16
|
{"name": "qore-observability", "kind": "contract", "legacyNames": ["quatronic-observe"]},
|
|
14
17
|
{"name": "qore-recommended-tools", "kind": "convenience", "requires": ["runtime=next"], "legacyNames": ["quatronic-recommended-tools"]},
|
|
15
18
|
{"name": "qore-secure-io", "kind": "convenience", "requires": ["runtime=next"], "legacyNames": ["quatronic-secure-io"]},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: qore-add-api-route
|
|
3
|
-
description: Add a business HTTP route under src/app/api/ for external callers{{#if auth}}, protected with the SDK{{/if}}. Use for API endpoints — internal mutations are Server Actions, not routes.
|
|
3
|
+
description: Add a business HTTP route under src/app/api/ for external callers{{#if auth}}, protected with the SDK{{/if}}. Use for API endpoints — internal mutations are Server Actions, not routes.{{#if mobile}} Also the server half of anything the phone app calls (see qore-mobile-call-server).{{/if}}
|
|
4
4
|
allowed-tools: Bash(pnpm:*), Edit, Read
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -13,7 +13,7 @@ provider slug uppercased, non-alphanumerics collapsed to `_`. The SDK reads only
|
|
|
13
13
|
this env — it never calls the portal at runtime.
|
|
14
14
|
|
|
15
15
|
> A single-module app has no connections. Only follow this once the portal shows
|
|
16
|
-
>
|
|
16
|
+
> the connection as Active in this module's Connections tab.
|
|
17
17
|
|
|
18
18
|
## Kinds of connection
|
|
19
19
|
|
|
@@ -50,6 +50,8 @@ clear startup error, not a mystery 500. For a service connection to `billing-api
|
|
|
50
50
|
CONN_BILLING_API_TOKEN: z.string().min(1),
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
How to declare, mark and check a key: `/qore-add-env-key`.
|
|
54
|
+
|
|
53
55
|
## 2. Fail-fast at startup
|
|
54
56
|
|
|
55
57
|
In a module-scoped init path (e.g. a server-only module imported by your feature
|
|
@@ -13,7 +13,7 @@ provider slug uppercased, non-alphanumerics collapsed to `_`. The SDK reads only
|
|
|
13
13
|
this env — it never calls the portal at runtime.
|
|
14
14
|
|
|
15
15
|
> A single-module app has no connections. Only follow this once the portal shows
|
|
16
|
-
>
|
|
16
|
+
> the connection as Active in this module's Connections tab.
|
|
17
17
|
|
|
18
18
|
This module is a plain `node:http` service (no framework), so the provider side
|
|
19
19
|
needs one small adapter — step 4 covers it.
|
|
@@ -53,6 +53,8 @@ startup error, not a mystery failure. For a service connection to `billing-api`
|
|
|
53
53
|
CONN_BILLING_API_TOKEN: z.string().min(1),
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
+
How to declare, mark and check a key: `/qore-add-env-key`.
|
|
57
|
+
|
|
56
58
|
## 2. Fail-fast at startup
|
|
57
59
|
|
|
58
60
|
In `src/index.ts`, before `server.listen(...)`, assert every wire this module
|