Class: DidBtcr2Api ​
Defined in: packages/api/src/api.ts:24
Main DidBtcr2Api facade — the primary entry point for the SDK.
Exposes sub-facades for Bitcoin, DID Method, KeyPair, Crypto, and KeyManager operations. Created via the createApi factory.
Constructors ​
Constructor ​
new DidBtcr2Api(
config?):DidBtcr2Api
Defined in: packages/api/src/api.ts:40
Parameters ​
config? ​
Returns ​
DidBtcr2Api
Properties ​
crypto ​
readonlycrypto:CryptoApi
Defined in: packages/api/src/api.ts:26
Cryptographic operations (keypair, multikey, cryptosuite, proof).
did ​
readonlydid:DidApi
Defined in: packages/api/src/api.ts:28
DID identifier operations (encode, decode, generate, parse).
kms ​
readonlykms:KeyManagerApi
Defined in: packages/api/src/api.ts:30
Key management operations.
Accessors ​
btc ​
Get Signature ​
get btc():
BitcoinApi
Defined in: packages/api/src/api.ts:54
Bitcoin API sub-facade (lazily initialized). Only available when btc config was provided to the constructor.
Throws ​
If the instance has been disposed or no Bitcoin config was provided.
Returns ​
btcr2 ​
Get Signature ​
get btcr2():
DidMethodApi
Defined in: packages/api/src/api.ts:91
DID Method API sub-facade (lazily initialized with bitcoin + CAS wiring).
Throws ​
If the instance has been disposed.
Returns ​
cas ​
Get Signature ​
get cas():
CasApi
Defined in: packages/api/src/api.ts:73
CAS API sub-facade (lazily initialized). Only available when cas config was provided to the constructor.
Throws ​
If the instance has been disposed or no CAS config was provided.
Returns ​
disposed ​
Get Signature ​
get disposed():
boolean
Defined in: packages/api/src/api.ts:106
Whether this API instance has been disposed.
Returns ​
boolean
Methods ​
createDid() ​
createDid(
type,genesisBytes,options?):string
Defined in: packages/api/src/api.ts:117
Create a DID using either deterministic (KEY) or external (EXTERNAL) mode.
Parameters ​
type ​
"deterministic" | "external"
The creation mode.
genesisBytes ​
Public key bytes (deterministic) or document bytes (external).
options? ​
Omit<DidCreateOptions, "idType">
Creation options (idType is set for you).
Returns ​
string
The created DID identifier string.
dispose() ​
dispose():
void
Defined in: packages/api/src/api.ts:273
Release internal references. After disposal, accessing btc, btcr2, or calling top-level methods will throw.
Note: the underlying BitcoinConnection does not hold persistent connections, so this is primarily a guard against accidental reuse.
Returns ​
void
generateDid() ​
generateDid(
options?):object
Defined in: packages/api/src/api.ts:135
Generate a new DID, create the keypair, and import it into the KMS.
Parameters ​
options? ​
Optional settings.
network? ​
Network for the generated DID (default 'regtest').
setActive? ​
boolean
Whether to set the imported key as active in the KMS (default true).
Returns ​
object
The generated DID string and KMS key identifier.
did ​
did:
string
keyId ​
keyId:
string
resolveDid() ​
resolveDid(
did,options?):Promise<DidResolutionResult>
Defined in: packages/api/src/api.ts:149
Resolve a DID, automatically injecting the configured Bitcoin connection.
Parameters ​
did ​
string
The DID to resolve.
options? ​
Optional resolution options.
Returns ​
Promise<DidResolutionResult>
The resolution result.
tryResolveDid() ​
tryResolveDid(
did,options?):Promise<ResolutionResult>
Defined in: packages/api/src/api.ts:163
Resolve a DID and return a discriminated result instead of throwing. Useful when resolution failure is an expected outcome (e.g. checking whether a DID exists before creating it).
Parameters ​
did ​
string
The DID to resolve.
options? ​
Optional resolution options.
Returns ​
Promise<ResolutionResult>
A ResolutionResult with ok: true on success or ok: false with error details on failure.
updateDid() ​
updateDid(
params):Promise<SignedBTCR2Update>
Defined in: packages/api/src/api.ts:205
Update a DID document: resolve the current state, apply patches, sign, and announce. Automatically injects the configured Bitcoin connection.
If sourceDocument and sourceVersionId are both provided, resolution is skipped. Otherwise the DID is resolved first to obtain them.
Parameters ​
params ​
The update parameters.
beaconId ​
string
did ​
string
patches ​
sourceDocument? ​
sourceVersionId? ​
number
verificationMethodId ​
string
Returns ​
Promise<SignedBTCR2Update>
The signed update.