@dbos-inc/dbos-sdk 0.7.19-preview → 0.7.20-preview
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/cloud-cli/cli.js +13 -8
- package/dist/src/cloud-cli/cli.js.map +1 -1
- package/dist/src/cloud-cli/login.d.ts +3 -1
- package/dist/src/cloud-cli/login.d.ts.map +1 -1
- package/dist/src/cloud-cli/login.js +83 -22
- package/dist/src/cloud-cli/login.js.map +1 -1
- package/dist/src/cloud-cli/register.d.ts +1 -1
- package/dist/src/cloud-cli/register.d.ts.map +1 -1
- package/dist/src/cloud-cli/register.js +8 -3
- package/dist/src/cloud-cli/register.js.map +1 -1
- package/dist/src/cloud-cli/utils.d.ts +1 -0
- package/dist/src/cloud-cli/utils.d.ts.map +1 -1
- package/dist/src/cloud-cli/utils.js +5 -1
- package/dist/src/cloud-cli/utils.js.map +1 -1
- package/package.json +3 -1
@@ -6,6 +6,7 @@ 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 utils_1 = require("./utils");
|
9
10
|
const program = new commander_1.Command();
|
10
11
|
const DEFAULT_HOST = "localhost";
|
11
12
|
const DEFAULT_PORT = "8080";
|
@@ -19,22 +20,26 @@ program.
|
|
19
20
|
program
|
20
21
|
.command('login')
|
21
22
|
.description('Log in to DBOS cloud')
|
22
|
-
.requiredOption('-u, --
|
23
|
-
.action((options) => {
|
24
|
-
(0, login_1.login)(options.
|
23
|
+
.requiredOption('-u, --username <string>', 'Username')
|
24
|
+
.action(async (options) => {
|
25
|
+
const exitCode = await (0, login_1.login)(options.username);
|
26
|
+
process.exit(exitCode);
|
25
27
|
});
|
26
28
|
program
|
27
29
|
.command('register')
|
28
30
|
.description('Register a user and log in to DBOS cloud')
|
29
|
-
.requiredOption('-u, --
|
31
|
+
.requiredOption('-u, --username <string>', 'Username')
|
30
32
|
.option('-h, --host <string>', 'Specify the host', DEFAULT_HOST)
|
31
33
|
.option('-p, --port <string>', 'Specify the port', DEFAULT_PORT)
|
32
34
|
.action(async (options) => {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
if (!(0, utils_1.credentialsExist)()) {
|
36
|
+
const exitCode = await (0, login_1.login)(options.username);
|
37
|
+
if (exitCode !== 0) {
|
38
|
+
process.exit(exitCode);
|
39
|
+
}
|
37
40
|
}
|
41
|
+
const exitCode = await (0, register_1.registerUser)(options.username, options.host, options.port);
|
42
|
+
process.exit(exitCode);
|
38
43
|
});
|
39
44
|
/////////////////////////////
|
40
45
|
/* APPLICATIONS MANAGEMENT */
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/cloud-cli/cli.ts"],"names":[],"mappings":";;;AAEA,kDAQyB;AACzB,yCAAoC;AACpC,mCAAgC;AAChC,yCAA0C;AAC1C,qCAAiE;
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/cloud-cli/cli.ts"],"names":[],"mappings":";;;AAEA,kDAQyB;AACzB,yCAAoC;AACpC,mCAAgC;AAChC,yCAA0C;AAC1C,qCAAiE;AACjE,mCAA2C;AAE3C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,MAAM,YAAY,GAAG,WAAW,CAAA;AAChC,MAAM,YAAY,GAAG,MAAM,CAAA;AAE3B,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,aA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-api";
|
2
4
|
export interface DBOSCloudCredentials {
|
3
5
|
token: string;
|
4
6
|
userName: string;
|
5
7
|
}
|
6
|
-
export declare function login(
|
8
|
+
export declare function login(username: string): Promise<number>;
|
7
9
|
//# sourceMappingURL=login.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/cloud-cli/login.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/cloud-cli/login.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW,UAAU,CAAC;AACnC,eAAO,MAAM,YAAY,qCAAqC,CAAA;AAC9D,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AAEnD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AA8CD,wBAAsB,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA2D7D"}
|
@@ -3,38 +3,99 @@ 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 = exports.dbosEnvPath = void 0;
|
7
|
-
const child_process_1 = require("child_process");
|
8
|
-
const jwt_simple_1 = require("jwt-simple");
|
6
|
+
exports.login = exports.DBOSCloudIdentifier = exports.DBOSClientID = exports.dbosEnvPath = void 0;
|
9
7
|
const logs_1 = require("../telemetry/logs");
|
8
|
+
const axios_1 = __importDefault(require("axios"));
|
9
|
+
const utils_1 = require("../utils");
|
10
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
11
|
+
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
12
|
+
const child_process_1 = require("child_process");
|
10
13
|
const fs_1 = __importDefault(require("fs"));
|
11
14
|
exports.dbosEnvPath = ".dbos";
|
12
|
-
|
13
|
-
|
15
|
+
exports.DBOSClientID = 'G38fLmVErczEo9ioCFjVIHea6yd0qMZu';
|
16
|
+
exports.DBOSCloudIdentifier = 'dbos-cloud-api';
|
17
|
+
const client = (0, jwks_rsa_1.default)({
|
18
|
+
jwksUri: 'https://dbos-inc.us.auth0.com/.well-known/jwks.json'
|
19
|
+
});
|
20
|
+
async function getSigningKey(kid) {
|
21
|
+
const key = await client.getSigningKey(kid);
|
22
|
+
return key.getPublicKey();
|
23
|
+
}
|
24
|
+
async function verifyToken(token) {
|
25
|
+
const decoded = jsonwebtoken_1.default.decode(token, { complete: true });
|
26
|
+
if (!decoded || typeof decoded === 'string' || !decoded.header.kid) {
|
27
|
+
throw new Error('Invalid token');
|
28
|
+
}
|
29
|
+
const signingKey = await getSigningKey(decoded.header.kid);
|
30
|
+
return new Promise((resolve, reject) => {
|
31
|
+
jsonwebtoken_1.default.verify(token, signingKey, { algorithms: ['RS256'] }, (err, verifiedToken) => {
|
32
|
+
if (err) {
|
33
|
+
reject(err);
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
resolve(verifiedToken);
|
37
|
+
}
|
38
|
+
});
|
39
|
+
});
|
40
|
+
}
|
41
|
+
async function login(username) {
|
14
42
|
const logger = (0, logs_1.createGlobalLogger)();
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
43
|
+
logger.info(`Logging in!`);
|
44
|
+
const deviceCodeRequest = {
|
45
|
+
method: 'POST',
|
46
|
+
url: 'https://dbos-inc.us.auth0.com/oauth/device/code',
|
47
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
48
|
+
data: { client_id: exports.DBOSClientID, scope: 'sub', audience: exports.DBOSCloudIdentifier }
|
49
|
+
};
|
50
|
+
let deviceCodeResponse;
|
51
|
+
try {
|
52
|
+
const response = await axios_1.default.request(deviceCodeRequest);
|
53
|
+
deviceCodeResponse = response.data;
|
54
|
+
}
|
55
|
+
catch (e) {
|
56
|
+
logger.error(`failed to log in`, e);
|
57
|
+
}
|
58
|
+
if (!deviceCodeResponse) {
|
59
|
+
return 1;
|
60
|
+
}
|
61
|
+
console.log(`Login URL: ${deviceCodeResponse.verification_uri_complete}`);
|
62
|
+
const tokenRequest = {
|
63
|
+
method: 'POST',
|
64
|
+
url: 'https://dbos-inc.us.auth0.com/oauth/token',
|
65
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
66
|
+
data: new URLSearchParams({
|
67
|
+
grant_type: 'urn:ietf:params:oauth:grant-type:device_code',
|
68
|
+
device_code: deviceCodeResponse.device_code,
|
69
|
+
client_id: exports.DBOSClientID
|
70
|
+
})
|
28
71
|
};
|
29
|
-
|
72
|
+
let tokenResponse;
|
73
|
+
let elapsedTimeSec = 0;
|
74
|
+
while (elapsedTimeSec < deviceCodeResponse.expires_in) {
|
75
|
+
try {
|
76
|
+
await (0, utils_1.sleep)(deviceCodeResponse.interval * 1000);
|
77
|
+
elapsedTimeSec += deviceCodeResponse.interval;
|
78
|
+
const response = await axios_1.default.request(tokenRequest);
|
79
|
+
tokenResponse = response.data;
|
80
|
+
break;
|
81
|
+
}
|
82
|
+
catch (e) {
|
83
|
+
logger.info(`Waiting for login...`);
|
84
|
+
}
|
85
|
+
}
|
86
|
+
if (!tokenResponse) {
|
87
|
+
return 1;
|
88
|
+
}
|
89
|
+
await verifyToken(tokenResponse.access_token);
|
30
90
|
const credentials = {
|
31
|
-
token,
|
32
|
-
userName,
|
91
|
+
token: tokenResponse.access_token,
|
92
|
+
userName: username,
|
33
93
|
};
|
34
94
|
(0, child_process_1.execSync)(`mkdir -p ${exports.dbosEnvPath}`);
|
35
95
|
fs_1.default.writeFileSync(`${exports.dbosEnvPath}/credentials`, JSON.stringify(credentials), "utf-8");
|
36
|
-
logger.info(`Successfully logged in as user: ${userName}`);
|
96
|
+
logger.info(`Successfully logged in as user: ${credentials.userName}`);
|
37
97
|
logger.info(`You can view your credentials in: ./${exports.dbosEnvPath}/credentials`);
|
98
|
+
return 0;
|
38
99
|
}
|
39
100
|
exports.login = login;
|
40
101
|
//# sourceMappingURL=login.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/cloud-cli/login.ts"],"names":[],"mappings":";;;;;;AAAA,
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/cloud-cli/login.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAuD;AACvD,kDAA0B;AAC1B,oCAAiC;AACjC,gEAA+C;AAC/C,wDAAkC;AAClC,iDAAyC;AACzC,4CAAoB;AAEP,QAAA,WAAW,GAAG,OAAO,CAAC;AACtB,QAAA,YAAY,GAAG,kCAAkC,CAAA;AACjD,QAAA,mBAAmB,GAAG,gBAAgB,CAAA;AAsBnD,MAAM,MAAM,GAAG,IAAA,kBAAU,EAAC;IACxB,OAAO,EAAE,qDAAqD;CAC/D,CAAC,CAAC;AAEH,KAAK,UAAU,aAAa,CAAC,GAAW;IACtC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC5C,OAAO,GAAG,CAAC,YAAY,EAAE,CAAC;AAC5B,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,KAAa;IACtC,MAAM,OAAO,GAAG,sBAAG,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE;QAClE,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;KAClC;IAED,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAE3D,OAAO,IAAI,OAAO,CAAC,CAAC,O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|
-
export declare function registerUser(
|
1
|
+
export declare function registerUser(username: string, host: string, port: string): Promise<number>;
|
2
2
|
//# sourceMappingURL=register.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/cloud-cli/register.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/cloud-cli/register.ts"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BhG"}
|
@@ -6,7 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.registerUser = void 0;
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
8
8
|
const logs_1 = require("../telemetry/logs");
|
9
|
-
|
9
|
+
const utils_1 = require("./utils");
|
10
|
+
async function registerUser(username, host, port) {
|
11
|
+
const userCredentials = (0, utils_1.getCloudCredentials)();
|
12
|
+
const bearerToken = "Bearer " + userCredentials.token;
|
13
|
+
const userName = userCredentials.userName;
|
10
14
|
const logger = (0, logs_1.createGlobalLogger)();
|
11
15
|
try {
|
12
16
|
// First, register the user.
|
@@ -15,6 +19,7 @@ async function registerUser(userName, host, port) {
|
|
15
19
|
}, {
|
16
20
|
headers: {
|
17
21
|
"Content-Type": "application/json",
|
22
|
+
Authorization: bearerToken,
|
18
23
|
},
|
19
24
|
});
|
20
25
|
const userUUID = register.data;
|
@@ -27,9 +32,9 @@ async function registerUser(userName, host, port) {
|
|
27
32
|
else {
|
28
33
|
logger.error(`failed to register user ${userName}: ${e.message}`);
|
29
34
|
}
|
30
|
-
return
|
35
|
+
return 1;
|
31
36
|
}
|
32
|
-
return
|
37
|
+
return 0;
|
33
38
|
}
|
34
39
|
exports.registerUser = registerUser;
|
35
40
|
//# sourceMappingURL=register.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/cloud-cli/register.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,4CAAuD;
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/cloud-cli/register.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,4CAAuD;AACvD,mCAA8C;AAEvC,KAAK,UAAU,YAAY,CAAC,QAAgB,EAAE,IAAY,EAAE,IAAY;IAC7E,MAAM,eAAe,GAAG,IAAA,2BAAmB,GAAE,CAAC;IAC9C,MAAM,WAAW,GAAG,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;IACtD,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAA,yBAAkB,GAAE,CAAC;IACpC,IAAI;QACF,4BAA4B;QAC5B,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,UAAU,IAAI,IAAI,IAAI,OAAO,EAC7B;YACE,IAAI,EAAE,QAAQ;SACf,EACD;YACE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,WAAW;aAC3B;SACF,CACF,CAAC;QACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAc,CAAC;QACzC,MAAM,CAAC,IAAI,CAAC,mBAAmB,QAAQ,WAAW,QAAQ,EAAE,CAAC,CAAC;KAC/D;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,eAAK,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE;YACvC,MAAM,CAAC,KAAK,CAAC,2BAA2B,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;SACzE;aAAM;YACL,MAAM,CAAC,KAAK,CAAC,2BAA2B,QAAQ,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;SAC9E;QACD,OAAO,CAAC,CAAC;KACV;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AA9BD,oCA8BC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cloud-cli/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAe,MAAM,SAAS,CAAC;AAG5D,wBAAgB,mBAAmB,IAAI,oBAAoB,CAM1D"}
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cloud-cli/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAe,MAAM,SAAS,CAAC;AAG5D,wBAAgB,mBAAmB,IAAI,oBAAoB,CAM1D;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C"}
|
@@ -3,7 +3,7 @@ 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.getCloudCredentials = void 0;
|
6
|
+
exports.credentialsExist = exports.getCloudCredentials = void 0;
|
7
7
|
const login_1 = require("./login");
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
9
9
|
function getCloudCredentials() {
|
@@ -14,4 +14,8 @@ function getCloudCredentials() {
|
|
14
14
|
};
|
15
15
|
}
|
16
16
|
exports.getCloudCredentials = getCloudCredentials;
|
17
|
+
function credentialsExist() {
|
18
|
+
return fs_1.default.existsSync(`./${login_1.dbosEnvPath}/credentials`);
|
19
|
+
}
|
20
|
+
exports.credentialsExist = credentialsExist;
|
17
21
|
//# sourceMappingURL=utils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/cloud-cli/utils.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA4D;AAC5D,4CAAoB;AAEpB,SAAgB,mBAAmB;IACjC,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,KAAK,mBAAW,cAAc,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAyB,CAAC;IAC9H,OAAO;QACL,QAAQ,EAAE,eAAe,CAAC,QAAQ;QAClC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,2BAA2B;KAChF,CAAC;AACJ,CAAC;AAND,kDAMC"}
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/cloud-cli/utils.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA4D;AAC5D,4CAAoB;AAEpB,SAAgB,mBAAmB;IACjC,MAAM,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,KAAK,mBAAW,cAAc,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAyB,CAAC;IAC9H,OAAO;QACL,QAAQ,EAAE,eAAe,CAAC,QAAQ;QAClC,KAAK,EAAE,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,EAAE,2BAA2B;KAChF,CAAC;AACJ,CAAC;AAND,kDAMC;AAED,SAAgB,gBAAgB;IAC9B,OAAO,YAAE,CAAC,UAAU,CAAC,KAAK,mBAAW,cAAc,CAAC,CAAC;AACvD,CAAC;AAFD,4CAEC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dbos-inc/dbos-sdk",
|
3
|
-
"version": "0.7.
|
3
|
+
"version": "0.7.20-preview",
|
4
4
|
"description": "A Typescript framework built on the database",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": {
|
@@ -57,6 +57,8 @@
|
|
57
57
|
"commander": "^11.0.0",
|
58
58
|
"fast-glob": "^3.3.1",
|
59
59
|
"form-data": "^4.0.0",
|
60
|
+
"jsonwebtoken": "^9.0.2",
|
61
|
+
"jwks-rsa": "^3.1.0",
|
60
62
|
"jwt-simple": "^0.5.6",
|
61
63
|
"knex": "^3.0.1",
|
62
64
|
"koa": "^2.14.2",
|