Files
openclaw/src/shared/device-auth.ts
2026-02-15 04:22:44 +00:00

31 lines
633 B
TypeScript

export type DeviceAuthEntry = {
token: string;
role: string;
scopes: string[];
updatedAtMs: number;
};
export type DeviceAuthStore = {
version: 1;
deviceId: string;
tokens: Record<string, DeviceAuthEntry>;
};
export function normalizeDeviceAuthRole(role: string): string {
return role.trim();
}
export function normalizeDeviceAuthScopes(scopes: string[] | undefined): string[] {
if (!Array.isArray(scopes)) {
return [];
}
const out = new Set<string>();
for (const scope of scopes) {
const trimmed = scope.trim();
if (trimmed) {
out.add(trimmed);
}
}
return [...out].toSorted();
}