@websign/sdk - v0.1.0
    Preparing search index...

    Interface FakeWebSign

    The installed fake: script what the person does next and inspect what your page asked.

    const fake = await installFakeWebSign();
    fake.failNext("PinLocked");
    await expect(sign(options)).rejects.toMatchObject({ code: "PinLocked" });
    expect(fake.requests.at(-1)).toMatchObject({ type: "sign", hash: "SHA-256" });
    interface FakeWebSign {
        certificates: readonly Certificate[];
        requests: readonly FakeRequest[];
        setScenario(
            scenario:
                | "ready"
                | "app-missing"
                | "app-outdated"
                | "extension-outdated"
                | "sdk-outdated",
        ): void;
        failNext(code: ErrorCode, details?: ErrorDetails): void;
        choose(certificate: CertificatePick): void;
        switchDuringNextSign(certificate: CertificatePick): void;
        verify(result: SignResult, data: Bytes): Promise<boolean>;
        uninstall(): void;
    }
    Index
    certificates: readonly Certificate[]

    The certificates, as sign() and certificates() return them.

    requests: readonly FakeRequest[]

    Every request your page made, oldest first.

    • Switches the state of the computer; the fake announces itself again, so onChange listeners fire. A page never loses its extension, so "extension-missing" is only accepted at install.

      Parameters

      • scenario: "ready" | "app-missing" | "app-outdated" | "extension-outdated" | "sdk-outdated"

      Returns void

      fake.setScenario("app-outdated");
      
    • The next certificates() or sign() fails with code, as if the app or the person ended it. Status checks are not affected.

      Parameters

      Returns void

      fake.failNext("UserCancelled");
      await expect(sign(options)).rejects.toMatchObject({ code: "UserCancelled" });
    • In the next sign(), the person switches to certificate after the first digest, so prepare runs twice and the second certificate signs.

      Parameters

      Returns void

      fake.switchDuringNextSign(1);