@glasshome/widget-cli 0.4.10 → 0.4.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/widget-cli",
3
- "version": "0.4.10",
3
+ "version": "0.4.11",
4
4
  "description": "CLI for creating and managing GlassHome widgets",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,10 +4,12 @@ import { log, spinner } from "@clack/prompts";
4
4
  import open from "open";
5
5
  import { getHubUrl, storeToken } from "../utils/auth";
6
6
 
7
+ // Public client: PKCE authenticates it, no client secret. The redirect is an
8
+ // IP-loopback URI (RFC 8252) registered on the hub.
7
9
  const CLIENT_ID = "glasshome-widget-cli";
8
- const CLIENT_SECRET = "glasshome-cli-public";
10
+ const REDIRECT_HOST = "127.0.0.1";
9
11
  const REDIRECT_PORT = 9274;
10
- const REDIRECT_URI = `http://localhost:${REDIRECT_PORT}/callback`;
12
+ const REDIRECT_URI = `http://${REDIRECT_HOST}:${REDIRECT_PORT}/callback`;
11
13
  const LOGIN_TIMEOUT_MS = 120_000;
12
14
 
13
15
  function base64url(buf: Buffer): string {
@@ -35,7 +37,7 @@ export async function runLogin(hubUrl?: string): Promise<void> {
35
37
  }, LOGIN_TIMEOUT_MS);
36
38
 
37
39
  const server = createServer((req: IncomingMessage, res: ServerResponse) => {
38
- const url = new URL(req.url!, `http://localhost:${REDIRECT_PORT}`);
40
+ const url = new URL(req.url!, `http://${REDIRECT_HOST}:${REDIRECT_PORT}`);
39
41
 
40
42
  if (url.pathname !== "/callback") {
41
43
  res.writeHead(404);
@@ -70,7 +72,7 @@ export async function runLogin(hubUrl?: string): Promise<void> {
70
72
  resolve({ code, receivedState });
71
73
  });
72
74
 
73
- server.listen(REDIRECT_PORT, () => {
75
+ server.listen(REDIRECT_PORT, REDIRECT_HOST, () => {
74
76
  const authUrl = new URL(`${hub}/api/auth/oauth2/authorize`);
75
77
  authUrl.searchParams.set("client_id", CLIENT_ID);
76
78
  authUrl.searchParams.set("redirect_uri", REDIRECT_URI);
@@ -109,7 +111,6 @@ export async function runLogin(hubUrl?: string): Promise<void> {
109
111
  redirect_uri: REDIRECT_URI,
110
112
  code_verifier: codeVerifier,
111
113
  client_id: CLIENT_ID,
112
- client_secret: CLIENT_SECRET,
113
114
  }),
114
115
  });
115
116
 
package/src/utils/auth.ts CHANGED
@@ -114,7 +114,6 @@ export async function getToken(hubUrl: string): Promise<string | null> {
114
114
  grant_type: "refresh_token",
115
115
  refresh_token: stored.refreshToken,
116
116
  client_id: "glasshome-widget-cli",
117
- client_secret: "glasshome-cli-public",
118
117
  }),
119
118
  });
120
119