@valbuild/server 0.150.14 → 0.150.17

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.
@@ -5,6 +5,7 @@ import type { HistoryError } from "./history/HistoryError.js";
5
5
  import type { AffectedFile, StoredModuleVersion, CommitPage, CommitPatch, HistoricalCommit } from "./history/types.js";
6
6
  import { result } from "@valbuild/core/fp";
7
7
  import { Buffer } from "buffer";
8
+ import type { SketchpadStore } from "./sketchpads/SketchpadStore.js";
8
9
  export declare class ValOpsFS extends ValOps {
9
10
  private readonly contentUrl;
10
11
  private readonly rootDir;
@@ -19,6 +20,8 @@ export declare class ValOpsFS extends ValOps {
19
20
  */
20
21
  readonly requiresAuth = false;
21
22
  constructor(contentUrl: string, rootDir: string, valModules: ValModules, options?: ValOpsOptions);
23
+ /** In `.val/sketchpads`. See `sketchpads/fsSketchpadStore.ts`. */
24
+ readonly sketchpads: SketchpadStore;
22
25
  /**
23
26
  * Change detection for `.jsonValues()` entry files, which no sha can see (their
24
27
  * content lives behind a thunk that `JSON.stringify` drops).
@@ -7,6 +7,7 @@ import type { HistoryError } from "./history/HistoryError.js";
7
7
  import type { AffectedFile, StoredModuleVersion, CommitPage, CommitPatch, HistoricalCommit } from "./history/types.js";
8
8
  import { ParentRef, ValCommit, ValDeployment } from "@valbuild/shared/internal";
9
9
  import { result } from "@valbuild/core/fp";
10
+ import type { SketchpadStore } from "./sketchpads/SketchpadStore.js";
10
11
  declare const PatchId: z.ZodString & z.ZodType<PatchId, string, z.core.$ZodTypeInternals<PatchId, string>>;
11
12
  declare const CommitSha: z.ZodString & z.ZodType<CommitSha, string, z.core.$ZodTypeInternals<CommitSha, string>>;
12
13
  declare const BaseSha: z.ZodString & z.ZodType<BaseSha, string, z.core.$ZodTypeInternals<BaseSha, string>>;
@@ -44,6 +45,8 @@ export declare class ValOpsHttp extends ValOps {
44
45
  /** Val's content service owns the store. See {@link ValOps.patchesAreLocal}. */
45
46
  readonly patchesAreLocal = false;
46
47
  readonly kind = "http";
48
+ /** The content service's. See `sketchpads/httpSketchpadStore.ts`. */
49
+ readonly sketchpads: SketchpadStore;
47
50
  /** See {@link ValOps.requiresAuth}. */
48
51
  readonly requiresAuth = true;
49
52
  /**
@@ -4,6 +4,7 @@ import { ValOps, type AuthorId, type BaseSha, type GenericErrorMessage, type Met
4
4
  import type { HistoryError } from "./history/HistoryError.js";
5
5
  import type { AffectedFile, CommitPage, CommitPatch, HistoricalCommit, StoredModuleVersion } from "./history/types.js";
6
6
  import { result } from "@valbuild/core/fp";
7
+ import { type SketchpadStore } from "./sketchpads/SketchpadStore.js";
7
8
  /**
8
9
  * One stored patch. Everything the ordered chain needs and nothing else.
9
10
  */
@@ -177,6 +178,8 @@ export declare class ValOpsMemory extends ValOps {
177
178
  */
178
179
  readonly patchesAreLocal = true;
179
180
  readonly kind = "memory";
181
+ /** For as long as the tab is open, like everything else in the demo. */
182
+ readonly sketchpads: SketchpadStore;
180
183
  /**
181
184
  * Required, unless the host explicitly takes the boundary itself.
182
185
  *
@@ -197,6 +197,18 @@ type ValServerOverrides = Partial<{
197
197
  * @example "https://content.val.build"
198
198
  */
199
199
  valContentUrl: string;
200
+ /**
201
+ * Where content analytics beacons are forwarded to be counted, on a
202
+ * self-hosted site in proxy mode. A site Val hosts never uses it: the
203
+ * platform answers `/api/val/analytics` itself.
204
+ *
205
+ * Typically this should not be set.
206
+ *
207
+ * Can also be overridden using the VAL_ANALYTICS_INGEST_URL env var.
208
+ *
209
+ * @example "https://platform.valstart.dev/__ingest/analytics"
210
+ */
211
+ valAnalyticsIngestUrl: string;
200
212
  /**
201
213
  * The full project name of the Val project.
202
214
  *
@@ -12,6 +12,13 @@ export type ValServerOptions = {
12
12
  formatter?: (code: string, filePath: string) => string | Promise<string>;
13
13
  valBuildUrl?: string;
14
14
  valContentUrl: string;
15
+ /**
16
+ * Where a self-hosted site's content analytics beacons are forwarded, in
17
+ * `http` mode. `initHandlerOptions` resolves it (the `valAnalyticsIngestUrl`
18
+ * option, then `VAL_ANALYTICS_INGEST_URL`); absent is
19
+ * {@link DEFAULT_ANALYTICS_INGEST_URL}.
20
+ */
21
+ valAnalyticsIngestUrl?: string;
15
22
  valSecret?: string;
16
23
  apiKey?: string;
17
24
  project?: string;
@@ -0,0 +1,76 @@
1
+ import type { SketchpadSummaryT, SketchpadT } from "@valbuild/shared/internal";
2
+ /**
3
+ * Where a project's sketchpads are kept, in each of the server's modes:
4
+ * `.val/sketchpads` in `fs` mode, the content service in `http` mode, the
5
+ * tab's memory in the demo. See `Sketchpad` in `ApiRoutes.ts` for what one
6
+ * is.
7
+ *
8
+ * The store keeps what it is given. Whether a text is a sketch at all is
9
+ * decided before it gets here (`checkSketch`, in `ValServer`), once for every
10
+ * mode, so no store has its own idea of the format.
11
+ */
12
+ export interface SketchpadStore {
13
+ list(filter: SketchpadFilter): Promise<SketchpadSummaryT[]>;
14
+ get(id: string): Promise<SketchpadT | null>;
15
+ create(input: SketchpadInput): Promise<SketchpadT>;
16
+ /**
17
+ * Applies `change` if the sketchpad is still at `change.baseVersion`, in
18
+ * one step: a store that checked and then wrote would let two writers in
19
+ * between.
20
+ */
21
+ update(id: string, change: SketchpadChange): Promise<SketchpadUpdate>;
22
+ }
23
+ export type SketchpadFilter = {
24
+ archived: "exclude" | "include" | "only";
25
+ page?: string;
26
+ };
27
+ export type SketchpadInput = {
28
+ text: string;
29
+ title: string | null;
30
+ page: string | null;
31
+ /** Profile id of whoever made it, when somebody is signed in. */
32
+ by: string | null;
33
+ };
34
+ export type SketchpadChange = {
35
+ baseVersion: number;
36
+ text?: string;
37
+ title?: string | null;
38
+ page?: string | null;
39
+ archived?: boolean;
40
+ by: string | null;
41
+ };
42
+ export type SketchpadUpdate = {
43
+ status: "updated";
44
+ sketchpad: SketchpadT;
45
+ } | {
46
+ status: "not-found";
47
+ }
48
+ /** Changed since `baseVersion`; `sketchpad` is how it is now. */
49
+ | {
50
+ status: "conflict";
51
+ sketchpad: SketchpadT;
52
+ };
53
+ /**
54
+ * Whether `id` is in the shape a sketchpad's id has. Every store checks it
55
+ * before the id goes anywhere it could mean something else: a file name in
56
+ * fs mode, a URL path in http mode, where `..` is not an id but a way out.
57
+ */
58
+ export declare function isSketchpadId(id: string): boolean;
59
+ /**
60
+ * A random id in the shape of a UUID. `getRandomValues` rather than
61
+ * `randomUUID`, which a browser only has in a secure context -- and the demo
62
+ * runs this server in the visitor's tab.
63
+ */
64
+ export declare function newSketchpadId(): string;
65
+ export declare function summaryOf(sketchpad: SketchpadT): SketchpadSummaryT;
66
+ export declare function matchesFilter(sketchpad: SketchpadSummaryT, filter: SketchpadFilter): boolean;
67
+ /** Newest change first, as every list of them is read. */
68
+ export declare function byUpdatedAt(a: SketchpadSummaryT, b: SketchpadSummaryT): number;
69
+ export declare function newSketchpad(input: SketchpadInput, now: Date): SketchpadT;
70
+ /** `current` with `change` applied, or why not. Pure: storing is the caller's. */
71
+ export declare function applySketchpadChange(current: SketchpadT | null, change: SketchpadChange, now: Date): SketchpadUpdate;
72
+ /**
73
+ * Sketchpads kept in memory, for as long as the server runs: the demo's
74
+ * store, where a reload starts over anyway, and the tests'.
75
+ */
76
+ export declare function createMemorySketchpadStore(now?: () => Date): SketchpadStore;
@@ -69,14 +69,15 @@ export declare function createValOps(valModules: ValModules, options: ValServerC
69
69
  * only `valBuildUrl` hands back the app token that becomes the session cookie,
70
70
  * so a single shared sentence would overstate one and understate the other.
71
71
  */
72
- type CredentialBearingUrl = "valBuildUrl" | "valContentUrl";
72
+ type CredentialBearingUrl = "valBuildUrl" | "valContentUrl" | "valAnalyticsIngestUrl";
73
73
  /**
74
74
  * Returns a warning if `url` would send credentials somewhere they can be read
75
75
  * off the wire, or null if it is fine.
76
76
  *
77
- * Both URLs default to https, but each is overridable - `opts.valBuildUrl` /
78
- * `VAL_BUILD_URL`, `opts.valContentUrl` / `VAL_CONTENT_URL` - and neither
79
- * override has ever been scheme-checked. Point one at a plain http host and the
77
+ * Each URL defaults to https, but each is overridable - `opts.valBuildUrl` /
78
+ * `VAL_BUILD_URL`, `opts.valContentUrl` / `VAL_CONTENT_URL`,
79
+ * `opts.valAnalyticsIngestUrl` / `VAL_ANALYTICS_INGEST_URL` - and no override
80
+ * was scheme-checked before this. Point one at a plain http host and the
80
81
  * api key goes out in clear text, and whatever comes back is whatever the
81
82
  * network says: for `valBuildUrl` that includes the app token this server
82
83
  * re-signs into the session cookie.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var ts = require('typescript');
4
- var ValRouterCore = require('./ValRouterCore-83973a50.cjs.prod.js');
4
+ var ValRouterCore = require('./ValRouterCore-6cae8ef3.cjs.prod.js');
5
5
  var fp = require('@valbuild/core/fp');
6
6
  var jsonValuesModule = require('./jsonValuesModule-d1bb8d8f.cjs.prod.js');
7
7
  require('@valbuild/core');
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var ts = require('typescript');
4
- var ValRouterCore = require('./ValRouterCore-c4b07665.cjs.dev.js');
4
+ var ValRouterCore = require('./ValRouterCore-71b88a4c.cjs.dev.js');
5
5
  var fp = require('@valbuild/core/fp');
6
6
  var jsonValuesModule = require('./jsonValuesModule-8ae503a8.cjs.dev.js');
7
7
  require('@valbuild/core');
@@ -1,5 +1,5 @@
1
1
  import ts from 'typescript';
2
- import { F as bytesToUtf8, G as posixPath } from './ValRouterCore-26bf9ed9.esm.js';
2
+ import { N as bytesToUtf8, O as posixPath } from './ValRouterCore-8ec75007.esm.js';
3
3
  import { result } from '@valbuild/core/fp';
4
4
  import { a as analyzeValModule, c as analyzeJsonValuesEntries } from './jsonValuesModule-427d68c8.esm.js';
5
5
  import '@valbuild/core';
@@ -12,7 +12,7 @@ var path = require('path');
12
12
  var fs = require('fs');
13
13
  var vm = require('node:vm');
14
14
  var node_module = require('node:module');
15
- var ValRouterCore = require('./ValRouterCore-c4b07665.cjs.dev.js');
15
+ var ValRouterCore = require('./ValRouterCore-71b88a4c.cjs.dev.js');
16
16
  var server = require('@valbuild/ui/server');
17
17
  var z = require('zod');
18
18
  var zodValidationError = require('zod-validation-error');
@@ -2469,6 +2469,88 @@ async function withPatchLock(lockFilePath, options, fn) {
2469
2469
  }
2470
2470
  }
2471
2471
 
2472
+ /**
2473
+ * Sketchpads in `fs` mode: one JSON file each, in `.val/sketchpads/` beside
2474
+ * the patch store (and nothing to do with it -- a sketchpad is not an edit
2475
+ * and is never published).
2476
+ *
2477
+ * A file is replaced by writing a temporary one and renaming it over, so a
2478
+ * reader never sees half of one. Changes to one sketchpad are queued in this
2479
+ * process, so its version check and its write are one step. Two dev servers
2480
+ * writing the same sketchpad at the same instant could still race; that is
2481
+ * a cost local development can carry, and the content service, which hosts
2482
+ * every real project's, does the check in one database statement.
2483
+ */
2484
+ function createFsSketchpadStore(rootDir, now = () => new Date()) {
2485
+ const dir = path__default["default"].join(rootDir, ".val", "sketchpads");
2486
+ const fileOf = id => path__default["default"].join(dir, `${id}.json`);
2487
+ const queues = new Map();
2488
+ const read = async id => {
2489
+ if (!ValRouterCore.isSketchpadId(id)) {
2490
+ return null;
2491
+ }
2492
+ let raw;
2493
+ try {
2494
+ raw = await fs__default["default"].promises.readFile(fileOf(id), "utf8");
2495
+ } catch {
2496
+ return null;
2497
+ }
2498
+ try {
2499
+ const parsed = internal.Sketchpad.safeParse(JSON.parse(raw));
2500
+ if (parsed.success) {
2501
+ return parsed.data;
2502
+ }
2503
+ } catch {
2504
+ // Reported below, as for a file that parsed and was not a sketchpad.
2505
+ }
2506
+ core.Internal.log.warn(`${fileOf(id)} is not a sketchpad, so it is left out. Move it away to stop this message.`);
2507
+ return null;
2508
+ };
2509
+ const write = async sketchpad => {
2510
+ await fs__default["default"].promises.mkdir(dir, {
2511
+ recursive: true
2512
+ });
2513
+ const temporary = `${fileOf(sketchpad.id)}.${process.pid}.tmp`;
2514
+ await fs__default["default"].promises.writeFile(temporary, JSON.stringify(sketchpad, null, 2));
2515
+ await fs__default["default"].promises.rename(temporary, fileOf(sketchpad.id));
2516
+ };
2517
+
2518
+ /** Runs `task` after every earlier change to `id` has finished. */
2519
+ const queued = (id, task) => {
2520
+ const previous = queues.get(id) ?? Promise.resolve();
2521
+ const next = previous.then(task, task);
2522
+ queues.set(id, next.catch(() => undefined));
2523
+ return next;
2524
+ };
2525
+ return {
2526
+ async list(filter) {
2527
+ let names;
2528
+ try {
2529
+ names = await fs__default["default"].promises.readdir(dir);
2530
+ } catch {
2531
+ return [];
2532
+ }
2533
+ const all = await Promise.all(names.filter(name => name.endsWith(".json")).map(name => read(name.slice(0, -".json".length))));
2534
+ return all.filter(sketchpad => sketchpad !== null).map(ValRouterCore.summaryOf).filter(sketchpad => ValRouterCore.matchesFilter(sketchpad, filter)).sort(ValRouterCore.byUpdatedAt);
2535
+ },
2536
+ get: read,
2537
+ async create(input) {
2538
+ const sketchpad = ValRouterCore.newSketchpad(input, now());
2539
+ await write(sketchpad);
2540
+ return sketchpad;
2541
+ },
2542
+ update(id, change) {
2543
+ return queued(id, async () => {
2544
+ const result = ValRouterCore.applySketchpadChange(await read(id), change, now());
2545
+ if (result.status === "updated") {
2546
+ await write(result.sketchpad);
2547
+ }
2548
+ return result;
2549
+ });
2550
+ }
2551
+ };
2552
+ }
2553
+
2472
2554
  /** Serializes a schema, or gives up quietly — serialization errors are reported elsewhere. */
2473
2555
  function serializeSchemaSafely(schema) {
2474
2556
  try {
@@ -2494,8 +2576,12 @@ class ValOpsFS extends ValRouterCore.ValOps {
2494
2576
  this.rootDir = rootDir;
2495
2577
  this.host = new FSOpsHost();
2496
2578
  this.jsonEntryFilesFingerprint = new JsonEntryFilesFingerprint(rootDir);
2579
+ this.sketchpads = createFsSketchpadStore(rootDir);
2497
2580
  }
2498
2581
 
2582
+ /** In `.val/sketchpads`. See `sketchpads/fsSketchpadStore.ts`. */
2583
+ sketchpads;
2584
+
2499
2585
  /**
2500
2586
  * Change detection for `.jsonValues()` entry files, which no sha can see (their
2501
2587
  * content lives behind a thunk that `JSON.stringify` drops).
@@ -5117,6 +5203,124 @@ function movesAtMerge(inputs, schemas) {
5117
5203
  };
5118
5204
  }
5119
5205
 
5206
+ /**
5207
+ * Sketchpads in `http` mode: the content service keeps them, per project, at
5208
+ * `/v1/{project}/sketchpads` (valbuild/home). This only carries requests
5209
+ * there and reads the answers; the version check is the service's, done in
5210
+ * one statement.
5211
+ */
5212
+ function createHttpSketchpadStore(options) {
5213
+ const request = async (path, init) => fetch(`${options.url}${path}`, {
5214
+ method: init.method,
5215
+ headers: {
5216
+ ...options.headers,
5217
+ // WHO, as for a proposal or a commit: the key names the project.
5218
+ ...(init.by ? {
5219
+ "x-val-profile-id": init.by
5220
+ } : {}),
5221
+ ...(init.body !== undefined ? {
5222
+ "Content-Type": "application/json"
5223
+ } : {})
5224
+ },
5225
+ ...(init.body !== undefined ? {
5226
+ body: JSON.stringify(init.body)
5227
+ } : {})
5228
+ });
5229
+ const failed = async (res, doing) => new Error(`Val Build could not ${doing} (HTTP ${res.status}): ${await res.text().catch(() => "")}`);
5230
+ return {
5231
+ async list(filter) {
5232
+ const query = new URLSearchParams({
5233
+ archived: filter.archived
5234
+ });
5235
+ if (filter.page !== undefined) {
5236
+ query.set("page", filter.page);
5237
+ }
5238
+ const res = await request(`?${query}`, {
5239
+ method: "GET"
5240
+ });
5241
+ if (!res.ok) {
5242
+ throw await failed(res, "list the sketchpads");
5243
+ }
5244
+ return z.z.object({
5245
+ sketchpads: z.z.array(internal.SketchpadSummary)
5246
+ }).parse(await res.json()).sketchpads;
5247
+ },
5248
+ async get(id) {
5249
+ if (!ValRouterCore.isSketchpadId(id)) {
5250
+ return null;
5251
+ }
5252
+ const res = await request(`/${encodeURIComponent(id)}`, {
5253
+ method: "GET"
5254
+ });
5255
+ if (res.status === 404) {
5256
+ return null;
5257
+ }
5258
+ if (!res.ok) {
5259
+ throw await failed(res, "read the sketchpad");
5260
+ }
5261
+ return z.z.object({
5262
+ sketchpad: internal.Sketchpad
5263
+ }).parse(await res.json()).sketchpad;
5264
+ },
5265
+ async create(input) {
5266
+ const res = await request("", {
5267
+ method: "POST",
5268
+ body: {
5269
+ text: input.text,
5270
+ title: input.title,
5271
+ page: input.page
5272
+ },
5273
+ by: input.by
5274
+ });
5275
+ if (!res.ok) {
5276
+ throw await failed(res, "make the sketchpad");
5277
+ }
5278
+ return z.z.object({
5279
+ sketchpad: internal.Sketchpad
5280
+ }).parse(await res.json()).sketchpad;
5281
+ },
5282
+ async update(id, change) {
5283
+ if (!ValRouterCore.isSketchpadId(id)) {
5284
+ return {
5285
+ status: "not-found"
5286
+ };
5287
+ }
5288
+ const {
5289
+ by,
5290
+ ...body
5291
+ } = change;
5292
+ const res = await request(`/${encodeURIComponent(id)}`, {
5293
+ method: "PATCH",
5294
+ body,
5295
+ by
5296
+ });
5297
+ if (res.status === 404) {
5298
+ return {
5299
+ status: "not-found"
5300
+ };
5301
+ }
5302
+ if (res.status === 409) {
5303
+ const current = z.z.object({
5304
+ sketchpad: internal.Sketchpad
5305
+ }).parse(await res.json()).sketchpad;
5306
+ return {
5307
+ status: "conflict",
5308
+ sketchpad: current
5309
+ };
5310
+ }
5311
+ if (!res.ok) {
5312
+ throw await failed(res, "save the sketchpad");
5313
+ }
5314
+ return {
5315
+ status: "updated",
5316
+ sketchpad: z.z.object({
5317
+ sketchpad: internal.Sketchpad
5318
+ }).parse(await res.json()).sketchpad
5319
+ };
5320
+ }
5321
+ };
5322
+ }
5323
+
5120
5324
  const textEncoder$2 = new TextEncoder();
5121
5325
 
5122
5326
  /** The body of the content API's 403 for a write the project's plan refuses. */
@@ -5418,6 +5622,8 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5418
5622
  /** Val's content service owns the store. See {@link ValOps.patchesAreLocal}. */
5419
5623
  patchesAreLocal = false;
5420
5624
  kind = "http";
5625
+ /** The content service's. See `sketchpads/httpSketchpadStore.ts`. */
5626
+ sketchpads;
5421
5627
  /** See {@link ValOps.requiresAuth}. */
5422
5628
  requiresAuth = true;
5423
5629
  /**
@@ -5545,6 +5751,10 @@ class ValOpsHttp extends ValRouterCore.ValOps {
5545
5751
  Authorization: `Bearer ${auth.apiKey}`
5546
5752
  };
5547
5753
  this.root = (options === null || options === void 0 ? void 0 : options.root) ?? "";
5754
+ this.sketchpads = createHttpSketchpadStore({
5755
+ url: `${contentUrl}/v1/${project}/sketchpads`,
5756
+ headers: this.authHeaders
5757
+ });
5548
5758
  this.proposal = (options === null || options === void 0 ? void 0 : options.proposal) ?? null;
5549
5759
  this.contentVersion = this.proposal === null ? (options === null || options === void 0 ? void 0 : options.contentVersion) ?? null : null;
5550
5760
  /*
@@ -8405,6 +8615,16 @@ async function initHandlerOptions(route, opts, config) {
8405
8615
  });
8406
8616
  if (isProxyMode) {
8407
8617
  var _config$files, _opts$versions, _opts$versions2;
8618
+ /*
8619
+ * Where a self-hosted site's analytics beacons are counted. Only http mode
8620
+ * forwards them -- it is the mode with the project's api key -- so only
8621
+ * it resolves this, and only here is it checked for a plain-http host:
8622
+ * the api key goes with every beacon.
8623
+ */
8624
+ const valAnalyticsIngestUrl = opts.valAnalyticsIngestUrl || process.env.VAL_ANALYTICS_INGEST_URL || ValRouterCore.DEFAULT_ANALYTICS_INGEST_URL;
8625
+ warnIfInsecureUrls({
8626
+ valAnalyticsIngestUrl
8627
+ });
8408
8628
  /*
8409
8629
  * Why this app is in http mode, in the message that says what is missing.
8410
8630
  *
@@ -8525,6 +8745,7 @@ async function initHandlerOptions(route, opts, config) {
8525
8745
  valDisableRedirectUrl,
8526
8746
  valContentUrl,
8527
8747
  valBuildUrl,
8748
+ valAnalyticsIngestUrl,
8528
8749
  config
8529
8750
  };
8530
8751
  } else {
@@ -8639,10 +8860,11 @@ function createValOps(valModules, options) {
8639
8860
  * so a single shared sentence would overstate one and understate the other.
8640
8861
  */
8641
8862
 
8642
- const CREDENTIAL_BEARING_URLS = ["valBuildUrl", "valContentUrl"];
8863
+ const CREDENTIAL_BEARING_URLS = ["valBuildUrl", "valContentUrl", "valAnalyticsIngestUrl"];
8643
8864
  const WHAT_IS_AT_RISK = {
8644
8865
  valBuildUrl: "Val's api key is sent to this host, and the token it returns is what this server signs into the session cookie, " + "so both can be read - and the token replaced - by anyone on the network path.",
8645
- valContentUrl: "Val's api key, or the caller's personal access token, is sent to this host, " + "so it can be read by anyone on the network path."
8866
+ valContentUrl: "Val's api key, or the caller's personal access token, is sent to this host, " + "so it can be read by anyone on the network path.",
8867
+ valAnalyticsIngestUrl: "Val's api key is sent to this host with every analytics beacon, " + "so it can be read by anyone on the network path."
8646
8868
  };
8647
8869
 
8648
8870
  // NOTE: `URL.hostname` keeps the brackets on an IPv6 literal, so this is
@@ -8670,9 +8892,10 @@ function forLog(parsed) {
8670
8892
  * Returns a warning if `url` would send credentials somewhere they can be read
8671
8893
  * off the wire, or null if it is fine.
8672
8894
  *
8673
- * Both URLs default to https, but each is overridable - `opts.valBuildUrl` /
8674
- * `VAL_BUILD_URL`, `opts.valContentUrl` / `VAL_CONTENT_URL` - and neither
8675
- * override has ever been scheme-checked. Point one at a plain http host and the
8895
+ * Each URL defaults to https, but each is overridable - `opts.valBuildUrl` /
8896
+ * `VAL_BUILD_URL`, `opts.valContentUrl` / `VAL_CONTENT_URL`,
8897
+ * `opts.valAnalyticsIngestUrl` / `VAL_ANALYTICS_INGEST_URL` - and no override
8898
+ * was scheme-checked before this. Point one at a plain http host and the
8676
8899
  * api key goes out in clear text, and whatever comes back is whatever the
8677
8900
  * network says: for `valBuildUrl` that includes the app token this server
8678
8901
  * re-signs into the session cookie.
@@ -8704,7 +8927,11 @@ function insecureUrlWarning(name, url) {
8704
8927
  }
8705
8928
  function warnIfInsecureUrls(urls) {
8706
8929
  for (const name of CREDENTIAL_BEARING_URLS) {
8707
- const warning = insecureUrlWarning(name, urls[name]);
8930
+ const url = urls[name];
8931
+ if (url === undefined) {
8932
+ continue;
8933
+ }
8934
+ const warning = insecureUrlWarning(name, url);
8708
8935
  if (warning) {
8709
8936
  core.Internal.log.warn(warning);
8710
8937
  }