@taggor/contract 0.4.0 → 0.6.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/dist/.tsbuildinfo +1 -1
- package/dist/artifact-keys.d.ts +11 -11
- package/dist/artifact-keys.d.ts.map +1 -1
- package/dist/artifact-keys.js +11 -11
- package/dist/artifact-keys.js.map +1 -1
- package/dist/assets.d.ts +5 -5
- package/dist/assets.js +5 -5
- package/dist/bounded-path.d.ts +2 -2
- package/dist/bounded-path.js +2 -2
- package/dist/bounded.d.ts +2 -2
- package/dist/bounded.js +2 -2
- package/dist/build-diagnostic.d.ts +5 -5
- package/dist/build-diagnostic.js +5 -5
- package/dist/component-types.d.ts +7 -7
- package/dist/component-types.js +4 -4
- package/dist/component-types.js.map +1 -1
- package/dist/contract-version.d.ts +17 -12
- package/dist/contract-version.d.ts.map +1 -1
- package/dist/contract-version.js +24 -17
- package/dist/contract-version.js.map +1 -1
- package/dist/credential-fields.d.ts +1 -1
- package/dist/credential-fields.js +1 -1
- package/dist/css-tokens.d.ts +1 -1
- package/dist/css-tokens.js +1 -1
- package/dist/css-value.d.ts +4 -4
- package/dist/css-value.js +4 -4
- package/dist/data-api.d.ts +14 -44
- package/dist/data-api.d.ts.map +1 -1
- package/dist/data-api.js +20 -54
- package/dist/data-api.js.map +1 -1
- package/dist/denylist-keys.d.ts +1 -1
- package/dist/denylist-keys.js +4 -4
- package/dist/diagnostic-catalog.d.ts +63 -89
- package/dist/diagnostic-catalog.d.ts.map +1 -1
- package/dist/diagnostic-catalog.js +63 -87
- package/dist/diagnostic-catalog.js.map +1 -1
- package/dist/dom-members.snapshot.d.ts +4 -4
- package/dist/dom-members.snapshot.js +8 -8
- package/dist/early-loading.d.ts +1 -1
- package/dist/early-loading.js +1 -1
- package/dist/error-catalog.d.ts +81 -7
- package/dist/error-catalog.d.ts.map +1 -1
- package/dist/error-catalog.js +121 -51
- package/dist/error-catalog.js.map +1 -1
- package/dist/error-titles-pt-br.d.ts +13 -0
- package/dist/error-titles-pt-br.d.ts.map +1 -0
- package/dist/error-titles-pt-br.js +99 -0
- package/dist/error-titles-pt-br.js.map +1 -0
- package/dist/event-params.d.ts +41 -0
- package/dist/event-params.d.ts.map +1 -0
- package/dist/event-params.js +92 -0
- package/dist/event-params.js.map +1 -0
- package/dist/executable-config.d.ts +1 -1
- package/dist/freeze.d.ts +2 -2
- package/dist/freeze.js +2 -2
- package/dist/gunzip.d.ts +3 -3
- package/dist/gunzip.js +4 -4
- package/dist/gunzip.js.map +1 -1
- package/dist/hostname.d.ts +5 -6
- package/dist/hostname.d.ts.map +1 -1
- package/dist/hostname.js +7 -8
- package/dist/hostname.js.map +1 -1
- package/dist/human-actions.d.ts +3 -3
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/dist/json-schema.d.ts +15 -15
- package/dist/json-schema.d.ts.map +1 -1
- package/dist/json-schema.js +20 -28
- package/dist/json-schema.js.map +1 -1
- package/dist/key-checksum.d.ts +1 -1
- package/dist/key-checksum.js +1 -1
- package/dist/libraries.d.ts +4 -4
- package/dist/libraries.d.ts.map +1 -1
- package/dist/libraries.js +4 -4
- package/dist/libraries.js.map +1 -1
- package/dist/limit-catalog.d.ts +19 -40
- package/dist/limit-catalog.d.ts.map +1 -1
- package/dist/limit-catalog.js +34 -55
- package/dist/limit-catalog.js.map +1 -1
- package/dist/limits.d.ts +22 -34
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +23 -35
- package/dist/limits.js.map +1 -1
- package/dist/locale-tag.d.ts +3 -3
- package/dist/locale-tag.js +3 -3
- package/dist/make-diagnostic.d.ts +2 -3
- package/dist/make-diagnostic.d.ts.map +1 -1
- package/dist/make-diagnostic.js.map +1 -1
- package/dist/manifest-compat-diagnostics.d.ts +1 -1
- package/dist/manifest-compat.js +1 -1
- package/dist/manifest.d.ts +44 -24
- package/dist/manifest.d.ts.map +1 -1
- package/dist/manifest.js +41 -61
- package/dist/manifest.js.map +1 -1
- package/dist/metering.d.ts +33 -21
- package/dist/metering.d.ts.map +1 -1
- package/dist/metering.js +33 -21
- package/dist/metering.js.map +1 -1
- package/dist/migrate.d.ts +1 -1
- package/dist/migrate.js +5 -5
- package/dist/migrate.js.map +1 -1
- package/dist/money.d.ts +2 -2
- package/dist/money.js +2 -2
- package/dist/names.d.ts +4 -4
- package/dist/names.js +4 -4
- package/dist/overage-pricing.d.ts +1 -1
- package/dist/overage-pricing.js +1 -1
- package/dist/plan-ids.d.ts +1 -1
- package/dist/plan-ids.js +1 -1
- package/dist/plan-limits.d.ts +13 -13
- package/dist/plan-limits.d.ts.map +1 -1
- package/dist/plan-limits.js +8 -8
- package/dist/plan-limits.js.map +1 -1
- package/dist/plan-pricing.d.ts +33 -62
- package/dist/plan-pricing.d.ts.map +1 -1
- package/dist/plan-pricing.js +20 -67
- package/dist/plan-pricing.js.map +1 -1
- package/dist/plan-usage.d.ts +18 -18
- package/dist/plan-usage.d.ts.map +1 -1
- package/dist/plan-usage.js +19 -20
- package/dist/plan-usage.js.map +1 -1
- package/dist/preview-token.js +2 -2
- package/dist/prop-names.d.ts +5 -5
- package/dist/prop-names.d.ts.map +1 -1
- package/dist/prop-names.js +10 -10
- package/dist/prop-names.js.map +1 -1
- package/dist/prop-type-docs.js +1 -1
- package/dist/prop-types.d.ts +6 -6
- package/dist/prop-types.js +16 -16
- package/dist/prop-types.js.map +1 -1
- package/dist/props.d.ts +5 -5
- package/dist/props.js +6 -6
- package/dist/props.js.map +1 -1
- package/dist/proto-guard.js +3 -3
- package/dist/proto-guard.js.map +1 -1
- package/dist/runtime-errors.d.ts +2 -2
- package/dist/runtime-errors.js +2 -2
- package/dist/runtime-pointers.d.ts +2 -2
- package/dist/runtime-pointers.js +2 -2
- package/{schema → dist/schema}/component-manifest.v1.json +7 -14
- package/{schema → dist/schema}/data-api.v1.json +4 -39
- package/dist/secret-scan.d.ts +10 -10
- package/dist/secret-scan.d.ts.map +1 -1
- package/dist/secret-scan.js +15 -16
- package/dist/secret-scan.js.map +1 -1
- package/dist/semver.d.ts +2 -2
- package/dist/semver.js +2 -2
- package/dist/server-key.js +1 -1
- package/dist/site-manifest-keys.d.ts +11 -11
- package/dist/site-manifest-keys.d.ts.map +1 -1
- package/dist/site-manifest-keys.js +18 -18
- package/dist/site-manifest-keys.js.map +1 -1
- package/dist/site-manifest.d.ts +3 -10
- package/dist/site-manifest.d.ts.map +1 -1
- package/dist/site-manifest.js +12 -15
- package/dist/site-manifest.js.map +1 -1
- package/dist/source-archive.d.ts +13 -13
- package/dist/source-archive.js +25 -25
- package/dist/source-archive.js.map +1 -1
- package/dist/source-package-corpus.d.ts +3 -4
- package/dist/source-package-corpus.d.ts.map +1 -1
- package/dist/source-package-corpus.js +4 -6
- package/dist/source-package-corpus.js.map +1 -1
- package/dist/source-package.d.ts +17 -17
- package/dist/source-package.d.ts.map +1 -1
- package/dist/source-package.js +15 -15
- package/dist/source-package.js.map +1 -1
- package/dist/source-secrets.js +1 -1
- package/dist/ssr-cap.d.ts +2 -2
- package/dist/ssr-cap.d.ts.map +1 -1
- package/dist/ssr-cap.js +4 -4
- package/dist/ssr-kv.d.ts +1 -1
- package/dist/ssr-kv.js +1 -1
- package/dist/ssr-render.d.ts +2 -2
- package/dist/ssr-render.d.ts.map +1 -1
- package/dist/ssr-render.js +3 -3
- package/dist/ssr-render.js.map +1 -1
- package/dist/ssr-version-ledger.js +3 -3
- package/dist/style-references.d.ts +2 -3
- package/dist/style-references.d.ts.map +1 -1
- package/dist/style-references.js +10 -11
- package/dist/style-references.js.map +1 -1
- package/dist/support-contact.d.ts +11 -0
- package/dist/support-contact.d.ts.map +1 -0
- package/dist/support-contact.js +11 -0
- package/dist/support-contact.js.map +1 -0
- package/dist/tag-name.d.ts +6 -6
- package/dist/tag-name.d.ts.map +1 -1
- package/dist/tag-name.js +7 -7
- package/dist/tag-name.js.map +1 -1
- package/dist/tar-writer.js +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/text-codec.d.ts +2 -2
- package/dist/text-codec.js +2 -2
- package/dist/url-value.d.ts +1 -1
- package/dist/url-value.d.ts.map +1 -1
- package/dist/url-value.js +7 -7
- package/dist/url-value.js.map +1 -1
- package/dist/usage-guard.d.ts +16 -16
- package/dist/usage-guard.js +15 -15
- package/dist/usage-mirror.d.ts +5 -5
- package/dist/value-check.d.ts +6 -6
- package/dist/value-check.js +20 -20
- package/dist/value-check.js.map +1 -1
- package/dist/value-patterns.js +2 -2
- package/dist/value-schema.d.ts +3 -3
- package/dist/value-schema.d.ts.map +1 -1
- package/dist/value-schema.js +4 -4
- package/dist/value-schema.js.map +1 -1
- package/dist/zod-free.d.ts +25 -25
- package/dist/zod-free.d.ts.map +1 -1
- package/dist/zod-free.js +26 -26
- package/dist/zod-free.js.map +1 -1
- package/package.json +9 -10
- package/dist/consent-text.d.ts +0 -31
- package/dist/consent-text.d.ts.map +0 -1
- package/dist/consent-text.js +0 -41
- package/dist/consent-text.js.map +0 -1
- package/schema/DEPLOYED +0 -12
- package/schema/published/SHA256SUMS +0 -41
- package/schema/published/build-diagnostic/v1.10.json +0 -83
- package/schema/published/build-diagnostic/v1.11.json +0 -83
- package/schema/published/build-diagnostic/v1.3.json +0 -83
- package/schema/published/build-diagnostic/v1.4.json +0 -83
- package/schema/published/build-diagnostic/v1.5.json +0 -83
- package/schema/published/build-diagnostic/v1.6.json +0 -83
- package/schema/published/build-diagnostic/v1.7.json +0 -83
- package/schema/published/build-diagnostic/v1.8.json +0 -83
- package/schema/published/build-diagnostic/v1.9.json +0 -83
- package/schema/published/component-manifest/v1.10.json +0 -1443
- package/schema/published/component-manifest/v1.11.json +0 -1443
- package/schema/published/component-manifest/v1.3.json +0 -1411
- package/schema/published/component-manifest/v1.4.json +0 -1419
- package/schema/published/component-manifest/v1.5.json +0 -1437
- package/schema/published/component-manifest/v1.6.json +0 -1437
- package/schema/published/component-manifest/v1.7.json +0 -1437
- package/schema/published/component-manifest/v1.8.json +0 -1437
- package/schema/published/component-manifest/v1.9.json +0 -1437
- package/schema/published/data-api/v1.10.json +0 -282
- package/schema/published/data-api/v1.11.json +0 -282
- package/schema/published/data-api/v1.3.json +0 -281
- package/schema/published/data-api/v1.4.json +0 -281
- package/schema/published/data-api/v1.5.json +0 -281
- package/schema/published/data-api/v1.6.json +0 -281
- package/schema/published/data-api/v1.7.json +0 -281
- package/schema/published/data-api/v1.8.json +0 -282
- package/schema/published/data-api/v1.9.json +0 -282
- package/schema/published/library-manifest/v1.10.json +0 -68
- package/schema/published/library-manifest/v1.11.json +0 -68
- package/schema/published/library-manifest/v1.5.json +0 -68
- package/schema/published/library-manifest/v1.6.json +0 -68
- package/schema/published/library-manifest/v1.7.json +0 -68
- package/schema/published/library-manifest/v1.8.json +0 -68
- package/schema/published/library-manifest/v1.9.json +0 -68
- package/schema/published/taggor-config/v1.10.json +0 -56
- package/schema/published/taggor-config/v1.11.json +0 -56
- package/schema/published/taggor-config/v1.5.json +0 -56
- package/schema/published/taggor-config/v1.6.json +0 -56
- package/schema/published/taggor-config/v1.7.json +0 -56
- package/schema/published/taggor-config/v1.8.json +0 -56
- package/schema/published/taggor-config/v1.9.json +0 -56
- /package/{schema → dist/schema}/build-diagnostic.v1.json +0 -0
- /package/{schema → dist/schema}/library-manifest.v1.json +0 -0
- /package/{schema → dist/schema}/taggor-config.v1.json +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Source of the pattern every site key matches, for schemas and database checks. */
|
|
2
2
|
export declare const SITE_KEY_PATTERN = "^st_[a-z2-7]{10}$";
|
|
3
3
|
/**
|
|
4
|
-
* Pattern of a site's Turnstile site key
|
|
4
|
+
* Pattern of a site's Turnstile site key: a PUBLIC key (the secret stays on the edge),
|
|
5
5
|
* the same shape the loader accepts.
|
|
6
6
|
*/
|
|
7
7
|
export declare const TURNSTILE_SITE_KEY_PATTERN = "^[A-Za-z0-9_-]{1,100}$";
|
|
@@ -11,19 +11,19 @@ export declare const TURNSTILE_SITE_KEY_PATTERN = "^[A-Za-z0-9_-]{1,100}$";
|
|
|
11
11
|
* Side effects: none.
|
|
12
12
|
*/
|
|
13
13
|
export declare function isTurnstileSiteKey(value: unknown): value is string;
|
|
14
|
-
/** What a site does with a submission the bot filter marked
|
|
14
|
+
/** What a site does with a submission the bot filter marked; `keep` is the default. */
|
|
15
15
|
export declare const SUSPECT_POLICIES: readonly ["keep", "drop"];
|
|
16
16
|
/** One of `SUSPECT_POLICIES`. */
|
|
17
17
|
export type SuspectPolicy = (typeof SUSPECT_POLICIES)[number];
|
|
18
18
|
/**
|
|
19
19
|
* Whether a site honors the visitor's Global Privacy Control (`Sec-GPC: 1`) or Do Not Track (`DNT: 1`)
|
|
20
|
-
* signal at the event ingest
|
|
20
|
+
* signal at the event ingest when its `protection.respectGpc` is absent. Privacy by default
|
|
21
21
|
* (golden rule 6): ON. The one place that holds the default; flip it here, nowhere else.
|
|
22
22
|
*/
|
|
23
23
|
export declare const RESPECT_GPC_DEFAULT = true;
|
|
24
24
|
/**
|
|
25
25
|
* Default daily cap of submissions per site to a form without a Turnstile key, and the hard
|
|
26
|
-
* bounds of a site's own `protection.dailyCap
|
|
26
|
+
* bounds of a site's own `protection.dailyCap`. The platform ceiling is lower and comes
|
|
27
27
|
* from the deploy's environment (the API reads it); the upper bound here only keeps a
|
|
28
28
|
* manifest value sane.
|
|
29
29
|
*/
|
|
@@ -49,29 +49,29 @@ export declare function manifestKvKey(siteKey: string, channel: ManifestChannel)
|
|
|
49
49
|
/** Seconds a daily cap mark lives (KV's `expirationTtl`); the consumer refreshes it while the cap holds. */
|
|
50
50
|
export declare const DAILY_CAP_MARK_TTL_SECONDS = 3600;
|
|
51
51
|
/**
|
|
52
|
-
* KV key of a site's daily cap mark
|
|
52
|
+
* KV key of a site's daily cap mark.
|
|
53
53
|
* Inputs: a site key. Output: `cap:<siteKey>`. Errors: `TypeError` when the site key is malformed.
|
|
54
54
|
* Side effects: none.
|
|
55
55
|
*/
|
|
56
56
|
export declare function dailyCapKvKey(siteKey: string): string;
|
|
57
57
|
/**
|
|
58
|
-
* Seconds a Free plan submission cut mark lives
|
|
58
|
+
* Seconds a Free plan submission cut mark lives. Six hours, like the render cut marks: the
|
|
59
59
|
* consumer rewrites it with every message it refuses and the usage job with every visit, so a plan
|
|
60
60
|
* upgrade lifts the cut within this time and a lapse of the writers only lets a few messages through
|
|
61
61
|
* (the consumer refuses them again and rewrites the mark).
|
|
62
62
|
*/
|
|
63
63
|
export declare const SUBMISSION_CAP_MARK_TTL_SECONDS: number;
|
|
64
64
|
/**
|
|
65
|
-
* KV key of a site's Free plan submission cut mark
|
|
65
|
+
* KV key of a site's Free plan submission cut mark.
|
|
66
66
|
* Inputs: a site key. Output: `subcap:<siteKey>`. Errors: `TypeError` when the site key is malformed.
|
|
67
67
|
* Side effects: none.
|
|
68
68
|
*/
|
|
69
69
|
export declare function submissionCapKvKey(siteKey: string): string;
|
|
70
70
|
/**
|
|
71
|
-
* KV key of a site's usage cut mark (
|
|
72
|
-
* present while the site's workspace is past its plan's renders per month plus the grace
|
|
71
|
+
* KV key of a site's usage cut mark (written by the plan's usage cut):
|
|
72
|
+
* present while the site's workspace is past its plan's renders per month plus the grace. The edge reads it on the loader and manifest routes
|
|
73
73
|
* only and then serves the inert answer; the data ingest ignores it, so a form already on a page
|
|
74
|
-
* keeps collecting
|
|
74
|
+
* keeps collecting.
|
|
75
75
|
* Inputs: a site key. Output: `viewcap:<siteKey>`. Errors: `TypeError` when the site key is malformed.
|
|
76
76
|
* Side effects: none.
|
|
77
77
|
*/
|
|
@@ -97,7 +97,7 @@ export interface EmptySiteManifest {
|
|
|
97
97
|
*/
|
|
98
98
|
export declare function emptySiteManifest(siteKey: string): EmptySiteManifest;
|
|
99
99
|
/**
|
|
100
|
-
* Most components one site manifest lists: the PLATFORM ceiling
|
|
100
|
+
* Most components one site manifest lists: the PLATFORM ceiling, equal to the highest
|
|
101
101
|
* `planQuotas[*].componentsPerSite` (a test keeps them equal). What one site may attach depends on
|
|
102
102
|
* its plan; this is only what the manifest schema and the loader accept at all, so a plan change
|
|
103
103
|
* never makes a stored manifest invalid. The loader repeats the number (`MAX_COMPONENTS`, it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-manifest-keys.d.ts","sourceRoot":"","sources":["../src/site-manifest-keys.ts"],"names":[],"mappings":"AAuBA,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAIpD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,2BAA2B,CAAC;AAInE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAElE;AAED,
|
|
1
|
+
{"version":3,"file":"site-manifest-keys.d.ts","sourceRoot":"","sources":["../src/site-manifest-keys.ts"],"names":[],"mappings":"AAuBA,qFAAqF;AACrF,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAIpD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,2BAA2B,CAAC;AAInE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAElE;AAED,uFAAuF;AACvF,eAAO,MAAM,gBAAgB,2BAA4B,CAAC;AAE1D,iCAAiC;AACjC,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AACvC,eAAO,MAAM,aAAa,IAAI,CAAC;AAC/B,eAAO,MAAM,kBAAkB,UAAY,CAAC;AAE5C,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,oCAAqC,CAAC;AAEpE,kCAAkC;AAClC,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAG/E;AAED,4GAA4G;AAC5G,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,QAAc,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,qFAAqF;AACrF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,cAAc,EAAE,SAAS,EAAE,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC;CAClC;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,iBAAiB,CAEpE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,MAAM,CAAC"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Zod-free pieces of the site manifest
|
|
2
|
+
* Zod-free pieces of the site manifest: the site key format, the KV key layout of the
|
|
3
3
|
* manifest store and of the published-bundle index, and the manifest served for a site that does
|
|
4
4
|
* not exist. The API writes KV with these keys and the edge reads with them (the edge never
|
|
5
|
-
* writes
|
|
5
|
+
* writes), so the layout lives in one place. Nothing here imports Zod, so the edge
|
|
6
6
|
* and the browser runtime can import it from `@taggor/contract/zod-free`.
|
|
7
7
|
*
|
|
8
8
|
* KV layout (one namespace, `MANIFESTS` in the edge):
|
|
9
9
|
* - `manifest:<siteKey>:<channel>`: the JSON of one `SiteManifest` (the channel is the site's
|
|
10
10
|
* environment). Absent for a site that is unknown, disabled or deleted, so those three read
|
|
11
|
-
* alike
|
|
11
|
+
* alike.
|
|
12
12
|
* - `published:<artifactKey>`: JSON `{ "contractVersion": "1.0.0" }` for each public artifact
|
|
13
13
|
* (`b/<sha256>.js|css`) of a version a site manifest points to. The CDN serves only keys with
|
|
14
|
-
* this entry, so a build that never became a published version is never hosted
|
|
15
|
-
* - `cap:<siteKey>`: written by the API's queue consumer
|
|
14
|
+
* this entry, so a build that never became a published version is never hosted.
|
|
15
|
+
* - `cap:<siteKey>`: written by the API's queue consumer for an hour when a site's form
|
|
16
16
|
* without a Turnstile key spent its daily cap of submissions; the edge answers 429
|
|
17
17
|
* `daily_cap_reached` while it exists. The value is not read, only the key's presence.
|
|
18
|
-
* - `subcap:<siteKey>`: written by the same consumer and by the hourly usage job
|
|
19
|
-
*
|
|
18
|
+
* - `subcap:<siteKey>`: written by the same consumer and by the hourly usage job
|
|
19
|
+
* when the workspace of a FREE site spent its month's submissions or its storage; the edge
|
|
20
20
|
* answers 429 before reading the body while it exists. Only the key's presence is read.
|
|
21
21
|
*/
|
|
22
22
|
import { isPublicArtifactKey } from "./artifact-keys.js";
|
|
@@ -24,7 +24,7 @@ import { isPublicArtifactKey } from "./artifact-keys.js";
|
|
|
24
24
|
export const SITE_KEY_PATTERN = "^st_[a-z2-7]{10}$";
|
|
25
25
|
const SITE_KEY = new RegExp(SITE_KEY_PATTERN);
|
|
26
26
|
/**
|
|
27
|
-
* Pattern of a site's Turnstile site key
|
|
27
|
+
* Pattern of a site's Turnstile site key: a PUBLIC key (the secret stays on the edge),
|
|
28
28
|
* the same shape the loader accepts.
|
|
29
29
|
*/
|
|
30
30
|
export const TURNSTILE_SITE_KEY_PATTERN = "^[A-Za-z0-9_-]{1,100}$";
|
|
@@ -37,17 +37,17 @@ const TURNSTILE_SITE_KEY = new RegExp(TURNSTILE_SITE_KEY_PATTERN);
|
|
|
37
37
|
export function isTurnstileSiteKey(value) {
|
|
38
38
|
return typeof value === "string" && TURNSTILE_SITE_KEY.test(value);
|
|
39
39
|
}
|
|
40
|
-
/** What a site does with a submission the bot filter marked
|
|
40
|
+
/** What a site does with a submission the bot filter marked; `keep` is the default. */
|
|
41
41
|
export const SUSPECT_POLICIES = ["keep", "drop"];
|
|
42
42
|
/**
|
|
43
43
|
* Whether a site honors the visitor's Global Privacy Control (`Sec-GPC: 1`) or Do Not Track (`DNT: 1`)
|
|
44
|
-
* signal at the event ingest
|
|
44
|
+
* signal at the event ingest when its `protection.respectGpc` is absent. Privacy by default
|
|
45
45
|
* (golden rule 6): ON. The one place that holds the default; flip it here, nowhere else.
|
|
46
46
|
*/
|
|
47
47
|
export const RESPECT_GPC_DEFAULT = true;
|
|
48
48
|
/**
|
|
49
49
|
* Default daily cap of submissions per site to a form without a Turnstile key, and the hard
|
|
50
|
-
* bounds of a site's own `protection.dailyCap
|
|
50
|
+
* bounds of a site's own `protection.dailyCap`. The platform ceiling is lower and comes
|
|
51
51
|
* from the deploy's environment (the API reads it); the upper bound here only keeps a
|
|
52
52
|
* manifest value sane.
|
|
53
53
|
*/
|
|
@@ -77,7 +77,7 @@ export function manifestKvKey(siteKey, channel) {
|
|
|
77
77
|
/** Seconds a daily cap mark lives (KV's `expirationTtl`); the consumer refreshes it while the cap holds. */
|
|
78
78
|
export const DAILY_CAP_MARK_TTL_SECONDS = 3600;
|
|
79
79
|
/**
|
|
80
|
-
* KV key of a site's daily cap mark
|
|
80
|
+
* KV key of a site's daily cap mark.
|
|
81
81
|
* Inputs: a site key. Output: `cap:<siteKey>`. Errors: `TypeError` when the site key is malformed.
|
|
82
82
|
* Side effects: none.
|
|
83
83
|
*/
|
|
@@ -87,14 +87,14 @@ export function dailyCapKvKey(siteKey) {
|
|
|
87
87
|
return `cap:${siteKey}`;
|
|
88
88
|
}
|
|
89
89
|
/**
|
|
90
|
-
* Seconds a Free plan submission cut mark lives
|
|
90
|
+
* Seconds a Free plan submission cut mark lives. Six hours, like the render cut marks: the
|
|
91
91
|
* consumer rewrites it with every message it refuses and the usage job with every visit, so a plan
|
|
92
92
|
* upgrade lifts the cut within this time and a lapse of the writers only lets a few messages through
|
|
93
93
|
* (the consumer refuses them again and rewrites the mark).
|
|
94
94
|
*/
|
|
95
95
|
export const SUBMISSION_CAP_MARK_TTL_SECONDS = 6 * 60 * 60;
|
|
96
96
|
/**
|
|
97
|
-
* KV key of a site's Free plan submission cut mark
|
|
97
|
+
* KV key of a site's Free plan submission cut mark.
|
|
98
98
|
* Inputs: a site key. Output: `subcap:<siteKey>`. Errors: `TypeError` when the site key is malformed.
|
|
99
99
|
* Side effects: none.
|
|
100
100
|
*/
|
|
@@ -104,10 +104,10 @@ export function submissionCapKvKey(siteKey) {
|
|
|
104
104
|
return `subcap:${siteKey}`;
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
* KV key of a site's usage cut mark (
|
|
108
|
-
* present while the site's workspace is past its plan's renders per month plus the grace
|
|
107
|
+
* KV key of a site's usage cut mark (written by the plan's usage cut):
|
|
108
|
+
* present while the site's workspace is past its plan's renders per month plus the grace. The edge reads it on the loader and manifest routes
|
|
109
109
|
* only and then serves the inert answer; the data ingest ignores it, so a form already on a page
|
|
110
|
-
* keeps collecting
|
|
110
|
+
* keeps collecting.
|
|
111
111
|
* Inputs: a site key. Output: `viewcap:<siteKey>`. Errors: `TypeError` when the site key is malformed.
|
|
112
112
|
* Side effects: none.
|
|
113
113
|
*/
|
|
@@ -136,7 +136,7 @@ export function emptySiteManifest(siteKey) {
|
|
|
136
136
|
return { siteKey, revision: 0, allowedDomains: [], components: [] };
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
|
-
* Most components one site manifest lists: the PLATFORM ceiling
|
|
139
|
+
* Most components one site manifest lists: the PLATFORM ceiling, equal to the highest
|
|
140
140
|
* `planQuotas[*].componentsPerSite` (a test keeps them equal). What one site may attach depends on
|
|
141
141
|
* its plan; this is only what the manifest schema and the loader accept at all, so a plan change
|
|
142
142
|
* never makes a stored manifest invalid. The loader repeats the number (`MAX_COMPONENTS`, it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-manifest-keys.js","sourceRoot":"","sources":["../src/site-manifest-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,qFAAqF;AACrF,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAEpD,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAEnE,MAAM,kBAAkB,GAAG,IAAI,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAElE;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACrE,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"site-manifest-keys.js","sourceRoot":"","sources":["../src/site-manifest-keys.ts"],"names":[],"mappings":"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"}
|
package/dist/site-manifest.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The site manifest
|
|
2
|
+
* The site manifest: what a site's snippet needs to load its components, compiled by the
|
|
3
3
|
* API from Postgres and stored in KV, served read-only by the edge at `/m/<siteKey>.json`. Public
|
|
4
4
|
* by nature (it goes to every visitor): it holds no workspace id, component id or customer data
|
|
5
5
|
* beyond the site's own allowed domains and component defaults.
|
|
@@ -11,9 +11,8 @@ import * as z from "zod";
|
|
|
11
11
|
import { SITE_MANIFEST_MAX_COMPONENTS } from "./site-manifest-keys.js";
|
|
12
12
|
export { SITE_MANIFEST_MAX_COMPONENTS };
|
|
13
13
|
/**
|
|
14
|
-
* What the data ingest needs to know about a component's collections
|
|
15
|
-
* collections to validate submissions against
|
|
16
|
-
* the prop that carries the privacy policy URL. Copied by the API from the published version's
|
|
14
|
+
* What the data ingest needs to know about a component's collections: the declared
|
|
15
|
+
* collections to validate submissions against. Copied by the API from the published version's
|
|
17
16
|
* manifest, so the edge never trusts the request for any of it. The edge strips it from the
|
|
18
17
|
* public `/m/` and `/s/` answers: visitors' pages do not need it.
|
|
19
18
|
*/
|
|
@@ -83,8 +82,6 @@ export declare const siteManifestComponentDataSchema: z.ZodObject<{
|
|
|
83
82
|
private: "private";
|
|
84
83
|
}>>;
|
|
85
84
|
}, z.core.$strict>>;
|
|
86
|
-
personal: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
-
privacyPolicyUrl: z.ZodOptional<z.ZodString>;
|
|
88
85
|
}, z.core.$strict>;
|
|
89
86
|
/** One component a site loads. */
|
|
90
87
|
export declare const siteManifestComponentSchema: z.ZodObject<{
|
|
@@ -168,8 +165,6 @@ export declare const siteManifestComponentSchema: z.ZodObject<{
|
|
|
168
165
|
private: "private";
|
|
169
166
|
}>>;
|
|
170
167
|
}, z.core.$strict>>;
|
|
171
|
-
personal: z.ZodOptional<z.ZodBoolean>;
|
|
172
|
-
privacyPolicyUrl: z.ZodOptional<z.ZodString>;
|
|
173
168
|
}, z.core.$strict>>;
|
|
174
169
|
}, z.core.$strict>;
|
|
175
170
|
/** The `data` entry of a site manifest component. */
|
|
@@ -262,8 +257,6 @@ export declare const siteManifestSchema: z.ZodObject<{
|
|
|
262
257
|
private: "private";
|
|
263
258
|
}>>;
|
|
264
259
|
}, z.core.$strict>>;
|
|
265
|
-
personal: z.ZodOptional<z.ZodBoolean>;
|
|
266
|
-
privacyPolicyUrl: z.ZodOptional<z.ZodString>;
|
|
267
260
|
}, z.core.$strict>>;
|
|
268
261
|
}, z.core.$strict>>;
|
|
269
262
|
turnstileSiteKey: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-manifest.d.ts","sourceRoot":"","sources":["../src/site-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAQzB,OAAO,EAIL,4BAA4B,EAG7B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,4BAA4B,EAAE,CAAC;AAExC
|
|
1
|
+
{"version":3,"file":"site-manifest.d.ts","sourceRoot":"","sources":["../src/site-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAQzB,OAAO,EAIL,4BAA4B,EAG7B,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,4BAA4B,EAAE,CAAC;AAExC;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAO1C,CAAC;AAEH,kCAAkC;AAClC,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6BtC,CAAC;AAEH,qDAAqD;AACrD,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,+BAA+B,CAAC,CAAC;AAExF,8CAA8C;AAC9C,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,gCAAgC;AAChC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAmC7B,CAAC;AAEH,yCAAyC;AACzC,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
package/dist/site-manifest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The site manifest
|
|
2
|
+
* The site manifest: what a site's snippet needs to load its components, compiled by the
|
|
3
3
|
* API from Postgres and stored in KV, served read-only by the edge at `/m/<siteKey>.json`. Public
|
|
4
4
|
* by nature (it goes to every visitor): it holds no workspace id, component id or customer data
|
|
5
5
|
* beyond the site's own allowed domains and component defaults.
|
|
@@ -13,21 +13,18 @@ import { boundedRecord } from "./bounded.js";
|
|
|
13
13
|
import { MANIFEST_LIMITS } from "./limits.js";
|
|
14
14
|
import { RUNTIME_RINGS } from "./runtime-pointers.js";
|
|
15
15
|
import { collectionSchema, eventSampleRateSchema } from "./manifest.js";
|
|
16
|
-
import { memberNameSchema
|
|
16
|
+
import { memberNameSchema } from "./names.js";
|
|
17
17
|
import { DAILY_CAP_HARD_MAX, DAILY_CAP_MIN, SITE_KEY_PATTERN, SITE_MANIFEST_MAX_COMPONENTS, SUSPECT_POLICIES, TURNSTILE_SITE_KEY_PATTERN, } from "./site-manifest-keys.js";
|
|
18
18
|
import { TAG_NAME_PATTERN } from "./tag-name.js";
|
|
19
19
|
export { SITE_MANIFEST_MAX_COMPONENTS };
|
|
20
20
|
/**
|
|
21
|
-
* What the data ingest needs to know about a component's collections
|
|
22
|
-
* collections to validate submissions against
|
|
23
|
-
* the prop that carries the privacy policy URL. Copied by the API from the published version's
|
|
21
|
+
* What the data ingest needs to know about a component's collections: the declared
|
|
22
|
+
* collections to validate submissions against. Copied by the API from the published version's
|
|
24
23
|
* manifest, so the edge never trusts the request for any of it. The edge strips it from the
|
|
25
24
|
* public `/m/` and `/s/` answers: visitors' pages do not need it.
|
|
26
25
|
*/
|
|
27
26
|
export const siteManifestComponentDataSchema = z.strictObject({
|
|
28
27
|
collections: boundedRecord(memberNameSchema, collectionSchema, MANIFEST_LIMITS.maxCollections, "collections"),
|
|
29
|
-
personal: z.boolean().optional(),
|
|
30
|
-
privacyPolicyUrl: propNameSchema.optional(),
|
|
31
28
|
});
|
|
32
29
|
/** One component a site loads. */
|
|
33
30
|
export const siteManifestComponentSchema = z.strictObject({
|
|
@@ -46,18 +43,18 @@ export const siteManifestComponentSchema = z.strictObject({
|
|
|
46
43
|
/** `disabled` is the kill switch: the loader skips the component. */
|
|
47
44
|
status: z.enum(["active", "disabled"]),
|
|
48
45
|
/**
|
|
49
|
-
* When the loader imports the bundle
|
|
46
|
+
* When the loader imports the bundle: `idle` waits for an idle moment of the page and
|
|
50
47
|
* fetches the loader's lazy `loading.js` module to do it. Absent means `eager` (on load), so
|
|
51
48
|
* manifests written before this field read the same. An older loader ignores the field.
|
|
52
49
|
*/
|
|
53
50
|
loading: z.enum(["idle"]).optional(),
|
|
54
51
|
/**
|
|
55
|
-
* The component's `eventSampleRate
|
|
56
|
-
* browser sends that share of `
|
|
52
|
+
* The component's `eventSampleRate`, copied from the published version's manifest: the
|
|
53
|
+
* browser sends that share of `track` events, and the edge weights what it
|
|
57
54
|
* stores by `1 / rate` from this stored value, never from the request. Absent: all are sent.
|
|
58
55
|
*/
|
|
59
56
|
eventSampleRate: eventSampleRateSchema.optional(),
|
|
60
|
-
/** Collections of the component for the data ingest
|
|
57
|
+
/** Collections of the component for the data ingest; absent when it declares none. */
|
|
61
58
|
data: siteManifestComponentDataSchema.optional(),
|
|
62
59
|
});
|
|
63
60
|
/** The manifest of one site. */
|
|
@@ -69,11 +66,11 @@ export const siteManifestSchema = z.strictObject({
|
|
|
69
66
|
components: z.array(siteManifestComponentSchema).max(SITE_MANIFEST_MAX_COMPONENTS),
|
|
70
67
|
/**
|
|
71
68
|
* The site's Turnstile public key, embedded in the loader of a site with a collection component
|
|
72
|
-
* so submissions carry a token
|
|
69
|
+
* so submissions carry a token; absent when the site has none.
|
|
73
70
|
*/
|
|
74
71
|
turnstileSiteKey: z.string().regex(new RegExp(TURNSTILE_SITE_KEY_PATTERN)).optional(),
|
|
75
72
|
/**
|
|
76
|
-
* What the customer chose about the submissions of the site's forms
|
|
73
|
+
* What the customer chose about the submissions of the site's forms: `suspects` (keep
|
|
77
74
|
* is the default, drop is opt-in) and `dailyCap` (per site, up to the platform ceiling the API
|
|
78
75
|
* checks). Absent when nothing was chosen. Never served to visitors (`/m/` leaves it out).
|
|
79
76
|
*/
|
|
@@ -81,12 +78,12 @@ export const siteManifestSchema = z.strictObject({
|
|
|
81
78
|
.strictObject({
|
|
82
79
|
suspects: z.enum(SUSPECT_POLICIES).optional(),
|
|
83
80
|
dailyCap: z.int().min(DAILY_CAP_MIN).max(DAILY_CAP_HARD_MAX).optional(),
|
|
84
|
-
/**
|
|
81
|
+
/** honor `Sec-GPC`/`DNT` at the event ingest; absent means `RESPECT_GPC_DEFAULT`. */
|
|
85
82
|
respectGpc: z.boolean().optional(),
|
|
86
83
|
})
|
|
87
84
|
.optional(),
|
|
88
85
|
/**
|
|
89
|
-
* The runtime ring of the site
|
|
86
|
+
* The runtime ring of the site: `canary` sites get the canary runtime version, the
|
|
90
87
|
* rest (field absent or `stable`) the stable one. Set by the Taggor operator, never by the
|
|
91
88
|
* customer; the API writes it only for canary sites, and the edge leaves it out of `/m/`.
|
|
92
89
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"site-manifest.js","sourceRoot":"","sources":["../src/site-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"site-manifest.js","sourceRoot":"","sources":["../src/site-manifest.ts"],"names":[],"mappings":"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"}
|
package/dist/source-archive.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type SourceProblem } from "./executable-config.js";
|
|
2
2
|
export type { SourceProblem } from "./executable-config.js";
|
|
3
3
|
/**
|
|
4
|
-
* Text extensions a source package may contain; `scss`
|
|
5
|
-
* The asset extensions (`ASSET_SOURCE_EXTENSIONS
|
|
4
|
+
* Text extensions a source package may contain; `scss` (compiled by the builder).
|
|
5
|
+
* The asset extensions (`ASSET_SOURCE_EXTENSIONS`) are accepted too, as bytes.
|
|
6
6
|
*/
|
|
7
7
|
export declare const SOURCE_EXTENSIONS: ReadonlySet<string>;
|
|
8
8
|
/** Most problems one read reports; the rest are dropped (each costs a diagnostic). */
|
|
9
9
|
export declare const MAX_SOURCE_PROBLEMS = 20;
|
|
10
10
|
/**
|
|
11
|
-
* The outcome: the text files (virtual path → text) and the asset files (virtual path → bytes
|
|
12
|
-
*
|
|
11
|
+
* The outcome: the text files (virtual path → text) and the asset files (virtual path → bytes;
|
|
12
|
+
* always empty for a policy that never places an asset), or why the archive was refused.
|
|
13
13
|
*/
|
|
14
14
|
export type SourceArchiveResult = {
|
|
15
15
|
readonly ok: true;
|
|
@@ -29,7 +29,7 @@ export interface SourceArchiveLimits {
|
|
|
29
29
|
readonly maxUnpackedBytes: number;
|
|
30
30
|
/**
|
|
31
31
|
* Headers of any kind (files, folders, refused entries, pax headers), so a package of tens of
|
|
32
|
-
* thousands of folders stops early
|
|
32
|
+
* thousands of folders stops early. Default: `ENTRIES_PER_FILE` ×
|
|
33
33
|
* `maxFiles`, so a caller that tunes only `maxFiles` (the builder's `tuneBuildLimits`) moves
|
|
34
34
|
* this cap with it.
|
|
35
35
|
*/
|
|
@@ -38,7 +38,7 @@ export interface SourceArchiveLimits {
|
|
|
38
38
|
/** Headers allowed per regular file when `maxEntries` is not given: room for folders and pax. */
|
|
39
39
|
export declare const ENTRIES_PER_FILE = 4;
|
|
40
40
|
/**
|
|
41
|
-
* Most bytes of one pax header
|
|
41
|
+
* Most bytes of one pax header: the only value read is `path`, at
|
|
42
42
|
* most `maxPathLength` characters, so 64 KiB leaves room for every metadata record; 20 MiB of
|
|
43
43
|
* tiny records took 6 s of CPU.
|
|
44
44
|
*/
|
|
@@ -48,9 +48,9 @@ export declare const MAX_PAX_RECORDS = 256;
|
|
|
48
48
|
/**
|
|
49
49
|
* Pax records allowed per entry in the whole archive: the cap is this × `maxEntries` (16,000
|
|
50
50
|
* with the default 2,000, about 40 ms at 2.3 µs a record). One header of 256 records per entry
|
|
51
|
-
* cost 1 to 1.4 s of CPU per read
|
|
51
|
+
* cost 1 to 1.4 s of CPU per read; a flat 4,096 refused a real
|
|
52
52
|
* package, 500 files and 101 folders from macOS bsdtar with `com.apple.quarantine` at 7 records
|
|
53
|
-
* each
|
|
53
|
+
* each.
|
|
54
54
|
*/
|
|
55
55
|
export declare const PAX_RECORDS_PER_ENTRY = 8;
|
|
56
56
|
/** The outcome of checking one archive path. */
|
|
@@ -72,7 +72,7 @@ export type ArchivePathResult = {
|
|
|
72
72
|
*/
|
|
73
73
|
export declare function checkArchivePath(raw: string, maxPathLength: number): ArchivePathResult;
|
|
74
74
|
/**
|
|
75
|
-
* Where a policy puts one entry: a virtual path (as bytes with `asset
|
|
75
|
+
* Where a policy puts one entry: a virtual path (as bytes with `asset`; as UTF-8 text
|
|
76
76
|
* otherwise), nowhere (`skip`) or a refusal.
|
|
77
77
|
*/
|
|
78
78
|
export type TarEntryPlacement = {
|
|
@@ -84,9 +84,9 @@ export type TarEntryPlacement = {
|
|
|
84
84
|
readonly problem: SourceProblem;
|
|
85
85
|
};
|
|
86
86
|
/**
|
|
87
|
-
* Where the regular files and folders of an archive go
|
|
87
|
+
* Where the regular files and folders of an archive go. `file` maps a regular file's
|
|
88
88
|
* stored path to its virtual path, skips it (`{ skip: true }`: not part of the result, its bytes
|
|
89
|
-
* still count in the limits) or refuses it; `directory` does the same for a folder (
|
|
89
|
+
* still count in the limits) or refuses it; `directory` does the same for a folder (the
|
|
90
90
|
* mapped path of an accepted folder is checked against the files, `folderClashes`; a skipped one,
|
|
91
91
|
* such as npm's `package/`, is not). The source package's policy is `fileProblem` below.
|
|
92
92
|
*/
|
|
@@ -99,7 +99,7 @@ export interface TarEntryPolicy {
|
|
|
99
99
|
*
|
|
100
100
|
* Inputs: the uncompressed archive bytes and the limits. Output: `{ ok: true, files, assets }` with
|
|
101
101
|
* every regular file decoded as UTF-8 under its virtual path (`/src/a.ts`), except the ones the
|
|
102
|
-
* policy places as assets (
|
|
102
|
+
* policy places as assets (the source package's images and fonts under `src/`), which are
|
|
103
103
|
* copied as bytes into `assets`; or `{ ok: false, problems }`
|
|
104
104
|
* (at most `MAX_SOURCE_PROBLEMS`). A broken archive stops at its first problem (`SOURCE_INVALID`:
|
|
105
105
|
* bad checksum, size or other numeric field, a GNU or v7 header, a truncated body or header, a
|
|
@@ -110,7 +110,7 @@ export interface TarEntryPolicy {
|
|
|
110
110
|
* (`checkArchivePath`), `SOURCE_ENTRY_NOT_ALLOWED` (symlink, hardlink, device, FIFO, GNU record),
|
|
111
111
|
* `SOURCE_CONFIG_NOT_ALLOWED` (`executableConfigProblem`), `SOURCE_EXTENSION_NOT_ALLOWED`, and
|
|
112
112
|
* `SOURCE_INVALID` for a duplicate path (also by letter case or Unicode normalization), a file that
|
|
113
|
-
* is also a folder (`folderClashes`) or content that is not UTF-8.
|
|
113
|
+
* is also a folder (`folderClashes`) or content that is not UTF-8. `policy` replaces the
|
|
114
114
|
* source package's own rules for paths and files (the npm tarballs of the builder's allowlist);
|
|
115
115
|
* the limits, the folder clashes and the pax bounds apply to every policy, on the paths it maps.
|
|
116
116
|
* Errors: never throws. Side effects: none.
|
package/dist/source-archive.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Reader of the (already decompressed) source package: a POSIX tar archive. Created in the
|
|
3
|
-
* builder
|
|
3
|
+
* builder; moved to the contract, so the API (first line,
|
|
4
4
|
* before the package is stored) and the build container (second line) read a package the same
|
|
5
5
|
* way and refuse it with the same diagnostic codes.
|
|
6
6
|
*
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* metadata, and pax headers are bounded in bytes and records. The result is the in-memory file
|
|
19
19
|
* map the build runs on, so nothing the customer sends is ever written to a disk.
|
|
20
20
|
*
|
|
21
|
-
*
|
|
21
|
+
* The asset files a component imports (`ASSET_SOURCE_EXTENSIONS`: images and WOFF2 fonts)
|
|
22
22
|
* may be in the package too, under `src/` only, and are kept as bytes (`assets`), never decoded as
|
|
23
23
|
* text; every other check (path, duplicates, limits) is the same for them.
|
|
24
24
|
*
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* `MAX_SOURCE_PROBLEMS`, so an agent fixes them in one round; a broken archive or a limit stops
|
|
27
27
|
* the read at once.
|
|
28
28
|
*
|
|
29
|
-
*
|
|
29
|
+
* The builder reads the npm tarballs of its allowlist with this same reader, through a
|
|
30
30
|
* `TarEntryPolicy` of its own (strip `package/`, keep only module files, skip the rest); the
|
|
31
31
|
* header, pax, entry-type, limit and duplicate checks are the same for both.
|
|
32
32
|
*
|
|
@@ -40,8 +40,8 @@ const BLOCK = 512;
|
|
|
40
40
|
/** Entry types that carry a body: regular files (`0`, NUL) and pax headers (`x`, `g`). */
|
|
41
41
|
const BODY_TYPES = new Set(["0", "\0", "x", "g"]);
|
|
42
42
|
/**
|
|
43
|
-
* Text extensions a source package may contain; `scss`
|
|
44
|
-
* The asset extensions (`ASSET_SOURCE_EXTENSIONS
|
|
43
|
+
* Text extensions a source package may contain; `scss` (compiled by the builder).
|
|
44
|
+
* The asset extensions (`ASSET_SOURCE_EXTENSIONS`) are accepted too, as bytes.
|
|
45
45
|
*/
|
|
46
46
|
export const SOURCE_EXTENSIONS = new Set([
|
|
47
47
|
"ts",
|
|
@@ -59,7 +59,7 @@ export const MAX_SOURCE_PROBLEMS = 20;
|
|
|
59
59
|
/** Headers allowed per regular file when `maxEntries` is not given: room for folders and pax. */
|
|
60
60
|
export const ENTRIES_PER_FILE = 4;
|
|
61
61
|
/**
|
|
62
|
-
* Names, pax keys and pax values keep a leading U+FEFF
|
|
62
|
+
* Names, pax keys and pax values keep a leading U+FEFF: a decoder
|
|
63
63
|
* that drops it made `\uFEFFsrc/index.tsx` read as `src/index.tsx` here while bsdtar keeps it
|
|
64
64
|
* outside `src/`, and made a `\uFEFFpath` key act as `path` here while bsdtar and tarfile ignore
|
|
65
65
|
* it. Kept, the BOM reaches `checkArchivePath` (and the key allowlist) and is refused. File
|
|
@@ -83,7 +83,7 @@ const POSIX_MAGIC = [0x75, 0x73, 0x74, 0x61, 0x72, 0x00, 0x30, 0x30];
|
|
|
83
83
|
* Whether a header is POSIX ustar (the format pax extends). GNU headers (`ustar \0`) and v7
|
|
84
84
|
* headers (no magic) are refused: in them the bytes at offset 345 are not a path prefix (GNU
|
|
85
85
|
* keeps times there), so reading them as one made the builder see a different tree from bsdtar
|
|
86
|
-
* and node-tar (
|
|
86
|
+
* and node-tar (M2 remainder).
|
|
87
87
|
*/
|
|
88
88
|
function isPosixUstar(header) {
|
|
89
89
|
return POSIX_MAGIC.every((byte, index) => header[257 + index] === byte);
|
|
@@ -91,8 +91,8 @@ function isPosixUstar(header) {
|
|
|
91
91
|
/**
|
|
92
92
|
* A numeric field as POSIX writes it: optional leading spaces, octal digits, then spaces or NULs
|
|
93
93
|
* to the end of the field. Nothing else: `trim()` accepted a leading `\v`, `\n`, `\f`, `\r` or
|
|
94
|
-
* U+00A0, which libarchive reads as 0, so the two disagreed on where the next header starts
|
|
95
|
-
*
|
|
94
|
+
* U+00A0, which libarchive reads as 0, so the two disagreed on where the next header starts.
|
|
95
|
+
* GNU's base-256 numbers are not POSIX and are refused too.
|
|
96
96
|
*/
|
|
97
97
|
const POSIX_NUMBER = /^ *([0-7]+)[ \0]*$/;
|
|
98
98
|
function octal(header, offset, length) {
|
|
@@ -104,7 +104,7 @@ function octal(header, offset, length) {
|
|
|
104
104
|
* them: optional leading spaces, octal digits, then spaces or NULs. The reader does not use their
|
|
105
105
|
* values, but bsdtar refuses an archive whose first header has, say, `000064x` as its mode, and
|
|
106
106
|
* tarfile stops at such a header further in, so both would see another tree (found by the
|
|
107
|
-
*
|
|
107
|
+
* tar oracle). GNU base-256 values are refused here as everywhere.
|
|
108
108
|
*/
|
|
109
109
|
const POSIX_NUMBER_OR_BLANK = /^ *[0-7]*[ \0]*$/;
|
|
110
110
|
const OTHER_NUMBER_FIELDS = [
|
|
@@ -131,10 +131,10 @@ function isZeroBlock(header) {
|
|
|
131
131
|
return header.every((byte) => byte === 0);
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
|
-
* The pax keys a package may carry
|
|
134
|
+
* The pax keys a package may carry: `path`, which the reader applies,
|
|
135
135
|
* and metadata that changes neither where an entry's data is nor what it is (times, owners, the
|
|
136
136
|
* node-tar `dev`/`ino`/`nlink`, a `comment` such as `git archive`'s, the creation time, the file
|
|
137
|
-
* flags bsdtar writes from the disk (`SCHILY.fflags`,
|
|
137
|
+
* flags bsdtar writes from the disk (`SCHILY.fflags`, only with the values of
|
|
138
138
|
* `ALLOWED_FFLAGS`) and the `com.apple.*` extended attributes macOS tar writes). Any other key is
|
|
139
139
|
* refused: `size`,
|
|
140
140
|
* `linkpath`, `GNU.sparse.*`, `SCHILY.realsize` (bsdtar truncates the file to it), `hdrcharset`
|
|
@@ -159,13 +159,13 @@ const ALLOWED_PAX_KEYS = new Set([
|
|
|
159
159
|
/**
|
|
160
160
|
* Extended attributes macOS tar writes (`SCHILY.xattr.com.apple.provenance`, `…quarantine`,
|
|
161
161
|
* `…metadata:kMDItemWhereFroms`), ignored, since their values are raw bytes. Only `com.apple.*`
|
|
162
|
-
* names with printable ASCII
|
|
162
|
+
* names with printable ASCII: a consumer that extracts the package with
|
|
163
163
|
* xattrs on Linux would apply `security.capability`, `trusted.*` or `system.posix_acl_*`, and a
|
|
164
164
|
* NUL would cut a name to whatever follows a harmless-looking prefix.
|
|
165
165
|
*/
|
|
166
166
|
const ALLOWED_XATTR_KEY = /^(?:SCHILY|LIBARCHIVE)\.xattr\.com\.apple\.[\x21-\x7e]{1,200}$/;
|
|
167
167
|
/**
|
|
168
|
-
* The file flags a `SCHILY.fflags` value may name
|
|
168
|
+
* The file flags a `SCHILY.fflags` value may name: the ones bsdtar
|
|
169
169
|
* writes for an ordinary file (`nocow` on btrfs; `nodump`, `noatime`, `notail`, `compress` from
|
|
170
170
|
* `chattr` on Linux; `hidden` on macOS), which a tool extracting as root may set on the file but
|
|
171
171
|
* which never stop it from being changed or removed. `schg`, `uchg`, `sappnd`, `uappnd` (immutable
|
|
@@ -193,7 +193,7 @@ function isAllowedPaxKey(key) {
|
|
|
193
193
|
return ALLOWED_PAX_KEYS.has(key) || ALLOWED_XATTR_KEY.test(key);
|
|
194
194
|
}
|
|
195
195
|
/**
|
|
196
|
-
* Most bytes of one pax header
|
|
196
|
+
* Most bytes of one pax header: the only value read is `path`, at
|
|
197
197
|
* most `maxPathLength` characters, so 64 KiB leaves room for every metadata record; 20 MiB of
|
|
198
198
|
* tiny records took 6 s of CPU.
|
|
199
199
|
*/
|
|
@@ -203,9 +203,9 @@ export const MAX_PAX_RECORDS = 256;
|
|
|
203
203
|
/**
|
|
204
204
|
* Pax records allowed per entry in the whole archive: the cap is this × `maxEntries` (16,000
|
|
205
205
|
* with the default 2,000, about 40 ms at 2.3 µs a record). One header of 256 records per entry
|
|
206
|
-
* cost 1 to 1.4 s of CPU per read
|
|
206
|
+
* cost 1 to 1.4 s of CPU per read; a flat 4,096 refused a real
|
|
207
207
|
* package, 500 files and 101 folders from macOS bsdtar with `com.apple.quarantine` at 7 records
|
|
208
|
-
* each
|
|
208
|
+
* each.
|
|
209
209
|
*/
|
|
210
210
|
export const PAX_RECORDS_PER_ENTRY = 8;
|
|
211
211
|
/** How to pack without the extended attributes Linux bsdtar stores by default. */
|
|
@@ -352,7 +352,7 @@ function extensionOf(path) {
|
|
|
352
352
|
/**
|
|
353
353
|
* The form two names share when a case-insensitive, normalizing disk (APFS, NTFS) would store
|
|
354
354
|
* them as one file: NFC, then upper and lower case, so `σ`/`ς`, `s`/`ſ` and `ss`/`ß` meet as
|
|
355
|
-
* well as `A`/`a
|
|
355
|
+
* well as `A`/`a`.
|
|
356
356
|
*/
|
|
357
357
|
function foldName(path) {
|
|
358
358
|
return path.normalize("NFC").toUpperCase().toLowerCase().normalize("NFC");
|
|
@@ -418,7 +418,7 @@ function sourcePolicy(limits) {
|
|
|
418
418
|
*
|
|
419
419
|
* Inputs: the uncompressed archive bytes and the limits. Output: `{ ok: true, files, assets }` with
|
|
420
420
|
* every regular file decoded as UTF-8 under its virtual path (`/src/a.ts`), except the ones the
|
|
421
|
-
* policy places as assets (
|
|
421
|
+
* policy places as assets (the source package's images and fonts under `src/`), which are
|
|
422
422
|
* copied as bytes into `assets`; or `{ ok: false, problems }`
|
|
423
423
|
* (at most `MAX_SOURCE_PROBLEMS`). A broken archive stops at its first problem (`SOURCE_INVALID`:
|
|
424
424
|
* bad checksum, size or other numeric field, a GNU or v7 header, a truncated body or header, a
|
|
@@ -429,7 +429,7 @@ function sourcePolicy(limits) {
|
|
|
429
429
|
* (`checkArchivePath`), `SOURCE_ENTRY_NOT_ALLOWED` (symlink, hardlink, device, FIFO, GNU record),
|
|
430
430
|
* `SOURCE_CONFIG_NOT_ALLOWED` (`executableConfigProblem`), `SOURCE_EXTENSION_NOT_ALLOWED`, and
|
|
431
431
|
* `SOURCE_INVALID` for a duplicate path (also by letter case or Unicode normalization), a file that
|
|
432
|
-
* is also a folder (`folderClashes`) or content that is not UTF-8.
|
|
432
|
+
* is also a folder (`folderClashes`) or content that is not UTF-8. `policy` replaces the
|
|
433
433
|
* source package's own rules for paths and files (the npm tarballs of the builder's allowlist);
|
|
434
434
|
* the limits, the folder clashes and the pax bounds apply to every policy, on the paths it maps.
|
|
435
435
|
* Errors: never throws. Side effects: none.
|
|
@@ -492,7 +492,7 @@ export function readSourceArchive(archive, limits, policy = sourcePolicy(limits)
|
|
|
492
492
|
const type = String.fromCharCode(header[156] ?? 0);
|
|
493
493
|
// Only regular files and pax headers have a body. bsdtar and tarfile read the body of any
|
|
494
494
|
// other entry (a directory, a link) as the next headers, so a size there would hide entries
|
|
495
|
-
// from this reader that they extract
|
|
495
|
+
// from this reader that they extract.
|
|
496
496
|
if (size !== 0 && !BODY_TYPES.has(type)) {
|
|
497
497
|
return invalid(`a ${JSON.stringify(type)} entry declares a body of ${String(size)} bytes`);
|
|
498
498
|
}
|
|
@@ -596,8 +596,8 @@ export function readSourceArchive(archive, limits, policy = sourcePolicy(limits)
|
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
598
|
// bsdtar fails on bytes left that are not a whole header, on a last body without its padding
|
|
599
|
-
// (
|
|
600
|
-
// after it, tarfile on a `g` header with none (found by the
|
|
599
|
+
// (the offset then passes the end) and on an `x` header with no entry
|
|
600
|
+
// after it, tarfile on a `g` header with none (found by the tar oracle).
|
|
601
601
|
if (problems.length < MAX_SOURCE_PROBLEMS) {
|
|
602
602
|
if (!ended && offset !== archive.length)
|
|
603
603
|
return invalid("truncated tar archive");
|
|
@@ -611,8 +611,8 @@ export function readSourceArchive(archive, limits, policy = sourcePolicy(limits)
|
|
|
611
611
|
return problems.length === 0 ? { ok: true, files, assets } : { ok: false, problems };
|
|
612
612
|
}
|
|
613
613
|
/**
|
|
614
|
-
* Entries that no disk can hold together, after folding (
|
|
615
|
-
* entries
|
|
614
|
+
* Entries that no disk can hold together, after folding (directory
|
|
615
|
+
* entries): a file or directory inside a path that is a file
|
|
616
616
|
* (`src/a.ts` and `src/a.ts/b.ts`), and a file that is also a directory entry (`src/a.ts` and
|
|
617
617
|
* `src/A.ts/`). Extracting the package would fail or drop one of them.
|
|
618
618
|
*/
|