mirror of
https://github.com/haveno-dex/haveno-ui.git
synced 2025-08-07 14:12:33 -04:00
feat: haveno daemon integration
- create account - login - change password - haveno hooks - electron-store hooks - haveno-ts --- Authored-by: schowdhuri Reviewed-by: localredhead
This commit is contained in:
parent
7bcf36d595
commit
a0c7875391
109 changed files with 2276 additions and 573 deletions
|
@ -16,12 +16,41 @@
|
|||
|
||||
import { ipcRenderer } from "electron";
|
||||
import { exposeInMainWorld } from "./exposeInMainWorld";
|
||||
import type { UserInfoInputType } from "./types";
|
||||
import type {
|
||||
AccountInfoDto,
|
||||
ChangePasswordInput,
|
||||
IPreferences,
|
||||
SetPasswordInput,
|
||||
} from "./types";
|
||||
import { IpcChannels } from "./types";
|
||||
|
||||
// Export for types in contracts.d.ts
|
||||
export const store = {
|
||||
storeUserinfo: async (data?: UserInfoInputType) =>
|
||||
ipcRenderer.invoke("store:userinfo", data),
|
||||
setPassword: async (data: SetPasswordInput): Promise<void> =>
|
||||
ipcRenderer.invoke(IpcChannels.SetPassword, data),
|
||||
|
||||
// returns jwt on success
|
||||
changePassword: async (data: ChangePasswordInput): Promise<string> =>
|
||||
ipcRenderer.invoke(IpcChannels.ChangePassword, data),
|
||||
|
||||
// returns jwt on success; null on failure
|
||||
verifyPassword: async (plainText: string): Promise<string | null> =>
|
||||
ipcRenderer.invoke(IpcChannels.VerifyPassword, plainText),
|
||||
|
||||
verifyAuthToken: async (token: string): Promise<boolean> =>
|
||||
ipcRenderer.invoke(IpcChannels.VerifyAuthToken, token),
|
||||
|
||||
setPrimaryFiat: async (value: string): Promise<void> =>
|
||||
ipcRenderer.invoke(IpcChannels.SetPrimaryFiat, value),
|
||||
|
||||
getAccountInfo: async (): Promise<AccountInfoDto> =>
|
||||
ipcRenderer.invoke(IpcChannels.GetAccountInfo),
|
||||
|
||||
setMoneroNode: async (value: string): Promise<void> =>
|
||||
ipcRenderer.invoke(IpcChannels.SetMoneroNode, value),
|
||||
|
||||
getPreferences: async (): Promise<IPreferences> =>
|
||||
ipcRenderer.invoke(IpcChannels.GetPreferences),
|
||||
};
|
||||
|
||||
exposeInMainWorld("electronStore", store);
|
||||
|
|
|
@ -14,4 +14,4 @@
|
|||
// limitations under the License.
|
||||
// =============================================================================
|
||||
|
||||
export * from "./store";
|
||||
export * from "../../../main/src/types";
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
// =============================================================================
|
||||
// Copyright 2022 Haveno
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// =============================================================================
|
||||
|
||||
import type { Schema } from "electron-store";
|
||||
|
||||
export enum StoreKeys {
|
||||
UserInfo = "UserInfo",
|
||||
Permissions = "Permissions",
|
||||
}
|
||||
|
||||
// TS types for StoreSchema
|
||||
export interface IStoreSchema {
|
||||
[StoreKeys.UserInfo]: IUserInfo;
|
||||
[StoreKeys.Permissions]: Array<IUserPermission>;
|
||||
}
|
||||
|
||||
export interface IUserInfo {
|
||||
username: string;
|
||||
password: Buffer;
|
||||
}
|
||||
|
||||
export type UserInfoInputType = Omit<IUserInfo, "password"> & {
|
||||
password: string;
|
||||
};
|
||||
|
||||
export interface IUserPermission {
|
||||
name: string;
|
||||
}
|
||||
|
||||
// this schema is used by electron-store
|
||||
// must mirror IStoreSchema
|
||||
export const StoreSchema: Schema<IStoreSchema> = {
|
||||
[StoreKeys.UserInfo]: {
|
||||
type: "object",
|
||||
required: [],
|
||||
properties: {
|
||||
username: { type: "string" },
|
||||
},
|
||||
},
|
||||
[StoreKeys.Permissions]: {
|
||||
type: "array",
|
||||
default: [],
|
||||
items: {
|
||||
type: "object",
|
||||
required: [],
|
||||
properties: {
|
||||
name: { type: "string" },
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue