Castor<Extras>
@hyperledger/identus-sdk v8.0.0
@hyperledger/identus-sdk / overview / Castor
Class: Castor<Extras>
Defined in: packages/lib/sdk/src/castor/index.ts:49
Castor is a powerful and flexible library for working with DIDs. Whether you are building a decentralised application or a more traditional system requiring secure and private identity management, Castor provides the tools and features you need to easily create, manage, and resolve DIDs.
The optional tuple type parameter Extras carries the concrete types of
any extra DID methods passed to the constructor, so that createDID,
publishDID, updateDID and deactivateDID only accept method names
that are actually registered (defaults "prism" | "peer" plus any extras)
and infer their payload types directly from each DID method instance.
Castor
Type Parameters
| Type Parameter | Default type |
|---|---|
Extras extends readonly DIDMethodInput[] | readonly [] |
Implements
Constructors
Constructor
new Castor<
Extras>(apollo:Apollo,extraMethods?:Extras):Castor<Extras>
Defined in: packages/lib/sdk/src/castor/index.ts:74
Creates an instance of Castor as soon as a valid cryptographic interface is provided (Apollo).
Registers prism and peer DID methods by default.
Pass additional DIDMethod instances to extend or override defaults.
Parameters
| Parameter | Type | Description |
|---|---|---|
apollo | Apollo | - |
extraMethods? | Extras | tuple of custom DID methods to register |
Returns
Castor<Extras>
Methods
createDID()
createDID<
M>(method:M,opts:CreatePayloadOf<MethodMapOf<readonly [PrismDIDMethod,PeerDIDMethod,Extras]>[M]>):Promise<DID>
Defined in: packages/lib/sdk/src/castor/index.ts:79
Type Parameters
| Type Parameter |
|---|
M extends string |
Parameters
| Parameter | Type |
|---|---|
method | M |
opts | CreatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]> |
Returns
Promise<DID>
Implementation of
deactivateDID()
deactivateDID<
M>(method:M,opts:DeactivatePayloadOf<MethodMapOf<readonly [PrismDIDMethod,PeerDIDMethod,Extras]>[M]>):Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod,PeerDIDMethod,Extras]>[M]>>
Defined in: packages/lib/sdk/src/castor/index.ts:116
Type Parameters
| Type Parameter |
|---|
M extends string |
Parameters
| Parameter | Type |
|---|---|
method | M |
opts | DeactivatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]> |
Returns
Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>
Implementation of
publishDID()
publishDID<
M>(method:M,opts:PublishPayloadOf<MethodMapOf<readonly [PrismDIDMethod,PeerDIDMethod,Extras]>[M]>):Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod,PeerDIDMethod,Extras]>[M]>>
Defined in: packages/lib/sdk/src/castor/index.ts:94
Type Parameters
| Type Parameter |
|---|
M extends string |
Parameters
| Parameter | Type |
|---|---|
method | M |
opts | PublishPayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]> |
Returns
Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>
Implementation of
resolveDID()
resolveDID(
didstr:string|DID):Promise<DIDDocument>
Defined in: packages/lib/sdk/src/castor/index.ts:143
Asynchronously resolves a DID to its corresponding DID Document. This function may throw an error if
the DID is invalid or the document cannot be retrieved.
Note: only prism and peer DID methods are currently supported!
Parameters
| Parameter | Type | Description |
|---|---|---|
didstr | string | DID | - |
Returns
Promise<DIDDocument>
Example
This function asynchronously resolves a DID to its corresponding DID Document. It may throw an error if the DID is invalid or the document is unretrievable.
const didDocument = await castor.resolveDID("did:prism:123456")
Implementation of
updateDID()
updateDID<
M>(method:M,opts:UpdatePayloadOf<MethodMapOf<readonly [PrismDIDMethod,PeerDIDMethod,Extras]>[M]>):Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod,PeerDIDMethod,Extras]>[M]>>
Defined in: packages/lib/sdk/src/castor/index.ts:105
Type Parameters
| Type Parameter |
|---|
M extends string |
Parameters
| Parameter | Type |
|---|---|
method | M |
opts | UpdatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]> |
Returns
Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>
Implementation of
verifySignature()
verifySignature(
did:DID,challenge:Uint8Array,signature:Uint8Array):Promise<boolean>
Defined in: packages/lib/sdk/src/castor/index.ts:86
Verify a cryptographic signature against a DID's verification methods.
Parameters
| Parameter | Type | Description |
|---|---|---|
did | DID | the signer's DID |
challenge | Uint8Array | the original data that was signed |
signature | Uint8Array | the signature bytes to verify |
Returns
Promise<boolean>
true if any verification method on the DID validates the signature