Replace NodeJS dict aliases with maps and named field reads
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { webcrypto } from "node:crypto";
|
||||
|
||||
import { isMapping } from "#common";
|
||||
import { field, isMapping } from "#common";
|
||||
import type { BotProfile } from "#profiles";
|
||||
|
||||
interface DefaultModels {
|
||||
@@ -80,7 +80,9 @@ async function parseProfile(entry: unknown, index: number, masterKey: string): P
|
||||
throw new Error(`${at}.${key}: unknown field`);
|
||||
}
|
||||
}
|
||||
const { type, model, token } = entry;
|
||||
const type = field(entry, "type");
|
||||
const model = field(entry, "model");
|
||||
const token = field(entry, "token");
|
||||
if (type !== "claude" && type !== "codex" && type !== "opencode") {
|
||||
throw new Error(`${at}.type: expected "claude", "codex", or "opencode"`);
|
||||
}
|
||||
@@ -112,7 +114,8 @@ export async function parseCredentials(text: string, masterKey: string): Promise
|
||||
throw new Error(`${key}: unknown field`);
|
||||
}
|
||||
}
|
||||
const { "reviewer-token": reviewerToken, profiles } = value;
|
||||
const reviewerToken = field(value, "reviewer-token");
|
||||
const profiles = field(value, "profiles");
|
||||
if (typeof reviewerToken !== "string") {
|
||||
throw new TypeError("reviewer-token: expected an encrypted credential");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user