4271aee14d675de30b2daac9493a96279c2d540cb1534ba75e6b8df1819281b2f5b1684a39a778b2b85e860611dc09e7e26c63440f3761c0a0c7284e518cda 606 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const FormPrompt = require('../prompts/form');
  3. const defaultAuthenticate = () => {
  4. throw new Error('expected prompt to have a custom authenticate method');
  5. };
  6. const factory = (authenticate = defaultAuthenticate) => {
  7. class AuthPrompt extends FormPrompt {
  8. constructor(options) {
  9. super(options);
  10. }
  11. async submit() {
  12. this.value = await authenticate.call(this, this.values, this.state);
  13. super.base.submit.call(this);
  14. }
  15. static create(authenticate) {
  16. return factory(authenticate);
  17. }
  18. }
  19. return AuthPrompt;
  20. };
  21. module.exports = factory();