alpic 0.0.0-dev.bc2891a → 0.0.0-dev.bcdbc80
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/commands/login.js +3 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/lib/auth/oauth/pages/CallbackPage.d.ts +7 -0
- package/dist/lib/auth/oauth/pages/CallbackPage.js +6 -0
- package/dist/lib/auth/oauth/pages/CallbackPage.js.map +1 -0
- package/dist/lib/auth/oauth/pages/Layout.d.ts +7 -0
- package/dist/lib/auth/oauth/pages/Layout.js +6 -0
- package/dist/lib/auth/oauth/pages/Layout.js.map +1 -0
- package/dist/lib/auth/oauth/pages/PickerPage.d.ts +5 -0
- package/dist/lib/auth/oauth/pages/PickerPage.js +11 -0
- package/dist/lib/auth/oauth/pages/PickerPage.js.map +1 -0
- package/dist/lib/auth/oauth/pages/styles.d.ts +1 -0
- package/dist/lib/auth/oauth/pages/styles.js +145 -0
- package/dist/lib/auth/oauth/pages/styles.js.map +1 -0
- package/dist/lib/auth/oauth/server.d.ts +3 -1
- package/dist/lib/auth/oauth/server.js +23 -35
- package/dist/lib/auth/oauth/server.js.map +1 -1
- package/package.json +16 -14
package/dist/commands/login.js
CHANGED
|
@@ -3,7 +3,7 @@ import chalk from "chalk";
|
|
|
3
3
|
import open from "open";
|
|
4
4
|
import { AlpicCommand } from "../lib/alpic-command.js";
|
|
5
5
|
import { oAuthClient } from "../lib/auth/oauth/client.js";
|
|
6
|
-
import { listenToOAuthCallback } from "../lib/auth/oauth/server.js";
|
|
6
|
+
import { getLoginPageUrl, listenToOAuthCallback } from "../lib/auth/oauth/server.js";
|
|
7
7
|
import { getWhoamiInfo } from "../lib/auth/whoami.js";
|
|
8
8
|
import { globalStore } from "../lib/global-store.js";
|
|
9
9
|
export class Login extends AlpicCommand {
|
|
@@ -19,11 +19,12 @@ export class Login extends AlpicCommand {
|
|
|
19
19
|
}
|
|
20
20
|
const { authorizeUrl, state, nonce, codeVerifier } = await oAuthClient.prepareOAuthConfig();
|
|
21
21
|
p.log.message("Opening browser to log in…");
|
|
22
|
-
await open(
|
|
22
|
+
await open(getLoginPageUrl());
|
|
23
23
|
const storedToken = await listenToOAuthCallback({
|
|
24
24
|
state,
|
|
25
25
|
nonce,
|
|
26
26
|
codeVerifier,
|
|
27
|
+
authorizeUrl: authorizeUrl.toString(),
|
|
27
28
|
});
|
|
28
29
|
globalStore.saveCredentials(storedToken);
|
|
29
30
|
const info = await getWhoamiInfo();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,OAAO,KAAM,SAAQ,YAAY;IACrC,MAAM,CAAU,WAAW,GAAG,gDAAgD,CAAC;IA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} from "./Layout.js";
|
|
3
|
+
export function CallbackPage({ title, body, success }) {
|
|
4
|
+
return (_jsx(Layout, { pageTitle: title, children: _jsxs("div", { class: success ? "callback callback--success" : "callback callback--error", children: [_jsx("h1", { children: title }), _jsx("p", { class: "subtitle", children: body })] }) }));
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=CallbackPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CallbackPage.js","sourceRoot":"","sources":["../../../../../src/lib/auth/oauth/pages/CallbackPage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAQrC,MAAM,UAAU,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAqB;IACtE,OAAO,CACL,KAAC,MAAM,IAAC,SAAS,EAAE,KAAK,YACtB,eAAK,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,0BAA0B,aAC7E,uBAAK,KAAK,GAAM,EAChB,YAAG,KAAK,EAAC,UAAU,YAAE,IAAI,GAAK,IAC1B,GACC,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { STYLES } from "./styles.js";
|
|
3
|
+
export function Layout({ pageTitle, children }) {
|
|
4
|
+
return (_jsxs("html", { lang: "en", children: [_jsxs("head", { children: [_jsx("meta", { charset: "UTF-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1.0" }), _jsx("title", { children: pageTitle }), _jsx("link", { href: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Mozilla+Text:wght@200..700&display=swap", rel: "stylesheet" }), _jsx("style", { dangerouslySetInnerHTML: { __html: STYLES } })] }), _jsx("body", { children: _jsx("div", { class: "card", children: children }) })] }));
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=Layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Layout.js","sourceRoot":"","sources":["../../../../../src/lib/auth/oauth/pages/Layout.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAOrC,MAAM,UAAU,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAe;IACzD,OAAO,CACL,gBAAM,IAAI,EAAC,IAAI,aACb,2BACE,eAAM,OAAO,EAAC,OAAO,GAAG,EACxB,eAAM,IAAI,EAAC,UAAU,EAAC,OAAO,EAAC,uCAAuC,GAAG,EACxE,0BAAQ,SAAS,GAAS,EAC1B,eACE,IAAI,EAAC,gHAAgH,EACrH,GAAG,EAAC,YAAY,GAChB,EACF,gBAAO,uBAAuB,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAI,IACjD,EACP,yBACE,cAAK,KAAK,EAAC,MAAM,YAAE,QAAQ,GAAO,GAC7B,IACF,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "preact/jsx-runtime";
|
|
2
|
+
import { Layout } from "./Layout.js";
|
|
3
|
+
function injectProvider(authorizeUrl, provider) {
|
|
4
|
+
const url = new URL(authorizeUrl);
|
|
5
|
+
url.searchParams.set("identity_provider", provider);
|
|
6
|
+
return url.toString();
|
|
7
|
+
}
|
|
8
|
+
export function PickerPage({ authorizeUrl }) {
|
|
9
|
+
return (_jsxs(Layout, { pageTitle: "Sign in to Alpic", children: [_jsx("h1", { children: "Welcome to Alpic" }), _jsx("p", { class: "subtitle", children: "Sign in to manage your MCP Servers" }), _jsxs("div", { class: "buttons", children: [_jsxs("a", { href: injectProvider(authorizeUrl, "Github"), class: "btn btn-github", children: [_jsxs("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("title", { children: "GitHub" }), _jsx("path", { d: "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" })] }), "Sign in with GitHub"] }), _jsxs("a", { href: injectProvider(authorizeUrl, "Google"), class: "btn btn-google", children: [_jsxs("svg", { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("title", { children: "Google" }), _jsx("path", { d: "M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.8 4.133-1.147 1.147-2.933 2.4-6.04 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z" })] }), "Sign in with Google"] })] })] }));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=PickerPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PickerPage.js","sourceRoot":"","sources":["../../../../../src/lib/auth/oauth/pages/PickerPage.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAMrC,SAAS,cAAc,CAAC,YAAoB,EAAE,QAAgB;IAC5D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IAClC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;IACpD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,EAAE,YAAY,EAAmB;IAC1D,OAAO,CACL,MAAC,MAAM,IAAC,SAAS,EAAC,kBAAkB,aAClC,4CAAyB,EACzB,YAAG,KAAK,EAAC,UAAU,mDAAuC,EAC1D,eAAK,KAAK,EAAC,SAAS,aAClB,aAAG,IAAI,EAAE,cAAc,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAC,gBAAgB,aACrE,eAAK,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,4BAA4B,aACzD,qCAAqB,EACrB,eAAM,CAAC,EAAC,0sBAA0sB,GAAG,IACjtB,2BAEJ,EACJ,aAAG,IAAI,EAAE,cAAc,CAAC,YAAY,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAC,gBAAgB,aACrE,eAAK,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,4BAA4B,aACzD,qCAAqB,EACrB,eAAM,CAAC,EAAC,0VAA0V,GAAG,IACjW,2BAEJ,IACA,IACC,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const STYLES = "\n *,\n *::before,\n *::after {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n }\n\n a {\n color: inherit;\n text-decoration: none;\n }\n\n :root {\n --midnight: #051413;\n }\n\n body {\n font-family: \"Inter\", system-ui, sans-serif;\n background-color: var(--midnight);\n min-height: 100vh;\n display: flex;\n padding: 64px;\n }\n\n .card {\n background: #fff;\n border-radius: 2px;\n padding: 48px;\n width: 50%;\n min-height: calc(100vh - 128px);\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n }\n\n h1 {\n font-family: \"Mozilla Text\", system-ui, sans-serif;\n font-weight: 400;\n font-size: 48px;\n color: var(--midnight);\n margin-bottom: 8px;\n }\n\n .subtitle {\n font-size: 20px;\n color: var(--midnight);\n margin-bottom: 32px;\n }\n\n .buttons {\n display: flex;\n flex-direction: column;\n gap: 12px;\n }\n\n .btn {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n height: 48px;\n width: 256px;\n padding: 0 16px;\n border-radius: 2px;\n border: 1px solid var(--midnight);\n font-family: \"Inter\", system-ui, sans-serif;\n font-size: 16px;\n font-weight: 500;\n cursor: pointer;\n transition: background 0.15s;\n }\n\n .btn:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--midnight);\n }\n\n .btn svg {\n width: 20px;\n height: 20px;\n flex-shrink: 0;\n }\n\n .btn-github {\n background: var(--midnight);\n color: #fff;\n }\n .btn-github svg {\n fill: #fff;\n }\n .btn-github:hover {\n background: rgba(5, 20, 19, 0.9);\n }\n\n .btn-google {\n background: #fff;\n color: var(--midnight);\n }\n .btn-google svg {\n fill: var(--midnight);\n }\n .btn-google:hover {\n background: rgba(5, 20, 19, 0.1);\n }\n\n .callback {\n padding-left: 24px;\n border-left: 4px solid var(--midnight);\n border-radius: 2px;\n }\n .callback--success {\n border-left-color: #10b981;\n }\n .callback--error {\n border-left-color: #ef4444;\n }\n .callback h1 {\n font-size: 36px;\n margin-bottom: 8px;\n }\n .callback .subtitle {\n margin-bottom: 0;\n }\n\n @media (max-width: 768px) {\n body {\n padding: 16px;\n }\n .card {\n width: 100%;\n height: auto;\n padding: 24px;\n }\n h1 {\n font-size: 36px;\n }\n .subtitle {\n font-size: 18px;\n }\n }\n";
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
export const STYLES = `
|
|
2
|
+
*,
|
|
3
|
+
*::before,
|
|
4
|
+
*::after {
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
a {
|
|
11
|
+
color: inherit;
|
|
12
|
+
text-decoration: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:root {
|
|
16
|
+
--midnight: #051413;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
body {
|
|
20
|
+
font-family: "Inter", system-ui, sans-serif;
|
|
21
|
+
background-color: var(--midnight);
|
|
22
|
+
min-height: 100vh;
|
|
23
|
+
display: flex;
|
|
24
|
+
padding: 64px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.card {
|
|
28
|
+
background: #fff;
|
|
29
|
+
border-radius: 2px;
|
|
30
|
+
padding: 48px;
|
|
31
|
+
width: 50%;
|
|
32
|
+
min-height: calc(100vh - 128px);
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
h1 {
|
|
40
|
+
font-family: "Mozilla Text", system-ui, sans-serif;
|
|
41
|
+
font-weight: 400;
|
|
42
|
+
font-size: 48px;
|
|
43
|
+
color: var(--midnight);
|
|
44
|
+
margin-bottom: 8px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.subtitle {
|
|
48
|
+
font-size: 20px;
|
|
49
|
+
color: var(--midnight);
|
|
50
|
+
margin-bottom: 32px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.buttons {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
gap: 12px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.btn {
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
gap: 8px;
|
|
64
|
+
height: 48px;
|
|
65
|
+
width: 256px;
|
|
66
|
+
padding: 0 16px;
|
|
67
|
+
border-radius: 2px;
|
|
68
|
+
border: 1px solid var(--midnight);
|
|
69
|
+
font-family: "Inter", system-ui, sans-serif;
|
|
70
|
+
font-size: 16px;
|
|
71
|
+
font-weight: 500;
|
|
72
|
+
cursor: pointer;
|
|
73
|
+
transition: background 0.15s;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.btn:focus-visible {
|
|
77
|
+
outline: none;
|
|
78
|
+
box-shadow: 0 0 0 2px var(--midnight);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.btn svg {
|
|
82
|
+
width: 20px;
|
|
83
|
+
height: 20px;
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.btn-github {
|
|
88
|
+
background: var(--midnight);
|
|
89
|
+
color: #fff;
|
|
90
|
+
}
|
|
91
|
+
.btn-github svg {
|
|
92
|
+
fill: #fff;
|
|
93
|
+
}
|
|
94
|
+
.btn-github:hover {
|
|
95
|
+
background: rgba(5, 20, 19, 0.9);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.btn-google {
|
|
99
|
+
background: #fff;
|
|
100
|
+
color: var(--midnight);
|
|
101
|
+
}
|
|
102
|
+
.btn-google svg {
|
|
103
|
+
fill: var(--midnight);
|
|
104
|
+
}
|
|
105
|
+
.btn-google:hover {
|
|
106
|
+
background: rgba(5, 20, 19, 0.1);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.callback {
|
|
110
|
+
padding-left: 24px;
|
|
111
|
+
border-left: 4px solid var(--midnight);
|
|
112
|
+
border-radius: 2px;
|
|
113
|
+
}
|
|
114
|
+
.callback--success {
|
|
115
|
+
border-left-color: #10b981;
|
|
116
|
+
}
|
|
117
|
+
.callback--error {
|
|
118
|
+
border-left-color: #ef4444;
|
|
119
|
+
}
|
|
120
|
+
.callback h1 {
|
|
121
|
+
font-size: 36px;
|
|
122
|
+
margin-bottom: 8px;
|
|
123
|
+
}
|
|
124
|
+
.callback .subtitle {
|
|
125
|
+
margin-bottom: 0;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@media (max-width: 768px) {
|
|
129
|
+
body {
|
|
130
|
+
padding: 16px;
|
|
131
|
+
}
|
|
132
|
+
.card {
|
|
133
|
+
width: 100%;
|
|
134
|
+
height: auto;
|
|
135
|
+
padding: 24px;
|
|
136
|
+
}
|
|
137
|
+
h1 {
|
|
138
|
+
font-size: 36px;
|
|
139
|
+
}
|
|
140
|
+
.subtitle {
|
|
141
|
+
font-size: 18px;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../../src/lib/auth/oauth/pages/styles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+IrB,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Credentials } from "../../global-store.js";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const getLoginPageUrl: () => string;
|
|
3
|
+
export declare const listenToOAuthCallback: ({ state, nonce, codeVerifier, authorizeUrl, }: {
|
|
3
4
|
state: string;
|
|
4
5
|
nonce: string;
|
|
5
6
|
codeVerifier: string;
|
|
7
|
+
authorizeUrl?: string;
|
|
6
8
|
}) => Promise<Credentials>;
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "preact/jsx-runtime";
|
|
1
2
|
import * as p from "@clack/prompts";
|
|
2
3
|
import { createServer } from "node:http";
|
|
4
|
+
import { renderToString } from "preact-render-to-string";
|
|
3
5
|
import { oAuthClient } from "./client.js";
|
|
4
6
|
import { LOOPBACK_HOST, LOOPBACK_PORT } from "./constants.js";
|
|
5
|
-
|
|
7
|
+
import { CallbackPage } from "./pages/CallbackPage.js";
|
|
8
|
+
import { PickerPage } from "./pages/PickerPage.js";
|
|
9
|
+
const createCallbackServer = ({ state, nonce, codeVerifier, authorizeUrl, onSuccess, onError, }) => createServer(async (req, res) => {
|
|
6
10
|
const url = req.url ?? "/";
|
|
11
|
+
const path = url.split("?")[0];
|
|
12
|
+
if (path === "/" || path === "/login") {
|
|
13
|
+
if (authorizeUrl) {
|
|
14
|
+
res.writeHead(200, { "Content-Type": "text/html", Connection: "close" });
|
|
15
|
+
res.end(renderToString(_jsx(PickerPage, { authorizeUrl: authorizeUrl })));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
p.log.message(`Ignoring request to ${url}`);
|
|
19
|
+
res.writeHead(404).end();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
7
22
|
if (!url.startsWith("/callback")) {
|
|
8
23
|
p.log.message(`Ignoring request to ${url}`);
|
|
9
24
|
res.writeHead(404).end();
|
|
@@ -27,23 +42,25 @@ const createCallbackServer = ({ state, nonce, codeVerifier, onSuccess, onError,
|
|
|
27
42
|
sub,
|
|
28
43
|
};
|
|
29
44
|
p.log.success("✅ Authentication successful");
|
|
30
|
-
res.writeHead(200, { "Content-Type": "text/html" });
|
|
31
|
-
res.end(
|
|
45
|
+
res.writeHead(200, { "Content-Type": "text/html", Connection: "close" });
|
|
46
|
+
res.end(renderToString(_jsx(CallbackPage, { title: "Logged in", body: "You can close this window.", success: true })));
|
|
32
47
|
onSuccess(stored);
|
|
33
48
|
}
|
|
34
49
|
catch (e) {
|
|
35
50
|
p.log.error(e instanceof Error ? e.message : String(e));
|
|
36
|
-
res.writeHead(500, { "Content-Type": "text/html" });
|
|
37
|
-
res.end(
|
|
51
|
+
res.writeHead(500, { "Content-Type": "text/html", Connection: "close" });
|
|
52
|
+
res.end(renderToString(_jsx(CallbackPage, { title: "Login failed", body: "Token exchange error. Try again.", success: false })));
|
|
38
53
|
onError(e instanceof Error ? e : new Error(String(e)));
|
|
39
54
|
}
|
|
40
55
|
});
|
|
41
|
-
export const
|
|
56
|
+
export const getLoginPageUrl = () => `http://${LOOPBACK_HOST}:${LOOPBACK_PORT}/`;
|
|
57
|
+
export const listenToOAuthCallback = ({ state, nonce, codeVerifier, authorizeUrl, }) => {
|
|
42
58
|
return new Promise((resolve, reject) => {
|
|
43
59
|
const callbackServer = createCallbackServer({
|
|
44
60
|
state,
|
|
45
61
|
nonce,
|
|
46
62
|
codeVerifier,
|
|
63
|
+
authorizeUrl,
|
|
47
64
|
onSuccess: (storedToken) => {
|
|
48
65
|
callbackServer.close();
|
|
49
66
|
resolve(storedToken);
|
|
@@ -56,33 +73,4 @@ export const listenToOAuthCallback = ({ state, nonce, codeVerifier, }) => {
|
|
|
56
73
|
callbackServer.listen(LOOPBACK_PORT, LOOPBACK_HOST);
|
|
57
74
|
});
|
|
58
75
|
};
|
|
59
|
-
function html(title, body, success) {
|
|
60
|
-
const bg = success ? "#ecfdf5" : "#fef2f2";
|
|
61
|
-
const border = success ? "#10b981" : "#ef4444";
|
|
62
|
-
const color = success ? "#065f46" : "#991b1b";
|
|
63
|
-
const logoSvg = `<svg width="120" height="24" viewBox="0 0 213 42" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18.139 41.4181H1.58758C0.877981 41.4181 0.302734 40.8443 0.302734 40.1347V16.4957C0.302734 15.3182 1.73285 14.7794 2.48612 15.6845C7.8891 22.1765 15.4029 32.6359 19.2489 39.5848C19.7114 40.4205 19.0941 41.4181 18.139 41.4181Z" fill="#0A0E1C"/><path d="M34.9934 41.4181H23.8233C23.3366 41.4181 22.8936 41.144 22.6686 40.7125C18.5795 32.8689 8.1012 17.5927 0.638233 9.39174C0.420845 9.15285 0.302734 8.84629 0.302734 8.5233V1.58783C0.302734 0.878225 0.876486 0.302979 1.58609 0.302979H6.87182C7.19145 0.302979 7.48677 0.406983 7.71702 0.628672C14.4657 7.1264 32.6261 34.0831 35.8013 40.2463C36.1263 40.8771 35.703 41.4181 34.9934 41.4181Z" fill="#0A0E1C"/><path d="M41.4179 22.479C41.4177 26.1486 41.4178 34.7435 41.4178 40.0835C41.4178 41.3801 39.7105 41.8673 39.0235 40.7677C32.9779 31.091 20.3757 11.3903 13.1298 2.51663C12.4214 1.64905 13.0384 0.302979 14.1585 0.302979H25.3523C25.7594 0.302979 26.1363 0.487723 26.3781 0.815243C28.4729 3.65265 38.6422 17.4716 41.2512 21.8598C41.3654 22.052 41.4179 22.2554 41.4179 22.479Z" fill="#0A0E1C"/><path d="M40.133 0.302979H31.6871C30.6461 0.302979 30.0373 1.47597 30.6363 2.32725L39.0823 14.3294C39.8043 15.3554 41.4179 14.8446 41.4179 13.59V1.58783C41.4179 0.878225 40.8426 0.302979 40.133 0.302979Z" fill="#0A0E1C"/><path d="M69.4252 40.871H61.9757L75.539 0.850139H84.1548L97.737 40.871H90.2875L87.0895 31.0026H72.6044L69.4252 40.871ZM74.4856 25.1792H85.2083L79.9974 9.05754H79.6964L74.4856 25.1792Z" fill="#0A0E1C"/><path d="M102.282 40.871V0.850139H109.261V34.7936H126.229V40.871H102.282Z" fill="#0A0E1C"/><path d="M131.757 40.871V0.850139H146.204C155.065 0.850139 159.786 6.45853 159.786 14.0992C159.786 21.7985 155.008 27.3483 146.11 27.3483H138.736V40.871H131.757ZM138.736 21.3882H145.17C150.362 21.3882 152.676 18.3593 152.676 14.0992C152.676 9.83919 150.362 6.90798 145.132 6.90798H138.736V21.3882Z" fill="#0A0E1C"/><path d="M172.298 0.850139V40.871H165.319V0.850139H172.298Z" fill="#0A0E1C"/><path d="M212.303 14.3533H205.267C204.458 9.56561 200.79 6.81027 196.106 6.81027C189.804 6.81027 185.364 11.8324 185.364 20.8606C185.364 30.045 189.842 34.9108 196.087 34.9108C200.696 34.9108 204.383 32.2727 205.267 27.5828L212.303 27.6219C211.231 35.2626 205.154 41.4181 195.993 41.4181C185.835 41.4181 178.348 33.7774 178.348 20.8606C178.348 7.92413 185.929 0.302979 195.993 0.302979C204.534 0.302979 211.118 5.46191 212.303 14.3533Z" fill="#0A0E1C"/></svg>`;
|
|
64
|
-
return `<!DOCTYPE html>
|
|
65
|
-
<html>
|
|
66
|
-
<head>
|
|
67
|
-
<meta charset="utf-8">
|
|
68
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
69
|
-
<title>${title}</title>
|
|
70
|
-
<style>
|
|
71
|
-
* { box-sizing: border-box; }
|
|
72
|
-
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2rem; font-family: system-ui, -apple-system, sans-serif; background: #f8fafc; }
|
|
73
|
-
.logo { flex-shrink: 0; }
|
|
74
|
-
.alert { max-width: 360px; padding: 1.25rem 1.5rem; border-radius: 8px; border-left: 4px solid ${border}; background: ${bg}; color: ${color}; }
|
|
75
|
-
.alert h1 { margin: 0 0 0.5rem; font-size: 1.125rem; font-weight: 600; }
|
|
76
|
-
.alert p { margin: 0; font-size: 0.9375rem; line-height: 1.5; opacity: 0.95; }
|
|
77
|
-
</style>
|
|
78
|
-
</head>
|
|
79
|
-
<body>
|
|
80
|
-
<div class="logo" aria-hidden="true">${logoSvg}</div>
|
|
81
|
-
<div class="alert">
|
|
82
|
-
<h1>${title}</h1>
|
|
83
|
-
<p>${body}</p>
|
|
84
|
-
</div>
|
|
85
|
-
</body>
|
|
86
|
-
</html>`;
|
|
87
|
-
}
|
|
88
76
|
//# sourceMappingURL=server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/lib/auth/oauth/server.
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/lib/auth/oauth/server.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAA6C,YAAY,EAAE,MAAM,WAAW,CAAC;AACpF,OAAO,E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
|
"name": "alpic",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.bcdbc80",
|
|
4
4
|
"description": "The command-line interface for Alpic",
|
|
5
5
|
"homepage": "https://alpic.ai",
|
|
6
6
|
"preferGlobal": true,
|
|
@@ -25,34 +25,36 @@
|
|
|
25
25
|
"author": "Alpic",
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@clack/prompts": "^1.0.
|
|
28
|
+
"@clack/prompts": "^1.0.1",
|
|
29
29
|
"@oclif/core": "^4.8.0",
|
|
30
|
-
"@orpc/client": "^1.13.
|
|
31
|
-
"@orpc/contract": "^1.13.
|
|
32
|
-
"@orpc/openapi-client": "^1.13.
|
|
30
|
+
"@orpc/client": "^1.13.5",
|
|
31
|
+
"@orpc/contract": "^1.13.5",
|
|
32
|
+
"@orpc/openapi-client": "^1.13.5",
|
|
33
33
|
"@t3-oss/env-core": "^0.13.10",
|
|
34
34
|
"chalk": "^5.6.2",
|
|
35
35
|
"ci-info": "^4.4.0",
|
|
36
36
|
"jwt-decode": "^4.0.0",
|
|
37
37
|
"open": "^11.0.0",
|
|
38
38
|
"openid-client": "^6.8.2",
|
|
39
|
-
"posthog-node": "^5.24.
|
|
40
|
-
"
|
|
39
|
+
"posthog-node": "^5.24.17",
|
|
40
|
+
"preact": "^10.28.0",
|
|
41
|
+
"preact-render-to-string": "^6.6.2",
|
|
42
|
+
"tar": "^7.5.9",
|
|
41
43
|
"xdg-app-paths": "^8.3.0",
|
|
42
44
|
"zod": "^4.3.6",
|
|
43
|
-
"@alpic-ai/api": "0.0.0-dev.
|
|
45
|
+
"@alpic-ai/api": "0.0.0-dev.bcdbc80"
|
|
44
46
|
},
|
|
45
47
|
"devDependencies": {
|
|
46
|
-
"@orpc/openapi": "^1.13.
|
|
47
|
-
"@orpc/server": "^1.13.
|
|
48
|
-
"@orpc/zod": "^1.13.
|
|
48
|
+
"@orpc/openapi": "^1.13.5",
|
|
49
|
+
"@orpc/server": "^1.13.5",
|
|
50
|
+
"@orpc/zod": "^1.13.5",
|
|
49
51
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
50
52
|
"@types/express": "^5.0.6",
|
|
51
|
-
"@types/node": "^25.
|
|
53
|
+
"@types/node": "^25.3.0",
|
|
52
54
|
"biome": "^0.3.3",
|
|
53
55
|
"express": "^5.2.1",
|
|
54
|
-
"jsdom": "^28.
|
|
55
|
-
"node-pty": "1.
|
|
56
|
+
"jsdom": "^28.1.0",
|
|
57
|
+
"node-pty": "1.1.0",
|
|
56
58
|
"selfsigned": "^5.5.0",
|
|
57
59
|
"shx": "^0.4.0",
|
|
58
60
|
"ts-node": "^10.9.2",
|