Open History to see the last commit
1import * as PlatformNodeCrypto from "@effect/platform-node/NodeCrypto";
2import { describe, expect, it } from "@effect/vitest";
3import * as Effect from "effect/Effect";
4
5import { desktopReadinessProof, isValidDesktopReadinessProof } from "./desktopReadinessProof.ts";
6
7describe("desktop readiness proof", () => {
8 it.effect("is valid only for the launch secret and challenge it was derived from", () =>
9 Effect.gen(function* () {
10 const proof = yield* desktopReadinessProof("launch-secret", "challenge-1");
11
12 expect(yield* isValidDesktopReadinessProof("launch-secret", "challenge-1", proof)).toBe(true);
13 expect(
14 yield* isValidDesktopReadinessProof("launch-secret", "challenge-1", `${proof}\n`),
15 ).toBe(true);
16 expect(yield* isValidDesktopReadinessProof("launch-secret", "challenge-2", proof)).toBe(
17 false,
18 );
19 expect(yield* isValidDesktopReadinessProof("other-secret", "challenge-1", proof)).toBe(false);
20 expect(yield* isValidDesktopReadinessProof("launch-secret", "challenge-1", "{}")).toBe(false);
21 }).pipe(Effect.provide(PlatformNodeCrypto.layerMac)),
22 );
23});