@estiva-app/protocol 0.27.0 → 0.28.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/anchors.d.ts +112 -1
- package/dist/anchors.d.ts.map +1 -1
- package/dist/anchors.js +109 -1
- package/dist/anchors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/anchors.ts +150 -2
- package/src/index.ts +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,36 @@ Every entry answers the wire question explicitly, including when the answer is
|
|
|
4
4
|
nothing (ADR 0002 §4b). A change to the bytes an app publishes is a MAJOR — in
|
|
5
5
|
`0.x`, a MINOR — even when no TypeScript signature moved.
|
|
6
6
|
|
|
7
|
+
## 0.28.1 — 2026-10-07
|
|
8
|
+
|
|
9
|
+
**Wire behaviour: no builder's bytes changed.** `absenceOf` was too trusting
|
|
10
|
+
(COM-2 security review).
|
|
11
|
+
|
|
12
|
+
- A `kind:5` now counts only when its signer is the address's author (NIP-09),
|
|
13
|
+
or when it is the shape Buzz checks: no `e` tag, and the address is its first
|
|
14
|
+
`a`. Buzz validates only the `e` targets, or only the first `a`, and stores
|
|
15
|
+
every tag; a member could add somebody's address as an extra `a` and make a
|
|
16
|
+
hidden object read "deleted". `deletions` items need `pubkey` again.
|
|
17
|
+
|
|
18
|
+
## 0.28.0 — 2026-10-07
|
|
19
|
+
|
|
20
|
+
**Wire behaviour: no builder's bytes changed; one tag is new and one is read
|
|
21
|
+
more narrowly** (COM-2, SPEC §13.6.1).
|
|
22
|
+
|
|
23
|
+
- New: a message points at one block of another object with
|
|
24
|
+
`["part", <address>, <block id>]`. `partTag`, `partsOf` (one per address,
|
|
25
|
+
first wins), `resolvePart` (five states: `resolved`, `unaddressable`,
|
|
26
|
+
`detached`, `deleted`, `unreadable`) and `absenceOf`, which tells a deleted
|
|
27
|
+
object from one you cannot read by a `kind:5` naming the address. The signer
|
|
28
|
+
is not compared with the author: the relay accepts the author's owner too
|
|
29
|
+
(§6.5), which no client can check. A part's block id must match
|
|
30
|
+
`[A-Za-z0-9_-]{1,64}`; any other is dropped, because it ends up in a URL
|
|
31
|
+
fragment and a selector.
|
|
32
|
+
- **Narrower:** `blockAnchorOf` returns `undefined` for an event whose `kind`
|
|
33
|
+
is given and is not 1111. A `kind:9` has no `A` to say whose block it names;
|
|
34
|
+
Ship read one against the page it was drawn on. Callers that pass only
|
|
35
|
+
`{ tags }` behave as before.
|
|
36
|
+
|
|
7
37
|
## 0.27.0 — 2026-10-06
|
|
8
38
|
|
|
9
39
|
**Wire behaviour: no builder's bytes changed.** One builder removed (COM-3).
|
package/dist/anchors.d.ts
CHANGED
|
@@ -53,8 +53,18 @@ export type BlockAnchor =
|
|
|
53
53
|
state: 'detached';
|
|
54
54
|
id: string;
|
|
55
55
|
};
|
|
56
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The block id a comment anchors to, or `undefined` when it anchors to none.
|
|
58
|
+
*
|
|
59
|
+
* Only a `kind:1111` anchors (§13.6): its `A` says which object the block is
|
|
60
|
+
* in. A `kind:9` has no `A`, so a `block` tag on one names a part of nothing in
|
|
61
|
+
* particular, and a reader that resolved it against the page it happened to be
|
|
62
|
+
* drawn on would report a confident "deleted" about the wrong document. Pass
|
|
63
|
+
* the event's kind and that case is refused; a message pointing at a block of
|
|
64
|
+
* another object says so with a `part` tag instead ({@link partsOf}).
|
|
65
|
+
*/
|
|
57
66
|
export declare function blockAnchorOf(event: {
|
|
67
|
+
kind?: number;
|
|
58
68
|
tags: string[][];
|
|
59
69
|
}): string | undefined;
|
|
60
70
|
/**
|
|
@@ -66,4 +76,105 @@ export declare function blockAnchorOf(event: {
|
|
|
66
76
|
* has no parts either, and a reader that throws renders nothing at all.
|
|
67
77
|
*/
|
|
68
78
|
export declare function resolveBlockAnchor(id: string | undefined, value: string, format: ContentFormat): BlockAnchor;
|
|
79
|
+
/**
|
|
80
|
+
* A message pointing at one block of another object — SPEC §13.6.1 (COM-2).
|
|
81
|
+
*
|
|
82
|
+
* `["part", <address>, <block id>]`, beside the `a` for the same address and a
|
|
83
|
+
* body that names it. The same `(object, block)` pair as an anchor, but a
|
|
84
|
+
* different relation: an anchor is what a comment is *about* (like a reply's
|
|
85
|
+
* `e`), a part is what a message *shows* (like a `q`). They are separate tags
|
|
86
|
+
* so that one comment can be both anchored and pointing, and so that a reader
|
|
87
|
+
* which knows neither draws an ordinary reference to the object.
|
|
88
|
+
*
|
|
89
|
+
* Index 3 is left free for an extent (a section, a range), which is not built.
|
|
90
|
+
*/
|
|
91
|
+
export declare const PART_TAG = "part";
|
|
92
|
+
/** One `part` tag, read. */
|
|
93
|
+
export interface PartPointer {
|
|
94
|
+
/** `kind:pubkey:d` — the object the block is in. */
|
|
95
|
+
address: string;
|
|
96
|
+
/** §13.3's block id within that object's body. */
|
|
97
|
+
block: string;
|
|
98
|
+
}
|
|
99
|
+
/** The `part` tag for one block of one object. */
|
|
100
|
+
export declare function partTag(address: string, block: string): string[];
|
|
101
|
+
/**
|
|
102
|
+
* The blocks a message points at, one per address, in tag order.
|
|
103
|
+
*
|
|
104
|
+
* The first tag for an address wins: a message shows one block of a given
|
|
105
|
+
* object, and a second tag for it would be a second card nobody can tell
|
|
106
|
+
* apart from the first by its reference in the text.
|
|
107
|
+
*
|
|
108
|
+
* **This is the tags only.** A reader draws a part only while the body still
|
|
109
|
+
* names its address — by `nostr:naddr…` or an app URL (§7.7) — because an edit
|
|
110
|
+
* carries no `part` (§6.8) and a person who removed the reference meant the
|
|
111
|
+
* card to go too. Which addresses the body names is the reader's own
|
|
112
|
+
* reference set; this function does not guess it.
|
|
113
|
+
*/
|
|
114
|
+
export declare function partsOf(event: {
|
|
115
|
+
tags: string[][];
|
|
116
|
+
}): PartPointer[];
|
|
117
|
+
/**
|
|
118
|
+
* What a part resolved to. Five states, and like {@link BlockAnchor} none of
|
|
119
|
+
* them is a degree of another:
|
|
120
|
+
*
|
|
121
|
+
* - `resolved` — the block is there; draw it.
|
|
122
|
+
* - `unaddressable` — the object's body is not a block document, so it has no
|
|
123
|
+
* parts. Permanent for that body, and nothing was deleted.
|
|
124
|
+
* - `detached` — the object is readable and the block is gone from it.
|
|
125
|
+
* - `deleted` — the whole object was deleted: its author's `kind:5` names it.
|
|
126
|
+
* - `unreadable` — nothing came back and no deletion did either. **Not
|
|
127
|
+
* "exists but forbidden"**: an address that never existed reads exactly the
|
|
128
|
+
* same, and saying more would confirm a hidden object to anyone holding its
|
|
129
|
+
* address. A reader says it is not available to them, and shows no title and
|
|
130
|
+
* no text.
|
|
131
|
+
*
|
|
132
|
+
* `deleted` and `unreadable` must not render alike. That is the rule this
|
|
133
|
+
* union is shaped to make hard to break.
|
|
134
|
+
*/
|
|
135
|
+
export type Part = {
|
|
136
|
+
state: 'resolved';
|
|
137
|
+
block: Block;
|
|
138
|
+
} | {
|
|
139
|
+
state: 'unaddressable';
|
|
140
|
+
} | {
|
|
141
|
+
state: 'detached';
|
|
142
|
+
} | {
|
|
143
|
+
state: 'deleted';
|
|
144
|
+
} | {
|
|
145
|
+
state: 'unreadable';
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* What a reader holds for the object a part points at: its body, or the reason
|
|
149
|
+
* it has none — from {@link absenceOf}.
|
|
150
|
+
*/
|
|
151
|
+
export type PartSource = {
|
|
152
|
+
value: string;
|
|
153
|
+
format: ContentFormat;
|
|
154
|
+
} | 'deleted' | 'unreadable';
|
|
155
|
+
/** Which of the five states a part is in, against its object as it is now. */
|
|
156
|
+
export declare function resolvePart(block: string, source: PartSource): Part;
|
|
157
|
+
/**
|
|
158
|
+
* Why a read by address came back empty: `deleted` when the relay holds a
|
|
159
|
+
* deletion of it by address (a `kind:5` with that `a`), else `unreadable`.
|
|
160
|
+
*
|
|
161
|
+
* `deletions` is what `{kinds: [5], "#a": [address]}` returned. A deletion
|
|
162
|
+
* counts when either holds:
|
|
163
|
+
*
|
|
164
|
+
* - **its signer is the address's author** — NIP-09, true on any relay; or
|
|
165
|
+
* - **it is the shape the relay checked**: no `e` tag, and the address is its
|
|
166
|
+
* *first* `a`. Buzz accepts that shape from the author or the author's owner
|
|
167
|
+
* (SPEC §6.5), and ownership is visible only to the relay — most objects here
|
|
168
|
+
* are written by an agent and deleted by the person who owns it.
|
|
169
|
+
*
|
|
170
|
+
* Anything else is unchecked. Buzz validates only the `e` targets when there
|
|
171
|
+
* are any, and only the first `a` when there are none, yet stores every tag; a
|
|
172
|
+
* member could otherwise add somebody's address as a second `a` and make their
|
|
173
|
+
* hidden object read "deleted" to everyone who cannot see it.
|
|
174
|
+
*/
|
|
175
|
+
export declare function absenceOf(address: string, deletions: readonly {
|
|
176
|
+
kind: number;
|
|
177
|
+
pubkey: string;
|
|
178
|
+
tags: string[][];
|
|
179
|
+
}[]): 'deleted' | 'unreadable';
|
|
69
180
|
//# sourceMappingURL=anchors.d.ts.map
|
package/dist/anchors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchors.d.ts","sourceRoot":"","sources":["../src/anchors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,KAAK,EAAqD,MAAM,aAAa,CAAA;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,kCAAkC;AAClC,eAAO,MAAM,gBAAgB,UAAU,CAAA;AAEvC;;;;;;GAMG;AACH,MAAM,MAAM,WAAW;AACrB,wEAAwE;AACtE;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE;AACzB,6CAA6C;GAC3C;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE;AACjD;;;;;GAKG;GACD;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,EAAE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|
|
21
21
|
export const BLOCK_ANCHOR_TAG = 'block';
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* The block id a comment anchors to, or `undefined` when it anchors to none.
|
|
24
|
+
*
|
|
25
|
+
* Only a `kind:1111` anchors (§13.6): its `A` says which object the block is
|
|
26
|
+
* in. A `kind:9` has no `A`, so a `block` tag on one names a part of nothing in
|
|
27
|
+
* particular, and a reader that resolved it against the page it happened to be
|
|
28
|
+
* drawn on would report a confident "deleted" about the wrong document. Pass
|
|
29
|
+
* the event's kind and that case is refused; a message pointing at a block of
|
|
30
|
+
* another object says so with a `part` tag instead ({@link partsOf}).
|
|
31
|
+
*/
|
|
23
32
|
export function blockAnchorOf(event) {
|
|
33
|
+
if (event.kind !== undefined && event.kind !== 1111)
|
|
34
|
+
return undefined;
|
|
24
35
|
const id = event.tags.find((t) => t[0] === BLOCK_ANCHOR_TAG)?.[1];
|
|
25
36
|
return id === undefined || id === '' ? undefined : id;
|
|
26
37
|
}
|
|
@@ -47,4 +58,101 @@ export function resolveBlockAnchor(id, value, format) {
|
|
|
47
58
|
const block = findBlock(document, id);
|
|
48
59
|
return block ? { state: 'resolved', id, block } : { state: 'detached', id };
|
|
49
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* A message pointing at one block of another object — SPEC §13.6.1 (COM-2).
|
|
63
|
+
*
|
|
64
|
+
* `["part", <address>, <block id>]`, beside the `a` for the same address and a
|
|
65
|
+
* body that names it. The same `(object, block)` pair as an anchor, but a
|
|
66
|
+
* different relation: an anchor is what a comment is *about* (like a reply's
|
|
67
|
+
* `e`), a part is what a message *shows* (like a `q`). They are separate tags
|
|
68
|
+
* so that one comment can be both anchored and pointing, and so that a reader
|
|
69
|
+
* which knows neither draws an ordinary reference to the object.
|
|
70
|
+
*
|
|
71
|
+
* Index 3 is left free for an extent (a section, a range), which is not built.
|
|
72
|
+
*/
|
|
73
|
+
export const PART_TAG = 'part';
|
|
74
|
+
/** The `part` tag for one block of one object. */
|
|
75
|
+
export function partTag(address, block) {
|
|
76
|
+
return [PART_TAG, address, block];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The blocks a message points at, one per address, in tag order.
|
|
80
|
+
*
|
|
81
|
+
* The first tag for an address wins: a message shows one block of a given
|
|
82
|
+
* object, and a second tag for it would be a second card nobody can tell
|
|
83
|
+
* apart from the first by its reference in the text.
|
|
84
|
+
*
|
|
85
|
+
* **This is the tags only.** A reader draws a part only while the body still
|
|
86
|
+
* names its address — by `nostr:naddr…` or an app URL (§7.7) — because an edit
|
|
87
|
+
* carries no `part` (§6.8) and a person who removed the reference meant the
|
|
88
|
+
* card to go too. Which addresses the body names is the reader's own
|
|
89
|
+
* reference set; this function does not guess it.
|
|
90
|
+
*/
|
|
91
|
+
export function partsOf(event) {
|
|
92
|
+
const out = [];
|
|
93
|
+
const seen = new Set();
|
|
94
|
+
for (const tag of event.tags) {
|
|
95
|
+
if (tag[0] !== PART_TAG)
|
|
96
|
+
continue;
|
|
97
|
+
const [, address, block] = tag;
|
|
98
|
+
if (!address || !block || !isAddress(address) || !BLOCK_ID.test(block) || seen.has(address))
|
|
99
|
+
continue;
|
|
100
|
+
seen.add(address);
|
|
101
|
+
out.push({ address, block });
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The block ids a part may name. §13.3 fixes no grammar (`newBlockId` writes 12
|
|
107
|
+
* hex; SPEC's examples say `b1`), but a part's id arrives from a stranger's tag
|
|
108
|
+
* or a pasted URL and ends up in a fragment and, in an app, a selector — so a
|
|
109
|
+
* reader takes only ids that are safe in both and drops the rest.
|
|
110
|
+
*/
|
|
111
|
+
const BLOCK_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
112
|
+
/** `kind:pubkey:d` with a numeric kind and a 64-hex pubkey. */
|
|
113
|
+
function isAddress(value) {
|
|
114
|
+
return /^\d+:[0-9a-f]{64}:/.test(value);
|
|
115
|
+
}
|
|
116
|
+
/** Which of the five states a part is in, against its object as it is now. */
|
|
117
|
+
export function resolvePart(block, source) {
|
|
118
|
+
if (source === 'deleted' || source === 'unreadable')
|
|
119
|
+
return { state: source };
|
|
120
|
+
const anchor = resolveBlockAnchor(block, source.value, source.format);
|
|
121
|
+
if (anchor.state === 'resolved')
|
|
122
|
+
return { state: 'resolved', block: anchor.block };
|
|
123
|
+
if (anchor.state === 'detached')
|
|
124
|
+
return { state: 'detached' };
|
|
125
|
+
return { state: 'unaddressable' };
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Why a read by address came back empty: `deleted` when the relay holds a
|
|
129
|
+
* deletion of it by address (a `kind:5` with that `a`), else `unreadable`.
|
|
130
|
+
*
|
|
131
|
+
* `deletions` is what `{kinds: [5], "#a": [address]}` returned. A deletion
|
|
132
|
+
* counts when either holds:
|
|
133
|
+
*
|
|
134
|
+
* - **its signer is the address's author** — NIP-09, true on any relay; or
|
|
135
|
+
* - **it is the shape the relay checked**: no `e` tag, and the address is its
|
|
136
|
+
* *first* `a`. Buzz accepts that shape from the author or the author's owner
|
|
137
|
+
* (SPEC §6.5), and ownership is visible only to the relay — most objects here
|
|
138
|
+
* are written by an agent and deleted by the person who owns it.
|
|
139
|
+
*
|
|
140
|
+
* Anything else is unchecked. Buzz validates only the `e` targets when there
|
|
141
|
+
* are any, and only the first `a` when there are none, yet stores every tag; a
|
|
142
|
+
* member could otherwise add somebody's address as a second `a` and make their
|
|
143
|
+
* hidden object read "deleted" to everyone who cannot see it.
|
|
144
|
+
*/
|
|
145
|
+
export function absenceOf(address, deletions) {
|
|
146
|
+
const author = address.split(':')[1];
|
|
147
|
+
const deleted = deletions.some((event) => {
|
|
148
|
+
if (event.kind !== 5)
|
|
149
|
+
return false;
|
|
150
|
+
if (event.pubkey === author)
|
|
151
|
+
return event.tags.some((t) => t[0] === 'a' && t[1] === address);
|
|
152
|
+
if (event.tags.some((t) => t[0] === 'e'))
|
|
153
|
+
return false;
|
|
154
|
+
return event.tags.find((t) => t[0] === 'a')?.[1] === address;
|
|
155
|
+
});
|
|
156
|
+
return deleted ? 'deleted' : 'unreadable';
|
|
157
|
+
}
|
|
50
158
|
//# sourceMappingURL=anchors.js.map
|
package/dist/anchors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anchors.js","sourceRoot":"","sources":["../src/anchors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAkC,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAG3F,kCAAkC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAwBvC
|
|
1
|
+
{"version":3,"file":"anchors.js","sourceRoot":"","sources":["../src/anchors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAkC,SAAS,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAG3F,kCAAkC;AAClC,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAA;AAwBvC;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,KAA0C;IACtE,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,SAAS,CAAA;IACrE,MAAM,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACjE,OAAO,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAA;AACvD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,EAAsB,EACtB,KAAa,EACb,MAAqB;IAErB,IAAI,EAAE,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE;QA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AAC;YAAE,OAAO,KAAK,CAAA;QAClC,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAA;QAC5F,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;YAAE,OAAO,KAAK,CAAA;QACtD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,OAAO,CAAA;IAC9D,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAA;AAC3C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
/** Bumped by hand with the version in package.json — `test/version.test.ts`
|
|
47
47
|
* pins the two together. It exists so "the upgrade reached the app" can be
|
|
48
48
|
* checked by grepping a built bundle rather than by trusting a lockfile. */
|
|
49
|
-
export declare const PROTOCOL_VERSION = "0.
|
|
49
|
+
export declare const PROTOCOL_VERSION = "0.28.1";
|
|
50
50
|
export { type NostrTag, type UnsignedEvent, type SignedEvent, type Profile, type ThreadRef, type ChannelVisibility, type ChannelKind, type MemberRole, type FolderOp, type Label, type ResolutionAction, KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_DM_OTHERS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE, computeEventId, toNostrSeconds, canonicalChannelName, threadTags, addr, relayAuthUrl, buildProfile, parseProfile, buildCreateChannel, buildDeleteChannel, buildEditChannelMetadata, buildFolderCommand, buildAddMember, buildDmOpen, buildDmHide, buildReaction, buildDeletion, buildEdit, buildMessage, buildResolution, buildBareFile, buildHighlight, buildUnsignedRelayAuthEvent, } from './events.js';
|
|
51
51
|
export { type AddressPointer, type EventPointer, encodeNevent, decodeNevent, convertBits, bech32Encode, bech32Decode, encodeNaddr, decodeNaddr, pointerToAddress, addressToPointer, addrToNaddr, naddrToAddr, referenceToPointer, NADDR_RE, findNaddrs, stripNaddrs, encodeNpub, decodeNpub, NOSTR_URI_RE, findNostrUris, } from './nip19.js';
|
|
52
52
|
export { type AuthEventArgs, TIMESTAMP_TOLERANCE_SECS, normalizeUrl, buildUnsignedAuthEvent, base64, authorizationHeaderFor, authorizationHeader, } from './nip98.js';
|
|
@@ -59,6 +59,6 @@ export { type Block, type BlockDocument, type KnownBlockType, KNOWN_BLOCK_TYPES,
|
|
|
59
59
|
export { type RenderInline, type RenderBlock, type RenderFormat, type ContentFormat, CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTree, renderTreeText, standaloneReference, referencesIn, } from './render.js';
|
|
60
60
|
export { markerTextToBlockDocument, blockDocumentToMarkerText, } from './bridge-content.js';
|
|
61
61
|
export { type EditorNode, type EditorDocument, EDITOR_BLOCK_TYPES, UNKNOWN_BLOCK_NODE, REFERENCE_NODE, documentForEditing, toEditorDocument, fromEditorDocument, publishableFromEditor, } from './editor.js';
|
|
62
|
-
export { type BlockAnchor, BLOCK_ANCHOR_TAG, blockAnchorOf, resolveBlockAnchor, } from './anchors.js';
|
|
62
|
+
export { type BlockAnchor, type Part, type PartPointer, type PartSource, BLOCK_ANCHOR_TAG, PART_TAG, absenceOf, blockAnchorOf, partTag, partsOf, resolveBlockAnchor, resolvePart, } from './anchors.js';
|
|
63
63
|
export { type BlossomVerb, type Imeta, BLOSSOM_AUTH_TTL_SECS, buildBlossomAuth, blossomAuthHeader, imetaTag, imetaOf, imetaFromAttrs, attachmentsInDocument, type BlobFetchLike, type BlobResponseLike, type FetchedBlob, sha256FromMediaUrl, fetchBlob, sha256Of, uploadBlob, imetaFor, canonicalizeImage, type UploadedBlob, type BlobUploadFetchLike, } from './media.js';
|
|
64
64
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,eAAO,MAAM,gBAAgB,WAAW,CAAA;AAExC,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,gBAAgB,EAErB,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EAEjB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY,EAEZ,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAk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AAqB,EACrB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
/** Bumped by hand with the version in package.json — `test/version.test.ts`
|
|
47
47
|
* pins the two together. It exists so "the upgrade reached the app" can be
|
|
48
48
|
* checked by grepping a built bundle rather than by trusting a lockfile. */
|
|
49
|
-
export const PROTOCOL_VERSION = '0.
|
|
49
|
+
export const PROTOCOL_VERSION = '0.28.1';
|
|
50
50
|
export {
|
|
51
51
|
// constants
|
|
52
52
|
KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_DM_OTHERS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE,
|
|
@@ -65,6 +65,6 @@ export { KNOWN_BLOCK_TYPES, BlockDocumentError, validateBlockDocument, parseBloc
|
|
|
65
65
|
export { CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTree, renderTreeText, standaloneReference, referencesIn, } from './render.js';
|
|
66
66
|
export { markerTextToBlockDocument, blockDocumentToMarkerText, } from './bridge-content.js';
|
|
67
67
|
export { EDITOR_BLOCK_TYPES, UNKNOWN_BLOCK_NODE, REFERENCE_NODE, documentForEditing, toEditorDocument, fromEditorDocument, publishableFromEditor, } from './editor.js';
|
|
68
|
-
export { BLOCK_ANCHOR_TAG, blockAnchorOf, resolveBlockAnchor, } from './anchors.js';
|
|
68
|
+
export { BLOCK_ANCHOR_TAG, PART_TAG, absenceOf, blockAnchorOf, partTag, partsOf, resolveBlockAnchor, resolvePart, } from './anchors.js';
|
|
69
69
|
export { BLOSSOM_AUTH_TTL_SECS, buildBlossomAuth, blossomAuthHeader, imetaTag, imetaOf, imetaFromAttrs, attachmentsInDocument, sha256FromMediaUrl, fetchBlob, sha256Of, uploadBlob, imetaFor, canonicalizeImage, } from './media.js';
|
|
70
70
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAA;AAExC,OAAO;AAaL,YAAY;AACZ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB;AACjB,8CAA8C;AAC9C,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,IAAI,EACJ,YAAY;AACZ,WAAW;AACX,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,SAAS,EACT,YAAY,EACZ,eAAe,EACf,aAAa,EACb,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAEpB,OAAO,EAGL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,WAAW,EACX,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAA;AAEnB,OAAO,EAEL,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,MAAM,EACN,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,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M,cAAc,CAAA;AAErB,OAAO,EAIL,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EAKL,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,YAAY,GACb,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAGL,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAKL,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,OAAO,EAGL,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,EAIrB,kBAAkB,EAClB,SAAS,EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,GAGlB,MAAM,YAAY,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estiva-app/protocol",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.1",
|
|
4
4
|
"description": "The Estiva wire format: Buzz-shaped Nostr event builders, NIP-01 ids, NIP-19 naddr, NIP-98 HTTP auth, and the relay clients. Speaks the protocol; interprets nothing.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/anchors.ts
CHANGED
|
@@ -44,8 +44,18 @@ export type BlockAnchor =
|
|
|
44
44
|
/** The tag names a block that is no longer in the document. */
|
|
45
45
|
| { state: 'detached'; id: string }
|
|
46
46
|
|
|
47
|
-
/**
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* The block id a comment anchors to, or `undefined` when it anchors to none.
|
|
49
|
+
*
|
|
50
|
+
* Only a `kind:1111` anchors (§13.6): its `A` says which object the block is
|
|
51
|
+
* in. A `kind:9` has no `A`, so a `block` tag on one names a part of nothing in
|
|
52
|
+
* particular, and a reader that resolved it against the page it happened to be
|
|
53
|
+
* drawn on would report a confident "deleted" about the wrong document. Pass
|
|
54
|
+
* the event's kind and that case is refused; a message pointing at a block of
|
|
55
|
+
* another object says so with a `part` tag instead ({@link partsOf}).
|
|
56
|
+
*/
|
|
57
|
+
export function blockAnchorOf(event: { kind?: number; tags: string[][] }): string | undefined {
|
|
58
|
+
if (event.kind !== undefined && event.kind !== 1111) return undefined
|
|
49
59
|
const id = event.tags.find((t) => t[0] === BLOCK_ANCHOR_TAG)?.[1]
|
|
50
60
|
return id === undefined || id === '' ? undefined : id
|
|
51
61
|
}
|
|
@@ -74,3 +84,141 @@ export function resolveBlockAnchor(
|
|
|
74
84
|
const block = findBlock(document, id)
|
|
75
85
|
return block ? { state: 'resolved', id, block } : { state: 'detached', id }
|
|
76
86
|
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* A message pointing at one block of another object — SPEC §13.6.1 (COM-2).
|
|
90
|
+
*
|
|
91
|
+
* `["part", <address>, <block id>]`, beside the `a` for the same address and a
|
|
92
|
+
* body that names it. The same `(object, block)` pair as an anchor, but a
|
|
93
|
+
* different relation: an anchor is what a comment is *about* (like a reply's
|
|
94
|
+
* `e`), a part is what a message *shows* (like a `q`). They are separate tags
|
|
95
|
+
* so that one comment can be both anchored and pointing, and so that a reader
|
|
96
|
+
* which knows neither draws an ordinary reference to the object.
|
|
97
|
+
*
|
|
98
|
+
* Index 3 is left free for an extent (a section, a range), which is not built.
|
|
99
|
+
*/
|
|
100
|
+
export const PART_TAG = 'part'
|
|
101
|
+
|
|
102
|
+
/** One `part` tag, read. */
|
|
103
|
+
export interface PartPointer {
|
|
104
|
+
/** `kind:pubkey:d` — the object the block is in. */
|
|
105
|
+
address: string
|
|
106
|
+
/** §13.3's block id within that object's body. */
|
|
107
|
+
block: string
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** The `part` tag for one block of one object. */
|
|
111
|
+
export function partTag(address: string, block: string): string[] {
|
|
112
|
+
return [PART_TAG, address, block]
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The blocks a message points at, one per address, in tag order.
|
|
117
|
+
*
|
|
118
|
+
* The first tag for an address wins: a message shows one block of a given
|
|
119
|
+
* object, and a second tag for it would be a second card nobody can tell
|
|
120
|
+
* apart from the first by its reference in the text.
|
|
121
|
+
*
|
|
122
|
+
* **This is the tags only.** A reader draws a part only while the body still
|
|
123
|
+
* names its address — by `nostr:naddr…` or an app URL (§7.7) — because an edit
|
|
124
|
+
* carries no `part` (§6.8) and a person who removed the reference meant the
|
|
125
|
+
* card to go too. Which addresses the body names is the reader's own
|
|
126
|
+
* reference set; this function does not guess it.
|
|
127
|
+
*/
|
|
128
|
+
export function partsOf(event: { tags: string[][] }): PartPointer[] {
|
|
129
|
+
const out: PartPointer[] = []
|
|
130
|
+
const seen = new Set<string>()
|
|
131
|
+
for (const tag of event.tags) {
|
|
132
|
+
if (tag[0] !== PART_TAG) continue
|
|
133
|
+
const [, address, block] = tag
|
|
134
|
+
if (!address || !block || !isAddress(address) || !BLOCK_ID.test(block) || seen.has(address)) continue
|
|
135
|
+
seen.add(address)
|
|
136
|
+
out.push({ address, block })
|
|
137
|
+
}
|
|
138
|
+
return out
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* The block ids a part may name. §13.3 fixes no grammar (`newBlockId` writes 12
|
|
143
|
+
* hex; SPEC's examples say `b1`), but a part's id arrives from a stranger's tag
|
|
144
|
+
* or a pasted URL and ends up in a fragment and, in an app, a selector — so a
|
|
145
|
+
* reader takes only ids that are safe in both and drops the rest.
|
|
146
|
+
*/
|
|
147
|
+
const BLOCK_ID = /^[A-Za-z0-9_-]{1,64}$/
|
|
148
|
+
|
|
149
|
+
/** `kind:pubkey:d` with a numeric kind and a 64-hex pubkey. */
|
|
150
|
+
function isAddress(value: string): boolean {
|
|
151
|
+
return /^\d+:[0-9a-f]{64}:/.test(value)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* What a part resolved to. Five states, and like {@link BlockAnchor} none of
|
|
156
|
+
* them is a degree of another:
|
|
157
|
+
*
|
|
158
|
+
* - `resolved` — the block is there; draw it.
|
|
159
|
+
* - `unaddressable` — the object's body is not a block document, so it has no
|
|
160
|
+
* parts. Permanent for that body, and nothing was deleted.
|
|
161
|
+
* - `detached` — the object is readable and the block is gone from it.
|
|
162
|
+
* - `deleted` — the whole object was deleted: its author's `kind:5` names it.
|
|
163
|
+
* - `unreadable` — nothing came back and no deletion did either. **Not
|
|
164
|
+
* "exists but forbidden"**: an address that never existed reads exactly the
|
|
165
|
+
* same, and saying more would confirm a hidden object to anyone holding its
|
|
166
|
+
* address. A reader says it is not available to them, and shows no title and
|
|
167
|
+
* no text.
|
|
168
|
+
*
|
|
169
|
+
* `deleted` and `unreadable` must not render alike. That is the rule this
|
|
170
|
+
* union is shaped to make hard to break.
|
|
171
|
+
*/
|
|
172
|
+
export type Part =
|
|
173
|
+
| { state: 'resolved'; block: Block }
|
|
174
|
+
| { state: 'unaddressable' }
|
|
175
|
+
| { state: 'detached' }
|
|
176
|
+
| { state: 'deleted' }
|
|
177
|
+
| { state: 'unreadable' }
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* What a reader holds for the object a part points at: its body, or the reason
|
|
181
|
+
* it has none — from {@link absenceOf}.
|
|
182
|
+
*/
|
|
183
|
+
export type PartSource = { value: string; format: ContentFormat } | 'deleted' | 'unreadable'
|
|
184
|
+
|
|
185
|
+
/** Which of the five states a part is in, against its object as it is now. */
|
|
186
|
+
export function resolvePart(block: string, source: PartSource): Part {
|
|
187
|
+
if (source === 'deleted' || source === 'unreadable') return { state: source }
|
|
188
|
+
const anchor = resolveBlockAnchor(block, source.value, source.format)
|
|
189
|
+
if (anchor.state === 'resolved') return { state: 'resolved', block: anchor.block }
|
|
190
|
+
if (anchor.state === 'detached') return { state: 'detached' }
|
|
191
|
+
return { state: 'unaddressable' }
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Why a read by address came back empty: `deleted` when the relay holds a
|
|
196
|
+
* deletion of it by address (a `kind:5` with that `a`), else `unreadable`.
|
|
197
|
+
*
|
|
198
|
+
* `deletions` is what `{kinds: [5], "#a": [address]}` returned. A deletion
|
|
199
|
+
* counts when either holds:
|
|
200
|
+
*
|
|
201
|
+
* - **its signer is the address's author** — NIP-09, true on any relay; or
|
|
202
|
+
* - **it is the shape the relay checked**: no `e` tag, and the address is its
|
|
203
|
+
* *first* `a`. Buzz accepts that shape from the author or the author's owner
|
|
204
|
+
* (SPEC §6.5), and ownership is visible only to the relay — most objects here
|
|
205
|
+
* are written by an agent and deleted by the person who owns it.
|
|
206
|
+
*
|
|
207
|
+
* Anything else is unchecked. Buzz validates only the `e` targets when there
|
|
208
|
+
* are any, and only the first `a` when there are none, yet stores every tag; a
|
|
209
|
+
* member could otherwise add somebody's address as a second `a` and make their
|
|
210
|
+
* hidden object read "deleted" to everyone who cannot see it.
|
|
211
|
+
*/
|
|
212
|
+
export function absenceOf(
|
|
213
|
+
address: string,
|
|
214
|
+
deletions: readonly { kind: number; pubkey: string; tags: string[][] }[],
|
|
215
|
+
): 'deleted' | 'unreadable' {
|
|
216
|
+
const author = address.split(':')[1]
|
|
217
|
+
const deleted = deletions.some((event) => {
|
|
218
|
+
if (event.kind !== 5) return false
|
|
219
|
+
if (event.pubkey === author) return event.tags.some((t) => t[0] === 'a' && t[1] === address)
|
|
220
|
+
if (event.tags.some((t) => t[0] === 'e')) return false
|
|
221
|
+
return event.tags.find((t) => t[0] === 'a')?.[1] === address
|
|
222
|
+
})
|
|
223
|
+
return deleted ? 'deleted' : 'unreadable'
|
|
224
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
/** Bumped by hand with the version in package.json — `test/version.test.ts`
|
|
48
48
|
* pins the two together. It exists so "the upgrade reached the app" can be
|
|
49
49
|
* checked by grepping a built bundle rather than by trusting a lockfile. */
|
|
50
|
-
export const PROTOCOL_VERSION = '0.
|
|
50
|
+
export const PROTOCOL_VERSION = '0.28.1'
|
|
51
51
|
|
|
52
52
|
export {
|
|
53
53
|
// types
|
|
@@ -240,9 +240,17 @@ export {
|
|
|
240
240
|
|
|
241
241
|
export {
|
|
242
242
|
type BlockAnchor,
|
|
243
|
+
type Part,
|
|
244
|
+
type PartPointer,
|
|
245
|
+
type PartSource,
|
|
243
246
|
BLOCK_ANCHOR_TAG,
|
|
247
|
+
PART_TAG,
|
|
248
|
+
absenceOf,
|
|
244
249
|
blockAnchorOf,
|
|
250
|
+
partTag,
|
|
251
|
+
partsOf,
|
|
245
252
|
resolveBlockAnchor,
|
|
253
|
+
resolvePart,
|
|
246
254
|
} from './anchors.js'
|
|
247
255
|
export {
|
|
248
256
|
type BlossomVerb,
|