mirror of
https://github.com/getpaseo/paseo.git
synced 2026-08-14 12:23:16 +00:00
refactor: use pino.Logger in daemon-keypair
This commit is contained in:
@@ -3,6 +3,7 @@ import { webcrypto } from "node:crypto";
|
|||||||
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
import type pino from "pino";
|
||||||
|
|
||||||
const KeyPairSchema = z.object({
|
const KeyPairSchema = z.object({
|
||||||
v: z.literal(1),
|
v: z.literal(1),
|
||||||
@@ -12,12 +13,6 @@ const KeyPairSchema = z.object({
|
|||||||
|
|
||||||
type StoredKeyPair = z.infer<typeof KeyPairSchema>;
|
type StoredKeyPair = z.infer<typeof KeyPairSchema>;
|
||||||
|
|
||||||
type LoggerLike = {
|
|
||||||
child(bindings: Record<string, unknown>): LoggerLike;
|
|
||||||
info(...args: any[]): void;
|
|
||||||
warn(...args: any[]): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
const KEYPAIR_FILENAME = "daemon-keypair.json";
|
const KEYPAIR_FILENAME = "daemon-keypair.json";
|
||||||
const ECDH_ALGORITHM = { name: "ECDH", namedCurve: "P-256" };
|
const ECDH_ALGORITHM = { name: "ECDH", namedCurve: "P-256" };
|
||||||
|
|
||||||
@@ -28,7 +23,7 @@ export type DaemonKeyPairBundle = {
|
|||||||
|
|
||||||
export async function loadOrCreateDaemonKeyPair(
|
export async function loadOrCreateDaemonKeyPair(
|
||||||
paseoHome: string,
|
paseoHome: string,
|
||||||
logger?: LoggerLike
|
logger?: pino.Logger
|
||||||
): Promise<DaemonKeyPairBundle> {
|
): Promise<DaemonKeyPairBundle> {
|
||||||
const log = logger?.child({ module: "daemon-keypair" });
|
const log = logger?.child({ module: "daemon-keypair" });
|
||||||
const filePath = path.join(paseoHome, KEYPAIR_FILENAME);
|
const filePath = path.join(paseoHome, KEYPAIR_FILENAME);
|
||||||
|
|||||||
Reference in New Issue
Block a user