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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”
protected
new DelegationChain(delegations
,publicKey
):DelegationChain
Defined in: packages/identity/src/identity/delegation.ts:231
Parameters
Section titled “Parameters”delegations
Section titled “delegations”publicKey
Section titled “publicKey”Returns
Section titled “Returns”DelegationChain
Properties
Section titled “Properties”delegations
Section titled “delegations”
readonly
delegations:SignedDelegation
[]
Defined in: packages/identity/src/identity/delegation.ts:232
publicKey
Section titled “publicKey”
readonly
publicKey:DerEncodedPublicKey
Defined in: packages/identity/src/identity/delegation.ts:233
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON():
JsonnableDelegationChain
Defined in: packages/identity/src/identity/delegation.ts:236
Returns
Section titled “Returns”create()
Section titled “create()”
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:
Parameters
Section titled “Parameters”The identity that will delegate.
The identity that gets delegated. It can now sign messages as if it was the identity above.
expiration
Section titled “expiration”Date
= ...
The length the delegation is valid. By default, 15 minutes from calling this function.
options
Section titled “options”A set of options for this delegation. expiration and previous
previous?
Section titled “previous?”DelegationChain
Another DelegationChain that this chain should start with.
targets?
Section titled “targets?”targets that scope the delegation (e.g. Canister Principals)
Returns
Section titled “Returns”Promise
<DelegationChain
>
Example
Section titled “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);
fromDelegations()
Section titled “fromDelegations()”
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.
Parameters
Section titled “Parameters”delegations
Section titled “delegations”The list of delegations.
publicKey
Section titled “publicKey”The DER-encoded public key of the key-pair signing the first delegation.
Returns
Section titled “Returns”DelegationChain
fromJSON()
Section titled “fromJSON()”
static
fromJSON(json
):DelegationChain
Defined in: packages/identity/src/identity/delegation.ts:187
Creates a DelegationChain object from a JSON string.
Parameters
Section titled “Parameters”The JSON string to parse.
string
| JsonnableDelegationChain
Returns
Section titled “Returns”DelegationChain