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

use kind30398 package #27

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"dependencies": {
"@henrygd/queue": "npm:@jsr/henrygd__queue@^1.0.6",
"@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.30.0",
"@shuesken/nostroots-kind30398event": "npm:@jsr/shuesken__nostroots-kind30398event@^0.0.1",
"dompurify": "^3.1.4",
"leaflet": "^1.9.3",
"leaflet.sidepanel": "https://github.com/maxwell-ilai/Leaflet.SidePanel",
Expand Down
8 changes: 6 additions & 2 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ export const DEFAULT_RELAYS = [
export const DEV_RELAYS = DEFAULT_RELAYS;
export const PANEL_CONTAINER_ID = "panelID";
export const BADGE_CONTAINER_ID = "badge";
export const CONTENT_MINIMUM_LENGTH = 3;
export const CONTENT_MAXIMUM_LENGTH = 300;

export {
CONTENT_MAXIMUM_LENGTH,
CONTENT_MINIMUM_LENGTH,
} from "@shuesken/nostroots-kind30398event";

export const EARLIEST_FILTER_SINCE = 1716736622;

export const TRUSTED_VALIDATION_PUBKEYS = [
Expand Down
30 changes: 10 additions & 20 deletions src/nostr/subscribe.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { newQueue } from "@henrygd/queue";
import * as nostrify from "@nostrify/nostrify";
import * as kind30398event from "@shuesken/nostroots-kind30398event";
import { Filter, Kind } from "nostr-tools";
import {
CONTENT_MAXIMUM_LENGTH,
Expand Down Expand Up @@ -49,31 +50,20 @@ export const subscribe = async ({
}: SubscribeParams) => {
console.log("#qnvvsm nostr/subscribe");

const onNoteEvent = (event: Kind30398Event) => {
const onNoteEvent = (event: any) => {
// if (isDev()) console.log("#gITVd2 gotNoteEvent", event);

if (
!doesStringPassSanitisation(event.content) ||
event.content.length > CONTENT_MAXIMUM_LENGTH ||
!doesStringPassSanitisation(event.pubkey)
) {
try {
const parsedEvent = kind30398event.kind30398EventSchema.parse(event);
kind30398Events.add(parsedEvent);
onEventReceived(parsedEvent);
const pubKey = getPublicKeyFromEvent({ event });
fetchProfileQueue.add(fetchProfileFactory(pubKey));
return;
}

const plusCode = getTagFirstValueFromEvent({
event,
tag: PLUS_CODE_TAG_KEY,
});
if (!isValidPlusCode(plusCode)) {
} catch (e) {
console.warn(`Event could not be parsed: ${JSON.stringify(event)}`);
return;
}

kind30398Events.add(event);

onEventReceived(event);
const pubKey = getPublicKeyFromEvent({ event });
fetchProfileQueue.add(fetchProfileFactory(pubKey));
return;
};

/*
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as nostrify from "@nostrify/nostrify";
import * as kind30398event from "@shuesken/nostroots-kind30398event";

export type MaybeLocalStorage = Partial<WindowLocalStorage>;

export type NostrEvent = nostrify.NostrEvent;
export type NostrEvent = kind30398event.Event;

export type UnsignedEvent = Omit<
NostrEvent,
Expand Down
112 changes: 61 additions & 51 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1440,90 +1440,99 @@ __metadata:
languageName: node
linkType: hard

"@swc/core-darwin-arm64@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-darwin-arm64@npm:1.7.10"
"@shuesken/nostroots-kind30398event@npm:@jsr/shuesken__nostroots-kind30398event@^0.0.1":
version: 0.0.1
resolution: "@jsr/shuesken__nostroots-kind30398event@npm:0.0.1::__archiveUrl=https%3A%2F%2Fnpm.jsr.io%2F~%2F11%2F%40jsr%2Fshuesken__nostroots-kind30398event%2F0.0.1.tgz"
dependencies:
zod: "npm:^3.23.8"
checksum: 10c0/a0f7f3130ddc3d1ec7d760cd0621aa8ad5e226fac4778d9d6bd4091873905903911a7482fcba98fce7b284e7f30e72e881c8826c7aaa3d4f840ea48471aea776
languageName: node
linkType: hard

"@swc/core-darwin-arm64@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-darwin-arm64@npm:1.7.14"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"@swc/core-darwin-x64@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-darwin-x64@npm:1.7.10"
"@swc/core-darwin-x64@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-darwin-x64@npm:1.7.14"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"@swc/core-linux-arm-gnueabihf@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.7.10"
"@swc/core-linux-arm-gnueabihf@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-linux-arm-gnueabihf@npm:1.7.14"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard

"@swc/core-linux-arm64-gnu@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-linux-arm64-gnu@npm:1.7.10"
"@swc/core-linux-arm64-gnu@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-linux-arm64-gnu@npm:1.7.14"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"@swc/core-linux-arm64-musl@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-linux-arm64-musl@npm:1.7.10"
"@swc/core-linux-arm64-musl@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-linux-arm64-musl@npm:1.7.14"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard

"@swc/core-linux-x64-gnu@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-linux-x64-gnu@npm:1.7.10"
"@swc/core-linux-x64-gnu@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-linux-x64-gnu@npm:1.7.14"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard

"@swc/core-linux-x64-musl@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-linux-x64-musl@npm:1.7.10"
"@swc/core-linux-x64-musl@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-linux-x64-musl@npm:1.7.14"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"@swc/core-win32-arm64-msvc@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-win32-arm64-msvc@npm:1.7.10"
"@swc/core-win32-arm64-msvc@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-win32-arm64-msvc@npm:1.7.14"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"@swc/core-win32-ia32-msvc@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-win32-ia32-msvc@npm:1.7.10"
"@swc/core-win32-ia32-msvc@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-win32-ia32-msvc@npm:1.7.14"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard

"@swc/core-win32-x64-msvc@npm:1.7.10":
version: 1.7.10
resolution: "@swc/core-win32-x64-msvc@npm:1.7.10"
"@swc/core-win32-x64-msvc@npm:1.7.14":
version: 1.7.14
resolution: "@swc/core-win32-x64-msvc@npm:1.7.14"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard

"@swc/core@npm:^1.3.36":
version: 1.7.10
resolution: "@swc/core@npm:1.7.10"
dependencies:
"@swc/core-darwin-arm64": "npm:1.7.10"
"@swc/core-darwin-x64": "npm:1.7.10"
"@swc/core-linux-arm-gnueabihf": "npm:1.7.10"
"@swc/core-linux-arm64-gnu": "npm:1.7.10"
"@swc/core-linux-arm64-musl": "npm:1.7.10"
"@swc/core-linux-x64-gnu": "npm:1.7.10"
"@swc/core-linux-x64-musl": "npm:1.7.10"
"@swc/core-win32-arm64-msvc": "npm:1.7.10"
"@swc/core-win32-ia32-msvc": "npm:1.7.10"
"@swc/core-win32-x64-msvc": "npm:1.7.10"
version: 1.7.14
resolution: "@swc/core@npm:1.7.14"
dependencies:
"@swc/core-darwin-arm64": "npm:1.7.14"
"@swc/core-darwin-x64": "npm:1.7.14"
"@swc/core-linux-arm-gnueabihf": "npm:1.7.14"
"@swc/core-linux-arm64-gnu": "npm:1.7.14"
"@swc/core-linux-arm64-musl": "npm:1.7.14"
"@swc/core-linux-x64-gnu": "npm:1.7.14"
"@swc/core-linux-x64-musl": "npm:1.7.14"
"@swc/core-win32-arm64-msvc": "npm:1.7.14"
"@swc/core-win32-ia32-msvc": "npm:1.7.14"
"@swc/core-win32-x64-msvc": "npm:1.7.14"
"@swc/counter": "npm:^0.1.3"
"@swc/types": "npm:^0.1.12"
peerDependencies:
Expand Down Expand Up @@ -1552,7 +1561,7 @@ __metadata:
peerDependenciesMeta:
"@swc/helpers":
optional: true
checksum: 10c0/c05ff9cf9d8a8a0961a7188d03bfcf6776b3f7e72798f72110a06d185ffe13b3a46138ddf0ff135dc07030aecfd689dd15d14e796b302cfaabd0ab8978831054
checksum: 10c0/d98e935a376d6358f53f16a269ee0021c00e2764cc7fabbc594904f283a97200a323b802d35eea034e44af67e8158f641f8ac7a8799b15312cb952765e03ba6b
languageName: node
linkType: hard

Expand Down Expand Up @@ -1726,9 +1735,9 @@ __metadata:
linkType: hard

"async@npm:^3.2.4":
version: 3.2.5
resolution: "async@npm:3.2.5"
checksum: 10c0/1408287b26c6db67d45cb346e34892cee555b8b59e6c68e6f8c3e495cad5ca13b4f218180e871f3c2ca30df4ab52693b66f2f6ff43644760cab0b2198bda79c1
version: 3.2.6
resolution: "async@npm:3.2.6"
checksum: 10c0/36484bb15ceddf07078688d95e27076379cc2f87b10c03b6dd8a83e89475a3c8df5848859dd06a4c95af1e4c16fc973de0171a77f18ea00be899aca2a4f85e70
languageName: node
linkType: hard

Expand Down Expand Up @@ -2128,9 +2137,9 @@ __metadata:
linkType: hard

"electron-to-chromium@npm:^1.5.4":
version: 1.5.6
resolution: "electron-to-chromium@npm:1.5.6"
checksum: 10c0/1dfef4feaa9f4e5231b8b0697f1f55623eb2ffd263b50e6d4ff995a0927653997ba116640ae06786661f8d24c7b99fa6727c0796e9c60d748f473674d78ab31e
version: 1.5.13
resolution: "electron-to-chromium@npm:1.5.13"
checksum: 10c0/1d88ac39447e1d718c4296f92fe89836df4688daf2d362d6c49108136795f05a56dd9c950f1c6715e0395fa037c3b5f5ea686c543fdc90e6d74a005877c45022
languageName: node
linkType: hard

Expand Down Expand Up @@ -2727,7 +2736,7 @@ __metadata:

"leaflet.sidepanel@https://github.com/maxwell-ilai/Leaflet.SidePanel":
version: 1.0.0
resolution: "leaflet.sidepanel@https://github.com/maxwell-ilai/Leaflet.SidePanel.git#commit=d384da30dab6c5ef98c6b63fb74d0f44906e4447"
resolution: "leaflet.sidepanel@git+ssh://git@github.com/maxwell-ilai/Leaflet.SidePanel.git#commit=d384da30dab6c5ef98c6b63fb74d0f44906e4447"
peerDependencies:
leaflet: ^1.0.0
checksum: 10c0/edd78bfa969f02ee8f6ee6092f5e0c0c72ca41363b6ef261200049a53a841b7005548abe7c7a8db8280db30b87629cbb8ce98c4688170c3ab354659a2abe6ea8
Expand Down Expand Up @@ -3272,6 +3281,7 @@ __metadata:
"@henrygd/queue": "npm:@jsr/henrygd__queue@^1.0.6"
"@nostrify/nostrify": "npm:@jsr/nostrify__nostrify@^0.30.0"
"@parcel/transformer-sass": "npm:2.8.3"
"@shuesken/nostroots-kind30398event": "npm:@jsr/shuesken__nostroots-kind30398event@^0.0.1"
"@types/dompurify": "npm:^3.0.5"
"@types/leaflet": "npm:^1.9.0"
dompurify: "npm:^3.1.4"
Expand Down