secure privkey

This commit is contained in:
Ren Amamiya
2023-07-09 16:55:25 +07:00
parent a5c2ec080a
commit cba94ab99e
20 changed files with 1011 additions and 499 deletions

View File

@@ -1,17 +1,29 @@
import { create } from 'zustand';
import { createJSONStorage, persist } from 'zustand/middleware';
export const useOnboarding = create(
persist(
(set) => ({
profile: {},
createProfile: (data) => {
set({ profile: data });
},
}),
{
name: 'onboarding',
storage: createJSONStorage(() => sessionStorage),
}
)
);
interface OnboardingState {
profile: { [x: string]: string };
pubkey: string;
privkey: string;
createProfile: (data: { [x: string]: string }) => void;
setPubkey: (pubkey: string) => void;
setPrivkey: (privkey: string) => void;
clearPrivkey: (privkey: string) => void;
}
export const useOnboarding = create<OnboardingState>((set) => ({
profile: {},
pubkey: '',
privkey: '',
createProfile: (data: { [x: string]: string }) => {
set({ profile: data });
},
setPubkey: (pubkey: string) => {
set({ pubkey: pubkey });
},
setPrivkey: (privkey: string) => {
set({ privkey: privkey });
},
clearPrivkey: () => {
set({ privkey: '' });
},
}));

13
src/stores/stronghold.tsx Normal file
View File

@@ -0,0 +1,13 @@
import { create } from 'zustand';
interface StrongholdState {
password: null | string;
setPassword: (password: string) => void;
}
export const useStronghold = create<StrongholdState>((set) => ({
password: null,
setPassword: (password: string) => {
set({ password: password });
},
}));