@theholocron/holocron-plugin-vercel 2.0.0-alpha.1 → 2.0.0-alpha.11

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/index.d.mts CHANGED
@@ -4,10 +4,13 @@ import { Deployment, DeploymentProject, DeploymentProjectSettings, DeploymentRec
4
4
  /**
5
5
  * Token resolution for the Vercel plugin.
6
6
  *
7
- * Resolution order:
7
+ * Resolution order (matches the standard 4-step precedence set by
8
+ * `.notes/tech-auth-bootstrap.spec.md`):
8
9
  * 1. explicit `cliToken` argument (from `--token` flag)
9
10
  * 2. HOLOCRON_VERCEL_TOKEN env var (preferred — explicit intent)
10
11
  * 3. VERCEL_TOKEN env var (the default the Vercel CLI also reads)
12
+ * 4. keyring (com.theholocron.cli / "vercel")
13
+ * 5. AuthError naming all four options + the bootstrap hint
11
14
  *
12
15
  * No `vercel auth` fallback — Vercel CLI auth is per-account-scoped
13
16
  * and the resulting tokens don't always cover team operations.
@@ -20,6 +23,8 @@ interface ResolveTokenInput {
20
23
  cliToken?: string;
21
24
  /** Env vars; passed in for testability. Defaults to `process.env`. */
22
25
  env?: NodeJS.ProcessEnv;
26
+ /** Keyring lookup fn; passed in for testability. Defaults to `getToken(provider)`. */
27
+ keyring?: (provider: string) => string | null;
23
28
  }
24
29
  declare function resolveToken(input?: ResolveTokenInput): string;
25
30
  //#endregion
@@ -88,6 +93,27 @@ declare class VercelDeployment implements Deployment {
88
93
  private getProjectByName;
89
94
  }
90
95
  //#endregion
96
+ //#region src/verify-token.d.ts
97
+ /**
98
+ * `verifyToken` — plugin-level export used by `holocron auth set` +
99
+ * `holocron auth check`. Hits `GET /v2/user` and translates the
100
+ * response into the normalized `VerifyTokenResult` shape.
101
+ */
102
+ interface VerifyTokenSuccess {
103
+ ok: true;
104
+ subject: string;
105
+ }
106
+ interface VerifyTokenFailure {
107
+ ok: false;
108
+ message: string;
109
+ }
110
+ type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
111
+ interface VerifyTokenOptions {
112
+ baseUrl?: string;
113
+ fetch?: typeof fetch;
114
+ }
115
+ declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
116
+ //#endregion
91
117
  //#region src/index.d.ts
92
118
  interface VercelPluginOptions extends ResolveTokenInput {
93
119
  /** Vercel team id. Set when working with a team-owned project. */
@@ -111,5 +137,12 @@ declare function createPlugin(options?: VercelPluginOptions): {
111
137
  deployment: () => Deployment;
112
138
  };
113
139
  };
140
+ /**
141
+ * One-line hint printed by `holocron auth set vercel` when no token
142
+ * is supplied or the supplied token is rejected. Points operators at
143
+ * https://vercel.com/account/tokens where PATs are minted with
144
+ * "Full Account" scope for team-level ops.
145
+ */
146
+ declare const AUTH_HINT: string;
114
147
  //#endregion
115
- export { AuthError, PluginContext, ResolveTokenInput, VercelDeployment, VercelPluginOptions, VercelRestClient, createContext, createPlugin, deployment, resolveToken };
148
+ export { AUTH_HINT, AuthError, PluginContext, ResolveTokenInput, VercelDeployment, VercelPluginOptions, VercelRestClient, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createPlugin, deployment, resolveToken, verifyToken };
package/dist/index.mjs CHANGED
@@ -1,12 +1,15 @@
1
- import { ProviderApiError } from "@theholocron/cli";
1
+ import { ProviderApiError, getToken } from "@theholocron/cli";
2
2
  //#region src/auth.ts
