UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

42 lines (41 loc) • 924 B
//#region packages/gateway-client/src/device-auth.ts function normalizeDeviceMetadataForAuth(e) { if (typeof e !== "string") return ""; return e.trim().replace(/[A-Z]/g, (e) => String.fromCharCode(e.charCodeAt(0) + 32)); } function buildDeviceAuthPayload(e) { const t = e.scopes.join(","); const n = e.token ?? ""; return [ "v2", e.deviceId, e.clientId, e.clientMode, e.role, t, String(e.signedAtMs), n, e.nonce ].join("|"); } function buildDeviceAuthPayloadV3(e) { const t = e.scopes.join(","); const n = e.token ?? ""; const r = normalizeDeviceMetadataForAuth(e.platform); const i = normalizeDeviceMetadataForAuth(e.deviceFamily); return [ "v3", e.deviceId, e.clientId, e.clientMode, e.role, t, String(e.signedAtMs), n, e.nonce, r, i ].join("|"); } //#endregion export { buildDeviceAuthPayloadV3 as n, normalizeDeviceMetadataForAuth as r, buildDeviceAuthPayload as t };