cctether 0.3.0 → 0.3.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.
- package/package.json +1 -1
- package/src/config.js +11 -5
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -7,8 +7,11 @@ import { join } from 'node:path';
|
|
|
7
7
|
|
|
8
8
|
export const DEFAULT_PORT = 27182;
|
|
9
9
|
export const WS_PATH = '/cctether';
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* cctether's own extension IDs, always accepted: the build people load themselves (fixed by the
|
|
12
|
+
* manifest key) and the Chrome Web Store build. "extensionIds" in config.json adds more.
|
|
13
|
+
*/
|
|
14
|
+
export const DEFAULT_EXTENSION_IDS = ['nfebjhhcnoilmfjacolkofphfekkjioh', 'mbkadoolgknacadjkfjjajldmllbkdib'];
|
|
12
15
|
|
|
13
16
|
export function configDir(env = process.env) {
|
|
14
17
|
if (env.CCTETHER_HOME) return env.CCTETHER_HOME;
|
|
@@ -62,7 +65,7 @@ function validate(raw) {
|
|
|
62
65
|
key: Buffer.from(String(raw.key ?? ''), 'base64url'),
|
|
63
66
|
port: raw.port ?? DEFAULT_PORT,
|
|
64
67
|
publicUrl: raw.publicUrl ?? null,
|
|
65
|
-
extensionIds: raw.extensionIds ??
|
|
68
|
+
extensionIds: raw.extensionIds ?? [],
|
|
66
69
|
trustProxySetting: raw.trustProxy ?? null,
|
|
67
70
|
};
|
|
68
71
|
if (cfg.trustProxySetting !== null && typeof cfg.trustProxySetting !== 'boolean') {
|
|
@@ -76,6 +79,8 @@ function validate(raw) {
|
|
|
76
79
|
if (!Array.isArray(cfg.extensionIds) || !cfg.extensionIds.every((id) => /^[a-p]{32}$/.test(id))) {
|
|
77
80
|
throw new ConfigError('config.json: "extensionIds" must be a list of 32-letter extension IDs.');
|
|
78
81
|
}
|
|
82
|
+
// Older config files list the built-in IDs explicitly; either way the built-in ones are included.
|
|
83
|
+
cfg.extensionIds = [...new Set([...DEFAULT_EXTENSION_IDS, ...cfg.extensionIds])];
|
|
79
84
|
return cfg;
|
|
80
85
|
}
|
|
81
86
|
|
|
@@ -131,7 +136,8 @@ export function saveConfig(dir, cfg) {
|
|
|
131
136
|
key: cfg.key.toString('base64url'),
|
|
132
137
|
port: cfg.port,
|
|
133
138
|
publicUrl: cfg.publicUrl,
|
|
134
|
-
|
|
139
|
+
// Only extra IDs are stored: the built-in ones can change with an update.
|
|
140
|
+
extensionIds: cfg.extensionIds.filter((id) => !DEFAULT_EXTENSION_IDS.includes(id)),
|
|
135
141
|
trustProxy: cfg.trustProxySetting ?? null,
|
|
136
142
|
};
|
|
137
143
|
writeFileSync(tmp, JSON.stringify(data, null, 2) + '\n', { mode: 0o600 });
|
|
@@ -151,7 +157,7 @@ export function initConfig(dir, { port, publicUrl } = {}) {
|
|
|
151
157
|
key: newKey().toString('base64url'),
|
|
152
158
|
port: port ?? DEFAULT_PORT,
|
|
153
159
|
publicUrl: publicUrl ?? null,
|
|
154
|
-
extensionIds:
|
|
160
|
+
extensionIds: [],
|
|
155
161
|
});
|
|
156
162
|
saveConfig(dir, cfg);
|
|
157
163
|
return { cfg, created: true };
|