UNPKG

@axway/amplify-sdk

Version:

Axway Amplify SDK for Node.js

95 lines (85 loc) 2.21 kB
import Authenticator from './authenticator.js'; import errors from '../errors.js'; import 'ejs'; import 'fs-extra'; import '../endpoints.js'; import 'jws'; import 'open'; import 'path'; import 'snooplogg'; import '../stores/token-store.js'; import 'pluralize'; import '../environments-C3ppEMBw.js'; import '@axway/amplify-request'; import '../server.js'; import 'crypto'; import 'get-port'; import 'http'; import 'url'; import '../util.js'; /** * Authentication scheme using a username and password. */ class OwnerPassword extends Authenticator { /** * Initializes an owner password authentication instance. * * @param {Object} opts - Various options. * @param {String} opts.username - The username used to authenticate. * @param {String} opts.password - The password used to authenticate. * @access public */ constructor(opts) { if (!opts || typeof opts !== 'object') { throw errors.INVALID_ARGUMENT('Expected options to be an object'); } if (!opts.username || typeof opts.username !== 'string') { throw errors.INVALID_ARGUMENT('Expected username to be a non-empty string'); } if (typeof opts.password !== 'string') { throw errors.INVALID_ARGUMENT('Expected password to be a string'); } super(opts); Object.defineProperty(this, 'username', { value: opts.username }); Object.defineProperty(this, 'password', { value: opts.password }); } /** * Parameters to include in the authenticated account object. Note that these values are * stripped when the Amplify SDK returns the account object. * * @type {Object} * @access private */ get authenticatorParams() { return { username: this.username, password: this.password }; } /** * Parameters to base the authenticator hash on. * * @type {Object} * @access private */ get hashParams() { return { username: this.username }; } /** * Parameters to include with authentication requests. * * @type {?Object} * @access private */ get tokenParams() { return { grantType: Authenticator.GrantTypes.Password, username: this.username, password: this.password }; } } export { OwnerPassword as default }; //# sourceMappingURL=owner-password.js.map