@ze-norm/cli 0.7.0 → 0.8.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-flow.d.ts","sourceRoot":"","sources":["../../src/auth/device-flow.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"device-flow.d.ts","sourceRoot":"","sources":["../../src/auth/device-flow.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAkUpD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAkDpE"}
|
package/dist/auth/device-flow.js
CHANGED
|
@@ -4,7 +4,7 @@ import { exec } from "node:child_process";
|
|
|
4
4
|
import { platform } from "node:os";
|
|
5
5
|
import { URL, URLSearchParams } from "node:url";
|
|
6
6
|
import { log } from "../util/logger.js";
|
|
7
|
-
import { CLI_CALLBACK_PORTS, PRODUCTION_CLERK_CLIENT_ID, PRODUCTION_CLERK_ISSUER,
|
|
7
|
+
import { CLI_CALLBACK_PORTS, PRODUCTION_CLERK_CLIENT_ID, PRODUCTION_CLERK_ISSUER, } from "../config/defaults.js";
|
|
8
8
|
/**
|
|
9
9
|
* Find the first pre-registered callback port that is free to bind. Clerk
|
|
10
10
|
* matches redirect_uris exactly, so the local listener must use one of the
|
|
@@ -28,10 +28,6 @@ async function pickFreeCallbackPort() {
|
|
|
28
28
|
function getClerkIssuer() {
|
|
29
29
|
return process.env["ZENORM_CLERK_ISSUER"] ?? PRODUCTION_CLERK_ISSUER;
|
|
30
30
|
}
|
|
31
|
-
/** Where the browser tab lands after a successful login. */
|
|
32
|
-
function getWebUrl() {
|
|
33
|
-
return process.env["ZENORM_WEB_URL"] ?? PRODUCTION_WEB_URL;
|
|
34
|
-
}
|
|
35
31
|
/** Escape user-influenced text before interpolating into the result page HTML. */
|
|
36
32
|
function escapeHtml(value) {
|
|
37
33
|
return value
|
|
@@ -169,6 +165,45 @@ function renderCallbackPage(heading, body) {
|
|
|
169
165
|
</body>
|
|
170
166
|
</html>`;
|
|
171
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Page served on a successful callback. The tab is no longer needed, so it
|
|
170
|
+
* immediately attempts to close itself. window.close() is honored only for
|
|
171
|
+
* script-opened windows — the CLI opens this tab via the OS, so most browsers
|
|
172
|
+
* refuse. The minimal text below is the fallback for that case: no card chrome,
|
|
173
|
+
* just a one-liner, so a refused close never leaves a spammy-looking page.
|
|
174
|
+
*/
|
|
175
|
+
function renderClosePage() {
|
|
176
|
+
return `<!doctype html>
|
|
177
|
+
<html lang="en">
|
|
178
|
+
<head>
|
|
179
|
+
<meta charset="utf-8" />
|
|
180
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
181
|
+
<title>ZeNorm CLI</title>
|
|
182
|
+
<style>
|
|
183
|
+
:root { color-scheme: dark; }
|
|
184
|
+
body {
|
|
185
|
+
margin: 0;
|
|
186
|
+
min-height: 100vh;
|
|
187
|
+
display: grid;
|
|
188
|
+
place-items: center;
|
|
189
|
+
background: #0a0a0b;
|
|
190
|
+
color: rgba(237,237,238,0.62);
|
|
191
|
+
font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
|
|
192
|
+
Roboto, Helvetica, Arial, sans-serif;
|
|
193
|
+
font-size: 0.9rem;
|
|
194
|
+
}
|
|
195
|
+
</style>
|
|
196
|
+
</head>
|
|
197
|
+
<body>
|
|
198
|
+
<p>Logged in. You can close this tab.</p>
|
|
199
|
+
<script>
|
|
200
|
+
// Best-effort: close the tab now that login is done. Ignored by browsers
|
|
201
|
+
// when the tab was not opened by script (the common case here).
|
|
202
|
+
window.close();
|
|
203
|
+
</script>
|
|
204
|
+
</body>
|
|
205
|
+
</html>`;
|
|
206
|
+
}
|
|
172
207
|
/**
|
|
173
208
|
* Start a localhost HTTP server and wait for the OAuth callback.
|
|
174
209
|
* Resolves with the authorization code once the redirect arrives.
|
|
@@ -200,13 +235,14 @@ function waitForCallback(port, expectedState) {
|
|
|
200
235
|
reject(new Error("Invalid callback: missing code or state mismatch"));
|
|
201
236
|
return;
|
|
202
237
|
}
|
|
203
|
-
//
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
//
|
|
207
|
-
//
|
|
208
|
-
|
|
209
|
-
res.
|
|
238
|
+
// The browser tab has done its job — try to close it. window.close()
|
|
239
|
+
// only works on script-opened windows, and the CLI opens this tab via the
|
|
240
|
+
// OS (open/xdg-open), so most browsers will refuse. We attempt it anyway
|
|
241
|
+
// and fall back to a tiny "you can close this tab" line, with no card
|
|
242
|
+
// chrome, so a refused close doesn't leave a spammy page behind. The CLI
|
|
243
|
+
// reports the real success in the terminal.
|
|
244
|
+
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
245
|
+
res.end(renderClosePage());
|
|
210
246
|
server.close();
|
|
211
247
|
resolve(code);
|
|
212
248
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export declare const PRODUCTION_API_URL = "https://api.zenorm.com";
|
|
2
2
|
export declare const PRODUCTION_CLERK_ISSUER = "https://clerk.zenorm.com";
|
|
3
|
-
export declare const PRODUCTION_WEB_URL = "https://zenorm.com";
|
|
4
3
|
export declare const PRODUCTION_CLERK_CLIENT_ID = "nUFCpxIFWJ4YSB3A";
|
|
5
4
|
export declare const CLI_CALLBACK_PORTS: readonly [4571, 4572, 4573];
|
|
6
5
|
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAC3D,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,2BAA2B,CAAC;AAC3D,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAWlE,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAK7D,eAAO,MAAM,kBAAkB,6BAA8B,CAAC"}
|
package/dist/config/defaults.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
export const PRODUCTION_API_URL = "https://api.zenorm.com";
|
|
2
2
|
export const PRODUCTION_CLERK_ISSUER = "https://clerk.zenorm.com";
|
|
3
|
-
// Prod web app. After a successful login the localhost callback 302-redirects
|
|
4
|
-
// the browser here so the tab lands on the real product (already signed in)
|
|
5
|
-
// instead of a standalone "you can close this tab" page.
|
|
6
|
-
export const PRODUCTION_WEB_URL = "https://zenorm.com";
|
|
7
3
|
// Clerk OAuth Application client id for the public CLI (prod instance
|
|
8
4
|
// clerk.zenorm.com). NOT the publishable key — this is the OAuth 2.0 client id
|
|
9
5
|
// from the "ZeNorm CLI" OAuth app. Its registered redirect_uris are the fixed
|