@wraps.dev/cli 2.21.18 → 2.21.19
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/api-lambda.zip
CHANGED
|
Binary file
|
package/dist/cli.js
CHANGED
|
@@ -10367,13 +10367,16 @@ init_events();
|
|
|
10367
10367
|
init_config();
|
|
10368
10368
|
init_json_output();
|
|
10369
10369
|
import * as clack2 from "@clack/prompts";
|
|
10370
|
+
import open from "open";
|
|
10371
|
+
import pc3 from "picocolors";
|
|
10372
|
+
|
|
10373
|
+
// src/utils/shared/auth-client.ts
|
|
10374
|
+
init_esm_shims();
|
|
10370
10375
|
import { createAuthClient } from "better-auth/client";
|
|
10371
10376
|
import {
|
|
10372
10377
|
deviceAuthorizationClient,
|
|
10373
10378
|
organizationClient
|
|
10374
10379
|
} from "better-auth/client/plugins";
|
|
10375
|
-
import open from "open";
|
|
10376
|
-
import pc3 from "picocolors";
|
|
10377
10380
|
function createCliAuthClient(baseURL) {
|
|
10378
10381
|
return createAuthClient({
|
|
10379
10382
|
baseURL,
|
|
@@ -10388,9 +10391,7 @@ async function fetchOrganizations(baseURL, token) {
|
|
|
10388
10391
|
headers: { Authorization: `Bearer ${token}` }
|
|
10389
10392
|
}
|
|
10390
10393
|
});
|
|
10391
|
-
if (!data)
|
|
10392
|
-
return [];
|
|
10393
|
-
}
|
|
10394
|
+
if (!data) return [];
|
|
10394
10395
|
return data.map((org) => ({
|
|
10395
10396
|
id: org.id,
|
|
10396
10397
|
name: org.name,
|
|
@@ -10400,6 +10401,8 @@ async function fetchOrganizations(baseURL, token) {
|
|
|
10400
10401
|
return [];
|
|
10401
10402
|
}
|
|
10402
10403
|
}
|
|
10404
|
+
|
|
10405
|
+
// src/commands/auth/login.ts
|
|
10403
10406
|
async function login(options) {
|
|
10404
10407
|
const startTime = Date.now();
|
|
10405
10408
|
if (options.token) {
|
|
@@ -34018,37 +34021,8 @@ init_metadata();
|
|
|
34018
34021
|
init_region_resolver();
|
|
34019
34022
|
init_aws();
|
|
34020
34023
|
import * as clack45 from "@clack/prompts";
|
|
34021
|
-
import { createAuthClient as createAuthClient2 } from "better-auth/client";
|
|
34022
|
-
import {
|
|
34023
|
-
deviceAuthorizationClient as deviceAuthorizationClient2,
|
|
34024
|
-
organizationClient as organizationClient2
|
|
34025
|
-
} from "better-auth/client/plugins";
|
|
34026
34024
|
import open2 from "open";
|
|
34027
34025
|
import pc48 from "picocolors";
|
|
34028
|
-
function createCliAuthClient2(baseURL) {
|
|
34029
|
-
return createAuthClient2({
|
|
34030
|
-
baseURL,
|
|
34031
|
-
plugins: [deviceAuthorizationClient2(), organizationClient2()]
|
|
34032
|
-
});
|
|
34033
|
-
}
|
|
34034
|
-
async function fetchOrganizations2(baseURL, token) {
|
|
34035
|
-
try {
|
|
34036
|
-
const client = createCliAuthClient2(baseURL);
|
|
34037
|
-
const { data } = await client.organization.list({
|
|
34038
|
-
fetchOptions: {
|
|
34039
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
34040
|
-
}
|
|
34041
|
-
});
|
|
34042
|
-
if (!data) return [];
|
|
34043
|
-
return data.map((org) => ({
|
|
34044
|
-
id: org.id,
|
|
34045
|
-
name: org.name,
|
|
34046
|
-
slug: org.slug
|
|
34047
|
-
}));
|
|
34048
|
-
} catch {
|
|
34049
|
-
return [];
|
|
34050
|
-
}
|
|
34051
|
-
}
|
|
34052
34026
|
async function selfhostLogin(options) {
|
|
34053
34027
|
const startTime = Date.now();
|
|
34054
34028
|
if (!isJsonMode()) {
|
|
@@ -34072,15 +34046,19 @@ Run ${pc48.cyan("wraps selfhost deploy")} to deploy the self-hosted control plan
|
|
|
34072
34046
|
process.exit(1);
|
|
34073
34047
|
return;
|
|
34074
34048
|
}
|
|
34075
|
-
const { appUrl } = metadata.services.selfhost.config;
|
|
34076
|
-
const baseURL = appUrl;
|
|
34049
|
+
const { appUrl: baseURL } = metadata.services.selfhost.config;
|
|
34077
34050
|
clack45.log.info(`Connecting to: ${pc48.cyan(baseURL)}`);
|
|
34078
|
-
const authClient =
|
|
34051
|
+
const authClient = createCliAuthClient(baseURL);
|
|
34079
34052
|
const spinner11 = clack45.spinner();
|
|
34080
34053
|
const { data: codeData, error: codeError } = await authClient.device.code({
|
|
34081
34054
|
client_id: "wraps-cli"
|
|
34082
34055
|
});
|
|
34083
34056
|
if (codeError || !codeData) {
|
|
34057
|
+
trackCommand("selfhost:login", {
|
|
34058
|
+
success: false,
|
|
34059
|
+
duration_ms: Date.now() - startTime,
|
|
34060
|
+
method: "device"
|
|
34061
|
+
});
|
|
34084
34062
|
trackError("DEVICE_AUTH_FAILED", "selfhost:login", {
|
|
34085
34063
|
step: "request_code"
|
|
34086
34064
|
});
|
|
@@ -34110,7 +34088,7 @@ Run ${pc48.cyan("wraps selfhost deploy")} to deploy the self-hosted control plan
|
|
|
34110
34088
|
});
|
|
34111
34089
|
if (tokenData?.access_token) {
|
|
34112
34090
|
spinner11.stop("Approved!");
|
|
34113
|
-
const organizations = await
|
|
34091
|
+
const organizations = await fetchOrganizations(
|
|
34114
34092
|
baseURL,
|
|
34115
34093
|
tokenData.access_token
|
|
34116
34094
|
);
|
|
@@ -34126,7 +34104,8 @@ Run ${pc48.cyan("wraps selfhost deploy")} to deploy the self-hosted control plan
|
|
|
34126
34104
|
});
|
|
34127
34105
|
trackCommand("selfhost:login", {
|
|
34128
34106
|
success: true,
|
|
34129
|
-
duration_ms: Date.now() - startTime
|
|
34107
|
+
duration_ms: Date.now() - startTime,
|
|
34108
|
+
method: "device"
|
|
34130
34109
|
});
|
|
34131
34110
|
clack45.log.success("Signed in to your self-hosted Wraps instance.");
|
|
34132
34111
|
if (organizations.length === 1) {
|
|
@@ -34154,6 +34133,11 @@ Run ${pc48.cyan("wraps selfhost deploy")} to deploy the self-hosted control plan
|
|
|
34154
34133
|
continue;
|
|
34155
34134
|
}
|
|
34156
34135
|
if (errorCode === "access_denied") {
|
|
34136
|
+
trackCommand("selfhost:login", {
|
|
34137
|
+
success: false,
|
|
34138
|
+
duration_ms: Date.now() - startTime,
|
|
34139
|
+
method: "device"
|
|
34140
|
+
});
|
|
34157
34141
|
trackError("ACCESS_DENIED", "selfhost:login", { step: "poll_token" });
|
|
34158
34142
|
spinner11.stop("Denied.");
|
|
34159
34143
|
clack45.log.error("Authorization was denied.");
|
|
@@ -34162,6 +34146,11 @@ Run ${pc48.cyan("wraps selfhost deploy")} to deploy the self-hosted control plan
|
|
|
34162
34146
|
if (errorCode === "expired_token") break;
|
|
34163
34147
|
}
|
|
34164
34148
|
}
|
|
34149
|
+
trackCommand("selfhost:login", {
|
|
34150
|
+
success: false,
|
|
34151
|
+
duration_ms: Date.now() - startTime,
|
|
34152
|
+
method: "device"
|
|
34153
|
+
});
|
|
34165
34154
|
trackError("DEVICE_CODE_EXPIRED", "selfhost:login", { step: "poll_token" });
|
|
34166
34155
|
spinner11.stop("Expired.");
|
|
34167
34156
|
clack45.log.error(
|