Fix basic to include connect
This commit is contained in:
parent
0044697159
commit
04ecb813b2
10
src/App.tsx
10
src/App.tsx
@ -62,15 +62,7 @@ function App() {
|
||||
dispatch(setPerms({ perms }))
|
||||
|
||||
const pending = await dbi.listPending()
|
||||
const firstPending = new Map<string, DbPending>()
|
||||
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)
|
||||
|
@ -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({
|
||||
|
@ -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',
|
||||
|
@ -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',
|
||||
}
|
@ -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':
|
||||
|
Loading…
x
Reference in New Issue
Block a user