rechrome 1.8.0 → 1.8.1

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/rech.js +3 -1
  3. package/rech.ts +3 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rechrome",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/snomiao/rechrome.git"
package/rech.js CHANGED
@@ -118,7 +118,8 @@ export function parseUrl(raw: string) {
118
118
  }
119
119
 
120
120
  export async function getOrCreateUrl(): Promise<string> {
121
- if (process.env[ENV_KEY]) return process.env[ENV_KEY];
121
+ // Treat a URL without a bearer key as missing — it cannot authenticate
122
+ try { if (process.env[ENV_KEY] && new URL(process.env[ENV_KEY]!).username) return process.env[ENV_KEY]!; } catch {}
122
123
  const key = randomBytes(9).toString("base64url"); // 12 chars
123
124
  const url = `http://${key}@127.0.0.1:${DEFAULT_PORT}`;
124
125
  const newLine = `${ENV_KEY}=${url}`;
@@ -645,6 +646,7 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
645
646
  if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
646
647
  const existing = await file(globalEnvPath).text().catch(() => "");
647
648
  const rechUrl = new URL(url);
649
+ if (!rechUrl.username) rechUrl.username = randomBytes(9).toString("base64url");
648
650
  rechUrl.searchParams.set("extension_id", extId);
649
651
  rechUrl.searchParams.set("token", token);
650
652
  rechUrl.searchParams.set("profile", profileEmail);
package/rech.ts CHANGED
@@ -118,7 +118,8 @@ export function parseUrl(raw: string) {
118
118
  }
119
119
 
120
120
  export async function getOrCreateUrl(): Promise<string> {
121
- if (process.env[ENV_KEY]) return process.env[ENV_KEY];
121
+ // Treat a URL without a bearer key as missing — it cannot authenticate
122
+ try { if (process.env[ENV_KEY] && new URL(process.env[ENV_KEY]!).username) return process.env[ENV_KEY]!; } catch {}
122
123
  const key = randomBytes(9).toString("base64url"); // 12 chars
123
124
  const url = `http://${key}@127.0.0.1:${DEFAULT_PORT}`;
124
125
  const newLine = `${ENV_KEY}=${url}`;
@@ -645,6 +646,7 @@ async function setup(opts: { profile?: string } = {}): Promise<void> {
645
646
  if (saveChoice === "2") mkdirSync(join(process.cwd(), ".rechrome"), { recursive: true });
646
647
  const existing = await file(globalEnvPath).text().catch(() => "");
647
648
  const rechUrl = new URL(url);
649
+ if (!rechUrl.username) rechUrl.username = randomBytes(9).toString("base64url");
648
650
  rechUrl.searchParams.set("extension_id", extId);
649
651
  rechUrl.searchParams.set("token", token);
650
652
  rechUrl.searchParams.set("profile", profileEmail);