Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: extend kind list, kind types, kind translaions #3179

Merged
merged 3 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions src/extension/background-script/actions/nostr/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "~/types";

import { addPermissionFor } from "~/extension/background-script/permissions";
import { EventKind } from "~/extension/providers/nostr/types";
import state from "../../state";
import { ExtensionIcon, setIcon } from "../setup/setIcon";

Expand Down Expand Up @@ -108,20 +109,27 @@ const enable = async (message: MessageAllowanceEnable, sender: Sender) => {
});

// Add specific signing permissions

const reasonableEventKindIds = [
0, // Update profile
1, // Short text note
3, // Update follow list
4, // Encrypted direct messages
7, // Reaction
9734, // Zap request
10002, // Relay list metadata
22242, // Client relay authentication
30023, // Long-form content
30008, // Manage profile badges
30009, // Badge definition
30078, // App Data
EventKind.Metadata,
EventKind.Text,
EventKind.Contacts,
EventKind.DM,
EventKind.Repost,
EventKind.React,
EventKind.ZapRequest,
EventKind.MuteList,
EventKind.RelayList,
EventKind.Bookmarks,
EventKind.Authenticate,
EventKind.HTTPAuth,
EventKind.LongNote,
EventKind.ProfileBadge,
EventKind.CreateBadge,
EventKind.AppData,
EventKind.UploadChunk,
];

reasonableEventKindIds.forEach(async (kindId) => {
await addPermissionFor(
PermissionMethodNostr.NOSTR_SIGNMESSAGE + "/" + kindId,
Expand Down
19 changes: 19 additions & 0 deletions src/extension/providers/nostr/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,26 @@ export enum EventKind {
Contacts = 3,
DM = 4,
Deleted = 5,
Repost = 6,
pavanjoshi914 marked this conversation as resolved.
Show resolved Hide resolved
React = 7,
AwardBadge = 8,
CreateChannel = 40,
UpdateChannel = 41,
SendChannelMessage = 42,
HideChannelMessage = 43,
MuteChannelUser = 44,
ReportNote = 1984,
ZapRequest = 9734,
ZapReceipt = 9735,
MuteList = 10000,
RelayList = 10002,
Bookmarks = 10003,
Authenticate = 22242,
RemoteSign = 24133,
HTTPAuth = 27235,
ProfileBadge = 30008,
CreateBadge = 30009,
LongNote = 30023,
AppData = 30078,
UploadChunk = 10000135,
}
12 changes: 12 additions & 0 deletions src/i18n/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1039,10 +1039,18 @@
"title": "zap receipt",
"description": "Display a confirmation of a paid lightning invoice"
},
"10000": {
"title": "mute list",
"description": "Blocks spammers and bad actors from your feed"
},
"10002": {
"title": "relay list",
"description": "Update preferred relays for discovering your notes and receiving others' notes"
},
"10003": {
"title": "bookmarks",
"description": "Bookmark user posts"
},
pavanjoshi914 marked this conversation as resolved.
Show resolved Hide resolved
"22242": {
"title": "authenticate",
"description": "Authenticate to a relay"
Expand All @@ -1051,6 +1059,10 @@
"title": "remote sign",
"description": "Request and sign events remotely"
},
"27235": {
"title": "HTTP Auth",
"description": "HTTP Authentication"
},
"30008": {
"title": "profile badge",
"description": "Accept, reject and change display order of awarded badges"
Expand Down
Loading