From 81a576c2007805849f963242bc93ef60bee8efa4 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 14 Jan 2025 16:55:44 -0800 Subject: public fields --- lib/utils.ts | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'lib') diff --git a/lib/utils.ts b/lib/utils.ts index 9cb6a690..fc0ee176 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -51,25 +51,7 @@ export const bip21 = (address, { amount, memo, tip, type }) => { return `${network}:${address}?${url.toString()}`; }; -export const fields = [ - "pubkey", - "password", - "username", - "currency", - "currencies", - "fiat", - "otpsecret", - "balance", - "ip", - "pin", - "display", - "haspin", - "profile", - "prompt", - "banner", -]; - -export const getUser = async (username, fields = whitelist) => { +export const getUser = async (username, fields) => { let update; if (username === "undefined") fail("invalid user"); const user = await migrate(username); @@ -97,7 +79,7 @@ export const getUser = async (username, fields = whitelist) => { if (update) s(`user:${user.id}`, user); - return user; + return fields ? pick(user, fields) : user; }; export const getInvoice = async (hash) => { @@ -208,7 +190,7 @@ export const fmt = (sats) => export const link = (id) => `${URL}/payment/${id}`; -export const publicFields = [ +export const fields = [ "about", "anon", "banner", -- cgit v1.2.3