src/protocol/signers.js
function createSigner(signatureScheme, signatureKey) {
  if (signatureKey) {
    // Create a SHA256-based signer that generates and validates signatures
    signatureScheme = signatureScheme || 'sha256';
    if (signatureScheme.indexOf('hmac-') === 0) {
      signatureScheme = signatureScheme.substr(5);
    }
    return {
      sign: function(values) {
        return computeSignature(values, signatureScheme, signatureKey);
      },
      validate: function(signature, values) {
        return signature === computeSignature(values, signatureScheme, signatureKey);
      }
    }
  }
  else {
    // Create a no-op signer
    return {
      sign: function() { return ''; },
      validate: function() { return true; }
    }
  }
}
function createSigner(signatureScheme, signatureKey) {
  if (signatureKey) {
    // Create a SHA256-based signer that generates and validates signatures
    signatureScheme = signatureScheme || 'sha256';
    if (signatureScheme.indexOf('hmac-') === 0) {
      signatureScheme = signatureScheme.substr(5);
    }
    return {
      sign: function(values) {
        return computeSignature(values, signatureScheme, signatureKey);
      },
      validate: function(signature, values) {
        return signature === computeSignature(values, signatureScheme, signatureKey);
      }
    }
  }
  else {
    // Create a no-op signer
    return {
      sign: function() { return ''; },
      validate: function() { return true; }
    }
  }
}
function createSigner ( signatureScheme , signatureKey ) { if ( signatureKey ) { // Create a SHA256-based signer that generates and validates signatures signatureScheme = signatureScheme || 'sha256' ; if ( signatureScheme . indexOf ( 'hmac-' ) === 0 ) { signatureScheme = signatureScheme . substr ( 5 ) ; } return { sign : function ( values ) { return computeSignature ( values , signatureScheme , signatureKey ) ; } , validate : function ( signature , values ) { return signature === computeSignature ( values , signatureScheme , signatureKey ) ; } } } else { // Create a no-op signer return { sign : function ( ) { return '' ; } , validate : function ( ) { return true ; } } } }
Creates a signer given the specified schema and key.
Creates a signer given the specified schema and key .