@estiva-app/protocol 0.30.0 → 0.31.0
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 +15 -0
- package/dist/embeds.d.ts +54 -0
- package/dist/embeds.d.ts.map +1 -0
- package/dist/embeds.js +164 -0
- package/dist/embeds.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/embeds.ts +176 -0
- package/src/index.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@ 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.31.0 — 2026-10-13
|
|
8
|
+
|
|
9
|
+
**Wire behaviour: a message can ask for a reference's card** (OPT-16, SPEC
|
|
10
|
+
§13.6.2). New tag `["embed", <address or event id>, "compact" | "detailed" |
|
|
11
|
+
"none"]` on a `kind:9`, a `kind:1111` and their `40003` edits. `embedsOf` reads
|
|
12
|
+
it (first per value, an unknown layout as `compact`), `embedTag` writes it, and
|
|
13
|
+
`cardsIn` says which cards a message draws: the values its folded body still
|
|
14
|
+
names — by `nostr:` reference, or by an app link the caller's `LinkResolver`
|
|
15
|
+
resolves by §7.7 (without one, a link names nothing) — in body order, with a
|
|
16
|
+
`part` winning over an `embed`.
|
|
17
|
+
There is no `a`/`q` match, so an edit can give a card to a reference it added.
|
|
18
|
+
Nothing this package publishes changes: nothing writes `embed` yet, and a
|
|
19
|
+
reader on 0.30 ignores the tag and draws the reference as before.
|
|
20
|
+
`standaloneReference` is unchanged.
|
|
21
|
+
|
|
7
22
|
## 0.30.0 — 2026-10-13
|
|
8
23
|
|
|
9
24
|
**Wire behaviour: a block document can hold a checklist item and a callout**
|
package/dist/embeds.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { PartPointer } from './anchors.js';
|
|
2
|
+
import type { RenderBlock } from './render.js';
|
|
3
|
+
export declare const EMBED_TAG = "embed";
|
|
4
|
+
/** How much of a referenced object a card shows, or `none` for no card. */
|
|
5
|
+
export type EmbedLayout = 'compact' | 'detailed' | 'none';
|
|
6
|
+
/** One `embed` tag, read. */
|
|
7
|
+
export interface Embed {
|
|
8
|
+
/** An address (`kind:pubkey:d`) or a 64-hex event id, lowercase hex. */
|
|
9
|
+
value: string;
|
|
10
|
+
layout: EmbedLayout;
|
|
11
|
+
}
|
|
12
|
+
/** The `embed` tag for one reference. */
|
|
13
|
+
export declare function embedTag(value: string, layout: EmbedLayout): string[];
|
|
14
|
+
/**
|
|
15
|
+
* The `embed` tags on one event, one per value, in tag order.
|
|
16
|
+
*
|
|
17
|
+
* The first tag for a value wins. A layout this reader does not know draws as
|
|
18
|
+
* `compact` rather than nothing: the author asked for a card, and the smallest
|
|
19
|
+
* one is the safe reading of a density added after this reader was written. A
|
|
20
|
+
* value that is neither an address nor an event id is skipped.
|
|
21
|
+
*
|
|
22
|
+
* **This is the tags only**, of one event. For a message, fold its edits first
|
|
23
|
+
* (`foldEmbeds` in `@estiva-app/conversation`), then ask {@link cardsIn} which
|
|
24
|
+
* of them the body still names.
|
|
25
|
+
*/
|
|
26
|
+
export declare function embedsOf(event: {
|
|
27
|
+
tags: readonly (readonly string[])[];
|
|
28
|
+
}): Embed[];
|
|
29
|
+
/**
|
|
30
|
+
* What an app link names, as the reader resolved it by §7.7 — the host and the
|
|
31
|
+
* `<type>` segment against a published `urls` pattern, then the one author who
|
|
32
|
+
* holds that `d` — or undefined. Never a match on the link's trailing
|
|
33
|
+
* identifier alone: that resolves any site's URL as somebody's object, and puts
|
|
34
|
+
* a real issue's card under a link that does not open it (§7.7).
|
|
35
|
+
*/
|
|
36
|
+
export type LinkResolver = (url: string) => string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The cards a message asks for, in the order the body first names them.
|
|
39
|
+
*
|
|
40
|
+
* `embeds` is the message's folded set; `blocks` its folded body as a render
|
|
41
|
+
* tree; `parts` its `part` pointers (§13.6.1). A value appears here only while
|
|
42
|
+
* the body names it — by a `nostr:` reference, or by an app link that
|
|
43
|
+
* `resolveLink` resolves to it (§7.7) — and only when no `part` names the
|
|
44
|
+
* same address, because the live block already stands for that object. Text in
|
|
45
|
+
* a code span names nothing (§13.1). Without `resolveLink` a link names nothing:
|
|
46
|
+
* resolving one needs the manifests and the relay, which this package does not hold.
|
|
47
|
+
*
|
|
48
|
+
* `none` entries are kept: they draw no card, but they still override the
|
|
49
|
+
* reader's own default for that value (as of 2026-10-13 Ship and Peek draw a
|
|
50
|
+
* reference alone on its line as its card; an `embed` replaces that). Filter
|
|
51
|
+
* them out to get the cards to draw.
|
|
52
|
+
*/
|
|
53
|
+
export declare function cardsIn(embeds: readonly Embed[], blocks: readonly RenderBlock[], parts?: readonly PartPointer[], resolveLink?: LinkResolver): Embed[];
|
|
54
|
+
//# sourceMappingURL=embeds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeds.d.ts","sourceRoot":"","sources":["../src/embeds.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,eAAO,MAAM,SAAS,UAAU,CAAA;AAEhC,2EAA2E;AAC3E,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,MAAM,CAAA;AAEzD,6BAA6B;AAC7B,MAAM,WAAW,KAAK;IACpB,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,WAAW,CAAA;CACpB;AAED,yCAAyC;AACzC,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,EAAE,CAErE;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAA;CAAE,GAAG,KAAK,EAAE,CAWjF;AAcD;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;AA+B9D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,WAAW,EAAE,EAAE,KAAK,GAAE,SAAS,WAAW,EAAO,EAAE,WAAW,CAAC,EAAE,YAAY,GAAG,KAAK,EAAE,CAuCzJ"}
|
package/dist/embeds.js
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Showing a reference as a card — SPEC §13.6.2 (OPT-16).
|
|
3
|
+
*
|
|
4
|
+
* `["embed", <value>, "compact" | "detailed" | "none"]` says how the author
|
|
5
|
+
* wants one reference in a message drawn: as a card under the message, and how
|
|
6
|
+
* much of it. `<value>` is what an `a` or `q` would carry for the same thing —
|
|
7
|
+
* an address or a 64-hex event id. The values are a density, not a widget
|
|
8
|
+
* name: `compact` is §7.5's closed `row` and `detailed` its closed `card`, so
|
|
9
|
+
* a richer card can come later without changing the wire.
|
|
10
|
+
*
|
|
11
|
+
* A reference with no `embed` is drawn by the reader's default (a chip, §13.1).
|
|
12
|
+
* An `embed` for a value overrides that default, which is why `none` exists:
|
|
13
|
+
* it is the author saying "no card" in an edit that replaces the set (§6.8).
|
|
14
|
+
*
|
|
15
|
+
* Like `part` (§13.6.1), the tags are only half the answer. A card is drawn
|
|
16
|
+
* only while the body — as edited — still names its value, and there is no
|
|
17
|
+
* `a`/`q` match: an edit carries no index tags (§6.8), and a value first named
|
|
18
|
+
* in an edit can still carry a card (Miky, 2026-10-13, OPT-16 kickoff).
|
|
19
|
+
* {@link cardsIn} applies that rule; {@link embedsOf} reads the tags alone.
|
|
20
|
+
*/
|
|
21
|
+
import { bech32Decode, convertBits, decodeNevent, naddrToAddr } from './nip19.js';
|
|
22
|
+
export const EMBED_TAG = 'embed';
|
|
23
|
+
/** The `embed` tag for one reference. */
|
|
24
|
+
export function embedTag(value, layout) {
|
|
25
|
+
return [EMBED_TAG, value, layout];
|
|
26
|
+
}
|
|
27
|
+
// `partsOf`'s shape: an empty `d` is a valid address (NIP-01).
|
|
28
|
+
const ADDRESS = /^\d+:[0-9a-f]{64}:/;
|
|
29
|
+
const EVENT_ID = /^[0-9a-f]{64}$/;
|
|
30
|
+
/**
|
|
31
|
+
* The `embed` tags on one event, one per value, in tag order.
|
|
32
|
+
*
|
|
33
|
+
* The first tag for a value wins. A layout this reader does not know draws as
|
|
34
|
+
* `compact` rather than nothing: the author asked for a card, and the smallest
|
|
35
|
+
* one is the safe reading of a density added after this reader was written. A
|
|
36
|
+
* value that is neither an address nor an event id is skipped.
|
|
37
|
+
*
|
|
38
|
+
* **This is the tags only**, of one event. For a message, fold its edits first
|
|
39
|
+
* (`foldEmbeds` in `@estiva-app/conversation`), then ask {@link cardsIn} which
|
|
40
|
+
* of them the body still names.
|
|
41
|
+
*/
|
|
42
|
+
export function embedsOf(event) {
|
|
43
|
+
const out = [];
|
|
44
|
+
const seen = new Set();
|
|
45
|
+
for (const tag of event.tags) {
|
|
46
|
+
if (tag[0] !== EMBED_TAG || !tag[1])
|
|
47
|
+
continue;
|
|
48
|
+
const value = normalise(tag[1]);
|
|
49
|
+
if (!value || seen.has(value))
|
|
50
|
+
continue;
|
|
51
|
+
seen.add(value);
|
|
52
|
+
out.push({ value, layout: layoutOf(tag[2]) });
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function layoutOf(raw) {
|
|
57
|
+
return raw === 'detailed' || raw === 'none' ? raw : 'compact';
|
|
58
|
+
}
|
|
59
|
+
function normalise(value) {
|
|
60
|
+
if (EVENT_ID.test(value.toLowerCase()))
|
|
61
|
+
return value.toLowerCase();
|
|
62
|
+
if (!ADDRESS.test(value))
|
|
63
|
+
return undefined;
|
|
64
|
+
// The kind and pubkey are hex and compared as such; the `d` is the author's and kept as written.
|
|
65
|
+
const [kind, pubkey, ...d] = value.split(':');
|
|
66
|
+
return `${kind}:${pubkey.toLowerCase()}:${d.join(':')}`;
|
|
67
|
+
}
|
|
68
|
+
const TRAILING = new Set(['.', ',', ';', ':', '!', '?', ')', ']']);
|
|
69
|
+
/** The http(s) links in a text. Trailing punctuation is the sentence's, not the link's; stripped by a loop, which stays linear on a hostile run of dots. */
|
|
70
|
+
function urlsIn(text) {
|
|
71
|
+
return (text.match(/https?:\/\/[^\s<>"'`]+/g) ?? []).map((url) => {
|
|
72
|
+
let end = url.length;
|
|
73
|
+
while (end > 0 && TRAILING.has(url[end - 1]))
|
|
74
|
+
end--;
|
|
75
|
+
return url.slice(0, end);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/** The address or event id a `nostr:` reference names, or undefined for a person or something unreadable. */
|
|
79
|
+
function valueOfReference(reference) {
|
|
80
|
+
const bare = reference.replace(/^nostr:/i, '').toLowerCase();
|
|
81
|
+
try {
|
|
82
|
+
if (bare.startsWith('naddr1'))
|
|
83
|
+
return normalise(naddrToAddr(bare));
|
|
84
|
+
if (bare.startsWith('nevent1'))
|
|
85
|
+
return decodeNevent(bare).id.toLowerCase();
|
|
86
|
+
if (bare.startsWith('note1')) {
|
|
87
|
+
const { hrp, data } = bech32Decode(bare);
|
|
88
|
+
if (hrp !== 'note')
|
|
89
|
+
return undefined;
|
|
90
|
+
const hex = convertBits(data, 5, 8, false).map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
91
|
+
return EVENT_ID.test(hex) ? hex : undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The cards a message asks for, in the order the body first names them.
|
|
101
|
+
*
|
|
102
|
+
* `embeds` is the message's folded set; `blocks` its folded body as a render
|
|
103
|
+
* tree; `parts` its `part` pointers (§13.6.1). A value appears here only while
|
|
104
|
+
* the body names it — by a `nostr:` reference, or by an app link that
|
|
105
|
+
* `resolveLink` resolves to it (§7.7) — and only when no `part` names the
|
|
106
|
+
* same address, because the live block already stands for that object. Text in
|
|
107
|
+
* a code span names nothing (§13.1). Without `resolveLink` a link names nothing:
|
|
108
|
+
* resolving one needs the manifests and the relay, which this package does not hold.
|
|
109
|
+
*
|
|
110
|
+
* `none` entries are kept: they draw no card, but they still override the
|
|
111
|
+
* reader's own default for that value (as of 2026-10-13 Ship and Peek draw a
|
|
112
|
+
* reference alone on its line as its card; an `embed` replaces that). Filter
|
|
113
|
+
* them out to get the cards to draw.
|
|
114
|
+
*/
|
|
115
|
+
export function cardsIn(embeds, blocks, parts = [], resolveLink) {
|
|
116
|
+
if (embeds.length === 0)
|
|
117
|
+
return [];
|
|
118
|
+
const byValue = new Map(embeds.map((e) => [e.value, e]));
|
|
119
|
+
const withPart = new Set(parts.map((p) => normalise(p.address)).filter((v) => !!v));
|
|
120
|
+
const out = [];
|
|
121
|
+
const seen = new Set();
|
|
122
|
+
const take = (value) => {
|
|
123
|
+
if (!value || seen.has(value) || withPart.has(value))
|
|
124
|
+
return;
|
|
125
|
+
const embed = byValue.get(value);
|
|
126
|
+
if (!embed)
|
|
127
|
+
return;
|
|
128
|
+
seen.add(value);
|
|
129
|
+
out.push(embed);
|
|
130
|
+
};
|
|
131
|
+
// Adjacent plain runs are read as one text, so a link a mark splits in two is still one link.
|
|
132
|
+
const scan = (text) => {
|
|
133
|
+
if (!resolveLink || !text.includes('://'))
|
|
134
|
+
return;
|
|
135
|
+
for (const url of urlsIn(text)) {
|
|
136
|
+
const value = resolveLink(url);
|
|
137
|
+
if (value)
|
|
138
|
+
take(normalise(value));
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
const walk = (bs) => {
|
|
142
|
+
for (const block of bs) {
|
|
143
|
+
if (block.type !== 'codeBlock') {
|
|
144
|
+
let text = '';
|
|
145
|
+
for (const run of block.inline ?? []) {
|
|
146
|
+
if (run.reference || run.marks.includes('code')) {
|
|
147
|
+
scan(text);
|
|
148
|
+
text = '';
|
|
149
|
+
if (run.reference)
|
|
150
|
+
take(valueOfReference(run.reference));
|
|
151
|
+
}
|
|
152
|
+
else
|
|
153
|
+
text += run.text;
|
|
154
|
+
}
|
|
155
|
+
scan(text);
|
|
156
|
+
}
|
|
157
|
+
if (block.children)
|
|
158
|
+
walk(block.children);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
walk(blocks);
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=embeds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeds.js","sourceRoot":"","sources":["../src/embeds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAIjF,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAA;AAYhC,yCAAyC;AACzC,MAAM,UAAU,QAAQ,CAAC,KAAa,EAAE,MAAmB;IACzD,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AACnC,CAAC;AAED,+DAA+D;AAC/D,MAAM,OAAO,GAAG,oBAAoB,CAAA;AACpC,MAAM,QAAQ,GAAG,gBAAgB,CAAA;AAEjC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CAAC,KAA+C;IACtE,MAAM,GAAG,GAAY,EAAE,CAAA;IACvB,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IA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D,IAAI,CAAC,MAAM,CAAC,CAAA;IACZ,OAAO,GAAG,CAAA;AACZ,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.31.0";
|
|
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';
|
|
@@ -60,5 +60,6 @@ export { type RenderInline, type RenderBlock, type RenderFormat, type ContentFor
|
|
|
60
60
|
export { markerTextToBlockDocument, blockDocumentToMarkerText, type DescriptionTextOptions, } 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
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
|
+
export { type Embed, type EmbedLayout, type LinkResolver, EMBED_TAG, cardsIn, embedTag, embedsOf } from './embeds.js';
|
|
63
64
|
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
65
|
//# 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,iB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EACR,SAAS,EACT,aAAa,EACb,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,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"}
|
|
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,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gB,EAChB,iBAAiB,EACjB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,qBAAqB,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.31.0';
|
|
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,
|
|
@@ -66,5 +66,6 @@ export { CONTENT_FORMAT_TAG, BLOCK_DOCUMENT_FORMAT, contentFormatOf, toRenderTre
|
|
|
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
68
|
export { BLOCK_ANCHOR_TAG, PART_TAG, absenceOf, blockAnchorOf, partTag, partsOf, resolveBlockAnchor, resolvePart, } from './anchors.js';
|
|
69
|
+
export { EMBED_TAG, cardsIn, embedTag, embedsOf } from './embeds.js';
|
|
69
70
|
export { BLOSSOM_AUTH_TTL_SECS, buildBlossomAuth, blossomAuthHeader, imetaTag, imetaOf, imetaFromAttrs, attachmentsInDocument, sha256FromMediaUrl, fetchBlob, sha256Of, uploadBlob, imetaFor, canonicalizeImage, } from './media.js';
|
|
70
71
|
//# 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,OAAO,EAGL,mBAAmB,EACnB,SAAS,EACT,eAAe,GAChB,MA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EACT,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,GAGlB,MAAM,YAAY,CAAA"}
|
|
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,OAAO,EAGL,mBAAmB,EACnB,SAAS,EACT,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EAOL,oBAAoB,EACpB,kBAAkB,EACl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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.31.0",
|
|
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/embeds.ts
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Showing a reference as a card — SPEC §13.6.2 (OPT-16).
|
|
3
|
+
*
|
|
4
|
+
* `["embed", <value>, "compact" | "detailed" | "none"]` says how the author
|
|
5
|
+
* wants one reference in a message drawn: as a card under the message, and how
|
|
6
|
+
* much of it. `<value>` is what an `a` or `q` would carry for the same thing —
|
|
7
|
+
* an address or a 64-hex event id. The values are a density, not a widget
|
|
8
|
+
* name: `compact` is §7.5's closed `row` and `detailed` its closed `card`, so
|
|
9
|
+
* a richer card can come later without changing the wire.
|
|
10
|
+
*
|
|
11
|
+
* A reference with no `embed` is drawn by the reader's default (a chip, §13.1).
|
|
12
|
+
* An `embed` for a value overrides that default, which is why `none` exists:
|
|
13
|
+
* it is the author saying "no card" in an edit that replaces the set (§6.8).
|
|
14
|
+
*
|
|
15
|
+
* Like `part` (§13.6.1), the tags are only half the answer. A card is drawn
|
|
16
|
+
* only while the body — as edited — still names its value, and there is no
|
|
17
|
+
* `a`/`q` match: an edit carries no index tags (§6.8), and a value first named
|
|
18
|
+
* in an edit can still carry a card (Miky, 2026-10-13, OPT-16 kickoff).
|
|
19
|
+
* {@link cardsIn} applies that rule; {@link embedsOf} reads the tags alone.
|
|
20
|
+
*/
|
|
21
|
+
import { bech32Decode, convertBits, decodeNevent, naddrToAddr } from './nip19.js'
|
|
22
|
+
import type { PartPointer } from './anchors.js'
|
|
23
|
+
import type { RenderBlock } from './render.js'
|
|
24
|
+
|
|
25
|
+
export const EMBED_TAG = 'embed'
|
|
26
|
+
|
|
27
|
+
/** How much of a referenced object a card shows, or `none` for no card. */
|
|
28
|
+
export type EmbedLayout = 'compact' | 'detailed' | 'none'
|
|
29
|
+
|
|
30
|
+
/** One `embed` tag, read. */
|
|
31
|
+
export interface Embed {
|
|
32
|
+
/** An address (`kind:pubkey:d`) or a 64-hex event id, lowercase hex. */
|
|
33
|
+
value: string
|
|
34
|
+
layout: EmbedLayout
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The `embed` tag for one reference. */
|
|
38
|
+
export function embedTag(value: string, layout: EmbedLayout): string[] {
|
|
39
|
+
return [EMBED_TAG, value, layout]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// `partsOf`'s shape: an empty `d` is a valid address (NIP-01).
|
|
43
|
+
const ADDRESS = /^\d+:[0-9a-f]{64}:/
|
|
44
|
+
const EVENT_ID = /^[0-9a-f]{64}$/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The `embed` tags on one event, one per value, in tag order.
|
|
48
|
+
*
|
|
49
|
+
* The first tag for a value wins. A layout this reader does not know draws as
|
|
50
|
+
* `compact` rather than nothing: the author asked for a card, and the smallest
|
|
51
|
+
* one is the safe reading of a density added after this reader was written. A
|
|
52
|
+
* value that is neither an address nor an event id is skipped.
|
|
53
|
+
*
|
|
54
|
+
* **This is the tags only**, of one event. For a message, fold its edits first
|
|
55
|
+
* (`foldEmbeds` in `@estiva-app/conversation`), then ask {@link cardsIn} which
|
|
56
|
+
* of them the body still names.
|
|
57
|
+
*/
|
|
58
|
+
export function embedsOf(event: { tags: readonly (readonly string[])[] }): Embed[] {
|
|
59
|
+
const out: Embed[] = []
|
|
60
|
+
const seen = new Set<string>()
|
|
61
|
+
for (const tag of event.tags) {
|
|
62
|
+
if (tag[0] !== EMBED_TAG || !tag[1]) continue
|
|
63
|
+
const value = normalise(tag[1])
|
|
64
|
+
if (!value || seen.has(value)) continue
|
|
65
|
+
seen.add(value)
|
|
66
|
+
out.push({ value, layout: layoutOf(tag[2]) })
|
|
67
|
+
}
|
|
68
|
+
return out
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function layoutOf(raw: string | undefined): EmbedLayout {
|
|
72
|
+
return raw === 'detailed' || raw === 'none' ? raw : 'compact'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function normalise(value: string): string | undefined {
|
|
76
|
+
if (EVENT_ID.test(value.toLowerCase())) return value.toLowerCase()
|
|
77
|
+
if (!ADDRESS.test(value)) return undefined
|
|
78
|
+
// The kind and pubkey are hex and compared as such; the `d` is the author's and kept as written.
|
|
79
|
+
const [kind, pubkey, ...d] = value.split(':')
|
|
80
|
+
return `${kind}:${pubkey.toLowerCase()}:${d.join(':')}`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* What an app link names, as the reader resolved it by §7.7 — the host and the
|
|
85
|
+
* `<type>` segment against a published `urls` pattern, then the one author who
|
|
86
|
+
* holds that `d` — or undefined. Never a match on the link's trailing
|
|
87
|
+
* identifier alone: that resolves any site's URL as somebody's object, and puts
|
|
88
|
+
* a real issue's card under a link that does not open it (§7.7).
|
|
89
|
+
*/
|
|
90
|
+
export type LinkResolver = (url: string) => string | undefined
|
|
91
|
+
|
|
92
|
+
const TRAILING = new Set(['.', ',', ';', ':', '!', '?', ')', ']'])
|
|
93
|
+
|
|
94
|
+
/** The http(s) links in a text. Trailing punctuation is the sentence's, not the link's; stripped by a loop, which stays linear on a hostile run of dots. */
|
|
95
|
+
function urlsIn(text: string): string[] {
|
|
96
|
+
return (text.match(/https?:\/\/[^\s<>"'`]+/g) ?? []).map((url) => {
|
|
97
|
+
let end = url.length
|
|
98
|
+
while (end > 0 && TRAILING.has(url[end - 1])) end--
|
|
99
|
+
return url.slice(0, end)
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The address or event id a `nostr:` reference names, or undefined for a person or something unreadable. */
|
|
104
|
+
function valueOfReference(reference: string): string | undefined {
|
|
105
|
+
const bare = reference.replace(/^nostr:/i, '').toLowerCase()
|
|
106
|
+
try {
|
|
107
|
+
if (bare.startsWith('naddr1')) return normalise(naddrToAddr(bare))
|
|
108
|
+
if (bare.startsWith('nevent1')) return decodeNevent(bare).id.toLowerCase()
|
|
109
|
+
if (bare.startsWith('note1')) {
|
|
110
|
+
const { hrp, data } = bech32Decode(bare)
|
|
111
|
+
if (hrp !== 'note') return undefined
|
|
112
|
+
const hex = convertBits(data, 5, 8, false).map((b) => b.toString(16).padStart(2, '0')).join('')
|
|
113
|
+
return EVENT_ID.test(hex) ? hex : undefined
|
|
114
|
+
}
|
|
115
|
+
} catch {
|
|
116
|
+
return undefined
|
|
117
|
+
}
|
|
118
|
+
return undefined
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The cards a message asks for, in the order the body first names them.
|
|
123
|
+
*
|
|
124
|
+
* `embeds` is the message's folded set; `blocks` its folded body as a render
|
|
125
|
+
* tree; `parts` its `part` pointers (§13.6.1). A value appears here only while
|
|
126
|
+
* the body names it — by a `nostr:` reference, or by an app link that
|
|
127
|
+
* `resolveLink` resolves to it (§7.7) — and only when no `part` names the
|
|
128
|
+
* same address, because the live block already stands for that object. Text in
|
|
129
|
+
* a code span names nothing (§13.1). Without `resolveLink` a link names nothing:
|
|
130
|
+
* resolving one needs the manifests and the relay, which this package does not hold.
|
|
131
|
+
*
|
|
132
|
+
* `none` entries are kept: they draw no card, but they still override the
|
|
133
|
+
* reader's own default for that value (as of 2026-10-13 Ship and Peek draw a
|
|
134
|
+
* reference alone on its line as its card; an `embed` replaces that). Filter
|
|
135
|
+
* them out to get the cards to draw.
|
|
136
|
+
*/
|
|
137
|
+
export function cardsIn(embeds: readonly Embed[], blocks: readonly RenderBlock[], parts: readonly PartPointer[] = [], resolveLink?: LinkResolver): Embed[] {
|
|
138
|
+
if (embeds.length === 0) return []
|
|
139
|
+
const byValue = new Map(embeds.map((e) => [e.value, e]))
|
|
140
|
+
const withPart = new Set(parts.map((p) => normalise(p.address)).filter((v): v is string => !!v))
|
|
141
|
+
const out: Embed[] = []
|
|
142
|
+
const seen = new Set<string>()
|
|
143
|
+
const take = (value: string | undefined) => {
|
|
144
|
+
if (!value || seen.has(value) || withPart.has(value)) return
|
|
145
|
+
const embed = byValue.get(value)
|
|
146
|
+
if (!embed) return
|
|
147
|
+
seen.add(value)
|
|
148
|
+
out.push(embed)
|
|
149
|
+
}
|
|
150
|
+
// Adjacent plain runs are read as one text, so a link a mark splits in two is still one link.
|
|
151
|
+
const scan = (text: string) => {
|
|
152
|
+
if (!resolveLink || !text.includes('://')) return
|
|
153
|
+
for (const url of urlsIn(text)) {
|
|
154
|
+
const value = resolveLink(url)
|
|
155
|
+
if (value) take(normalise(value))
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const walk = (bs: readonly RenderBlock[]) => {
|
|
159
|
+
for (const block of bs) {
|
|
160
|
+
if (block.type !== 'codeBlock') {
|
|
161
|
+
let text = ''
|
|
162
|
+
for (const run of block.inline ?? []) {
|
|
163
|
+
if (run.reference || run.marks.includes('code')) {
|
|
164
|
+
scan(text)
|
|
165
|
+
text = ''
|
|
166
|
+
if (run.reference) take(valueOfReference(run.reference))
|
|
167
|
+
} else text += run.text
|
|
168
|
+
}
|
|
169
|
+
scan(text)
|
|
170
|
+
}
|
|
171
|
+
if (block.children) walk(block.children)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
walk(blocks)
|
|
175
|
+
return out
|
|
176
|
+
}
|
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.31.0'
|
|
51
51
|
|
|
52
52
|
export {
|
|
53
53
|
// types
|
|
@@ -259,6 +259,7 @@ export {
|
|
|
259
259
|
resolveBlockAnchor,
|
|
260
260
|
resolvePart,
|
|
261
261
|
} from './anchors.js'
|
|
262
|
+
export { type Embed, type EmbedLayout, type LinkResolver, EMBED_TAG, cardsIn, embedTag, embedsOf } from './embeds.js'
|
|
262
263
|
export {
|
|
263
264
|
type BlossomVerb,
|
|
264
265
|
type Imeta,
|