Skip to content

Commit 220ccfa

Browse files
committed
feat: encrypt token on disk using safe storage api
Signed-off-by: Adam Setch <[email protected]>
1 parent 679f2ef commit 220ccfa

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

src/renderer/context/App.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -284,31 +284,19 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
284284
if (existing.settings) {
285285
setKeyboardShortcut(existing.settings.keyboardShortcut);
286286
setAlternateIdleIcon(existing.settings.useAlternateIdleIcon);
287-
setSettings({
288-
...defaultSettings,
289-
...Object.fromEntries(
290-
Object.entries(existing.settings).filter(
291-
([key]) => key in defaultSettings,
292-
),
293-
),
294-
});
287+
setSettings({ ...defaultSettings, ...existing.settings });
295288
webFrame.setZoomLevel(
296289
zoomPercentageToLevel(existing.settings.zoomPercentage),
297290
);
298291
}
299292

300293
if (existing.auth) {
301-
setAuth({
302-
...defaultAuth,
303-
...Object.fromEntries(
304-
Object.entries(existing.auth).filter(([key]) => key in defaultAuth),
305-
),
306-
});
294+
setAuth({ ...defaultAuth, ...existing.auth });
307295

308296
// Refresh account data on app start
309297
for (const account of existing.auth.accounts) {
310298
/**
311-
* Check if each account has an encrypted token.
299+
* Check if the account is using an encrypted token.
312300
* If not encrypt it and save it.
313301
*/
314302
try {
@@ -321,8 +309,6 @@ export const AppProvider = ({ children }: { children: ReactNode }) => {
321309
await refreshAccount(account);
322310
}
323311
}
324-
325-
// saveState({ auth: existing.auth, settings });
326312
}, []);
327313

328314
const fetchNotificationsWithAccounts = useCallback(

src/renderer/utils/api/request.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export async function apiRequestAuth(
4646
fetchAllRecords = false,
4747
): AxiosPromise | null {
4848
let apiToken = token;
49+
// TODO - Remove this try-catch block in a future release
4950
try {
5051
apiToken = (await decryptValue(token)) as Token;
5152
} catch (err) {

0 commit comments

Comments
 (0)