MCPcopy Create free account
hub / github.com/davewasmer/devcert / readProtectedFile

Method readProtectedFile

src/platforms/win32.ts:70–86  ·  view source on GitHub ↗
(filepath: string)

Source from the content-addressed store, hash-verified

68 }
69
70 async readProtectedFile(filepath: string): Promise<string> {
71 assertNotTouchingFiles(filepath, 'read');
72 if (!encryptionKey) {
73 encryptionKey = await UI.getWindowsEncryptionPassword();
74 }
75 // Try to decrypt the file
76 try {
77 return this.decrypt(read(filepath, 'utf8'), encryptionKey);
78 } catch (e) {
79 // If it's a bad password, clear the cached copy and retry
80 if (e.message.indexOf('bad decrypt') >= -1) {
81 encryptionKey = null;
82 return await this.readProtectedFile(filepath);
83 }
84 throw e;
85 }
86 }
87
88 async writeProtectedFile(filepath: string, contents: string) {
89 assertNotTouchingFiles(filepath, 'write');

Callers

nothing calls this directly

Calls 3

decryptMethod · 0.95
assertNotTouchingFilesFunction · 0.90

Tested by

no test coverage detected