@openclaw/whatsapp 2026.5.2 → 2026.5.3-beta.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/dist/access-control-BQ3tCkH8.js +288 -0
- package/dist/account-config-CNQ33oav.js +47 -0
- package/dist/account-ids-DG18xddX.js +5 -0
- package/dist/accounts-BDqgpFEB.js +116 -0
- package/dist/action-runtime-DTGNgG-i.js +74 -0
- package/dist/action-runtime-api.js +2 -0
- package/dist/action-runtime.runtime.js +2 -0
- package/dist/active-listener-N7GFKsuN.js +11 -0
- package/dist/agent-tools-login-DpRxLNRB.js +89 -0
- package/dist/api.js +148 -0
- package/dist/audio-preflight.runtime-Bcdsl_ri.js +7 -0
- package/dist/auth-presence.js +32 -0
- package/dist/auth-store-BjCb50Ry.js +381 -0
- package/dist/channel-DQ-5Xoj9.js +542 -0
- package/dist/channel-config-api.js +2 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel-react-action-Df20qAy9.js +42 -0
- package/dist/channel.runtime-DKXRnA8x.js +55 -0
- package/dist/channel.setup-DOHR2BGp.js +20 -0
- package/dist/command-policy-O8sRnqUV.js +8 -0
- package/dist/config-schema-Dmo66Ubb.js +27 -0
- package/dist/connection-controller-BiHAsTM8.js +596 -0
- package/dist/connection-controller-registry-D_iIGz5m.js +22 -0
- package/dist/constants-DLGCIbfl.js +4 -0
- package/dist/constants.js +2 -0
- package/dist/contract-api.js +19 -0
- package/dist/creds-files-_2V8jzQa.js +19 -0
- package/dist/directory-config-DVs4ffXu.js +37 -0
- package/dist/directory-contract-api.js +2 -0
- package/dist/doctor-A9tXm9Om.js +48 -0
- package/dist/doctor-contract-api.js +10 -0
- package/dist/group-session-contract-B8QBn0I2.js +15 -0
- package/dist/identity-QHAlV7Fu.js +75 -0
- package/dist/index.js +18 -0
- package/dist/legacy-session-surface-api.js +8 -0
- package/dist/legacy-state-migrations-api.js +2 -0
- package/dist/light-runtime-api.js +5 -0
- package/dist/login-DymdrKca.js +52 -0
- package/dist/login-qr-DIS0Iv-7.js +378 -0
- package/dist/login-qr-api.js +2 -0
- package/dist/login-qr-runtime.js +16 -0
- package/dist/monitor-C4Fhg_lD.js +3349 -0
- package/dist/normalize-CWYiGkXw.js +2 -0
- package/dist/normalize-target-BPVHNsM5.js +74 -0
- package/dist/outbound-adapter-BssVnZdz.js +29 -0
- package/dist/outbound-base-Bq1UYEK5.js +119 -0
- package/dist/outbound-media-contract-CGss_QHy.js +163 -0
- package/dist/outbound-payload-test-api.js +2 -0
- package/dist/quoted-message-TENQzyxV.js +108 -0
- package/dist/reaction-level-CRVEVAfi.js +16 -0
- package/dist/reply-resolver.runtime-BRCgoO4C.js +2 -0
- package/dist/resolve-outbound-target-CN-Wo6IY.js +39 -0
- package/dist/rolldown-runtime-RkAeH_Qm.js +27 -0
- package/dist/runtime-6fZ67abR.js +8 -0
- package/dist/runtime-api.js +15 -0
- package/dist/runtime-group-policy-Gp1lQ0at.js +11 -0
- package/dist/secret-contract-api.js +5 -0
- package/dist/security-contract-DqH8JDX6.js +26 -0
- package/dist/security-contract-api.js +2 -0
- package/dist/send-CIyLFxdZ.js +234 -0
- package/dist/session-contract-B0efQf9P.js +27 -0
- package/dist/session-errors-CSuKZPub.js +63 -0
- package/dist/session.runtime-C1eSE_KK.js +13 -0
- package/dist/setup-core-DZKvpzbH.js +46 -0
- package/dist/setup-entry.js +23 -0
- package/dist/setup-plugin-api.js +2 -0
- package/dist/setup-surface-ieFnIW4g.js +344 -0
- package/dist/shared-D_wzSVar.js +307 -0
- package/dist/state-migrations-DnCdvoYD.js +39 -0
- package/dist/targets.js +2 -0
- package/dist/test-api.js +3 -0
- package/dist/text-runtime-C1zNiZeO.js +116 -0
- package/package.json +14 -6
- package/action-runtime-api.ts +0 -1
- package/action-runtime.runtime.ts +0 -1
- package/api.ts +0 -213
- package/auth-presence.ts +0 -80
- package/channel-config-api.ts +0 -1
- package/channel-plugin-api.ts +0 -3
- package/config-api.ts +0 -4
- package/constants.ts +0 -1
- package/contract-api.ts +0 -29
- package/directory-contract-api.ts +0 -4
- package/doctor-contract-api.ts +0 -8
- package/index.test.ts +0 -13
- package/index.ts +0 -16
- package/legacy-session-surface-api.ts +0 -6
- package/legacy-state-migrations-api.ts +0 -1
- package/light-runtime-api.ts +0 -12
- package/login-qr-api.ts +0 -1
- package/login-qr-runtime.ts +0 -23
- package/outbound-payload-test-api.ts +0 -1
- package/runtime-api.ts +0 -84
- package/secret-contract-api.ts +0 -4
- package/security-contract-api.ts +0 -4
- package/setup-entry.test.ts +0 -21
- package/setup-entry.ts +0 -21
- package/setup-plugin-api.ts +0 -3
- package/src/account-config.ts +0 -77
- package/src/account-ids.ts +0 -13
- package/src/account-types.ts +0 -5
- package/src/accounts.test.ts +0 -182
- package/src/accounts.ts +0 -176
- package/src/accounts.whatsapp-auth.test.ts +0 -59
- package/src/action-runtime-target-auth.ts +0 -27
- package/src/action-runtime.test.ts +0 -330
- package/src/action-runtime.ts +0 -76
- package/src/active-listener.test.ts +0 -65
- package/src/active-listener.ts +0 -17
- package/src/agent-tools-login.test.ts +0 -81
- package/src/agent-tools-login.ts +0 -113
- package/src/approval-auth.test.ts +0 -24
- package/src/approval-auth.ts +0 -27
- package/src/auth-store.runtime.ts +0 -1
- package/src/auth-store.test.ts +0 -311
- package/src/auth-store.ts +0 -502
- package/src/auto-reply/config.runtime.ts +0 -16
- package/src/auto-reply/constants.ts +0 -1
- package/src/auto-reply/deliver-reply.test.ts +0 -843
- package/src/auto-reply/deliver-reply.ts +0 -279
- package/src/auto-reply/loggers.ts +0 -6
- package/src/auto-reply/mentions.ts +0 -131
- package/src/auto-reply/monitor/ack-reaction.test.ts +0 -170
- package/src/auto-reply/monitor/ack-reaction.ts +0 -99
- package/src/auto-reply/monitor/audio-preflight.runtime.ts +0 -9
- package/src/auto-reply/monitor/broadcast.ts +0 -153
- package/src/auto-reply/monitor/commands.ts +0 -19
- package/src/auto-reply/monitor/echo.ts +0 -64
- package/src/auto-reply/monitor/group-activation.runtime.ts +0 -1
- package/src/auto-reply/monitor/group-activation.test.ts +0 -189
- package/src/auto-reply/monitor/group-activation.ts +0 -73
- package/src/auto-reply/monitor/group-gating.audio-preflight.test.ts +0 -103
- package/src/auto-reply/monitor/group-gating.runtime.ts +0 -8
- package/src/auto-reply/monitor/group-gating.ts +0 -217
- package/src/auto-reply/monitor/group-members.test.ts +0 -56
- package/src/auto-reply/monitor/group-members.ts +0 -65
- package/src/auto-reply/monitor/inbound-context.test.ts +0 -97
- package/src/auto-reply/monitor/inbound-context.ts +0 -92
- package/src/auto-reply/monitor/inbound-dispatch.runtime.ts +0 -21
- package/src/auto-reply/monitor/inbound-dispatch.test.ts +0 -895
- package/src/auto-reply/monitor/inbound-dispatch.ts +0 -422
- package/src/auto-reply/monitor/last-route.test.ts +0 -37
- package/src/auto-reply/monitor/last-route.ts +0 -61
- package/src/auto-reply/monitor/message-line.runtime.ts +0 -38
- package/src/auto-reply/monitor/message-line.ts +0 -54
- package/src/auto-reply/monitor/on-message.audio-preflight.test.ts +0 -354
- package/src/auto-reply/monitor/on-message.ts +0 -291
- package/src/auto-reply/monitor/peer.ts +0 -17
- package/src/auto-reply/monitor/process-message.audio-preflight.test.ts +0 -420
- package/src/auto-reply/monitor/process-message.test.ts +0 -355
- package/src/auto-reply/monitor/process-message.ts +0 -531
- package/src/auto-reply/monitor/runtime-api.ts +0 -30
- package/src/auto-reply/monitor-state.test.ts +0 -64
- package/src/auto-reply/monitor-state.ts +0 -106
- package/src/auto-reply/monitor.ts +0 -600
- package/src/auto-reply/reply-resolver.runtime.ts +0 -1
- package/src/auto-reply/types.ts +0 -48
- package/src/auto-reply/util.ts +0 -63
- package/src/auto-reply/web-auto-reply-monitor.test.ts +0 -687
- package/src/auto-reply/web-auto-reply-utils.test.ts +0 -392
- package/src/auto-reply.broadcast-groups.combined.test.ts +0 -246
- package/src/auto-reply.broadcast-groups.test-harness.ts +0 -47
- package/src/auto-reply.impl.ts +0 -6
- package/src/auto-reply.test-harness.ts +0 -421
- package/src/auto-reply.ts +0 -1
- package/src/auto-reply.web-auto-reply.compresses-common-formats-jpeg-cap.test.ts +0 -427
- package/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts +0 -908
- package/src/auto-reply.web-auto-reply.last-route.test.ts +0 -184
- package/src/channel-actions.runtime.ts +0 -7
- package/src/channel-actions.test.ts +0 -216
- package/src/channel-actions.ts +0 -84
- package/src/channel-outbound.test.ts +0 -131
- package/src/channel-outbound.ts +0 -36
- package/src/channel-react-action.runtime.ts +0 -7
- package/src/channel-react-action.test.ts +0 -294
- package/src/channel-react-action.ts +0 -84
- package/src/channel.runtime.ts +0 -117
- package/src/channel.setup.test.ts +0 -461
- package/src/channel.setup.ts +0 -28
- package/src/channel.ts +0 -339
- package/src/command-policy.ts +0 -7
- package/src/config-accessors.test.ts +0 -34
- package/src/config-accessors.ts +0 -22
- package/src/config-schema.test.ts +0 -121
- package/src/config-schema.ts +0 -6
- package/src/config-ui-hints.ts +0 -24
- package/src/connection-controller-registry.test.ts +0 -27
- package/src/connection-controller-registry.ts +0 -49
- package/src/connection-controller.test.ts +0 -282
- package/src/connection-controller.ts +0 -679
- package/src/creds-files.ts +0 -19
- package/src/creds-persistence.ts +0 -102
- package/src/directory-config.test.ts +0 -60
- package/src/directory-config.ts +0 -40
- package/src/directory-contract.test.ts +0 -56
- package/src/doctor-contract.ts +0 -11
- package/src/doctor.test.ts +0 -74
- package/src/doctor.ts +0 -56
- package/src/group-intro.ts +0 -15
- package/src/group-policy.test.ts +0 -36
- package/src/group-policy.ts +0 -40
- package/src/group-session-contract.ts +0 -20
- package/src/group-session-key.test.ts +0 -53
- package/src/group-session-key.ts +0 -41
- package/src/heartbeat.ts +0 -34
- package/src/identity.ts +0 -164
- package/src/inbound/access-control.test-harness.ts +0 -37
- package/src/inbound/access-control.test.ts +0 -375
- package/src/inbound/access-control.ts +0 -237
- package/src/inbound/dedupe.ts +0 -132
- package/src/inbound/extract.test.ts +0 -282
- package/src/inbound/extract.ts +0 -488
- package/src/inbound/lifecycle.ts +0 -39
- package/src/inbound/media.node.test.ts +0 -83
- package/src/inbound/media.ts +0 -102
- package/src/inbound/monitor.ts +0 -890
- package/src/inbound/runtime-api.ts +0 -7
- package/src/inbound/save-media.runtime.ts +0 -1
- package/src/inbound/send-api.test.ts +0 -319
- package/src/inbound/send-api.ts +0 -145
- package/src/inbound/send-result.ts +0 -61
- package/src/inbound/types.ts +0 -106
- package/src/inbound-context.contract.test.ts +0 -32
- package/src/inbound-policy.ts +0 -231
- package/src/inbound.media.test.ts +0 -320
- package/src/inbound.test.ts +0 -290
- package/src/inbound.ts +0 -9
- package/src/login-qr.test.ts +0 -483
- package/src/login-qr.ts +0 -542
- package/src/login.coverage.test.ts +0 -133
- package/src/login.test.ts +0 -89
- package/src/login.ts +0 -70
- package/src/logout.test.ts +0 -162
- package/src/media.test.ts +0 -480
- package/src/media.ts +0 -10
- package/src/monitor-inbox.allows-messages-from-senders-allowfrom-list.test-support.ts +0 -400
- package/src/monitor-inbox.append-upsert.test-support.ts +0 -133
- package/src/monitor-inbox.behavior.test.ts +0 -5
- package/src/monitor-inbox.blocks-messages-from-unauthorized-senders-not-allowfrom.test-support.ts +0 -362
- package/src/monitor-inbox.captures-media-path-image-messages.test-support.ts +0 -306
- package/src/monitor-inbox.streams-inbound-messages.test-support.ts +0 -729
- package/src/monitor-inbox.test-harness.ts +0 -304
- package/src/normalize-target.ts +0 -123
- package/src/normalize.ts +0 -7
- package/src/outbound-adapter.poll.test.ts +0 -62
- package/src/outbound-adapter.sendpayload.test.ts +0 -195
- package/src/outbound-adapter.ts +0 -36
- package/src/outbound-base.test.ts +0 -560
- package/src/outbound-base.ts +0 -244
- package/src/outbound-media-contract.ts +0 -278
- package/src/outbound-media.runtime.ts +0 -36
- package/src/outbound-payload.contract.test.ts +0 -61
- package/src/outbound-send-deps.ts +0 -1
- package/src/outbound-test-support.ts +0 -16
- package/src/pairing-security.test-harness.ts +0 -59
- package/src/qr-image.ts +0 -1
- package/src/qr-terminal.ts +0 -1
- package/src/quoted-message.test.ts +0 -83
- package/src/quoted-message.ts +0 -184
- package/src/reaction-level.test.ts +0 -94
- package/src/reaction-level.ts +0 -21
- package/src/reconnect.test.ts +0 -51
- package/src/reconnect.ts +0 -55
- package/src/resolve-outbound-target.test.ts +0 -288
- package/src/resolve-outbound-target.ts +0 -58
- package/src/resolve-target.test.ts +0 -120
- package/src/runtime-api.ts +0 -59
- package/src/runtime-group-policy.ts +0 -16
- package/src/runtime.ts +0 -9
- package/src/security-contract.ts +0 -47
- package/src/security-fix.ts +0 -71
- package/src/send.test.ts +0 -534
- package/src/send.ts +0 -292
- package/src/session-contract.test.ts +0 -31
- package/src/session-contract.ts +0 -43
- package/src/session-errors.ts +0 -125
- package/src/session-route.test.ts +0 -41
- package/src/session-route.ts +0 -32
- package/src/session.runtime.ts +0 -8
- package/src/session.test.ts +0 -559
- package/src/session.ts +0 -330
- package/src/setup-core.ts +0 -52
- package/src/setup-finalize.ts +0 -446
- package/src/setup-surface.test.ts +0 -367
- package/src/setup-surface.ts +0 -69
- package/src/setup-test-helpers.ts +0 -216
- package/src/shared.ts +0 -291
- package/src/socket-timing.test.ts +0 -49
- package/src/socket-timing.ts +0 -38
- package/src/state-migrations.ts +0 -54
- package/src/status-issues.test.ts +0 -137
- package/src/status-issues.ts +0 -185
- package/src/system-prompt.test.ts +0 -199
- package/src/system-prompt.ts +0 -31
- package/src/targets-runtime.ts +0 -180
- package/src/test-helpers.ts +0 -690
- package/src/text-runtime.test.ts +0 -162
- package/src/text-runtime.ts +0 -11
- package/src/vcard.ts +0 -84
- package/targets.ts +0 -5
- package/test-api.ts +0 -2
- package/tsconfig.json +0 -16
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createPluginSetupWizardStatus,
|
|
3
|
-
createQueuedWizardPrompter,
|
|
4
|
-
runSetupWizardFinalize,
|
|
5
|
-
} from "openclaw/plugin-sdk/plugin-test-runtime";
|
|
6
|
-
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
|
|
7
|
-
import { DEFAULT_ACCOUNT_ID, type OpenClawConfig } from "openclaw/plugin-sdk/setup";
|
|
8
|
-
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
9
|
-
import { whatsappSetupWizard } from "./setup-surface.js";
|
|
10
|
-
import {
|
|
11
|
-
createWhatsAppAllowlistModeInput,
|
|
12
|
-
createWhatsAppLinkingHarness,
|
|
13
|
-
createWhatsAppOwnerAllowlistHarness,
|
|
14
|
-
createWhatsAppPersonalPhoneHarness,
|
|
15
|
-
createWhatsAppRootAllowFromConfig,
|
|
16
|
-
createWhatsAppWorkAccountConfig,
|
|
17
|
-
expectNoWhatsAppLoginFollowup,
|
|
18
|
-
expectWhatsAppAllowlistModeSetup,
|
|
19
|
-
expectWhatsAppLoginFollowup,
|
|
20
|
-
expectWhatsAppOpenPolicySetup,
|
|
21
|
-
expectWhatsAppOwnerAllowlistSetup,
|
|
22
|
-
expectWhatsAppPersonalPhoneSetup,
|
|
23
|
-
expectWhatsAppSeparatePhoneDisabledSetup,
|
|
24
|
-
expectWhatsAppWorkAccountAccessNote,
|
|
25
|
-
expectWhatsAppWorkAccountOpenAccess,
|
|
26
|
-
} from "./setup-test-helpers.js";
|
|
27
|
-
|
|
28
|
-
const hoisted = vi.hoisted(() => ({
|
|
29
|
-
detectWhatsAppLinked: vi.fn<(cfg: OpenClawConfig, accountId: string) => Promise<boolean>>(
|
|
30
|
-
async () => false,
|
|
31
|
-
),
|
|
32
|
-
loginWeb: vi.fn(async () => {}),
|
|
33
|
-
pathExists: vi.fn(async () => false),
|
|
34
|
-
readWebAuthState: vi.fn<(authDir: string) => Promise<"linked" | "not-linked" | "unstable">>(
|
|
35
|
-
async () => "not-linked",
|
|
36
|
-
),
|
|
37
|
-
resolveWhatsAppAuthDir: vi.fn<
|
|
38
|
-
(params: { cfg: OpenClawConfig; accountId: string }) => { authDir: string }
|
|
39
|
-
>(() => ({
|
|
40
|
-
authDir: "/tmp/openclaw-whatsapp-test",
|
|
41
|
-
})),
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
|
-
vi.mock("./login.js", () => ({
|
|
45
|
-
loginWeb: hoisted.loginWeb,
|
|
46
|
-
}));
|
|
47
|
-
|
|
48
|
-
vi.mock("./setup-finalize.js", async () => {
|
|
49
|
-
const actual = await vi.importActual<typeof import("./setup-finalize.js")>("./setup-finalize.js");
|
|
50
|
-
return {
|
|
51
|
-
...actual,
|
|
52
|
-
detectWhatsAppLinked: hoisted.detectWhatsAppLinked,
|
|
53
|
-
};
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
vi.mock("openclaw/plugin-sdk/setup", async () => {
|
|
57
|
-
const actual = await vi.importActual<typeof import("openclaw/plugin-sdk/setup")>(
|
|
58
|
-
"openclaw/plugin-sdk/setup",
|
|
59
|
-
);
|
|
60
|
-
return {
|
|
61
|
-
...actual,
|
|
62
|
-
pathExists: hoisted.pathExists,
|
|
63
|
-
};
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
vi.mock("./accounts.js", async () => {
|
|
67
|
-
const actual = await vi.importActual<typeof import("./accounts.js")>("./accounts.js");
|
|
68
|
-
return Object.assign({}, actual, {
|
|
69
|
-
resolveWhatsAppAuthDir: hoisted.resolveWhatsAppAuthDir,
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
vi.mock("./auth-store.js", async () => {
|
|
74
|
-
const actual = await vi.importActual<typeof import("./auth-store.js")>("./auth-store.js");
|
|
75
|
-
return Object.assign({}, actual, {
|
|
76
|
-
readWebAuthState: hoisted.readWebAuthState,
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const createRuntime = (): RuntimeEnv =>
|
|
81
|
-
({
|
|
82
|
-
error: vi.fn(),
|
|
83
|
-
}) as unknown as RuntimeEnv;
|
|
84
|
-
|
|
85
|
-
const whatsappGetStatus = createPluginSetupWizardStatus({
|
|
86
|
-
id: "whatsapp",
|
|
87
|
-
meta: {
|
|
88
|
-
label: "WhatsApp",
|
|
89
|
-
},
|
|
90
|
-
setupWizard: whatsappSetupWizard,
|
|
91
|
-
} as never);
|
|
92
|
-
|
|
93
|
-
async function runFinalizeWithHarness(params: {
|
|
94
|
-
harness: ReturnType<typeof createQueuedWizardPrompter>;
|
|
95
|
-
cfg?: Parameters<NonNullable<typeof whatsappSetupWizard.finalize>>[0]["cfg"];
|
|
96
|
-
runtime?: RuntimeEnv;
|
|
97
|
-
forceAllowFrom?: boolean;
|
|
98
|
-
accountId?: string;
|
|
99
|
-
}) {
|
|
100
|
-
return await runSetupWizardFinalize({
|
|
101
|
-
finalize: whatsappSetupWizard.finalize,
|
|
102
|
-
cfg: params.cfg ?? {},
|
|
103
|
-
accountId: params.accountId ?? DEFAULT_ACCOUNT_ID,
|
|
104
|
-
runtime: params.runtime ?? createRuntime(),
|
|
105
|
-
prompter: params.harness.prompter,
|
|
106
|
-
forceAllowFrom: params.forceAllowFrom ?? false,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function createSeparatePhoneHarness(params: { selectValues: string[]; textValues?: string[] }) {
|
|
111
|
-
return createQueuedWizardPrompter({
|
|
112
|
-
confirmValues: [false],
|
|
113
|
-
selectValues: params.selectValues,
|
|
114
|
-
textValues: params.textValues,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function expectFinalizeResult(result: Awaited<ReturnType<typeof runFinalizeWithHarness>>): {
|
|
119
|
-
cfg: OpenClawConfig;
|
|
120
|
-
} {
|
|
121
|
-
expect(result).toBeDefined();
|
|
122
|
-
if (!result || typeof result !== "object" || !("cfg" in result) || !result.cfg) {
|
|
123
|
-
throw new Error("Expected WhatsApp finalize result with cfg");
|
|
124
|
-
}
|
|
125
|
-
return result as { cfg: OpenClawConfig };
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
async function runSeparatePhoneFlow(params: { selectValues: string[]; textValues?: string[] }) {
|
|
129
|
-
hoisted.pathExists.mockResolvedValue(true);
|
|
130
|
-
const harness = createSeparatePhoneHarness({
|
|
131
|
-
selectValues: params.selectValues,
|
|
132
|
-
textValues: params.textValues,
|
|
133
|
-
});
|
|
134
|
-
const result = expectFinalizeResult(
|
|
135
|
-
await runFinalizeWithHarness({
|
|
136
|
-
harness,
|
|
137
|
-
}),
|
|
138
|
-
);
|
|
139
|
-
return { harness, result };
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
describe("whatsapp setup wizard", () => {
|
|
143
|
-
beforeEach(() => {
|
|
144
|
-
hoisted.detectWhatsAppLinked.mockReset();
|
|
145
|
-
hoisted.detectWhatsAppLinked.mockResolvedValue(false);
|
|
146
|
-
hoisted.loginWeb.mockReset();
|
|
147
|
-
hoisted.pathExists.mockReset();
|
|
148
|
-
hoisted.pathExists.mockResolvedValue(false);
|
|
149
|
-
hoisted.readWebAuthState.mockReset();
|
|
150
|
-
hoisted.readWebAuthState.mockResolvedValue("not-linked");
|
|
151
|
-
hoisted.resolveWhatsAppAuthDir.mockReset();
|
|
152
|
-
hoisted.resolveWhatsAppAuthDir.mockReturnValue({ authDir: "/tmp/openclaw-whatsapp-test" });
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("applies owner allowlist when forceAllowFrom is enabled", async () => {
|
|
156
|
-
const harness = createWhatsAppOwnerAllowlistHarness(createQueuedWizardPrompter);
|
|
157
|
-
|
|
158
|
-
const result = expectFinalizeResult(
|
|
159
|
-
await runFinalizeWithHarness({
|
|
160
|
-
harness,
|
|
161
|
-
forceAllowFrom: true,
|
|
162
|
-
}),
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
expect(hoisted.loginWeb).not.toHaveBeenCalled();
|
|
166
|
-
expectWhatsAppOwnerAllowlistSetup(result.cfg, harness);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("supports disabled DM policy for separate-phone setup", async () => {
|
|
170
|
-
const { harness, result } = await runSeparatePhoneFlow({
|
|
171
|
-
selectValues: ["separate", "disabled"],
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
expectWhatsAppSeparatePhoneDisabledSetup(result.cfg, harness);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("writes named-account DM policy and allowFrom instead of the channel root", async () => {
|
|
178
|
-
hoisted.pathExists.mockResolvedValue(true);
|
|
179
|
-
const harness = createSeparatePhoneHarness({
|
|
180
|
-
selectValues: ["separate", "open"],
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const named = expectFinalizeResult(
|
|
184
|
-
await runFinalizeWithHarness({
|
|
185
|
-
harness,
|
|
186
|
-
accountId: "work",
|
|
187
|
-
cfg: createWhatsAppWorkAccountConfig() as OpenClawConfig,
|
|
188
|
-
}),
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
expectWhatsAppWorkAccountOpenAccess(named.cfg);
|
|
192
|
-
expectWhatsAppWorkAccountAccessNote(harness);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it("labels the selected named account in setup status even when not linked", async () => {
|
|
196
|
-
const status = await whatsappGetStatus({
|
|
197
|
-
cfg: {
|
|
198
|
-
channels: {
|
|
199
|
-
whatsapp: {
|
|
200
|
-
accounts: {
|
|
201
|
-
work: {
|
|
202
|
-
authDir: "/tmp/work",
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
} as OpenClawConfig,
|
|
208
|
-
accountOverrides: {
|
|
209
|
-
whatsapp: "work",
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
expect(status.configured).toBe(false);
|
|
214
|
-
expect(status.statusLines).toEqual(["WhatsApp (work): not linked"]);
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
it("uses configured defaultAccount for omitted-account setup status", async () => {
|
|
218
|
-
hoisted.resolveWhatsAppAuthDir.mockImplementation(({ accountId }: { accountId: string }) => ({
|
|
219
|
-
authDir: accountId === "work" ? "/tmp/work" : "/tmp/default",
|
|
220
|
-
}));
|
|
221
|
-
hoisted.readWebAuthState.mockImplementation(async (authDir: string) =>
|
|
222
|
-
authDir === "/tmp/work" ? "linked" : "not-linked",
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
const status = await whatsappGetStatus({
|
|
226
|
-
cfg: {
|
|
227
|
-
channels: {
|
|
228
|
-
whatsapp: {
|
|
229
|
-
defaultAccount: "work",
|
|
230
|
-
accounts: {
|
|
231
|
-
default: {
|
|
232
|
-
authDir: "/tmp/default",
|
|
233
|
-
},
|
|
234
|
-
work: {
|
|
235
|
-
authDir: "/tmp/work",
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
} as OpenClawConfig,
|
|
241
|
-
accountOverrides: {},
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
expect(status.configured).toBe(true);
|
|
245
|
-
expect(status.statusLines).toEqual(["WhatsApp (work): linked"]);
|
|
246
|
-
expect(hoisted.readWebAuthState).toHaveBeenCalledWith("/tmp/default");
|
|
247
|
-
expect(hoisted.readWebAuthState).toHaveBeenCalledWith("/tmp/work");
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it("shows auth stabilizing when auth reads time out", async () => {
|
|
251
|
-
hoisted.resolveWhatsAppAuthDir.mockReturnValue({ authDir: "/tmp/work" });
|
|
252
|
-
hoisted.readWebAuthState.mockResolvedValue("unstable");
|
|
253
|
-
|
|
254
|
-
const status = await whatsappGetStatus({
|
|
255
|
-
cfg: {
|
|
256
|
-
channels: {
|
|
257
|
-
whatsapp: {
|
|
258
|
-
accounts: {
|
|
259
|
-
work: {
|
|
260
|
-
authDir: "/tmp/work",
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
} as OpenClawConfig,
|
|
266
|
-
accountOverrides: {
|
|
267
|
-
whatsapp: "work",
|
|
268
|
-
},
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
expect(status.configured).toBe(false);
|
|
272
|
-
expect(status.statusLines).toEqual(["WhatsApp (work): auth stabilizing"]);
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it("uses configured defaultAccount for omitted-account finalize writes", async () => {
|
|
276
|
-
hoisted.pathExists.mockResolvedValue(true);
|
|
277
|
-
const harness = createSeparatePhoneHarness({
|
|
278
|
-
selectValues: ["separate", "open"],
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
const result = expectFinalizeResult(
|
|
282
|
-
await runFinalizeWithHarness({
|
|
283
|
-
harness,
|
|
284
|
-
accountId: "",
|
|
285
|
-
cfg: createWhatsAppWorkAccountConfig({ defaultAccount: "work" }) as OpenClawConfig,
|
|
286
|
-
}),
|
|
287
|
-
);
|
|
288
|
-
|
|
289
|
-
expectWhatsAppWorkAccountOpenAccess(result.cfg);
|
|
290
|
-
expectWhatsAppWorkAccountAccessNote(harness);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it("normalizes allowFrom entries when list mode is selected", async () => {
|
|
294
|
-
const { result } = await runSeparatePhoneFlow(createWhatsAppAllowlistModeInput());
|
|
295
|
-
|
|
296
|
-
expectWhatsAppAllowlistModeSetup(result.cfg);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
it("enables allowlist self-chat mode for personal-phone setup", async () => {
|
|
300
|
-
hoisted.pathExists.mockResolvedValue(true);
|
|
301
|
-
const harness = createWhatsAppPersonalPhoneHarness(createQueuedWizardPrompter);
|
|
302
|
-
|
|
303
|
-
const result = expectFinalizeResult(
|
|
304
|
-
await runFinalizeWithHarness({
|
|
305
|
-
harness,
|
|
306
|
-
}),
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
expectWhatsAppPersonalPhoneSetup(result.cfg);
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
it("forces wildcard allowFrom for open policy without allowFrom follow-up prompts", async () => {
|
|
313
|
-
hoisted.pathExists.mockResolvedValue(true);
|
|
314
|
-
const harness = createSeparatePhoneHarness({
|
|
315
|
-
selectValues: ["separate", "open"],
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
const result = expectFinalizeResult(
|
|
319
|
-
await runFinalizeWithHarness({
|
|
320
|
-
harness,
|
|
321
|
-
cfg: createWhatsAppRootAllowFromConfig() as OpenClawConfig,
|
|
322
|
-
}),
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
expectWhatsAppOpenPolicySetup(result.cfg, harness);
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it("runs WhatsApp login when not linked and user confirms linking", async () => {
|
|
329
|
-
hoisted.pathExists.mockResolvedValue(false);
|
|
330
|
-
const harness = createWhatsAppLinkingHarness(createQueuedWizardPrompter);
|
|
331
|
-
const runtime = createRuntime();
|
|
332
|
-
|
|
333
|
-
await runFinalizeWithHarness({
|
|
334
|
-
harness,
|
|
335
|
-
runtime,
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
expect(hoisted.loginWeb).toHaveBeenCalledWith(false, undefined, runtime, DEFAULT_ACCOUNT_ID);
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
it("skips relink note when already linked and relink is declined", async () => {
|
|
342
|
-
hoisted.pathExists.mockResolvedValue(true);
|
|
343
|
-
const harness = createSeparatePhoneHarness({
|
|
344
|
-
selectValues: ["separate", "disabled"],
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
await runFinalizeWithHarness({
|
|
348
|
-
harness,
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
expect(hoisted.loginWeb).not.toHaveBeenCalled();
|
|
352
|
-
expectNoWhatsAppLoginFollowup(harness);
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
it("shows follow-up login command note when not linked and linking is skipped", async () => {
|
|
356
|
-
hoisted.pathExists.mockResolvedValue(false);
|
|
357
|
-
const harness = createSeparatePhoneHarness({
|
|
358
|
-
selectValues: ["separate", "disabled"],
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
await runFinalizeWithHarness({
|
|
362
|
-
harness,
|
|
363
|
-
});
|
|
364
|
-
|
|
365
|
-
expectWhatsAppLoginFollowup(harness);
|
|
366
|
-
});
|
|
367
|
-
});
|
package/src/setup-surface.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { ChannelSetupWizard } from "openclaw/plugin-sdk/setup";
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_ACCOUNT_ID,
|
|
4
|
-
setSetupChannelEnabled,
|
|
5
|
-
type OpenClawConfig,
|
|
6
|
-
} from "openclaw/plugin-sdk/setup";
|
|
7
|
-
import { listWhatsAppAccountIds, resolveWhatsAppAuthDir } from "./accounts.js";
|
|
8
|
-
import { formatWhatsAppWebAuthStatusState, readWebAuthState } from "./auth-store.js";
|
|
9
|
-
import { finalizeWhatsAppSetup } from "./setup-finalize.js";
|
|
10
|
-
|
|
11
|
-
const channel = "whatsapp" as const;
|
|
12
|
-
|
|
13
|
-
type WhatsAppSetupLinkState = "linked" | "not-linked" | "unstable";
|
|
14
|
-
|
|
15
|
-
async function readWhatsAppSetupLinkState(
|
|
16
|
-
cfg: OpenClawConfig,
|
|
17
|
-
accountId: string,
|
|
18
|
-
): Promise<WhatsAppSetupLinkState> {
|
|
19
|
-
const { authDir } = resolveWhatsAppAuthDir({ cfg, accountId });
|
|
20
|
-
return await readWebAuthState(authDir);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const whatsappSetupWizard: ChannelSetupWizard = {
|
|
24
|
-
channel,
|
|
25
|
-
status: {
|
|
26
|
-
configuredLabel: "linked",
|
|
27
|
-
unconfiguredLabel: "not linked",
|
|
28
|
-
configuredHint: "linked",
|
|
29
|
-
unconfiguredHint: "not linked",
|
|
30
|
-
configuredScore: 5,
|
|
31
|
-
unconfiguredScore: 4,
|
|
32
|
-
resolveConfigured: async ({ cfg, accountId }) => {
|
|
33
|
-
for (const resolvedAccountId of accountId ? [accountId] : listWhatsAppAccountIds(cfg)) {
|
|
34
|
-
if ((await readWhatsAppSetupLinkState(cfg, resolvedAccountId)) === "linked") {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
},
|
|
40
|
-
resolveStatusLines: async ({ cfg, accountId, configured }) => {
|
|
41
|
-
const linkedAccountId = (
|
|
42
|
-
await Promise.all(
|
|
43
|
-
(accountId ? [accountId] : listWhatsAppAccountIds(cfg)).map(
|
|
44
|
-
async (resolvedAccountId) => ({
|
|
45
|
-
accountId: resolvedAccountId,
|
|
46
|
-
state: await readWhatsAppSetupLinkState(cfg, resolvedAccountId),
|
|
47
|
-
}),
|
|
48
|
-
),
|
|
49
|
-
)
|
|
50
|
-
).find((entry) => entry.state === "linked" || entry.state === "unstable");
|
|
51
|
-
const labelAccountId = accountId ?? linkedAccountId?.accountId;
|
|
52
|
-
const label = labelAccountId
|
|
53
|
-
? `WhatsApp (${labelAccountId === DEFAULT_ACCOUNT_ID ? "default" : labelAccountId})`
|
|
54
|
-
: "WhatsApp";
|
|
55
|
-
const stateLabel = configured
|
|
56
|
-
? formatWhatsAppWebAuthStatusState("linked")
|
|
57
|
-
: formatWhatsAppWebAuthStatusState(linkedAccountId?.state ?? "not-linked");
|
|
58
|
-
return [`${label}: ${stateLabel}`];
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
resolveShouldPromptAccountIds: ({ shouldPromptAccountIds }) => shouldPromptAccountIds,
|
|
62
|
-
credentials: [],
|
|
63
|
-
finalize: async ({ cfg, accountId, forceAllowFrom, prompter, runtime }) =>
|
|
64
|
-
await finalizeWhatsAppSetup({ cfg, accountId, forceAllowFrom, prompter, runtime }),
|
|
65
|
-
disable: (cfg) => setSetupChannelEnabled(cfg, channel, false),
|
|
66
|
-
onAccountRecorded: (accountId, options) => {
|
|
67
|
-
options?.onAccountId?.(channel, accountId);
|
|
68
|
-
},
|
|
69
|
-
};
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { expect } from "vitest";
|
|
2
|
-
|
|
3
|
-
type WhatsAppSetupConfig = {
|
|
4
|
-
channels?: {
|
|
5
|
-
whatsapp?: {
|
|
6
|
-
selfChatMode?: boolean;
|
|
7
|
-
dmPolicy?: string;
|
|
8
|
-
allowFrom?: string[];
|
|
9
|
-
accounts?: Record<string, { dmPolicy?: string; allowFrom?: string[]; authDir?: string }>;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type WizardPromptHarness = {
|
|
15
|
-
text: (...args: unknown[]) => unknown;
|
|
16
|
-
select: (...args: unknown[]) => unknown;
|
|
17
|
-
note: (...args: unknown[]) => unknown;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type QueuedWizardPrompterFactory<T extends WizardPromptHarness> = (params: {
|
|
21
|
-
confirmValues?: boolean[];
|
|
22
|
-
selectValues?: string[];
|
|
23
|
-
textValues?: string[];
|
|
24
|
-
}) => T;
|
|
25
|
-
|
|
26
|
-
const WHATSAPP_OWNER_NUMBER_INPUT = "+1 (555) 555-0123";
|
|
27
|
-
const WHATSAPP_OWNER_NUMBER = "+15555550123";
|
|
28
|
-
const WHATSAPP_PERSONAL_NUMBER_INPUT = "+1 (555) 111-2222";
|
|
29
|
-
const WHATSAPP_PERSONAL_NUMBER = "+15551112222";
|
|
30
|
-
const WHATSAPP_ACCESS_NOTE_TITLE = "WhatsApp DM access";
|
|
31
|
-
const WHATSAPP_LOGIN_NOTE_TITLE = "WhatsApp";
|
|
32
|
-
|
|
33
|
-
export function createWhatsAppRootAllowFromConfig(): WhatsAppSetupConfig {
|
|
34
|
-
return {
|
|
35
|
-
channels: {
|
|
36
|
-
whatsapp: {
|
|
37
|
-
allowFrom: [WHATSAPP_OWNER_NUMBER],
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function createWhatsAppOwnerAllowlistHarness<T extends WizardPromptHarness>(
|
|
44
|
-
createPrompter: QueuedWizardPrompterFactory<T>,
|
|
45
|
-
): T {
|
|
46
|
-
return createPrompter({
|
|
47
|
-
confirmValues: [false],
|
|
48
|
-
textValues: [WHATSAPP_OWNER_NUMBER_INPUT],
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function createWhatsAppPersonalPhoneHarness<T extends WizardPromptHarness>(
|
|
53
|
-
createPrompter: QueuedWizardPrompterFactory<T>,
|
|
54
|
-
): T {
|
|
55
|
-
return createPrompter({
|
|
56
|
-
confirmValues: [false],
|
|
57
|
-
selectValues: ["personal"],
|
|
58
|
-
textValues: [WHATSAPP_PERSONAL_NUMBER_INPUT],
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function createWhatsAppLinkingHarness<T extends WizardPromptHarness>(
|
|
63
|
-
createPrompter: QueuedWizardPrompterFactory<T>,
|
|
64
|
-
): T {
|
|
65
|
-
return createPrompter({
|
|
66
|
-
confirmValues: [true],
|
|
67
|
-
selectValues: ["separate", "disabled"],
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function createWhatsAppWorkAccountConfig(
|
|
72
|
-
params: {
|
|
73
|
-
defaultAccount?: string;
|
|
74
|
-
} = {},
|
|
75
|
-
): WhatsAppSetupConfig {
|
|
76
|
-
return {
|
|
77
|
-
channels: {
|
|
78
|
-
whatsapp: {
|
|
79
|
-
...(params.defaultAccount ? { defaultAccount: params.defaultAccount } : {}),
|
|
80
|
-
dmPolicy: "disabled",
|
|
81
|
-
allowFrom: [WHATSAPP_OWNER_NUMBER],
|
|
82
|
-
accounts: {
|
|
83
|
-
work: {
|
|
84
|
-
authDir: "/tmp/work",
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function createWhatsAppAllowlistModeInput(): {
|
|
93
|
-
selectValues: string[];
|
|
94
|
-
textValues: string[];
|
|
95
|
-
} {
|
|
96
|
-
return {
|
|
97
|
-
selectValues: ["separate", "allowlist", "list"],
|
|
98
|
-
textValues: [`${WHATSAPP_OWNER_NUMBER_INPUT}, ${WHATSAPP_OWNER_NUMBER}, *`],
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function expectWhatsAppDmAccess(
|
|
103
|
-
cfg: WhatsAppSetupConfig,
|
|
104
|
-
expected: {
|
|
105
|
-
selfChatMode: boolean;
|
|
106
|
-
dmPolicy: string;
|
|
107
|
-
allowFrom?: string[];
|
|
108
|
-
},
|
|
109
|
-
): void {
|
|
110
|
-
expect(cfg.channels?.whatsapp?.selfChatMode).toBe(expected.selfChatMode);
|
|
111
|
-
expect(cfg.channels?.whatsapp?.dmPolicy).toBe(expected.dmPolicy);
|
|
112
|
-
if ("allowFrom" in expected) {
|
|
113
|
-
expect(cfg.channels?.whatsapp?.allowFrom).toEqual(expected.allowFrom);
|
|
114
|
-
} else {
|
|
115
|
-
expect(cfg.channels?.whatsapp?.allowFrom).toBeUndefined();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function expectWhatsAppWorkAccountOpenAccess(cfg: WhatsAppSetupConfig): void {
|
|
120
|
-
expect(cfg.channels?.whatsapp?.dmPolicy).toBe("disabled");
|
|
121
|
-
expect(cfg.channels?.whatsapp?.allowFrom).toEqual([WHATSAPP_OWNER_NUMBER]);
|
|
122
|
-
expect(cfg.channels?.whatsapp?.accounts?.work?.dmPolicy).toBe("open");
|
|
123
|
-
expect(cfg.channels?.whatsapp?.accounts?.work?.allowFrom).toEqual(["*", WHATSAPP_OWNER_NUMBER]);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function expectWhatsAppOwnerNumberPrompt(harness: WizardPromptHarness): void {
|
|
127
|
-
expect(harness.text).toHaveBeenCalledWith(
|
|
128
|
-
expect.objectContaining({
|
|
129
|
-
message: "Your personal WhatsApp number (the phone you will message from)",
|
|
130
|
-
}),
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export function expectWhatsAppOwnerAllowlistSetup(
|
|
135
|
-
cfg: WhatsAppSetupConfig,
|
|
136
|
-
harness: WizardPromptHarness,
|
|
137
|
-
): void {
|
|
138
|
-
expectWhatsAppDmAccess(cfg, {
|
|
139
|
-
selfChatMode: true,
|
|
140
|
-
dmPolicy: "allowlist",
|
|
141
|
-
allowFrom: [WHATSAPP_OWNER_NUMBER],
|
|
142
|
-
});
|
|
143
|
-
expectWhatsAppOwnerNumberPrompt(harness);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function expectWhatsAppSeparatePhoneDisabledSetup(
|
|
147
|
-
cfg: WhatsAppSetupConfig,
|
|
148
|
-
harness: WizardPromptHarness,
|
|
149
|
-
): void {
|
|
150
|
-
expectWhatsAppDmAccess(cfg, {
|
|
151
|
-
selfChatMode: false,
|
|
152
|
-
dmPolicy: "disabled",
|
|
153
|
-
});
|
|
154
|
-
expect(harness.text).not.toHaveBeenCalled();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function expectWhatsAppAllowlistModeSetup(cfg: WhatsAppSetupConfig): void {
|
|
158
|
-
expectWhatsAppDmAccess(cfg, {
|
|
159
|
-
selfChatMode: false,
|
|
160
|
-
dmPolicy: "allowlist",
|
|
161
|
-
allowFrom: [WHATSAPP_OWNER_NUMBER, "*"],
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function expectWhatsAppPersonalPhoneSetup(cfg: WhatsAppSetupConfig): void {
|
|
166
|
-
expectWhatsAppDmAccess(cfg, {
|
|
167
|
-
selfChatMode: true,
|
|
168
|
-
dmPolicy: "allowlist",
|
|
169
|
-
allowFrom: [WHATSAPP_PERSONAL_NUMBER],
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export function expectWhatsAppOpenPolicySetup(
|
|
174
|
-
cfg: WhatsAppSetupConfig,
|
|
175
|
-
harness: WizardPromptHarness,
|
|
176
|
-
): void {
|
|
177
|
-
expectWhatsAppDmAccess(cfg, {
|
|
178
|
-
selfChatMode: false,
|
|
179
|
-
dmPolicy: "open",
|
|
180
|
-
allowFrom: ["*", WHATSAPP_OWNER_NUMBER],
|
|
181
|
-
});
|
|
182
|
-
expect(harness.select).toHaveBeenCalledTimes(2);
|
|
183
|
-
expect(harness.text).not.toHaveBeenCalled();
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export function expectNoWhatsAppLoginFollowup(harness: WizardPromptHarness): void {
|
|
187
|
-
expect(harness.note).not.toHaveBeenCalledWith(
|
|
188
|
-
expect.stringContaining("openclaw channels login"),
|
|
189
|
-
WHATSAPP_LOGIN_NOTE_TITLE,
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export function expectWhatsAppLoginFollowup(harness: WizardPromptHarness): void {
|
|
194
|
-
expect(harness.note).toHaveBeenCalledWith(
|
|
195
|
-
expect.stringContaining("openclaw channels login"),
|
|
196
|
-
WHATSAPP_LOGIN_NOTE_TITLE,
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export function expectWhatsAppWorkAccountAccessNote(harness: WizardPromptHarness): void {
|
|
201
|
-
expect(harness.note).toHaveBeenCalledWith(
|
|
202
|
-
expect.stringContaining(
|
|
203
|
-
"`channels.whatsapp.accounts.work.dmPolicy` + `channels.whatsapp.accounts.work.allowFrom`",
|
|
204
|
-
),
|
|
205
|
-
WHATSAPP_ACCESS_NOTE_TITLE,
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export function expectWhatsAppDefaultAccountAccessNote(harness: WizardPromptHarness): void {
|
|
210
|
-
expect(harness.note).toHaveBeenCalledWith(
|
|
211
|
-
expect.stringContaining(
|
|
212
|
-
"`channels.whatsapp.accounts.default.dmPolicy` + `channels.whatsapp.accounts.default.allowFrom`",
|
|
213
|
-
),
|
|
214
|
-
WHATSAPP_ACCESS_NOTE_TITLE,
|
|
215
|
-
);
|
|
216
|
-
}
|