@theholocron/holocron-plugin-vercel 5.0.0-alpha.514 → 5.0.0-alpha.515

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.
Files changed (2) hide show
  1. package/dist/index.mjs +41 -14
  2. package/package.json +6 -6
package/dist/index.mjs CHANGED
@@ -3,16 +3,26 @@ import { errorMessage } from "@theholocron/misc-utils";
3
3
  import { createVercelClient } from "@theholocron/vercel-client";
4
4
  // src/probes/token/expectations.ts
5
5
  /**
6
- * Where the Vercel token is held: a laptop (`local`, `dev`) and CI. Vercel does not report a token's scope (a personal
7
- * access token's "Full Account" is a setting, not something the API answers), so no permissions are declared and the
8
- * probe says so instead of guessing. This is the plugin's `tokens` declaration, read through `tokenExpectations()`;
9
- * change it and the Vercel note in `docs/src/content/docs/tokens.mdx` together.
6
+ * Where the Vercel token is held: a laptop (`local`, `dev`) and CI. A Vercel token has no per-endpoint scope (a personal
7
+ * access token's "Full Account" or team scope is a setting, not something the API answers), so the only thing the probe
8
+ * can prove is what the token can reach. `webhooks` is the one permission declared: a laptop token makes the team's
9
+ * Comlink relay webhook (`setup notifications`, `POST /v1/webhooks`), and the probe proves it only as far as `GET
10
+ * /v1/webhooks` answers (a read proves the token sees the team's webhooks, not that it may make one). `ci` holds the
11
+ * token with no rule: nothing in CI makes a webhook, but Vercel cannot take the permission off a token, so it is not
12
+ * declared `absent` (the probe would have nothing to prove it with). This is the plugin's `tokens` declaration, read
13
+ * through `tokenExpectations()`; change it and the Vercel table in `docs/src/content/docs/tokens.mdx` together.
10
14
  */
11
- const EXPECTED = { layers: [
12
- "local",
13
- "dev",
14
- "ci"
15
- ] };
15
+ const EXPECTED = {
16
+ layers: [
17
+ "local",
18
+ "dev",
19
+ "ci"
20
+ ],
21
+ permissions: {
22
+ local: { webhooks: "required" },
23
+ dev: { webhooks: "required" }
24
+ }
25
+ };
16
26
  // src/auth.ts
17
27
  /** Resolves the Vercel token from `--token`, `HOLOCRON_VERCEL_TOKEN`, `VERCEL_TOKEN` or the keyring, and throws an `AuthError` when none is set. */
18
28
  const resolveToken = createResolveToken({
@@ -343,13 +353,14 @@ function parseLayer(args) {
343
353
  // src/probes/token/token.ts
344
354
  /**
345
355
  * The `token` probe for Vercel. It asks who the token belongs to (the plugin's `verifyToken`, `/v2/user`) and whether it can list projects, which
346
- * are reads and change nothing. Vercel does not report a token's scope, so the probe cannot judge permissions: it says
347
- * so, and with `--layer` (passed because `--environment` named a layer) it only says whether that layer is one that
348
- * should hold the token, from the plugin's `tokens` declaration. The token is never printed.
356
+ * are reads and change nothing, and the team's webhook list, the read next to making a relay webhook. Vercel does not
357
+ * report a token's scope, so the probe cannot judge permissions beyond that: it says so, and with `--layer` (passed
358
+ * because `--environment` named a layer) it says whether that layer is one that should hold the token and, for a layer
359
+ * that requires `webhooks`, fails when the list is refused. The token is never printed.
349
360
  */
350
361
  function tokenProbe(ctx) {
351
362
  return {
352
- summary: "Check a Vercel token with the current user and the project list, and for a layer that it is one that should hold the token. Vercel cannot report a token's scope, so permissions are not checked. Read-only.",
363
+ summary: "Check a Vercel token with the current user, the project list and the team's webhook list, and for a layer that it is one that should hold the token (a laptop layer must see the webhooks). Vercel cannot report a token's scope, so making a webhook is not tried. Read-only.",
353
364
  writes: false,
354
365
  acceptsToken: true,
355
366
  async run(probe) {
@@ -402,10 +413,26 @@ function tokenProbe(ctx) {
402
413
  detail: errorMessage(err)
403
414
  });
404
415
  }
416
+ const needsWebhooks = layer ? tokenExpectations(tokens, { layer }).some((entry) => entry.required.includes("webhooks")) : false;
417
+ try {
418
+ const hooks = await client.webhooks.list();
419
+ probe.say({
420
+ status: "ok",
421
+ label: "Webhooks: Read",
422
+ detail: `${hooks.length} webhooks`
423
+ });
424
+ } catch (err) {
425
+ const noAccess = err instanceof ProviderApiError && (err.status === 401 || err.status === 403);
426
+ probe.say({
427
+ status: noAccess && !needsWebhooks ? "info" : "fail",
428
+ label: "Webhooks: Read",
429
+ detail: noAccess ? `no access (${err.status})` : errorMessage(err)
430
+ });
431
+ }
405
432
  probe.say({
406
433
  status: "info",
407
434
  label: "permissions",
408
- detail: "Vercel cannot report a token's scope, so it is not checked"
435
+ detail: "Vercel cannot report a token's scope: reading the team's webhooks is proven, making one is not (it would write)"
409
436
  });
410
437
  }
411
438
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-vercel",
3
- "version": "5.0.0-alpha.514",
3
+ "version": "5.0.0-alpha.515",
4
4
  "description": "Holocron plugin for Vercel. Implements the deployment capability against the Vercel REST API.",
5
5
  "keywords": [
6
6
  "deployment",
@@ -40,19 +40,19 @@
40
40
  "tsx": "4.23.15",
41
41
  "typescript": "^5.9.3",
42
42
  "vitest": "^5.1.0",
43
- "@theholocron/eslint-config": "^8.9.0-alpha.21",
44
- "@theholocron/cli": "5.0.0-alpha.514",
45
43
  "@theholocron/http-client": "^1.58.0-alpha.49",
46
- "@theholocron/tsconfig": "^8.9.0-alpha.21",
44
+ "@theholocron/cli": "5.0.0-alpha.515",
45
+ "@theholocron/eslint-config": "^8.9.0-alpha.21",
47
46
  "@theholocron/misc-utils": "^1.17.0-alpha.5",
48
- "@theholocron/vercel-client": "^1.58.0-alpha.49",
49
47
  "@theholocron/tsdown-config": "^8.9.0-alpha.21",
48
+ "@theholocron/vercel-client": "^1.58.0-alpha.49",
49
+ "@theholocron/tsconfig": "^8.9.0-alpha.21",
50
50
  "@theholocron/vitest-config": "^8.9.0-alpha.21"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@theholocron/misc-utils": "^1.16.0",
54
54
  "@theholocron/vercel-client": "^1.43.1",
55
- "@theholocron/cli": "5.0.0-alpha.514"
55
+ "@theholocron/cli": "5.0.0-alpha.515"
56
56
  },
57
57
  "peerDependenciesMeta": {
58
58
  "@theholocron/vercel-client": {}