UNPKG

@gleif-it/did-webs-ts

Version:
16 lines (15 loc) 848 B
import { generateConditionalProofBlock } from './generateConditionalProofBlock.js'; import { generateKeyBlock } from './generateKeyBlock.js'; const hasDelegator = (delegator, delegatorDid) => delegator !== undefined && delegatorDid !== undefined; // currently this all gets tested in the generateDocument function export const generateCapabilityDelegationBlock = (delegator, delegatorDid) => hasDelegator(delegator, delegatorDid) ? capabilityDelegationBlock(delegator, delegatorDid) : {}; const capabilityDelegationBlock = (delegator, did) => ({ capabilityDelegation: delegator.keyState.k.length > 1 ? [ generateConditionalProofBlock(delegator, did), ...delegator.keyState.k.map((key) => generateKeyBlock(did, key)), ] : delegator.keyState.k.map((key) => generateKeyBlock(did, key)), });