mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-16 12:43:07 +00:00
38 lines
903 B
TypeScript
38 lines
903 B
TypeScript
import { Button } from "@material-ui/core";
|
|
import React from "react";
|
|
import { loadKeyPairFromStorage } from "./key_pair_storage";
|
|
import { KeyPair } from "../crypto";
|
|
|
|
export interface Props {
|
|
setEncryptionKeyPair: (keyPair: KeyPair) => void;
|
|
disabled: boolean;
|
|
password: string | undefined;
|
|
}
|
|
|
|
export function LoadKeyPair({
|
|
password,
|
|
disabled,
|
|
setEncryptionKeyPair,
|
|
}: Props) {
|
|
const loadKeyPair = () => {
|
|
if (disabled) return;
|
|
if (!password) return;
|
|
loadKeyPairFromStorage(password).then((keyPair: KeyPair | undefined) => {
|
|
if (!keyPair) return;
|
|
console.log("Encryption KeyPair loaded from storage");
|
|
setEncryptionKeyPair(keyPair);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<Button
|
|
variant="contained"
|
|
color="primary"
|
|
onClick={loadKeyPair}
|
|
disabled={!password || disabled}
|
|
>
|
|
Load Encryption Key Pair from storage
|
|
</Button>
|
|
);
|
|
}
|