feat: adding initial leveldb configuration

This commit is contained in:
Chubby Granny Chaser 2025-01-15 16:58:59 +00:00
parent d4be5b8c66
commit 2c5fb8a037
No known key found for this signature in database
18 changed files with 202 additions and 196 deletions

View file

@ -1,17 +1,21 @@
import { shell } from "electron";
import { registerEvent } from "../register-event";
import { userAuthRepository } from "@main/repository";
import { HydraApi } from "@main/services";
import { Crypto, HydraApi } from "@main/services";
import { db } from "@main/level";
import type { Auth } from "@types";
import { levelKeys } from "@main/level/sublevels/keys";
const openCheckout = async (_event: Electron.IpcMainInvokeEvent) => {
const userAuth = await userAuthRepository.findOne({ where: { id: 1 } });
const auth = await db.get<string, Auth>(levelKeys.auth, {
valueEncoding: "json",
});
if (!userAuth) {
if (!auth) {
return;
}
const paymentToken = await HydraApi.post("/auth/payment", {
refreshToken: userAuth.refreshToken,
refreshToken: Crypto.decrypt(auth.refreshToken),
}).then((response) => response.accessToken);
const params = new URLSearchParams({