@openclaw/bluebubbles 2026.2.14 → 2026.2.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/src/send.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { OpenClawConfig } from "openclaw/plugin-sdk";
2
1
  import crypto from "node:crypto";
2
+ import type { OpenClawConfig } from "openclaw/plugin-sdk";
3
3
  import { stripMarkdown } from "openclaw/plugin-sdk";
4
4
  import { resolveBlueBubblesAccount } from "./accounts.js";
5
5
  import { getCachedBlueBubblesPrivateApiStatus } from "./probe.js";
package/src/targets.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ isAllowedParsedChatSender,
2
3
  parseChatAllowTargetPrefixes,
3
4
  parseChatTargetPrefixesOrThrow,
4
5
  resolveServicePrefixedAllowTarget,
@@ -329,43 +330,15 @@ export function isAllowedBlueBubblesSender(params: {
329
330
  chatGuid?: string | null;
330
331
  chatIdentifier?: string | null;
331
332
  }): boolean {
332
- const allowFrom = params.allowFrom.map((entry) => String(entry).trim());
333
- if (allowFrom.length === 0) {
334
- return true;
335
- }
336
- if (allowFrom.includes("*")) {
337
- return true;
338
- }
339
-
340
- const senderNormalized = normalizeBlueBubblesHandle(params.sender);
341
- const chatId = params.chatId ?? undefined;
342
- const chatGuid = params.chatGuid?.trim();
343
- const chatIdentifier = params.chatIdentifier?.trim();
344
-
345
- for (const entry of allowFrom) {
346
- if (!entry) {
347
- continue;
348
- }
349
- const parsed = parseBlueBubblesAllowTarget(entry);
350
- if (parsed.kind === "chat_id" && chatId !== undefined) {
351
- if (parsed.chatId === chatId) {
352
- return true;
353
- }
354
- } else if (parsed.kind === "chat_guid" && chatGuid) {
355
- if (parsed.chatGuid === chatGuid) {
356
- return true;
357
- }
358
- } else if (parsed.kind === "chat_identifier" && chatIdentifier) {
359
- if (parsed.chatIdentifier === chatIdentifier) {
360
- return true;
361
- }
362
- } else if (parsed.kind === "handle" && senderNormalized) {
363
- if (parsed.handle === senderNormalized) {
364
- return true;
365
- }
366
- }
367
- }
368
- return false;
333
+ return isAllowedParsedChatSender({
334
+ allowFrom: params.allowFrom,
335
+ sender: params.sender,
336
+ chatId: params.chatId,
337
+ chatGuid: params.chatGuid,
338
+ chatIdentifier: params.chatIdentifier,
339
+ normalizeSender: normalizeBlueBubblesHandle,
340
+ parseAllowTarget: parseBlueBubblesAllowTarget,
341
+ });
369
342
  }
370
343
 
371
344
  export function formatBlueBubblesChatTarget(params: {
@@ -0,0 +1,50 @@
1
+ import type { Mock } from "vitest";
2
+ import { afterEach, beforeEach, vi } from "vitest";
3
+
4
+ export function resolveBlueBubblesAccountFromConfig(params: {
5
+ cfg?: { channels?: { bluebubbles?: Record<string, unknown> } };
6
+ accountId?: string;
7
+ }) {
8
+ const config = params.cfg?.channels?.bluebubbles ?? {};
9
+ return {
10
+ accountId: params.accountId ?? "default",
11
+ enabled: config.enabled !== false,
12
+ configured: Boolean(config.serverUrl && config.password),
13
+ config,
14
+ };
15
+ }
16
+
17
+ export function createBlueBubblesAccountsMockModule() {
18
+ return {
19
+ resolveBlueBubblesAccount: vi.fn(resolveBlueBubblesAccountFromConfig),
20
+ };
21
+ }
22
+
23
+ type BlueBubblesProbeMockModule = {
24
+ getCachedBlueBubblesPrivateApiStatus: Mock<() => boolean | null>;
25
+ };
26
+
27
+ export function createBlueBubblesProbeMockModule(): BlueBubblesProbeMockModule {
28
+ return {
29
+ getCachedBlueBubblesPrivateApiStatus: vi.fn().mockReturnValue(null),
30
+ };
31
+ }
32
+
33
+ export function installBlueBubblesFetchTestHooks(params: {
34
+ mockFetch: ReturnType<typeof vi.fn>;
35
+ privateApiStatusMock: {
36
+ mockReset: () => unknown;
37
+ mockReturnValue: (value: boolean | null) => unknown;
38
+ };
39
+ }) {
40
+ beforeEach(() => {
41
+ vi.stubGlobal("fetch", params.mockFetch);
42
+ params.mockFetch.mockReset();
43
+ params.privateApiStatusMock.mockReset();
44
+ params.privateApiStatusMock.mockReturnValue(null);
45
+ });
46
+
47
+ afterEach(() => {
48
+ vi.unstubAllGlobals();
49
+ });
50
+ }
@@ -0,0 +1,11 @@
1
+ import { vi } from "vitest";
2
+
3
+ vi.mock("./accounts.js", async () => {
4
+ const { createBlueBubblesAccountsMockModule } = await import("./test-harness.js");
5
+ return createBlueBubblesAccountsMockModule();
6
+ });
7
+
8
+ vi.mock("./probe.js", async () => {
9
+ const { createBlueBubblesProbeMockModule } = await import("./test-harness.js");
10
+ return createBlueBubblesProbeMockModule();
11
+ });