Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix(credentials): separate management from reads and add explicit file storage

kashorin8690e795c596
diff --git a/package.json b/package.json
index 56bcb016..e74c696b 100644
--- a/package.json
+++ b/package.json
@@ -203,6 +203,7 @@
"@hypit/comment-sticker-studio": "workspace:*",
"@hypit/composition": "workspace:*",
"@hypit/credential-store-env": "workspace:*",
+ "@hypit/credential-store-file": "workspace:*",
"@hypit/credential-store-os": "workspace:*",
"@hypit/deck-track": "workspace:*",
"@hypit/deck-track-studio": "workspace:*",
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 10b6d058..5f280c1d 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -27,6 +27,7 @@
"typescript": "5.9.3"
},
"devDependencies": {
+ "@hypit/runtime-local": "workspace:*",
"@hypit/markup": "workspace:*",
"@hypit/run-markup": "workspace:*",
"@hypit/workspace-fs-node": "workspace:*"
diff --git a/packages/cli/src/commands/environment.ts b/packages/cli/src/commands/environment.ts
index 8eb1cff8..66b14a3b 100644
--- a/packages/cli/src/commands/environment.ts
+++ b/packages/cli/src/commands/environment.ts
@@ -364,13 +364,10 @@ export async function runEnvironmentCommand(input: {
}
const credentialsControl = await (await runtimeHost(runtimeProfile)).openCredentials(args.endpoint);
try {
- let credentials = await credentialsControl.credentials(args.endpoint);
- if (args.slot !== undefined) credentials = credentials.filter((item) => item.slot === args.slot);
- if (credentials.length === 0) throw new Error(`Endpoint ${args.endpoint} has no matching credential`);
- if (args.slot === undefined && credentials.length > 1 && args.action !== "status") {
- throw new Error(`Endpoint ${args.endpoint} has several credentials; select one with --slot`);
- }
if (args.action === "status") {
+ let credentials = await credentialsControl.credentials(args.endpoint);
+ if (args.slot !== undefined) credentials = credentials.filter((item) => item.slot === args.slot);
+ if (credentials.length === 0) throw new Error(`Endpoint ${args.endpoint} has no matching credential`);
const view = credentials.slice(0, args.limit).map((item) => ({
endpoint: item.endpoint,
slot: item.slot,
@@ -397,7 +394,15 @@ export async function runEnvironmentCommand(input: {
: `login opens OAuth: ${item.acquisition.authorizationEndpoint}`;
return `${item.slot}: ${item.configured ? "configured" : "missing"} · ${item.writable ? "writable" : "read-only"} · ${entry}`;
}));
- } else if (args.action === "login") {
+ return;
+ }
+ let credentials = await credentialsControl.describeCredentials(args.endpoint);
+ if (args.slot !== undefined) credentials = credentials.filter((item) => item.slot === args.slot);
+ if (credentials.length === 0) throw new Error(`Endpoint ${args.endpoint} has no matching credential`);
+ if (args.slot === undefined && credentials.length > 1) {
+ throw new Error(`Endpoint ${args.endpoint} has several credentials; select one with --slot`);
+ }
+ if (args.action === "login") {
const [item] = credentials;
if (item === undefined) throw new Error(`Endpoint ${args.endpoint} has no matching credential`);
if (!item.writable) {
diff --git a/packages/cli/src/main.ts b/packages/cli/src/main.ts
index dea9dca6..9ca52c18 100644
--- a/packages/cli/src/main.ts
+++ b/packages/cli/src/main.ts
@@ -148,7 +148,8 @@ export async function runCli(
}, "Runtime Profile created", "success", [
["Profile", selected.profile],
["Project", selected.projectRoot],
- ], ["No package was installed, no service was contacted and no Worker was started."]);
+ ], ["Review the Profile’s credential stores and Endpoint settings before login or runtime up.",
+ "No package was installed, no service was contacted and no Worker was started."]);
return;
}
if (args.command === "runtime" && args.action === "use") {
diff --git a/packages/cli/test/control-commands.test.ts b/packages/cli/test/control-commands.test.ts
index 182bd7d4..0e8e0d56 100644
--- a/packages/cli/test/control-commands.test.ts
+++ b/packages/cli/test/control-commands.test.ts
@@ -7,6 +7,7 @@ import test from "node:test";
import type { CliDistribution } from "../src/distribution.js";
import { runCli } from "../src/main.js";
import type { CliCredentialControl, CliRuntimeControl } from "../src/runtime-port.js";
+import { createLocalCredentialControl } from "@hypit/runtime-local";
import { commandHint } from "../src/command-hint.js";
test("activity opens Runtime control without constructing execution Providers", async () => {
@@ -590,7 +591,7 @@ test("auth login explains an environment-owned credential before asking for a se
let prompted = false;
let closed = false;
const credentials = {
- async credentials() {
+ async describeCredentials() {
return [{
endpoint: "images.project",
slot: "apiKey",
@@ -725,3 +726,37 @@ test("a stopped Worker ends observation with scoped evidence commands, not a Res
assert.equal(closed, true);
assert.equal(resultOpened, false);
});
+
+
+test("auth can replace and delete a credential whose Store cannot read its old value", async () => {
+ let value = "damaged";
+ let reads = 0;
+ const endpoint: Parameters<typeof createLocalCredentialControl>[0]["endpoints"][number] = {
+ instance: { id: "service.project", pool: "service.project" }, offers: [], install() {},
+ credentials: [{ endpoint: "service.project", slot: "apiKey", label: "Service key", kind: "secret",
+ ref: { store: "test", key: "service" } }],
+ };
+ const credentialStore = {
+ owns: () => true,
+ async resolve() { reads++; throw new Error("credential cannot be read"); },
+ async put(_ref: unknown, input: { secret: string }) { value = input.secret; },
+ async delete() { value = ""; return true; },
+ };
+ const distribution = {
+ openRuntimeHost: async () => ({
+ openCredentials: async () => createLocalCredentialControl({ credentialStore, endpoints: [endpoint] }),
+ }),
+ } as unknown as CliDistribution;
+ await assert.rejects(runCli(["auth", "status", "service.project", "--runtime", "/tmp/runtime.json"],
+ { write() {} }, distribution), /credential cannot be read/u);
+ reads = 0;
+ for (const action of ["login", "logout"]) {
+ let output = "";
+ await runCli(["auth", action, "service.project", "--runtime", "/tmp/runtime.json", "--json"], {
+ write(text) { output += text; }, readSecret: async () => "replacement",
+ }, distribution);
+ assert.equal(JSON.parse(output).configured, action === "login");
+ assert.equal(value, action === "login" ? "replacement" : "");
+ }
+ assert.equal(reads, 0, "management must not read the previous or newly written secret");
+});
diff --git a/packages/credential-store-file/README.md b/packages/credential-store-file/README.md
new file mode 100644
index 00000000..c0a6aafb
--- /dev/null
+++ b/packages/credential-store-file/README.md
@@ -0,0 +1,60 @@
+# `@hypit/credential-store-file`
+
+A writable CredentialStore for a deployment that explicitly chooses local file storage, including
+Linux without an OS credential locker. It stores unencrypted credential values in an owner-private
+directory outside the video project. On Windows the selected directory must have a private user ACL;
+POSIX file modes do not set Windows ACLs. Choose `@hypit/credential-store-os` when using macOS Keychain
+or Windows Credential Locker, or `@hypit/credential-store-env` for externally supplied, read-only values.
+
+## Select it before login
+
+After `hypit runtime init`, edit the created Profile before running `auth` or starting its Runtime.
+Replace its credential-store selection and the chosen Endpoint's credential reference together:
+
+```json
+{
+ "credentials": {
+ "file": { "use": "@hypit/credential-store-file" }
+ },
+ "endpoints": {
+ "hypihub.default": {
+ "use": "@hypit/provider-hypihub",
+ "config": {
+ "baseUrl": "https://hypit.ai",
+ "apiKey": { "store": "file", "key": "hypihub.oauth" }
+ }
+ }
+ }
+}
+```
+
+This is a Profile fragment: preserve its format, dataRoot, other Endpoints and bindings. For an
+existing Profile, edit only the selected references and use `hypit runtime use <profile>` to select it.
+The Endpoint still owns its acquisition flow; the Store only persists its result:
+
+```bash
+hypit auth login hypihub.default
+hypit auth status hypihub.default
+hypit auth logout hypihub.default
+```
+
+No existing OS credential is migrated and no failed lookup tries another Store. A damaged document
+can be replaced by login or deleted by logout without decoding the old value. Status and execution
+report the read error rather than treating corruption as a missing credential.
+
+## Storage
+
+The default directory is `credentials` under the Host state root printed by `hypit paths`.
+`config.path` explicitly selects a directory, resolving relative paths against that Host root.
+Opening the adapter and reading an absent key do not create files. Keep this directory outside Git.
+
+Each key has its own JSON file containing only `secret` and optional `expiresAt`, as defined by
+CredentialValue. Filenames use reversible lower-case hex encoding of the key's UTF-16 bytes, with a
+`key-` prefix; they are not hashes or secret encryption. This preserves case-sensitive key identity on
+case-insensitive filesystems and keeps slashes and reserved names out of filesystem path syntax.
+Filesystem path-length limits still apply; an overlong key fails rather than selecting another name.
+
+Writes create an owner-only temporary file and replace the single destination with rename. Different
+keys do not overwrite each other's updates; concurrent writes to the same key keep the last completed
+replacement. The Store does not enumerate credentials, maintain an index, or record write history.
+Permission and I/O errors propagate. Existing directory permissions are not silently changed.
diff --git a/packages/credential-store-file/package.json b/packages/credential-store-file/package.json
new file mode 100644
index 00000000..6a18efb0
--- /dev/null
+++ b/packages/credential-store-file/package.json
@@ -0,0 +1,21 @@
+{
+ "name": "@hypit/credential-store-file",
+ "version": "0.0.0-dev",
+ "license": "SEE LICENSE IN LICENSE",
+ "private": true,
+ "type": "module",
+ "exports": {
+ ".": "./src/index.ts"
+ },
+ "files": [
+ "src",
+ "README.md"
+ ],
+ "hypit": {
+ "activation": "./src/activation.ts"
+ },
+ "dependencies": {
+ "@hypit/runtime": "workspace:*",
+ "@hypit/runtime-kit": "workspace:*"
+ }
+}
diff --git a/packages/credential-store-file/src/activation.ts b/packages/credential-store-file/src/activation.ts
new file mode 100644
index 00000000..e6e532e8
--- /dev/null
+++ b/packages/credential-store-file/src/activation.ts
@@ -0,0 +1,29 @@
+import { join, resolve } from "node:path";
+import {
+ createRuntimeCredentialStoreAdapterFacet,
+ runtimeConfigExact,
+ runtimeConfigObject,
+ runtimeConfigString,
+} from "@hypit/runtime-kit";
+import { FileCredentialStore } from "./store.js";
+
+const fileCredentialStoreAdapter = createRuntimeCredentialStoreAdapterFacet({
+ use: "@hypit/credential-store-file",
+ validate(context) {
+ const config = runtimeConfigObject(context.config, "file CredentialStore");
+ runtimeConfigExact(config, ["path"], "file CredentialStore");
+ runtimeConfigString(config.path, "file credential path");
+ },
+ open(context) {
+ const config = runtimeConfigObject(context.config, "file CredentialStore");
+ const path = runtimeConfigString(config.path, "file credential path");
+ return { value: new FileCredentialStore(path === undefined
+ ? join(context.hostStateRoot, "credentials") : resolve(context.hostStateRoot, path)) };
+ },
+});
+
+export const hypitPackage = {
+ format: "hypit.node-package@1" as const,
+ hostFacets: [fileCredentialStoreAdapter],
+};
+export default hypitPackage;
diff --git a/packages/credential-store-file/src/index.ts b/packages/credential-store-file/src/index.ts
new file mode 100644
index 00000000..481b1203
--- /dev/null
+++ b/packages/credential-store-file/src/index.ts
@@ -0,0 +1 @@
+export { FileCredentialStore } from "./store.js";
diff --git a/packages/credential-store-file/src/store.ts b/packages/credential-store-file/src/store.ts
new file mode 100644
index 00000000..228d9239
--- /dev/null
+++ b/packages/credential-store-file/src/store.ts
@@ -0,0 +1,89 @@
+import { randomUUID } from "node:crypto";
+import { mkdir, open, rename, rm, stat, unlink } from "node:fs/promises";
+import { join } from "node:path";
+import { verifyCredentialRef } from "@hypit/runtime";
+import type { CredentialRef, CredentialValue, WritableCredentialStore } from "@hypit/runtime";
+
+function missing(error: unknown): boolean {
+ return error instanceof Error && "code" in error && error.code === "ENOENT";
+}
+
+function credentialValue(value: unknown): CredentialValue {
+ if (value === null || typeof value !== "object" || Array.isArray(value)) throw new Error("invalid credential value");
+ const record = value as Record<string, unknown>;
+ if (typeof record.secret !== "string" || record.secret.length === 0
+ || (record.expiresAt !== undefined && (typeof record.expiresAt !== "number" || !Number.isFinite(record.expiresAt)))) {
+ throw new Error("invalid credential value");
+ }
+ return { secret: record.secret, ...(record.expiresAt === undefined ? {} : { expiresAt: record.expiresAt as number }) };
+}
+
+/** One file per Store-local key; no enumeration, index or cross-key read/modify/write. */
+export class FileCredentialStore implements WritableCredentialStore {
+ constructor(readonly directory: string) {}
+
+ owns(ref: CredentialRef): boolean { return ref.store === "file"; }
+
+ #path(ref: CredentialRef): string {
+ verifyCredentialRef(ref);
+ if (!this.owns(ref)) throw new Error(`File CredentialStore does not own ${ref.store}`);
+ // Reversible UTF-16 encoding preserves the opaque JS key, even on case-insensitive filesystems.
+ // The prefix avoids reserved OS filenames; no key characters become path separators.
+ return join(this.directory, `key-${Buffer.from(ref.key, "utf16le").toString("hex")}.json`);
+ }
+
+ async #privateDirectory(create: boolean): Promise<void> {
+ if (create) await mkdir(this.directory, { recursive: true, mode: 0o700 });
+ const info = await stat(this.directory);
+ if (!info.isDirectory()) throw new Error(`Credential path is not a directory: ${this.directory}`);
+ if (process.platform !== "win32" && (info.mode & 0o077) !== 0) {
+ throw new Error(`Credential directory must be owner-private: ${this.directory}`);
+ }
+ }
+
+ async resolve(ref: CredentialRef): Promise<CredentialValue | undefined> {
+ if (!this.owns(ref)) return undefined;
+ const path = this.#path(ref);
+ try { await this.#privateDirectory(false); } catch (error) {
+ if (missing(error)) return undefined;
+ throw error;
+ }
+ let file;
+ try { file = await open(path, "r"); } catch (error) {
+ if (missing(error)) return undefined;
+ throw error;
+ }
+ try {
+ const info = await file.stat();
+ if (process.platform !== "win32" && (info.mode & 0o077) !== 0) {
+ throw new Error(`Credential file must be owner-private: ${path}`);
+ }
+ const text = await file.readFile("utf8");
+ // JSON parser messages may include secret bytes. Report the file, never its contents.
+ try { return credentialValue(JSON.parse(text)); } catch {
+ throw new Error(`Cannot decode credential file: ${path}; replace it with auth login or remove it with auth logout`);
+ }
+ } finally { await file.close(); }
+ }
+
+ async put(ref: CredentialRef, value: CredentialValue): Promise<void> {
+ const path = this.#path(ref);
+ const contents = JSON.stringify(credentialValue(value));
+ await this.#privateDirectory(true);
+ const temporary = join(this.directory, `.write-${randomUUID()}.tmp`);
+ const file = await open(temporary, "wx", 0o600);
+ try {
+ try { await file.writeFile(`${contents}\n`, "utf8"); } finally { await file.close(); }
+ await rename(temporary, path);
+ } finally { await rm(temporary, { force: true }); }
+ }
+
+ async delete(ref: CredentialRef): Promise<boolean> {
+ const path = this.#path(ref);
+ // Deletion never opens or decodes the old document.
+ try { await unlink(path); return true; } catch (error) {
+ if (missing(error)) return false;
+ throw error;
+ }
+ }
+}
diff --git a/packages/credential-store-file/test/store.test.ts b/packages/credential-store-file/test/store.test.ts
new file mode 100644
index 00000000..af3a8bc9
--- /dev/null
+++ b/packages/credential-store-file/test/store.test.ts
@@ -0,0 +1,66 @@
+import assert from "node:assert/strict";
+import { chmod, mkdtemp, readdir, readFile, rm, stat, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import test from "node:test";
+import { credentialRef } from "@hypit/runtime";
+import { FileCredentialStore } from "../src/store.js";
+
+test("independent credential keys retain concurrent writes and round-trip opaque names", async () => {
+ const root = await mkdtemp(join(tmpdir(), "hypit-file-credentials-"));
+ try {
+ const directory = join(root, "private");
+ const store = new FileCredentialStore(directory);
+ const keys = ["Account", "account", "../outside", "密钥/one", "CON", "\ud800", "\ufffd"];
+ assert.equal(await store.resolve(credentialRef("file", "missing")), undefined);
+ const writers = keys.map(() => new FileCredentialStore(directory));
+ await Promise.all(keys.map((key, index) => writers[index]!.put(credentialRef("file", key), {
+ secret: `secret-${index}`, expiresAt: 12345,
+ })));
+ for (const [index, key] of keys.entries()) {
+ assert.deepEqual(await store.resolve(credentialRef("file", key)), { secret: `secret-${index}`, expiresAt: 12345 });
+ }
+ assert.deepEqual(await readdir(root), ["private"]);
+ const files = await readdir(directory);
+ assert.equal(files.length, keys.length);
+ for (const name of files) {
+ assert.deepEqual(Object.keys(JSON.parse(await readFile(join(directory, name), "utf8"))).sort(), ["expiresAt", "secret"]);
+ if (process.platform !== "win32") assert.equal((await stat(join(directory, name))).mode & 0o777, 0o600);
+ }
+ assert.equal(await store.resolve(credentialRef("env", "Account")), undefined);
+ assert.equal(await store.delete(credentialRef("file", keys[0]!)), true);
+ assert.equal(await store.delete(credentialRef("file", keys[0]!)), false);
+ assert.deepEqual(await store.resolve(credentialRef("file", keys[1]!)), { secret: "secret-1", expiresAt: 12345 });
+ } finally { await rm(root, { recursive: true, force: true }); }
+});
+
+test("corrupt values report no secret bytes and can be replaced or deleted without reading", async () => {
+ const root = await mkdtemp(join(tmpdir(), "hypit-file-credentials-"));
+ try {
+ const store = new FileCredentialStore(root);
+ const ref = credentialRef("file", "service");
+ await store.put(ref, { secret: "original" });
+ const path = join(root, (await readdir(root))[0]!);
+ await writeFile(path, 'private-secret-not-json');
+ await assert.rejects(store.resolve(ref), error => {
+ assert.match(String(error), /Cannot decode credential file/u);
+ assert.doesNotMatch(String(error), /private-secret/u);
+ return true;
+ });
+ await store.put(ref, { secret: "replacement" });
+ assert.deepEqual(await store.resolve(ref), { secret: "replacement" });
+ await writeFile(path, '{"secret":false}');
+ assert.equal(await store.delete(ref), true);
+ assert.equal(await store.resolve(ref), undefined);
+ } finally { await rm(root, { recursive: true, force: true }); }
+});
+
+test("file credentials require an owner-private directory on POSIX", { skip: process.platform === "win32" }, async () => {
+ const root = await mkdtemp(join(tmpdir(), "hypit-file-credentials-"));
+ try {
+ await chmod(root, 0o755);
+ const store = new FileCredentialStore(root);
+ await assert.rejects(store.put(credentialRef("file", "service"), { secret: "secret" }), /owner-private/u);
+ assert.deepEqual(await readdir(root), []);
+ } finally { await rm(root, { recursive: true, force: true }); }
+});
diff --git a/packages/runtime-host-node/src/index.ts b/packages/runtime-host-node/src/index.ts
index f8644a5a..3abe4f75 100644
--- a/packages/runtime-host-node/src/index.ts
+++ b/packages/runtime-host-node/src/index.ts
@@ -70,17 +70,20 @@ export type BuildView = {
}[];
};
-export type RuntimeHostCredentialStatus = {
+export type RuntimeHostCredentialDescription = {
readonly endpoint: string;
readonly slot: string;
readonly label: string;
readonly kind: "secret" | "json";
readonly ref: CredentialRef;
readonly acquisition?: CredentialAcquisition;
- readonly configured: boolean;
readonly writable: boolean;
};
+export type RuntimeHostCredentialStatus = RuntimeHostCredentialDescription & {
+ readonly configured: boolean;
+};
+
export type RuntimeHostControl = {
/** Build evidence while active. Finished evidence is read through its Result Repository. */
logs?(build: string, lines: number): Promise<import("@hypit/runtime").ExecutionLogView | undefined>;
@@ -105,6 +108,8 @@ export type RuntimeHostResultControl = {
};
export type RuntimeHostCredentialControl = {
+ /** Endpoint declarations and Store write capability; never reads an existing secret. */
+ describeCredentials(endpoint?: string): Promise<readonly RuntimeHostCredentialDescription[]>;
credentials(endpoint?: string): Promise<readonly RuntimeHostCredentialStatus[]>;
putCredential(endpoint: string, slot: string, secret: string): Promise<RuntimeHostCredentialStatus>;
deleteCredential(endpoint: string, slot: string): Promise<{
diff --git a/packages/runtime-local/README.md b/packages/runtime-local/README.md
index cb0d5202..87c2099c 100644
--- a/packages/runtime-local/README.md
+++ b/packages/runtime-local/README.md
@@ -258,3 +258,13 @@ capacity release and every completed Result. They use the production execution p
This is a load experiment rather than part of every package regression. It reports fixture preparation,
local progress, completion, executor RSS and cleanup separately; total test time also includes creating
and removing the temporary Result repositories. Neither suite uses a completion-time performance target.
+
+
+### Credential management without reading the old value
+
+`openCredentials(endpoint)` opens only the selected Endpoint's credential control.
+`describeCredentials(endpoint)` returns its declared slots and each Store's write capability without
+resolving secrets. `credentials(endpoint)` also reads current values to report status and propagates
+read failures. Login and logout use the former: a damaged old credential cannot prevent replacement
+or deletion. Successful writes and deletions report their operation's result without rereading the
+secret. Execution still resolves credentials normally and reports Store errors.
diff --git a/packages/runtime-local/src/credentials.ts b/packages/runtime-local/src/credentials.ts
index 53d1b57c..650133c0 100644
--- a/packages/runtime-local/src/credentials.ts
+++ b/packages/runtime-local/src/credentials.ts
@@ -28,16 +28,21 @@ export function createLocalCredentialControl(
: `Endpoint ${endpoint} repeats credential slot ${slot}`);
return matches[0]!;
};
- const status = async (item: typeof descriptions[number]) => ({
+ const describe = async (item: typeof descriptions[number]) => ({
...structuredClone(item),
- configured: await options.credentialStore.resolve(item.ref) !== undefined,
writable: await writableCredentialStore(options.credentialStore, item.ref) !== undefined,
});
return {
+ async describeCredentials(endpoint) {
+ return await Promise.all(descriptions.filter((item) => endpoint === undefined || item.endpoint === endpoint).map(describe));
+ },
async credentials(endpoint) {
const selected = descriptions.filter((item) => endpoint === undefined || item.endpoint === endpoint);
- return await Promise.all(selected.map(status));
+ return await Promise.all(selected.map(async (item) => ({
+ ...await describe(item),
+ configured: await options.credentialStore.resolve(item.ref) !== undefined,
+ })));
},
async putCredential(endpoint, slot, secret) {
assert(secret.length > 0, "credential secret is empty");
@@ -45,14 +50,14 @@ export function createLocalCredentialControl(
const store = await writableCredentialStore(options.credentialStore, item.ref);
assert(store !== undefined, `CredentialStore ${item.ref.store} is not writable`);
await store.put(item.ref, { secret });
- return await status(item);
+ return { ...structuredClone(item), writable: true, configured: true };
},
async deleteCredential(endpoint, slot) {
const item = credential(endpoint, slot);
const store = await writableCredentialStore(options.credentialStore, item.ref);
assert(store !== undefined, `CredentialStore ${item.ref.store} is not writable`);
const deleted = await store.delete(item.ref);
- return { deleted, credential: await status(item) };
+ return { deleted, credential: { ...structuredClone(item), writable: true, configured: false } };
},
close() {
return options.close?.();
diff --git a/packages/video-cli/README.md b/packages/video-cli/README.md
index 4853ee87..c846d6ea 100644
--- a/packages/video-cli/README.md
+++ b/packages/video-cli/README.md
@@ -34,7 +34,11 @@ an editable starter; its Endpoint entries describe available routes, not choices
Keep an existing chosen service, or configure the chosen local or hosted Provider and its capability
bindings. HypiHub is the recommended integrated hosted route in the official Distribution; other
services use project Provider packages. If the user chooses HypiHub,
-`hypit auth login hypihub.default` connects that account.
+`hypit auth login hypihub.default` connects that account after choosing its CredentialStore.
+The starter selects the OS store for macOS Keychain / Windows Credential Locker. On Linux, or when
+explicitly choosing file storage, edit the Profile's `credentials` and Endpoint reference as shown
+in [file CredentialStore](../credential-store-file/README.md#select-it-before-login) before `auth` or
+`runtime up`. This selection is configuration; execution never switches stores automatically.
`hypit doctor --endpoint <name>` checks a selected Endpoint;
`hypit runtime up --endpoint <name>` prepares that Endpoint and starts the Worker. Repeat the flag
for several chosen Endpoints; omitting it prepares the whole Profile. `hypit programs up --endpoint
diff --git a/packages/video-cli/package.json b/packages/video-cli/package.json
index 1524e8aa..bbec7c79 100644
--- a/packages/video-cli/package.json
+++ b/packages/video-cli/package.json
@@ -13,6 +13,7 @@
"@hypit/cli": "workspace:*",
"@hypit/compiler-markup-node": "workspace:*",
"@hypit/composition": "workspace:*",
+ "@hypit/credential-store-file": "workspace:*",
"@hypit/credential-store-os": "workspace:*",
"@hypit/driver-node": "workspace:*",
"@hypit/estimate": "workspace:*",
diff --git a/packages/video-cli/test/file-credentials.test.ts b/packages/video-cli/test/file-credentials.test.ts
new file mode 100644
index 00000000..620e54d6
--- /dev/null
+++ b/packages/video-cli/test/file-credentials.test.ts
@@ -0,0 +1,53 @@
+import assert from "node:assert/strict";
+import { execFile } from "node:child_process";
+import { mkdtemp, readFile, readdir, rm, writeFile } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import { fileURLToPath } from "node:url";
+import { promisify } from "node:util";
+import test from "node:test";
+
+const exec = promisify(execFile);
+const launcher = fileURLToPath(new URL("../../../bin/hypit.mjs", import.meta.url));
+
+test("an explicitly selected file Store supports CLI login, repair and logout without starting execution", async (t) => {
+ const root = await mkdtemp(join(tmpdir(), "hypit-cli-file-credentials-"));
+ t.after(() => rm(root, { recursive: true, force: true }));
+ const state = join(root, "host");
+ const run = (...args: string[]) => exec(process.execPath, [launcher, ...args, "--json"], {
+ cwd: root, env: { ...process.env, HYPIT_STATE_HOME: state }, timeout: 30_000, windowsHide: true,
+ });
+ await run("runtime", "init", "--workspace", root);
+ const profilePath = join(root, "hypit.runtime.json");
+ const profile = JSON.parse(await readFile(profilePath, "utf8"));
+ assert.equal(profile.credentials.os.use, "@hypit/credential-store-os", "initialization preserves the existing starter choice");
+ profile.credentials = { file: { use: "@hypit/credential-store-file" } };
+ profile.endpoints = { "hypihub.default": { ...profile.endpoints["hypihub.default"], config: {
+ ...profile.endpoints["hypihub.default"].config,
+ apiKey: { store: "file", key: "test.oauth" },
+ } } };
+ await writeFile(profilePath, JSON.stringify(profile));
+ const auth = (action: string, ...args: string[]) => run("auth", action, "hypihub.default", "--runtime", profilePath, ...args);
+ assert.equal(JSON.parse((await auth("status")).stdout).credentials[0].configured, false);
+ const input = join(root, "input.txt");
+ await writeFile(input, "test-secret-never-display");
+ await auth("login", "--from", input);
+ const status = (await auth("status")).stdout;
+ assert.equal(JSON.parse(status).credentials[0].configured, true);
+ assert.doesNotMatch(status, /test-secret-never-display/u);
+ const directory = join(state, "credentials");
+ const path = join(directory, (await readdir(directory))[0]!);
+ await writeFile(path, "corrupt-secret-never-display");
+ await assert.rejects(auth("status"), error => {
+ const output = String((error as { stdout?: string }).stdout);
+ assert.match(JSON.parse(output).error.message, /Cannot decode credential file/u);
+ assert.doesNotMatch(output, /corrupt-secret-never-display/u);
+ return true;
+ });
+ await auth("login", "--from", input);
+ assert.equal(JSON.parse((await auth("status")).stdout).credentials[0].configured, true);
+ await writeFile(path, "corrupt-again");
+ await auth("logout");
+ assert.equal(JSON.parse((await auth("status")).stdout).credentials[0].configured, false);
+ assert.deepEqual(await readdir(directory), []);
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 348b620d..9ae67447 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -87,6 +87,9 @@ importers:
'@hypit/credential-store-env':
specifier: workspace:*
version: link:packages/credential-store-env
+ '@hypit/credential-store-file':
+ specifier: workspace:*
+ version: link:packages/credential-store-file
'@hypit/credential-store-os':
specifier: workspace:*
version: link:packages/credential-store-os
@@ -748,6 +751,9 @@ importers:
'@hypit/run-markup':
specifier: workspace:*
version: link:../run-markup
+ '@hypit/runtime-local':
+ specifier: workspace:*
+ version: link:../runtime-local
'@hypit/workspace-fs-node':
specifier: workspace:*
version: link:../workspace-fs-node
@@ -942,6 +948,15 @@ importers:
specifier: workspace:*
version: link:../runtime-kit
+ packages/credential-store-file:
+ dependencies:
+ '@hypit/runtime':
+ specifier: workspace:*
+ version: link:../runtime
+ '@hypit/runtime-kit':
+ specifier: workspace:*
+ version: link:../runtime-kit
+
packages/credential-store-os:
dependencies:
'@hypit/runtime':
@@ -3343,6 +3358,9 @@ importers:
'@hypit/composition':
specifier: workspace:*
version: link:../composition
+ '@hypit/credential-store-file':
+ specifier: workspace:*
+ version: link:../credential-store-file
'@hypit/credential-store-os':
specifier: workspace:*
version: link:../credential-store-os
diff --git a/skills/hypit/references/environment/profile.md b/skills/hypit/references/environment/profile.md
index f521b350..bb09c57f 100644
--- a/skills/hypit/references/environment/profile.md
+++ b/skills/hypit/references/environment/profile.md
@@ -244,7 +244,16 @@ and project implementation; see [Build execution scope](../production/builds.md#
A Profile names a Credential Store and key; the secret stays in that store. The writable OS store
uses macOS Keychain or Windows Credential Locker. The environment store reads one explicitly named
-environment variable and is read-only.
+environment variable and is read-only. The writable file store is available for Linux or an explicit
+choice of local file storage; it stores unencrypted values outside the project, not in an OS locker.
+
+`runtime init` writes an editable starter that selects the OS store. Before `auth` or `runtime up`
+on Linux, explicitly change `credentials` to `{ "file": { "use": "@hypit/credential-store-file" } }`
+and change the selected Endpoint's credential reference to `{ "store": "file", "key": "<chosen-key>" }`.
+Preserve other Endpoint settings and bindings. Its default directory is `credentials` under the Host
+state root printed by `hypit paths`; an optional Store `config.path` chooses another private directory.
+On Windows, ensure that directory's ACL is private to the user. Preserve an existing Store choice;
+never switch or migrate credentials just because one Store could not read them.
Inspect one Endpoint's credential slots without revealing their values:
@@ -264,7 +273,9 @@ credential exists and the Provider's declared browser acquisition when present.
OAuth Endpoint, `auth login` opens that browser flow immediately; without a browser acquisition it
securely prompts for the secret. `--from <secret-file>` explicitly imports a secret instead of
opening OAuth. An Endpoint backed by the read-only environment store is configured in the Worker
-process environment instead.
+process environment instead. Login and logout use the declared slot and write capability without
+reading the old credential; a damaged stored value can therefore be replaced or removed. Status and
+execution still report read errors.
For example, after choosing HypiHub, `hypit auth login hypihub.default` uses its browser login;
`hypit auth login hypihub.default --from /private/path/hypihub-key.txt` instead stores a HypiHub API