kinds: more reliable regular/replaceable kind figuring.

This commit is contained in:
fiatjaf
2025-11-24 20:07:44 -03:00
parent d3ddd490c2
commit 34a1d8db47
3 changed files with 4 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@nostr/tools",
"version": "2.18.0",
"version": "2.18.1",
"exports": {
".": "./index.ts",
"./core": "./core.ts",

View File

@@ -2,12 +2,12 @@ import { NostrEvent, validateEvent } from './pure.ts'
/** Events are **regular**, which means they're all expected to be stored by relays. */
export function isRegularKind(kind: number): boolean {
return (1000 <= kind && kind < 10000) || [1, 2, 4, 5, 6, 7, 8, 16, 40, 41, 42, 43, 44].includes(kind)
return kind < 10000 && kind !== 0 && kind !== 3
}
/** Events are **replaceable**, which means that, for each combination of `pubkey` and `kind`, only the latest event is expected to (SHOULD) be stored by relays, older versions are expected to be discarded. */
export function isReplaceableKind(kind: number): boolean {
return [0, 3].includes(kind) || (10000 <= kind && kind < 20000)
return kind === 0 || kind === 3 || (10000 <= kind && kind < 20000)
}
/** Events are **ephemeral**, which means they are not expected to be stored by relays. */

View File

@@ -1,7 +1,7 @@
{
"type": "module",
"name": "nostr-tools",
"version": "2.18.0",
"version": "2.18.1",
"description": "Tools for making a Nostr client.",
"repository": {
"type": "git",