3
3
  /**
4
4
  * Token resolution for the Vercel plugin.
5
5
  *
6
- * Resolution order:
6
+ * Resolution order (matches the standard 4-step precedence set by
7
+ * `.notes/tech-auth-bootstrap.spec.md`):
7
8
  * 1. explicit `cliToken` argument (from `--token` flag)
8
9
  * 2. HOLOCRON_VERCEL_TOKEN env var (preferred — explicit intent)
9
10
  * 3. VERCEL_TOKEN env var (the default the Vercel CLI also reads)
11
+ * 4. keyring (com.theholocron.cli / "vercel")
12
+ * 5. AuthError naming all four options + the bootstrap hint
10
13
  *
11
14
  * No `vercel auth` fallback — Vercel CLI auth is per-account-scoped
12
15
  * and the resulting tokens don't always cover team operations.
@@ -16,8 +19,9 @@ var AuthError = class extends Error {
16
19
  };
17
20
  function resolveToken(input = {}) {
18
21
  const env = input.env ?? process.env;
19
- const token = input.cliToken || env.HOLOCRON_VERCEL_TOKEN || env.VERCEL_TOKEN;
20
- if (!token) throw new AuthError("no Vercel token found. Pass --token <PAT>, or set HOLOCRON_VERCEL_TOKEN / VERCEL_TOKEN.");
22
+ const keyring = input.keyring ?? getToken;
23
+ const token = input.cliToken || env["HOLOCRON_VERCEL_TOKEN"] || env["VERCEL_TOKEN"] || keyring("vercel");
24
+ if (!token) throw new AuthError("no Vercel token found. Pass --token <PAT>, set HOLOCRON_VERCEL_TOKEN / VERCEL_TOKEN, or run: holocron auth set vercel <PAT>");
21
25
  return token;
22
26
  }
23
27
  //#endregion
@@ -215,6 +219,31 @@ var VercelRestClient = class {
215
219
  }
216
220
  };
217
221
  //#endregion
222
+ //#region src/verify-token.ts
223
+ /**
224
+ * `verifyToken` — plugin-level export used by `holocron auth set` +
225
+ * `holocron auth check`. Hits `GET /v2/user` and translates the
226
+ * response into the normalized `VerifyTokenResult` shape.
227
+ */
228
+ async function verifyToken(token, opts = {}) {
229
+ const restOpts = { token };
230
+ if (opts.baseUrl !== void 0) restOpts.baseUrl = opts.baseUrl;
231
+ if (opts.fetch !== void 0) restOpts.fetch = opts.fetch;
232
+ const rest = new VercelRestClient(restOpts);
233
+ try {
234
+ const res = await rest.request("/v2/user");
235
+ return {
236
+ ok: true,
237
+ subject: `user @ ${res?.user?.email ?? res?.user?.username ?? res?.user?.name ?? res?.user?.id ?? "unknown"}`
238
+ };
239
+ } catch (err) {
240
+ return {
241
+ ok: false,
242
+ message: err instanceof Error ? err.message : String(err)
243
+ };
244
+ }
245
+ }
246
+ //#endregion
218
247
  //#region src/index.ts
219
248
  function createContext(options = {}) {
220
249
  const restOpts = { token: resolveToken(options) };
@@ -238,5 +267,12 @@ function createPlugin(options = {}) {
238
267
  capabilities: { deployment: () => deployment(ctx) }
239
268
  };
240
269
  }
270
+ /**
271
+ * One-line hint printed by `holocron auth set vercel` when no token
272
+ * is supplied or the supplied token is rejected. Points operators at
273
+ * https://vercel.com/account/tokens where PATs are minted with
274
+ * "Full Account" scope for team-level ops.
275
+ */
276
+ const AUTH_HINT = "generate a Vercel Personal Access Token at https://vercel.com/account/tokens (scope: Full Account for team ops), then run: holocron auth set vercel <PAT>";
241
277
  //#endregion
242
- export { AuthError, VercelDeployment, VercelRestClient, createContext, createPlugin, deployment, resolveToken };
278
+ export { AUTH_HINT, AuthError, VercelDeployment, VercelRestClient, createContext, createPlugin, deployment, resolveToken, verifyToken };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/holocron-plugin-vercel",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.11",
4
4
  "description": "Holocron plugin for Vercel. Implements the deployment capability against the Vercel REST API.",
5
5
  "homepage": "https://github.com/theholocron/holocron/tree/main/packages/holocron-plugin-vercel#readme",
6
6
  "bugs": "https://github.com/theholocron/holocron/issues",
@@ -21,7 +21,7 @@
21
21
  }
22
22
  },
23
23
  "peerDependencies": {
24
- "@theholocron/cli": "2.0.0-alpha.1"
24
+ "@theholocron/cli": "2.0.0-alpha.11"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@theholocron/tsconfig": "^4.1.0",
@@ -32,7 +32,8 @@
32
32
  "typescript": "^5.9.3",
33
33
  "vitest": "^3.2.6",
34
34
  "tsdown": "^0.22.3",
35
- "@theholocron/cli": "2.0.0-alpha.1"
35
+ "tsx": "^4.22.4",
36
+ "@theholocron/cli": "2.0.0-alpha.11"
36
37
  },
37
38
  "publishConfig": {
38
39
  "access": "public"
@@ -47,7 +48,8 @@
47
48
  "typecheck": "tsc --noEmit",
48
49
  "test": "vitest run",
49
50
  "test:watch": "vitest",
50
- "test:coverage": "vitest run --coverage"
51
+ "test:coverage": "vitest run --coverage",
52
+ "validate": "tsx scripts/validate.mjs"
51
53
  },
52
54
  "types": "./dist/index.d.mts"
53
55
  }