Keyring

@keyring/sdk/testing

A stub control plane, a checksum-valid test-key minter and a pre-filled store, for testing an integration with no control plane at all.

Generated from packages/sdk/src/testing.ts and the declarations it exports, by packages/docs/tools/generate-reference.mjs. Every signature below is printed from the source; the prose is the source's own doc comment.

Not publicly available yet

@keyring/sdk is not on the npm registry, and the repository it builds from is private today, so it installs only from a tarball someone with repository access builds. Start in 5 minutes has the build, the overrides block and how to ask for access.

Imported as @keyring/sdk/testing, beside the package's main entry point.

Functions

hashKeyOf

export function hashKeyOf(raw: string): string;

mintTestKey

A real, checksum-valid key and the policy record a snapshot would carry.

export function mintTestKey(overrides: Partial<KeyPolicy> & {
    env?: Environment;
} = {}): {
    raw: string;
    policy: KeyPolicy;
};

storeWith

A store whose freshness the test states outright.

export function storeWith(policies: readonly KeyPolicy[], status: {
    snapshotVersion?: number | null;
    fetchedAt?: number | null;
    source?: PolicyStoreSource;
    complete?: boolean;
} = {}): MemoryPolicyStore;

Classes

StubControlPlane

The policy feed, as the control plane serves it, small enough to drive from a test. It speaks the wire protocol @keyring/cache already implements against packages/api/src/policy/policy.controller.ts, so a test can mint a key after a node's snapshot and assert what happens when the delta lands.

export class StubControlPlane {
    snapshots: number;
    deltas: number;
    failWith: number | null;
    pageSize: number;
    readonly snapshotQueries: URLSearchParams[];
    readonly deltaQueries: URLSearchParams[];
    failHotWith: number | null;
    answerHotWith: unknown;
    rateLimitChecks: number;
    idempotencyClaims: number;
    constructor(readonly workspaceId = 'ws-1', readonly projectId = 'proj-1');
    mint(policy: KeyPolicy): void;
    revoke(policy: KeyPolicy): void;
    get version(): number;
    readonly fetch: FetchLike & ShipperFetch & ControlPlaneFetch;
}

On this page