@youkno/edge-cli 1.20.2338 → 1.20.2340
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 +0 -1
- package/dist/commands/config.js +0 -1
- package/dist/index.js +0 -1
- package/dist/lib/auth.js +0 -15
- package/dist/lib/config.js +1 -2
- package/package.json +1 -1
- package/src/commands/config.ts +0 -1
- package/src/index.ts +0 -1
- package/src/lib/auth.ts +0 -18
- package/src/lib/config.ts +1 -2
- package/src/lib/types.ts +0 -2
package/README.md
CHANGED
package/dist/commands/config.js
CHANGED
|
@@ -19,7 +19,6 @@ function registerConfig(program) {
|
|
|
19
19
|
process.stdout.write(`env=${resolved.env}\n`);
|
|
20
20
|
process.stdout.write(`baseUrl=${resolved.baseUrl}\n`);
|
|
21
21
|
process.stdout.write(`clientId=${resolved.clientId ?? ""}\n`);
|
|
22
|
-
process.stdout.write(`auth=${resolved.auth ? "<configured>" : ""}\n`);
|
|
23
22
|
process.stdout.write(`configFiles=${resolved.configFiles.join(",") || "<none>"}\n`);
|
|
24
23
|
});
|
|
25
24
|
}
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,6 @@ program
|
|
|
18
18
|
.option("--env <env>", "Environment (devlocal|devel|prod)", "prod")
|
|
19
19
|
.option("--base-url <url>", "Override API base URL")
|
|
20
20
|
.option("--client <clientId>", "Client ID")
|
|
21
|
-
.option("--auth <token:secret>", "Client auth token")
|
|
22
21
|
.option("--config-path <path>", "Additional edge-api style config file")
|
|
23
22
|
.hook("preAction", (command) => {
|
|
24
23
|
const env = command.opts().env;
|
package/dist/lib/auth.js
CHANGED
|
@@ -9,7 +9,6 @@ exports.logout = logout;
|
|
|
9
9
|
exports.login = login;
|
|
10
10
|
exports.resolveAccessToken = resolveAccessToken;
|
|
11
11
|
exports.resolveAuthHeader = resolveAuthHeader;
|
|
12
|
-
exports.getAuthHeaderFromOverride = getAuthHeaderFromOverride;
|
|
13
12
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
14
13
|
const node_os_1 = __importDefault(require("node:os"));
|
|
15
14
|
const node_path_1 = __importDefault(require("node:path"));
|
|
@@ -107,12 +106,6 @@ function extractEmailFromToken(accessToken) {
|
|
|
107
106
|
}
|
|
108
107
|
return "unknown@local";
|
|
109
108
|
}
|
|
110
|
-
function getAuthHeaderFromOverride(auth) {
|
|
111
|
-
if (!auth) {
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
return `Basic ${Buffer.from(auth).toString("base64")}`;
|
|
115
|
-
}
|
|
116
109
|
async function requestTokenEndpoint(cfg, endpoint, payload) {
|
|
117
110
|
const url = `${cfg.baseUrl.replace(/\/$/, "")}/api/v1/auth/${endpoint}`;
|
|
118
111
|
const response = await fetch(url, {
|
|
@@ -399,10 +392,6 @@ async function refreshDefaultToken(cfg) {
|
|
|
399
392
|
return merged.accessToken;
|
|
400
393
|
}
|
|
401
394
|
async function resolveAccessToken(cfg, forceRefresh = false) {
|
|
402
|
-
const override = getAuthHeaderFromOverride(cfg.auth);
|
|
403
|
-
if (override) {
|
|
404
|
-
throw new Error("Cannot derive JWT token when --auth basic credentials are used.");
|
|
405
|
-
}
|
|
406
395
|
const db = readDb();
|
|
407
396
|
const scope = getScope(db, cfg);
|
|
408
397
|
const email = scope.default;
|
|
@@ -442,10 +431,6 @@ async function resolveAccessToken(cfg, forceRefresh = false) {
|
|
|
442
431
|
return accessToken;
|
|
443
432
|
}
|
|
444
433
|
async function resolveAuthHeader(cfg) {
|
|
445
|
-
const override = getAuthHeaderFromOverride(cfg.auth);
|
|
446
|
-
if (override) {
|
|
447
|
-
return override;
|
|
448
|
-
}
|
|
449
434
|
const accessToken = await resolveAccessToken(cfg);
|
|
450
435
|
return `Bearer ${accessToken}`;
|
|
451
436
|
}
|
package/dist/lib/config.js
CHANGED
|
@@ -12,7 +12,7 @@ const promises_1 = __importDefault(require("node:readline/promises"));
|
|
|
12
12
|
const default_edge_api_config_json_1 = __importDefault(require("../default-edge-api-config.json"));
|
|
13
13
|
const EDGE_API_CONFIG_URL = "https://cdn.youkno.ai/tools/edge-api-config.json";
|
|
14
14
|
const DEFAULT_EDGE_API_PATH = node_path_1.default.join(node_os_1.default.homedir(), ".edge-api");
|
|
15
|
-
const FILE_KEYS = ["PRODUCT", "ENV", "BASE_URL", "CLIENT_ID"
|
|
15
|
+
const FILE_KEYS = ["PRODUCT", "ENV", "BASE_URL", "CLIENT_ID"];
|
|
16
16
|
function expandPath(inputPath) {
|
|
17
17
|
if (inputPath.startsWith("~/")) {
|
|
18
18
|
return node_path_1.default.join(node_os_1.default.homedir(), inputPath.slice(2));
|
|
@@ -196,7 +196,6 @@ async function resolveEffectiveConfig(options) {
|
|
|
196
196
|
baseUrl,
|
|
197
197
|
consoleBaseUrl: resolveConsoleBaseUrl(product, env, productsConfig),
|
|
198
198
|
clientId: options.clientId ?? merged.CLIENT_ID,
|
|
199
|
-
auth: options.auth ?? merged.CLIENT_AUTH,
|
|
200
199
|
configFiles: usedFiles
|
|
201
200
|
};
|
|
202
201
|
}
|
package/package.json
CHANGED
package/src/commands/config.ts
CHANGED
|
@@ -22,7 +22,6 @@ export function registerConfig(program: Command): void {
|
|
|
22
22
|
process.stdout.write(`env=${resolved.env}\n`);
|
|
23
23
|
process.stdout.write(`baseUrl=${resolved.baseUrl}\n`);
|
|
24
24
|
process.stdout.write(`clientId=${resolved.clientId ?? ""}\n`);
|
|
25
|
-
process.stdout.write(`auth=${resolved.auth ? "<configured>" : ""}\n`);
|
|
26
25
|
process.stdout.write(`configFiles=${resolved.configFiles.join(",") || "<none>"}\n`);
|
|
27
26
|
});
|
|
28
27
|
}
|
package/src/index.ts
CHANGED
|
@@ -21,7 +21,6 @@ program
|
|
|
21
21
|
.option("--env <env>", "Environment (devlocal|devel|prod)", "prod")
|
|
22
22
|
.option("--base-url <url>", "Override API base URL")
|
|
23
23
|
.option("--client <clientId>", "Client ID")
|
|
24
|
-
.option("--auth <token:secret>", "Client auth token")
|
|
25
24
|
.option("--config-path <path>", "Additional edge-api style config file")
|
|
26
25
|
.hook("preAction", (command) => {
|
|
27
26
|
const env = command.opts().env as string;
|
package/src/lib/auth.ts
CHANGED
|
@@ -132,13 +132,6 @@ function extractEmailFromToken(accessToken: string): string {
|
|
|
132
132
|
return "unknown@local";
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
function getAuthHeaderFromOverride(auth?: string): string | undefined {
|
|
136
|
-
if (!auth) {
|
|
137
|
-
return undefined;
|
|
138
|
-
}
|
|
139
|
-
return `Basic ${Buffer.from(auth).toString("base64")}`;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
135
|
async function requestTokenEndpoint(
|
|
143
136
|
cfg: EffectiveConfig,
|
|
144
137
|
endpoint: "exchange" | "refresh" | "logout",
|
|
@@ -467,11 +460,6 @@ async function refreshDefaultToken(cfg: EffectiveConfig): Promise<string | undef
|
|
|
467
460
|
}
|
|
468
461
|
|
|
469
462
|
export async function resolveAccessToken(cfg: EffectiveConfig, forceRefresh = false): Promise<string> {
|
|
470
|
-
const override = getAuthHeaderFromOverride(cfg.auth);
|
|
471
|
-
if (override) {
|
|
472
|
-
throw new Error("Cannot derive JWT token when --auth basic credentials are used.");
|
|
473
|
-
}
|
|
474
|
-
|
|
475
463
|
const db = readDb();
|
|
476
464
|
const scope = getScope(db, cfg);
|
|
477
465
|
const email = scope.default;
|
|
@@ -516,12 +504,6 @@ export async function resolveAccessToken(cfg: EffectiveConfig, forceRefresh = fa
|
|
|
516
504
|
}
|
|
517
505
|
|
|
518
506
|
export async function resolveAuthHeader(cfg: EffectiveConfig): Promise<string> {
|
|
519
|
-
const override = getAuthHeaderFromOverride(cfg.auth);
|
|
520
|
-
if (override) {
|
|
521
|
-
return override;
|
|
522
|
-
}
|
|
523
507
|
const accessToken = await resolveAccessToken(cfg);
|
|
524
508
|
return `Bearer ${accessToken}`;
|
|
525
509
|
}
|
|
526
|
-
|
|
527
|
-
export { getAuthHeaderFromOverride };
|
package/src/lib/config.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { CliEnv, CliOptions, EdgeApiConfig, EffectiveConfig, ProductConfig } fro
|
|
|
9
9
|
const EDGE_API_CONFIG_URL = "https://cdn.youkno.ai/tools/edge-api-config.json";
|
|
10
10
|
const DEFAULT_EDGE_API_PATH = path.join(os.homedir(), ".edge-api");
|
|
11
11
|
|
|
12
|
-
const FILE_KEYS = ["PRODUCT", "ENV", "BASE_URL", "CLIENT_ID"
|
|
12
|
+
const FILE_KEYS = ["PRODUCT", "ENV", "BASE_URL", "CLIENT_ID"] as const;
|
|
13
13
|
|
|
14
14
|
type EdgeApiFileConfig = Partial<Record<(typeof FILE_KEYS)[number], string>>;
|
|
15
15
|
|
|
@@ -229,7 +229,6 @@ export async function resolveEffectiveConfig(options: CliOptions): Promise<Effec
|
|
|
229
229
|
baseUrl,
|
|
230
230
|
consoleBaseUrl: resolveConsoleBaseUrl(product, env, productsConfig),
|
|
231
231
|
clientId: options.clientId ?? merged.CLIENT_ID,
|
|
232
|
-
auth: options.auth ?? merged.CLIENT_AUTH,
|
|
233
232
|
configFiles: usedFiles
|
|
234
233
|
};
|
|
235
234
|
}
|
package/src/lib/types.ts
CHANGED
|
@@ -5,7 +5,6 @@ export type CliOptions = {
|
|
|
5
5
|
env?: CliEnv;
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
clientId?: string;
|
|
8
|
-
auth?: string;
|
|
9
8
|
configPath?: string;
|
|
10
9
|
};
|
|
11
10
|
|
|
@@ -30,6 +29,5 @@ export type EffectiveConfig = {
|
|
|
30
29
|
baseUrl: string;
|
|
31
30
|
consoleBaseUrl?: string;
|
|
32
31
|
clientId?: string;
|
|
33
|
-
auth?: string;
|
|
34
32
|
configFiles: string[];
|
|
35
33
|
};
|