@base44-preview/cli 0.0.1-pr.10.77d2052
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/README.md +49 -0
- package/dist/cli/commands/auth/login.d.ts +3 -0
- package/dist/cli/commands/auth/login.d.ts.map +1 -0
- package/dist/cli/commands/auth/login.js +69 -0
- package/dist/cli/commands/auth/login.js.map +1 -0
- package/dist/cli/commands/auth/logout.d.ts +3 -0
- package/dist/cli/commands/auth/logout.d.ts.map +1 -0
- package/dist/cli/commands/auth/logout.js +14 -0
- package/dist/cli/commands/auth/logout.js.map +1 -0
- package/dist/cli/commands/auth/whoami.d.ts +3 -0
- package/dist/cli/commands/auth/whoami.d.ts.map +1 -0
- package/dist/cli/commands/auth/whoami.js +14 -0
- package/dist/cli/commands/auth/whoami.js.map +1 -0
- package/dist/cli/commands/project/show-project.d.ts +3 -0
- package/dist/cli/commands/project/show-project.d.ts.map +1 -0
- package/dist/cli/commands/project/show-project.js +20 -0
- package/dist/cli/commands/project/show-project.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +21 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/index.d.ts +4 -0
- package/dist/cli/utils/index.d.ts.map +1 -0
- package/dist/cli/utils/index.js +4 -0
- package/dist/cli/utils/index.js.map +1 -0
- package/dist/cli/utils/packageVersion.d.ts +2 -0
- package/dist/cli/utils/packageVersion.d.ts.map +1 -0
- package/dist/cli/utils/packageVersion.js +12 -0
- package/dist/cli/utils/packageVersion.js.map +1 -0
- package/dist/cli/utils/runCommand.d.ts +8 -0
- package/dist/cli/utils/runCommand.d.ts.map +1 -0
- package/dist/cli/utils/runCommand.js +25 -0
- package/dist/cli/utils/runCommand.js.map +1 -0
- package/dist/cli/utils/runTask.d.ts +14 -0
- package/dist/cli/utils/runTask.d.ts.map +1 -0
- package/dist/cli/utils/runTask.js +24 -0
- package/dist/cli/utils/runTask.js.map +1 -0
- package/dist/core/auth/api.d.ts +5 -0
- package/dist/core/auth/api.d.ts.map +1 -0
- package/dist/core/auth/api.js +81 -0
- package/dist/core/auth/api.js.map +1 -0
- package/dist/core/auth/authClient.d.ts +7 -0
- package/dist/core/auth/authClient.d.ts.map +1 -0
- package/dist/core/auth/authClient.js +14 -0
- package/dist/core/auth/authClient.js.map +1 -0
- package/dist/core/auth/config.d.ts +11 -0
- package/dist/core/auth/config.d.ts.map +1 -0
- package/dist/core/auth/config.js +70 -0
- package/dist/core/auth/config.js.map +1 -0
- package/dist/core/auth/index.d.ts +4 -0
- package/dist/core/auth/index.d.ts.map +1 -0
- package/dist/core/auth/index.js +4 -0
- package/dist/core/auth/index.js.map +1 -0
- package/dist/core/auth/schema.d.ts +63 -0
- package/dist/core/auth/schema.d.ts.map +1 -0
- package/dist/core/auth/schema.js +62 -0
- package/dist/core/auth/schema.js.map +1 -0
- package/dist/core/config/app.d.ts +22 -0
- package/dist/core/config/app.d.ts.map +1 -0
- package/dist/core/config/app.js +14 -0
- package/dist/core/config/app.js.map +1 -0
- package/dist/core/config/index.d.ts +4 -0
- package/dist/core/config/index.d.ts.map +1 -0
- package/dist/core/config/index.js +3 -0
- package/dist/core/config/index.js.map +1 -0
- package/dist/core/config/project.d.ts +25 -0
- package/dist/core/config/project.d.ts.map +1 -0
- package/dist/core/config/project.js +62 -0
- package/dist/core/config/project.js.map +1 -0
- package/dist/core/config/resource.d.ts +4 -0
- package/dist/core/config/resource.d.ts.map +1 -0
- package/dist/core/config/resource.js +2 -0
- package/dist/core/config/resource.js.map +1 -0
- package/dist/core/consts.d.ts +8 -0
- package/dist/core/consts.d.ts.map +1 -0
- package/dist/core/consts.js +24 -0
- package/dist/core/consts.js.map +1 -0
- package/dist/core/errors.d.ts +8 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +15 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +6 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/resources/entity/config.d.ts +3 -0
- package/dist/core/resources/entity/config.d.ts.map +1 -0
- package/dist/core/resources/entity/config.js +25 -0
- package/dist/core/resources/entity/config.js.map +1 -0
- package/dist/core/resources/entity/index.d.ts +4 -0
- package/dist/core/resources/entity/index.d.ts.map +1 -0
- package/dist/core/resources/entity/index.js +4 -0
- package/dist/core/resources/entity/index.js.map +1 -0
- package/dist/core/resources/entity/resource.d.ts +4 -0
- package/dist/core/resources/entity/resource.d.ts.map +1 -0
- package/dist/core/resources/entity/resource.js +5 -0
- package/dist/core/resources/entity/resource.js.map +1 -0
- package/dist/core/resources/entity/schema.d.ts +47 -0
- package/dist/core/resources/entity/schema.d.ts.map +1 -0
- package/dist/core/resources/entity/schema.js +29 -0
- package/dist/core/resources/entity/schema.js.map +1 -0
- package/dist/core/resources/function/config.d.ts +4 -0
- package/dist/core/resources/function/config.d.ts.map +1 -0
- package/dist/core/resources/function/config.js +26 -0
- package/dist/core/resources/function/config.js.map +1 -0
- package/dist/core/resources/function/index.d.ts +4 -0
- package/dist/core/resources/function/index.d.ts.map +1 -0
- package/dist/core/resources/function/index.js +4 -0
- package/dist/core/resources/function/index.js.map +1 -0
- package/dist/core/resources/function/resource.d.ts +4 -0
- package/dist/core/resources/function/resource.d.ts.map +1 -0
- package/dist/core/resources/function/resource.js +5 -0
- package/dist/core/resources/function/resource.js.map +1 -0
- package/dist/core/resources/function/schema.d.ts +91 -0
- package/dist/core/resources/function/schema.d.ts.map +1 -0
- package/dist/core/resources/function/schema.js +36 -0
- package/dist/core/resources/function/schema.js.map +1 -0
- package/dist/core/resources/index.d.ts +3 -0
- package/dist/core/resources/index.d.ts.map +1 -0
- package/dist/core/resources/index.js +3 -0
- package/dist/core/resources/index.js.map +1 -0
- package/dist/core/utils/fs.d.ts +5 -0
- package/dist/core/utils/fs.d.ts.map +1 -0
- package/dist/core/utils/fs.js +56 -0
- package/dist/core/utils/fs.js.map +1 -0
- package/dist/core/utils/httpClient.d.ts +3 -0
- package/dist/core/utils/httpClient.d.ts.map +1 -0
- package/dist/core/utils/httpClient.js +41 -0
- package/dist/core/utils/httpClient.js.map +1 -0
- package/dist/core/utils/index.d.ts +3 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/index.js +3 -0
- package/dist/core/utils/index.js.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Base44 CLI
|
|
2
|
+
|
|
3
|
+
A unified command-line interface for managing Base44 applications, entities, functions, deployments, and related services.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Using npm
|
|
9
|
+
npm install
|
|
10
|
+
|
|
11
|
+
# Build the project
|
|
12
|
+
npm run build
|
|
13
|
+
|
|
14
|
+
# Run the CLI
|
|
15
|
+
npm start # Using node directly
|
|
16
|
+
./dist/cli/index.js # Run executable directly
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Development
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Run in development mode
|
|
23
|
+
npm run dev
|
|
24
|
+
|
|
25
|
+
# Build the project
|
|
26
|
+
npm run build
|
|
27
|
+
|
|
28
|
+
# Run the built CLI
|
|
29
|
+
npm run start
|
|
30
|
+
|
|
31
|
+
# Clean build artifacts
|
|
32
|
+
npm run clean
|
|
33
|
+
|
|
34
|
+
# Lint the code
|
|
35
|
+
npm run lint
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Commands
|
|
40
|
+
|
|
41
|
+
### Authentication
|
|
42
|
+
|
|
43
|
+
- `base44 login` - Authenticate with Base44 using device code flow
|
|
44
|
+
- `base44 whoami` - Display current authenticated user
|
|
45
|
+
- `base44 logout` - Logout from current device
|
|
46
|
+
|
|
47
|
+
### Project
|
|
48
|
+
|
|
49
|
+
- `base44 show-project` - Display project configuration, entities, and functions
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmGpC,eAAO,MAAM,YAAY,SAIrB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { log } from "@clack/prompts";
|
|
3
|
+
import pWaitFor from "p-wait-for";
|
|
4
|
+
import { writeAuth, generateDeviceCode, getTokenFromDeviceCode, } from "../../../core/auth/index.js";
|
|
5
|
+
import { runCommand, runTask } from "../../utils/index.js";
|
|
6
|
+
async function generateAndDisplayDeviceCode() {
|
|
7
|
+
const deviceCodeResponse = await runTask("Generating device code...", async () => {
|
|
8
|
+
return await generateDeviceCode();
|
|
9
|
+
}, {
|
|
10
|
+
successMessage: "Device code generated",
|
|
11
|
+
errorMessage: "Failed to generate device code",
|
|
12
|
+
});
|
|
13
|
+
log.info(`Please visit: ${deviceCodeResponse.verificationUri}\n` +
|
|
14
|
+
`Enter your device code: ${deviceCodeResponse.userCode}`);
|
|
15
|
+
return deviceCodeResponse;
|
|
16
|
+
}
|
|
17
|
+
async function waitForAuthentication(deviceCode, expiresIn) {
|
|
18
|
+
let tokenResponse;
|
|
19
|
+
try {
|
|
20
|
+
await runTask("Waiting for you to complete authentication...", async () => {
|
|
21
|
+
await pWaitFor(async () => {
|
|
22
|
+
const result = await getTokenFromDeviceCode(deviceCode);
|
|
23
|
+
if (result !== null) {
|
|
24
|
+
tokenResponse = result;
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}, {
|
|
29
|
+
interval: 2000,
|
|
30
|
+
timeout: expiresIn * 1000,
|
|
31
|
+
});
|
|
32
|
+
}, {
|
|
33
|
+
successMessage: "Authentication completed!",
|
|
34
|
+
errorMessage: "Authentication failed",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
if (error instanceof Error && error.message.includes("timed out")) {
|
|
39
|
+
throw new Error("Authentication timed out. Please try again.");
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
if (tokenResponse === undefined) {
|
|
44
|
+
throw new Error("Failed to retrieve authentication token.");
|
|
45
|
+
}
|
|
46
|
+
return tokenResponse;
|
|
47
|
+
}
|
|
48
|
+
async function saveAuthData(response) {
|
|
49
|
+
// TODO: Fetch user info (email, name) from the server after authentication
|
|
50
|
+
// For now, we store placeholder values until a /userinfo endpoint is available
|
|
51
|
+
await writeAuth({
|
|
52
|
+
accessToken: response.accessToken,
|
|
53
|
+
refreshToken: response.refreshToken,
|
|
54
|
+
email: "user@base44.com",
|
|
55
|
+
name: "Base44 User",
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async function login() {
|
|
59
|
+
const deviceCodeResponse = await generateAndDisplayDeviceCode();
|
|
60
|
+
const token = await waitForAuthentication(deviceCodeResponse.deviceCode, deviceCodeResponse.expiresIn);
|
|
61
|
+
await saveAuthData(token);
|
|
62
|
+
log.success("Successfully logged in!");
|
|
63
|
+
}
|
|
64
|
+
export const loginCommand = new Command("login")
|
|
65
|
+
.description("Authenticate with Base44")
|
|
66
|
+
.action(async () => {
|
|
67
|
+
await runCommand(login);
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../../src/cli/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EACL,SAAS,EACT,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE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;IACd,CAAC;IAED,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,QAAuB;IACjD,2EAA2E;IAC3E,+EAA+E;IAC/E,MAAM,SAAS,CAAC;QACd,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,KAAK,EAAE,iBAAiB;QACxB,IAAI,EAAE,aAAa;KACpB,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,KAAK;IAClB,MAAM,kBAAkB,GAAG,MAAM,4BAA4B,EAAE,CAAC;IAEhE,MAAM,KAAK,GAAG,MAAM,qBAAqB,CACvC,kBAAkB,CAAC,UAAU,EAC7B,kBAAkB,CAAC,SAAS,CAC7B,CAAC;IAEF,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;IAE1B,GAAG,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;KAC7C,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,UAAU,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,aAAa,SAItB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { log } from "@clack/prompts";
|
|
3
|
+
import { deleteAuth } from "../../../core/auth/index.js";
|
|
4
|
+
import { runCommand } from "../../utils/index.js";
|
|
5
|
+
async function logout() {
|
|
6
|
+
await deleteAuth();
|
|
7
|
+
log.info("Logged out successfully");
|
|
8
|
+
}
|
|
9
|
+
export const logoutCommand = new Command("logout")
|
|
10
|
+
.description("Logout from current device")
|
|
11
|
+
.action(async () => {
|
|
12
|
+
await runCommand(logout);
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=logout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../../src/cli/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,KAAK,UAAU,MAAM;IACnB,MAAM,UAAU,EAAE,CAAC;IACnB,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,aAAa,SAItB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { log } from "@clack/prompts";
|
|
3
|
+
import { readAuth } from "../../../core/auth/index.js";
|
|
4
|
+
import { runCommand } from "../../utils/index.js";
|
|
5
|
+
async function whoami() {
|
|
6
|
+
const auth = await readAuth();
|
|
7
|
+
log.info(`Logged in as: ${auth.name} (${auth.email})`);
|
|
8
|
+
}
|
|
9
|
+
export const whoamiCommand = new Command("whoami")
|
|
10
|
+
.description("Display current authenticated user")
|
|
11
|
+
.action(async () => {
|
|
12
|
+
await runCommand(whoami);
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../../src/cli/commands/auth/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,KAAK,UAAU,MAAM;IACnB,MAAM,IAAI,GAAG,MAAM,QAAQ,EAAE,CAAC;IAC9B,GAAG,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-project.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/project/show-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC,eAAO,MAAM,kBAAkB,SAI3B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { log } from "@clack/prompts";
|
|
3
|
+
import { readProjectConfig } from "../../../core/config/project.js";
|
|
4
|
+
import { runCommand, runTask } from "../../utils/index.js";
|
|
5
|
+
async function showProject() {
|
|
6
|
+
const projectData = await runTask("Reading project configuration", async () => {
|
|
7
|
+
return await readProjectConfig();
|
|
8
|
+
}, {
|
|
9
|
+
successMessage: "Project configuration loaded",
|
|
10
|
+
errorMessage: "Failed to load project configuration",
|
|
11
|
+
});
|
|
12
|
+
const jsonOutput = JSON.stringify(projectData, null, 2);
|
|
13
|
+
log.info(jsonOutput);
|
|
14
|
+
}
|
|
15
|
+
export const showProjectCommand = new Command("show-project")
|
|
16
|
+
.description("Display project configuration, entities, and functions")
|
|
17
|
+
.action(async () => {
|
|
18
|
+
await runCommand(showProject);
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=show-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-project.js","sourceRoot":"","sources":["../../../../src/cli/commands/project/show-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE3D,KAAK,UAAU,WAAW;IACxB,MAAM,WAAW,GAAG,MAAM,OAAO,CAC/B,+BAA+B,EAC/B,KAAK,IAAI,EAAE;QACT,OAAO,MAAM,iBAAiB,EAAE,CAAC;IACnC,CAAC,EACD;QACE,cAAc,EAAE,8BAA8B;QAC9C,YAAY,EAAE,sCAAsC;KACrD,CACF,CAAC;IAEF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACxD,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC;KAC1D,WAAW,CAAC,wDAAwD,CAAC;KACrE,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import { getPackageVersion } from "./utils/index.js";
|
|
4
|
+
import { loginCommand } from "./commands/auth/login.js";
|
|
5
|
+
import { whoamiCommand } from "./commands/auth/whoami.js";
|
|
6
|
+
import { logoutCommand } from "./commands/auth/logout.js";
|
|
7
|
+
import { showProjectCommand } from "./commands/project/show-project.js";
|
|
8
|
+
const program = new Command();
|
|
9
|
+
program
|
|
10
|
+
.name("base44")
|
|
11
|
+
.description("Base44 CLI - Unified interface for managing Base44 applications")
|
|
12
|
+
.version(getPackageVersion());
|
|
13
|
+
// Register authentication commands
|
|
14
|
+
program.addCommand(loginCommand);
|
|
15
|
+
program.addCommand(whoamiCommand);
|
|
16
|
+
program.addCommand(logoutCommand);
|
|
17
|
+
// Register project commands
|
|
18
|
+
program.addCommand(showProjectCommand);
|
|
19
|
+
// Parse command line arguments
|
|
20
|
+
program.parse();
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CACV,iEAAiE,CAClE;KACA,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAEhC,mCAAmC;AACnC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACjC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAElC,4BAA4B;AAC5B,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAEvC,+BAA+B;AAC/B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/packageVersion.ts"],"names":[],"mappings":"AAIA,wBAAgB,iBAAiB,IAAI,MAAM,CAQ1C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
export function getPackageVersion() {
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = dirname(__filename);
|
|
7
|
+
// From dist/cli/utils -> package.json at root"
|
|
8
|
+
const packageJsonPath = join(__dirname, "..", "..", "..", "package.json");
|
|
9
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
10
|
+
return packageJson.version;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../../../src/cli/utils/packageVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,UAAU,iBAAiB;IAC/B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEtC,+CAA+C;IAC/C,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IAC1E,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IACvE,OAAO,WAAW,CAAC,OAAO,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a command function with the Base44 intro banner.
|
|
3
|
+
* All CLI commands should use this utility to ensure consistent branding.
|
|
4
|
+
*
|
|
5
|
+
* @param commandFn - The async function to execute as the command
|
|
6
|
+
*/
|
|
7
|
+
export declare function runCommand(commandFn: () => Promise<void>): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=runCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCommand.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/runCommand.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC7B,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { intro, log } from "@clack/prompts";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
const base44Color = chalk.bgHex("#E86B3C");
|
|
4
|
+
/**
|
|
5
|
+
* Wraps a command function with the Base44 intro banner.
|
|
6
|
+
* All CLI commands should use this utility to ensure consistent branding.
|
|
7
|
+
*
|
|
8
|
+
* @param commandFn - The async function to execute as the command
|
|
9
|
+
*/
|
|
10
|
+
export async function runCommand(commandFn) {
|
|
11
|
+
intro(base44Color(" Base 44 "));
|
|
12
|
+
try {
|
|
13
|
+
await commandFn();
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
if (e instanceof Error) {
|
|
17
|
+
log.error(e.stack ?? e.message);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
log.error(String(e));
|
|
21
|
+
}
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=runCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runCommand.js","sourceRoot":"","sources":["../../../src/cli/utils/runCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,SAA8B;IAE9B,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IAEhC,IAAI,CAAC;QACH,MAAM,SAAS,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;YACvB,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps an async operation with automatic spinner management.
|
|
3
|
+
* The spinner is automatically started, and stopped on both success and error.
|
|
4
|
+
*
|
|
5
|
+
* @param startMessage - Message to show when spinner starts
|
|
6
|
+
* @param operation - The async operation to execute
|
|
7
|
+
* @param options - Optional configuration
|
|
8
|
+
* @returns The result of the operation
|
|
9
|
+
*/
|
|
10
|
+
export declare function runTask<T>(startMessage: string, operation: () => Promise<T>, options?: {
|
|
11
|
+
successMessage?: string;
|
|
12
|
+
errorMessage?: string;
|
|
13
|
+
}): Promise<T>;
|
|
14
|
+
//# sourceMappingURL=runTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runTask.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/runTask.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACA,OAAO,CAAC,CAAC,CAAC,CAYZ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { spinner } from "@clack/prompts";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an async operation with automatic spinner management.
|
|
4
|
+
* The spinner is automatically started, and stopped on both success and error.
|
|
5
|
+
*
|
|
6
|
+
* @param startMessage - Message to show when spinner starts
|
|
7
|
+
* @param operation - The async operation to execute
|
|
8
|
+
* @param options - Optional configuration
|
|
9
|
+
* @returns The result of the operation
|
|
10
|
+
*/
|
|
11
|
+
export async function runTask(startMessage, operation, options) {
|
|
12
|
+
const s = spinner();
|
|
13
|
+
s.start(startMessage);
|
|
14
|
+
try {
|
|
15
|
+
const result = await operation();
|
|
16
|
+
s.stop(options?.successMessage || startMessage);
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
s.stop(options?.errorMessage || "Failed");
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=runTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runTask.js","sourceRoot":"","sources":["../../../src/cli/utils/runTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,YAAoB,EACpB,SAA2B,EAC3B,OAGC;IAED,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAEtB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,IAAI,YAAY,CAAC,CAAC;QAChD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,IAAI,QAAQ,CAAC,CAAC;QAC1C,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DeviceCodeResponse, TokenResponse } from "./schema.js";
|
|
2
|
+
export declare function generateDeviceCode(): Promise<DeviceCodeResponse>;
|
|
3
|
+
export declare function getTokenFromDeviceCode(deviceCode: string): Promise<TokenResponse | null>;
|
|
4
|
+
export declare function renewAccessToken(refreshToken: string): Promise<TokenResponse>;
|
|
5
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/core/auth/api.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIrE,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAwBtE;AAED,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA8C/B;AAED,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,aAAa,CAAC,CAoCxB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AuthApiError, AuthValidationError } from "../errors.js";
|
|
2
|
+
import { DeviceCodeResponseSchema, TokenResponseSchema, OAuthErrorSchema, } from "./schema.js";
|
|
3
|
+
import { AUTH_CLIENT_ID } from "../consts.js";
|
|
4
|
+
import authClient from "./authClient.js";
|
|
5
|
+
export async function generateDeviceCode() {
|
|
6
|
+
const response = await authClient.post("oauth/device/code", {
|
|
7
|
+
json: {
|
|
8
|
+
client_id: AUTH_CLIENT_ID,
|
|
9
|
+
scope: "apps:read apps:write",
|
|
10
|
+
},
|
|
11
|
+
throwHttpErrors: false,
|
|
12
|
+
});
|
|
13
|
+
if (!response.ok) {
|
|
14
|
+
throw new AuthApiError(`Failed to generate device code: ${response.status} ${response.statusText}`);
|
|
15
|
+
}
|
|
16
|
+
const result = DeviceCodeResponseSchema.safeParse(await response.json());
|
|
17
|
+
if (!result.success) {
|
|
18
|
+
throw new AuthValidationError(`Invalid device code response from server: ${result.error.message}`);
|
|
19
|
+
}
|
|
20
|
+
return result.data;
|
|
21
|
+
}
|
|
22
|
+
export async function getTokenFromDeviceCode(deviceCode) {
|
|
23
|
+
const searchParams = new URLSearchParams();
|
|
24
|
+
searchParams.set("grant_type", "urn:ietf:params:oauth:grant-type:device_code");
|
|
25
|
+
searchParams.set("device_code", deviceCode);
|
|
26
|
+
searchParams.set("client_id", AUTH_CLIENT_ID);
|
|
27
|
+
const response = await authClient.post("oauth/token", {
|
|
28
|
+
body: searchParams.toString(),
|
|
29
|
+
headers: {
|
|
30
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
31
|
+
},
|
|
32
|
+
throwHttpErrors: false,
|
|
33
|
+
});
|
|
34
|
+
const json = await response.json();
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
const errorResult = OAuthErrorSchema.safeParse(json);
|
|
37
|
+
if (!errorResult.success) {
|
|
38
|
+
throw new AuthApiError(`Token request failed: ${response.statusText}`);
|
|
39
|
+
}
|
|
40
|
+
const { error, error_description } = errorResult.data;
|
|
41
|
+
// Polling states - user hasn't completed auth yet
|
|
42
|
+
if (error === "authorization_pending" || error === "slow_down") {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
// Actual errors
|
|
46
|
+
throw new AuthApiError(error_description ?? `OAuth error: ${error}`);
|
|
47
|
+
}
|
|
48
|
+
const result = TokenResponseSchema.safeParse(json);
|
|
49
|
+
if (!result.success) {
|
|
50
|
+
throw new AuthValidationError(`Invalid token response from server: ${result.error.message}`);
|
|
51
|
+
}
|
|
52
|
+
return result.data;
|
|
53
|
+
}
|
|
54
|
+
export async function renewAccessToken(refreshToken) {
|
|
55
|
+
const searchParams = new URLSearchParams();
|
|
56
|
+
searchParams.set("grant_type", "refresh_token");
|
|
57
|
+
searchParams.set("refresh_token", refreshToken);
|
|
58
|
+
searchParams.set("client_id", AUTH_CLIENT_ID);
|
|
59
|
+
const response = await authClient.post("oauth/token", {
|
|
60
|
+
body: searchParams.toString(),
|
|
61
|
+
headers: {
|
|
62
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
63
|
+
},
|
|
64
|
+
throwHttpErrors: false,
|
|
65
|
+
});
|
|
66
|
+
const json = await response.json();
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
const errorResult = OAuthErrorSchema.safeParse(json);
|
|
69
|
+
if (!errorResult.success) {
|
|
70
|
+
throw new AuthApiError(`Token refresh failed: ${response.statusText}`);
|
|
71
|
+
}
|
|
72
|
+
const { error, error_description } = errorResult.data;
|
|
73
|
+
throw new AuthApiError(error_description ?? `OAuth error: ${error}`);
|
|
74
|
+
}
|
|
75
|
+
const result = TokenResponseSchema.safeParse(json);
|
|
76
|
+
if (!result.success) {
|
|
77
|
+
throw new AuthValidationError(`Invalid token response from server: ${result.error.message}`);
|
|
78
|
+
}
|
|
79
|
+
return result.data;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/core/auth/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,UAAU,MAAM,iBAAiB,CAAC;AAEzC,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,mBAAmB,EAAE;QAC1D,IAAI,EAAE;YACJ,SAAS,EA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,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,WAAW,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAErD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,YAAY,CAAC,yBAAyB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC;QACtD,MAAM,IAAI,YAAY,CAAC,iBAAiB,IAAI,gBAAgB,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAEnD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,mBAAmB,CAC3B,uCAAuC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAC9D,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authClient.d.ts","sourceRoot":"","sources":["../../../src/core/auth/authClient.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,QAAA,MAAM,UAAU,yBAKd,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ky from "ky";
|
|
2
|
+
import { getBase44ApiUrl } from "../consts.js";
|
|
3
|
+
/**
|
|
4
|
+
* Separate ky instance for OAuth endpoints.
|
|
5
|
+
* These don't need Authorization headers (they use client_id + tokens in body).
|
|
6
|
+
*/
|
|
7
|
+
const authClient = ky.create({
|
|
8
|
+
prefixUrl: getBase44ApiUrl(),
|
|
9
|
+
headers: {
|
|
10
|
+
"User-Agent": "Base44 CLI",
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
export default authClient;
|
|
14
|
+
//# sourceMappingURL=authClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authClient.js","sourceRoot":"","sources":["../../../src/core/auth/authClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,GAAG,EAAE,CAAC,MAAM,CAAC;IAC3B,SAAS,EAAE,eAAe,EAAE;IAC5B,OAAO,EAAE;QACP,YAAY,EAAE,YAAY;KAC3B;CACF,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AuthData } from "./schema.js";
|
|
2
|
+
export declare function readAuth(): Promise<AuthData>;
|
|
3
|
+
export declare function writeAuth(authData: AuthData): Promise<void>;
|
|
4
|
+
export declare function deleteAuth(): Promise<void>;
|
|
5
|
+
/**
|
|
6
|
+
* Refreshes the access token and saves the new tokens.
|
|
7
|
+
* Returns the new access token, or null if refresh failed.
|
|
8
|
+
* Used by httpClient to handle 401 responses.
|
|
9
|
+
*/
|
|
10
|
+
export declare function refreshAndSaveTokens(): Promise<string | null>;
|
|
11
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/core/auth/config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,wBAAsB,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,CA2BlD;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBjE;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAUhD;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiBnE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { getAuthFilePath } from "../consts.js";
|
|
2
|
+
import { readJsonFile, writeJsonFile, deleteFile } from "../utils/fs.js";
|
|
3
|
+
import { renewAccessToken } from "./api.js";
|
|
4
|
+
import { AuthDataSchema } from "./schema.js";
|
|
5
|
+
export async function readAuth() {
|
|
6
|
+
try {
|
|
7
|
+
const parsed = await readJsonFile(getAuthFilePath());
|
|
8
|
+
const result = AuthDataSchema.safeParse(parsed);
|
|
9
|
+
if (!result.success) {
|
|
10
|
+
throw new Error(`Invalid authentication data: ${result.error.issues
|
|
11
|
+
.map((e) => e.message)
|
|
12
|
+
.join(", ")}`);
|
|
13
|
+
}
|
|
14
|
+
return result.data;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
if (error instanceof Error && error.message.includes("Authentication")) {
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
if (error instanceof Error && error.message.includes("File not found")) {
|
|
21
|
+
throw new Error("Authentication file not found. Please login first.");
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`Failed to read authentication file: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export async function writeAuth(authData) {
|
|
27
|
+
const result = AuthDataSchema.safeParse(authData);
|
|
28
|
+
if (!result.success) {
|
|
29
|
+
throw new Error(`Invalid authentication data: ${result.error.issues
|
|
30
|
+
.map((e) => e.message)
|
|
31
|
+
.join(", ")}`);
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
await writeJsonFile(getAuthFilePath(), result.data);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
throw new Error(`Failed to write authentication file: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function deleteAuth() {
|
|
41
|
+
try {
|
|
42
|
+
await deleteFile(getAuthFilePath());
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw new Error(`Failed to delete authentication file: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Refreshes the access token and saves the new tokens.
|
|
50
|
+
* Returns the new access token, or null if refresh failed.
|
|
51
|
+
* Used by httpClient to handle 401 responses.
|
|
52
|
+
*/
|
|
53
|
+
export async function refreshAndSaveTokens() {
|
|
54
|
+
try {
|
|
55
|
+
const auth = await readAuth();
|
|
56
|
+
const tokenResponse = await renewAccessToken(auth.refreshToken);
|
|
57
|
+
await writeAuth({
|
|
58
|
+
...auth,
|
|
59
|
+
accessToken: tokenResponse.accessToken,
|
|
60
|
+
refreshToken: tokenResponse.refreshToken,
|
|
61
|
+
});
|
|
62
|
+
return tokenResponse.accessToken;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Refresh failed - delete auth, user needs to login again
|
|
66
|
+
await deleteAuth();
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/core/auth/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAC,CAAC;QACrD,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEhD,IAAI,CAAC,MAAM,CAAC,OAAO,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