@keyring-dev/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.@keyring-dev/sdk is on npm under the MIT license: npm install @keyring-dev/sdk, on Node 22 or later. Questions: hello@keyringdev.com.Imported as @keyring-dev/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 same wire protocol @keyring-dev/cache implements
against the real control plane, 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;
}