@selvajs/server 1.0.0-beta.8 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -20
- package/dist/access/project-access-input.d.ts +13 -16
- package/dist/access/project-access-input.d.ts.map +1 -1
- package/dist/access/project-access-input.js +2 -2
- package/dist/access/project-access-input.js.map +1 -1
- package/dist/compute/idempotency.d.ts +18 -22
- package/dist/compute/idempotency.d.ts.map +1 -1
- package/dist/compute/idempotency.js +10 -14
- package/dist/compute/idempotency.js.map +1 -1
- package/dist/compute/index.d.ts.map +1 -1
- package/dist/compute/index.js +3 -5
- package/dist/compute/index.js.map +1 -1
- package/dist/compute/limits.d.ts +70 -86
- package/dist/compute/limits.d.ts.map +1 -1
- package/dist/compute/limits.js +27 -56
- package/dist/compute/limits.js.map +1 -1
- package/dist/compute/rate-limit.d.ts +41 -53
- package/dist/compute/rate-limit.d.ts.map +1 -1
- package/dist/compute/rate-limit.js +27 -35
- package/dist/compute/rate-limit.js.map +1 -1
- package/dist/compute/remote-definition.d.ts +8 -22
- package/dist/compute/remote-definition.d.ts.map +1 -1
- package/dist/compute/remote-definition.js +9 -19
- package/dist/compute/remote-definition.js.map +1 -1
- package/dist/compute/safe-url.d.ts +7 -5
- package/dist/compute/safe-url.d.ts.map +1 -1
- package/dist/compute/safe-url.js +26 -28
- package/dist/compute/safe-url.js.map +1 -1
- package/dist/definitions/definition-service.d.ts +13 -38
- package/dist/definitions/definition-service.d.ts.map +1 -1
- package/dist/definitions/definition-service.js +25 -53
- package/dist/definitions/definition-service.js.map +1 -1
- package/dist/definitions/index.d.ts +1 -1
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/definitions/index.js +0 -4
- package/dist/definitions/index.js.map +1 -1
- package/dist/definitions/load-for-render.d.ts +23 -20
- package/dist/definitions/load-for-render.d.ts.map +1 -1
- package/dist/definitions/load-for-render.js +37 -40
- package/dist/definitions/load-for-render.js.map +1 -1
- package/dist/definitions/schema-extraction.d.ts +11 -14
- package/dist/definitions/schema-extraction.d.ts.map +1 -1
- package/dist/definitions/schema-extraction.js +17 -26
- package/dist/definitions/schema-extraction.js.map +1 -1
- package/dist/errors/SentryErrorReporter.d.ts +2 -3
- package/dist/errors/SentryErrorReporter.d.ts.map +1 -1
- package/dist/errors/SentryErrorReporter.js +10 -14
- package/dist/errors/SentryErrorReporter.js.map +1 -1
- package/dist/http/body-size.d.ts +8 -11
- package/dist/http/body-size.d.ts.map +1 -1
- package/dist/http/body-size.js +8 -11
- package/dist/http/body-size.js.map +1 -1
- package/dist/http/redirect.d.ts +3 -7
- package/dist/http/redirect.d.ts.map +1 -1
- package/dist/http/redirect.js +8 -8
- package/dist/http/redirect.js.map +1 -1
- package/dist/http/route-classifier.d.ts +20 -24
- package/dist/http/route-classifier.d.ts.map +1 -1
- package/dist/http/route-classifier.js +6 -7
- package/dist/http/route-classifier.js.map +1 -1
- package/dist/http/security-headers.d.ts +13 -15
- package/dist/http/security-headers.d.ts.map +1 -1
- package/dist/http/security-headers.js +10 -12
- package/dist/http/security-headers.js.map +1 -1
- package/dist/logging/PinoLogger.d.ts +8 -14
- package/dist/logging/PinoLogger.d.ts.map +1 -1
- package/dist/logging/PinoLogger.js +29 -35
- package/dist/logging/PinoLogger.js.map +1 -1
- package/dist/logging/requestId.d.ts +20 -28
- package/dist/logging/requestId.d.ts.map +1 -1
- package/dist/logging/requestId.js +29 -37
- package/dist/logging/requestId.js.map +1 -1
- package/dist/ops/index.d.ts.map +1 -1
- package/dist/ops/index.js +2 -1
- package/dist/ops/index.js.map +1 -1
- package/dist/ops/semver.d.ts +22 -24
- package/dist/ops/semver.d.ts.map +1 -1
- package/dist/ops/semver.js +22 -25
- package/dist/ops/semver.js.map +1 -1
- package/dist/providers/create-selva-providers.d.ts +19 -27
- package/dist/providers/create-selva-providers.d.ts.map +1 -1
- package/dist/providers/create-selva-providers.js +28 -34
- package/dist/providers/create-selva-providers.js.map +1 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +2 -4
- package/dist/providers/index.js.map +1 -1
- package/dist/tokens/token-codec.d.ts +24 -27
- package/dist/tokens/token-codec.d.ts.map +1 -1
- package/dist/tokens/token-codec.js +18 -21
- package/dist/tokens/token-codec.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// resolution, schema fetch (with the ADR 0005 staleness check), default merging.
|
|
1
|
+
// Given a definition record, produces everything the client needs to render its
|
|
2
|
+
// form and solve it.
|
|
4
3
|
//
|
|
5
|
-
// Access gating is
|
|
6
|
-
// whether `ctx`
|
|
7
|
-
//
|
|
4
|
+
// Access gating is deliberately NOT done here — the calling route decides
|
|
5
|
+
// whether `ctx` may load this definition, since gates differ across routes
|
|
6
|
+
// (project membership, segment ownership, share-token, admin override).
|
|
8
7
|
//
|
|
9
|
-
// Everything stateful is injected
|
|
10
|
-
//
|
|
11
|
-
// on the engine can wire its own composition root.
|
|
8
|
+
// Everything stateful is injected, so any app on the engine can wire its own
|
|
9
|
+
// composition root.
|
|
12
10
|
import { UI_SCHEMA_VERSION } from '@selvajs/schemas';
|
|
13
11
|
import { NoopLogger } from '@selvajs/platform';
|
|
14
12
|
import { fetchSchemaFromCompute } from './schema-extraction.js';
|
|
@@ -23,18 +21,13 @@ export class DefinitionLoadError extends Error {
|
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* merged compute defaults). By default it resolves the `channel` pointer
|
|
30
|
-
* (live/draft); pass `explicitVersionId` to render an arbitrary historical
|
|
31
|
-
* version instead — the caller must gate that behind edit permission
|
|
32
|
-
* (editor-only, like the draft channel). Throws `DefinitionLoadError` for
|
|
33
|
-
* classified failures so the caller can translate to HTTP status codes.
|
|
24
|
+
* The returned loader resolves the `channel` pointer (live/draft) by default.
|
|
25
|
+
* `explicitVersionId` renders an arbitrary historical version instead — the
|
|
26
|
+
* caller MUST gate that behind edit permission, as with the draft channel.
|
|
34
27
|
*/
|
|
35
28
|
export function createDefinitionLoader(deps) {
|
|
36
29
|
const { storage, definitions, projects, resolveServer, getClient, fetchSchema = fetchSchemaFromCompute, computeDebug = false, onWarn, logger = new NoopLogger() } = deps;
|
|
37
|
-
return async function loadDefinitionForRender(ctx, record, channel, explicitVersionId) {
|
|
30
|
+
return async function loadDefinitionForRender(ctx, record, channel, explicitVersionId, options) {
|
|
38
31
|
const versionId = explicitVersionId ?? (channel === 'draft' ? record.draftVersionId : record.liveVersionId);
|
|
39
32
|
if (!versionId)
|
|
40
33
|
throw new DefinitionLoadError('data', `Definition '${record.guid}' has no ${channel} version`);
|
|
@@ -57,6 +50,15 @@ export function createDefinitionLoader(deps) {
|
|
|
57
50
|
catch (err) {
|
|
58
51
|
throw new DefinitionLoadError('missing-config', 'No compute server configured for this definition', err);
|
|
59
52
|
}
|
|
53
|
+
// Returning before `getClient` is the point — the connect is the cost, not
|
|
54
|
+
// the `getIO` it carries. A missing or stale-format cache falls through to
|
|
55
|
+
// the full path below, so the result is always a valid schema.
|
|
56
|
+
if (options?.skipComputeDefaults) {
|
|
57
|
+
const cachedSchema = version.schema;
|
|
58
|
+
if (cachedSchema && cachedSchema.schemaVersion === UI_SCHEMA_VERSION) {
|
|
59
|
+
return { version, definitionSource, computeServer, schema: cachedSchema };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
60
62
|
// Only the client is used here (getIO); the entry's solve scheduler rides
|
|
61
63
|
// along unused.
|
|
62
64
|
let client;
|
|
@@ -68,24 +70,21 @@ export function createDefinitionLoader(deps) {
|
|
|
68
70
|
throw new DefinitionLoadError('connect', `Failed to connect to Rhino Compute server: ${message}`, err);
|
|
69
71
|
}
|
|
70
72
|
try {
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
// migrates schemas itself. `getIO` is always needed to merge compute
|
|
77
|
-
// default values into the schema, cached or not.
|
|
73
|
+
// The stored schema is a disposable cache, used ONLY when its format
|
|
74
|
+
// version matches the app's. On a mismatch (or a pre-caching row with no
|
|
75
|
+
// schema) re-extract from compute, whose C# SchemaMigrator emits the
|
|
76
|
+
// current format — the web side never migrates schemas itself. `getIO`
|
|
77
|
+
// runs either way, to merge compute default values in.
|
|
78
78
|
const cachedSchema = version.schema;
|
|
79
79
|
const freshCache = cachedSchema && cachedSchema.schemaVersion === UI_SCHEMA_VERSION ? cachedSchema : null;
|
|
80
80
|
const [definition, fetchedSchema] = await Promise.all([
|
|
81
81
|
client.getIO(definitionSource),
|
|
82
82
|
freshCache ? Promise.resolve(freshCache) : fetchSchema(definitionSource, computeServer)
|
|
83
83
|
]);
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
// plugin behind the app) would just go stale again next render.
|
|
84
|
+
// Best-effort — a viewer context may lack write access, and the next
|
|
85
|
+
// editor render or the solve-time backfill will land it. Guarded on the
|
|
86
|
+
// current version because persisting an older format (compute plugin
|
|
87
|
+
// behind the app) would just go stale again next render.
|
|
89
88
|
if (!freshCache && fetchedSchema.schemaVersion === UI_SCHEMA_VERSION) {
|
|
90
89
|
definitions.setVersionSchema(ctx, version.id, fetchedSchema).catch((err) => {
|
|
91
90
|
if (onWarn) {
|
|
@@ -103,13 +102,12 @@ export function createDefinitionLoader(deps) {
|
|
|
103
102
|
if (!definition) {
|
|
104
103
|
throw new Error(`Failed to get definition IO — server returned undefined`);
|
|
105
104
|
}
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
// dump is gated on `computeDebug`.
|
|
105
|
+
// Zero inputs or reported parse/load problems mean a definition that will
|
|
106
|
+
// render wrong without saying why: an empty ValueList whose backing GH
|
|
107
|
+
// component didn't resolve ("Missing Definition Objects"), or a PascalCase
|
|
108
|
+
// /io response the parser silently dropped to []. Warning is always on —
|
|
109
|
+
// it only fires on the unhappy path — while the raw wire dump costs an
|
|
110
|
+
// extra round-trip and stays behind `computeDebug`.
|
|
113
111
|
const ioParseErrors = definition.parseErrors ?? [];
|
|
114
112
|
const ioLoadErrors = definition.loadErrors ?? [];
|
|
115
113
|
const ioLooksBroken = definition.inputs.length === 0 || ioParseErrors.length > 0 || ioLoadErrors.length > 0;
|
|
@@ -161,9 +159,8 @@ export function createDefinitionLoader(deps) {
|
|
|
161
159
|
}
|
|
162
160
|
};
|
|
163
161
|
}
|
|
164
|
-
//
|
|
165
|
-
//
|
|
166
|
-
// color picker can consume them directly.
|
|
162
|
+
// Colors come back from Compute as "r,g,b" or "a,r,g,b" strings — converted to
|
|
163
|
+
// hex here so the color picker can consume them directly.
|
|
167
164
|
function mergeComputeDefaults(schema, computeInputs) {
|
|
168
165
|
const byParamId = new Map(computeInputs.map((input) => [input.id, input]));
|
|
169
166
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-for-render.js","sourceRoot":"","sources":["../../src/definitions/load-for-render.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,
|
|
1
|
+
{"version":3,"file":"load-for-render.js","sourceRoot":"","sources":["../../src/definitions/load-for-render.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,qBAAqB;AACrB,EAAE;AACF,0EAA0E;AAC1E,2EAA2E;AAC3E,wEAAwE;AACxE,EAAE;AACF,6EAA6E;AAC7E,oBAAoB;AAGpB,OAAO,EAAE,iBAAiB,EAAiB,MAAM,kBAAkB,CAAC;AAUpE,OAAO,EAAE,UAAU,EAAgB,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAoBhE,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAE5B;IAEA;IAHjB,YACiB,IAA6B,EAC7C,OAAe,EACC,KAAe;QAE/B,KAAK,CAAC,OAAO,C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AAE,CAAC;gBACxD,OAAO,EAAE,GAAG,WAAW,EAAE,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC;YAC1D,CAAC;YACD,OAAO,WAAW,CAAC;QACpB,CAAC,CAAC;KACF,CAAC;AACH,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { type UISchema } from '@selvajs/schemas';
|
|
|
3
3
|
import type { ComputeServerConfig } from '@selvajs/platform';
|
|
4
4
|
/** One entry of the compute schema endpoint's response, typed to our `UISchema`. */
|
|
5
5
|
export type SchemaExtractionResult = SchemaEndpointResult<UISchema>;
|
|
6
|
-
/**
|
|
6
|
+
/** Thin re-export of @selvajs/compute's unwrap, typed to `UISchema`. */
|
|
7
7
|
export declare function readSchemaResults(raw: unknown): SchemaExtractionResult[];
|
|
8
8
|
/** Thrown when compute is reachable but the definition yields no usable schema. */
|
|
9
9
|
export declare class SchemaExtractionError extends Error {
|
|
@@ -11,25 +11,22 @@ export declare class SchemaExtractionError extends Error {
|
|
|
11
11
|
constructor(kind: 'unreachable' | 'invalid' | 'unsupported', message: string);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* optional additions.
|
|
14
|
+
* Rejects a schema from a NEWER plugin than this app was built against — its
|
|
15
|
+
* shape may contain constructs the renderer doesn't know. Older (or missing)
|
|
16
|
+
* versions pass: the compute-side C# migrator always emits its own current
|
|
17
|
+
* version, and an older shape only lacks optional additions.
|
|
19
18
|
*/
|
|
20
19
|
export declare function assertSupportedSchemaVersion(schema: UISchema): void;
|
|
21
20
|
/**
|
|
22
|
-
*
|
|
23
|
-
* solve required)
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* diagnose, since single-file and multi-file callers want different messages.
|
|
21
|
+
* POSTs a multipart form to Rhino Compute's `/grasshopper/schema` endpoint (no
|
|
22
|
+
* solve required). Throws 'unreachable' on a network failure or non-2xx. The
|
|
23
|
+
* per-file `error` Compute reports on its 200-with-no-schemas case is left to
|
|
24
|
+
* the caller — single-file and multi-file callers want different messages.
|
|
27
25
|
*/
|
|
28
26
|
export declare function postSchemaFormData(formData: FormData, server: ComputeServerConfig): Promise<SchemaExtractionResult[]>;
|
|
29
27
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* right HTTP status (503 unreachable / 422 invalid or unsupported).
|
|
28
|
+
* Throws `SchemaExtractionError` so callers can map to the right HTTP status:
|
|
29
|
+
* 503 unreachable / 422 invalid or unsupported.
|
|
33
30
|
*/
|
|
34
31
|
export declare function fetchSchemaFromCompute(definitionBytes: Uint8Array, server: ComputeServerConfig): Promise<UISchema>;
|
|
35
32
|
//# sourceMappingURL=schema-extraction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-extraction.d.ts","sourceRoot":"","sources":["../../src/definitions/schema-extraction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema-extraction.d.ts","sourceRoot":"","sources":["../../src/definitions/schema-extraction.ts"],"names":[],"mappings":"AAIA,OAAO,EAEN,KAAK,oBAAoB,EACzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAqB,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,oFAAoF;AACpF,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;AAEpE,wEAAwE;AACxE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,sBAAsB,EAAE,CAExE;AAED,mFAAmF;AACnF,qBAAa,qBAAsB,SAAQ,KAAK;aAE9B,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,aAAa;gBAA/C,IAAI,EAAE,aAAa,GAAG,SAAS,GAAG,aAAa,EAC/D,OAAO,EAAE,MAAM;CAKhB;AAOD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAmBnE;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACvC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,mBAAmB,GACzB,OAAO,CAAC,sBAAsB,EAAE,CAAC,CA0BnC;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAC3C,eAAe,EAAE,UAAU,EAC3B,MAAM,EAAE,mBAAmB,GACzB,OAAO,CAAC,QAAQ,CAAC,CA2BnB"}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
// Shared compute-schema extraction. One implementation used by:
|
|
2
|
-
// - upload routes (validate-and-cache gate — no upload without a valid schema)
|
|
3
|
-
// - the render path (falls back to live extraction for un-cached or stale
|
|
4
|
-
// versions; see load-for-render.ts and ADR 0005)
|
|
5
|
-
// - the temporary solve-time backfill bridge (see the app's specs/SchemaCaching.md)
|
|
6
|
-
//
|
|
7
1
|
// Extraction IS validation: a `.gh` with no valid "Schema" output, or an
|
|
8
|
-
// unreachable compute server, throws here
|
|
2
|
+
// unreachable compute server, throws here — which is what makes this the upload
|
|
3
|
+
// gate as well as the render path's fallback for un-cached or stale versions.
|
|
9
4
|
import { readSchemaResults as readWrapper } from '@selvajs/compute/grasshopper';
|
|
10
5
|
import { UI_SCHEMA_VERSION } from '@selvajs/schemas';
|
|
11
|
-
/**
|
|
6
|
+
/** Thin re-export of @selvajs/compute's unwrap, typed to `UISchema`. */
|
|
12
7
|
export function readSchemaResults(raw) {
|
|
13
8
|
return readWrapper(raw);
|
|
14
9
|
}
|
|
@@ -26,11 +21,10 @@ function parseSemver(version) {
|
|
|
26
21
|
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
27
22
|
}
|
|
28
23
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* optional additions.
|
|
24
|
+
* Rejects a schema from a NEWER plugin than this app was built against — its
|
|
25
|
+
* shape may contain constructs the renderer doesn't know. Older (or missing)
|
|
26
|
+
* versions pass: the compute-side C# migrator always emits its own current
|
|
27
|
+
* version, and an older shape only lacks optional additions.
|
|
34
28
|
*/
|
|
35
29
|
export function assertSupportedSchemaVersion(schema) {
|
|
36
30
|
const version = schema.schemaVersion;
|
|
@@ -51,11 +45,10 @@ export function assertSupportedSchemaVersion(schema) {
|
|
|
51
45
|
}
|
|
52
46
|
}
|
|
53
47
|
/**
|
|
54
|
-
*
|
|
55
|
-
* solve required)
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* diagnose, since single-file and multi-file callers want different messages.
|
|
48
|
+
* POSTs a multipart form to Rhino Compute's `/grasshopper/schema` endpoint (no
|
|
49
|
+
* solve required). Throws 'unreachable' on a network failure or non-2xx. The
|
|
50
|
+
* per-file `error` Compute reports on its 200-with-no-schemas case is left to
|
|
51
|
+
* the caller — single-file and multi-file callers want different messages.
|
|
59
52
|
*/
|
|
60
53
|
export async function postSchemaFormData(formData, server) {
|
|
61
54
|
const schemaUrl = new URL('/grasshopper/schema', server.serverUrl).toString();
|
|
@@ -76,9 +69,8 @@ export async function postSchemaFormData(formData, server) {
|
|
|
76
69
|
return readSchemaResults(await response.json());
|
|
77
70
|
}
|
|
78
71
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* right HTTP status (503 unreachable / 422 invalid or unsupported).
|
|
72
|
+
* Throws `SchemaExtractionError` so callers can map to the right HTTP status:
|
|
73
|
+
* 503 unreachable / 422 invalid or unsupported.
|
|
82
74
|
*/
|
|
83
75
|
export async function fetchSchemaFromCompute(definitionBytes, server) {
|
|
84
76
|
const formData = new FormData();
|
|
@@ -87,11 +79,10 @@ export async function fetchSchemaFromCompute(definitionBytes, server) {
|
|
|
87
79
|
const results = await postSchemaFormData(formData, server);
|
|
88
80
|
const schemas = results.flatMap((r) => r.schemas ?? []);
|
|
89
81
|
if (schemas.length === 0) {
|
|
90
|
-
// Compute
|
|
91
|
-
//
|
|
92
|
-
//
|
|
93
|
-
// which the generic fallback below cannot
|
|
94
|
-
// wrong thing.
|
|
82
|
+
// Compute answers 200 while reporting a per-file `error`, so the
|
|
83
|
+
// !response.ok guard never fires for it. Surface that message verbatim: it
|
|
84
|
+
// names the actual cause (bad Schema source, no embedded schema, ...),
|
|
85
|
+
// which the generic fallback below cannot.
|
|
95
86
|
const diagnosis = results.map((r) => r.error).filter(Boolean);
|
|
96
87
|
if (diagnosis.length > 0) {
|
|
97
88
|
throw new SchemaExtractionError('invalid', diagnosis.join('\n'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-extraction.js","sourceRoot":"","sources":["../../src/definitions/schema-extraction.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"schema-extraction.js","sourceRoot":"","sources":["../../src/definitions/schema-extraction.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,gFAAgF;AAChF,8EAA8E;AAE9E,OAAO,EACN,iBAAiB,IAAI,WAAW,EAEhC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAiB,MAAM,kBAAkB,CAAC;AAMpE,wEAAwE;AACxE,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC7C,OAAO,WAAW,CAAW,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,mFAAmF;AACnF,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAE9B;IADjB,YACiB,IAA+C,EAC/D,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAA2C;QAI/D,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACrC,CAAC;CACD;AAED,SAAS,WAAW,CAAC,OAAe;IACnC,MAAM,CAAC,GAAG,uBAAuB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,C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AAE,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAExD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,iEAAiE;QACjE,2EAA2E;QAC3E,uEAAuE;QACvE,2CAA2C;QAC3C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC9D,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,qBAAqB,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,IAAI,qBAAqB,CAC9B,SAAS,EACT,qCAAqC;YACpC,mHAAmH,CACpH,CAAC;IACH,CAAC;IAED,4BAA4B,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -3,9 +3,8 @@ export declare class SentryErrorReporter implements IErrorReporter {
|
|
|
3
3
|
private readonly sentry;
|
|
4
4
|
private constructor();
|
|
5
5
|
/**
|
|
6
|
-
* Initialize Sentry and return a reporter, or `null`
|
|
7
|
-
*
|
|
8
|
-
* error-tracker must not take down boot.
|
|
6
|
+
* Initialize Sentry and return a reporter, or `null` when `@sentry/node`
|
|
7
|
+
* won't load. Never throws — a broken error-tracker must not take down boot.
|
|
9
8
|
*/
|
|
10
9
|
static create(opts: {
|
|
11
10
|
dsn: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentryErrorReporter.d.ts","sourceRoot":"","sources":["../../src/errors/SentryErrorReporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"SentryErrorReporter.d.ts","sourceRoot":"","sources":["../../src/errors/SentryErrorReporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA0BtE,qBAAa,mBAAoB,YAAW,cAAc;IACrC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAA3C,OAAO;IAEP;;;OAGG;WACU,MAAM,CAAC,IAAI,EAAE;QACzB,GAAG,EAAE,MAAM,CAAC;QACZ,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IA4BvC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI;CAgBrD"}
|
|
@@ -4,19 +4,15 @@ export class SentryErrorReporter {
|
|
|
4
4
|
this.sentry = sentry;
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Initialize Sentry and return a reporter, or `null`
|
|
8
|
-
*
|
|
9
|
-
* error-tracker must not take down boot.
|
|
7
|
+
* Initialize Sentry and return a reporter, or `null` when `@sentry/node`
|
|
8
|
+
* won't load. Never throws — a broken error-tracker must not take down boot.
|
|
10
9
|
*/
|
|
11
10
|
static async create(opts) {
|
|
12
11
|
try {
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// dep in some installs, absent in others — so we can't assert the error
|
|
18
|
-
// is always present. The `as unknown as` cast narrows whatever loads to
|
|
19
|
-
// the two calls we use.
|
|
12
|
+
// `@vite-ignore` stops the bundler resolving an absent package at build
|
|
13
|
+
// time. `@ts-ignore` rather than `@ts-expect-error` because the module
|
|
14
|
+
// is a real dep in some installs and missing in others, so we can't
|
|
15
|
+
// assert the error is always there for `expect-error` to consume.
|
|
20
16
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
21
17
|
// @ts-ignore -- optional dependency, may be absent at type-check time
|
|
22
18
|
const sentry = (await import(/* @vite-ignore */ '@sentry/node'));
|
|
@@ -24,8 +20,8 @@ export class SentryErrorReporter {
|
|
|
24
20
|
dsn: opts.dsn,
|
|
25
21
|
environment: opts.environment,
|
|
26
22
|
release: opts.release,
|
|
27
|
-
//
|
|
28
|
-
//
|
|
23
|
+
// 0 = error tracking only, no performance tracing. Raise it to
|
|
24
|
+
// sample transactions/spans.
|
|
29
25
|
tracesSampleRate: 0
|
|
30
26
|
});
|
|
31
27
|
return new SentryErrorReporter(sentry);
|
|
@@ -51,8 +47,8 @@ export class SentryErrorReporter {
|
|
|
51
47
|
});
|
|
52
48
|
}
|
|
53
49
|
catch (err) {
|
|
54
|
-
//
|
|
55
|
-
// failure
|
|
50
|
+
// Best-effort, and this sits on the error path — letting a second
|
|
51
|
+
// failure escape would mask the first.
|
|
56
52
|
console.error('[ErrorReporter] Failed to capture error:', err);
|
|
57
53
|
}
|
|
58
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SentryErrorReporter.js","sourceRoot":"","sources":["../../src/errors/SentryErrorReporter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SentryErrorReporter.js","sourceRoot":"","sources":["../../src/errors/SentryErrorReporter.ts"],"names":[],"mappings":"AA0BA,MAAM,OAAO,mBAAmB;IACM;IAArC,YAAqC,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE3D;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAInB;QACA,IAAI,CAAC;YACJ,wEAAwE;YACxE,uEAAuE;YACvE,oEAAoE;YACpE,kEAAkE;YAClE,6DAA6D;YAC7D,sEAAsE;YACtE,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAA0B,CAAC;YAC1F,MAAM,CAAC,IAAI,CAAC;gBACX,GAAG,EAAE,IAAI,CAAC,GAAG;gBAC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5
|
/**
|
|
6
|
-
* True when the request's declared `Content-Length` exceeds `maxBytes`.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* result to its transport's 413.
|
|
6
|
+
* True when the request's declared `Content-Length` exceeds `maxBytes`. Call it
|
|
7
|
+
* BEFORE reading the body, so a huge payload aimed at a small-body endpoint
|
|
8
|
+
* can't burn memory; the route maps `true` to its transport's 413.
|
|
10
9
|
*
|
|
11
|
-
*
|
|
12
|
-
* has to
|
|
13
|
-
*
|
|
14
|
-
* per-route lower bound.
|
|
10
|
+
* This is the per-route lower bound. A global limit (e.g. adapter-node's
|
|
11
|
+
* `BODY_SIZE_LIMIT`) has to clear the largest legitimate upload, so every small
|
|
12
|
+
* JSON endpoint would otherwise inherit that ceiling.
|
|
15
13
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* The global limit is the backstop for those.
|
|
14
|
+
* Requests without `Content-Length` (chunked encoding) slip past this check —
|
|
15
|
+
* the global limit is the backstop there.
|
|
19
16
|
*/
|
|
20
17
|
export declare function declaredBodySizeExceeds(headers: HeadersLike, maxBytes: number): boolean;
|
|
21
18
|
//# sourceMappingURL=body-size.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-size.d.ts","sourceRoot":"","sources":["../../src/http/body-size.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACjC;AAED
|
|
1
|
+
{"version":3,"file":"body-size.d.ts","sourceRoot":"","sources":["../../src/http/body-size.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,WAAW,WAAW;IAC3B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGvF"}
|
package/dist/http/body-size.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* True when the request's declared `Content-Length` exceeds `maxBytes`.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* result to its transport's 413.
|
|
2
|
+
* True when the request's declared `Content-Length` exceeds `maxBytes`. Call it
|
|
3
|
+
* BEFORE reading the body, so a huge payload aimed at a small-body endpoint
|
|
4
|
+
* can't burn memory; the route maps `true` to its transport's 413.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
* has to
|
|
9
|
-
*
|
|
10
|
-
* per-route lower bound.
|
|
6
|
+
* This is the per-route lower bound. A global limit (e.g. adapter-node's
|
|
7
|
+
* `BODY_SIZE_LIMIT`) has to clear the largest legitimate upload, so every small
|
|
8
|
+
* JSON endpoint would otherwise inherit that ceiling.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* The global limit is the backstop for those.
|
|
10
|
+
* Requests without `Content-Length` (chunked encoding) slip past this check —
|
|
11
|
+
* the global limit is the backstop there.
|
|
15
12
|
*/
|
|
16
13
|
export function declaredBodySizeExceeds(headers, maxBytes) {
|
|
17
14
|
const declared = Number(headers.get('content-length'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"body-size.js","sourceRoot":"","sources":["../../src/http/body-size.ts"],"names":[],"mappings":"AAKA
|
|
1
|
+
{"version":3,"file":"body-size.js","sourceRoot":"","sources":["../../src/http/body-size.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAoB,EAAE,QAAgB;IAC7E,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvD,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,QAAQ,CAAC;AACzD,CAAC"}
|
package/dist/http/redirect.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validate a user-supplied post-login redirect target
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* and `/\evil.com` (back-slash variants some browsers normalize) are rejected.
|
|
6
|
-
*
|
|
7
|
-
* Always returns a safe path: the validated target on success, the fallback
|
|
8
|
-
* otherwise. Routes call this with `redirectTo` from form data or query string.
|
|
2
|
+
* Validate a user-supplied post-login redirect target (`redirectTo` from form
|
|
3
|
+
* data or a query string) against open redirects. Returns the target when it is
|
|
4
|
+
* a same-origin relative path, the fallback otherwise — never a raw target.
|
|
9
5
|
*/
|
|
10
6
|
export declare function safeRedirectTarget(raw: string | null | undefined, fallback: string): string;
|
|
11
7
|
//# sourceMappingURL=redirect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../src/http/redirect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../src/http/redirect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU3F"}
|
package/dist/http/redirect.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validate a user-supplied post-login redirect target
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* and `/\evil.com` (back-slash variants some browsers normalize) are rejected.
|
|
6
|
-
*
|
|
7
|
-
* Always returns a safe path: the validated target on success, the fallback
|
|
8
|
-
* otherwise. Routes call this with `redirectTo` from form data or query string.
|
|
2
|
+
* Validate a user-supplied post-login redirect target (`redirectTo` from form
|
|
3
|
+
* data or a query string) against open redirects. Returns the target when it is
|
|
4
|
+
* a same-origin relative path, the fallback otherwise — never a raw target.
|
|
9
5
|
*/
|
|
10
6
|
export function safeRedirectTarget(raw, fallback) {
|
|
7
|
+
// A valid target is `/` plus at least one more character, so the two guards
|
|
8
|
+
// below always have a real `raw[1]` to inspect.
|
|
11
9
|
if (typeof raw !== 'string' || raw.length < 2)
|
|
12
10
|
return fallback;
|
|
11
|
+
// Absolute URLs (`https://evil.com`) leave this origin.
|
|
13
12
|
if (raw[0] !== '/')
|
|
14
13
|
return fallback;
|
|
15
|
-
//
|
|
14
|
+
// `//evil.com` is protocol-relative — a browser treats it as cross-origin —
|
|
15
|
+
// and some browsers normalize `/\evil.com` into the same thing.
|
|
16
16
|
if (raw[1] === '/' || raw[1] === '\\')
|
|
17
17
|
return fallback;
|
|
18
18
|
return raw;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../src/http/redirect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"redirect.js","sourceRoot":"","sources":["../../src/http/redirect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAA8B,EAAE,QAAgB;IAClF,4EAA4E;IAC5E,gDAAgD;IAChD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC/D,wDAAwD;IACxD,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;QAAE,OAAO,QAAQ,CAAC;IACpC,4EAA4E;IAC5E,gEAAgE;IAChE,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IACvD,OAAO,GAAG,CAAC;AACZ,CAAC"}
|
|
@@ -1,46 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Deny-by-default route classification.
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* loud 401/redirect), not silently public.
|
|
2
|
+
* Deny-by-default route classification. A request is gated unless its path
|
|
3
|
+
* matches one of the allowlists supplied here, so forgetting to list a new
|
|
4
|
+
* route makes it gated — a loud 401/redirect, not silently public.
|
|
6
5
|
*
|
|
7
|
-
* The
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* The pattern is reusable; the values are app policy, supplied by the consuming
|
|
7
|
+
* app. Matching is plain exact/prefix string comparison: cheap enough for the
|
|
8
|
+
* hooks hot path, and no regex to get wrong.
|
|
10
9
|
*/
|
|
11
10
|
export interface RouteClassifierConfig {
|
|
12
|
-
/** Exact-match
|
|
11
|
+
/** Exact-match pages needing no session (e.g. `/`, `/login`). */
|
|
13
12
|
publicPages?: Iterable<string>;
|
|
14
|
-
/**
|
|
15
|
-
* Public path prefixes (e.g. `/auth/` for OAuth start + callback — the
|
|
16
|
-
* user has no session yet by definition).
|
|
17
|
-
*/
|
|
13
|
+
/** Public path prefixes (e.g. `/auth/` — OAuth start and callback precede any session). */
|
|
18
14
|
publicPrefixes?: readonly string[];
|
|
19
15
|
/**
|
|
20
|
-
* Exact-match API endpoints that
|
|
21
|
-
* load-balancer health probe). Anything
|
|
22
|
-
*
|
|
16
|
+
* Exact-match API endpoints that answer without a session (e.g. a
|
|
17
|
+
* load-balancer health probe). Anything listed here is exposed to anonymous
|
|
18
|
+
* callers.
|
|
23
19
|
*/
|
|
24
20
|
publicApis?: Iterable<string>;
|
|
25
21
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* the
|
|
30
|
-
*
|
|
22
|
+
* One prefix whose routes authorize each request themselves (e.g. a blob
|
|
23
|
+
* proxy classifying per asset path). These classify as public so the hook
|
|
24
|
+
* attaches a session best-effort and does not deny up front; the route makes
|
|
25
|
+
* the real decision. Keep it to ONE prefix — every other API route stays
|
|
26
|
+
* deny-by-default.
|
|
31
27
|
*/
|
|
32
28
|
selfGatingPrefix?: string;
|
|
33
|
-
/** Static-asset
|
|
29
|
+
/** Static-asset prefixes the adapter serves directly (e.g. `/_app/`). */
|
|
34
30
|
staticPrefixes?: readonly string[];
|
|
35
31
|
/** Exact static-asset paths (e.g. `/favicon.svg`, `/robots.txt`). */
|
|
36
32
|
staticPaths?: Iterable<string>;
|
|
37
33
|
}
|
|
38
34
|
export interface RouteClassifier {
|
|
39
|
-
/**
|
|
35
|
+
/** Matches `staticPaths`/`staticPrefixes`. These bypass auth gating entirely. */
|
|
40
36
|
isStaticAsset(pathname: string): boolean;
|
|
41
|
-
/**
|
|
37
|
+
/** Matches `selfGatingPrefix`. The hook must not deny these — the route gates itself. */
|
|
42
38
|
isSelfGatingApiRoute(pathname: string): boolean;
|
|
43
|
-
/**
|
|
39
|
+
/** Needs no session: a public page, API, prefix, or a self-gating route. */
|
|
44
40
|
isPublicRoute(pathname: string): boolean;
|
|
45
41
|
}
|
|
46
42
|
export declare function createRouteClassifier(config: RouteClassifierConfig): RouteClassifier;
|