lib/service.js
function SvcAws (requestedSvc, options) {
  if (this.constructor.name === 'Object') {
    throw new Error('Must be instantiated using new')
  } else if (this.constructor.name === 'SvcAws') {
    throw new Error('Abstract class ' +
      this.constructor.name + ' should not be instantiated')
  }
  EventEmitter.call(this)
  let self = this

  // initialize the property bag of AWS services which will be created
  this._services = {}

  let credOptions = Object.assign({}, options)

  internals.initLogger(options.isLogging)
  this.logger = internals.logger

  credOptions.logger = this.logger
  let credsManager = new Credentials(credOptions)

  credsManager.once(internals.EVENT_INITIALIZED, function (err, data) {
    if (err) {
      self.logger.warn(internals.EVENT_INITIALIZED, err)

      internals.emitAsync.call(self, internals.EVENT_INITIALIZED, err)
      return
    } else {
      self.logger.info(internals.EVENT_INITIALIZED, 'success')
    }

    if (self._services.hasOwnProperty(requestedSvc.serviceIdentifier)) {
      let serviceName = requestedSvc.serviceIdentifier
      self.logger.info('Refreshing service: ' + serviceName)
    }

    // Always instantiate the requested aws service, even if old one exists
    internals.newService.call(self, credsManager._awsConfig, requestedSvc)
  })
}
function SvcAws (requestedSvc, options) {
  if (this.constructor.name === 'Object') {
    throw new Error('Must be instantiated using new')
  } else if (this.constructor.name === 'SvcAws') {
    throw new Error('Abstract class ' +
      this.constructor.name + ' should not be instantiated')
  }
  EventEmitter.call(this)
  let self = this

  // initialize the property bag of AWS services which will be created
  this._services = {}

  let credOptions = Object.assign({}, options)

  internals.initLogger(options.isLogging)
  this.logger = internals.logger

  credOptions.logger = this.logger
  let credsManager = new Credentials(credOptions)

  credsManager.once(internals.EVENT_INITIALIZED, function (err, data) {
    if (err) {
      self.logger.warn(internals.EVENT_INITIALIZED, err)

      internals.emitAsync.call(self, internals.EVENT_INITIALIZED, err)
      return
    } else {
      self.logger.info(internals.EVENT_INITIALIZED, 'success')
    }

    if (self._services.hasOwnProperty(requestedSvc.serviceIdentifier)) {
      let serviceName = requestedSvc.serviceIdentifier
      self.logger.info('Refreshing service: ' + serviceName)
    }

    // Always instantiate the requested aws service, even if old one exists
    internals.newService.call(self, credsManager._awsConfig, requestedSvc)
  })
}
function SvcAws ( requestedSvc , options ) { if ( this . constructor . name === 'Object' ) { throw new Error ( 'Must be instantiated using new' ) } else if ( this . constructor . name === 'SvcAws' ) { throw new Error ( 'Abstract class ' + this . constructor . name + ' should not be instantiated' ) } EventEmitter . call ( this ) let self = this // initialize the property bag of AWS services which will be created this . _services = { } let credOptions = Object . assign ( { } , options ) internals . initLogger ( options . isLogging ) this . logger = internals . logger credOptions . logger = this . logger let credsManager = new Credentials ( credOptions ) credsManager . once ( internals . EVENT_INITIALIZED , function ( err , data ) { if ( err ) { self . logger . warn ( internals . EVENT_INITIALIZED , err ) internals . emitAsync . call ( self , internals . EVENT_INITIALIZED , err ) return } else { self . logger . info ( internals . EVENT_INITIALIZED , 'success' ) } if ( self . _services . hasOwnProperty ( requestedSvc . serviceIdentifier ) ) { let serviceName = requestedSvc . serviceIdentifier self . logger . info ( 'Refreshing service: ' + serviceName ) } // Always instantiate the requested aws service, even if old one exists internals . newService . call ( self , credsManager . _awsConfig , requestedSvc ) } ) }
Constructs a new SvcAws object for managing aws credentials
@constructor
@abstract
@arg {class} requestedSvc - The AWS.Service class to instantiate [aws docs]{@link http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Service.html}
@arg {object} options - The AWS service IAM credentials
@arg {object} options.keys - Credentials for the service API authentication. See [aws docs]{@link http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Credentials.html}
@arg {string} options.keys.accessKeyId - AWS access key ID
@arg {string} options.keys.secretAccessKey - AWS secret access key
@arg {string} options.keys.region - The EC2 region to send service requests
@arg {object} options.upgrade - Temporary Session Token credentials. See [aws docs]{@link http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/STS.html#getSessionToken-property}
@arg {string} options.upgrade.serialNumber - Identifies the user's hardware or virtual MFA device
@arg {number} options.upgrade.tokenCode - Time-based one-time password (TOTP) that the MFA devices produces
@arg {number} [options.upgrade.durationSeconds=900] - The duration, in seconds, that the credentials should remain valid
@arg {boolean} [options.isLogging=false] - Use internal logging
@throws {error}
@emits {intialized}
Constructs a new SvcAws object for managing aws credentials