Skip to main content

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 ParameterDefault 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

ParameterTypeDescription
apolloApollo-
extraMethods?Extrastuple 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

ParameterType
methodM
optsCreatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>

Returns

Promise<DID>

Implementation of

Castor.createDID


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

ParameterType
methodM
optsDeactivatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>

Returns

Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>

Implementation of

Castor.deactivateDID


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

ParameterType
methodM
optsPublishPayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>

Returns

Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>

Implementation of

Castor.publishDID


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

ParameterTypeDescription
didstrstring | 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

Castor.resolveDID


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

ParameterType
methodM
optsUpdatePayloadOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>

Returns

Promise<MetadataOf<MethodMapOf<readonly [PrismDIDMethod, PeerDIDMethod, Extras]>[M]>>

Implementation of

Castor.updateDID


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

ParameterTypeDescription
didDIDthe signer's DID
challengeUint8Arraythe original data that was signed
signatureUint8Arraythe signature bytes to verify

Returns

Promise<boolean>

true if any verification method on the DID validates the signature

Implementation of

Castor.verifySignature