import { AuthenticationModel } from './AuthenticationModel' ; import { BaseIssuanceModel } from './BaseIssuanceModel' ; import { EventBindingModel } from './EventBindingModel' ; import { IssuanceAttestationsModel } from './IssuanceAttestationsModel' ; import { RefreshConfigurationModel } from './RefreshConfigurationModel' ; import { RemoteKeyModel } from './RemoteKeyModel' ; import { RulesPermissionModel } from './RulesPermissionModel' ; import { TrustedIssuerModel } from './TrustedIssuerModel' ; import { VerifiableCredentialModel } from './VerifiableCredentialModel' ; /**
 * Data Model to serialize a Rules file into
 */ export class RulesModel extends BaseIssuanceModel { param credentialIssuer param issuer param attestations param validityInterval param decryptionKeys param signingKeys param refresh param statusCheckDisabled param clientRevocationDisabled param vc param minimalDisclosure param endorsers param authentication constructor ( credentialIssuer ? , issuer ? , attestations ? , public validityInterval ? , public decryptionKeys ? , public signingKeys ? , public refresh ? , public statusCheckDisabled = false , public clientRevocationDisabled = false , public vc ? , public minimalDisclosure = false , public endorsers ? , public permissions ? , public authentication ? , public eventBindings ? ) { super ( credentialIssuer , issuer , attestations ) ; } param input populateFrom ( input ) { super . populateFrom ( input ) ; this . validityInterval = input . validityInterval ; this . statusCheckDisabled = input . statusCheckDisabled ?? false ; this . minimalDisclosure = input . minimalDisclosure ?? false ; this . endorsers = input . endorsers ; this . clientRevocationDisabled = input . clientRevocationDisabled ?? false ; const { decryptionKeys , permissions , refresh , signingKeys , vc , authentication , eventBindings } = input ; if ( authentication ) { this . authentication = AuthenticationModel . fromJSON ( authentication ) ; } if ( decryptionKeys ) { this . decryptionKeys = Array . from ( decryptionKeys , key => RulesModel . createRemoteKey ( key , this . authentication ) ) ; } if ( signingKeys ) { this . signingKeys = Array . from ( signingKeys , key => RulesModel . createRemoteKey ( key , this . authentication ) ) ; } if ( refresh ) { this . refresh = new RefreshConfigurationModel ( ) ; this . refresh . populateFrom ( refresh ) ; } if ( vc ) { this . vc = new VerifiableCredentialModel ( ) ; this . vc . populateFrom ( vc ) ; } if ( permissions ) { this . permissions = Object . entries ( < { [ endpoint ] : any ; } > permissions ) . reduce ( ( all , [ endpoint , input ] ) => ( Object . assign ( all , { [ endpoint ] : RulesPermissionModel . create ( input ) } ) ) , < { [ endpoint ] : RulesPermissionModel ; } > { } ) ; } if ( eventBindings ) { this . eventBindings = EventBindingModel . fromJSON ( eventBindings , this . authentication ) ; } } private static createRemoteKey ( key , authentication ? ) { const k = new RemoteKeyModel ( ) ; k . populateFrom ( key , authentication ) ; return k ; } }