@base44-preview/cli 0.0.54-pr.537.21faea5 → 0.0.54-pr.537.391d6bc
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/cli/index.js +17 -19
- package/dist/cli/index.js.map +8 -8
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -235165,27 +235165,28 @@ function decodeJwtClaims(token) {
|
|
|
235165
235165
|
return null;
|
|
235166
235166
|
}
|
|
235167
235167
|
}
|
|
235168
|
-
function
|
|
235168
|
+
async function seedAuthFromEnv() {
|
|
235169
235169
|
const accessToken = process.env.BASE44_ACCESS_TOKEN;
|
|
235170
235170
|
if (!accessToken) {
|
|
235171
|
-
return
|
|
235171
|
+
return false;
|
|
235172
235172
|
}
|
|
235173
|
+
const refreshToken = process.env.BASE44_REFRESH_TOKEN;
|
|
235173
235174
|
const claims = decodeJwtClaims(accessToken);
|
|
235174
|
-
const sub = typeof claims?.sub === "string" ? claims.sub :
|
|
235175
|
-
const exp = typeof claims?.exp === "number" ? claims.exp :
|
|
235176
|
-
|
|
235175
|
+
const sub = typeof claims?.sub === "string" ? claims.sub : undefined;
|
|
235176
|
+
const exp = typeof claims?.exp === "number" ? claims.exp : undefined;
|
|
235177
|
+
if (!refreshToken || !sub || !exp) {
|
|
235178
|
+
return false;
|
|
235179
|
+
}
|
|
235180
|
+
await writeAuth({
|
|
235177
235181
|
accessToken,
|
|
235178
|
-
refreshToken
|
|
235179
|
-
expiresAt: exp
|
|
235182
|
+
refreshToken,
|
|
235183
|
+
expiresAt: exp * 1000,
|
|
235180
235184
|
email: sub,
|
|
235181
|
-
name:
|
|
235182
|
-
};
|
|
235185
|
+
name: sub
|
|
235186
|
+
});
|
|
235187
|
+
return true;
|
|
235183
235188
|
}
|
|
235184
235189
|
async function readAuth() {
|
|
235185
|
-
const envAuth = readEnvAuth();
|
|
235186
|
-
if (envAuth) {
|
|
235187
|
-
return envAuth;
|
|
235188
|
-
}
|
|
235189
235190
|
try {
|
|
235190
235191
|
const authData = await readJsonFile(getAuthFilePath());
|
|
235191
235192
|
const result = AuthDataSchema.safeParse(authData);
|
|
@@ -235222,9 +235223,6 @@ function isTokenExpired(auth) {
|
|
|
235222
235223
|
return Date.now() >= auth.expiresAt - TOKEN_REFRESH_BUFFER_MS;
|
|
235223
235224
|
}
|
|
235224
235225
|
async function refreshAndSaveTokens() {
|
|
235225
|
-
if (readEnvAuth()) {
|
|
235226
|
-
return null;
|
|
235227
|
-
}
|
|
235228
235226
|
if (refreshPromise) {
|
|
235229
235227
|
return refreshPromise;
|
|
235230
235228
|
}
|
|
@@ -244399,6 +244397,7 @@ async function login({
|
|
|
244399
244397
|
|
|
244400
244398
|
// src/cli/utils/command/middleware.ts
|
|
244401
244399
|
async function ensureAuth(ctx) {
|
|
244400
|
+
await seedAuthFromEnv();
|
|
244402
244401
|
const loggedIn = await isLoggedIn();
|
|
244403
244402
|
if (!loggedIn) {
|
|
244404
244403
|
ctx.log.info("You need to login first to continue.");
|
|
@@ -251781,8 +251780,7 @@ function getLogoutCommand() {
|
|
|
251781
251780
|
// src/cli/commands/auth/whoami.ts
|
|
251782
251781
|
async function whoami(_ctx) {
|
|
251783
251782
|
const auth2 = await readAuth();
|
|
251784
|
-
|
|
251785
|
-
return { outroMessage: `Logged in as: ${theme.styles.bold(identity4)}` };
|
|
251783
|
+
return { outroMessage: `Logged in as: ${theme.styles.bold(auth2.email)}` };
|
|
251786
251784
|
}
|
|
251787
251785
|
function getWhoamiCommand() {
|
|
251788
251786
|
return new Base44Command("whoami", { requireAppConfig: false }).description("Display current authenticated user").action(whoami);
|
|
@@ -261675,4 +261673,4 @@ export {
|
|
|
261675
261673
|
CLIExitError
|
|
261676
261674
|
};
|
|
261677
261675
|
|
|
261678
|
-
//# debugId=
|
|
261676
|
+
//# debugId=1EB78D62F7CFAAF364756E2164756E21
|