repowise 0.1.2 → 0.1.4
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/bin/repowise.js +42 -11
- package/package.json +1 -1
package/dist/bin/repowise.js
CHANGED
|
@@ -23,11 +23,11 @@ var init_env = __esm({
|
|
|
23
23
|
staging = false;
|
|
24
24
|
PRODUCTION = {
|
|
25
25
|
apiUrl: "https://api.repowise.ai",
|
|
26
|
-
cognitoDomain: "auth
|
|
26
|
+
cognitoDomain: "auth.repowise.ai",
|
|
27
27
|
cognitoClientId: "",
|
|
28
|
-
// TODO: set production
|
|
28
|
+
// TODO: set after production Cognito deploy
|
|
29
29
|
cognitoRegion: "us-east-1",
|
|
30
|
-
customDomain:
|
|
30
|
+
customDomain: true
|
|
31
31
|
};
|
|
32
32
|
STAGING = {
|
|
33
33
|
apiUrl: "https://staging-api.repowise.ai",
|
|
@@ -68,7 +68,7 @@ function generateState() {
|
|
|
68
68
|
return randomBytes(32).toString("hex");
|
|
69
69
|
}
|
|
70
70
|
function getAuthorizeUrl(codeChallenge, state) {
|
|
71
|
-
const {
|
|
71
|
+
const { clientId } = getCognitoConfig();
|
|
72
72
|
if (!clientId) {
|
|
73
73
|
throw new Error(
|
|
74
74
|
"Missing REPOWISE_COGNITO_CLIENT_ID environment variable. Configure it before running login."
|
|
@@ -102,24 +102,20 @@ function startCallbackServer() {
|
|
|
102
102
|
const error = url.searchParams.get("error");
|
|
103
103
|
if (error) {
|
|
104
104
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
105
|
-
res.end(
|
|
106
|
-
"<html><body><h1>Authentication failed.</h1><p>You can close this tab.</p></body></html>"
|
|
107
|
-
);
|
|
105
|
+
res.end(callbackPage("Authentication Failed", "Something went wrong. Please close this tab and try again.", true));
|
|
108
106
|
server.close();
|
|
109
107
|
reject(new Error(`Authentication error: ${error}`));
|
|
110
108
|
return;
|
|
111
109
|
}
|
|
112
110
|
if (!code || !state) {
|
|
113
111
|
res.writeHead(400, { "Content-Type": "text/html" });
|
|
114
|
-
res.end("
|
|
112
|
+
res.end(callbackPage("Missing Parameters", "The callback was missing required data. Please close this tab and try again.", true));
|
|
115
113
|
server.close();
|
|
116
114
|
reject(new Error("Missing code or state in callback"));
|
|
117
115
|
return;
|
|
118
116
|
}
|
|
119
117
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
120
|
-
res.end(
|
|
121
|
-
"<html><body><h1>Authentication successful!</h1><p>You can close this tab and return to the terminal.</p></body></html>"
|
|
122
|
-
);
|
|
118
|
+
res.end(callbackPage("Authentication Successful", "You can close this tab and return to the terminal.", false));
|
|
123
119
|
server.close();
|
|
124
120
|
resolve({ code, state });
|
|
125
121
|
});
|
|
@@ -249,6 +245,41 @@ Open this URL in your browser to authenticate:
|
|
|
249
245
|
await storeCredentials(credentials);
|
|
250
246
|
return credentials;
|
|
251
247
|
}
|
|
248
|
+
function callbackPage(title, message, isError) {
|
|
249
|
+
const icon = isError ? '<svg width="48" height="48" fill="none" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" stroke="#ef4444" stroke-width="2"/><path stroke="#ef4444" stroke-width="2" stroke-linecap="round" d="M15 9l-6 6M9 9l6 6"/></svg>' : '<svg width="48" height="48" fill="none" viewBox="0 0 24 24"><circle cx="12" cy="12" r="10" stroke="#10b981" stroke-width="2"/><path stroke="#10b981" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M8 12l3 3 5-5"/></svg>';
|
|
250
|
+
return `<!DOCTYPE html>
|
|
251
|
+
<html lang="en">
|
|
252
|
+
<head>
|
|
253
|
+
<meta charset="UTF-8">
|
|
254
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
255
|
+
<title>${title} \u2014 RepoWise</title>
|
|
256
|
+
<link rel="icon" href="https://staging.repowise.ai/favicon.svg" type="image/svg+xml">
|
|
257
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
258
|
+
<style>
|
|
259
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
260
|
+
body { font-family: 'Inter', system-ui, sans-serif; background: #0a0b14; color: #e4e4e7; min-height: 100vh; display: flex; align-items: center; justify-content: center; }
|
|
261
|
+
.card { text-align: center; max-width: 440px; padding: 48px 40px; }
|
|
262
|
+
.logo { margin-bottom: 32px; }
|
|
263
|
+
.logo svg { height: 48px; width: auto; }
|
|
264
|
+
.icon { margin-bottom: 20px; }
|
|
265
|
+
h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; color: ${isError ? "#ef4444" : "#e4e4e7"}; }
|
|
266
|
+
p { font-size: 15px; color: #a1a1aa; line-height: 1.5; }
|
|
267
|
+
</style>
|
|
268
|
+
</head>
|
|
269
|
+
<body>
|
|
270
|
+
<div class="card">
|
|
271
|
+
<div class="logo">
|
|
272
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 50" height="48">
|
|
273
|
+
<text x="0" y="38" font-family="Inter, system-ui, sans-serif" font-weight="700" font-size="36" fill="#e4e4e7">Repo<tspan fill="#6c5ce7">Wise</tspan></text>
|
|
274
|
+
</svg>
|
|
275
|
+
</div>
|
|
276
|
+
<div class="icon">${icon}</div>
|
|
277
|
+
<h1>${title}</h1>
|
|
278
|
+
<p>${message}</p>
|
|
279
|
+
</div>
|
|
280
|
+
</body>
|
|
281
|
+
</html>`;
|
|
282
|
+
}
|
|
252
283
|
function decodeIdToken(idToken) {
|
|
253
284
|
try {
|
|
254
285
|
const parts = idToken.split(".");
|