@vzn/vx-reapi 0.0.630 → 0.0.632

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
@@ -45,9 +45,10 @@ adds gRPC metadata to every call: a hosted server's API key goes there
45
45
  `RequestMetadata.tool_details`, and `correlatedInvocationsId` groups several
46
46
  runs as one build in a server's UI.
47
47
 
48
- TLS is on for a `grpcs://` or `https://` endpoint, or with any PEM below;
49
- a bare `host:port` is plaintext, unless `tls: true` turns it on (`tls: false`
50
- turns it off). It uses the system roots unless told otherwise. A server behind a private
48
+ TLS is on unless asked off, as in Bazel: a bare `host:port`, a `grpcs://`
49
+ or `https://` endpoint, and a `dns:`/`ipv4:`/`ipv6:` target all use it.
50
+ Plaintext takes a `grpc://` or `http://` endpoint or `tls: false`; a `unix:`
51
+ or `unix-abstract:` socket is plaintext (`tls: true` turns it on). It uses the system roots unless told otherwise. A server behind a private
51
52
  CA takes `tlsCertificate` (or `VX_REAPI_TLS_CERTIFICATE`), a PEM file of
52
53
  that CA; one that asks for mutual TLS takes `tlsClientCertificate` and
53
54
  `tlsClientKey` (`VX_REAPI_TLS_CLIENT_CERTIFICATE` / `VX_REAPI_TLS_CLIENT_KEY`)
@@ -335,7 +336,7 @@ server:
335
336
  docker run -d -p 19092:9092 buchgr/bazel-remote-cache:latest \
336
337
  --dir /data --max_size 1 --grpc_address 0.0.0.0:9092 --http_address 0.0.0.0:8080
337
338
 
338
- VX_REAPI_TEST_ENDPOINT=127.0.0.1:19092 bun test
339
+ VX_REAPI_TEST_ENDPOINT=grpc://127.0.0.1:19092 bun test
339
340
  ```
340
341
 
341
342
  Without an endpoint those tests skip; CI sets `VX_REQUIRE_REAPI=1`, which turns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vzn/vx-reapi",
3
- "version": "0.0.630",
3
+ "version": "0.0.632",
4
4
  "license": "MIT",
5
5
  "description": "Bazel Remote Execution API plugin for vx — remote cache (ActionCache + CAS) against NativeLink, BuildBuddy, Buildbarn or bazel-remote.",
6
6
  "keywords": [
@@ -39,7 +39,7 @@
39
39
  "access": "public"
40
40
  },
41
41
  "peerDependencies": {
42
- "@vzn/vx": "^0.0.630"
42
+ "@vzn/vx": "^0.0.632"
43
43
  },
44
44
  "repository": {
45
45
  "type": "git",
package/src/index.ts CHANGED
@@ -51,7 +51,9 @@ export interface ReapiPluginOptions extends Partial<
51
51
  /**
52
52
  * Endpoint, or omit to read `VX_REAPI_ENDPOINT`. With neither the plugin
53
53
  * DECLINES — a declared-but-unconfigured plugin costs nothing and must
54
- * never fail a run.
54
+ * never fail a run. TLS unless it starts `grpc://`, `http://`, `unix:` or
55
+ * `unix-abstract:`, or `tls: false` is set, as Bazel reads a schemeless
56
+ * `--remote_cache`.
55
57
  */
56
58
  endpoint?: string
57
59
  /**
@@ -173,7 +175,7 @@ function assertEndpoint(endpoint: string, from: string): void {
173
175
  const port = m?.[2] === undefined ? undefined : Number(m[2])
174
176
  if (m === null || (port !== undefined && (port < 1 || port > 65_535))) {
175
177
  throw new UserError(
176
- `vx/reapi: ${from} is ${JSON.stringify(endpoint)}, which is not host[:port] (e.g. cache.example.com:443 or grpcs://cache.example.com)`,
178
+ `vx/reapi: ${from} is ${JSON.stringify(endpoint)}, which is not host[:port] (e.g. grpcs://cache.example.com:443)`,
177
179
  )
178
180
  }
179
181
  }
package/src/wire.ts CHANGED
@@ -329,13 +329,13 @@ function abortableSleep(ms: number, signal: AbortSignal | undefined): Promise<vo
329
329
  const NOT_FOUND = grpc.status.NOT_FOUND
330
330
 
331
331
  export interface ReapiOptions {
332
- /** `host:port` of the REAPI server. */
332
+ /** `host:port` of the REAPI server; TLS unless `grpc://`, `http://` or a socket. */
333
333
  endpoint: string
334
334
  /** Multi-tenant servers scope by instance; most single-tenant ones use ''. */
335
335
  instanceName?: string
336
336
  /** Sent on every call (auth, routing). */
337
337
  headers?: Record<string, string>
338
- /** TLS. Default: on with any PEM below or an `https://`/`grpcs://` endpoint, else insecure. */
338
+ /** TLS. Default: on, unless the endpoint is `grpc://`, `http://`, `unix:` or `unix-abstract:` and no PEM below is set. */
339
339
  tls?: boolean
340
340
  /** PEM of the CA that signed the server's certificate, in place of the system roots. */
341
341
  tlsCaPem?: string
@@ -453,11 +453,13 @@ export class ReapiClient {
453
453
  assertBunSupportsChunking()
454
454
  const pem = (text: string | undefined): Buffer | null =>
455
455
  text === undefined ? null : Buffer.from(text)
456
+ // TLS unless the endpoint says plaintext, as Bazel reads a schemeless
457
+ // `--remote_cache`; a unix socket stays plaintext.
456
458
  const tls =
457
459
  opts.tls ??
458
460
  (opts.tlsCaPem !== undefined ||
459
461
  opts.tlsClientCertPem !== undefined ||
460
- /^(https|grpcs):\/\//.test(opts.endpoint))
462
+ !/^((http|grpc):\/\/|unix:|unix-abstract:)/.test(opts.endpoint))
461
463
  const target = opts.endpoint.replace(/^(https?|grpcs?):\/\//, '')
462
464
  this.svc = loadServices(
463
465
  target,