EvanVerificationService

Source bcc
Reference Implementation Verifications Overview DApp
Wrapper for api-blockchain-core library

Blockchain-core wrapper service to handle users verifications.

  • ensRootOwner - string: owner of the evan root verification domain (= 0x4a6723fC5a926FA150bAeAf04bfD673B056Ba83D)

getQueueId

bcService.getQueueId(dispatcher, id);

Return the queue id to watch for any action for a demo.

Parameters

  1. dispatcher - string: optional name of the dispatcher (default is * = watch everything)
  2. id - string: optional id for the queue id

Returns

QueueId: The handling queue identifier.

Example

this.queueWatcher = await this.queue.onQueueFinish(
  this.verificationService.getQueueId(),
  async (reload, results) => {
    this.loadVerifications();
  }
);

isVerificationLoading

bcService.getCisVerificationLoading(verification);

Checks if a verification is current loading (issuing, accepting, deleting).

Parameters

  1. verification - any: the verification object that should be checked (loaded vom api-blockchain-core / getVerifications function)

Returns

boolean: True if verificationn loading, False otherwise.

Example

// check if anything is loading for the verification (accept, issue, delete)
verification.loading = this.isVerificationLoading(verification);

getVerifications

bcServicegetVerifications(subject, topic, isIdentity);

Get all the verifications for a specific subject, including all nested verifications for a deep integrity check.

Parameters

  1. subject - string: subject to load the verifications for.
  2. topic - string: topic to load the verifications for.
  3. isIdentity - boolean: optional indicates if the subject is already a identity

Returns

Promise returns Array<any>: all the verifications with the following properties.

Example

Reference Implementation: Verifications Overview DApp

this.verificationsService.getVerifications('0x123...', '/test')

// will return

{
  // creator of the verification
  issuer: '0x1813587e095cDdfd174DdB595372Cb738AA2753A',
  // topic of the verification
  name: '/company/b-s-s/employee/swo',
  // -1: Not issued => no verification was issued
  // 0: Issued => status = 0, warning.length > 0
  // 1: Confirmed => issued by both, self issued state is 2, values match
  status: 2,
  // verification for account id / contract id
  subject: subject,
  // ???
  value: '',
  // ???
  uri: '',
  // ???
  signature: ''
  // icon for cards display
  icon: 'icon to display',
  // if the verification was rejected, a reject reason could be applied
  rejectReason: '' || { },
  // subjec type
  subjectType: 'account' || 'contract',
  // if it's a contract, it can be an contract
  subjectOwner: 'account' || 'contract',
  // warnings
  [
    'issued', // verification.status === 0
    'missing', // no verification exists
    'expired', // is the verification expired?
    'rejected', // rejected
    'selfIssued' // issuer === subject
    'invalid', // signature is manipulated
    'parentMissing',  // parent path does not exist
    'parentUntrusted',  // root path (/) is not issued by evan
    'notEnsRootOwner', // invalid ens root owner when check topic is
    'noIdentity', // checked subject has no identity
  ],
  parents: [ ... ],
  parentComputed: [ ... ]
}

computeVerifications

bcService.computeVerifications(topic, verifications);

Takes an array of verifications and combines all the states for one quick view.

Parameters

  1. topic - string: topic of all the verifications
  2. verifications - Array<any>: all verifications of a specific topic

Returns

any: computed verification including latest creationDate, combined color, displayName

Example

// load all sub verifications
verification.parents = await this.getVerifications(verification.issuerAccount, verification.parent || '/', false);

// use all the parents and create a viewable computed tree
verification.tree = this
  .flatVerificationsToLevels(verification)
  .map(level => this.computeVerifications(level.name, level.verifications));

// returns =>
//   const computed:any = {
//     verifications: verifications,
//     creationDate: null,
//     displayName: topic.split('/').pop() || 'evan',
//     loading: verifications.filter(verification => verification.loading).length > 0,
//     name: topic,
//     status: -1,
//     subjects: [ ],
//     warnings: [ ],
//   }

getProfileActiveVerifications

bcService.getCurrentBugetProfileActiveVerifications(includeSaving);

Load the list of verification topics, that are configured as active for the current profile

Parameters

  1. includeSaving - boolean: should the saving flag returned?

Returns

Promise returns any: Array of topics or object including verifications array and saving property

Example

Reference Implementation: Profile Verifications Component

this.verificationsService.getProfileActiveVerifications() // => returns [ '/test/twi' ]