fix: bind bootstrap setup codes to node profile

This commit is contained in:
Peter Steinberger
2026-03-22 23:55:10 -07:00
parent 4580d585ff
commit a600c72ed7
8 changed files with 117 additions and 9 deletions

View File

@@ -149,6 +149,10 @@ describe("device-pair /pair qr", () => {
const text = requireText(result);
expect(pluginApiMocks.renderQrPngBase64).toHaveBeenCalledTimes(1);
expect(pluginApiMocks.issueDeviceBootstrapToken).toHaveBeenCalledWith({
roles: ["node"],
scopes: [],
});
expect(text).toContain("Scan this QR code with the OpenClaw iOS app:");
expect(text).toContain("![OpenClaw pairing QR](data:image/png;base64,ZmFrZXBuZw==)");
expect(text).toContain("- Security: single-use bootstrap token");

View File

@@ -43,6 +43,8 @@ function formatDurationMinutes(expiresAtMs: number): string {
}
const DEFAULT_GATEWAY_PORT = 18789;
const SETUP_CODE_ROLES = ["node"] as const;
const SETUP_CODE_SCOPES: string[] = [];
type DevicePairPluginConfig = {
publicUrl?: string;
@@ -515,7 +517,10 @@ function resolveQrReplyTarget(ctx: QrCommandContext): string {
}
async function issueSetupPayload(url: string): Promise<SetupPayload> {
const issuedBootstrap = await issueDeviceBootstrapToken();
const issuedBootstrap = await issueDeviceBootstrapToken({
roles: SETUP_CODE_ROLES,
scopes: SETUP_CODE_SCOPES,
});
return {
url,
bootstrapToken: issuedBootstrap.token,