Skip to content

Commit

Permalink
Clarify which variables needs storage
Browse files Browse the repository at this point in the history
  • Loading branch information
marty-mcflai committed Apr 1, 2022
1 parent 71b2b93 commit 41dc4d8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const decryptPayload = (data: string, nonce: string, sharedSecret?: Uint8Array)
return JSON.parse(Buffer.from(decryptedData).toString("utf8"));
};

const encryptPayload = (payload: any, sharedSecret: Uint8Array) => {
const encryptPayload = (payload: any, sharedSecret?: Uint8Array) => {
if (!sharedSecret) throw new Error("missing shared secret");

const nonce = nacl.randomBytes(24);
Expand All @@ -60,13 +60,12 @@ export default function App() {
const addLog = useCallback((log: string) => setLogs((logs) => [...logs, "> " + log]), []);
const scrollViewRef = useRef<any>(null);

// store dappKeyPair and sharedSecret SECURELY on device
// store dappKeyPair, sharedSecret, session and account SECURELY on device
// to avoid having to reconnect users.
const [dappKeyPair] = useState(nacl.box.keyPair());
const [sharedSecret, setSharedSecret] = useState<Uint8Array>();

const [phantomWalletPublicKey, setPhantomWalletPublicKey] = useState<PublicKey>();
const [session, setSession] = useState<string>();
const [phantomWalletPublicKey, setPhantomWalletPublicKey] = useState<PublicKey>();

useEffect(() => {
(async () => {
Expand Down

0 comments on commit 41dc4d8

Please sign in to comment.