fastly.js 0.9.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/LICENSE +21 -0
- package/README.md +702 -0
- package/dist/browser.d.ts +10 -0
- package/dist/browser.js +10544 -0
- package/dist/csrf-protection.d.ts +10 -0
- package/dist/diagnostics.d.ts +11 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10435 -0
- package/dist/node-loader.d.ts +3 -0
- package/dist/platform-browser.d.ts +2 -0
- package/dist/platform-node.d.ts +2 -0
- package/dist/platform.d.ts +48 -0
- package/dist/runtime/browser.d.ts +49 -0
- package/dist/runtime/pipeline.d.ts +49 -0
- package/dist/utils.d.ts +7 -0
- package/dist/vcl-accept.d.ts +8 -0
- package/dist/vcl-acl.d.ts +19 -0
- package/dist/vcl-address.d.ts +8 -0
- package/dist/vcl-binary.d.ts +5 -0
- package/dist/vcl-builtin-types.d.ts +10 -0
- package/dist/vcl-compiler.d.ts +513 -0
- package/dist/vcl-digest.d.ts +87 -0
- package/dist/vcl-esi.d.ts +32 -0
- package/dist/vcl-fetch.d.ts +6 -0
- package/dist/vcl-header.d.ts +18 -0
- package/dist/vcl-limits.d.ts +10 -0
- package/dist/vcl-math.d.ts +45 -0
- package/dist/vcl-misc.d.ts +29 -0
- package/dist/vcl-node.d.ts +2 -0
- package/dist/vcl-parser-impl.d.ts +126 -0
- package/dist/vcl-parser.d.ts +320 -0
- package/dist/vcl-querystring.d.ts +46 -0
- package/dist/vcl-ratelimit.d.ts +39 -0
- package/dist/vcl-security.d.ts +23 -0
- package/dist/vcl-std.d.ts +43 -0
- package/dist/vcl-strings.d.ts +47 -0
- package/dist/vcl-table.d.ts +27 -0
- package/dist/vcl-testing.d.ts +60 -0
- package/dist/vcl-time.d.ts +60 -0
- package/dist/vcl-utf8.d.ts +6 -0
- package/dist/vcl-uuid.d.ts +38 -0
- package/dist/vcl-value.d.ts +96 -0
- package/dist/vcl-waf.d.ts +14 -0
- package/dist/vcl.d.ts +7 -0
- package/package.json +90 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export declare function isAlnumByte(b: number): boolean;
|
|
2
|
+
/** Value of a hex digit byte, or -1 when the byte is not a hex digit. */
|
|
3
|
+
export declare function hexVal(b: number): number;
|
|
4
|
+
export declare function isUnreservedByte(code: number): boolean;
|
|
5
|
+
export declare function toHexUpper(b: number): string;
|
|
6
|
+
/** Escapes regex metacharacters so `s` matches literally inside a RegExp. */
|
|
7
|
+
export declare function regexQuote(s: string): string;
|
|
8
|
+
export declare function urlencode(src: string): string | null;
|
|
9
|
+
export declare function urldecode(src: string): string | null;
|
|
10
|
+
export declare function cstr_escape(str: string): string;
|
|
11
|
+
export declare function json_escape(str: string): string;
|
|
12
|
+
export declare function xml_escape(str: string): string;
|
|
13
|
+
export declare function strtol(s: string, base: number): number | null;
|
|
14
|
+
export declare function regsub(str: string, pattern: string, replacement: string): string;
|
|
15
|
+
export declare function regsuball(str: string, pattern: string, replacement: string): string;
|
|
16
|
+
export declare function substr(str: string, offset: number, length?: number): string;
|
|
17
|
+
export declare function subfield(header: string, name: string, separator?: string): string | null;
|
|
18
|
+
export declare function strcasecmp(a: string, b: string): boolean;
|
|
19
|
+
export declare function strstr(haystack: string, needle: string): string | null;
|
|
20
|
+
export declare function strpad(s: string, width: number, pad: string): string;
|
|
21
|
+
export declare function strrep(s: string, count: number): string;
|
|
22
|
+
export declare function strrev(s: string): string | null;
|
|
23
|
+
export declare function prefixof(s: string, prefix: string): boolean;
|
|
24
|
+
export declare function suffixof(s: string, suffix: string): boolean;
|
|
25
|
+
export declare function replace(s: string, target: string, replacement: string): string;
|
|
26
|
+
export declare function replaceall(s: string, target: string, replacement: string): string;
|
|
27
|
+
export declare function replace_prefix(s: string, prefix: string, replacement: string): string;
|
|
28
|
+
export declare function replace_suffix(s: string, suffix: string, replacement: string): string;
|
|
29
|
+
export declare function tolower(s: string): string;
|
|
30
|
+
export declare function toupper(s: string): string;
|
|
31
|
+
export declare function basename(s: string): string;
|
|
32
|
+
export declare function dirname(s: string): string;
|
|
33
|
+
export declare function atoi(s: string): number | null;
|
|
34
|
+
export declare function atof(s: string): number | null;
|
|
35
|
+
export declare function strtof(s: string, base: number): number | null;
|
|
36
|
+
export declare function itoa(n: number, base?: number): string | null;
|
|
37
|
+
export declare function itoa_charset(n: number, charset: string): string;
|
|
38
|
+
export declare function urlNormalize(input: string): string;
|
|
39
|
+
export declare function boltsort_sort(url: string): string;
|
|
40
|
+
export declare function setcookie_get_value_by_name(setCookieHeader: string, name: string): string | null;
|
|
41
|
+
export declare function setcookie_delete_by_name(setCookieHeader: string, name: string): string;
|
|
42
|
+
export declare const Utf8Module: {
|
|
43
|
+
is_valid: (str: string) => boolean;
|
|
44
|
+
codepoint_count: (str: string) => number;
|
|
45
|
+
substr: (str: string, offset: number, length?: number) => string;
|
|
46
|
+
strpad: (str: string, width: number, pad: string) => string;
|
|
47
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VCL Table Functions Module
|
|
3
|
+
*
|
|
4
|
+
* Implements all table.* functions from Fastly VCL.
|
|
5
|
+
* Reference: https://developer.fastly.com/reference/vcl/functions/table/
|
|
6
|
+
*/
|
|
7
|
+
export interface Table {
|
|
8
|
+
name: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
entries: Record<string, any>;
|
|
11
|
+
}
|
|
12
|
+
export interface Tables {
|
|
13
|
+
[name: string]: Table;
|
|
14
|
+
}
|
|
15
|
+
export interface TableModule {
|
|
16
|
+
lookup: (tables: Tables, tableName: string, key: string, defaultValue?: string) => string | null;
|
|
17
|
+
lookup_bool: (tables: Tables, tableName: string, key: string, defaultValue?: boolean) => boolean;
|
|
18
|
+
lookup_integer: (tables: Tables, tableName: string, key: string, defaultValue?: number) => number;
|
|
19
|
+
lookup_float: (tables: Tables, tableName: string, key: string, defaultValue?: number) => number;
|
|
20
|
+
lookup_ip: (tables: Tables, tableName: string, key: string, defaultValue?: string) => string;
|
|
21
|
+
lookup_rtime: (tables: Tables, tableName: string, key: string, defaultValue?: number) => number;
|
|
22
|
+
lookup_acl: (tables: Tables, tableName: string, key: string) => string | null;
|
|
23
|
+
lookup_backend: (tables: Tables, tableName: string, key: string) => string | null;
|
|
24
|
+
lookup_regex: (tables: Tables, tableName: string, key: string) => RegExp | null;
|
|
25
|
+
contains: (tables: Tables, tableName: string, key: string) => boolean;
|
|
26
|
+
}
|
|
27
|
+
export declare function createTableModule(): TableModule;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface TestingState {
|
|
2
|
+
_state: string;
|
|
3
|
+
_restarted: boolean;
|
|
4
|
+
_error: {
|
|
5
|
+
status: number;
|
|
6
|
+
message: string;
|
|
7
|
+
} | null;
|
|
8
|
+
_subroutinesCalled: Map<string, number>;
|
|
9
|
+
_injectedVariables: Map<string, any>;
|
|
10
|
+
_mocks: Map<string, string>;
|
|
11
|
+
_fixedTime: number | null;
|
|
12
|
+
_fixedAccessRate: number | null;
|
|
13
|
+
_overrideHost: string | null;
|
|
14
|
+
_returnValue: any;
|
|
15
|
+
}
|
|
16
|
+
export declare function createTestingState(): TestingState;
|
|
17
|
+
export declare class AssertionError extends Error {
|
|
18
|
+
constructor(message: string);
|
|
19
|
+
}
|
|
20
|
+
export declare function createAssertModule(state: TestingState): {
|
|
21
|
+
equal: (actual: any, expected: any, message?: string) => void;
|
|
22
|
+
not_equal: (actual: any, expected: any, message?: string) => void;
|
|
23
|
+
strict_equal: (actual: any, expected: any, message?: string) => void;
|
|
24
|
+
not_strict_equal: (actual: any, expected: any, message?: string) => void;
|
|
25
|
+
equal_fold: (actual: any, expected: any, message?: string) => void;
|
|
26
|
+
true: (value: any, message?: string) => void;
|
|
27
|
+
false: (value: any, message?: string) => void;
|
|
28
|
+
contains: (haystack: any, needle: any, message?: string) => void;
|
|
29
|
+
not_contains: (haystack: any, needle: any, message?: string) => void;
|
|
30
|
+
starts_with: (str: any, prefix: any, message?: string) => void;
|
|
31
|
+
ends_with: (str: any, suffix: any, message?: string) => void;
|
|
32
|
+
match: (str: any, pattern: any, message?: string) => void;
|
|
33
|
+
not_match: (str: any, pattern: any, message?: string) => void;
|
|
34
|
+
state: (expectedState: any, message?: string) => void;
|
|
35
|
+
not_state: (expectedState: any, message?: string) => void;
|
|
36
|
+
restart: (message?: string) => void;
|
|
37
|
+
not_restart: (message?: string) => void;
|
|
38
|
+
error: (status?: any, responseText?: any, message?: string) => void;
|
|
39
|
+
not_error: (message?: string) => void;
|
|
40
|
+
is_notset: (value: any, message?: string) => void;
|
|
41
|
+
is_json: (value: any, message?: string) => void;
|
|
42
|
+
subroutine_called: (name: any, timesOrMessage?: any, message?: string) => void;
|
|
43
|
+
not_subroutine_called: (name: any, message?: string) => void;
|
|
44
|
+
};
|
|
45
|
+
export declare function createTestingModule(state: TestingState, subroutines: Record<string, (...args: any[]) => unknown>, context: any): {
|
|
46
|
+
call_subroutine: (name: any) => void;
|
|
47
|
+
inspect: (path: any) => any;
|
|
48
|
+
inject_variable: (name: any, value: any) => void;
|
|
49
|
+
override_host: (host: any) => void;
|
|
50
|
+
mock: (original: any, mock: any) => void;
|
|
51
|
+
restore_mock: (...names: any[]) => void;
|
|
52
|
+
restore_all_mocks: () => void;
|
|
53
|
+
table_set: (tableName: any, key: any, value: any) => void;
|
|
54
|
+
table_merge: (baseTableName: any, mergeTableName: any) => void;
|
|
55
|
+
fixed_time: (time: any) => void;
|
|
56
|
+
fixed_access_rate: (rate: any) => void;
|
|
57
|
+
set_backend_health: (backendName: any, healthy: any) => void;
|
|
58
|
+
get_env: (name: any) => any;
|
|
59
|
+
return_value: () => any;
|
|
60
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VCL Time Functions Module
|
|
3
|
+
*
|
|
4
|
+
* Implements the date-and-time VCL builtins, matching Fastly's behavior.
|
|
5
|
+
*
|
|
6
|
+
* Reference: https://developer.fastly.com/reference/vcl/functions/date-and-time/
|
|
7
|
+
*/
|
|
8
|
+
export interface TimeModule {
|
|
9
|
+
now: () => Date;
|
|
10
|
+
/** time.add(TIME, RTIME) -> TIME */
|
|
11
|
+
add: (time: any, duration?: any) => any;
|
|
12
|
+
/** time.sub(TIME, RTIME) -> TIME */
|
|
13
|
+
sub: (time: any, duration?: any) => any;
|
|
14
|
+
/** time.is_after(TIME, TIME) -> BOOL */
|
|
15
|
+
is_after: (time1: any, time2?: any) => boolean;
|
|
16
|
+
/** time.hex_to_time(INTEGER divisor, STRING hex) -> TIME */
|
|
17
|
+
hex_to_time: (divisor: any, hex?: any) => any;
|
|
18
|
+
/** time.units(STRING unit, TIME) -> STRING (null when unit is invalid: EINVAL) */
|
|
19
|
+
units: (unit: any, time?: any) => any;
|
|
20
|
+
/** time.runits(STRING unit, RTIME) -> STRING (null when unit is invalid: EINVAL) */
|
|
21
|
+
runits: (unit: any, rtime?: any) => any;
|
|
22
|
+
/** time.interval_elapsed_ratio(TIME now, TIME start, TIME end) -> FLOAT */
|
|
23
|
+
interval_elapsed_ratio: (now: any, start?: any, end?: any) => any;
|
|
24
|
+
hex?: string;
|
|
25
|
+
}
|
|
26
|
+
export type StrftimeFunction = (format: string, time: Date) => any;
|
|
27
|
+
export type ParseTimeDeltaFunction = (delta: string) => any;
|
|
28
|
+
export declare const TIME_UNITS: Record<string, number>;
|
|
29
|
+
export declare function parseTimeValue(str: string): number;
|
|
30
|
+
export declare function createTimeModule(platform?: {
|
|
31
|
+
now(): number;
|
|
32
|
+
}): TimeModule;
|
|
33
|
+
/** std.integer2time(INTEGER unix-seconds) -> TIME. */
|
|
34
|
+
export declare function std_integer2time(seconds: any): Date;
|
|
35
|
+
/**
|
|
36
|
+
* std.time(STRING, TIME fallback) -> TIME.
|
|
37
|
+
*
|
|
38
|
+
* Tries the format list; on success returns immediately (no out-of-bounds
|
|
39
|
+
* check on that path, matching Fastly's behavior). Otherwise parses unix epoch seconds
|
|
40
|
+
* (anything after a "." is dropped); when that fails the fallback is used.
|
|
41
|
+
* On this second path, a negative unix time yields an out-of-bounds TIME
|
|
42
|
+
* that stringifies as "[out of bounds]".
|
|
43
|
+
*/
|
|
44
|
+
export declare function std_time(str: any, fallback: any): Date;
|
|
45
|
+
/**
|
|
46
|
+
* strftime with Fastly's semantics (verified against production): standard
|
|
47
|
+
* POSIX conversion specifiers computed on UTC components, padding flags
|
|
48
|
+
* "0" (zero), "_" (space) and "-" (none) with optional width digits that are
|
|
49
|
+
* accepted but ignored, and no-op E/O modifiers. %Z is always "GMT" and %z
|
|
50
|
+
* "+0000" since VCL TIME values carry no zone. Unsupported specifiers
|
|
51
|
+
* (e.g. %l, %P) are a compile error on Fastly; this returns null (not set).
|
|
52
|
+
*/
|
|
53
|
+
export declare function createStrftime(): StrftimeFunction;
|
|
54
|
+
/**
|
|
55
|
+
* parse_time_delta: skip leading whitespace, parse an optional sign and a
|
|
56
|
+
* run of digits, then read at most one unit character (d/h/m, case
|
|
57
|
+
* insensitive; anything else means seconds). Everything after the unit is
|
|
58
|
+
* silently ignored ("1d2h" == "1d"). Invalid or negative input returns -1.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createParseTimeDelta(): ParseTimeDeltaFunction;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VCL UUID Module - UUID generation, validation, and conversion
|
|
3
|
+
*/
|
|
4
|
+
import { type VCLPlatform } from "./platform.js";
|
|
5
|
+
export declare function createUUIDModule(platform?: VCLPlatform): {
|
|
6
|
+
version3(namespace: string, name: string): string | null;
|
|
7
|
+
version4(): string;
|
|
8
|
+
version5(namespace: string, name: string): string | null;
|
|
9
|
+
dns(): string;
|
|
10
|
+
url(): string;
|
|
11
|
+
is_valid(uuid: string): boolean;
|
|
12
|
+
is_version3(uuid: string): boolean;
|
|
13
|
+
is_version4(uuid: string): boolean;
|
|
14
|
+
is_version5(uuid: string): boolean;
|
|
15
|
+
decode(uuid: string): Uint8Array | null;
|
|
16
|
+
encode(binary: any): string;
|
|
17
|
+
version7(): string;
|
|
18
|
+
is_version7(uuid: string): boolean;
|
|
19
|
+
oid(): string;
|
|
20
|
+
x500(): string;
|
|
21
|
+
};
|
|
22
|
+
export declare const UUIDModule: {
|
|
23
|
+
version3(namespace: string, name: string): string | null;
|
|
24
|
+
version4(): string;
|
|
25
|
+
version5(namespace: string, name: string): string | null;
|
|
26
|
+
dns(): string;
|
|
27
|
+
url(): string;
|
|
28
|
+
is_valid(uuid: string): boolean;
|
|
29
|
+
is_version3(uuid: string): boolean;
|
|
30
|
+
is_version4(uuid: string): boolean;
|
|
31
|
+
is_version5(uuid: string): boolean;
|
|
32
|
+
decode(uuid: string): Uint8Array | null;
|
|
33
|
+
encode(binary: any): string;
|
|
34
|
+
version7(): string;
|
|
35
|
+
is_version7(uuid: string): boolean;
|
|
36
|
+
oid(): string;
|
|
37
|
+
x500(): string;
|
|
38
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VCLString represents VCL's three-valued string system: NOTSET, empty string, and a value.
|
|
3
|
+
*
|
|
4
|
+
* In Fastly VCL:
|
|
5
|
+
* - `declare local var.S STRING;` creates a NOTSET variable
|
|
6
|
+
* - Unset/missing HTTP headers are NOTSET
|
|
7
|
+
* - `!var.S` is true when NOTSET, false when empty string
|
|
8
|
+
* - `var.S == ""` is false when NOTSET, true when empty string
|
|
9
|
+
* - Stringifying NOTSET produces "(null)"
|
|
10
|
+
* - `std.strlen` of NOTSET returns 0
|
|
11
|
+
*/
|
|
12
|
+
export declare class VCLString {
|
|
13
|
+
readonly value: string;
|
|
14
|
+
readonly isNotSet: boolean;
|
|
15
|
+
private constructor();
|
|
16
|
+
static notset(): VCLString;
|
|
17
|
+
static from(value: string): VCLString;
|
|
18
|
+
toString(): string;
|
|
19
|
+
get length(): number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* VCLFloat wraps a JS number that carries the VCL FLOAT type.
|
|
23
|
+
*
|
|
24
|
+
* Fastly renders FLOAT values with three decimal places ("8.000", "2.303"),
|
|
25
|
+
* while INTEGER values render without a decimal point. JS numbers cannot carry
|
|
26
|
+
* that distinction, so FLOAT-typed values are wrapped. valueOf() lets
|
|
27
|
+
* arithmetic and comparisons treat the wrapper as a plain number.
|
|
28
|
+
*/
|
|
29
|
+
export declare class VCLFloat {
|
|
30
|
+
readonly value: number;
|
|
31
|
+
constructor(value: number);
|
|
32
|
+
valueOf(): number;
|
|
33
|
+
toString(): string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* VCLRTime is a relative-time (RTIME) value, stored in seconds.
|
|
37
|
+
* Stringifies with millisecond precision and three decimals ("90.000").
|
|
38
|
+
*/
|
|
39
|
+
export declare class VCLRTime {
|
|
40
|
+
readonly seconds: number;
|
|
41
|
+
constructor(seconds: number);
|
|
42
|
+
valueOf(): number;
|
|
43
|
+
toString(): string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* VCLTime is an absolute TIME value. It extends Date so existing code that
|
|
47
|
+
* expects Date instances (getTime() etc.) keeps working; stringification uses
|
|
48
|
+
* the IMF-fixdate format Fastly uses ("Mon, 02 Jan 2006 22:04:05 GMT").
|
|
49
|
+
*/
|
|
50
|
+
export declare class VCLTime extends Date {
|
|
51
|
+
toString(): string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Separator between stored fragments of a multi-value HTTP header (one per
|
|
55
|
+
* `add` statement). A plain read returns the first fragment; std.collect
|
|
56
|
+
* merges them; serializers emit one header line per fragment.
|
|
57
|
+
*/
|
|
58
|
+
export declare const HEADER_FRAGMENT_SEPARATOR = "\n";
|
|
59
|
+
/** First fragment of a possibly multi-fragment header value. */
|
|
60
|
+
export declare function firstHeaderFragment(value: string): string;
|
|
61
|
+
/** Convert any runtime value to its VCL string form. */
|
|
62
|
+
export declare function vclToString(v: any): string;
|
|
63
|
+
/** Check if a value is a NOTSET VCLString */
|
|
64
|
+
export declare function isNotSet(v: any): v is VCLString;
|
|
65
|
+
/** Get the raw string value (empty string for NOTSET) */
|
|
66
|
+
export declare function toRawString(v: any): string;
|
|
67
|
+
/** Get the display string value ("(null)" for NOTSET) */
|
|
68
|
+
export declare function toDisplayString(v: any): string;
|
|
69
|
+
/**
|
|
70
|
+
* Result of string concatenation that tracks NOTSET parts.
|
|
71
|
+
* The final string depends on the storage target (header vs local).
|
|
72
|
+
*/
|
|
73
|
+
export declare class VCLConcatResult {
|
|
74
|
+
/** The parts of the concatenation with their NOTSET status */
|
|
75
|
+
readonly parts: Array<{
|
|
76
|
+
value: string;
|
|
77
|
+
notset: boolean;
|
|
78
|
+
}>;
|
|
79
|
+
/** Whether ALL parts are NOTSET */
|
|
80
|
+
readonly allNotSet: boolean;
|
|
81
|
+
constructor(parts: Array<{
|
|
82
|
+
value: string;
|
|
83
|
+
notset: boolean;
|
|
84
|
+
}>);
|
|
85
|
+
/** Resolve for storing in a local variable: NOTSET parts become empty, flag is lost */
|
|
86
|
+
forLocal(): string;
|
|
87
|
+
/** Resolve for storing in a header: NOTSET parts become "(null)" */
|
|
88
|
+
forHeader(): string | VCLString;
|
|
89
|
+
/** Full display string: NOTSET parts render as "(null)". */
|
|
90
|
+
display(): string;
|
|
91
|
+
}
|
|
92
|
+
/** Parse a value into concat parts for tracking NOTSET through concatenation */
|
|
93
|
+
export declare function toConcatPart(v: any): {
|
|
94
|
+
value: string;
|
|
95
|
+
notset: boolean;
|
|
96
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VCL WAF Module - Web Application Firewall functionality
|
|
3
|
+
*/
|
|
4
|
+
export declare const WAFModule: {
|
|
5
|
+
init(): void;
|
|
6
|
+
allow(): void;
|
|
7
|
+
block(status: number, message: string): void;
|
|
8
|
+
log(message: string): void;
|
|
9
|
+
rate_limit(key: string, limit: number, window: number): boolean;
|
|
10
|
+
rate_limit_tokens(key: string): number;
|
|
11
|
+
detect_attack(requestData: string, attackType: string): boolean;
|
|
12
|
+
get_logs(): string[];
|
|
13
|
+
clear_logs(): void;
|
|
14
|
+
};
|
package/dist/vcl.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type VCLPlatform } from "./platform.js";
|
|
2
|
+
import { type VCLContext, type VCLSubroutines } from "./vcl-compiler.js";
|
|
3
|
+
export type { VCLContext, VCLSubroutines };
|
|
4
|
+
export declare function loadVCLContent(content: string): VCLSubroutines;
|
|
5
|
+
export declare function executeVCLByName(subroutines: VCLSubroutines, name: string, context: VCLContext): string;
|
|
6
|
+
export declare function createVCLContext(platform?: VCLPlatform): VCLContext;
|
|
7
|
+
export declare function executeVCL(subroutines: VCLSubroutines, subroutineName: keyof VCLSubroutines, context: VCLContext): string;
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "fastly.js",
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "A reimplementation of the Fastly platform in TypeScript: parse and execute Fastly VCL locally, with the full request pipeline, caching, ESI, and the VCL standard library.",
|
|
5
|
+
"author": "Frank Denis <github@pureftpd.org>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/jedisct1/fastly.js.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/jedisct1/fastly.js#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/jedisct1/fastly.js/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"fastly",
|
|
17
|
+
"vcl",
|
|
18
|
+
"varnish",
|
|
19
|
+
"cdn",
|
|
20
|
+
"edge",
|
|
21
|
+
"cache",
|
|
22
|
+
"proxy",
|
|
23
|
+
"esi"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./browser": {
|
|
35
|
+
"types": "./dist/browser.d.ts",
|
|
36
|
+
"default": "./dist/browser.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist"
|
|
42
|
+
],
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=18"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"start": "bun run index.ts",
|
|
48
|
+
"build": "bun run build:node && bun run build:browser && bun run build:types",
|
|
49
|
+
"build:node": "bun build src/index.ts --outdir dist --target=node --packages external",
|
|
50
|
+
"build:browser": "bun build src/browser.ts --outdir dist --target=browser --packages external",
|
|
51
|
+
"build:types": "tsc -p tsconfig.build.json && bun run scripts/add-dts-extensions.ts",
|
|
52
|
+
"prepublishOnly": "rm -rf dist && bun run build && bun run test:package",
|
|
53
|
+
"test:package": "bun run test/package-smoke.ts",
|
|
54
|
+
"test": "bun run test/run-tests.ts",
|
|
55
|
+
"test:basic": "bun run test/basic-vcl-tests.ts",
|
|
56
|
+
"test:stdlib": "bun run test/stdlib-tests.ts",
|
|
57
|
+
"test:caching": "bun run test/caching-tests.ts",
|
|
58
|
+
"test:backend": "bun run test/backend-error-tests.ts",
|
|
59
|
+
"test:root": "bun run test/run-root-tests.ts",
|
|
60
|
+
"test:integration": "bun run test/run-integration-tests.ts",
|
|
61
|
+
"test:tables": "bun test ./test/table-functions-tests.ts ./test/direct-table-functions-tests.ts ./test/vcl-table-functions-tests.ts",
|
|
62
|
+
"test:browser": "bun run test/browser-bundle-smoke.test.ts",
|
|
63
|
+
"test:compat": "bun test ./test/crypto-compat.test.ts",
|
|
64
|
+
"test:limits": "bun test ./test/limits.test.ts",
|
|
65
|
+
"test:sim": "bun test ./test/browser-simulation.test.ts",
|
|
66
|
+
"test:parity": "bun test ./test/vcl-parity-pipeline-tests.ts",
|
|
67
|
+
"web:build": "bun build web/main.ts --target=browser --outdir web/dist",
|
|
68
|
+
"web:dist": "bun run web/dist.ts",
|
|
69
|
+
"web": "bun run web:build && bun run web/serve.ts",
|
|
70
|
+
"test:all": "bun run test && bun run test:root && bun run test:integration && bun run test:tables && bun run test:compat && bun run test:limits && bun run test:sim && bun run test:parity && bun run test:browser",
|
|
71
|
+
"lint": "biome lint .",
|
|
72
|
+
"format": "biome format --write .",
|
|
73
|
+
"check": "biome check --write .",
|
|
74
|
+
"typecheck": "tsc --noEmit"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@biomejs/biome": "^2.4.6",
|
|
78
|
+
"@types/bun": "^1.3.10",
|
|
79
|
+
"@types/chai": "^5.2.3",
|
|
80
|
+
"chai": "^6.2.2",
|
|
81
|
+
"typescript": "^5.9.3"
|
|
82
|
+
},
|
|
83
|
+
"dependencies": {
|
|
84
|
+
"@noble/ciphers": "^2.2.0",
|
|
85
|
+
"@noble/hashes": "^2.2.0",
|
|
86
|
+
"buffer": "^6.0.3",
|
|
87
|
+
"js-xxhash": "^5.0.1",
|
|
88
|
+
"uuid": "^13.0.0"
|
|
89
|
+
}
|
|
90
|
+
}
|