diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 5183db8..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "nostr.ts"] - path = nostr.ts - url = https://github.com/BlowaterNostr/nostr.ts diff --git a/channel.ts b/channel.ts index e55850a..78fe194 100644 --- a/channel.ts +++ b/channel.ts @@ -1,30 +1,30 @@ -import { ChannelCreation, ChannelEdition, Kind_V2 } from "./nostr.ts/nostr.ts"; +import { v2 } from "@blowater/nostr-sdk"; import { DB, SqliteError } from "https://deno.land/x/sqlite@v3.8/mod.ts"; export type func_GetChannelByName = ( name: string, -) => Promise<{ create: ChannelCreation; edit?: ChannelEdition } | undefined>; +) => Promise<{ create: v2.ChannelCreation; edit?: v2.ChannelEdition } | undefined>; export type func_GetChannelByID = ( id: string, -) => Promise<{ create: ChannelCreation; edit?: ChannelEdition } | undefined>; +) => Promise<{ create: v2.ChannelCreation; edit?: v2.ChannelEdition } | undefined>; -export type func_CreateChannel = (event: ChannelCreation) => Promise; -export type func_EditChannel = (event: ChannelEdition) => Promise; +export type func_CreateChannel = (event: v2.ChannelCreation) => Promise; +export type func_EditChannel = (event: v2.ChannelEdition) => Promise; export function channel_creation_key(id: string) { - return ["event_v2", Kind_V2.ChannelCreation, id]; + return ["event_v2", v2.Kind_V2.ChannelCreation, id]; } export function channel_edition_key(id: string) { - return ["event_v2", Kind_V2.ChannelEdition, id]; + return ["event_v2", v2.Kind_V2.ChannelEdition, id]; } -export const create_channel_kv = (kv: Deno.Kv): func_CreateChannel => async (event: ChannelCreation) => { +export const create_channel_kv = (kv: Deno.Kv): func_CreateChannel => async (event: v2.ChannelCreation) => { const result = await kv.set(channel_creation_key(event.id), event); return result.ok; }; -export const create_channel_sqlite = (db: DB): func_CreateChannel => async (event: ChannelCreation) => { +export const create_channel_sqlite = (db: DB): func_CreateChannel => async (event: v2.ChannelCreation) => { const rows = db.query( `INSERT INTO channels (channel_id, name, creation_event) VALUES (?, ?, ?);`, [event.id, event.name, JSON.stringify(event)], @@ -32,8 +32,8 @@ export const create_channel_sqlite = (db: DB): func_CreateChannel => async (even return true; }; -export const edit_channel_kv = (kv: Deno.Kv): func_EditChannel => async (event: ChannelEdition) => { - const chan = await kv.get(channel_creation_key(event.channel_id)); +export const edit_channel_kv = (kv: Deno.Kv): func_EditChannel => async (event: v2.ChannelEdition) => { + const chan = await kv.get(channel_creation_key(event.channel_id)); if (chan.value == null) { return new Error(`channel ${event.channel_id} does not exist`); } @@ -49,7 +49,7 @@ export const edit_channel_kv = (kv: Deno.Kv): func_EditChannel => async (event: } }; -export const edit_channel_sqlite = (db: DB): func_EditChannel => async (event: ChannelEdition) => { +export const edit_channel_sqlite = (db: DB): func_EditChannel => async (event: v2.ChannelEdition) => { const channel = await get_channel_by_id_sqlite(db)(event.channel_id); if (channel == undefined) { return new Error(`channel ${event.channel_id} does not exist`); @@ -71,11 +71,11 @@ export const edit_channel_sqlite = (db: DB): func_EditChannel => async (event: C }; export const get_channel_by_id_kv = (kv: Deno.Kv): func_GetChannelByID => async (id: string) => { - const chan = await kv.get(channel_creation_key(id)); + const chan = await kv.get(channel_creation_key(id)); if (chan.value == null) { return undefined; } - const chan_edit = await kv.get(channel_edition_key(id)); + const chan_edit = await kv.get(channel_edition_key(id)); return { create: chan.value, edit: chan_edit.value || undefined, diff --git a/deno.json b/deno.json index 948fd14..fc963a4 100644 --- a/deno.json +++ b/deno.json @@ -18,6 +18,8 @@ "**/_fresh/*" ], "imports": { + "@blowater/nostr-sdk": "jsr:@blowater/nostr-sdk@^0.0.13", + "@std/datetime": "jsr:@std/datetime@^0.224.5", "preact": "https://esm.sh/preact@10.19.6", "preact/": "https://esm.sh/preact@10.19.6/", "tailwindcss": "npm:tailwindcss@3.4.1", diff --git a/deno.lock b/deno.lock new file mode 100644 index 0000000..9025c50 --- /dev/null +++ b/deno.lock @@ -0,0 +1,297 @@ +{ + "version": "3", + "packages": { + "specifiers": { + "jsr:@blowater/collections@^0.0.0-rc1": "jsr:@blowater/collections@0.0.0-rc3", + "jsr:@blowater/csp@1.0.0": "jsr:@blowater/csp@1.0.0", + "jsr:@blowater/nostr-sdk@^0.0.13": "jsr:@blowater/nostr-sdk@0.0.13", + "jsr:@noble/secp256k1@2.1.0": "jsr:@noble/secp256k1@2.1.0", + "jsr:@std/assert@0.226.0": "jsr:@std/assert@0.226.0", + "jsr:@std/datetime@0.224.1": "jsr:@std/datetime@0.224.1", + "jsr:@std/datetime@^0.224.5": "jsr:@std/datetime@0.224.5", + "jsr:@std/encoding@0.224.3": "jsr:@std/encoding@0.224.3", + "jsr:@std/internal@^1.0.0": "jsr:@std/internal@1.0.1", + "npm:@noble/ciphers@0.4.1": "npm:@noble/ciphers@0.4.1", + "npm:@noble/curves@1.4.0": "npm:@noble/curves@1.4.0", + "npm:@noble/hashes@1.4.0": "npm:@noble/hashes@1.4.0", + "npm:@scure/bip32@1.3.2": "npm:@scure/bip32@1.3.2", + "npm:@scure/bip39@1.2.1": "npm:@scure/bip39@1.2.1", + "npm:json-stable-stringify@1.1.1": "npm:json-stable-stringify@1.1.1", + "npm:zod@3.23.8": "npm:zod@3.23.8" + }, + "jsr": { + "@blowater/collections@0.0.0-rc3": { + "integrity": "54cdc175266e16d50aaf780885b6e6eb3009f99c66641ff9b0c6c60f5b6e629d" + }, + "@blowater/csp@1.0.0": { + "integrity": "415d4e8bf1656e4a508997fb8e725e9372e1e39b2b714afa76e86efd733f8c4c" + }, + "@blowater/nostr-sdk@0.0.13": { + "integrity": "0135d7f3ec6ce8c7e0ece2704c27dbb4ad2c5c7dfb0e5e1925c50cb1b117c3a7", + "dependencies": [ + "jsr:@blowater/collections@^0.0.0-rc1", + "jsr:@blowater/csp@1.0.0", + "jsr:@noble/secp256k1@2.1.0", + "jsr:@std/assert@0.226.0", + "jsr:@std/datetime@0.224.1", + "jsr:@std/encoding@0.224.3", + "npm:@noble/ciphers@0.4.1", + "npm:@noble/curves@1.4.0", + "npm:@noble/hashes@1.4.0", + "npm:@scure/bip32@1.3.2", + "npm:@scure/bip39@1.2.1", + "npm:json-stable-stringify@1.1.1", + "npm:zod@3.23.8" + ] + }, + "@noble/secp256k1@2.1.0": { + "integrity": "b5843dfb90c67026ec5d2771cc2c809155fa5954ff0300b23de5d4a1f4eec758" + }, + "@std/assert@0.226.0": { + "integrity": "0dfb5f7c7723c18cec118e080fec76ce15b4c31154b15ad2bd74822603ef75b3", + "dependencies": [ + "jsr:@std/internal@^1.0.0" + ] + }, + "@std/datetime@0.224.1": { + "integrity": "3b4d5062333a3fe2e8f94b343e05e8c34ec8b09e2e8311fe0e879a6773075830" + }, + "@std/datetime@0.224.5": { + "integrity": "363fca6e2e46c1e85139c10ba77745d25c0936abd112b8bfdc9b8fc3615added" + }, + "@std/encoding@0.224.3": { + "integrity": "5e861b6d81be5359fad4155e591acf17c0207b595112d1840998bb9f476dbdaf" + }, + "@std/internal@1.0.1": { + "integrity": "6f8c7544d06a11dd256c8d6ba54b11ed870aac6c5aeafff499892662c57673e6" + } + }, + "npm": { + "@noble/ciphers@0.4.1": { + "integrity": "sha512-QCOA9cgf3Rc33owG0AYBB9wszz+Ul2kramWN8tXG44Gyciud/tbkEqvxRF/IpqQaBpRBNi9f4jdNxqB2CQCIXg==", + "dependencies": {} + }, + "@noble/curves@1.2.0": { + "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "dependencies": { + "@noble/hashes": "@noble/hashes@1.3.2" + } + }, + "@noble/curves@1.4.0": { + "integrity": "sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==", + "dependencies": { + "@noble/hashes": "@noble/hashes@1.4.0" + } + }, + "@noble/hashes@1.3.2": { + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "dependencies": {} + }, + "@noble/hashes@1.3.3": { + "integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==", + "dependencies": {} + }, + "@noble/hashes@1.4.0": { + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "dependencies": {} + }, + "@scure/base@1.1.7": { + "integrity": "sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g==", + "dependencies": {} + }, + "@scure/bip32@1.3.2": { + "integrity": "sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==", + "dependencies": { + "@noble/curves": "@noble/curves@1.2.0", + "@noble/hashes": "@noble/hashes@1.3.3", + "@scure/base": "@scure/base@1.1.7" + } + }, + "@scure/bip39@1.2.1": { + "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", + "dependencies": { + "@noble/hashes": "@noble/hashes@1.3.3", + "@scure/base": "@scure/base@1.1.7" + } + }, + "call-bind@1.0.7": { + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dependencies": { + "es-define-property": "es-define-property@1.0.0", + "es-errors": "es-errors@1.3.0", + "function-bind": "function-bind@1.1.2", + "get-intrinsic": "get-intrinsic@1.2.4", + "set-function-length": "set-function-length@1.2.2" + } + }, + "define-data-property@1.1.4": { + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dependencies": { + "es-define-property": "es-define-property@1.0.0", + "es-errors": "es-errors@1.3.0", + "gopd": "gopd@1.0.1" + } + }, + "es-define-property@1.0.0": { + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "get-intrinsic@1.2.4" + } + }, + "es-errors@1.3.0": { + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dependencies": {} + }, + "function-bind@1.1.2": { + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dependencies": {} + }, + "get-intrinsic@1.2.4": { + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dependencies": { + "es-errors": "es-errors@1.3.0", + "function-bind": "function-bind@1.1.2", + "has-proto": "has-proto@1.0.3", + "has-symbols": "has-symbols@1.0.3", + "hasown": "hasown@2.0.2" + } + }, + "gopd@1.0.1": { + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "get-intrinsic@1.2.4" + } + }, + "has-property-descriptors@1.0.2": { + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "es-define-property@1.0.0" + } + }, + "has-proto@1.0.3": { + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "dependencies": {} + }, + "has-symbols@1.0.3": { + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dependencies": {} + }, + "hasown@2.0.2": { + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dependencies": { + "function-bind": "function-bind@1.1.2" + } + }, + "isarray@2.0.5": { + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dependencies": {} + }, + "json-stable-stringify@1.1.1": { + "integrity": "sha512-SU/971Kt5qVQfJpyDveVhQ/vya+5hvrjClFOcr8c0Fq5aODJjMwutrOfCU+eCnVD5gpx1Q3fEqkyom77zH1iIg==", + "dependencies": { + "call-bind": "call-bind@1.0.7", + "isarray": "isarray@2.0.5", + "jsonify": "jsonify@0.0.1", + "object-keys": "object-keys@1.1.1" + } + }, + "jsonify@0.0.1": { + "integrity": "sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==", + "dependencies": {} + }, + "object-keys@1.1.1": { + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dependencies": {} + }, + "set-function-length@1.2.2": { + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "define-data-property@1.1.4", + "es-errors": "es-errors@1.3.0", + "function-bind": "function-bind@1.1.2", + "get-intrinsic": "get-intrinsic@1.2.4", + "gopd": "gopd@1.0.1", + "has-property-descriptors": "has-property-descriptors@1.0.2" + } + }, + "zod@3.23.8": { + "integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==", + "dependencies": {} + } + } + }, + "remote": { + "https://deno.land/std@0.220.1/assert/_constants.ts": "a271e8ef5a573f1df8e822a6eb9d09df064ad66a4390f21b3e31f820a38e0975", + "https://deno.land/std@0.220.1/assert/_diff.ts": "4bf42969aa8b1a33aaf23eb8e478b011bfaa31b82d85d2ff4b5c4662d8780d2b", + "https://deno.land/std@0.220.1/assert/_format.ts": "0ba808961bf678437fb486b56405b6fefad2cf87b5809667c781ddee8c32aff4", + "https://deno.land/std@0.220.1/assert/assert_equals.ts": "4497c56fe7d2993b0d447926702802fc0becb44e319079e8eca39b482ee01b4e", + "https://deno.land/std@0.220.1/assert/assertion_error.ts": "9f689a101ee586c4ce92f52fa7ddd362e86434ffdf1f848e45987dc7689976b8", + "https://deno.land/std@0.220.1/assert/equal.ts": "fae5e8a52a11d3ac694bbe1a53e13a7969e3f60791262312e91a3e741ae519e2", + "https://deno.land/std@0.220.1/fmt/colors.ts": "d239d84620b921ea520125d778947881f62c50e78deef2657073840b8af9559a", + "https://deno.land/std@0.224.0/assert/_constants.ts": "a271e8ef5a573f1df8e822a6eb9d09df064ad66a4390f21b3e31f820a38e0975", + "https://deno.land/std@0.224.0/assert/assert.ts": "09d30564c09de846855b7b071e62b5974b001bb72a4b797958fe0660e7849834", + "https://deno.land/std@0.224.0/assert/assert_almost_equals.ts": "9e416114322012c9a21fa68e187637ce2d7df25bcbdbfd957cd639e65d3cf293", + "https://deno.land/std@0.224.0/assert/assert_array_includes.ts": "14c5094471bc8e4a7895fc6aa5a184300d8a1879606574cb1cd715ef36a4a3c7", + "https://deno.land/std@0.224.0/assert/assert_equals.ts": "3bbca947d85b9d374a108687b1a8ba3785a7850436b5a8930d81f34a32cb8c74", + "https://deno.land/std@0.224.0/assert/assert_exists.ts": "43420cf7f956748ae6ed1230646567b3593cb7a36c5a5327269279c870c5ddfd", + "https://deno.land/std@0.224.0/assert/assert_false.ts": "3e9be8e33275db00d952e9acb0cd29481a44fa0a4af6d37239ff58d79e8edeff", + "https://deno.land/std@0.224.0/assert/assert_greater.ts": "5e57b201fd51b64ced36c828e3dfd773412c1a6120c1a5a99066c9b261974e46", + "https://deno.land/std@0.224.0/assert/assert_greater_or_equal.ts": "9870030f997a08361b6f63400273c2fb1856f5db86c0c3852aab2a002e425c5b", + "https://deno.land/std@0.224.0/assert/assert_instance_of.ts": "e22343c1fdcacfaea8f37784ad782683ec1cf599ae9b1b618954e9c22f376f2c", + "https://deno.land/std@0.224.0/assert/assert_is_error.ts": "f856b3bc978a7aa6a601f3fec6603491ab6255118afa6baa84b04426dd3cc491", + "https://deno.land/std@0.224.0/assert/assert_less.ts": "60b61e13a1982865a72726a5fa86c24fad7eb27c3c08b13883fb68882b307f68", + "https://deno.land/std@0.224.0/assert/assert_less_or_equal.ts": "d2c84e17faba4afe085e6c9123a63395accf4f9e00150db899c46e67420e0ec3", + "https://deno.land/std@0.224.0/assert/assert_match.ts": "ace1710dd3b2811c391946954234b5da910c5665aed817943d086d4d4871a8b7", + "https://deno.land/std@0.224.0/assert/assert_not_equals.ts": "78d45dd46133d76ce624b2c6c09392f6110f0df9b73f911d20208a68dee2ef29", + "https://deno.land/std@0.224.0/assert/assert_not_instance_of.ts": "3434a669b4d20cdcc5359779301a0588f941ffdc2ad68803c31eabdb4890cf7a", + "https://deno.land/std@0.224.0/assert/assert_not_match.ts": "df30417240aa2d35b1ea44df7e541991348a063d9ee823430e0b58079a72242a", + "https://deno.land/std@0.224.0/assert/assert_not_strict_equals.ts": "37f73880bd672709373d6dc2c5f148691119bed161f3020fff3548a0496f71b8", + "https://deno.land/std@0.224.0/assert/assert_object_match.ts": "411450fd194fdaabc0089ae68f916b545a49d7b7e6d0026e84a54c9e7eed2693", + "https://deno.land/std@0.224.0/assert/assert_rejects.ts": "4bee1d6d565a5b623146a14668da8f9eb1f026a4f338bbf92b37e43e0aa53c31", + "https://deno.land/std@0.224.0/assert/assert_strict_equals.ts": "b4f45f0fd2e54d9029171876bd0b42dd9ed0efd8f853ab92a3f50127acfa54f5", + "https://deno.land/std@0.224.0/assert/assert_string_includes.ts": "496b9ecad84deab72c8718735373feb6cdaa071eb91a98206f6f3cb4285e71b8", + "https://deno.land/std@0.224.0/assert/assert_throws.ts": "c6508b2879d465898dab2798009299867e67c570d7d34c90a2d235e4553906eb", + "https://deno.land/std@0.224.0/assert/assertion_error.ts": "ba8752bd27ebc51f723702fac2f54d3e94447598f54264a6653d6413738a8917", + "https://deno.land/std@0.224.0/assert/equal.ts": "bddf07bb5fc718e10bb72d5dc2c36c1ce5a8bdd3b647069b6319e07af181ac47", + "https://deno.land/std@0.224.0/assert/fail.ts": "0eba674ffb47dff083f02ced76d5130460bff1a9a68c6514ebe0cdea4abadb68", + "https://deno.land/std@0.224.0/assert/mod.ts": "48b8cb8a619ea0b7958ad7ee9376500fe902284bb36f0e32c598c3dc34cbd6f3", + "https://deno.land/std@0.224.0/assert/unimplemented.ts": "8c55a5793e9147b4f1ef68cd66496b7d5ba7a9e7ca30c6da070c1a58da723d73", + "https://deno.land/std@0.224.0/assert/unreachable.ts": "5ae3dbf63ef988615b93eb08d395dda771c96546565f9e521ed86f6510c29e19", + "https://deno.land/std@0.224.0/fmt/colors.ts": "508563c0659dd7198ba4bbf87e97f654af3c34eb56ba790260f252ad8012e1c5", + "https://deno.land/std@0.224.0/http/cookie.ts": "a377fa60175ba5f61dd4b8a70b34f2bbfbc70782dfd5faf36d314c42e4306006", + "https://deno.land/std@0.224.0/internal/diff.ts": "6234a4b493ebe65dc67a18a0eb97ef683626a1166a1906232ce186ae9f65f4e6", + "https://deno.land/std@0.224.0/internal/format.ts": "0a98ee226fd3d43450245b1844b47003419d34d210fa989900861c79820d21c2", + "https://deno.land/std@0.224.0/internal/mod.ts": "534125398c8e7426183e12dc255bb635d94e06d0f93c60a297723abe69d3b22e", + "https://deno.land/x/graphql_tag@0.1.2/deps.ts": "5696461c8bb42db7c83486db452e125f7cfdc62a2c628bb470a4447d934b90b3", + "https://deno.land/x/graphql_tag@0.1.2/mod.ts": "57fd56de5f7cbc66e23ce896cc8e99521d286e89969d83e09d960642b0a9d652", + "https://deno.land/x/sqlite@v3.8/build/sqlite.js": "72f63689fffcb9bb5ae10b1e8f7db09ea845cdf713e0e3a9693d8416a28f92a6", + "https://deno.land/x/sqlite@v3.8/build/vfs.js": "08533cc78fb29b9d9bd62f6bb93e5ef333407013fed185776808f11223ba0e70", + "https://deno.land/x/sqlite@v3.8/mod.ts": "e09fc79d8065fe222578114b109b1fd60077bff1bb75448532077f784f4d6a83", + "https://deno.land/x/sqlite@v3.8/src/constants.ts": "90f3be047ec0a89bcb5d6fc30db121685fc82cb00b1c476124ff47a4b0472aa9", + "https://deno.land/x/sqlite@v3.8/src/db.ts": "7d3251021756fa80f382c3952217c7446c5c8c1642b63511da0938fe33562663", + "https://deno.land/x/sqlite@v3.8/src/error.ts": "f7a15cb00d7c3797da1aefee3cf86d23e0ae92e73f0ba3165496c3816ab9503a", + "https://deno.land/x/sqlite@v3.8/src/function.ts": "e4c83b8ec64bf88bafad2407376b0c6a3b54e777593c70336fb40d43a79865f2", + "https://deno.land/x/sqlite@v3.8/src/query.ts": "d58abda928f6582d77bad685ecf551b1be8a15e8e38403e293ec38522e030cad", + "https://deno.land/x/sqlite@v3.8/src/wasm.ts": "e79d0baa6e42423257fb3c7cc98091c54399254867e0f34a09b5bdef37bd9487", + "https://esm.sh/graphql@16.6.0/language/ast#=": "3370c36acfd7dc994d7f2242361dbc538b7b239f0cb41603f97a5d67273f5255", + "https://esm.sh/graphql@16.6.0/language/parser#=": "38b1158134aed40573b9885cc5f3b020fe8b60c75aa8b32420388c577615b97a", + "https://esm.sh/graphql@16.8.1": "50c951dc0b67f3f01e70d1511ca68ebb067ef99d3590d6a7afb36819c84595f9", + "https://esm.sh/preact-render-to-string@6.4.1": "502d356922296aa8b105dbbf7de0e43d41146966e7af4c485053d64627029c98", + "https://esm.sh/preact@10.19.6/jsx-runtime": "f4c9e5f72ef18435eab846ae02e315a63da724f64fb08d806d2ddeaf08d99bd8", + "https://esm.sh/stable/preact@10.19.6/denonext/jsx-runtime.js": "97e9eeb40443de53a8cb3b70f264d04db2bbfc5c2298fdb15d1c471283ccd6aa", + "https://esm.sh/stable/preact@10.19.6/denonext/preact.mjs": "68491395d287895f4d697e403ded5b0ebb8fed0494f9e870c422bc017e5e52f5", + "https://esm.sh/stable/preact@10.20.0/denonext/preact.mjs": "323ac0dab4ede066d3ef67ae2f51029ed1bd5f81f5a07982924a00aee3c54ada", + "https://esm.sh/stable/preact@10.20.2/denonext/preact.mjs": "f418bc70c24b785703afb9d4dea8cdc1e315e43c8df620a0c52fd27ad9bd70eb", + "https://esm.sh/v135/graphql@16.6.0/denonext/language/ast.js": "1c8cc697db4ec96d354496fa69a2d6552ec5801a6c3bdbe5505f369d872d594c", + "https://esm.sh/v135/graphql@16.6.0/denonext/language/parser.js": "82063e5ee234089909652e04ccd9f0e1c0670c04ac6db896099a638ae759b182", + "https://esm.sh/v135/graphql@16.8.1/denonext/graphql.mjs": "585b84022623b931e27a7a8134cd24ec50b33ea12fd18b43254527628a0fddac", + "https://esm.sh/v135/preact-render-to-string@6.4.1/denonext/preact-render-to-string.mjs": "0226110b9ae616d3143c7ea00b822faa1cdd96588188fc3f28e2bf8ead94ba4f" + }, + "workspace": { + "dependencies": [ + "jsr:@blowater/nostr-sdk@^0.0.13", + "jsr:@std/datetime@^0.224.5", + "npm:tailwindcss@3.4.1" + ] + } +} diff --git a/main.ts b/main.ts index d76b5dd..6799472 100644 --- a/main.ts +++ b/main.ts @@ -30,7 +30,6 @@ import Landing from "./routes/landing.tsx"; import Error404 from "./routes/_404.tsx"; import { RelayInfomationBase, RelayInformation, RelayInformationStore } from "./resolvers/nip11.ts"; import { Cookie, getCookies, setCookie } from "https://deno.land/std@0.224.0/http/cookie.ts"; -import { Event_V2, Kind_V2, NostrEvent, NostrKind, verify_event_v2, verifyEvent } from "./nostr.ts/nostr.ts"; import { create_channel_sqlite, edit_channel_sqlite, @@ -47,8 +46,8 @@ import { func_DeleteEventsFromPubkey, func_GetDeletedEventIDs, } from "./resolvers/event_deletion.ts"; -import { PublicKey } from "./nostr.ts/key.ts"; -import { parseJSON } from "./nostr.ts/_helper.ts"; + +import { NostrEvent, NostrKind, parseJSON, PublicKey, v2, verifyEvent } from "@blowater/nostr-sdk"; const schema = gql.buildSchema(gql.print(typeDefs)); @@ -475,31 +474,31 @@ const event_v2_handler = (args: { }) => async (req: Request) => { const text = await req.text(); - const event = parseJSON(text); + const event = parseJSON(text); if (event instanceof Error) { return new Response(event.message, { status: 400, }); } - const ok = await verify_event_v2(event); + const ok = await v2.verify_event_v2(event); if (!ok) { console.error("event", event); return new Response("event is not valid", { status: 400 }); } - if (event.kind == Kind_V2.ChannelCreation) { + if (event.kind == v2.Kind_V2.ChannelCreation) { const ok = await args.create_channel(event); if (ok) { return new Response(); } else { return new Response("failed to write event", { status: 400 }); } - } else if (event.kind == Kind_V2.ChannelEdition) { + } else if (event.kind == v2.Kind_V2.ChannelEdition) { const res = await args.edit_channel(event); if (res instanceof Error) { return new Response(res.message, { status: 400 }); } return new Response(); - } else if (event.kind == Kind_V2.SpaceMember) { + } else if (event.kind == v2.Kind_V2.SpaceMember) { const res = await args.add_space_member(event); if (res instanceof Error) { console.error(res); diff --git a/makefile b/makefile index 242486d..4af1eeb 100644 --- a/makefile +++ b/makefile @@ -11,7 +11,7 @@ fmt: deno fmt test: fmt - deno test --lock deno.test.lock \ + deno test --lock --lock-write deno.test.lock \ --trace-leaks --unstable-kv \ --allow-read=queries,test.sqlite,relayed.db,relayed.db-journal \ --allow-net --allow-write --allow-ffi \ diff --git a/nostr.ts b/nostr.ts deleted file mode 160000 index 7534e65..0000000 --- a/nostr.ts +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7534e6521edbe1d3fd114617e1396ca6856b3b30 diff --git a/resolvers/event.ts b/resolvers/event.ts index 401e7b5..d908ddc 100644 --- a/resolvers/event.ts +++ b/resolvers/event.ts @@ -1,5 +1,5 @@ import { DB, SqliteError } from "https://deno.land/x/sqlite@v3.8/mod.ts"; -import { NostrEvent, NostrFilter, NostrKind } from "../nostr.ts/nostr.ts"; +import { NostrEvent, NostrFilter, NostrKind } from "@blowater/nostr-sdk"; export type func_GetEventsByIDs = (ids: Set) => AsyncIterable; export type interface_GetEventsByIDs = { diff --git a/resolvers/event_deletion.ts b/resolvers/event_deletion.ts index 458d960..88b2660 100644 --- a/resolvers/event_deletion.ts +++ b/resolvers/event_deletion.ts @@ -1,5 +1,5 @@ import { DB } from "https://deno.land/x/sqlite@v3.8/mod.ts"; -import { PublicKey } from "../nostr.ts/key.ts"; +import { PublicKey } from "@blowater/nostr-sdk"; export type func_DeleteEvent = (event_id: string) => Promise; export type func_DeleteEventsFromPubkey = (pubkey: string | PublicKey) => Promise; diff --git a/resolvers/nip11.ts b/resolvers/nip11.ts index 6292f04..5b86e91 100644 --- a/resolvers/nip11.ts +++ b/resolvers/nip11.ts @@ -1,5 +1,5 @@ +import { PublicKey } from "@blowater/nostr-sdk"; import { software, supported_nips } from "../main.ts"; -import { PublicKey } from "../nostr.ts/key.ts"; export type RelayInfomationBase = { name?: string; diff --git a/resolvers/policy.ts b/resolvers/policy.ts index 2a13b57..a3585c9 100644 --- a/resolvers/policy.ts +++ b/resolvers/policy.ts @@ -1,9 +1,7 @@ import { DB } from "https://deno.land/x/sqlite@v3.8/mod.ts"; import { DefaultPolicy } from "../main.ts"; -import { Kind_V2, SpaceMember, verify_event_v2 } from "../nostr.ts/nostr.ts"; -import { parseJSON } from "../nostr.ts/_helper.ts"; -import { PublicKey } from "../nostr.ts/key.ts"; -import { NostrKind } from "../nostr.ts/nostr.ts"; + +import { NostrKind, parseJSON, PublicKey, v2 } from "@blowater/nostr-sdk"; export const Policies = (kv: Deno.Kv) => async function () { @@ -111,18 +109,18 @@ export class PolicyStore { }; } -export type func_GetSpaceMembers = () => Promise; -export type func_AddSpaceMember = (event: SpaceMember) => Promise; +export type func_GetSpaceMembers = () => Promise; +export type func_AddSpaceMember = (event: v2.SpaceMember) => Promise; export type func_IsSpaceMember = (pubkey: string) => Promise; export const get_space_members = (db: DB): func_GetSpaceMembers => async () => { const rows = db.query<[string]>( "select event from events_v2 where kind = (?)", - [Kind_V2.SpaceMember], + [v2.Kind_V2.SpaceMember], ); - const events = [] as SpaceMember[]; + const events = [] as v2.SpaceMember[]; for (const row of rows) { - const space_member_event = parseJSON(row[0]); + const space_member_event = parseJSON(row[0]); if (space_member_event instanceof Error) { return space_member_event; } @@ -132,7 +130,7 @@ export const get_space_members = (db: DB): func_GetSpaceMembers => async () => { }; export const add_space_member = - (args: { admin: PublicKey; db: DB }): func_AddSpaceMember => async (event: SpaceMember) => { + (args: { admin: PublicKey; db: DB }): func_AddSpaceMember => async (event: v2.SpaceMember) => { if (event.pubkey != args.admin.hex) { return new Error("Only administrators can add members to the space."); } @@ -155,7 +153,7 @@ export const is_space_member = try { const rows = args.db.query<[string]>( "select event from events_v2 where kind = (?) and json_extract(event, '$.member') = (?)", - [Kind_V2.SpaceMember, pubkey], + [v2.Kind_V2.SpaceMember, pubkey], ); return rows.length > 0; } catch (e) { diff --git a/resolvers/root.ts b/resolvers/root.ts index 9fa42e2..a14c116 100644 --- a/resolvers/root.ts +++ b/resolvers/root.ts @@ -3,7 +3,7 @@ import { Policies } from "./policy.ts"; import { RelayInformationStore } from "./nip11.ts"; import { func_GetEventCount } from "./event.ts"; import { func_DeleteEvent, func_DeleteEventsFromPubkey, func_GetDeletedEventIDs } from "./event_deletion.ts"; -import { NostrKind } from "../nostr.ts/nostr.ts"; +import { NostrKind } from "@blowater/nostr-sdk"; export function RootResolver({ deps }: { deps: { diff --git a/tests/space-member-test.ts b/tests/space-member-test.ts index 3bbcb49..dfe324b 100644 --- a/tests/space-member-test.ts +++ b/tests/space-member-test.ts @@ -1,8 +1,8 @@ import { Relay, run } from "../main.ts"; -import { InMemoryAccountContext } from "../nostr.ts/nostr.ts"; + import { fail } from "https://deno.land/std@0.224.0/assert/fail.ts"; import { assertEquals } from "https://deno.land/std@0.220.1/assert/assert_equals.ts"; -import { prepareSpaceMember } from "../nostr.ts/space-member.ts"; +import { InMemoryAccountContext, v2 } from "@blowater/nostr-sdk"; const test_ctx = InMemoryAccountContext.Generate(); const test_kv = async () => { @@ -24,7 +24,7 @@ Deno.test("Space Member", async (t) => { const new_member = InMemoryAccountContext.Generate(); await t.step("admin can add member", async () => { - const add_member_event = await prepareSpaceMember(test_ctx, new_member.publicKey.hex); + const add_member_event = await v2.prepareSpaceMember(test_ctx, new_member.publicKey.hex); if (add_member_event instanceof Error) fail(add_member_event.message); const r = await fetch(`${relay.http_url}`, { method: "POST", @@ -39,7 +39,7 @@ Deno.test("Space Member", async (t) => { await t.step("other can not add member", async () => { const other = InMemoryAccountContext.Generate(); - const add_member_event = await prepareSpaceMember(other, new_member.publicKey.hex); + const add_member_event = await v2.prepareSpaceMember(other, new_member.publicKey.hex); if (add_member_event instanceof Error) fail(add_member_event.message); const r = await fetch(`${relay.http_url}`, { method: "POST", @@ -53,7 +53,7 @@ Deno.test("Space Member", async (t) => { }); await t.step("it it already a member", async () => { - const redo = await prepareSpaceMember(test_ctx, new_member.publicKey.hex); + const redo = await v2.prepareSpaceMember(test_ctx, new_member.publicKey.hex); if (redo instanceof Error) fail(redo.message); const r = await fetch(`${relay.http_url}`, { method: "POST", diff --git a/tests/test.ts b/tests/test.ts index 91d7554..ca0b3d4 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -7,23 +7,19 @@ import { } from "https://deno.land/std@0.224.0/assert/mod.ts"; import { fail } from "https://deno.land/std@0.224.0/assert/fail.ts"; -import * as client_test from "../nostr.ts/relay-single-test.ts"; import { - ChannelCreation, - ChannelEdition, InMemoryAccountContext, - Kind_V2, NostrKind, + prepareNostrEvent, + PrivateKey, + RelayRejectedEvent, RelayResponse_Event, - Signer, -} from "../nostr.ts/nostr.ts"; -import { prepareNormalNostrEvent } from "../nostr.ts/event.ts"; -import { RelayRejectedEvent, SingleRelayConnection, SubscriptionStream } from "../nostr.ts/relay-single.ts"; -import { PrivateKey } from "../nostr.ts/key.ts"; -import { sleep } from "https://raw.githubusercontent.com/BlowaterNostr/csp/master/csp.ts"; -import { RFC3339 } from "../nostr.ts/_helper.ts"; -import { format } from "https://deno.land/std@0.224.0/datetime/format.ts"; -import { prepareSpaceMember } from "../nostr.ts/space-member.ts"; + SingleRelayConnection, + SubscriptionStream, + v2, +} from "@blowater/nostr-sdk"; + +import { sleep } from "jsr:@blowater/csp@1.0.0"; const test_kv = async () => { try { @@ -34,7 +30,7 @@ const test_kv = async () => { const test_ctx = InMemoryAccountContext.Generate(); const test_auth_event = async () => { - const event = await prepareNormalNostrEvent(test_ctx, { + const event = await prepareNostrEvent(test_ctx, { kind: NostrKind.TEXT_NOTE, content: "", }); @@ -66,7 +62,7 @@ Deno.test({ // relay logic const ctx = InMemoryAccountContext.Generate(); - const client = SingleRelayConnection.New(relay.ws_url, { log: false }); + const client = SingleRelayConnection.New(relay.ws_url, { log: false }) as SingleRelayConnection; { // because default policy allows no kinds @@ -118,16 +114,6 @@ Deno.test({ assertIsError(err, Error); }); - await t.step("client_test", async () => { - await client_test.limit(relay.ws_url)(); - await client_test.no_event(relay.ws_url)(); - await client_test.newSub_multiple_filters(relay.ws_url)(); - await client_test.two_clients_communicate(relay.ws_url)(); - await client_test.get_event_by_id(relay.ws_url)(); - await client_test.close_sub_keep_reading(relay.ws_url)(); - await client_test.get_correct_kind(relay.ws_url)(); - }); - await client.close(); await relay.shutdown(); }, @@ -145,7 +131,7 @@ Deno.test({ }, kv: await test_kv(), }) as Relay; - const client = SingleRelayConnection.New(relay.ws_url); + const client = SingleRelayConnection.New(relay.ws_url) as SingleRelayConnection; { const ctx1 = InMemoryAccountContext.Generate(); const ctx2 = InMemoryAccountContext.Generate(); @@ -155,14 +141,14 @@ Deno.test({ }); if (err instanceof Error) fail(err.message); - const event1 = await prepareNormalNostrEvent(ctx1, { + const event1 = await prepareNostrEvent(ctx1, { kind: 1, content: "1", }); const err1 = await client.sendEvent(event1); if (err1 instanceof Error) fail(err1.message); - const event2 = await prepareNormalNostrEvent(ctx2, { + const event2 = await prepareNostrEvent(ctx2, { kind: 1, content: "2", }); @@ -178,74 +164,6 @@ Deno.test({ }, }); -Deno.test({ - name: "channel", - // ignore: true, - fn: async () => { - const relay = await run({ - auth_required: false, - admin: test_ctx.publicKey, - default_policy: { - allowed_kinds: "none", - }, - kv: await test_kv(), - // system_key: PrivateKey.Generate(), - }); - if (relay instanceof Error) { - console.error(relay); - fail(relay.message); - } - - { - const ctx = InMemoryAccountContext.Generate(); - const ChannelCreation_event: ChannelCreation = await ctx.signEventV2({ - pubkey: ctx.publicKey.hex, - kind: Kind_V2.ChannelCreation, - name: "test", - scope: "server", - created_at: format(new Date(), RFC3339), - }); - const r = await fetch(`${relay.http_url}`, { - method: "POST", - body: JSON.stringify(ChannelCreation_event), - }); - await r.text(); - assertEquals(r.status, 200); - - // get the channel - const chan = await relay.get_channel_by_id(ChannelCreation_event.id); - assertEquals(chan, { - create: ChannelCreation_event as ChannelCreation, - edit: undefined, - }); - - // edit the channel - const event_edit = await ctx.signEventV2({ - pubkey: ctx.publicKey.hex, - kind: Kind_V2.ChannelEdition, - channel_id: ChannelCreation_event.id, - name: "test2", - scope: "server", - created_at: format(new Date(), RFC3339), - }); - const r2 = await fetch(`${relay.http_url}`, { - method: "POST", - body: JSON.stringify(event_edit), - }); - - assertEquals(r2.status, 200, await r2.text()); - - // get the channel - const chan2 = await relay.get_channel_by_id(ChannelCreation_event.id); - assertEquals(chan2, { - create: ChannelCreation_event as ChannelCreation, - edit: event_edit as ChannelEdition, - }); - } - await relay.shutdown(); - }, -}); - // https://github.com/nostr-protocol/nips/blob/master/01.md#kinds // https://github.com/nostr-protocol/nips/blob/master/11.md Deno.test({ @@ -383,7 +301,7 @@ Deno.test({ await t.step("admin is always allowed", async () => { const client = SingleRelayConnection.New(relay.ws_url, { signer: ctx, - }); + }) as SingleRelayConnection; const err = await client.newSub("", {}); assertNotInstanceOf(err, Error); await client.close(); @@ -391,12 +309,12 @@ Deno.test({ await t.step("a member is allowed", async () => { const user = InMemoryAccountContext.Generate(); - const spaceMemberEvennt = await prepareSpaceMember(ctx, user.publicKey.hex); + const spaceMemberEvennt = await v2.prepareSpaceMember(ctx, user.publicKey.hex); if (spaceMemberEvennt instanceof Error) fail(spaceMemberEvennt.message); await relay.add_space_member(spaceMemberEvennt); const client = SingleRelayConnection.New(relay.ws_url, { signer: user, - }); + }) as SingleRelayConnection; await sleep(10); const err = await client.newSub("", {}); if (err instanceof Error) fail(err.message); @@ -406,7 +324,7 @@ Deno.test({ await t.step("stranger is blocked", async () => { const client = SingleRelayConnection.New(relay.ws_url, { signer: InMemoryAccountContext.Generate(), - }); + }) as SingleRelayConnection; await sleep(30); const err = await client.newSub("", {}); assertIsError(err, Error); @@ -417,7 +335,7 @@ Deno.test({ }); async function randomEvent(ctx: InMemoryAccountContext, kind?: NostrKind, content?: string) { - const event = await prepareNormalNostrEvent(ctx, { + const event = await prepareNostrEvent(ctx, { kind: kind || NostrKind.TEXT_NOTE, content: content || "", }); diff --git a/tests/v2.ts b/tests/v2.ts new file mode 100644 index 0000000..c558bd6 --- /dev/null +++ b/tests/v2.ts @@ -0,0 +1,82 @@ +import { assertEquals } from "https://deno.land/std@0.224.0/assert/assert_equals.ts"; +import { fail } from "https://deno.land/std@0.224.0/assert/fail.ts"; +import { format } from "@std/datetime"; + +import { InMemoryAccountContext, RFC3339, v2 } from "@blowater/nostr-sdk"; +import { run } from "../main.ts"; + +const test_ctx = InMemoryAccountContext.Generate(); +const test_kv = async () => { + try { + await Deno.remove("test.sqlite"); + } catch (e) {} + return await Deno.openKv("test.sqlite"); +}; + +Deno.test({ + name: "channel", + // ignore: true, + fn: async () => { + const relay = await run({ + auth_required: false, + admin: test_ctx.publicKey, + default_policy: { + allowed_kinds: "none", + }, + kv: await test_kv(), + // system_key: PrivateKey.Generate(), + }); + if (relay instanceof Error) { + console.error(relay); + fail(relay.message); + } + + { + const ctx = InMemoryAccountContext.Generate(); + const ChannelCreation_event: v2.ChannelCreation = await ctx.signEventV2({ + pubkey: ctx.publicKey.hex, + kind: v2.Kind_V2.ChannelCreation, + name: "test", + scope: "server", + created_at: format(new Date(), RFC3339), + }); + const r = await fetch(`${relay.http_url}`, { + method: "POST", + body: JSON.stringify(ChannelCreation_event), + }); + await r.text(); + assertEquals(r.status, 200); + + // get the channel + const chan = await relay.get_channel_by_id(ChannelCreation_event.id); + assertEquals(chan, { + create: ChannelCreation_event as v2.ChannelCreation, + edit: undefined, + }); + + // edit the channel + const event_edit = await ctx.signEventV2({ + pubkey: ctx.publicKey.hex, + kind: v2.Kind_V2.ChannelEdition, + channel_id: ChannelCreation_event.id, + name: "test2", + scope: "server", + created_at: format(new Date(), RFC3339), + }); + const r2 = await fetch(`${relay.http_url}`, { + method: "POST", + body: JSON.stringify(event_edit), + }); + + assertEquals(r2.status, 200, await r2.text()); + + // get the channel + const chan2 = await relay.get_channel_by_id(ChannelCreation_event.id); + assertEquals(chan2, { + create: ChannelCreation_event as v2.ChannelCreation, + edit: event_edit as v2.ChannelEdition, + }); + } + await relay.shutdown(); + }, +}); diff --git a/ws.ts b/ws.ts index 86908dc..510283c 100644 --- a/ws.ts +++ b/ws.ts @@ -5,8 +5,6 @@ import { func_WriteRegularEvent, func_WriteReplaceableEvent } from "./resolvers/ import { func_GetEventsByFilter } from "./resolvers/event.ts"; import { func_DeleteEvent } from "./resolvers/event_deletion.ts"; -import { parseJSON } from "./nostr.ts/_helper.ts"; -import { PublicKey } from "./nostr.ts/key.ts"; import { _RelayResponse_EOSE, _RelayResponse_Event, @@ -19,8 +17,10 @@ import { NostrEvent, NostrFilter, NostrKind, + parseJSON, + PublicKey, verifyEvent, -} from "./nostr.ts/nostr.ts"; +} from "@blowater/nostr-sdk"; export const ws_handler = ( args: {