diff --git a/src/components/SettingsTab.component.pug b/src/components/SettingsTab.component.pug index 2116f13..81e60f8 100644 --- a/src/components/SettingsTab.component.pug +++ b/src/components/SettingsTab.component.pug @@ -43,6 +43,16 @@ div.sync-config-settings-tab [(ngModel)]='config.store.syncConfig.encryption', (ngModelChange)='config.save()', ) + .form-line + .header + .title EncryptUpload + .description Encrypt upload to git + input.form-control( + type='text', + placeholder="encryptKey", + [(ngModel)]='config.store.syncConfig.encryptKey', + (ngModelChange)='config.save()', + ) .form-line .header .title Gist diff --git a/src/components/SettingsTab.component.ts b/src/components/SettingsTab.component.ts index 2b06ccd..4c00ef7 100644 --- a/src/components/SettingsTab.component.ts +++ b/src/components/SettingsTab.component.ts @@ -74,11 +74,18 @@ export class SyncConfigSettingsTabComponent implements OnInit { const store = yaml.load(this.config.readRaw()) as any; + const key = store.syncConfig.encryptKey + // no sync self delete store.syncConfig; + let source = yaml.dump(store) + + // encrypt upload + key && (source = this.aesEncrypt(source,key)) + // config file - files.push(new GistFile('config.json', yaml.dump(store))); + files.push(new GistFile('config.json', source)); // ssh password files.push(new GistFile('ssh.auth.json', JSON.stringify(await this.getSSHPluginAllPasswordInfos(token)))); @@ -90,7 +97,14 @@ export class SyncConfigSettingsTabComponent implements OnInit { const result = await getGist(type, token, baseUrl, gist); if (result.has('config.json')) { - const config = yaml.load(result.get('config.json').value) as any; + let source = result.get('config.json').value + + const key = this.config.store.syncConfig.encryptKey + + //download decrypt + key && (source = this.aesDecrypt(source,key)) + + const config = yaml.load(source) as any; config.syncConfig = selfConfig; this.config.writeRaw(yaml.dump(config)); } diff --git a/src/config.ts b/src/config.ts index 772968b..ad7409a 100644 --- a/src/config.ts +++ b/src/config.ts @@ -8,7 +8,8 @@ export class SyncConfigProvider extends ConfigProvider { token: '', gist: '', lastSyncTime: '-', - encryption: false + encryption: false, + encryptKey: '' } } } \ No newline at end of file