lib/auth.js
// matches the event. 'event' is assumed to be an AWS Lambda Proxy Event
matches the event. 'event' is assumed to be an AWS Lambda Proxy Event
matches the event . ' event ' is assumed to be an AWS Lambda Proxy Event
function auth(event, credentials, options) {
  var options = options || { }
  var skew = options.skew || DEFAULT_SKEW_TOLERANCE
  if (!isAWS4Signed(event)) {
    throw new Error("InvalidSignature")
  }
  if (isRequestTimeTooSkewed(event, skew)) {
    throw new Error("RequestTimeTooSkewed")
  }
  var clientSignature = util.getAWSV4SignatureFromHeader(event.headers['Authorization']) 
  if (options.verbose) console.log("CLIENT", event, clientSignature)
  var serverEvent = sign(event, credentials)
  var serverSignature = serverEvent.signature
  if (options.verbose) console.log("SERVER", serverSignature, serverEvent)
  if (clientSignature != serverSignature) {
    throw new Error("SignatureDoesNotMatch")
  }
  return clientSignature
}
function auth ( event , credentials , options ) { var options = options || { } var skew = options . skew || DEFAULT_SKEW_TOLERANCE if ( ! isAWS4Signed ( event ) ) { throw new Error ( "InvalidSignature" ) } if ( isRequestTimeTooSkewed ( event , skew ) ) { throw new Error ( "RequestTimeTooSkewed" ) } var clientSignature = util . getAWSV4SignatureFromHeader ( event . headers [ 'Authorization' ] ) if ( options . verbose ) console . log ( "CLIENT" , event , clientSignature ) var serverEvent = sign ( event , credentials ) var serverSignature = serverEvent . signature if ( options . verbose ) console . log ( "SERVER" , serverSignature , serverEvent ) if ( clientSignature != serverSignature ) { throw new Error ( "SignatureDoesNotMatch" ) } return clientSignature }
matches the event.
matches the event .