-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
52 additions
and
93 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,9 @@ | |
"private": true, | ||
"author": "OneKey <[email protected]>", | ||
"scripts": { | ||
"postinstall": "yarn keytar", | ||
"keytar": "bash development/build_keytar.sh", | ||
"lint": "tsc --noEmit && eslint . --ext .ts,.tsx", | ||
"lint:fix": "tsc --noEmit && eslint . --ext .ts,.tsx --fix", | ||
"dev": "yarn keytar && npx concurrently \"yarn build:main\" \"yarn dev:renderer\" \"cross-env LAUNCH_ELECTRON=true node scripts/dev.js\"", | ||
"dev": "npx concurrently \"yarn build:main\" \"yarn dev:renderer\" \"cross-env LAUNCH_ELECTRON=true node scripts/dev.js\"", | ||
"dev:main": "electron --inspect=5858 dist/app.js", | ||
"dev:renderer": "TRANSFORM_REGENERATOR_DISABLED=true BROWSER=none WEB_PORT=3001 expo start --web", | ||
"clean": "rimraf ./build-electron && rimraf ./build && rimraf ./dist && rimraf node_modules && rimraf .expo && rimraf __generated__", | ||
|
@@ -21,9 +19,9 @@ | |
"build:electron:winms": "electron-builder build -w --config electron-builder-ms.config.js", | ||
"build:electron:mac": "electron-builder build -m --config electron-builder.config.js", | ||
"build:electron:mas": "electron-builder build -m --config electron-builder-mas.config.js", | ||
"build": "yarn keytar && NODE_ENV=production sh -c \"yarn clean:build && yarn build:renderer && yarn build:main && yarn build:electron --publish never\"", | ||
"build": "NODE_ENV=production sh -c \"yarn clean:build && yarn build:renderer && yarn build:main && yarn build:electron --publish never\"", | ||
"build:mac": "NODE_ENV=production sh -c \"yarn clean:build && yarn build:renderer && yarn build:main && yarn build:electron:mac --publish never\"", | ||
"build:mas": "yarn keytar && NODE_ENV=production sh -c \"yarn clean:build && yarn build:renderer && yarn build:main && yarn build:electron:mas --publish never\"", | ||
"build:mas": "NODE_ENV=production sh -c \"yarn clean:build && yarn build:renderer && yarn build:main && yarn build:electron:mas --publish never\"", | ||
"build:winms": "NODE_ENV=production && DESK_CHANNEL=ms-store sh -c \"yarn clean:build && yarn build:renderer && yarn build:main && yarn build:electron:winms --publish never\"", | ||
"publish:all": "NODE_ENV=production sh -c \"yarn clean:build && yarn build:renderer && yarn build:main && yarn build:electron --publish always\"", | ||
"publish:winms": "NODE_ENV=production && DESK_CHANNEL=ms-store sh -c \"yarn clean:build && yarn build:renderer && yarn build:main && yarn build:electron:winms --publish always\"" | ||
|
@@ -39,7 +37,6 @@ | |
"electron-store": "^8.1.0", | ||
"electron-updater": "^5.2.1", | ||
"expo": "49.0.6", | ||
"keytar": "^7.9.0", | ||
"node-fetch": "^2.6.7" | ||
}, | ||
"devDependencies": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,48 @@ | ||
import { safeStorage } from 'electron'; | ||
import Store from 'electron-store'; | ||
|
||
const store = new Store(); | ||
|
||
export type LocalStore = { | ||
getUpdateSettings(): UpdateSettings; | ||
setUpdateSettings(updateSettings: UpdateSettings): void; | ||
clear(): void; | ||
clearUpdateSettings(): void; | ||
}; | ||
|
||
export type UpdateSettings = { | ||
useTestFeedUrl: boolean; | ||
}; | ||
|
||
const EncryptedData = 'EncryptedData'; | ||
|
||
export const getUpdateSettings = (): UpdateSettings => | ||
store.get('updateSettings', { useTestFeedUrl: false }) as UpdateSettings; | ||
|
||
export const setUpdateSettings = (updateSettings: UpdateSettings): void => { | ||
store.set('updateSettings', updateSettings); | ||
}; | ||
|
||
export const clear = () => { | ||
store.clear(); | ||
export const clearUpdateSettings = () => { | ||
store.delete('updateSettings'); | ||
}; | ||
|
||
export const getSecureItem = (key: string) => { | ||
const item = store.get(EncryptedData, {}) as Record<string, string>; | ||
const value = item[key]; | ||
if (value) { | ||
const result = safeStorage.decryptString(Buffer.from(value, 'hex')); | ||
return result; | ||
} | ||
}; | ||
|
||
export const setSecureItem = (key: string, value: string): void => { | ||
const items = store.get(EncryptedData, {}) as Record<string, string>; | ||
items[key] = safeStorage.encryptString(value).toString('hex'); | ||
store.set(EncryptedData, items); | ||
}; | ||
|
||
export const clearSecureItem = (key: string) => { | ||
const items = store.get(EncryptedData, {}) as Record<string, string>; | ||
delete items[key]; | ||
store.set(EncryptedData, items); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters