index.js
function _normalizeProofs(proofs) {
  // Validate proofs arg
  if (!_isArray(proofs)) throw new Error('proofs arg must be an Array')
  if (_isEmpty(proofs)) throw new Error('proofs arg must be a non-empty Array')

  // If any entry in the proofs Array is an Object, process
  // it assuming the same form as the output of getProofs().
  return _map(proofs, proof => {
    if (_isObject(proof) && _has(proof, 'proof') && _isString(proof.proof)) {
      // Probably result of `submitProofs()` call. Extract proof String
      return proof.proof
    } else if (
      _isObject(proof) &&
      _has(proof, 'type') &&
      proof.type === 'Chainpoint'
    ) {
      // Probably a JS Object Proof
      return proof
    } else if (_isString(proof) && (isJSON(proof) || isBase64(proof))) {
      // Probably a JSON String or Base64 encoded binary proof
      return proof
    } else {
      throw new Error(
        'proofs arg Array has elements that are not Objects or Strings'
      )
    }
  })
}
function _normalizeProofs(proofs) {
  // Validate proofs arg
  if (!_isArray(proofs)) throw new Error('proofs arg must be an Array')
  if (_isEmpty(proofs)) throw new Error('proofs arg must be a non-empty Array')

  // If any entry in the proofs Array is an Object, process
  // it assuming the same form as the output of getProofs().
  return _map(proofs, proof => {
    if (_isObject(proof) && _has(proof, 'proof') && _isString(proof.proof)) {
      // Probably result of `submitProofs()` call. Extract proof String
      return proof.proof
    } else if (
      _isObject(proof) &&
      _has(proof, 'type') &&
      proof.type === 'Chainpoint'
    ) {
      // Probably a JS Object Proof
      return proof
    } else if (_isString(proof) && (isJSON(proof) || isBase64(proof))) {
      // Probably a JSON String or Base64 encoded binary proof
      return proof
    } else {
      throw new Error(
        'proofs arg Array has elements that are not Objects or Strings'
      )
    }
  })
}
function _normalizeProofs ( proofs ) { // Validate proofs arg if ( ! _isArray ( proofs ) ) throw new Error ( 'proofs arg must be an Array' ) if ( _isEmpty ( proofs ) ) throw new Error ( 'proofs arg must be a non-empty Array' ) // If any entry in the proofs Array is an Object, process // it assuming the same form as the output of getProofs(). return _map ( proofs , proof => { if ( _isObject ( proof ) && _has ( proof , 'proof' ) && _isString ( proof . proof ) ) { // Probably result of `submitProofs()` call. Extract proof String return proof . proof } else if ( _isObject ( proof ) && _has ( proof , 'type' ) && proof . type === 'Chainpoint' ) { // Probably a JS Object Proof return proof } else if ( _isString ( proof ) && ( isJSON ( proof ) || isBase64 ( proof ) ) ) { // Probably a JSON String or Base64 encoded binary proof return proof } else { throw new Error ( 'proofs arg Array has elements that are not Objects or Strings' ) } } ) }
validate and normalize proofs for actions such as parsing
@param {Array} proofs - An Array of String, or Object proofs from getProofs(), to be verified. Proofs can be in any of the supported JSON-LD or Binary formats.
@return {Array<Object>} - An Array of Objects, one for each proof submitted.
validate and normalize proofs for actions such as parsing