Skip to content

DelegationChain

Defined in: packages/identity/src/identity/delegation.ts:137

A chain of delegations. This is JSON Serializable. This is the object to serialize and pass to a DelegationIdentity. It does not keep any private keys.

protected new DelegationChain(delegations, publicKey): DelegationChain

Defined in: packages/identity/src/identity/delegation.ts:231

SignedDelegation[]

DerEncodedPublicKey

DelegationChain

readonly delegations: SignedDelegation[]

Defined in: packages/identity/src/identity/delegation.ts:232


readonly publicKey: DerEncodedPublicKey

Defined in: packages/identity/src/identity/delegation.ts:233

toJSON(): JsonnableDelegationChain

Defined in: packages/identity/src/identity/delegation.ts:236

JsonnableDelegationChain


static create(from, to, expiration, options): Promise<DelegationChain>

Defined in: packages/identity/src/identity/delegation.ts:167

Create a delegation chain between two (or more) keys. By default, the expiration time will be very short (15 minutes).

To build a chain of more than 2 identities, this function needs to be called multiple times, passing the previous delegation chain into the options argument. For example:

SignIdentity

The identity that will delegate.

PublicKey

The identity that gets delegated. It can now sign messages as if it was the identity above.

Date = ...

The length the delegation is valid. By default, 15 minutes from calling this function.

A set of options for this delegation. expiration and previous

DelegationChain

Another DelegationChain that this chain should start with.

Principal[]

targets that scope the delegation (e.g. Canister Principals)

Promise<DelegationChain>

const rootKey = createKey();
const middleKey = createKey();
const bottomeKey = createKey();
const rootToMiddle = await DelegationChain.create(
root, middle.getPublicKey(), Date.parse('2100-01-01'),
);
const middleToBottom = await DelegationChain.create(
middle, bottom.getPublicKey(), Date.parse('2100-01-01'), { previous: rootToMiddle },
);
// We can now use a delegation identity that uses the delegation above:
const identity = DelegationIdentity.fromDelegation(bottomKey, middleToBottom);

static fromDelegations(delegations, publicKey): DelegationChain

Defined in: packages/identity/src/identity/delegation.ts:224

Creates a DelegationChain object from a list of delegations and a DER-encoded public key.

SignedDelegation[]

The list of delegations.

DerEncodedPublicKey

The DER-encoded public key of the key-pair signing the first delegation.

DelegationChain


static fromJSON(json): DelegationChain

Defined in: packages/identity/src/identity/delegation.ts:187

Creates a DelegationChain object from a JSON string.

The JSON string to parse.

string | JsonnableDelegationChain

DelegationChain