@sentio/cli 4.4.0-rc.2 → 4.4.0
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/index.js +10 -2
- package/package.json +1 -1
- package/src/commands/login-server.ts +12 -2
package/dist/index.js
CHANGED
|
@@ -46183,6 +46183,13 @@ function isAccessTokenExpired(expiresAt) {
|
|
|
46183
46183
|
}
|
|
46184
46184
|
//#endregion
|
|
46185
46185
|
//#region src/commands/login-server.ts
|
|
46186
|
+
function loginResultPage(message) {
|
|
46187
|
+
return `<!doctype html>
|
|
46188
|
+
<html lang="en">
|
|
46189
|
+
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Sentio CLI</title></head>
|
|
46190
|
+
<body><p>${message}</p></body>
|
|
46191
|
+
</html>`;
|
|
46192
|
+
}
|
|
46186
46193
|
function startServer(params) {
|
|
46187
46194
|
return new Promise((resolve, reject) => {
|
|
46188
46195
|
const app = (0, import_express.default)();
|
|
@@ -46206,8 +46213,9 @@ function startServer(params) {
|
|
|
46206
46213
|
process.once("SIGINT", interrupted);
|
|
46207
46214
|
app.get("/callback", async (req, res) => {
|
|
46208
46215
|
res.setHeader("Cache-Control", "no-store");
|
|
46216
|
+
res.type("html");
|
|
46209
46217
|
if (typeof req.query.state !== "string" || req.query.state !== params.state) {
|
|
46210
|
-
res.status(400).end("Invalid authorization state");
|
|
46218
|
+
res.status(400).end(loginResultPage("Invalid authorization state"));
|
|
46211
46219
|
return;
|
|
46212
46220
|
}
|
|
46213
46221
|
responses++;
|
|
@@ -46220,7 +46228,7 @@ function startServer(params) {
|
|
|
46220
46228
|
};
|
|
46221
46229
|
if (res.destroyed) return complete();
|
|
46222
46230
|
res.once("close", complete);
|
|
46223
|
-
res.status(error ? 400 : 200).end(message, complete);
|
|
46231
|
+
res.status(error ? 400 : 200).end(loginResultPage(message), complete);
|
|
46224
46232
|
};
|
|
46225
46233
|
try {
|
|
46226
46234
|
if (req.query.error) throw new Error("Authorization was not completed");
|
package/package.json
CHANGED
|
@@ -17,6 +17,15 @@ interface AuthParams {
|
|
|
17
17
|
timeoutMs?: number
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// Only fixed messages are rendered; OAuth parameters never appear in the page.
|
|
21
|
+
function loginResultPage(message: string): string {
|
|
22
|
+
return `<!doctype html>
|
|
23
|
+
<html lang="en">
|
|
24
|
+
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Sentio CLI</title></head>
|
|
25
|
+
<body><p>${message}</p></body>
|
|
26
|
+
</html>`
|
|
27
|
+
}
|
|
28
|
+
|
|
20
29
|
export function startServer(params: AuthParams): Promise<void> {
|
|
21
30
|
return new Promise((resolve, reject) => {
|
|
22
31
|
const app = express()
|
|
@@ -43,8 +52,9 @@ export function startServer(params: AuthParams): Promise<void> {
|
|
|
43
52
|
process.once('SIGINT', interrupted)
|
|
44
53
|
app.get('/callback', async (req, res) => {
|
|
45
54
|
res.setHeader('Cache-Control', 'no-store')
|
|
55
|
+
res.type('html')
|
|
46
56
|
if (typeof req.query.state !== 'string' || req.query.state !== params.state) {
|
|
47
|
-
res.status(400).end('Invalid authorization state')
|
|
57
|
+
res.status(400).end(loginResultPage('Invalid authorization state'))
|
|
48
58
|
return
|
|
49
59
|
}
|
|
50
60
|
responses++
|
|
@@ -59,7 +69,7 @@ export function startServer(params: AuthParams): Promise<void> {
|
|
|
59
69
|
}
|
|
60
70
|
if (res.destroyed) return complete()
|
|
61
71
|
res.once('close', complete)
|
|
62
|
-
res.status(error ? 400 : 200).end(message, complete)
|
|
72
|
+
res.status(error ? 400 : 200).end(loginResultPage(message), complete)
|
|
63
73
|
}
|
|
64
74
|
try {
|
|
65
75
|
if (req.query.error) throw new Error('Authorization was not completed')
|