pixellint 0.34.0 → 0.36.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 CHANGED
@@ -95,3 +95,23 @@ This npm wrapper loads the Node-target WASM build. Its ESM entry uses
95
95
  - [Writing a rulepack](https://github.com/aleksUIX/pixellint/blob/main/docs/RULEPACK_SCHEMA.md)
96
96
 
97
97
  Apache-2.0. Not affiliated with any vendor named in its rulepacks.
98
+
99
+ ## HAR requests use recorded clocks and explicit availability.
100
+
101
+ ```js
102
+ import { importHar, validateHar } from "pixellint";
103
+ const imported = importHar(harText, { headerPolicy: "chrome_sanitized" });
104
+ const report = validateHar(harText, { headerPolicy: "chrome_sanitized" });
105
+ ```
106
+
107
+ HAR input stays offline. Default replay uses each capture's startedDateTime;
108
+ `at` overrides it with safe integer Unix seconds. Missing/invalid capture clocks
109
+ require an explicit override. The default `unknown` header policy treats absent
110
+ Authorization/Cookie as unavailable. `chrome_sanitized` records their omission
111
+ as redaction; `complete` establishes absent headers and enables missing-field
112
+ findings. Observable methods, headers and bodies retain their checks.
113
+
114
+ Import and replay results preserve original URLs, headers and bodies and can
115
+ contain credentials. They are private capture data, not sanitized output.
116
+ See [the HAR request schema](https://github.com/aleksUIX/pixellint/blob/main/docs/HAR_REQUEST_SCHEMA.md)
117
+ for body encoding, byte limits, deduplication and provenance details.
package/index.cjs CHANGED
@@ -14,6 +14,18 @@ function validateMany(document) {
14
14
  return wasm.validate_many(JSON.stringify(document));
15
15
  }
16
16
 
17
+ /** Extract local HAR 1.2 requests. Returned captures can contain credentials. */
18
+ function importHar(har, options = {}) {
19
+ const raw = typeof har === "string" ? har : JSON.stringify(har);
20
+ return wasm.import_har(raw, options.headerPolicy ?? "unknown");
21
+ }
22
+
23
+ /** Replay local HAR requests at capture timestamps, or an explicit Unix clock. */
24
+ function validateHar(har, options = {}) {
25
+ const raw = typeof har === "string" ? har : JSON.stringify(har);
26
+ return wasm.validate_har(raw, options.headerPolicy ?? "unknown", options.at);
27
+ }
28
+
17
29
  function isOk(summary) {
18
30
  return summary.reports.every((report) =>
19
31
  report.violations.every((violation) => violation.severity !== "error"),
@@ -23,6 +35,8 @@ function isOk(summary) {
23
35
  module.exports = {
24
36
  validate,
25
37
  validateMany,
38
+ importHar,
39
+ validateHar,
26
40
  isOk,
27
41
  rulepacks: () => wasm.rulepacks(),
28
42
  vendors: () => wasm.vendors(),
package/index.d.ts CHANGED
@@ -17,6 +17,8 @@ export interface HttpRequest {
17
17
  method: string;
18
18
  headers: Record<string, string> | Array<{ name: string; value: string }>;
19
19
  body?: string;
20
+ /** Omitted capture fields remain unvalidated. Absent metadata retains complete-capture semantics. */
21
+ capture?: HttpCaptureContext;
20
22
  }
21
23
 
22
24
  export type Severity = "error" | "warning" | "info";
@@ -144,3 +146,69 @@ export function vendorForHost(host: string): VendorEntry | null;
144
146
 
145
147
  /** The pixellint-core version this build wraps. */
146
148
  export function version(): string;
149
+
150
+ export type HarBodyAvailability = "available" | "absent" | "unavailable" | "redacted";
151
+ export type HarHeaderPolicy = "unknown" | "complete" | "chrome_sanitized";
152
+
153
+ export interface HttpCaptureContext {
154
+ headers_unavailable?: boolean;
155
+ unavailable_headers?: string[];
156
+ redacted_headers?: string[];
157
+ body?: HarBodyAvailability;
158
+ }
159
+
160
+ export interface HarOptions {
161
+ /** unknown assumes omitted Authorization/Cookie may have been removed by the exporter. */
162
+ headerPolicy?: HarHeaderPolicy;
163
+ }
164
+
165
+ export interface HarValidateOptions extends HarOptions {
166
+ /** Safe integer Unix seconds. Overrides every HAR capture timestamp. */
167
+ at?: number;
168
+ }
169
+
170
+ export interface DocumentArtifactInput {
171
+ artifact_kind?: ArtifactKind;
172
+ artifact: string;
173
+ claimed_vendor?: string | null;
174
+ expansion_state?: ExpansionState;
175
+ occurrences?: ArtifactOccurrence[];
176
+ }
177
+
178
+ export interface DocumentRequest {
179
+ document_kind: string;
180
+ extractor?: { id: string; version?: string | null };
181
+ artifacts: DocumentArtifactInput[];
182
+ }
183
+
184
+ export interface HarEntryMetadata {
185
+ entry_index: number;
186
+ occurrence_id: string;
187
+ path: string;
188
+ started_date_time: string | null;
189
+ reference_time_unix_seconds: number | null;
190
+ page_ref: string | null;
191
+ body_size: number | null;
192
+ body_availability: HarBodyAvailability;
193
+ body_reason: string | null;
194
+ post_data: object | null;
195
+ capture: HttpCaptureContext;
196
+ }
197
+
198
+ export interface HarImport {
199
+ document: DocumentRequest;
200
+ header_policy: HarHeaderPolicy;
201
+ entries: HarEntryMetadata[];
202
+ }
203
+
204
+ export interface HarReport extends DocumentReport {
205
+ header_policy: HarHeaderPolicy;
206
+ reference_time_override: number | null;
207
+ captures: HarEntryMetadata[];
208
+ }
209
+
210
+ /** Import local HAR requests. This does not fetch URLs or sanitize the returned private captures. */
211
+ export function importHar(har: string | object, options?: HarOptions): HarImport;
212
+
213
+ /** Validate local HAR requests at their recorded clocks. Missing clocks require an explicit at override. */
214
+ export function validateHar(har: string | object, options?: HarValidateOptions): HarReport;
package/index.mjs CHANGED
@@ -30,6 +30,18 @@ export function validateMany(document) {
30
30
  return wasm.validate_many(JSON.stringify(document));
31
31
  }
32
32
 
33
+ /** Extract local HAR 1.2 requests. Returned captures can contain credentials. */
34
+ export function importHar(har, options = {}) {
35
+ const raw = typeof har === "string" ? har : JSON.stringify(har);
36
+ return wasm.import_har(raw, options.headerPolicy ?? "unknown");
37
+ }
38
+
39
+ /** Replay local HAR requests at capture timestamps, or an explicit Unix clock. */
40
+ export function validateHar(har, options = {}) {
41
+ const raw = typeof har === "string" ? har : JSON.stringify(har);
42
+ return wasm.validate_har(raw, options.headerPolicy ?? "unknown", options.at);
43
+ }
44
+
33
45
  /** Rulepacks this build ships, with their evidence levels. */
34
46
  export function rulepacks() {
35
47
  return wasm.rulepacks();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pixellint",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "description": "Validator for pixels, postbacks, conversion API payloads, and tracking URLs: Meta CAPI, Facebook pixel, GTM, and vendor rulepacks",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Aleks <aleks@vastlint.org>",
@@ -1,6 +1,11 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * Extracts local HAR 1.2 requests and records unavailable capture fields.
6
+ */
7
+ export function import_har(har_json: string, header_policy: string): any;
8
+
4
9
  /**
5
10
  * Every rulepack the engine ships, with its evidence level.
6
11
  */
@@ -12,6 +17,11 @@ export function rulepacks(): any;
12
17
  */
13
18
  export function validate(artifact_kind: string, artifact: string, expansion_state?: string | null, claimed_vendor?: string | null): any;
14
19
 
20
+ /**
21
+ * Validates offline at each capture timestamp, or one caller-supplied override.
22
+ */
23
+ export function validate_har(har_json: string, header_policy: string, reference_time?: number | null): any;
24
+
15
25
  /**
16
26
  * Validates extracted artifacts as one document. The caller already pulled
17
27
  * tracking URLs out. A JSON array of URL strings is a list of `url` artifacts.
package/wasm/pixellint.js CHANGED
@@ -1,5 +1,24 @@
1
1
  /* @ts-self-types="./pixellint.d.ts" */
2
2
 
3
+ /**
4
+ * Extracts local HAR 1.2 requests and records unavailable capture fields.
5
+ * @param {string} har_json
6
+ * @param {string} header_policy
7
+ * @returns {any}
8
+ */
9
+ function import_har(har_json, header_policy) {
10
+ const ptr0 = passStringToWasm0(har_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
11
+ const len0 = WASM_VECTOR_LEN;
12
+ const ptr1 = passStringToWasm0(header_policy, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
13
+ const len1 = WASM_VECTOR_LEN;
14
+ const ret = wasm.import_har(ptr0, len0, ptr1, len1);
15
+ if (ret[2]) {
16
+ throw takeFromExternrefTable0(ret[1]);
17
+ }
18
+ return takeFromExternrefTable0(ret[0]);
19
+ }
20
+ exports.import_har = import_har;
21
+
3
22
  /**
4
23
  * Every rulepack the engine ships, with its evidence level.
5
24
  * @returns {any}
@@ -39,6 +58,26 @@ function validate(artifact_kind, artifact, expansion_state, claimed_vendor) {
39
58
  }
40
59
  exports.validate = validate;
41
60
 
61
+ /**
62
+ * Validates offline at each capture timestamp, or one caller-supplied override.
63
+ * @param {string} har_json
64
+ * @param {string} header_policy
65
+ * @param {number | null} [reference_time]
66
+ * @returns {any}
67
+ */
68
+ function validate_har(har_json, header_policy, reference_time) {
69
+ const ptr0 = passStringToWasm0(har_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
70
+ const len0 = WASM_VECTOR_LEN;
71
+ const ptr1 = passStringToWasm0(header_policy, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
72
+ const len1 = WASM_VECTOR_LEN;
73
+ const ret = wasm.validate_har(ptr0, len0, ptr1, len1, !isLikeNone(reference_time), isLikeNone(reference_time) ? 0 : reference_time);
74
+ if (ret[2]) {
75
+ throw takeFromExternrefTable0(ret[1]);
76
+ }
77
+ return takeFromExternrefTable0(ret[0]);
78
+ }
79
+ exports.validate_har = validate_har;
80
+
42
81
  /**
43
82
  * Validates extracted artifacts as one document. The caller already pulled
44
83
  * tracking URLs out. A JSON array of URL strings is a list of `url` artifacts.
@@ -132,6 +171,10 @@ function __wbg_get_imports() {
132
171
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
133
172
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
134
173
  },
174
+ __wbg___wbindgen_is_string_ea5e6cc2e4141dfe: function(arg0) {
175
+ const ret = typeof(arg0) === 'string';
176
+ return ret;
177
+ },
135
178
  __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
136
179
  throw new Error(getStringFromWasm0(arg0, arg1));
137
180
  },
@@ -139,14 +182,22 @@ function __wbg_get_imports() {
139
182
  const ret = new Array();
140
183
  return ret;
141
184
  },
185
+ __wbg_new_7796ffc7ed656783: function() {
186
+ const ret = new Map();
187
+ return ret;
188
+ },
142
189
  __wbg_new_da52cf8fe3429cb2: function() {
143
190
  const ret = new Object();
144
191
  return ret;
145
192
  },
146
- __wbg_now_1e2da45fa673f925: function() {
193
+ __wbg_now_18ba40740da8f711: function() {
147
194
  const ret = Date.now();
148
195
  return ret;
149
196
  },
197
+ __wbg_set_575dd786d51585f8: function(arg0, arg1, arg2) {
198
+ const ret = arg0.set(arg1, arg2);
199
+ return ret;
200
+ },
150
201
  __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
151
202
  arg0[arg1] = arg2;
152
203
  },
@@ -158,12 +209,17 @@ function __wbg_get_imports() {
158
209
  const ret = arg0;
159
210
  return ret;
160
211
  },
161
- __wbindgen_cast_0000000000000002: function(arg0, arg1) {
212
+ __wbindgen_cast_0000000000000002: function(arg0) {
213
+ // Cast intrinsic for `I64 -> Externref`.
214
+ const ret = arg0;
215
+ return ret;
216
+ },
217
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
162
218
  // Cast intrinsic for `Ref(String) -> Externref`.
163
219
  const ret = getStringFromWasm0(arg0, arg1);
164
220
  return ret;
165
221
  },
166
- __wbindgen_cast_0000000000000003: function(arg0) {
222
+ __wbindgen_cast_0000000000000004: function(arg0) {
167
223
  // Cast intrinsic for `U64 -> Externref`.
168
224
  const ret = BigInt.asUintN(64, arg0);
169
225
  return ret;
Binary file
@@ -1,8 +1,10 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
+ export const import_har: (a: number, b: number, c: number, d: number) => [number, number, number];
4
5
  export const rulepacks: () => [number, number, number];
5
6
  export const validate: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
7
+ export const validate_har: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
6
8
  export const validate_many: (a: number, b: number) => [number, number, number];
7
9
  export const validate_url: (a: number, b: number) => [number, number, number];
8
10
  export const vendor_for_host: (a: number, b: number) => [number, number, number];