blun-king-cli 9.1.16 → 9.1.17
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
|
@@ -59318,13 +59318,32 @@ function defaultAccess() {
|
|
|
59318
59318
|
pending: {}
|
|
59319
59319
|
};
|
|
59320
59320
|
}
|
|
59321
|
+
function normalizeIdList(value) {
|
|
59322
|
+
if (!Array.isArray(value)) return [];
|
|
59323
|
+
return [...new Set(value.filter((entry) => typeof entry === "string" || typeof entry === "number").map((entry) => String(entry).trim()).filter((entry) => entry.length > 0))];
|
|
59324
|
+
}
|
|
59325
|
+
function normalizeGroups(value) {
|
|
59326
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
59327
|
+
const groups = {};
|
|
59328
|
+
for (const [chatId, rawPolicy] of Object.entries(value)) {
|
|
59329
|
+
if (rawPolicy === null || typeof rawPolicy !== "object" || Array.isArray(rawPolicy)) continue;
|
|
59330
|
+
const policy = rawPolicy;
|
|
59331
|
+
const alwaysAllowFrom = normalizeIdList(policy.alwaysAllowFrom);
|
|
59332
|
+
groups[chatId] = {
|
|
59333
|
+
requireMention: policy.requireMention !== false,
|
|
59334
|
+
allowFrom: normalizeIdList(policy.allowFrom),
|
|
59335
|
+
...alwaysAllowFrom.length > 0 ? { alwaysAllowFrom } : {}
|
|
59336
|
+
};
|
|
59337
|
+
}
|
|
59338
|
+
return groups;
|
|
59339
|
+
}
|
|
59321
59340
|
function readAccess() {
|
|
59322
59341
|
try {
|
|
59323
59342
|
const parsed = JSON.parse(readFileSync(accessFile(), "utf8"));
|
|
59324
59343
|
return {
|
|
59325
59344
|
dmPolicy: parsed.dmPolicy ?? "pairing",
|
|
59326
|
-
allowFrom: parsed.allowFrom
|
|
59327
|
-
groups: parsed.groups
|
|
59345
|
+
allowFrom: normalizeIdList(parsed.allowFrom),
|
|
59346
|
+
groups: normalizeGroups(parsed.groups),
|
|
59328
59347
|
pending: parsed.pending ?? {},
|
|
59329
59348
|
mentionPatterns: parsed.mentionPatterns,
|
|
59330
59349
|
ignorePatterns: parsed.ignorePatterns,
|
|
@@ -59333,8 +59352,8 @@ function readAccess() {
|
|
|
59333
59352
|
textChunkLimit: parsed.textChunkLimit,
|
|
59334
59353
|
chunkMode: parsed.chunkMode
|
|
59335
59354
|
};
|
|
59336
|
-
} catch (
|
|
59337
|
-
if (
|
|
59355
|
+
} catch (error) {
|
|
59356
|
+
if (error.code === "ENOENT") return defaultAccess();
|
|
59338
59357
|
try {
|
|
59339
59358
|
renameSync(accessFile(), `${accessFile()}.corrupt-${Date.now()}`);
|
|
59340
59359
|
} catch {}
|
|
@@ -73135,13 +73135,32 @@ function defaultAccess() {
|
|
|
73135
73135
|
pending: {}
|
|
73136
73136
|
};
|
|
73137
73137
|
}
|
|
73138
|
+
function normalizeIdList(value) {
|
|
73139
|
+
if (!Array.isArray(value)) return [];
|
|
73140
|
+
return [...new Set(value.filter((entry) => typeof entry === "string" || typeof entry === "number").map((entry) => String(entry).trim()).filter((entry) => entry.length > 0))];
|
|
73141
|
+
}
|
|
73142
|
+
function normalizeGroups(value) {
|
|
73143
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
73144
|
+
const groups = {};
|
|
73145
|
+
for (const [chatId, rawPolicy] of Object.entries(value)) {
|
|
73146
|
+
if (rawPolicy === null || typeof rawPolicy !== "object" || Array.isArray(rawPolicy)) continue;
|
|
73147
|
+
const policy = rawPolicy;
|
|
73148
|
+
const alwaysAllowFrom = normalizeIdList(policy.alwaysAllowFrom);
|
|
73149
|
+
groups[chatId] = {
|
|
73150
|
+
requireMention: policy.requireMention !== false,
|
|
73151
|
+
allowFrom: normalizeIdList(policy.allowFrom),
|
|
73152
|
+
...alwaysAllowFrom.length > 0 ? { alwaysAllowFrom } : {}
|
|
73153
|
+
};
|
|
73154
|
+
}
|
|
73155
|
+
return groups;
|
|
73156
|
+
}
|
|
73138
73157
|
function readAccess() {
|
|
73139
73158
|
try {
|
|
73140
73159
|
const parsed = JSON.parse(readFileSync(accessFile(), "utf8"));
|
|
73141
73160
|
return {
|
|
73142
73161
|
dmPolicy: parsed.dmPolicy ?? "pairing",
|
|
73143
|
-
allowFrom: parsed.allowFrom
|
|
73144
|
-
groups: parsed.groups
|
|
73162
|
+
allowFrom: normalizeIdList(parsed.allowFrom),
|
|
73163
|
+
groups: normalizeGroups(parsed.groups),
|
|
73145
73164
|
pending: parsed.pending ?? {},
|
|
73146
73165
|
mentionPatterns: parsed.mentionPatterns,
|
|
73147
73166
|
ignorePatterns: parsed.ignorePatterns,
|
|
@@ -73150,8 +73169,8 @@ function readAccess() {
|
|
|
73150
73169
|
textChunkLimit: parsed.textChunkLimit,
|
|
73151
73170
|
chunkMode: parsed.chunkMode
|
|
73152
73171
|
};
|
|
73153
|
-
} catch (
|
|
73154
|
-
if (
|
|
73172
|
+
} catch (error) {
|
|
73173
|
+
if (error.code === "ENOENT") return defaultAccess();
|
|
73155
73174
|
try {
|
|
73156
73175
|
renameSync(accessFile(), `${accessFile()}.corrupt-${Date.now()}`);
|
|
73157
73176
|
} catch {}
|