Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypt upload to git #31

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/components/SettingsTab.component.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions src/components/SettingsTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))));
Expand All @@ -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));
}
Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export class SyncConfigProvider extends ConfigProvider {
token: '',
gist: '',
lastSyncTime: '-',
encryption: false
encryption: false,
encryptKey: ''
}
}
}