@vite-hub/env 0.4.1 → 0.5.1
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 +3 -3
- package/dist/{access-B8lSDip4.js → access-DIErLk3w.js} +2 -3
- package/dist/{bridge-Cs9YfQWk.d.ts → bridge-BWwIooe0.d.ts} +0 -12
- package/dist/{bridge-error-BhJ77age.js → bridge-error-DEqzARPJ.js} +1 -3
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +9 -10
- package/dist/{cli-BPp7rdcA.d.ts → cli-B-LW6l_J.d.ts} +1 -6
- package/dist/cli-CAlHK5nn.js +1354 -0
- package/dist/cli.d.ts +3 -6
- package/dist/cli.js +1 -2
- package/dist/database.d.ts +2 -4
- package/dist/database.js +2 -5
- package/dist/{declarations-C5XR3aKw.d.ts → declarations-DNjO52_s.d.ts} +1 -21
- package/dist/{schema-C_a0WZyd.js → declarations-meg4Rmgd.js} +43 -105
- package/dist/{object-C7Jt4ez2.js → error-diagnostics-5BceFRdD.js} +57 -14
- package/dist/{error-diagnostics-DsDPsST_.js → error-diagnostics-BFzFaXcH.js} +2 -4
- package/dist/index.d.ts +3 -13
- package/dist/index.js +8 -12
- package/dist/internal/agent.d.ts +2 -4
- package/dist/internal/agent.js +3 -4
- package/dist/internal/connections.d.ts +2 -4
- package/dist/internal/connections.js +3 -4
- package/dist/internal/server.d.ts +2 -2
- package/dist/internal/server.js +1 -2
- package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
- package/dist/{operations-B1PFpKzy.js → operations-BftegDMd.js} +2 -3
- package/dist/operations.d.ts +2 -6
- package/dist/operations.js +7 -41
- package/dist/runtime/public-env.d.ts +2 -4
- package/dist/runtime/public-env.js +2 -3
- package/dist/runtime/server-env.d.ts +2 -3
- package/dist/runtime/server-env.js +2 -3
- package/dist/seal.d.ts +1 -3
- package/dist/seal.js +1 -2
- package/dist/{secret-DJd-fy5T.js → secret-VhbE53Vm.js} +1 -2
- package/dist/{server-CgKAEAE6.d.ts → server-CPEywepM.d.ts} +1 -12
- package/dist/{server-B9-8r6MZ.js → server-pTqnkM7n.js} +213 -168
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -2
- package/dist/vite.d.ts +5 -17
- package/dist/vite.js +20 -37
- package/package.json +11 -10
- package/dist/cli-C51D6V-M.js +0 -669
package/README.md
CHANGED
|
@@ -256,7 +256,7 @@ VITEHUB_RETRIES=3
|
|
|
256
256
|
VITEHUB_API_TOKEN=
|
|
257
257
|
```
|
|
258
258
|
|
|
259
|
-
This uses the restricted `env-spec-v1` profile
|
|
259
|
+
This uses the restricted [`env-spec-v1` profile](https://vitehub.dev/docs/env/env-spec). Its [@env-spec syntax](https://varlock.dev/env-spec/reference/) parser reads static metadata. It does not run Varlock, load developer `.env` files, or evaluate expansions and functions.
|
|
260
260
|
|
|
261
261
|
A nonempty assignment is a real default. `KEY=` has no default; `KEY=""` is an explicit empty string. Put documentation samples in `@example`, which never supplies a value. Review existing example assignments before opting in. All fields default to required and sensitive; the default type is always string, so `CODE=00123` preserves its zeroes.
|
|
262
262
|
|
|
@@ -417,7 +417,7 @@ Read the complete [Env guide](https://vitehub.dev/docs/env), the [host support m
|
|
|
417
417
|
`hubEnv()` contributes two CLI commands:
|
|
418
418
|
|
|
419
419
|
```bash
|
|
420
|
-
vitehub env
|
|
420
|
+
vitehub env list [--stage <name>] [--json]
|
|
421
421
|
vitehub env check [--stage <name>] [--json]
|
|
422
422
|
```
|
|
423
423
|
|
|
@@ -426,7 +426,7 @@ Both commands load the Vite config in the selected stage mode, including `.env.<
|
|
|
426
426
|
`hubEnv()` also contributes the `env.inspect` operation. It asks the running app, not a local stage, so the CLI and the Console can check that a deployed app has its env. It answers on the signed `POST /_vitehub/rpc` endpoint like every other operation, and needs the `env` Console section (`env:read` is enough).
|
|
427
427
|
|
|
428
428
|
```bash
|
|
429
|
-
vitehub env
|
|
429
|
+
vitehub env list --url https://my-app.example.com
|
|
430
430
|
```
|
|
431
431
|
|
|
432
432
|
The result has `ok`, the `host` that the app runs on when it is known, and one entry per declaration: `path`, `names`, `name` (the host variable that supplied the value), `source`, `provider`, `required`, `secret`, `status`, and `blocking`. The status is `available`, `defaulted`, `missing`, `invalid`, or `error`, as in `inspectServerEnv()`. The result never holds a value, a preview, or a length.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as envBridgeError } from "./bridge-error-
|
|
1
|
+
import { t as envBridgeError } from "./bridge-error-DEqzARPJ.js";
|
|
2
2
|
import { defineGrant } from "@vite-hub/runtime/internal/grant";
|
|
3
|
-
|
|
3
|
+
// src/internal/access.ts
|
|
4
4
|
/** Marks the type of contexts that Env creates. The bridge trusts only the `envAccess` grant registry, not this marker. */
|
|
5
5
|
const envAccessGrant = Symbol("vitehub.env.access-grant");
|
|
6
6
|
const envAccess = defineGrant("vitehub.env.access", (authority) => authority.kind === "key" ? Object.freeze({
|
|
@@ -50,5 +50,4 @@ function envAccessAuthority(context) {
|
|
|
50
50
|
if (!authority) throw envBridgeError("untrusted");
|
|
51
51
|
return authority;
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
53
|
export { validateEnvActor as i, envIdentifier as n, grantEnvAccess as r, envAccessAuthority as t };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
//#region src/internal/access.d.ts
|
|
2
1
|
/** Marks the type of contexts that Env creates. The bridge trusts only the `envAccess` grant registry, not this marker. */
|
|
3
2
|
declare const envAccessGrant: unique symbol;
|
|
4
3
|
interface EnvAttribution {
|
|
5
4
|
traceId?: string;
|
|
6
5
|
invocationId?: string;
|
|
7
6
|
}
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/secret.d.ts
|
|
10
7
|
declare class SecretEnv<T = string> {
|
|
11
8
|
#private;
|
|
12
9
|
constructor(value: T);
|
|
@@ -15,8 +12,6 @@ declare class SecretEnv<T = string> {
|
|
|
15
12
|
toJSON(): string;
|
|
16
13
|
[Symbol.toPrimitive](): string;
|
|
17
14
|
}
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/http.d.ts
|
|
20
15
|
interface EnvManagement {
|
|
21
16
|
bridge: EnvBridge;
|
|
22
17
|
authenticate(request: Request): EnvAccessContext | null | Promise<EnvAccessContext | null>;
|
|
@@ -35,8 +30,6 @@ type EnvManagementResolver = (path: string) => {
|
|
|
35
30
|
} | undefined;
|
|
36
31
|
/** Mount only on a server route. resolve selects declared credentials, never arbitrary store keys. */
|
|
37
32
|
declare function createEnvBridgeHandler(resolve: EnvManagementResolver): (request: Request, options?: EnvBridgeRequestOptions) => Promise<Response>;
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/types.d.ts
|
|
40
33
|
type EnvDiagnostics = "off" | "summary" | "trace";
|
|
41
34
|
type EnvMode = "build" | "runtime";
|
|
42
35
|
/** Options of `vitehub({ env })` and `hubEnv()`: the Env declarations and how ViteHub resolves them. */
|
|
@@ -305,8 +298,6 @@ interface ServerEnvDescription {
|
|
|
305
298
|
interface ServerEnvInspection {
|
|
306
299
|
entries: readonly ServerEnvInspectionEntry[];
|
|
307
300
|
}
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region src/auth.d.ts
|
|
310
301
|
interface EnvHumanSession {
|
|
311
302
|
user: {
|
|
312
303
|
id: string;
|
|
@@ -336,8 +327,6 @@ interface EnvAuthenticatorOptions<Human extends EnvHumanSession, Agent extends E
|
|
|
336
327
|
}
|
|
337
328
|
/** Authenticate management requests without coupling Env to a particular Better Auth plugin version. */
|
|
338
329
|
declare function createEnvAuthenticator<Human extends EnvHumanSession, Agent extends EnvAgentSession = EnvAgentSession>(options: EnvAuthenticatorOptions<Human, Agent>): (request: Request) => Promise<EnvAccessContext | null>;
|
|
339
|
-
//#endregion
|
|
340
|
-
//#region src/bridge.d.ts
|
|
341
330
|
type EnvPermission = "inspect" | "preview" | "replace" | "use";
|
|
342
331
|
interface EnvActor {
|
|
343
332
|
id: string;
|
|
@@ -443,5 +432,4 @@ interface EnvBridge extends EnvProvider {
|
|
|
443
432
|
revoke(context: EnvAccessContext, actor: EnvActor, key: string): Promise<void>;
|
|
444
433
|
}
|
|
445
434
|
declare function createEnvBridge(options: EnvBridgeOptions): EnvBridge;
|
|
446
|
-
//#endregion
|
|
447
435
|
export { EnvAttribution as $, EnvRuntimeRegistry as A, PublicEnv as B, EnvMode as C, EnvProviderValues as D, EnvProviderContext as E, EnvTypedVariableOptions as F, ServerEnvInspection as G, ServerEnv as H, EnvValueSchema as I, EnvBridgeRequestOptions as J, ServerEnvInspectionEntry as K, EnvVariableDeclaration as L, EnvSource as M, EnvSourceContext as N, EnvProviders as O, EnvSourceResolver as P, SecretEnv as Q, EnvVariableOptions as R, EnvDiagnostics as S, EnvProvider as T, ServerEnvDescription as U, ReadonlyServerEnv as V, ServerEnvDescriptionEntry as W, EnvManagementResolver as X, EnvManagement as Y, createEnvBridgeHandler as Z, EnvHumanSession as _, EnvActor as a, EnvDeclarations as b, EnvGrant as c, EnvSecretMetadata as d, EnvSecretStore as f, EnvAuthenticatorOptions as g, EnvAgentSession as h, EnvActivity as i, EnvSchemaModuleReference as j, EnvRuntimeConfigOptions as k, EnvPermission as l, EnvAgentScope as m, EnvAccessScope as n, EnvBridge as o, createEnvBridge as p, ServerEnvInspectionStatus as q, EnvAccessStore as r, EnvBridgeOptions as s, EnvAccessContext as t, EnvReplacement as u, createEnvAuthenticator as v, EnvOptions as w, EnvDiagnosticEntry as x, DeepReadonly as y, LoadServerEnvOptions as z };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineDiagnostics } from "nostics";
|
|
2
2
|
import { ViteHubError, isViteHubError } from "@vite-hub/runtime";
|
|
3
|
-
|
|
3
|
+
// src/bridge-error.ts
|
|
4
4
|
const messages = {
|
|
5
5
|
denied: "Env access denied.",
|
|
6
6
|
conflict: "The credential changed. Refresh before replacing it.",
|
|
@@ -17,7 +17,6 @@ const guidance = (fix) => ({
|
|
|
17
17
|
why: ({ message }) => message,
|
|
18
18
|
fix
|
|
19
19
|
});
|
|
20
|
-
/** Repair guidance that the management route adds to each bridge error body. */
|
|
21
20
|
const envBridgeDiagnostics = /*#__PURE__*/ defineDiagnostics({
|
|
22
21
|
docsBase: "https://vitehub.dev/docs/env/diagnostics",
|
|
23
22
|
codes: {
|
|
@@ -62,5 +61,4 @@ function sanitizeEnvBridgeError(error) {
|
|
|
62
61
|
}
|
|
63
62
|
return envBridgeError("operation_failed");
|
|
64
63
|
}
|
|
65
|
-
//#endregion
|
|
66
64
|
export { envBridgeErrorBody as n, sanitizeEnvBridgeError as r, envBridgeError as t };
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { J as EnvBridgeRequestOptions, X as EnvManagementResolver, Y as EnvManagement, Z as createEnvBridgeHandler, _ as EnvHumanSession, a as EnvActor, c as EnvGrant, d as EnvSecretMetadata, f as EnvSecretStore, g as EnvAuthenticatorOptions, h as EnvAgentSession, i as EnvActivity, l as EnvPermission, m as EnvAgentScope, n as EnvAccessScope, o as EnvBridge, p as createEnvBridge, r as EnvAccessStore, s as EnvBridgeOptions, t as EnvAccessContext, u as EnvReplacement, v as createEnvAuthenticator } from "./bridge-
|
|
1
|
+
import { J as EnvBridgeRequestOptions, X as EnvManagementResolver, Y as EnvManagement, Z as createEnvBridgeHandler, _ as EnvHumanSession, a as EnvActor, c as EnvGrant, d as EnvSecretMetadata, f as EnvSecretStore, g as EnvAuthenticatorOptions, h as EnvAgentSession, i as EnvActivity, l as EnvPermission, m as EnvAgentScope, n as EnvAccessScope, o as EnvBridge, p as createEnvBridge, r as EnvAccessStore, s as EnvBridgeOptions, t as EnvAccessContext, u as EnvReplacement, v as createEnvAuthenticator } from "./bridge-BWwIooe0.js";
|
|
2
2
|
export { EnvAccessContext, EnvAccessScope, EnvAccessStore, EnvActivity, EnvActor, type EnvAgentScope, type EnvAgentSession, type EnvAuthenticatorOptions, EnvBridge, EnvBridgeOptions, type EnvBridgeRequestOptions, EnvGrant, type EnvHumanSession, type EnvManagement, type EnvManagementResolver, EnvPermission, EnvReplacement, EnvSecretMetadata, EnvSecretStore, createEnvAuthenticator, createEnvBridge, createEnvBridgeHandler };
|
package/dist/bridge.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { n as
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { n as envBridgeErrorBody, r as sanitizeEnvBridgeError, t as envBridgeError } from "./bridge-error-DEqzARPJ.js";
|
|
2
|
+
import { i as validateEnvActor, n as envIdentifier, r as grantEnvAccess, t as envAccessAuthority } from "./access-DIErLk3w.js";
|
|
3
|
+
import { t as SecretEnv } from "./secret-VhbE53Vm.js";
|
|
4
|
+
// src/auth.ts
|
|
5
5
|
const permissions$1 = [
|
|
6
6
|
"inspect",
|
|
7
7
|
"preview",
|
|
@@ -42,8 +42,7 @@ function createEnvAuthenticator(options) {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
//#region src/http.ts
|
|
45
|
+
// src/http.ts
|
|
47
46
|
function record(value) {
|
|
48
47
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
49
48
|
}
|
|
@@ -162,8 +161,7 @@ function createEnvBridgeHandler(resolve) {
|
|
|
162
161
|
}
|
|
163
162
|
};
|
|
164
163
|
}
|
|
165
|
-
|
|
166
|
-
//#region src/bridge.ts
|
|
164
|
+
// src/bridge.ts
|
|
167
165
|
async function safe(run) {
|
|
168
166
|
try {
|
|
169
167
|
return await run();
|
|
@@ -180,7 +178,9 @@ function createEnvBridge(options) {
|
|
|
180
178
|
}
|
|
181
179
|
try {
|
|
182
180
|
await options.emit?.(structuredClone(event));
|
|
183
|
-
} catch {
|
|
181
|
+
} catch {
|
|
182
|
+
console.warn(`[vitehub] Env activity export failed for event ${event.id}. The activity store keeps the event.`);
|
|
183
|
+
}
|
|
184
184
|
}
|
|
185
185
|
async function allowed(context, key, permission) {
|
|
186
186
|
const authority = envAccessAuthority(context);
|
|
@@ -350,5 +350,4 @@ function createEnvBridge(options) {
|
|
|
350
350
|
};
|
|
351
351
|
return bridge;
|
|
352
352
|
}
|
|
353
|
-
//#endregion
|
|
354
353
|
export { createEnvAuthenticator, createEnvBridge, createEnvBridgeHandler };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Diagnostic } from "nostics";
|
|
2
|
-
//#region ../internal/src/host-credentials.d.ts
|
|
3
2
|
interface HostCliRunResult {
|
|
4
3
|
exitCode: number | null;
|
|
5
4
|
stdout: string;
|
|
5
|
+
stderr?: string;
|
|
6
6
|
}
|
|
7
7
|
/** Runs a host CLI with an argument array and no shell, and returns its stdout. */
|
|
8
8
|
type HostCliRun = (command: string, args: readonly string[], options: {
|
|
@@ -10,8 +10,6 @@ type HostCliRun = (command: string, args: readonly string[], options: {
|
|
|
10
10
|
env: NodeJS.ProcessEnv;
|
|
11
11
|
signal?: AbortSignal;
|
|
12
12
|
}) => Promise<HostCliRunResult>;
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region ../internal/src/provision.d.ts
|
|
15
13
|
type ProvisionProvider = "cloudflare" | "vercel";
|
|
16
14
|
interface ProvisionLogger {
|
|
17
15
|
log: (message: string) => void;
|
|
@@ -63,8 +61,6 @@ interface ProvisionStep {
|
|
|
63
61
|
/** Describes the Provision State this step records. Runs without network access, also without credentials. */
|
|
64
62
|
recordedState?: (context: Pick<ProvisionContext, "env">) => ProvisionStateCategory[];
|
|
65
63
|
}
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region ../internal/src/cli.d.ts
|
|
68
64
|
interface ViteHubCliStreams {
|
|
69
65
|
stderr: {
|
|
70
66
|
write: (chunk: string | Uint8Array, encoding?: BufferEncoding | StdoutWriteCallback, callback?: StdoutWriteCallback) => unknown;
|
|
@@ -155,5 +151,4 @@ interface ViteHubCliContributor {
|
|
|
155
151
|
publicUrl?: string;
|
|
156
152
|
}
|
|
157
153
|
type StdoutWriteCallback = (error?: Error | null) => void;
|
|
158
|
-
//#endregion
|
|
159
154
|
export { ViteHubCliContributor as n, ViteHubCliContext as t };
|