did-btcr2-js

ADR 033: Rename @did-btcr2/kms to @did-btcr2/key-manager; Kms to LocalKeyManager; KmsSigner to KeyManagerSigner

Status: Accepted

Date: 2026-05-18

Branch / PR: refactor/kms-signing-flow

References: ADR 007, ADR 012

Context

The package previously named @did-btcr2/kms (established by ADR 007 on 2025-10-28) provides the KeyManager interface, a default in-process implementation, and a Signer adapter that wraps any KeyManager. Three concrete naming choices in that package conflate “interface contract” with “this particular reference implementation”:

The keypair package already establishes the right naming pattern: Signer is the contract; LocalSigner says “in-process implementation.” The kms package broke that pattern by calling its in-process implementation Kms.

Options considered

  1. Keep all names. Status quo. Preserves prior ADR-007/012 surface but cements the overclaim.

  2. Rename only the classes; keep the package name. Cleaner classes but the package label still over-promises.

  3. Rename the classes AND the package. Surfaces the long-term direction (pluggable external KMS adapters) at every layer.

  4. Rename to @did-btcr2/keystore. Accurate (“a store of keys”) but loses the connection to “key management” which the interface covers (lifecycle, IDs, watch-only, active-key state). keystore reads as storage-only.

Decision

Option 3. Three renames land together:

Before After
@did-btcr2/kms (package) @did-btcr2/key-manager
Kms (class) LocalKeyManager
KmsSigner (class) KeyManagerSigner

The interface name KeyManager (and KeyManagerError in common) was already correct and is preserved.

Internal package category labels are unaffected:

The renamed classes and file paths:

Consequences

Positive

Negative

Forward direction

@did-btcr2/api is the intended public entry point for did:btcr2 consumers. ADR-006 (api package boundary) established the facade. This rename clarifies the next step:

  1. Today: LocalKeyManager ships with the package as the default. new KeyManagerApi() constructs one automatically. new KeyManagerApi(myCustomKm) accepts any KeyManager implementation.

  2. Near-term: users implement adapters against AWS KMS / GCP KMS / Azure Key Vault / HashiCorp Vault Transit by satisfying the KeyManager interface. The adapter handles network dispatch, IAM-style permissions, audit emission, etc. The api package and Beacon broadcast paths see only the abstract Signer view via KeyManagerSigner.

  3. Encouragement: documentation will explicitly recommend external KMS adapters for production. LocalKeyManager is positioned as a dev / test / reference implementation, not a production target.

This direction does not require changes to the KeyManager interface itself; it requires the naming to stop implying that the bundled implementation is the intended endpoint. ADR-033 completes that re-framing.

Files updated

Lockfile is regenerated by pnpm install.

References