1 | import passwordPrompt from 'password-prompt';
|
2 | import { waitForUser } from './utils';
|
3 |
|
4 | export interface UserInterface {
|
5 | getWindowsEncryptionPassword(): Promise<string>;
|
6 | warnChromeOnLinuxWithoutCertutil(): Promise<void>;
|
7 | closeFirefoxBeforeContinuing(): Promise<void>;
|
8 | startFirefoxWizard(certificateHost: string): Promise<void>;
|
9 | firefoxWizardPromptPage(certificateURL: string): Promise<string>;
|
10 | waitForFirefoxWizard(): Promise<void>;
|
11 | }
|
12 |
|
13 | const DefaultUI: UserInterface = {
|
14 | async getWindowsEncryptionPassword() {
|
15 | return await passwordPrompt('devcert password (http://bit.ly/devcert-what-password?):');
|
16 | },
|
17 | async warnChromeOnLinuxWithoutCertutil() {
|
18 | console.warn(`
|
19 | WARNING: It looks like you have Chrome installed, but you specified
|
20 | 'skipCertutilInstall: true'. Unfortunately, without installing
|
21 | certutil, it's impossible get Chrome to trust devcert's certificates
|
22 | The certificates will work, but Chrome will continue to warn you that
|
23 | they are untrusted.
|
24 | `);
|
25 | },
|
26 | async closeFirefoxBeforeContinuing() {
|
27 | console.log('Please close Firefox before continuing');
|
28 | },
|
29 | async startFirefoxWizard(certificateHost) {
|
30 | console.log(`
|
31 | devcert was unable to automatically configure Firefox. You'll need to
|
32 | complete this process manually. Don't worry though - Firefox will walk
|
33 | you through it.
|
34 |
|
35 | When you're ready, hit any key to continue. Firefox will launch and
|
36 | display a wizard to walk you through how to trust the devcert
|
37 | certificate. When you are finished, come back here and we'll finish up.
|
38 |
|
39 | (If Firefox doesn't start, go ahead and start it and navigate to
|
40 | ${ certificateHost } in a new tab.)
|
41 |
|
42 | If you are curious about why all this is necessary, check out
|
43 | https://github.com/davewasmer/devcert#how-it-works
|
44 |
|
45 | <Press any key to launch Firefox wizard>
|
46 | `);
|
47 | await waitForUser();
|
48 | },
|
49 | async firefoxWizardPromptPage(certificateURL: string) {
|
50 | return `
|
51 | <html>
|
52 | <head>
|
53 | <meta http-equiv="refresh" content="0; url="${certificateURL}" />
|
54 | </head>
|
55 | </html>
|
56 | `;
|
57 | },
|
58 | async waitForFirefoxWizard() {
|
59 | console.log(`
|
60 | Launching Firefox ...
|
61 |
|
62 | Great! Once you've finished the Firefox wizard for adding the devcert
|
63 | certificate, just hit any key here again and we'll wrap up.
|
64 |
|
65 | <Press any key to continue>
|
66 | `)
|
67 | await waitForUser();
|
68 | }
|
69 | }
|
70 |
|
71 | export default DefaultUI; |
\ | No newline at end of file |