.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / enquirer / lib / prompts / basicauth.js
1 'use strict';
2
3 const AuthPrompt = require('../types/auth');
4
5 function defaultAuthenticate(value, state) {
6   if (value.username === this.options.username && value.password === this.options.password) {
7     return true;
8   }
9   return false;
10 }
11
12 const factory = (authenticate = defaultAuthenticate) => {
13   const choices = [
14     { name: 'username', message: 'username' },
15     {
16       name: 'password',
17       message: 'password',
18       format(input) {
19         if (this.options.showPassword) {
20           return input;
21         }
22         let color = this.state.submitted ? this.styles.primary : this.styles.muted;
23         return color(this.symbols.asterisk.repeat(input.length));
24       }
25     }
26   ];
27
28   class BasicAuthPrompt extends AuthPrompt.create(authenticate) {
29     constructor(options) {
30       super({ ...options, choices });
31     }
32
33     static create(authenticate) {
34       return factory(authenticate);
35     }
36   }
37
38   return BasicAuthPrompt;
39 };
40
41 module.exports = factory();