feat(FN-4749): complete Step 1 — normalize missing apiKey message
Fusion-Task-Id: FN-4749 Fusion-Task-Lineage: 4d1f47b6-1df7-4e1b-8c45-0c2d1d4957c3
This commit is contained in:
committed by
gsxdsm
parent
78402db294
commit
de71cafa13
@@ -3,6 +3,8 @@ import type { AuthMaterialSnapshot, NodeConfig, ProviderAuthEntry } from "@fusio
|
|||||||
import { ApiError } from "../api-error.js";
|
import { ApiError } from "../api-error.js";
|
||||||
import { getAuthFileCandidates, type StoredAuthProvider } from "../auth-paths.js";
|
import { getAuthFileCandidates, type StoredAuthProvider } from "../auth-paths.js";
|
||||||
|
|
||||||
|
export const MISSING_REMOTE_NODE_API_KEY_MESSAGE = "Remote node requires an apiKey for authenticated sync";
|
||||||
|
|
||||||
export async function readStoredAuthProvidersFromDisk(): Promise<Record<string, StoredAuthProvider>> {
|
export async function readStoredAuthProvidersFromDisk(): Promise<Record<string, StoredAuthProvider>> {
|
||||||
const merged: Record<string, StoredAuthProvider> = {};
|
const merged: Record<string, StoredAuthProvider> = {};
|
||||||
for (const authJsonPath of getAuthFileCandidates()) {
|
for (const authJsonPath of getAuthFileCandidates()) {
|
||||||
@@ -66,7 +68,7 @@ export async function fetchFromRemoteNode(
|
|||||||
|
|
||||||
// Validate node has apiKey (secure sync requires node authentication)
|
// Validate node has apiKey (secure sync requires node authentication)
|
||||||
if (!node.apiKey) {
|
if (!node.apiKey) {
|
||||||
throw new ApiError(400, "Remote node requires an apiKey for authenticated sync");
|
throw new ApiError(400, MISSING_REMOTE_NODE_API_KEY_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const method = options?.method ?? "GET";
|
const method = options?.method ?? "GET";
|
||||||
|
|||||||
@@ -2,7 +2,12 @@ import type { ProjectSettings } from "@fusion/core";
|
|||||||
import { basename } from "node:path";
|
import { basename } from "node:path";
|
||||||
import { ApiError, badRequest, notFound } from "../api-error.js";
|
import { ApiError, badRequest, notFound } from "../api-error.js";
|
||||||
import { getFusionAuthPath } from "../auth-paths.js";
|
import { getFusionAuthPath } from "../auth-paths.js";
|
||||||
import { fetchFromRemoteNode, readStoredAuthProvidersFromDisk, toProviderAuthEntries } from "./register-settings-sync-helpers.js";
|
import {
|
||||||
|
fetchFromRemoteNode,
|
||||||
|
MISSING_REMOTE_NODE_API_KEY_MESSAGE,
|
||||||
|
readStoredAuthProvidersFromDisk,
|
||||||
|
toProviderAuthEntries,
|
||||||
|
} from "./register-settings-sync-helpers.js";
|
||||||
import type { ApiRouteRegistrar } from "./types.js";
|
import type { ApiRouteRegistrar } from "./types.js";
|
||||||
|
|
||||||
function computeSettingsDiff(
|
function computeSettingsDiff(
|
||||||
@@ -347,7 +352,7 @@ export const registerSettingsSyncRoutes: ApiRouteRegistrar = (ctx) => {
|
|||||||
|
|
||||||
if (!node.apiKey) {
|
if (!node.apiKey) {
|
||||||
await central.close();
|
await central.close();
|
||||||
throw badRequest("Remote node requires an apiKey for auth sync");
|
throw badRequest(MISSING_REMOTE_NODE_API_KEY_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const direction = req.body?.direction ?? "push";
|
const direction = req.body?.direction ?? "push";
|
||||||
|
|||||||
Reference in New Issue
Block a user