aidimag 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -167,10 +167,13 @@ export function registerSyncCommands(program) {
|
|
|
167
167
|
const root = findRepoRoot();
|
|
168
168
|
if (!root)
|
|
169
169
|
fail("not inside a repo — run this command from a project directory");
|
|
170
|
-
const
|
|
170
|
+
const cfg = readCloudConfig(root);
|
|
171
|
+
const server = opts.server?.replace(/\/$/, "") ?? cfg?.server;
|
|
171
172
|
if (!server)
|
|
172
173
|
fail("no server: pass --server <url> or link the repo with `dim cloud link` first");
|
|
173
|
-
|
|
174
|
+
// Pass the brain so the approval page knows which project is requesting access
|
|
175
|
+
const requestedBrain = cfg?.brain;
|
|
176
|
+
const start = await startDeviceLogin(server, requestedBrain);
|
|
174
177
|
const approveUrl = `${start.verification_uri}?code=${encodeURIComponent(start.user_code)}`;
|
|
175
178
|
console.log(`\nTo approve this device, open:\n\n ${approveUrl}\n\nand confirm the code: ${start.user_code}\n`);
|
|
176
179
|
if (opts.open)
|
package/dist/sync/client.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export interface DeviceStart {
|
|
|
29
29
|
expires_in: number;
|
|
30
30
|
}
|
|
31
31
|
/** Begin a device-code login: server hands back a user code + approval URL. */
|
|
32
|
-
export declare function startDeviceLogin(server: string): Promise<DeviceStart>;
|
|
32
|
+
export declare function startDeviceLogin(server: string, brain?: string): Promise<DeviceStart>;
|
|
33
33
|
/** Poll until the device is approved in the browser. Returns the token (caller must save it). */
|
|
34
34
|
export declare function pollDeviceLogin(server: string, start: DeviceStart): Promise<{
|
|
35
35
|
token: string;
|
package/dist/sync/client.js
CHANGED
|
@@ -71,8 +71,12 @@ export function getToken(server, repoRoot) {
|
|
|
71
71
|
return null;
|
|
72
72
|
}
|
|
73
73
|
/** Begin a device-code login: server hands back a user code + approval URL. */
|
|
74
|
-
export async function startDeviceLogin(server) {
|
|
75
|
-
const res = await cloudFetch(server, `${server}/v1/auth/device`, {
|
|
74
|
+
export async function startDeviceLogin(server, brain) {
|
|
75
|
+
const res = await cloudFetch(server, `${server}/v1/auth/device`, {
|
|
76
|
+
method: "POST",
|
|
77
|
+
headers: { "Content-Type": "application/json" },
|
|
78
|
+
body: brain ? JSON.stringify({ brain }) : undefined,
|
|
79
|
+
});
|
|
76
80
|
if (!res.ok) {
|
|
77
81
|
throw new Error(res.status === 404
|
|
78
82
|
? `server does not support device login (upgrade it to this aidimag version)`
|