@gradual-so/cli 0.1.0 → 0.1.2
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.
- package/dist/index.js +36 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3690,7 +3690,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
3690
3690
|
emitter.on(ev, cb);
|
|
3691
3691
|
return remove;
|
|
3692
3692
|
};
|
|
3693
|
-
unload = function
|
|
3693
|
+
unload = function unload2() {
|
|
3694
3694
|
if (!loaded || !processOk(global.process)) {
|
|
3695
3695
|
return;
|
|
3696
3696
|
}
|
|
@@ -3705,7 +3705,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
3705
3705
|
emitter.count -= 1;
|
|
3706
3706
|
};
|
|
3707
3707
|
module.exports.unload = unload;
|
|
3708
|
-
emit = function
|
|
3708
|
+
emit = function emit2(event, code, signal) {
|
|
3709
3709
|
if (emitter.emitted[event]) {
|
|
3710
3710
|
return;
|
|
3711
3711
|
}
|
|
@@ -3734,7 +3734,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
3734
3734
|
return signals;
|
|
3735
3735
|
};
|
|
3736
3736
|
loaded = false;
|
|
3737
|
-
load = function
|
|
3737
|
+
load = function load2() {
|
|
3738
3738
|
if (loaded || !processOk(global.process)) {
|
|
3739
3739
|
return;
|
|
3740
3740
|
}
|
|
@@ -3753,7 +3753,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
3753
3753
|
};
|
|
3754
3754
|
module.exports.load = load;
|
|
3755
3755
|
originalProcessReallyExit = process2.reallyExit;
|
|
3756
|
-
processReallyExit = function
|
|
3756
|
+
processReallyExit = function processReallyExit2(code) {
|
|
3757
3757
|
if (!processOk(global.process)) {
|
|
3758
3758
|
return;
|
|
3759
3759
|
}
|
|
@@ -3763,7 +3763,7 @@ var require_signal_exit = __commonJS((exports, module) => {
|
|
|
3763
3763
|
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
3764
3764
|
};
|
|
3765
3765
|
originalProcessEmit = process2.emit;
|
|
3766
|
-
processEmit = function
|
|
3766
|
+
processEmit = function processEmit2(ev, arg) {
|
|
3767
3767
|
if (ev === "exit" && processOk(global.process)) {
|
|
3768
3768
|
if (arg !== undefined) {
|
|
3769
3769
|
process2.exitCode = arg;
|
|
@@ -7308,12 +7308,12 @@ var require_wcwidth = __commonJS((exports, module) => {
|
|
|
7308
7308
|
nul: 0,
|
|
7309
7309
|
control: 0
|
|
7310
7310
|
};
|
|
7311
|
-
module.exports = function
|
|
7311
|
+
module.exports = function wcwidth2(str) {
|
|
7312
7312
|
return wcswidth(str, DEFAULTS);
|
|
7313
7313
|
};
|
|
7314
7314
|
module.exports.config = function(opts) {
|
|
7315
7315
|
opts = defaults(opts || {}, DEFAULTS);
|
|
7316
|
-
return function
|
|
7316
|
+
return function wcwidth2(str) {
|
|
7317
7317
|
return wcswidth(str, opts);
|
|
7318
7318
|
};
|
|
7319
7319
|
};
|
|
@@ -20489,7 +20489,7 @@ var effectScheduler = {
|
|
|
20489
20489
|
// ../../node_modules/@inquirer/core/dist/esm/lib/use-state.js
|
|
20490
20490
|
function useState(defaultValue) {
|
|
20491
20491
|
return withPointer((pointer) => {
|
|
20492
|
-
const setState = AsyncResource2.bind(function
|
|
20492
|
+
const setState = AsyncResource2.bind(function setState2(newValue) {
|
|
20493
20493
|
if (pointer.get() !== newValue) {
|
|
20494
20494
|
pointer.set(newValue);
|
|
20495
20495
|
handleChange();
|
|
@@ -22189,11 +22189,11 @@ function sleep(ms) {
|
|
|
22189
22189
|
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
22190
22190
|
}
|
|
22191
22191
|
async function deviceLogin(dashboardUrl) {
|
|
22192
|
-
const codeResponse = await fetch(`${dashboardUrl}/api/auth/device/
|
|
22192
|
+
const codeResponse = await fetch(`${dashboardUrl}/api/auth/device/code`, {
|
|
22193
22193
|
method: "POST",
|
|
22194
22194
|
headers: { "Content-Type": "application/json" },
|
|
22195
22195
|
body: JSON.stringify({
|
|
22196
|
-
|
|
22196
|
+
client_id: "gradual-cli"
|
|
22197
22197
|
})
|
|
22198
22198
|
});
|
|
22199
22199
|
if (!codeResponse.ok) {
|
|
@@ -22202,25 +22202,40 @@ async function deviceLogin(dashboardUrl) {
|
|
|
22202
22202
|
}
|
|
22203
22203
|
const codeData = await codeResponse.json();
|
|
22204
22204
|
console.log();
|
|
22205
|
-
console.log(` Your authorization code: ${source_default.bold.cyan(codeData.
|
|
22205
|
+
console.log(` Your authorization code: ${source_default.bold.cyan(codeData.user_code)}`);
|
|
22206
22206
|
console.log();
|
|
22207
22207
|
console.log(` ${source_default.dim("Opening browser to verify...")}`);
|
|
22208
22208
|
console.log();
|
|
22209
|
-
await open_default(codeData.
|
|
22209
|
+
await open_default(codeData.verification_uri_complete || codeData.verification_uri);
|
|
22210
22210
|
let pollInterval = codeData.interval * 1000;
|
|
22211
|
-
const deadline = Date.now() + codeData.
|
|
22211
|
+
const deadline = Date.now() + codeData.expires_in * 1000;
|
|
22212
22212
|
while (Date.now() < deadline) {
|
|
22213
22213
|
await sleep(pollInterval);
|
|
22214
|
-
const tokenResponse = await fetch(`${dashboardUrl}/api/auth/device/
|
|
22214
|
+
const tokenResponse = await fetch(`${dashboardUrl}/api/auth/device/token`, {
|
|
22215
22215
|
method: "POST",
|
|
22216
22216
|
headers: { "Content-Type": "application/json" },
|
|
22217
22217
|
body: JSON.stringify({
|
|
22218
|
-
|
|
22219
|
-
|
|
22218
|
+
grant_type: "urn:ietf:params:oauth:grant-type:device_code",
|
|
22219
|
+
device_code: codeData.device_code,
|
|
22220
|
+
client_id: "gradual-cli"
|
|
22220
22221
|
})
|
|
22221
22222
|
});
|
|
22222
22223
|
if (tokenResponse.ok) {
|
|
22223
|
-
|
|
22224
|
+
const tokenData = await tokenResponse.json();
|
|
22225
|
+
const sessionResponse = await fetch(`${dashboardUrl}/api/auth/get-session`, {
|
|
22226
|
+
headers: {
|
|
22227
|
+
Authorization: `Bearer ${tokenData.access_token}`
|
|
22228
|
+
}
|
|
22229
|
+
});
|
|
22230
|
+
if (!sessionResponse.ok) {
|
|
22231
|
+
throw new Error("Failed to fetch session after authorization");
|
|
22232
|
+
}
|
|
22233
|
+
const session = await sessionResponse.json();
|
|
22234
|
+
return {
|
|
22235
|
+
token: tokenData.access_token,
|
|
22236
|
+
expiresAt: session.session.expiresAt,
|
|
22237
|
+
user: session.user
|
|
22238
|
+
};
|
|
22224
22239
|
}
|
|
22225
22240
|
const error2 = await tokenResponse.json();
|
|
22226
22241
|
if (error2.error === "authorization_pending") {
|
|
@@ -22230,10 +22245,13 @@ async function deviceLogin(dashboardUrl) {
|
|
|
22230
22245
|
pollInterval += 5000;
|
|
22231
22246
|
continue;
|
|
22232
22247
|
}
|
|
22248
|
+
if (error2.error === "access_denied") {
|
|
22249
|
+
throw new Error("Authorization was denied.");
|
|
22250
|
+
}
|
|
22233
22251
|
if (error2.error === "expired_token") {
|
|
22234
22252
|
throw new Error("Device code expired. Please try again.");
|
|
22235
22253
|
}
|
|
22236
|
-
throw new Error(error2.
|
|
22254
|
+
throw new Error(error2.error_description ?? error2.error ?? "Device authorization failed");
|
|
22237
22255
|
}
|
|
22238
22256
|
throw new Error("Device code expired. Please try again.");
|
|
22239
22257
|
}
|