@fabraix/nyx 0.1.0 → 0.1.2
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/api/client.js +1 -1
- package/dist/api/client.js.map +1 -1
- package/dist/api/types.d.ts +7 -9
- package/dist/commands/login.js +50 -46
- package/dist/commands/login.js.map +1 -1
- package/dist/config/schema.d.ts +16 -16
- package/dist/ui/callback-page.d.ts +1 -0
- package/dist/ui/callback-page.js +85 -0
- package/dist/ui/callback-page.js.map +1 -0
- package/package.json +1 -1
package/dist/api/client.js
CHANGED
package/dist/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAE/C,MAAM,UAAU,UAAU;IACxB,OAAO,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,YAAY,CAAC;AACjD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,MAAc,EACd,IAAY,EACZ,IAAc;IAEd,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE;QACtC,MAAM,EAAE,kBAAkB;QAC1B,IAAI;KACL,CAAC,CAAC;IACH,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAC;AAClC,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAc,EACd,IAAY,EACZ,MAAc;IAEd,OAAO,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,KAAK,UAAU,OAAO,CACpB,MAAc,EACd,IAAY,EACZ,IAAwC;IAExC,MAAM,KAAK,GAAG,QAAQ,EAAE,CAA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IAEF,MAAM,IAAI,QAAQ,CAChB,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,aAAa,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,EAC5D,KAAK,EACL,GAAG,CAAC,MAAM,CACX,CAAC;AACJ,CAAC"}
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
balance_usd: number;
|
|
9
|
-
};
|
|
1
|
+
export interface TokenValidationResponse {
|
|
2
|
+
userId: string;
|
|
3
|
+
email: string;
|
|
4
|
+
username: string;
|
|
5
|
+
beta: string;
|
|
6
|
+
skillCreated: boolean;
|
|
7
|
+
token: string;
|
|
10
8
|
}
|
|
11
9
|
export interface ProtocolEndpoint {
|
|
12
10
|
method: string;
|
package/dist/commands/login.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createServer } from "node:http";
|
|
2
2
|
import open from "open";
|
|
3
3
|
import chalk from "chalk";
|
|
4
|
-
import { saveCredentials } from "../config/auth.js";
|
|
5
|
-
import {
|
|
4
|
+
import { getToken, saveCredentials } from "../config/auth.js";
|
|
5
|
+
import { getBaseUrl } from "../api/client.js";
|
|
6
6
|
import { NyxError, handleError } from "../utils/errors.js";
|
|
7
|
+
import { callbackPage } from "../ui/callback-page.js";
|
|
7
8
|
export function registerLogin(program) {
|
|
8
9
|
program
|
|
9
10
|
.command("login")
|
|
@@ -24,82 +25,85 @@ export function registerLogin(program) {
|
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
async function checkAuth() {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
console.log(` Plan: ${resp.account.plan}`);
|
|
31
|
-
console.log(` Balance: $${resp.account.balance_usd.toFixed(2)}\n`);
|
|
32
|
-
}
|
|
33
|
-
async function interactiveLogin() {
|
|
34
|
-
const { port, codePromise, server } = startCallbackServer();
|
|
35
|
-
const loginUrl = `https://app.fabraix.com/auth/cli?port=${port}`;
|
|
36
|
-
console.log(chalk.dim(`\n Opening browser to: ${loginUrl}`));
|
|
37
|
-
console.log(chalk.dim(" Waiting for authentication...\n"));
|
|
38
|
-
await open(loginUrl);
|
|
39
|
-
let code;
|
|
40
|
-
try {
|
|
41
|
-
code = await codePromise;
|
|
42
|
-
}
|
|
43
|
-
finally {
|
|
44
|
-
server.close();
|
|
28
|
+
const token = getToken();
|
|
29
|
+
if (!token) {
|
|
30
|
+
throw new NyxError("Not authenticated. Run `nyx login` or set NYX_TOKEN.", "auth");
|
|
45
31
|
}
|
|
46
32
|
const baseUrl = getBaseUrl();
|
|
47
33
|
let res;
|
|
48
34
|
try {
|
|
49
|
-
res = await fetch(`${baseUrl}/v1/
|
|
50
|
-
method: "
|
|
51
|
-
headers: { "
|
|
52
|
-
body: JSON.stringify({ code }),
|
|
35
|
+
res = await fetch(`${baseUrl}/v1/verify/token-validation`, {
|
|
36
|
+
method: "GET",
|
|
37
|
+
headers: { "X-Verification-Token": token },
|
|
53
38
|
});
|
|
54
39
|
}
|
|
55
40
|
catch {
|
|
56
41
|
throw new NyxError(`Network error: could not reach ${baseUrl}. Check your internet connection.`, "network");
|
|
57
42
|
}
|
|
58
43
|
if (!res.ok) {
|
|
59
|
-
throw new NyxError("
|
|
44
|
+
throw new NyxError("Authentication failed. Your token may have expired. Run `nyx login`.", "auth");
|
|
60
45
|
}
|
|
61
46
|
const data = (await res.json());
|
|
62
|
-
|
|
63
|
-
|
|
47
|
+
console.log(chalk.green("\n Authenticated"));
|
|
48
|
+
console.log(` Email: ${data.email}`);
|
|
49
|
+
console.log(` User: ${data.username}\n`);
|
|
50
|
+
}
|
|
51
|
+
async function interactiveLogin() {
|
|
52
|
+
const { port, tokenPromise, server } = startCallbackServer();
|
|
53
|
+
const loginUrl = `https://app.fabraix.com/auth/cli?port=${port}`;
|
|
54
|
+
console.log(chalk.dim(`\n Opening browser to: ${loginUrl}`));
|
|
55
|
+
console.log(chalk.dim(" Waiting for authentication...\n"));
|
|
56
|
+
await open(loginUrl);
|
|
57
|
+
let token;
|
|
58
|
+
let email;
|
|
59
|
+
try {
|
|
60
|
+
const result = await tokenPromise;
|
|
61
|
+
token = result.token;
|
|
62
|
+
email = result.email;
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
server.close();
|
|
64
66
|
}
|
|
65
67
|
saveCredentials({
|
|
66
|
-
token
|
|
67
|
-
email
|
|
68
|
-
expires_at: data.expires_at,
|
|
68
|
+
token,
|
|
69
|
+
email,
|
|
69
70
|
});
|
|
70
71
|
console.log(chalk.green(" Logged in successfully!"));
|
|
71
|
-
|
|
72
|
+
if (email) {
|
|
73
|
+
console.log(` Email: ${email}\n`);
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
76
|
function startCallbackServer() {
|
|
74
|
-
let
|
|
75
|
-
let
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
let resolveToken;
|
|
78
|
+
let rejectToken;
|
|
79
|
+
const tokenPromise = new Promise((resolve, reject) => {
|
|
80
|
+
resolveToken = resolve;
|
|
81
|
+
rejectToken = reject;
|
|
79
82
|
});
|
|
80
83
|
const server = createServer((req, res) => {
|
|
81
84
|
const url = new URL(req.url, `http://localhost`);
|
|
82
|
-
const
|
|
83
|
-
|
|
85
|
+
const token = url.searchParams.get("token");
|
|
86
|
+
const email = url.searchParams.get("email") ?? undefined;
|
|
87
|
+
if (token) {
|
|
84
88
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
85
|
-
res.end("
|
|
86
|
-
|
|
89
|
+
res.end(callbackPage("success", email));
|
|
90
|
+
resolveToken({ token, email });
|
|
87
91
|
}
|
|
88
92
|
else {
|
|
89
|
-
res.writeHead(400, { "Content-Type": "text/
|
|
90
|
-
res.end("
|
|
93
|
+
res.writeHead(400, { "Content-Type": "text/html" });
|
|
94
|
+
res.end(callbackPage("error"));
|
|
91
95
|
}
|
|
92
96
|
});
|
|
93
97
|
server.on("error", (err) => {
|
|
94
|
-
|
|
98
|
+
rejectToken(new NyxError(`Failed to start login server: ${err.message}`, "network"));
|
|
95
99
|
});
|
|
96
100
|
server.listen(0);
|
|
97
101
|
const port = server.address().port;
|
|
98
102
|
const timeout = setTimeout(() => {
|
|
99
|
-
|
|
103
|
+
rejectToken(new NyxError("Login timed out. Please try again.", "auth"));
|
|
100
104
|
server.close();
|
|
101
105
|
}, 120_000);
|
|
102
|
-
|
|
103
|
-
return { port,
|
|
106
|
+
tokenPromise.finally(() => clearTimeout(timeout));
|
|
107
|
+
return { port, tokenPromise, server };
|
|
104
108
|
}
|
|
105
109
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SACh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M,CAAC,CAAC,CAAC;QACxE,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC,EAAE,OAAO,CAAC,CAAC;IAEZ,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;IAElD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC"}
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -10,12 +10,12 @@ export declare const configSchema: z.ZodObject<{
|
|
|
10
10
|
body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
11
11
|
response: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
method: "
|
|
13
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
14
14
|
path: string;
|
|
15
15
|
body?: Record<string, unknown> | undefined;
|
|
16
16
|
response?: Record<string, string> | undefined;
|
|
17
17
|
}, {
|
|
18
|
-
method: "
|
|
18
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
19
19
|
path: string;
|
|
20
20
|
body?: Record<string, unknown> | undefined;
|
|
21
21
|
response?: Record<string, string> | undefined;
|
|
@@ -26,38 +26,38 @@ export declare const configSchema: z.ZodObject<{
|
|
|
26
26
|
body: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
27
27
|
response: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
28
28
|
}, "strip", z.ZodTypeAny, {
|
|
29
|
-
method: "
|
|
29
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
30
30
|
path: string;
|
|
31
31
|
body?: Record<string, unknown> | undefined;
|
|
32
32
|
response?: Record<string, string> | undefined;
|
|
33
33
|
}, {
|
|
34
|
-
method: "
|
|
34
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
35
35
|
path: string;
|
|
36
36
|
body?: Record<string, unknown> | undefined;
|
|
37
37
|
response?: Record<string, string> | undefined;
|
|
38
38
|
}>;
|
|
39
39
|
}, "strip", z.ZodTypeAny, {
|
|
40
40
|
create_session: {
|
|
41
|
-
method: "
|
|
41
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
42
42
|
path: string;
|
|
43
43
|
body?: Record<string, unknown> | undefined;
|
|
44
44
|
response?: Record<string, string> | undefined;
|
|
45
45
|
};
|
|
46
46
|
send_message: {
|
|
47
|
-
method: "
|
|
47
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
48
48
|
path: string;
|
|
49
49
|
body?: Record<string, unknown> | undefined;
|
|
50
50
|
response?: Record<string, string> | undefined;
|
|
51
51
|
};
|
|
52
52
|
}, {
|
|
53
53
|
create_session: {
|
|
54
|
-
method: "
|
|
54
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
55
55
|
path: string;
|
|
56
56
|
body?: Record<string, unknown> | undefined;
|
|
57
57
|
response?: Record<string, string> | undefined;
|
|
58
58
|
};
|
|
59
59
|
send_message: {
|
|
60
|
-
method: "
|
|
60
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
61
61
|
path: string;
|
|
62
62
|
body?: Record<string, unknown> | undefined;
|
|
63
63
|
response?: Record<string, string> | undefined;
|
|
@@ -67,13 +67,13 @@ export declare const configSchema: z.ZodObject<{
|
|
|
67
67
|
base_url: string;
|
|
68
68
|
protocol: {
|
|
69
69
|
create_session: {
|
|
70
|
-
method: "
|
|
70
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
71
71
|
path: string;
|
|
72
72
|
body?: Record<string, unknown> | undefined;
|
|
73
73
|
response?: Record<string, string> | undefined;
|
|
74
74
|
};
|
|
75
75
|
send_message: {
|
|
76
|
-
method: "
|
|
76
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
77
77
|
path: string;
|
|
78
78
|
body?: Record<string, unknown> | undefined;
|
|
79
79
|
response?: Record<string, string> | undefined;
|
|
@@ -83,13 +83,13 @@ export declare const configSchema: z.ZodObject<{
|
|
|
83
83
|
base_url: string;
|
|
84
84
|
protocol: {
|
|
85
85
|
create_session: {
|
|
86
|
-
method: "
|
|
86
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
87
87
|
path: string;
|
|
88
88
|
body?: Record<string, unknown> | undefined;
|
|
89
89
|
response?: Record<string, string> | undefined;
|
|
90
90
|
};
|
|
91
91
|
send_message: {
|
|
92
|
-
method: "
|
|
92
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
93
93
|
path: string;
|
|
94
94
|
body?: Record<string, unknown> | undefined;
|
|
95
95
|
response?: Record<string, string> | undefined;
|
|
@@ -106,13 +106,13 @@ export declare const configSchema: z.ZodObject<{
|
|
|
106
106
|
base_url: string;
|
|
107
107
|
protocol: {
|
|
108
108
|
create_session: {
|
|
109
|
-
method: "
|
|
109
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
110
110
|
path: string;
|
|
111
111
|
body?: Record<string, unknown> | undefined;
|
|
112
112
|
response?: Record<string, string> | undefined;
|
|
113
113
|
};
|
|
114
114
|
send_message: {
|
|
115
|
-
method: "
|
|
115
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
116
116
|
path: string;
|
|
117
117
|
body?: Record<string, unknown> | undefined;
|
|
118
118
|
response?: Record<string, string> | undefined;
|
|
@@ -129,13 +129,13 @@ export declare const configSchema: z.ZodObject<{
|
|
|
129
129
|
base_url: string;
|
|
130
130
|
protocol: {
|
|
131
131
|
create_session: {
|
|
132
|
-
method: "
|
|
132
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
133
133
|
path: string;
|
|
134
134
|
body?: Record<string, unknown> | undefined;
|
|
135
135
|
response?: Record<string, string> | undefined;
|
|
136
136
|
};
|
|
137
137
|
send_message: {
|
|
138
|
-
method: "
|
|
138
|
+
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
139
139
|
path: string;
|
|
140
140
|
body?: Record<string, unknown> | undefined;
|
|
141
141
|
response?: Record<string, string> | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function callbackPage(status: "success" | "error", email?: string): string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const FONT_URL = "https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap";
|
|
2
|
+
const STYLES = `
|
|
3
|
+
*{margin:0;padding:0;box-sizing:border-box}
|
|
4
|
+
body{
|
|
5
|
+
font-family:'JetBrains Mono',monospace;
|
|
6
|
+
background:#fff;
|
|
7
|
+
min-height:100vh;
|
|
8
|
+
display:flex;
|
|
9
|
+
align-items:center;
|
|
10
|
+
justify-content:center;
|
|
11
|
+
padding:24px;
|
|
12
|
+
}
|
|
13
|
+
.container{width:100%;max-width:448px}
|
|
14
|
+
.logo{text-align:center;margin-bottom:32px;font-size:24px;font-weight:700;letter-spacing:-0.025em;color:#171717}
|
|
15
|
+
.card{border:1px solid #e5e5e5;padding:32px}
|
|
16
|
+
.header{display:flex;align-items:center;gap:8px;margin-bottom:8px}
|
|
17
|
+
.prefix{color:#f97316;font-size:14px}
|
|
18
|
+
.title{color:#525252;font-size:14px;text-transform:uppercase;letter-spacing:0.05em}
|
|
19
|
+
.subtitle{font-size:14px;color:#737373;margin-bottom:24px}
|
|
20
|
+
.icon{display:flex;justify-content:center;margin-bottom:16px}
|
|
21
|
+
.body{text-align:center}
|
|
22
|
+
.error-box{border:1px solid #fecaca;background:#fef2f2;padding:16px}
|
|
23
|
+
.error-box p{font-size:14px;color:#991b1b;margin:0}
|
|
24
|
+
.error-box code{background:#fee2e2;padding:2px 6px}
|
|
25
|
+
.footer{margin-top:24px;text-align:center}
|
|
26
|
+
.footer p{font-size:11px;color:#a3a3a3}
|
|
27
|
+
.footer a{color:#a3a3a3;text-decoration:underline}
|
|
28
|
+
.footer a:hover{color:#525252}
|
|
29
|
+
code{font-family:'JetBrains Mono',monospace}
|
|
30
|
+
`;
|
|
31
|
+
const ICONS = {
|
|
32
|
+
success: `<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="#16a34a" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 13l4 4L19 7"/></svg>`,
|
|
33
|
+
error: `<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="#dc2626" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 6L6 18"/><path d="M6 6l12 12"/></svg>`,
|
|
34
|
+
};
|
|
35
|
+
function successBody(email) {
|
|
36
|
+
return [
|
|
37
|
+
`<p style="font-size:14px;color:#404040;margin:0 0 8px">Authentication successful.</p>`,
|
|
38
|
+
email
|
|
39
|
+
? `<p style="font-size:13px;color:#737373;margin:0 0 8px">${email}</p>`
|
|
40
|
+
: "",
|
|
41
|
+
`<p style="font-size:13px;color:#737373;margin:0">You can close this tab and return to your terminal.</p>`,
|
|
42
|
+
].join("\n");
|
|
43
|
+
}
|
|
44
|
+
function errorBody() {
|
|
45
|
+
return `<div class="error-box">
|
|
46
|
+
<p>Authentication failed. Please run <code>nyx login</code> again.</p>
|
|
47
|
+
</div>`;
|
|
48
|
+
}
|
|
49
|
+
export function callbackPage(status, email) {
|
|
50
|
+
const isSuccess = status === "success";
|
|
51
|
+
return `<!DOCTYPE html>
|
|
52
|
+
<html lang="en">
|
|
53
|
+
<head>
|
|
54
|
+
<meta charset="utf-8"/>
|
|
55
|
+
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
|
56
|
+
<title>Fabraix CLI Auth</title>
|
|
57
|
+
<link rel="preconnect" href="https://fonts.googleapis.com"/>
|
|
58
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
|
|
59
|
+
<link href="${FONT_URL}" rel="stylesheet"/>
|
|
60
|
+
<style>${STYLES}</style>
|
|
61
|
+
</head>
|
|
62
|
+
<body>
|
|
63
|
+
<div class="container">
|
|
64
|
+
<div class="logo">FABRAIX</div>
|
|
65
|
+
<div class="card">
|
|
66
|
+
<div class="header">
|
|
67
|
+
<span class="prefix">${isSuccess ? "○" : "x"}</span>
|
|
68
|
+
<span class="title">${isSuccess ? "CLI Authentication" : "Authentication Error"}</span>
|
|
69
|
+
</div>
|
|
70
|
+
<p class="subtitle">Nyx CLI authentication</p>
|
|
71
|
+
<div class="icon">${ICONS[status]}</div>
|
|
72
|
+
<div class="body">${isSuccess ? successBody(email) : errorBody()}</div>
|
|
73
|
+
</div>
|
|
74
|
+
<div class="footer">
|
|
75
|
+
<p>
|
|
76
|
+
<a href="https://www.fabraix.com/privacy-policy">Privacy Policy</a>
|
|
77
|
+
·
|
|
78
|
+
<a href="https://www.fabraix.com/terms">Terms of Service</a>
|
|
79
|
+
</p>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</body>
|
|
83
|
+
</html>`;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=callback-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callback-page.js","sourceRoot":"","sources":["../../src/ui/callback-page.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GACZ,2FAA2F,CAAC;AAE9F,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4Bd,CAAC;AAEF,MAAM,KAAK,GAAG;IACZ,OAAO,EAAE,+KAA+K;IACxL,KAAK,EAAE,iMAAiM;CACzM,CAAC;AAEF,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO;QACL,uFAAuF;QACvF,KAAK;YACH,CAAC,CAAC,0DAA0D,KAAK,MAAM;YACvE,CAAC,CAAC,EAAE;QACN,0GAA0G;KAC3G,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAS,SAAS;IAChB,OAAO;;OAEF,CAAC;AACR,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,MAA2B,EAC3B,KAAc;IAEd,MAAM,SAAS,GAAG,MAAM,KAAK,SAAS,CAAC;IAEvC,OAAO;;;;;;;;gBAQO,QAAQ;WACb,MAAM;;;;;;;+BAOc,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG;8BACtB,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,sBAAsB;;;0BAG7D,KAAK,CAAC,MAAM,CAAC;0BACb,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE;;;;;;;;;;;QAW9D,CAAC;AACT,CAAC"}
|