@gobing-ai/ts-runtime 0.4.3 → 0.4.5
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.
|
@@ -24,7 +24,8 @@ export interface StructuredConfigLoadOptions {
|
|
|
24
24
|
/**
|
|
25
25
|
* Allow `http(s)://` `$schema` refs. Off by default: remote fetches are an SSRF/DoS surface when
|
|
26
26
|
* configs are authored by third parties. Prefer bundled package-specifier refs (resolved from
|
|
27
|
-
* `node_modules`).
|
|
27
|
+
* `node_modules`). Must be combined with an explicit `fetch` — pass your own time-bounded
|
|
28
|
+
* or APIClient-backed fetch implementation.
|
|
28
29
|
*/
|
|
29
30
|
allowRemote?: boolean;
|
|
30
31
|
fetch?: (input: string) => Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-validation.d.ts","sourceRoot":"","sources":["../src/schema-validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"schema-validation.d.ts","sourceRoot":"","sources":["../src/schema-validation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAOhD,4GAA4G;AAC5G,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,wFAAwF;AACxF,MAAM,WAAW,UAAU;IACvB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACxC,oBAAoB,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAC5C,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB,KAAK,CAAC,EAA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B,kBAAkB,CAC9B,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,UAAU,EAClB,IAAI,SAAK,EACT,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAM,EACrC,QAAQ,GAAE,WAAW,CAAC,MAAM,CAAa,GAC1C,mBAAmB,EAAE,CAwDvB"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { parse as parseYaml } from 'yaml';
|
|
2
2
|
import { createNodeFileSystem } from './file-system-node.js';
|
|
3
3
|
import { dirnamePath, getProcessCwd, isAbsolutePath, joinPath } from './path.js';
|
|
4
|
-
/** Default time budget for a single remote schema fetch. */
|
|
5
|
-
const REMOTE_SCHEMA_FETCH_TIMEOUT_MS = 5_000;
|
|
6
4
|
/** Upper bound on a remote schema body. A timeout alone lets a slow multi-GB drip exhaust memory. */
|
|
7
5
|
const REMOTE_SCHEMA_MAX_BYTES = 5 * 1024 * 1024;
|
|
8
6
|
/** Error thrown when structured config validation fails, carrying the list of {@link JsonSchemaViolation}s. */
|
|
@@ -206,9 +204,9 @@ function splitPackageSpecifier(specifier) {
|
|
|
206
204
|
}
|
|
207
205
|
async function readSchema(schemaLocation, options) {
|
|
208
206
|
if (isRemoteRef(schemaLocation)) {
|
|
209
|
-
const fetchFn = options.fetch
|
|
207
|
+
const fetchFn = options.fetch;
|
|
210
208
|
if (fetchFn === undefined) {
|
|
211
|
-
throw new StructuredConfigSchemaError(`Refusing to fetch remote JSON schema "${schemaLocation}": pass
|
|
209
|
+
throw new StructuredConfigSchemaError(`Refusing to fetch remote JSON schema "${schemaLocation}": pass a fetch implementation to opt in`);
|
|
212
210
|
}
|
|
213
211
|
const response = await fetchFn(schemaLocation);
|
|
214
212
|
if (!response.ok) {
|
|
@@ -259,10 +257,6 @@ async function readBoundedBody(response, schemaLocation) {
|
|
|
259
257
|
return new TextDecoder().decode(merged);
|
|
260
258
|
}
|
|
261
259
|
const defaultResolve = typeof Bun !== 'undefined' ? (specifier, from) => Bun.resolveSync(specifier, from) : undefined;
|
|
262
|
-
/** Default remote fetch, time-bounded so a slow/hung schema host cannot stall config loading. */
|
|
263
|
-
function boundedFetch(input) {
|
|
264
|
-
return globalThis.fetch(input, { signal: AbortSignal.timeout(REMOTE_SCHEMA_FETCH_TIMEOUT_MS) });
|
|
265
|
-
}
|
|
266
260
|
function isObject(value) {
|
|
267
261
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
268
262
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gobing-ai/ts-runtime",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "@gobing-ai/ts-runtime — Runtime abstractions for Bun, Node, and Cloudflare Workers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-runtime-v<version> && git push --tags' && exit 1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@gobing-ai/ts-utils": "^0.4.
|
|
61
|
+
"@gobing-ai/ts-utils": "^0.4.5",
|
|
62
62
|
"execa": "^9.5.0",
|
|
63
63
|
"yaml": "^2.7.0",
|
|
64
64
|
"zod": "^4.1.0"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@gobing-ai/ts-db": "^0.4.
|
|
67
|
+
"@gobing-ai/ts-db": "^0.4.5",
|
|
68
68
|
"@types/bun": "1.3.14"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
package/src/schema-validation.ts
CHANGED
|
@@ -3,9 +3,6 @@ import type { FileSystem } from './file-system';
|
|
|
3
3
|
import { createNodeFileSystem } from './file-system-node';
|
|
4
4
|
import { dirnamePath, getProcessCwd, isAbsolutePath, joinPath } from './path';
|
|
5
5
|
|
|
6
|
-
/** Default time budget for a single remote schema fetch. */
|
|
7
|
-
const REMOTE_SCHEMA_FETCH_TIMEOUT_MS = 5_000;
|
|
8
|
-
|
|
9
6
|
/** Upper bound on a remote schema body. A timeout alone lets a slow multi-GB drip exhaust memory. */
|
|
10
7
|
const REMOTE_SCHEMA_MAX_BYTES = 5 * 1024 * 1024;
|
|
11
8
|
|
|
@@ -36,7 +33,8 @@ export interface StructuredConfigLoadOptions {
|
|
|
36
33
|
/**
|
|
37
34
|
* Allow `http(s)://` `$schema` refs. Off by default: remote fetches are an SSRF/DoS surface when
|
|
38
35
|
* configs are authored by third parties. Prefer bundled package-specifier refs (resolved from
|
|
39
|
-
* `node_modules`).
|
|
36
|
+
* `node_modules`). Must be combined with an explicit `fetch` — pass your own time-bounded
|
|
37
|
+
* or APIClient-backed fetch implementation.
|
|
40
38
|
*/
|
|
41
39
|
allowRemote?: boolean;
|
|
42
40
|
fetch?: (input: string) => Promise<Response>;
|
|
@@ -346,10 +344,10 @@ function splitPackageSpecifier(specifier: string): { pkg: string; subpath: strin
|
|
|
346
344
|
|
|
347
345
|
async function readSchema(schemaLocation: string, options: StructuredConfigLoadOptions): Promise<string> {
|
|
348
346
|
if (isRemoteRef(schemaLocation)) {
|
|
349
|
-
const fetchFn = options.fetch
|
|
347
|
+
const fetchFn = options.fetch;
|
|
350
348
|
if (fetchFn === undefined) {
|
|
351
349
|
throw new StructuredConfigSchemaError(
|
|
352
|
-
`Refusing to fetch remote JSON schema "${schemaLocation}": pass
|
|
350
|
+
`Refusing to fetch remote JSON schema "${schemaLocation}": pass a fetch implementation to opt in`,
|
|
353
351
|
);
|
|
354
352
|
}
|
|
355
353
|
const response = await fetchFn(schemaLocation);
|
|
@@ -411,11 +409,6 @@ async function readBoundedBody(response: Response, schemaLocation: string): Prom
|
|
|
411
409
|
const defaultResolve: ((specifier: string, from: string) => string) | undefined =
|
|
412
410
|
typeof Bun !== 'undefined' ? (specifier, from) => Bun.resolveSync(specifier, from) : undefined;
|
|
413
411
|
|
|
414
|
-
/** Default remote fetch, time-bounded so a slow/hung schema host cannot stall config loading. */
|
|
415
|
-
function boundedFetch(input: string): Promise<Response> {
|
|
416
|
-
return globalThis.fetch(input, { signal: AbortSignal.timeout(REMOTE_SCHEMA_FETCH_TIMEOUT_MS) });
|
|
417
|
-
}
|
|
418
|
-
|
|
419
412
|
function isObject(value: unknown): value is Record<string, unknown> {
|
|
420
413
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
421
414
|
}
|