- contracts 1.8.0 / Accounts 1.1.0: import.finish lists the subs the product relies on; Accounts checks each is held, not deleted and known to it (the count+hash failed a second move after Undo once someone had joined through Accounts). - Events: connects to the church's Accounts once the Hub lists it; moveNewPeople (demo data, people added after the move); set-demo moves demo people; e2e/sign-in-accounts.spec.ts with Accounts in memory and an e2e-only /api rewrite. test:accounts 14/14; Jest auto-connect tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
2.0 KiB
TypeScript
40 lines
2.0 KiB
TypeScript
import { identityRequestSchema, importPersonSchema, sealedValueSchema } from "../src";
|
|
import { newLinkSecret, openLinkValue, sealLinkValue } from "../src/signing";
|
|
import { sample } from "./helpers";
|
|
|
|
describe("crosscode.identity-request/1", () => {
|
|
test("a sealed value opens with the same link secret, and only that one", () => {
|
|
const secret = newLinkSecret();
|
|
const hash = "$2b$10$abcdefghijklmnopqrstuuJt1Yx0H1iLx3m6nS6m1j0fDqv3p4q5W";
|
|
const sealed = sealLinkValue(secret, hash);
|
|
expect(sealedValueSchema.safeParse(sealed).success).toBe(true);
|
|
expect(sealed).not.toContain("abcdefghij");
|
|
expect(openLinkValue(secret, sealed)).toBe(hash);
|
|
expect(() => openLinkValue(newLinkSecret(), sealed)).toThrow();
|
|
const tampered = sealed.slice(0, -2) + (sealed.endsWith("A") ? "BB" : "AA");
|
|
expect(() => openLinkValue(secret, tampered)).toThrow();
|
|
});
|
|
|
|
test("import.finish lists the subs (uuids)", () => {
|
|
const finish = sample<{ subs: string[] }>("import-finish.json");
|
|
expect(identityRequestSchema.safeParse(finish).success).toBe(true);
|
|
expect(identityRequestSchema.safeParse({ ...finish, subs: ["not-a-uuid"] }).success).toBe(false);
|
|
});
|
|
|
|
test("an unsealed password hash is refused", () => {
|
|
const person = sample<{ people: Record<string, unknown>[] }>("import-batch.json").people[0]!;
|
|
expect(importPersonSchema.safeParse(person).success).toBe(true);
|
|
expect(importPersonSchema.safeParse({ ...person, passwordHash: "$2b$10$plain" }).success).toBe(false);
|
|
});
|
|
|
|
test("a batch is at most 200 people", () => {
|
|
const batch = sample<{ people: unknown[] }>("import-batch.json");
|
|
const many = { ...batch, people: Array.from({ length: 201 }, () => batch.people[0]) };
|
|
expect(identityRequestSchema.safeParse(many).success).toBe(false);
|
|
});
|
|
|
|
test("unknown request types are refused", () => {
|
|
expect(identityRequestSchema.safeParse({ ...sample("people-ensure.json"), type: "people.delete" }).success).toBe(false);
|
|
});
|
|
});
|