@dbos-inc/dbos-sdk 0.9.10-preview → 0.9.12-preview
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/packages/dbos-cloud/cli.js +13 -25
- package/dist/packages/dbos-cloud/cli.js.map +1 -1
- package/dist/packages/dbos-cloud/cloudutils.d.ts +6 -1
- package/dist/packages/dbos-cloud/cloudutils.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/cloudutils.js +5 -4
- package/dist/packages/dbos-cloud/cloudutils.js.map +1 -1
- package/dist/packages/dbos-cloud/login.d.ts +0 -7
- package/dist/packages/dbos-cloud/login.d.ts.map +1 -1
- package/dist/packages/dbos-cloud/login.js +14 -12
- package/dist/packages/dbos-cloud/login.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -6,8 +6,8 @@ const commander_1 = require("commander");
|
|
6
6
|
const login_1 = require("./login");
|
7
7
|
const register_1 = require("./register");
|
8
8
|
const userdb_1 = require("./userdb");
|
9
|
+
const cloudutils_1 = require("./cloudutils");
|
9
10
|
const program = new commander_1.Command();
|
10
|
-
const DEFAULT_HOST = process.env.DBOS_DOMAIN; // TODO: Once we have a "production" cluster, hardcode its domain name here
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
12
12
|
const packageJson = require('../../../package.json');
|
13
13
|
program.
|
@@ -27,9 +27,8 @@ program
|
|
27
27
|
.command('register')
|
28
28
|
.description('Register a user and log in to DBOS cloud')
|
29
29
|
.requiredOption('-u, --username <string>', 'Username')
|
30
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST)
|
31
30
|
.action(async (options) => {
|
32
|
-
const exitCode = await (0, register_1.registerUser)(options.username,
|
31
|
+
const exitCode = await (0, register_1.registerUser)(options.username, cloudutils_1.DBOSCloudHost);
|
33
32
|
process.exit(exitCode);
|
34
33
|
});
|
35
34
|
/////////////////////////////
|
@@ -37,23 +36,20 @@ program
|
|
37
36
|
/////////////////////////////
|
38
37
|
const applicationCommands = program
|
39
38
|
.command('applications')
|
40
|
-
.description('Manage your DBOS applications')
|
41
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST);
|
39
|
+
.description('Manage your DBOS applications');
|
42
40
|
applicationCommands
|
43
41
|
.command('register')
|
44
42
|
.description('Register a new application')
|
45
43
|
.requiredOption('-d, --database <string>', 'Specify the app database name')
|
46
44
|
.action(async (options) => {
|
47
|
-
const
|
48
|
-
const exitCode = await (0, applications_1.registerApp)(options.database, host);
|
45
|
+
const exitCode = await (0, applications_1.registerApp)(options.database, cloudutils_1.DBOSCloudHost);
|
49
46
|
process.exit(exitCode);
|
50
47
|
});
|
51
48
|
applicationCommands
|
52
49
|
.command('update')
|
53
50
|
.description('Update an application')
|
54
51
|
.action(async () => {
|
55
|
-
const
|
56
|
-
const exitCode = await (0, applications_1.updateApp)(host);
|
52
|
+
const exitCode = await (0, applications_1.updateApp)(cloudutils_1.DBOSCloudHost);
|
57
53
|
process.exit(exitCode);
|
58
54
|
});
|
59
55
|
applicationCommands
|
@@ -61,16 +57,14 @@ applicationCommands
|
|
61
57
|
.description('Deploy an application code to the cloud')
|
62
58
|
.option('--no-docker', 'Build the code locally without using Docker')
|
63
59
|
.action(async (options) => {
|
64
|
-
const
|
65
|
-
const exitCode = await (0, applications_1.deployAppCode)(host, options.docker);
|
60
|
+
const exitCode = await (0, applications_1.deployAppCode)(cloudutils_1.DBOSCloudHost, options.docker);
|
66
61
|
process.exit(exitCode);
|
67
62
|
});
|
68
63
|
applicationCommands
|
69
64
|
.command('delete')
|
70
65
|
.description('Delete a previously deployed application')
|
71
66
|
.action(async () => {
|
72
|
-
const
|
73
|
-
const exitCode = await (0, applications_1.deleteApp)(host);
|
67
|
+
const exitCode = await (0, applications_1.deleteApp)(cloudutils_1.DBOSCloudHost);
|
74
68
|
process.exit(exitCode);
|
75
69
|
});
|
76
70
|
applicationCommands
|
@@ -78,8 +72,7 @@ applicationCommands
|
|
78
72
|
.description('List all deployed applications')
|
79
73
|
.option('--json', 'Emit JSON output')
|
80
74
|
.action(async (options) => {
|
81
|
-
const
|
82
|
-
const exitCode = await (0, applications_1.listApps)(host, options.json);
|
75
|
+
const exitCode = await (0, applications_1.listApps)(cloudutils_1.DBOSCloudHost, options.json);
|
83
76
|
process.exit(exitCode);
|
84
77
|
});
|
85
78
|
applicationCommands
|
@@ -87,8 +80,7 @@ applicationCommands
|
|
87
80
|
.description('Print the microVM logs of a deployed application')
|
88
81
|
.option('-l, --last <integer>', 'How far back to query, in seconds from current time. By default, we retrieve all data', parseInt)
|
89
82
|
.action(async (options) => {
|
90
|
-
const
|
91
|
-
const exitCode = await (0, applications_1.getAppLogs)(host, options.last);
|
83
|
+
const exitCode = await (0, applications_1.getAppLogs)(cloudutils_1.DBOSCloudHost, options.last);
|
92
84
|
process.exit(exitCode);
|
93
85
|
});
|
94
86
|
//////////////////////////////
|
@@ -96,8 +88,7 @@ applicationCommands
|
|
96
88
|
//////////////////////////////
|
97
89
|
const userdbCommands = program
|
98
90
|
.command('userdb')
|
99
|
-
.description('Manage your databases')
|
100
|
-
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST);
|
91
|
+
.description('Manage your databases');
|
101
92
|
userdbCommands
|
102
93
|
.command('create')
|
103
94
|
.argument('<string>', 'database name')
|
@@ -105,8 +96,7 @@ userdbCommands
|
|
105
96
|
.requiredOption('-W, --password <string>', 'Specify the admin password')
|
106
97
|
.option('-s, --sync', 'make synchronous call', true)
|
107
98
|
.action((async (dbname, options) => {
|
108
|
-
const
|
109
|
-
const exitCode = await (0, userdb_1.createUserDb)(host, dbname, options.admin, options.password, options.sync);
|
99
|
+
const exitCode = await (0, userdb_1.createUserDb)(cloudutils_1.DBOSCloudHost, dbname, options.admin, options.password, options.sync);
|
110
100
|
process.exit(exitCode);
|
111
101
|
}));
|
112
102
|
userdbCommands
|
@@ -114,16 +104,14 @@ userdbCommands
|
|
114
104
|
.argument('<string>', 'database name')
|
115
105
|
.option('--json', 'Emit JSON output')
|
116
106
|
.action((async (dbname, options) => {
|
117
|
-
const
|
118
|
-
const exitCode = await (0, userdb_1.getUserDb)(host, dbname, options.json);
|
107
|
+
const exitCode = await (0, userdb_1.getUserDb)(cloudutils_1.DBOSCloudHost, dbname, options.json);
|
119
108
|
process.exit(exitCode);
|
120
109
|
}));
|
121
110
|
userdbCommands
|
122
111
|
.command('delete')
|
123
112
|
.argument('<string>', 'database name')
|
124
113
|
.action((async (dbname) => {
|
125
|
-
const
|
126
|
-
const exitCode = await (0, userdb_1.deleteUserDb)(host, dbname);
|
114
|
+
const exitCode = await (0, userdb_1.deleteUserDb)(cloudutils_1.DBOSCloudHost, dbname);
|
127
115
|
process.exit(exitCode);
|
128
116
|
}));
|
129
117
|
program.parse(process.argv);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/cli.ts"],"names":[],"mappings":";;;AAEA,iDAOwB;AACxB,yCAAoC;AACpC,mCAAgC;AAChC,yCAA0C;AAC1C,qCAAiE;
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/cli.ts"],"names":[],"mappings":";;;AAEA,iDAOwB;AACxB,yCAAoC;AACpC,mCAAgC;AAChC,yCAA0C;AAC1C,qCAAiE;AACjE,6CAA6C;AAE7C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,8DAA8D;AAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,uBAAuB,CAAwB,CAAC;AAC5E,OAAO;IACL,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAE/B,qBAAqB;AACrB,qBAAqB;AACrB,qBAAqB;AAErB,OAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,sBAAsB,CAAC;KACnC,cAAc,CAAC,yBAAyB,EAAE,UAAU,CAAC;KACrD,MAAM,CAAC,KAAK,EAAE,OAA6B,EAAE,EAAE;IAC9C,MAAM,QAAQ,GAAG,MAAM,IAAA,a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MAAc,EAAE,EAAE;IAChC,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAY,EAAC,0BAAa,EAAE,MAAM,CAAC,CAAA;IAC1D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC,CAAA;AAEL,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,oDAAoD;AACpD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
|
@@ -1,8 +1,13 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
-
import { DBOSCloudCredentials } from "./login";
|
3
2
|
import { Logger } from "winston";
|
4
3
|
import { AxiosError } from "axios";
|
4
|
+
export interface DBOSCloudCredentials {
|
5
|
+
token: string;
|
6
|
+
userName: string;
|
7
|
+
}
|
5
8
|
export declare const dbosConfigFilePath = "dbos-config.yaml";
|
9
|
+
export declare const DBOSCloudHost: string;
|
10
|
+
export declare const dbosEnvPath = ".dbos";
|
6
11
|
export declare function getLogger(): Logger;
|
7
12
|
export declare function getCloudCredentials(): DBOSCloudCredentials;
|
8
13
|
export declare function credentialsExist(): boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cloudutils.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/cloudutils.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"cloudutils.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/cloudutils.ts"],"names":[],"mappings":";AAEA,OAAO,EAAoC,MAAM,EAAE,MAAM,SAAS,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,kBAAkB,qBAAqB,CAAC;AACrD,eAAO,MAAM,aAAa,QAA8C,CAAC;AACzE,eAAO,MAAM,WAAW,UAAU,CAAC;AAGnC,wBAAgB,SAAS,IAAI,MAAM,CASlC;AAqBD,wBAAgB,mBAAmB,IAAI,oBAAoB,CAW1D;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAGD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAkBhF;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,cAAuB,GAAG,MAAM,GAAG,MAAM,CAa7F;AAED,eAAO,MAAM,KAAK,OAAQ,MAAM,qBAA0C,CAAC;AAE3E,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAGrC,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEhE;AAED,UAAU,qBAAqB;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,qBAAqB,CAKlF;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,UAAU,QAI3D"}
|
@@ -3,12 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.handleAPIErrors = exports.isCloudAPIErrorResponse = exports.createDirectory = exports.sleep = exports.readFileSync = exports.runCommand = exports.credentialsExist = exports.getCloudCredentials = exports.getLogger = exports.dbosConfigFilePath = void 0;
|
7
|
-
const login_1 = require("./login");
|
6
|
+
exports.handleAPIErrors = exports.isCloudAPIErrorResponse = exports.createDirectory = exports.sleep = exports.readFileSync = exports.runCommand = exports.credentialsExist = exports.getCloudCredentials = exports.getLogger = exports.dbosEnvPath = exports.DBOSCloudHost = exports.dbosConfigFilePath = void 0;
|
8
7
|
const child_process_1 = require("child_process");
|
9
8
|
const winston_1 = require("winston");
|
10
9
|
const fs_1 = __importDefault(require("fs"));
|
11
10
|
exports.dbosConfigFilePath = "dbos-config.yaml";
|
11
|
+
exports.DBOSCloudHost = process.env.DBOS_DOMAIN || "cloud.dbos.dev";
|
12
|
+
exports.dbosEnvPath = ".dbos";
|
12
13
|
// FIXME: we should have a global instance of the logger created in cli.ts
|
13
14
|
function getLogger() {
|
14
15
|
const winstonTransports = [];
|
@@ -36,7 +37,7 @@ function getCloudCredentials() {
|
|
36
37
|
logger.error("Error: not logged in");
|
37
38
|
process.exit(1);
|
38
39
|
}
|
39
|
-
const userCredentials = JSON.parse(fs_1.default.readFileSync(`./${
|
40
|
+
const userCredentials = JSON.parse(fs_1.default.readFileSync(`./${exports.dbosEnvPath}/credentials`).toString("utf-8"));
|
40
41
|
return {
|
41
42
|
userName: userCredentials.userName,
|
42
43
|
token: userCredentials.token.replace(/\r|\n/g, ""), // Trim the trailing /r /n.
|
@@ -44,7 +45,7 @@ function getCloudCredentials() {
|
|
44
45
|
}
|
45
46
|
exports.getCloudCredentials = getCloudCredentials;
|
46
47
|
function credentialsExist() {
|
47
|
-
return fs_1.default.existsSync(`./${
|
48
|
+
return fs_1.default.existsSync(`./${exports.dbosEnvPath}/credentials`);
|
48
49
|
}
|
49
50
|
exports.credentialsExist = credentialsExist;
|
50
51
|
// Run a command, streaming its output to stdout
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cloudutils.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/cloudutils.ts"],"names":[],"mappings":";;;;;;
|
1
|
+
{"version":3,"file":"cloudutils.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/cloudutils.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AAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC;AAFD,0CAEC;AAQD,SAAgB,uBAAuB,CAAC,GAAY;IAClD,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;QAC5C,SAAS,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,SAAS,CAAC,KAAK,QAAQ;QACtD,YAAY,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,YAAY,CAAC,KAAK,QAAQ;QAC5D,WAAW,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,WAAW,CAAC,KAAK,QAAQ,CAAC;AAC/D,CAAC;AALD,0DAKC;AAED,SAAgB,eAAe,CAAC,KAAa,EAAE,CAAa;IAC1D,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,IAAI,GAA0B,CAAC,CAAC,QAAQ,EAAE,IAA6B,CAAC;IAC9E,MAAM,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,KAAK,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;AACjE,CAAC;AAJD,0CAIC"}
|
@@ -1,9 +1,2 @@
|
|
1
|
-
export declare const dbosEnvPath = ".dbos";
|
2
|
-
export declare const DBOSClientID = "G38fLmVErczEo9ioCFjVIHea6yd0qMZu";
|
3
|
-
export declare const DBOSCloudIdentifier = "dbos-cloud-api";
|
4
|
-
export interface DBOSCloudCredentials {
|
5
|
-
token: string;
|
6
|
-
userName: string;
|
7
|
-
}
|
8
1
|
export declare function login(username: string): Promise<number>;
|
9
2
|
//# sourceMappingURL=login.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/login.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../packages/dbos-cloud/login.ts"],"names":[],"mappings":"AAyDA,wBAAsB,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA4D7D"}
|
@@ -3,18 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
exports.login =
|
6
|
+
exports.login = void 0;
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
8
8
|
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
9
9
|
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
10
10
|
const child_process_1 = require("child_process");
|
11
11
|
const fs_1 = __importDefault(require("fs"));
|
12
12
|
const cloudutils_1 = require("./cloudutils");
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
const DBOSCloudHost = process.env.DBOS_DOMAIN || "cloud.dbos.dev";
|
14
|
+
const productionEnvironment = DBOSCloudHost === "cloud.dbos.dev";
|
15
|
+
const Auth0Domain = productionEnvironment ? 'login.dbos.dev' : 'dbos-inc.us.auth0.com';
|
16
|
+
const DBOSClientID = productionEnvironment ? '6p7Sjxf13cyLMkdwn14MxlH7JdhILled' : 'G38fLmVErczEo9ioCFjVIHea6yd0qMZu';
|
17
|
+
const DBOSCloudIdentifier = 'dbos-cloud-api';
|
16
18
|
const client = (0, jwks_rsa_1.default)({
|
17
|
-
jwksUri:
|
19
|
+
jwksUri: `https://${Auth0Domain}/.well-known/jwks.json`
|
18
20
|
});
|
19
21
|
async function getSigningKey(kid) {
|
20
22
|
const key = await client.getSigningKey(kid);
|
@@ -42,9 +44,9 @@ async function login(username) {
|
|
42
44
|
logger.info(`Please authenticate with DBOS Cloud!`);
|
43
45
|
const deviceCodeRequest = {
|
44
46
|
method: 'POST',
|
45
|
-
url:
|
47
|
+
url: `https://${Auth0Domain}/oauth/device/code`,
|
46
48
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
47
|
-
data: { client_id:
|
49
|
+
data: { client_id: DBOSClientID, scope: 'sub', audience: DBOSCloudIdentifier }
|
48
50
|
};
|
49
51
|
let deviceCodeResponse;
|
50
52
|
try {
|
@@ -61,12 +63,12 @@ async function login(username) {
|
|
61
63
|
console.log(`Login URL: ${deviceCodeResponse.verification_uri_complete}`);
|
62
64
|
const tokenRequest = {
|
63
65
|
method: 'POST',
|
64
|
-
url:
|
66
|
+
url: `https://${Auth0Domain}/oauth/token`,
|
65
67
|
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
66
68
|
data: new URLSearchParams({
|
67
69
|
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
68
70
|
device_code: deviceCodeResponse.device_code,
|
69
|
-
client_id:
|
71
|
+
client_id: DBOSClientID
|
70
72
|
})
|
71
73
|
};
|
72
74
|
let tokenResponse;
|
@@ -91,10 +93,10 @@ async function login(username) {
|
|
91
93
|
token: tokenResponse.access_token,
|
92
94
|
userName: username,
|
93
95
|
};
|
94
|
-
(0, child_process_1.execSync)(`mkdir -p ${
|
95
|
-
fs_1.default.writeFileSync(`${
|
96
|
+
(0, child_process_1.execSync)(`mkdir -p ${cloudutils_1.dbosEnvPath}`);
|
97
|
+
fs_1.default.writeFileSync(`${cloudutils_1.dbosEnvPath}/credentials`, JSON.stringify(credentials), "utf-8");
|
96
98
|
logger.info(`Successfully logged in as user: ${credentials.userName}`);
|
97
|
-
logger.info(`You can view your credentials in: ./${
|
99
|
+
logger.info(`You can view your credentials in: ./${cloudutils_1.dbosEnvPath}/credentials`);
|
98
100
|
return 0;
|
99
101
|
}
|
100
102
|
exports.login = login;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/login.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gEAA+C;AAC/C,wDAAkC;AAClC,iDAAyC;AACzC,4CAAoB;AACpB,
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../packages/dbos-cloud/login.ts"],"names":[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