Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

  • DelegationChain

Index

Constructors

Properties

delegations: SignedDelegation[]
publicKey: DerEncodedPublicKey

Methods

  • toJSON(): JsonnableDelegationChain
  • create(from: SignIdentity, to: PublicKey, expiration?: Date, options?: { previous?: DelegationChain; targets?: Principal[] }): Promise<DelegationChain>
  • 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:

    example

    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);

    Parameters

    • from: SignIdentity

      The identity that will delegate.

    • to: PublicKey

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

    • expiration: Date = ...

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

    • options: { previous?: DelegationChain; targets?: Principal[] } = {}

      A set of options for this delegation. expiration and previous

      • Optional previous?: DelegationChain

        Another DelegationChain that this chain should start with.

      • Optional targets?: Principal[]

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

    Returns Promise<DelegationChain>

Generated using TypeDoc