@wirecat/cli-core 0.660.0 → 0.662.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.
- package/CHANGELOG.md +89 -0
- package/dist/attachments/markup.js +2 -11
- package/dist/calendar/mcp/index.js +23 -17
- package/dist/cli/ai-model-command.js +3 -3
- package/dist/cli/bot/api-http.d.ts +43 -0
- package/dist/cli/bot/api-http.js +160 -0
- package/dist/cli/command-availability.d.ts +1 -1
- package/dist/cli/command-availability.js +4 -4
- package/dist/cli/dry-run-guard.js +7 -5
- package/dist/cli/early-refusal.d.ts +1 -1
- package/dist/cli/early-refusal.js +2 -2
- package/dist/cli/effects.d.ts +9 -2
- package/dist/cli/effects.js +16 -4
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/messenger/admin-moderation-command.js +2 -2
- package/dist/cli/messenger/archive-commands.js +2 -2
- package/dist/cli/messenger/context.d.ts +2 -2
- package/dist/cli/messenger/context.js +5 -3
- package/dist/cli/messenger/rankings-command.js +2 -1
- package/dist/cli/messenger/serve-command.js +7 -2
- package/dist/cli/messenger/tasks-command.d.ts +7 -2
- package/dist/cli/messenger/tasks-command.js +8 -4
- package/dist/cli/preview.js +3 -5
- package/dist/cli/program.js +2 -2
- package/dist/cli/schedule/schedule-command.js +3 -0
- package/dist/cli/shadowed-options.d.ts +7 -0
- package/dist/cli/shadowed-options.js +26 -0
- package/dist/crm/cli/index.js +4 -2
- package/dist/domain/html-entities.d.ts +5 -0
- package/dist/domain/html-entities.js +56 -0
- package/dist/domain/locator.js +12 -4
- package/dist/domain/references.js +11 -3
- package/dist/entities/listings.d.ts +4 -4
- package/dist/entities/listings.js +2 -2
- package/dist/kit/sync-after-install.d.ts +10 -1
- package/dist/kit/sync-after-install.js +35 -11
- package/dist/mail/headers.js +3 -3
- package/dist/mail/parse.js +9 -8
- package/dist/mail/resume.d.ts +4 -1
- package/dist/mail/resume.js +11 -2
- package/dist/mail/retry.d.ts +2 -1
- package/dist/mail/retry.js +6 -4
- package/dist/mail/sender-scores.js +1 -6
- package/dist/mail/server-search.js +3 -3
- package/dist/mail/stored.d.ts +4 -1
- package/dist/mail/stored.js +6 -1
- package/dist/mail/sync.js +8 -3
- package/dist/mail/testing/fake.d.ts +2 -0
- package/dist/mail/testing/fake.js +3 -1
- package/dist/mcp/all-profiles.js +8 -18
- package/dist/mcp/app-server.js +1 -16
- package/dist/mcp/bot/server.js +9 -7
- package/dist/mcp/caller.js +2 -1
- package/dist/mcp/prompts.js +17 -2
- package/dist/mcp/server.js +14 -20
- package/dist/mcp/stdio-wire.d.ts +5 -2
- package/dist/mcp/stdio-wire.js +39 -12
- package/dist/mcp/tool.js +6 -4
- package/dist/mcp/tools/messages-photo.js +4 -2
- package/dist/meetings/cli/search.js +8 -2
- package/dist/meetings/hit-query.js +11 -6
- package/dist/meetings/mcp/index.d.ts +15 -15
- package/dist/sends/guard.js +11 -21
- package/dist/sends/keyed-guard.d.ts +1 -1
- package/dist/sends/keyed-guard.js +2 -1
- package/dist/sends/permissions.d.ts +14 -0
- package/dist/sends/permissions.js +32 -0
- package/dist/services/listings.js +2 -1
- package/dist/services/message-resolution.js +6 -3
- package/dist/services/server-search.js +1 -1
- package/dist/store/sqlite/mention-drain.d.ts +4 -1
- package/dist/store/sqlite/mention-drain.js +7 -3
- package/dist/store/sqlite/messages.js +12 -1
- package/dist/store/sqlite/query-filter.d.ts +1 -0
- package/dist/store/sqlite/query-filter.js +2 -2
- package/dist/store/sqlite/tags.js +1 -1
- package/package.json +1 -1
- package/parity.json +2 -1
package/dist/cli/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export { askBeforeWrite } from "./ask-before-write.js";
|
|
|
57
57
|
export { actorOf } from "./author.js";
|
|
58
58
|
export { type BaseStagesCommandOptions, baseStagesCommand } from "./base-stages-command.js";
|
|
59
59
|
export type { ApiCommandInput, ApiCommands } from "./bot/api.js";
|
|
60
|
+
export { type HttpApiExecutorOptions, type HttpApiRequest, httpApiExecutor, httpApiRequest } from "./bot/api-http.js";
|
|
60
61
|
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, } from "./bot/api-input.js";
|
|
61
62
|
export { prepareRpcApiBody, type RpcApiBody } from "./bot/api-rpc.js";
|
|
62
63
|
export { type BotContext, botContext, botWords } from "./bot/context.js";
|
|
@@ -84,7 +85,7 @@ export { DEFAULT_CONFIG, ensureDefaultConfig } from "./default-config.js";
|
|
|
84
85
|
export { DISCOVERY_DESCRIPTIONS } from "./discovery-descriptions.js";
|
|
85
86
|
export { type DoctorReportsSource, doctorReportsCommand } from "./doctor-reports-command.js";
|
|
86
87
|
export { refuseOffline } from "./early-refusal.js";
|
|
87
|
-
export { admittedUnderLock, changesAuthority, changesAuthorityAt, changesAuthorityNow, destroysNothing, FETCH, fetchesOnly, fetchesOnlyAt, grantsAuthority, isLogin, isOtherServiceCall, isProposal, isStoreChange, judgedEffects, judgedTargets, LOCAL_READ, LOCAL_WRITE, LOCKED_AUTHORITY_COMMANDS, logsInOrOut, NO_EFFECTS, narrowsUnderLock, ownerOnlyOption, PROPOSE_COMMANDS, previewFlag, proposesOnly, REMOTE_READ, REMOTE_WRITE, reachesOtherService, readsOverMcp, readsOverMcpAt, refuseUnderReadOnly, storeChangeRefusal, writesFileOnlyWith, writesNewFileOnlyWith, } from "./effects.js";
|
|
88
|
+
export { admittedUnderLock, changesAuthority, changesAuthorityAt, changesAuthorityNow, destroysNothing, FETCH, fetchesOnly, fetchesOnlyAt, grantsAuthority, isLogin, isOtherServiceCall, isProposal, isStoreChange, judgedEffects, judgedTargets, LOCAL_READ, LOCAL_WRITE, LOCKED_AUTHORITY_COMMANDS, logsInOrOut, NO_EFFECTS, narrowsUnderLock, ownerOnlyOption, PROPOSE_COMMANDS, previewFlag, proposesOnly, REMOTE_READ, REMOTE_WRITE, reachesOtherService, readsOverMcp, readsOverMcpAt, refuseUnderReadOnly, storeChangeRefusal, writesFileOnlyWith, writesNewFileOnlyWith, writesOwnerFiles, } from "./effects.js";
|
|
88
89
|
export { type CliEntry, type EntryContext, type EntryIo, openBrowser, startCli } from "./entry.js";
|
|
89
90
|
export { type AnswerOutput, answerSchema, type Body, type ItemBody, isBody, itemAnswer, itemOf, jsonlRecords, judgedAnswer, type ListBody, type ListInput, listOf, metaNow, printItem, renderAnswer, sealed, snakeKeys, snakeKeysKeeping, } from "./envelope.js";
|
|
90
91
|
export { withAbort } from "./execution.js";
|
package/dist/cli/index.js
CHANGED
|
@@ -50,6 +50,7 @@ export { openAppStore } from "./app-store.js";
|
|
|
50
50
|
export { askBeforeWrite } from "./ask-before-write.js";
|
|
51
51
|
export { actorOf } from "./author.js";
|
|
52
52
|
export { baseStagesCommand } from "./base-stages-command.js";
|
|
53
|
+
export { httpApiExecutor, httpApiRequest } from "./bot/api-http.js";
|
|
53
54
|
export { apiFlagOf, apiJson, apiOptionKey, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson, readApiBody, } from "./bot/api-input.js";
|
|
54
55
|
export { prepareRpcApiBody } from "./bot/api-rpc.js";
|
|
55
56
|
export { botContext, botWords } from "./bot/context.js";
|
|
@@ -75,7 +76,7 @@ export { DEFAULT_CONFIG, ensureDefaultConfig } from "./default-config.js";
|
|
|
75
76
|
export { DISCOVERY_DESCRIPTIONS } from "./discovery-descriptions.js";
|
|
76
77
|
export { doctorReportsCommand } from "./doctor-reports-command.js";
|
|
77
78
|
export { refuseOffline } from "./early-refusal.js";
|
|
78
|
-
export { admittedUnderLock, changesAuthority, changesAuthorityAt, changesAuthorityNow, destroysNothing, FETCH, fetchesOnly, fetchesOnlyAt, grantsAuthority, isLogin, isOtherServiceCall, isProposal, isStoreChange, judgedEffects, judgedTargets, LOCAL_READ, LOCAL_WRITE, LOCKED_AUTHORITY_COMMANDS, logsInOrOut, NO_EFFECTS, narrowsUnderLock, ownerOnlyOption, PROPOSE_COMMANDS, previewFlag, proposesOnly, REMOTE_READ, REMOTE_WRITE, reachesOtherService, readsOverMcp, readsOverMcpAt, refuseUnderReadOnly, storeChangeRefusal, writesFileOnlyWith, writesNewFileOnlyWith, } from "./effects.js";
|
|
79
|
+
export { admittedUnderLock, changesAuthority, changesAuthorityAt, changesAuthorityNow, destroysNothing, FETCH, fetchesOnly, fetchesOnlyAt, grantsAuthority, isLogin, isOtherServiceCall, isProposal, isStoreChange, judgedEffects, judgedTargets, LOCAL_READ, LOCAL_WRITE, LOCKED_AUTHORITY_COMMANDS, logsInOrOut, NO_EFFECTS, narrowsUnderLock, ownerOnlyOption, PROPOSE_COMMANDS, previewFlag, proposesOnly, REMOTE_READ, REMOTE_WRITE, reachesOtherService, readsOverMcp, readsOverMcpAt, refuseUnderReadOnly, storeChangeRefusal, writesFileOnlyWith, writesNewFileOnlyWith, writesOwnerFiles, } from "./effects.js";
|
|
79
80
|
export { openBrowser, startCli } from "./entry.js";
|
|
80
81
|
export { answerSchema, isBody, itemAnswer, itemOf, jsonlRecords, judgedAnswer, listOf, metaNow, printItem, renderAnswer, sealed, snakeKeys, snakeKeysKeeping, } from "./envelope.js";
|
|
81
82
|
export { withAbort } from "./execution.js";
|
|
@@ -4,7 +4,7 @@ import { Command } from "commander";
|
|
|
4
4
|
import { describe, MAX_ACTIONS } from "../../moderation/check.js";
|
|
5
5
|
import { RULE_KEYS } from "../../moderation/rules.js";
|
|
6
6
|
import { dateWindow } from "../../services/moment.js";
|
|
7
|
-
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE, REMOTE_WRITE } from "../effects.js";
|
|
7
|
+
import { grantsAuthority, LOCAL_READ, LOCAL_WRITE, ownerOnlyOption, REMOTE_WRITE } from "../effects.js";
|
|
8
8
|
import { itemOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
9
9
|
import { answerOf } from "./ask.js";
|
|
10
10
|
import { renderItem } from "./chat-answers.js";
|
|
@@ -48,7 +48,7 @@ export const moderateCommand = (messenger) => annotate(new Command("moderate"),
|
|
|
48
48
|
.argument("<chat>", messenger.chatArgument)
|
|
49
49
|
.option("--since-time <time>", "judge what came after this ISO 8601 time, or 2h / 1d ago; the saved point stays")
|
|
50
50
|
.option("--dry-run", "judge and plan; do nothing")
|
|
51
|
-
.
|
|
51
|
+
.addOption(ownerOnlyOption("--allow-dangerous", "yes to every action whose level in the group's rules is ask"))
|
|
52
52
|
.option("--max-actions <n>", `at most this many actions in one run; ${MAX_ACTIONS} if not given`)
|
|
53
53
|
.action(async function (chat) {
|
|
54
54
|
const context = messengerContext(this, messenger);
|
|
@@ -10,7 +10,7 @@ import { seal } from "../../sealed.js";
|
|
|
10
10
|
import { CHAT_KINDS } from "../../services/chats.js";
|
|
11
11
|
import { kindsOf } from "../../services/inbox.js";
|
|
12
12
|
import { dateWindow } from "../../services/moment.js";
|
|
13
|
-
import { destroysNothing, LOCAL_READ, LOCAL_WRITE } from "../effects.js";
|
|
13
|
+
import { destroysNothing, LOCAL_READ, LOCAL_WRITE, ownerOnlyOption } from "../effects.js";
|
|
14
14
|
import { itemOf, listOf, renderAnswer, snakeKeys } from "../envelope.js";
|
|
15
15
|
import { commandAt, lineOf } from "../steps.js";
|
|
16
16
|
import { jobsCommand } from "./backfill-command.js";
|
|
@@ -123,7 +123,7 @@ const leftLines = (left) => {
|
|
|
123
123
|
const clearCommand = (messenger) => annotate(new Command("clear"), { output: { entity: "store_clear" }, effects: LOCAL_WRITE })
|
|
124
124
|
.description("delete from the store the chats this account has left, with their messages")
|
|
125
125
|
.option("--left", "the chats this account has left — the only thing this clears")
|
|
126
|
-
.
|
|
126
|
+
.addOption(ownerOnlyOption("--allow-dangerous", "yes, delete — it cannot be undone, and a chat you left cannot be fetched again"))
|
|
127
127
|
.option("--dry-run", "list the chats it would delete, and delete nothing")
|
|
128
128
|
.action(async function () {
|
|
129
129
|
const { left, allowDangerous, dryRun } = this.opts();
|
|
@@ -286,8 +286,8 @@ export declare const connectedFor: (command: Command, messenger: Pick<Messenger,
|
|
|
286
286
|
export declare const markedProfile: (messenger: Messenger, profile: string, env: NodeJS.ProcessEnv) => string;
|
|
287
287
|
/**
|
|
288
288
|
* A write to the local store alone. `deny` already stopped the command (`messengerContext`); `readonly`
|
|
289
|
-
* stops this write too
|
|
290
|
-
* writing unasked.
|
|
289
|
+
* stops this write too, unless it only fetches from the messenger (`fetchesUnder`). There is no
|
|
290
|
+
* question to put to the owner here, so `ask` refuses rather than writing unasked.
|
|
291
291
|
*/
|
|
292
292
|
export declare const refuseLocalWrite: (context: MessengerContext, command: string, permission: PermissionKey) => void;
|
|
293
293
|
export declare const messengerContext: (command: Command, messenger: Messenger, resolving?: Pick<ResolveOptions, "needsProfile">) => MessengerContext;
|
|
@@ -3,7 +3,7 @@ import { servingProfiles } from "../../background/lock.js";
|
|
|
3
3
|
import { FloodMemory, floodPathFor } from "../../sends/flood.js";
|
|
4
4
|
import { ceilingRefusal, guardFor } from "../../sends/guard.js";
|
|
5
5
|
import { DEFAULT_PACE, Pacer, pacePathFor } from "../../sends/pace.js";
|
|
6
|
-
import { CEILING_KEY, levelFor, readKeysForCommand } from "../../sends/permissions.js";
|
|
6
|
+
import { CEILING_KEY, fetchesUnder, levelFor, readKeysForCommand } from "../../sends/permissions.js";
|
|
7
7
|
import { RecipientList, recipientsPathFor } from "../../sends/recipients.js";
|
|
8
8
|
import { OFFLINE, servicesFor } from "../../services/index.js";
|
|
9
9
|
import { openStore } from "../../store/store.js";
|
|
@@ -344,14 +344,16 @@ const refuseDenied = (command, settings) => {
|
|
|
344
344
|
};
|
|
345
345
|
/**
|
|
346
346
|
* A write to the local store alone. `deny` already stopped the command (`messengerContext`); `readonly`
|
|
347
|
-
* stops this write too
|
|
348
|
-
* writing unasked.
|
|
347
|
+
* stops this write too, unless it only fetches from the messenger (`fetchesUnder`). There is no
|
|
348
|
+
* question to put to the owner here, so `ask` refuses rather than writing unasked.
|
|
349
349
|
*/
|
|
350
350
|
export const refuseLocalWrite = (context, command, permission) => {
|
|
351
351
|
const { settings } = context;
|
|
352
352
|
const { level, key } = levelFor(settings.permissions, permission);
|
|
353
353
|
if (level === "allow" || (level === "ask" && context.agent))
|
|
354
354
|
return;
|
|
355
|
+
if (fetchesUnder(level, permission))
|
|
356
|
+
return;
|
|
355
357
|
if (key === CEILING_KEY)
|
|
356
358
|
throw ceilingRefusal(permission, command);
|
|
357
359
|
throw new CliError(level === "ask" ? "confirmation_required" : "permission_error", `profile ${settings.profile} does not let ${permission} write (permissions.${key} is ${level}, from the ` +
|
|
@@ -61,7 +61,8 @@ export const rankingsTopCommand = (messenger, target) => {
|
|
|
61
61
|
return services.rankings.top(target, {
|
|
62
62
|
...params,
|
|
63
63
|
...sync,
|
|
64
|
-
|
|
64
|
+
// A configured limit is a listing's page; a ranking takes at most 100 rows, so it is capped, not refused.
|
|
65
|
+
limit: params.limit ?? Math.min(context.settings.limit, 100),
|
|
65
66
|
signal: environmentOf(this).commandSignal ?? environmentOf(this).signal,
|
|
66
67
|
...(saved ? { saved } : {}),
|
|
67
68
|
});
|
|
@@ -80,7 +80,7 @@ export const serveCommand = (messenger) => {
|
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
82
|
const counts = {};
|
|
83
|
-
const rules = replying(context, messenger, Date.parse(startedAt));
|
|
83
|
+
const rules = replying(context, messenger, Date.parse(startedAt), () => messenger.resolveSettings(this.optsWithGlobals(), { env: context.env }));
|
|
84
84
|
const tasks = tasking(context, warn);
|
|
85
85
|
const { handled, startSyncDelayMs, outdated: outdatedHook } = environmentOf(this);
|
|
86
86
|
const count = (event) => {
|
|
@@ -226,7 +226,7 @@ const NO_REPLIES = {
|
|
|
226
226
|
stop: () => { },
|
|
227
227
|
summary: () => ({}),
|
|
228
228
|
};
|
|
229
|
-
const replying = (context, messenger, since) => {
|
|
229
|
+
const replying = (context, messenger, since, reload) => {
|
|
230
230
|
if (messenger.autoReplies === false)
|
|
231
231
|
return NO_REPLIES;
|
|
232
232
|
const controller = new AbortController();
|
|
@@ -252,6 +252,11 @@ const replying = (context, messenger, since) => {
|
|
|
252
252
|
if (connection === undefined || controller.signal.aborted)
|
|
253
253
|
return;
|
|
254
254
|
const open = connection;
|
|
255
|
+
// serve runs for days: `config set permissions.replies.send deny` must stop the next reply, as it stops the next
|
|
256
|
+
// MCP call. The send guard reads the same settings.
|
|
257
|
+
const current = reload();
|
|
258
|
+
settings.permissions = current.permissions;
|
|
259
|
+
settings.permissionSources = current.permissionSources;
|
|
255
260
|
const answer = await replyTo({
|
|
256
261
|
rulesPath: repliesPathFor(app, profile, env),
|
|
257
262
|
statePath: repliesStatePathFor(app, profile, env),
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { type Messenger } from "./context.js";
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* `none` clears a date; anything else is a time ahead. Not `null`: commander stores a parser's `null` as "". With
|
|
5
|
+
* `end`, a date alone is the end of that day: a task due on the 20th is not overdue all of the 20th.
|
|
6
|
+
*/
|
|
7
|
+
export declare const dateOrNone: (flag: string, { end }?: {
|
|
8
|
+
end?: boolean;
|
|
9
|
+
}) => (typed: string) => "none" | Date;
|
|
5
10
|
/** What waits on the owner — kept in the local store by `src/tasks/`; nothing here reaches the messenger. */
|
|
6
11
|
export declare const tasksCommand: (messenger: Messenger) => Command;
|
|
7
12
|
export declare const tasksStatsCommand: (messenger: Messenger) => Command;
|
|
@@ -96,8 +96,11 @@ const pairLine = (pair) => [
|
|
|
96
96
|
`${pair.task?.title ?? ""} | ${pair.other.title}`,
|
|
97
97
|
`(${pair.reasons.join(", ")})`,
|
|
98
98
|
].join(" ");
|
|
99
|
-
/**
|
|
100
|
-
|
|
99
|
+
/**
|
|
100
|
+
* `none` clears a date; anything else is a time ahead. Not `null`: commander stores a parser's `null` as "". With
|
|
101
|
+
* `end`, a date alone is the end of that day: a task due on the 20th is not overdue all of the 20th.
|
|
102
|
+
*/
|
|
103
|
+
export const dateOrNone = (flag, { end = false } = {}) => (typed) => typed.trim().toLowerCase() === "none" ? "none" : new Date(aheadOf(typed, flag, Date.now(), { end }));
|
|
101
104
|
const durationOf = (flag) => (typed) => {
|
|
102
105
|
const wanted = typed.trim();
|
|
103
106
|
const ms = Date.now() - momentOf(wanted, flag);
|
|
@@ -108,7 +111,7 @@ const durationOf = (flag) => (typed) => {
|
|
|
108
111
|
const planOptions = (command, verb) => command
|
|
109
112
|
.option("--title <title>", `one line: the action and its object — ${verb}`)
|
|
110
113
|
.option("--description <text>", "the detail, in Markdown: who owes whom, done when, next step, keywords")
|
|
111
|
-
.option("--due <time>", "when it must be done: an ISO 8601 time or 2h, 3d from now; none clears it", dateOrNone("--due"))
|
|
114
|
+
.option("--due <time>", "when it must be done: an ISO 8601 time or 2h, 3d from now; none clears it", dateOrNone("--due", { end: true }))
|
|
112
115
|
.option("--remind-time <time>", "when to look at it again: an ISO 8601 time or 2h, 3d from now; none clears it", dateOrNone("--remind-time"))
|
|
113
116
|
.option("--assignee <person...>", "who does it: sender (whoever sent the task's message) or person:<id>; none clears it. Leave it out when " +
|
|
114
117
|
"unsure: a task with no assignee is better than none");
|
|
@@ -438,9 +441,10 @@ export const tasksCommand = (messenger) => {
|
|
|
438
441
|
"Reads only the local store")
|
|
439
442
|
.argument("<chat...>", messenger.chatArgument)
|
|
440
443
|
.option("--last <n>", `read the newest n stored messages of each chat (default ${ARRIVAL_WINDOW}, at most 1000)`, positiveCount("--last"))
|
|
444
|
+
.option("--yes", "open and close the tasks it lists; otherwise only list them")
|
|
441
445
|
.action(async function (chats) {
|
|
442
446
|
const context = messengerContext(this, messenger);
|
|
443
|
-
const { last, yes = false } = this.
|
|
447
|
+
const { last, yes = false } = this.opts();
|
|
444
448
|
if (yes)
|
|
445
449
|
refuseLocalWrite(context, messenger.app.command, "tasks.scan");
|
|
446
450
|
const passes = await context.withStore(async (store, account) => {
|
package/dist/cli/preview.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CliError } from "@wirecat/cli-base";
|
|
2
2
|
import { metaOf } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { writes as writesAnything } from "@wirecat/cli-base/standards";
|
|
4
|
-
import {
|
|
4
|
+
import { keyForCommand, levelFor, readKeysForCommand, WRITE_KEYS } from "../sends/permissions.js";
|
|
5
5
|
import { commandPathOf } from "./command-contract.js";
|
|
6
6
|
import { fetchesOnly } from "./effects.js";
|
|
7
7
|
import { refuseUnknownPermissionKeys } from "./permission-keys.js";
|
|
@@ -14,9 +14,7 @@ export const preview = (command, settings, tool, keys, messenger = true) => {
|
|
|
14
14
|
const keyOf = typeof keys === "object" ? keys.keyOf : keys;
|
|
15
15
|
refuseUnknownPermissionKeys(command, settings, tool, declared ?? (keyOf && ((one) => keyOf(commandPathOf(one)))));
|
|
16
16
|
const key = declared ? declared.keyOf(path) : (keyOf?.(path) ?? keyForCommand(path));
|
|
17
|
-
const { level, key:
|
|
18
|
-
? levelFor(permissions, key, declared?.defaults)
|
|
19
|
-
: { level: "allow", key: null };
|
|
17
|
+
const { level } = key ? levelFor(permissions, key, declared?.defaults) : { level: "allow" };
|
|
20
18
|
for (const source of declared ? [] : readKeysForCommand(path)) {
|
|
21
19
|
if (levelFor(permissions, source).level === "deny")
|
|
22
20
|
throw new CliError("permission_error", `this profile does not permit ${source}`, { permission: source });
|
|
@@ -24,7 +22,7 @@ export const preview = (command, settings, tool, keys, messenger = true) => {
|
|
|
24
22
|
const meta = metaOf(command);
|
|
25
23
|
const writes = ((meta.effects !== undefined && writesAnything(meta.effects)) ||
|
|
26
24
|
(!declared && key !== null && key !== undefined && WRITE_KEYS.includes(key))) &&
|
|
27
|
-
!
|
|
25
|
+
!fetchesOnly(command);
|
|
28
26
|
if (level === "deny" || (writes && level === "readonly"))
|
|
29
27
|
throw new CliError("permission_error", `this profile does not permit ${path.join(" ")}`, { permission: key });
|
|
30
28
|
const also = (declared?.alsoChecks?.(path) ?? []).map((one) => {
|
package/dist/cli/program.js
CHANGED
|
@@ -38,6 +38,7 @@ import { PreviewComplete, preview } from "./preview.js";
|
|
|
38
38
|
import { commandWords, isProfileName, liftProfile, sampleCommand, takesProfile, valuedOptions } from "./profile.js";
|
|
39
39
|
import { absolutePaths, relayTarget } from "./relay-route.js";
|
|
40
40
|
import { NoProfileHere, namedProfile, settingsFor, } from "./settings.js";
|
|
41
|
+
import { shareShadowedOptions } from "./shadowed-options.js";
|
|
41
42
|
import { assertSharedContracts } from "./shared-contracts.js";
|
|
42
43
|
import { skillSourceOf } from "./skill-command.js";
|
|
43
44
|
import { refreshSkills, skipsSkillRefresh } from "./skill-refresh.js";
|
|
@@ -330,8 +331,7 @@ const runOnce = async (argv, definition, options) => {
|
|
|
330
331
|
if (flags.input === false || (headless && !options.answer))
|
|
331
332
|
environment.answer = () => null;
|
|
332
333
|
const localPreview = action.options.some((option) => option.long === "--dry-run");
|
|
333
|
-
|
|
334
|
-
action.setOptionValue("dryRun", true);
|
|
334
|
+
shareShadowedOptions(action);
|
|
335
335
|
refuseOfflineCommand(action, definition.app, flags.offline === true, flags.dryRun === true && localPreview);
|
|
336
336
|
const path = commandPathOf(action);
|
|
337
337
|
await enterCommandServer(action, command);
|
|
@@ -52,6 +52,9 @@ const whenOf = ({ every, at = [], atTime }, minimum) => {
|
|
|
52
52
|
throw new CliError("validation_error", "say when: --every <30m|2h|1d>, --at HH:MM (daily) or --at 'mon HH:MM' (weekly), repeated for more times, or --at-time <30m|2d|ISO time>");
|
|
53
53
|
}
|
|
54
54
|
if (atTime) {
|
|
55
|
+
// As messages send --at-time: a date alone would be its midnight, which nobody means by "send on the 20th".
|
|
56
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(atTime.trim()))
|
|
57
|
+
throw new CliError("validation_error", `--at-time needs a time of day as well: ${atTime.trim()}T09:00`);
|
|
55
58
|
const time = aheadOf(atTime, "--at-time");
|
|
56
59
|
if (time <= Date.now())
|
|
57
60
|
throw new CliError("validation_error", "--at-time is in the past");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* commander gives a flag that the root and the command both declare (`--yes`, `--timeout`, `--dry-run`) to the root,
|
|
4
|
+
* so the command's own option stays empty (BUG-760). The value goes to the command's option too, through its own
|
|
5
|
+
* parser, so `--timeout 2m` on an option that takes seconds still arrives as seconds.
|
|
6
|
+
*/
|
|
7
|
+
export declare const shareShadowedOptions: (action: Command) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const GIVEN = new Set(["cli", "env", "config"]);
|
|
2
|
+
/**
|
|
3
|
+
* commander gives a flag that the root and the command both declare (`--yes`, `--timeout`, `--dry-run`) to the root,
|
|
4
|
+
* so the command's own option stays empty (BUG-760). The value goes to the command's option too, through its own
|
|
5
|
+
* parser, so `--timeout 2m` on an option that takes seconds still arrives as seconds.
|
|
6
|
+
*/
|
|
7
|
+
export const shareShadowedOptions = (action) => {
|
|
8
|
+
const ancestors = [];
|
|
9
|
+
for (let at = action.parent; at; at = at.parent)
|
|
10
|
+
ancestors.push(at);
|
|
11
|
+
for (const option of action.options) {
|
|
12
|
+
const key = option.attributeName();
|
|
13
|
+
if (GIVEN.has(action.getOptionValueSource(key) ?? ""))
|
|
14
|
+
continue;
|
|
15
|
+
const holder = ancestors.find((one) => GIVEN.has(one.getOptionValueSource(key) ?? ""));
|
|
16
|
+
if (!holder)
|
|
17
|
+
continue;
|
|
18
|
+
const value = holder.getOptionValue(key);
|
|
19
|
+
const takesValue = option.required || option.optional;
|
|
20
|
+
if (typeof value === "boolean" && !takesValue)
|
|
21
|
+
action.setOptionValueWithSource(key, value, "cli");
|
|
22
|
+
// commander's own handler parses and validates it, as when typed; its types leave out that a Command is an emitter.
|
|
23
|
+
else if (typeof value === "string" && takesValue)
|
|
24
|
+
action.emit(`option:${option.name()}`, value);
|
|
25
|
+
}
|
|
26
|
+
};
|
package/dist/crm/cli/index.js
CHANGED
|
@@ -280,8 +280,10 @@ const addCrmCommandsDefinition = (program, options) => {
|
|
|
280
280
|
});
|
|
281
281
|
example(answerEntity(annotate(store.command("apply"), { effects: LOCAL_WRITE }), "crm_contacts_removed", crmContactsApplied).description("apply scope mine to the contacts already stored: remove those no deal or lead of the chosen users and no " +
|
|
282
282
|
"kept company names, and the people they leave empty; counts only unless --yes, under scope all too. A " +
|
|
283
|
-
"sync that narrows the scope, or sync --rescan under mine, does this itself"), "store apply", "store apply --yes")
|
|
284
|
-
|
|
283
|
+
"sync that narrows the scope, or sync --rescan under mine, does this itself"), "store apply", "store apply --yes")
|
|
284
|
+
.option("--yes", "remove the contacts it counts; otherwise only count them")
|
|
285
|
+
.action(async (opts, command) => {
|
|
286
|
+
const yes = opts.yes === true;
|
|
285
287
|
await within(command, async (run) => {
|
|
286
288
|
const scope = crmSettingKey(run.account, "scope");
|
|
287
289
|
if (yes && (await run.store.crm.scope(run.account)).mode !== "mine")
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML character references as text, in one pass so `&lt;` stays the text `<`. Numeric ones are all decoded;
|
|
3
|
+
* of the named ones, those that mail and calendar invitations use. An unknown name stays as written.
|
|
4
|
+
*/
|
|
5
|
+
export declare const decodeEntities: (text: string) => string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const NAMED = {
|
|
2
|
+
amp: "&",
|
|
3
|
+
lt: "<",
|
|
4
|
+
gt: ">",
|
|
5
|
+
quot: '"',
|
|
6
|
+
apos: "'",
|
|
7
|
+
nbsp: "\u00a0",
|
|
8
|
+
shy: "\u00ad",
|
|
9
|
+
ensp: "\u2002",
|
|
10
|
+
emsp: "\u2003",
|
|
11
|
+
thinsp: "\u2009",
|
|
12
|
+
zwnj: "\u200c",
|
|
13
|
+
zwj: "\u200d",
|
|
14
|
+
lsquo: "‘",
|
|
15
|
+
rsquo: "’",
|
|
16
|
+
sbquo: "‚",
|
|
17
|
+
ldquo: "“",
|
|
18
|
+
rdquo: "”",
|
|
19
|
+
bdquo: "„",
|
|
20
|
+
laquo: "«",
|
|
21
|
+
raquo: "»",
|
|
22
|
+
lsaquo: "‹",
|
|
23
|
+
rsaquo: "›",
|
|
24
|
+
ndash: "–",
|
|
25
|
+
mdash: "—",
|
|
26
|
+
hellip: "…",
|
|
27
|
+
bull: "•",
|
|
28
|
+
middot: "·",
|
|
29
|
+
copy: "©",
|
|
30
|
+
reg: "®",
|
|
31
|
+
trade: "™",
|
|
32
|
+
euro: "€",
|
|
33
|
+
pound: "£",
|
|
34
|
+
yen: "¥",
|
|
35
|
+
cent: "¢",
|
|
36
|
+
deg: "°",
|
|
37
|
+
plusmn: "±",
|
|
38
|
+
times: "×",
|
|
39
|
+
divide: "÷",
|
|
40
|
+
sect: "§",
|
|
41
|
+
para: "¶",
|
|
42
|
+
iexcl: "¡",
|
|
43
|
+
iquest: "¿",
|
|
44
|
+
};
|
|
45
|
+
const character = (code, entity) => code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : entity;
|
|
46
|
+
/**
|
|
47
|
+
* HTML character references as text, in one pass so `&lt;` stays the text `<`. Numeric ones are all decoded;
|
|
48
|
+
* of the named ones, those that mail and calendar invitations use. An unknown name stays as written.
|
|
49
|
+
*/
|
|
50
|
+
export const decodeEntities = (text) => text.replace(/&(#x[0-9a-f]{1,6}|#\d{1,7}|[a-z]{2,8});/gi, (entity, body) => {
|
|
51
|
+
if (body[0] !== "#")
|
|
52
|
+
return NAMED[body] ?? NAMED[body.toLowerCase()] ?? entity;
|
|
53
|
+
return body[1] === "x" || body[1] === "X"
|
|
54
|
+
? character(Number.parseInt(body.slice(2), 16), entity)
|
|
55
|
+
: character(Number(body.slice(1)), entity);
|
|
56
|
+
});
|
package/dist/domain/locator.js
CHANGED
|
@@ -6,9 +6,17 @@ export const isLocator = (reference) => reference.trim().startsWith(SCHEME);
|
|
|
6
6
|
export const parseLocator = (reference) => {
|
|
7
7
|
const trimmed = reference.trim();
|
|
8
8
|
const parts = trimmed.startsWith(SCHEME) ? trimmed.slice(SCHEME.length).split("/") : [];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
9
|
+
const malformed = () => new CliError("validation_error", `"${singleLine(reference)}" is not a message locator — expected msg:<provider>/<account>/<chat>/<message>`);
|
|
10
|
+
if (parts.length !== 4 || parts.some((part) => part === ""))
|
|
11
|
+
throw malformed();
|
|
12
|
+
const decoded = (part) => {
|
|
13
|
+
try {
|
|
14
|
+
return decodeURIComponent(part);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
throw malformed();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const [provider, account, chat, message] = parts.map(decoded);
|
|
13
21
|
return { provider, account, chat, message };
|
|
14
22
|
};
|
|
@@ -32,11 +32,19 @@ export const SIMPLE_REFERENCES = [
|
|
|
32
32
|
const malformed = (text, shape) => new CliError("validation_error", `"${singleLine(text)}" is not a reference — expected ${shape}`, {
|
|
33
33
|
reason: "ref.malformed",
|
|
34
34
|
});
|
|
35
|
+
const decoded = (part, text, shape) => {
|
|
36
|
+
try {
|
|
37
|
+
return decodeURIComponent(part);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
throw malformed(text, shape);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
35
43
|
const parts = (rest, count, text, shape) => {
|
|
36
44
|
const split = rest.split("/");
|
|
37
45
|
if (split.length !== count || split.some((part) => part === ""))
|
|
38
46
|
throw malformed(text, shape);
|
|
39
|
-
return split.map(
|
|
47
|
+
return split.map((part) => decoded(part, text, shape));
|
|
40
48
|
};
|
|
41
49
|
const encoded = (...values) => values.map(encodeURIComponent).join("/");
|
|
42
50
|
/** A subfolder spelled one way: no leading, trailing or doubled slash, and `.` for the folder itself. */
|
|
@@ -104,8 +112,8 @@ export const REF_KINDS = [
|
|
|
104
112
|
shape: "folder:<id>[/<path>]",
|
|
105
113
|
parse: (rest, text) => {
|
|
106
114
|
const slash = rest.indexOf("/");
|
|
107
|
-
const id =
|
|
108
|
-
const path = slash < 0 ? null : folderPath(
|
|
115
|
+
const id = decoded(slash < 0 ? rest : rest.slice(0, slash), text, "folder:<id>[/<path>]");
|
|
116
|
+
const path = slash < 0 ? null : folderPath(decoded(rest.slice(slash + 1), text, "folder:<id>[/<path>]"));
|
|
109
117
|
if (!id.trim() || path === "")
|
|
110
118
|
throw malformed(text, "folder:<id>[/<path>]");
|
|
111
119
|
return { type: "folder", id, path };
|
|
@@ -59,9 +59,9 @@ export declare const documentEntryDetails: v.StrictObjectSchema<{
|
|
|
59
59
|
readonly has_text: v.BooleanSchema<undefined>;
|
|
60
60
|
readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
61
61
|
readonly text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
62
|
-
/** Where `text` starts in the whole text, in
|
|
62
|
+
/** Where `text` starts in the whole text, in Unicode code points: an emoji counts once, a combining mark apart. */
|
|
63
63
|
readonly text_offset: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
64
|
-
/** The whole text's length, in
|
|
64
|
+
/** The whole text's length, in code points. The next part starts at `text_offset` plus the code points of `text`. */
|
|
65
65
|
readonly text_length: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
66
66
|
/** More text follows `text`: read it with a larger offset. */
|
|
67
67
|
readonly has_more: v.BooleanSchema<undefined>;
|
|
@@ -318,9 +318,9 @@ export declare const LISTING_ENTITIES: {
|
|
|
318
318
|
readonly has_text: v.BooleanSchema<undefined>;
|
|
319
319
|
readonly untrusted: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
320
320
|
readonly text: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
321
|
-
/** Where `text` starts in the whole text, in
|
|
321
|
+
/** Where `text` starts in the whole text, in Unicode code points: an emoji counts once, a combining mark apart. */
|
|
322
322
|
readonly text_offset: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
323
|
-
/** The whole text's length, in
|
|
323
|
+
/** The whole text's length, in code points. The next part starts at `text_offset` plus the code points of `text`. */
|
|
324
324
|
readonly text_length: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
325
325
|
/** More text follows `text`: read it with a larger offset. */
|
|
326
326
|
readonly has_more: v.BooleanSchema<undefined>;
|
|
@@ -40,9 +40,9 @@ const linked = v.strictObject({ ref: reference, title: v.nullable(text), at: v.n
|
|
|
40
40
|
export const documentEntryDetails = v.strictObject({
|
|
41
41
|
...documentEntry.entries,
|
|
42
42
|
text: v.nullable(text),
|
|
43
|
-
/** Where `text` starts in the whole text, in
|
|
43
|
+
/** Where `text` starts in the whole text, in Unicode code points: an emoji counts once, a combining mark apart. */
|
|
44
44
|
text_offset: count,
|
|
45
|
-
/** The whole text's length, in
|
|
45
|
+
/** The whole text's length, in code points. The next part starts at `text_offset` plus the code points of `text`. */
|
|
46
46
|
text_length: count,
|
|
47
47
|
/** More text follows `text`: read it with a larger offset. */
|
|
48
48
|
has_more: v.boolean(),
|
|
@@ -15,8 +15,17 @@ export interface SyncAfterInstallOptions {
|
|
|
15
15
|
err: string;
|
|
16
16
|
out?: string;
|
|
17
17
|
}>;
|
|
18
|
-
/** Words of a
|
|
18
|
+
/** Words of a change that a `readonly` level must still refuse, as a check it opens no more. */
|
|
19
19
|
refusedUnderReadOnly?: readonly string[];
|
|
20
|
+
/**
|
|
21
|
+
* The profile's own levels, set in a config of its own: `variable` names the CLI's config folder
|
|
22
|
+
* (`TG_CONFIG_DIR`), and each of `keys` (`messages`, the key the sync's command names) is set to `readonly`, which
|
|
23
|
+
* the sync must pass, and to `deny`, which must refuse it.
|
|
24
|
+
*/
|
|
25
|
+
profileLevels?: {
|
|
26
|
+
variable: string;
|
|
27
|
+
keys: readonly string[];
|
|
28
|
+
};
|
|
20
29
|
}
|
|
21
30
|
/**
|
|
22
31
|
* Cases that a CLI's sync runs right after install, whatever state the shared config is in. The kit points
|
|
@@ -4,7 +4,8 @@ import { tmpdir } from "node:os";
|
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
/**
|
|
6
6
|
* The shared config (`~/.config/WireCat/config.json`) as a fresh or damaged machine has it. Only an explicit
|
|
7
|
-
* "read only" answer limits a tool, and even then a sync runs: it only reads the service (owner
|
|
7
|
+
* "read only" answer limits a tool, and even then a sync runs: it only reads the service (owner rulings, 2026-11-13
|
|
8
|
+
* and 2026-11-14, which extends it to a profile's own `readonly`).
|
|
8
9
|
* A slip with one reading is mended in place (2026-11-14), so only `broken` states may fail a step.
|
|
9
10
|
*/
|
|
10
11
|
const SHARED_CONFIGS = [
|
|
@@ -51,15 +52,32 @@ const errorCodeOf = (text) => {
|
|
|
51
52
|
* the CLI's own harness gives.
|
|
52
53
|
*/
|
|
53
54
|
export const syncAfterInstallCases = (options) => {
|
|
54
|
-
const { sync, refusedUnderReadOnly } = options;
|
|
55
|
-
const
|
|
55
|
+
const { sync, refusedUnderReadOnly, profileLevels } = options;
|
|
56
|
+
const profile = sync[0];
|
|
57
|
+
const cli = async (argv, shared, levels) => {
|
|
56
58
|
const configDir = mkdtempSync(join(tmpdir(), "sync-after-install-"));
|
|
57
59
|
shared.write?.(configDir);
|
|
60
|
+
const own = {};
|
|
61
|
+
if (levels && profileLevels) {
|
|
62
|
+
const dir = mkdtempSync(join(tmpdir(), "sync-after-install-own-"));
|
|
63
|
+
writeFileSync(join(dir, "config.json"), JSON.stringify({ profiles: { [profile]: { permissions: levels } } }));
|
|
64
|
+
own[profileLevels.variable] = dir;
|
|
65
|
+
}
|
|
58
66
|
const ran = await options.run(argv.includes("--json") ? [...argv] : [...argv, "--json"], {
|
|
59
67
|
WIRECAT_CONFIG_DIR: configDir,
|
|
68
|
+
...own,
|
|
60
69
|
});
|
|
61
70
|
return { code: ran.code, out: ran.out ?? "", err: ran.err };
|
|
62
71
|
};
|
|
72
|
+
const fresh = SHARED_CONFIGS[0];
|
|
73
|
+
const readOnly = SHARED_CONFIGS.find((one) => one.readOnly);
|
|
74
|
+
const refused = (name, argv, shared, levels) => ({
|
|
75
|
+
name,
|
|
76
|
+
run: async () => {
|
|
77
|
+
const ran = await cli(argv, shared, levels);
|
|
78
|
+
assert.equal(errorCodeOf(ran.err), "permission_error", `it was not refused: ${ran.out}${ran.err}`);
|
|
79
|
+
},
|
|
80
|
+
});
|
|
63
81
|
return [
|
|
64
82
|
...SHARED_CONFIGS.map((shared) => ({
|
|
65
83
|
name: `${sync.join(" ")} runs with ${shared.state}`,
|
|
@@ -71,16 +89,22 @@ export const syncAfterInstallCases = (options) => {
|
|
|
71
89
|
assert.equal(ran.code, 0, `sync exited ${ran.code}: ${ran.out}${ran.err}`);
|
|
72
90
|
},
|
|
73
91
|
})),
|
|
92
|
+
...(profileLevels?.keys ?? []).flatMap((key) => [
|
|
93
|
+
{
|
|
94
|
+
name: `${sync.join(" ")} runs with permissions.${key} readonly in the profile`,
|
|
95
|
+
run: async () => {
|
|
96
|
+
const ran = await cli(sync, fresh, { [key]: "readonly" });
|
|
97
|
+
assert.notEqual(errorCodeOf(ran.err), "permission_error", `sync was refused: ${ran.err}`);
|
|
98
|
+
assert.equal(ran.code, 0, `sync exited ${ran.code}: ${ran.out}${ran.err}`);
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
refused(`${sync.join(" ")} is refused with permissions.${key} deny in the profile`, sync, fresh, {
|
|
102
|
+
[key]: "deny",
|
|
103
|
+
}),
|
|
104
|
+
]),
|
|
74
105
|
...(refusedUnderReadOnly
|
|
75
106
|
? [
|
|
76
|
-
{
|
|
77
|
-
name: `${refusedUnderReadOnly.join(" ")} is still refused under the explicit "read only" answer`,
|
|
78
|
-
run: async () => {
|
|
79
|
-
const readOnly = SHARED_CONFIGS.find((one) => one.readOnly);
|
|
80
|
-
const ran = await cli(refusedUnderReadOnly, readOnly);
|
|
81
|
-
assert.equal(errorCodeOf(ran.err), "permission_error", `it was not refused: ${ran.out}${ran.err}`);
|
|
82
|
-
},
|
|
83
|
-
},
|
|
107
|
+
refused(`${refusedUnderReadOnly.join(" ")} is still refused under the explicit "read only" answer`, refusedUnderReadOnly, readOnly),
|
|
84
108
|
]
|
|
85
109
|
: []),
|
|
86
110
|
];
|
package/dist/mail/headers.js
CHANGED
|
@@ -31,9 +31,9 @@ export const authOf = (unfolded) => {
|
|
|
31
31
|
export const addressesOf = (value) => {
|
|
32
32
|
if (value === undefined)
|
|
33
33
|
return [];
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
return
|
|
34
|
+
// A display name may itself look like an address ("bob@y.com" <real@z.com>), so quoted names and comments go first.
|
|
35
|
+
const bare = value.replace(/"(?:[^"\\]|\\.)*"/g, " ").replace(/\([^()]*\)/g, " ");
|
|
36
|
+
return [...bare.matchAll(/<([^<>\s]+@[^<>\s]+)>|([^\s<>,;:"()]+@[^\s<>,;:"()]+)/g)].map(([, bracketed, plain]) => String(bracketed ?? plain).toLowerCase());
|
|
37
37
|
};
|
|
38
38
|
const nameOf = (value) => {
|
|
39
39
|
const before = /^\s*(.*?)\s*<[^<>]+>\s*$/.exec(value)?.[1];
|