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
// frontend lib module which is injected into the codegen'd hooks | |
import { getAuthToken } from './auth' | |
export const API_URL = process.env.REACT_APP_API_URL! | |
/** | |
* Custom fetcher used by codegen'd hooks to first load auth token, then make the fetch request. | |
*/ | |
export const fetcher = <TData, TVariables>(query: string, variables?: TVariables) => { | |
return async (): Promise<TData> => { |
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
async function aesEncrypt(data, password, difficulty = 10) { | |
const hashKey = await grindKey(password, difficulty) | |
const iv = await getIv(password, data) | |
const key = await window.crypto.subtle.importKey( | |
'raw', | |
hashKey, { | |
name: 'AES-GCM', | |
}, | |
false, |