lib/a2p3.js
function createAgentRequest ( config, vault, params ) {
  if (!vault || !config || !params)
    throw new Error('"config", "vault", "params" are required) ')
  if (!params.returnURL && !params.callbackURL)
    throw new Error('params must have either "returnURL" or "callbackURL"')
  config = _init( config, vault )
  var credentials = vault[ config.ix ].latest
  var details =
    { header:
      { typ: 'JWS'
      , alg: ALG_REQUEST
      }
    , payload:
      { 'iss': config.appID
      , 'aud': config.ix
      , 'iat': jwt.iat()
      , 'request.a2p3.org':
        { 'resources': params.resources || []
        , 'auth': config.auth
        , 'ix': 'a2p3.net'
        }
      }
    , credentials: credentials
    }
  if ( params.returnURL )
    details.payload['request.a2p3.org'].returnURL = params.returnURL
  else if ( params.callbackURL )
    details.payload['request.a2p3.org'].callbackURL = params.callbackURL
  this.agentRequest = jwt.jws( details )
  return this.agentRequest
}
function createAgentRequest ( config, vault, params ) {
  if (!vault || !config || !params)
    throw new Error('"config", "vault", "params" are required) ')
  if (!params.returnURL && !params.callbackURL)
    throw new Error('params must have either "returnURL" or "callbackURL"')
  config = _init( config, vault )
  var credentials = vault[ config.ix ].latest
  var details =
    { header:
      { typ: 'JWS'
      , alg: ALG_REQUEST
      }
    , payload:
      { 'iss': config.appID
      , 'aud': config.ix
      , 'iat': jwt.iat()
      , 'request.a2p3.org':
        { 'resources': params.resources || []
        , 'auth': config.auth
        , 'ix': 'a2p3.net'
        }
      }
    , credentials: credentials
    }
  if ( params.returnURL )
    details.payload['request.a2p3.org'].returnURL = params.returnURL
  else if ( params.callbackURL )
    details.payload['request.a2p3.org'].callbackURL = params.callbackURL
  this.agentRequest = jwt.jws( details )
  return this.agentRequest
}
function createAgentRequest ( config , vault , params ) { if ( ! vault || ! config || ! params ) throw new Error ( '"config", "vault", "params" are required) ' ) if ( ! params . returnURL && ! params . callbackURL ) throw new Error ( 'params must have either "returnURL" or "callbackURL"' ) config = _init ( config , vault ) var credentials = vault [ config . ix ] . latest var details = { header : { typ : 'JWS' , alg : ALG_REQUEST } , payload : { 'iss' : config . appID , 'aud' : config . ix , 'iat' : jwt . iat ( ) , 'request.a2p3.org' : { 'resources' : params . resources || [ ] , 'auth' : config . auth , 'ix' : 'a2p3.net' } } , credentials : credentials } if ( params . returnURL ) details . payload [ 'request.a2p3.org' ] . returnURL = params . returnURL else if ( params . callbackURL ) details . payload [ 'request.a2p3.org' ] . callbackURL = params . callbackURL this . agentRequest = jwt . jws ( details ) return this . agentRequest }
create an Agent Request
create an Agent Request