module import { CREDENTIAL_CONTEXT_URL } from '../../contexts' ; import { CredentialMetadata , ContextArray , CredentialSubject , ContextTypeAlias , } from '../../types' ; type ComposeCredentialParams = { subject : CredentialSubject ; metadata ? : CredentialMetadata ; context ? : ContextArray ; alias ? : ContextTypeAlias ; } ; function param params param { object } params . subject param { object } params . metadata param { object } params . context param { object } params . alias returns { object } export const generateCredential = ( { subject , metadata = { } , context = [ CREDENTIAL_CONTEXT_URL ] , alias = { } , } ) => { let contextMerged = context ; if ( Object . keys ( alias ) . length > 0 ) { contextMerged = [ ... context , alias ] ; } if ( ! metadata . type ) { metadata . type = [ 'VerifiableCredential' ] ; } const credential = { '@context' : contextMerged , ... metadata , credentialSubject : subject } ; return credential ; } ;