Move all Signal channel implementation files from src/signal/ to extensions/signal/src/ and replace originals with re-export shims. This continues the channel plugin migration pattern used by other extensions, keeping backward compatibility via shims while the real code lives in the extension. - Copy 32 .ts files (source + tests) to extensions/signal/src/ - Transform all relative import paths for the new location - Create 2-line re-export shims in src/signal/ for each moved file - Preserve existing extension files (channel.ts, runtime.ts, etc.) - Change tsconfig.plugin-sdk.dts.json rootDir from "src" to "." to support cross-boundary re-exports from extensions/
57 lines
1.7 KiB
TypeScript
57 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
looksLikeUuid,
|
|
resolveSignalPeerId,
|
|
resolveSignalRecipient,
|
|
resolveSignalSender,
|
|
} from "./identity.js";
|
|
|
|
describe("looksLikeUuid", () => {
|
|
it("accepts hyphenated UUIDs", () => {
|
|
expect(looksLikeUuid("123e4567-e89b-12d3-a456-426614174000")).toBe(true);
|
|
});
|
|
|
|
it("accepts compact UUIDs", () => {
|
|
expect(looksLikeUuid("123e4567e89b12d3a456426614174000")).toBe(true); // pragma: allowlist secret
|
|
});
|
|
|
|
it("accepts uuid-like hex values with letters", () => {
|
|
expect(looksLikeUuid("abcd-1234")).toBe(true);
|
|
});
|
|
|
|
it("rejects numeric ids and phone-like values", () => {
|
|
expect(looksLikeUuid("1234567890")).toBe(false);
|
|
expect(looksLikeUuid("+15555551212")).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("signal sender identity", () => {
|
|
it("prefers sourceNumber over sourceUuid", () => {
|
|
const sender = resolveSignalSender({
|
|
sourceNumber: " +15550001111 ",
|
|
sourceUuid: "123e4567-e89b-12d3-a456-426614174000",
|
|
});
|
|
expect(sender).toEqual({
|
|
kind: "phone",
|
|
raw: "+15550001111",
|
|
e164: "+15550001111",
|
|
});
|
|
});
|
|
|
|
it("uses sourceUuid when sourceNumber is missing", () => {
|
|
const sender = resolveSignalSender({
|
|
sourceUuid: "123e4567-e89b-12d3-a456-426614174000",
|
|
});
|
|
expect(sender).toEqual({
|
|
kind: "uuid",
|
|
raw: "123e4567-e89b-12d3-a456-426614174000",
|
|
});
|
|
});
|
|
|
|
it("maps uuid senders to recipient and peer ids", () => {
|
|
const sender = { kind: "uuid", raw: "123e4567-e89b-12d3-a456-426614174000" } as const;
|
|
expect(resolveSignalRecipient(sender)).toBe("123e4567-e89b-12d3-a456-426614174000");
|
|
expect(resolveSignalPeerId(sender)).toBe("uuid:123e4567-e89b-12d3-a456-426614174000");
|
|
});
|
|
});
|