diff --git a/src/App.tsx b/src/App.tsx index 54e0082..3b8c205 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -62,15 +62,7 @@ function App() { dispatch(setPerms({ perms })) const pending = await dbi.listPending() - const firstPending = new Map() - for (const p of pending) { - if (firstPending.get(p.appNpub)) continue - firstPending.set(p.appNpub, p) - } -// console.log({ pending, firstPending }) - - // @ts-ignore - dispatch(setPending({ pending: [...firstPending.values()] })) + dispatch(setPending({ pending })) // rerender // setRender((r) => r + 1) diff --git a/src/modules/backend.ts b/src/modules/backend.ts index 81e1a40..e69414c 100644 --- a/src/modules/backend.ts +++ b/src/modules/backend.ts @@ -440,7 +440,7 @@ export class NoauthBackend { } private getPerm(req: DbPending): string { - const perm = getReqPerm(req) + const reqPerm = getReqPerm(req) const appPerms = this.perms.filter( (p) => p.npub === req.npub && @@ -448,13 +448,13 @@ export class NoauthBackend { ) // exact match first - let p = appPerms.find((p) => p.perm === perm) + let perm = appPerms.find((p) => p.perm === reqPerm) // non-exact next - if (!p) - p = appPerms.find((p) => isPackagePerm(p.perm, perm)) + if (!perm) + perm = appPerms.find((p) => isPackagePerm(p.perm, reqPerm)) - console.log("req", req, "perm", perm, "value", p); - return p?.value || '' + console.log("req", req, "perm", reqPerm, "value", perm, appPerms); + return perm?.value || '' } private async allowPermitCallback({ diff --git a/src/pages/KeyPage/Key.Page.tsx b/src/pages/KeyPage/Key.Page.tsx index 26cfda8..85f8a50 100644 --- a/src/pages/KeyPage/Key.Page.tsx +++ b/src/pages/KeyPage/Key.Page.tsx @@ -65,7 +65,7 @@ const KeyPage = () => { const npubConnectPerms = filteredPerms.filter( (perm) => perm.perm === 'connect' - || perm.perm === ACTION_TYPE.BASIC.toLowerCase(), + || perm.perm === ACTION_TYPE.BASIC, ) const excludeConnectPendings = filteredPendingReqs.filter( (pr) => pr.method !== 'connect', diff --git a/src/utils/consts.ts b/src/utils/consts.ts index f935a0e..ddb2f63 100644 --- a/src/utils/consts.ts +++ b/src/utils/consts.ts @@ -3,7 +3,7 @@ export const NOAUTHD_URL = process.env.REACT_APP_NOAUTHD_URL export const WEB_PUSH_PUBKEY = process.env.REACT_APP_WEB_PUSH_PUBKEY export enum ACTION_TYPE { - BASIC = 'Basic', - ADVANCED = 'Advanced', - CUSTOM = 'Custom', + BASIC = 'basic', + ADVANCED = 'advanced', + CUSTOM = 'custom', } \ No newline at end of file diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index bafbc52..6398d41 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -59,8 +59,9 @@ export function getReqPerm(req: DbPending): string { } export function isPackagePerm(perm: string, reqPerm: string) { - if (perm === ACTION_TYPE.BASIC.toLowerCase()) { + if (perm === ACTION_TYPE.BASIC) { switch (reqPerm) { + case 'connect': case 'get_public_key': case 'nip04_decrypt': case 'nip04_encrypt':