Allow saving the password in the system keychain

parent a78e618d
This diff is collapsed.
......@@ -16,8 +16,9 @@
"dist"
],
"dependencies": {
"@samuelthomas2774/icloud-api": "0.1.*",
"@samuelthomas2774/icloud-api": "^0.1.4",
"fuse-bindings": "^2.11.2",
"keytar": "^4.2.1",
"yargs": "^12.0.2"
},
"devDependencies": {
......
......@@ -4,6 +4,7 @@ import path from 'path';
import readline from 'readline';
import yargs from 'yargs';
import fuse from './fuse';
import keytar from 'keytar';
import iCloudService from '@samuelthomas2774/icloud-api';
import mount from '..';
......@@ -29,7 +30,15 @@ process.on('SIGINT', () => process.stdout.write('\u001B[28m'));
let password;
try {
password = await prompt(`Password for ${apple_id}: \u001B[8m`);
password = await keytar.getPassword('icloud-drive-fs', apple_id);
if (!password) {
password = await prompt(`Password for ${apple_id}: \u001B[8m`);
const save_password = await prompt(`Save password in system keychain (Y/n)? `);
if (!save_password.match(/n/i)) await keytar.setPassword('icloud-drive-fs', apple_id, password);
}
} finally {
process.stdout.write('\u001B[28m');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment