mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 07:30:21 +00:00
refactor: dedupe oauth tls record helper
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import path from "node:path";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { asNullableObjectRecord } from "../shared/record-coerce.js";
|
||||
import { note } from "../terminal/note.js";
|
||||
|
||||
const TLS_CERT_ERROR_CODES = new Set([
|
||||
@@ -33,17 +34,13 @@ export type OpenAIOAuthTlsPreflightResult =
|
||||
message: string;
|
||||
};
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | null {
|
||||
return value && typeof value === "object" ? (value as Record<string, unknown>) : null;
|
||||
}
|
||||
|
||||
function extractFailure(error: unknown): {
|
||||
code?: string;
|
||||
message: string;
|
||||
kind: PreflightFailureKind;
|
||||
} {
|
||||
const root = asRecord(error);
|
||||
const rootCause = asRecord(root?.cause);
|
||||
const root = asNullableObjectRecord(error);
|
||||
const rootCause = asNullableObjectRecord(root?.cause);
|
||||
const code = typeof rootCause?.code === "string" ? rootCause.code : undefined;
|
||||
const message =
|
||||
typeof rootCause?.message === "string"
|
||||
|
||||
@@ -7,3 +7,7 @@ export function asRecord(value: unknown): Record<string, unknown> {
|
||||
export function asNullableRecord(value: unknown): Record<string, unknown> | null {
|
||||
return isRecord(value) ? value : null;
|
||||
}
|
||||
|
||||
export function asNullableObjectRecord(value: unknown): Record<string, unknown> | null {
|
||||
return value && typeof value === "object" ? (value as Record<string, unknown>) : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user