openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
116 lines (115 loc) • 3.68 kB
TypeScript
import { n as GatewayClientName, t as GatewayClientMode } from "./client-info-CgGSgtDZ.js";
import { a as EventFrame, o as HelloOk } from "./schema-CLIlcFpU.js";
//#region src/infra/device-identity.d.ts
/** Gateway/device Ed25519 identity used for APNs relay and gateway authentication. */
type DeviceIdentity = {
deviceId: string;
publicKeyPem: string;
privateKeyPem: string;
};
//#endregion
//#region src/gateway/client.d.ts
type DeviceAuthTokenRecord = {
token?: string;
scopes?: string[];
};
type GatewayClientHostDeps = {
loadOrCreateDeviceIdentity?: () => DeviceIdentity | undefined;
signDevicePayload?: (privateKeyPem: string, payload: string) => string;
publicKeyRawBase64UrlFromPem?: (publicKeyPem: string) => string;
loadDeviceAuthToken?: (params: {
deviceId: string;
role: string;
env?: NodeJS.ProcessEnv;
}) => DeviceAuthTokenRecord | null;
storeDeviceAuthToken?: (params: {
deviceId: string;
role: string;
token: string;
scopes: string[];
env?: NodeJS.ProcessEnv;
}) => void;
clearDeviceAuthToken?: (params: {
deviceId: string;
role: string;
env?: NodeJS.ProcessEnv;
}) => void;
beforeConnect?: () => void;
registerGatewayLoopbackBypass?: (url: string) => (() => void) | undefined;
logDebug?: (message: string) => void;
logError?: (message: string) => void;
redactForLog?: (message: string) => string;
normalizeTlsFingerprint?: (fingerprint: string | undefined) => string;
};
type GatewayClientRequestOptions = {
expectFinal?: boolean;
timeoutMs?: number | null;
signal?: AbortSignal;
onAccepted?: (payload: unknown) => void;
};
type GatewayReconnectPausedInfo = {
code: number;
reason: string;
detailCode: string | null;
};
type GatewayClientOptions = {
url?: string;
connectChallengeTimeoutMs?: number; /** @deprecated Use connectChallengeTimeoutMs. */
connectDelayMs?: number;
preauthHandshakeTimeoutMs?: number;
tickWatchMinIntervalMs?: number;
tickWatchTimeoutMs?: number;
requestTimeoutMs?: number;
token?: string;
bootstrapToken?: string;
deviceToken?: string;
password?: string;
approvalRuntimeToken?: string;
instanceId?: string;
clientName?: GatewayClientName;
clientDisplayName?: string;
clientVersion?: string;
platform?: string;
deviceFamily?: string;
mode?: GatewayClientMode;
role?: string;
scopes?: string[];
caps?: string[];
commands?: string[];
permissions?: Record<string, boolean>;
pathEnv?: string;
env?: NodeJS.ProcessEnv;
deviceIdentity?: DeviceIdentity | null;
hostDeps?: GatewayClientHostDeps;
minProtocol?: number;
maxProtocol?: number;
tlsFingerprint?: string;
onEvent?: (evt: EventFrame) => void;
onHelloOk?: (hello: HelloOk) => void;
onConnectError?: (err: Error) => void;
onReconnectPaused?: (info: GatewayReconnectPausedInfo) => void;
onClose?: (code: number, reason: string) => void;
onGap?: (info: {
expected: number;
received: number;
}) => void;
};
type GatewayClientConnectionMetadata = {
clientName?: GatewayClientName;
hasDeviceIdentity: boolean;
mode?: GatewayClientMode;
preauthHandshakeTimeoutMs?: number;
};
declare class GatewayClient {
#private;
constructor(opts: GatewayClientOptions);
start(): void;
stop(): void;
stopAndWait(opts?: {
timeoutMs?: number;
}): Promise<void>;
request<T = Record<string, unknown>>(method: string, params?: unknown, opts?: GatewayClientRequestOptions): Promise<T>;
getConnectionMetadata(): GatewayClientConnectionMetadata;
}
//#endregion
export { DeviceIdentity as a, GatewayReconnectPausedInfo as i, GatewayClientOptions as n, GatewayClientRequestOptions as r, GatewayClient as t };