@estiva-app/conversation 0.8.1 → 0.10.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 +26 -0
- package/dist/builders.d.ts +5 -9
- package/dist/builders.d.ts.map +1 -1
- package/dist/builders.js +6 -11
- package/dist/builders.js.map +1 -1
- package/dist/drafts.d.ts +22 -3
- package/dist/drafts.d.ts.map +1 -1
- package/dist/drafts.js +30 -22
- package/dist/drafts.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/builders.ts +7 -11
- package/src/drafts.ts +58 -24
- package/src/index.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,32 @@ none. A change to how an event is read is a MINOR in `0.x` even when no
|
|
|
6
6
|
signature moved, because two apps on different versions would then disagree
|
|
7
7
|
about a conversation.
|
|
8
8
|
|
|
9
|
+
## 0.10.0 — 2026-10-06
|
|
10
|
+
|
|
11
|
+
**Edit and Delete only on your own message** (SHI-29):
|
|
12
|
+
`offersEditAndDelete({ viewer, author })` is now viewer equals author, and
|
|
13
|
+
`authorIsBot` is gone. An agent's message no longer offers the controls to
|
|
14
|
+
every viewer: the relay accepts them only from the agent's NIP-OA owner, whom
|
|
15
|
+
no app can identify, so everybody else saw a control that always failed. An
|
|
16
|
+
unknown viewer is offered nothing.
|
|
17
|
+
|
|
18
|
+
SPEC: §6.5's 2026-09-29 rule and C14, amended 2026-10-06 — an app SHOULD NOT
|
|
19
|
+
offer Edit or Delete on a message the viewer did not write, an agent's
|
|
20
|
+
included. Nothing on the wire changes; the relay still adjudicates.
|
|
21
|
+
|
|
22
|
+
## 0.9.0 — 2026-10-06
|
|
23
|
+
|
|
24
|
+
**A restored draft keeps an urgent mention urgent** (CON-31): a draft now
|
|
25
|
+
keeps whom it names urgently beside its text — `write(key, text, urgent?)`
|
|
26
|
+
and `readDraft(key)` → `{ text, urgent? }`. The text cannot say it: an urgent
|
|
27
|
+
mention of somebody with a key is the same `nostr:npub…` as an ordinary one,
|
|
28
|
+
so a restored draft was sent without its `urgent` tag. `read` still returns
|
|
29
|
+
the text; a draft kept before this reads as text alone, and a malformed
|
|
30
|
+
`urgent` list costs the urgency, never the words.
|
|
31
|
+
|
|
32
|
+
SPEC: none. Drafts are local and never on the relay; the send writes §13.1's
|
|
33
|
+
existing `["urgent", <pubkey>]`, now also for a restored draft.
|
|
34
|
+
|
|
9
35
|
## 0.8.1 — 2026-10-06
|
|
10
36
|
|
|
11
37
|
**A sentence after an unmatched `[` stops asking the relay** (08d7f243):
|
package/dist/builders.d.ts
CHANGED
|
@@ -56,18 +56,14 @@ export declare function buildReply(pubkey: string, createdAtMs: number, args: {
|
|
|
56
56
|
tags?: readonly NostrTag[];
|
|
57
57
|
}): UnsignedEvent;
|
|
58
58
|
/**
|
|
59
|
-
* Whether to offer Edit and Delete on a message — §6.5, decided 2026-
|
|
60
|
-
* (C14). Offered on the viewer's own message
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* `authorIsBot` is the author's `kind:0` `bot` field: `undefined` when the
|
|
65
|
-
* profile could not be read, which offers the control — never wrong, since
|
|
66
|
-
* the relay adjudicates and the app surfaces a refusal in its words.
|
|
59
|
+
* Whether to offer Edit and Delete on a message — §6.5, decided 2026-10-06
|
|
60
|
+
* (SHI-29, C14). Offered only on the viewer's own message: not on another
|
|
61
|
+
* person's, and not on an agent's, whose NIP-OA owner the relay accepts but
|
|
62
|
+
* no app can identify — offering it to everyone showed every other viewer a
|
|
63
|
+
* control the relay refuses. An unknown viewer is offered nothing.
|
|
67
64
|
*/
|
|
68
65
|
export declare function offersEditAndDelete(args: {
|
|
69
66
|
viewer: string | null | undefined;
|
|
70
67
|
author: string;
|
|
71
|
-
authorIsBot: boolean | undefined;
|
|
72
68
|
}): boolean;
|
|
73
69
|
//# sourceMappingURL=builders.d.ts.map
|
package/dist/builders.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAA4B,KAAK,KAAK,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAmB9G;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,GAC5H,aAAa,CAsBf;AAED,6CAA6C;AAC7C,MAAM,WAAW,UAAU;IACzB,oBAAoB;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,GAChH,aAAa,CAsBf;AAED
|
|
1
|
+
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAA4B,KAAK,KA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Edit and Delete on a message — §6.5, decided 2026-
|
|
96
|
-
* (C14). Offered on the viewer's own message
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* `authorIsBot` is the author's `kind:0` `bot` field: `undefined` when the
|
|
101
|
-
* profile could not be read, which offers the control — never wrong, since
|
|
102
|
-
* the relay adjudicates and the app surfaces a refusal in its words.
|
|
95
|
+
* Whether to offer Edit and Delete on a message — §6.5, decided 2026-10-06
|
|
96
|
+
* (SHI-29, C14). Offered only on the viewer's own message: not on another
|
|
97
|
+
* person's, and not on an agent's, whose NIP-OA owner the relay accepts but
|
|
98
|
+
* no app can identify — offering it to everyone showed every other viewer a
|
|
99
|
+
* control the relay refuses. An unknown viewer is offered nothing.
|
|
103
100
|
*/
|
|
104
101
|
export function offersEditAndDelete(args) {
|
|
105
|
-
|
|
106
|
-
return true;
|
|
107
|
-
return args.authorIsBot !== false;
|
|
102
|
+
return !!args.viewer && args.viewer === args.author;
|
|
108
103
|
}
|
|
109
104
|
//# sourceMappingURL=builders.js.map
|
package/dist/builders.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builders.js","sourceRoot":"","sources":["../src/builders.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAiD,MAAM,sBAAsB,CAAA;AAC9G,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEpD;;;;GAIG;AACH,SAAS,YAAY,CAAC,MAAc;IAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;AAChH,CAAC;AAED,kEAAkE;AAClE,SAAS,aAAa,CAAC,OAAe;IACpC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GA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CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;YAC1B,CAAC,GAAG,EAAE,IAAI,CAAC;YACX,CAAC,GAAG,EAAE,MAAM,CAAC;YACb,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACtB,CAAC,GAAG,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;YAC3B,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC5D,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;YAClB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;YACvC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC;YACnC,GAAG,MAAM;SACV;QACD,OAAO,EAAE,IAAI,CAAC,IAAI;KACnB,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAA2D;IAC7F,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAA;AACrD,CAAC"}
|
package/dist/drafts.d.ts
CHANGED
|
@@ -55,11 +55,30 @@ export interface DraftStorage {
|
|
|
55
55
|
setItem(key: string, value: string): void;
|
|
56
56
|
removeItem(key: string): void;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A draft as a composer seeds from it: the marker text, and the keys of the
|
|
60
|
+
* people it names urgently (CON-31).
|
|
61
|
+
*
|
|
62
|
+
* The text cannot carry the urgency. An urgent mention of somebody with a key
|
|
63
|
+
* is written as the same `nostr:npub…` as an ordinary one, and the urgency is
|
|
64
|
+
* the `["urgent", <pubkey>]` tag the send adds (SPEC §13.1) — so a draft kept
|
|
65
|
+
* as text alone came back as an ordinary mention and was sent as one.
|
|
66
|
+
*/
|
|
67
|
+
export interface Draft {
|
|
68
|
+
text: string;
|
|
69
|
+
/** Whom the urgent chips named, by key; absent when none did. What `urgentTagsFor` takes. */
|
|
70
|
+
urgent?: string[];
|
|
71
|
+
}
|
|
58
72
|
export interface DraftStore {
|
|
59
|
-
/** The draft for this key, or `undefined` — including when storage is unusable. */
|
|
73
|
+
/** The draft's text for this key, or `undefined` — including when storage is unusable. */
|
|
60
74
|
read(key: string): string | undefined;
|
|
61
|
-
/**
|
|
62
|
-
|
|
75
|
+
/** The whole draft — its text and its urgent picks — or `undefined`, as {@link DraftStore.read}. */
|
|
76
|
+
readDraft(key: string): Draft | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Keep this text, and whom it names urgently (the composer's urgent chips, by
|
|
79
|
+
* key). An empty or whitespace-only draft is a cleared one.
|
|
80
|
+
*/
|
|
81
|
+
write(key: string, text: string, urgent?: readonly string[]): void;
|
|
63
82
|
/** Forget it — what a successful send calls. */
|
|
64
83
|
clear(key: string): void;
|
|
65
84
|
}
|
package/dist/drafts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drafts.d.ts","sourceRoot":"","sources":["../src/drafts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,mGAAmG;AACnG,eAAO,MAAM,gBAAgB,QAA2B,CAAA;AAExD;;;;GAIG;AACH,eAAO,MAAM,eAAe,OAAO,CAAA;AAKnC;;;;GAIG;AACH,eAAO,MAAM,SAAS;IACpB,6DAA6D;mBAC9C,MAAM;IACrB,yDAAyD;0BACnC,MAAM;IAC5B,mGAAmG;oBACnF,MAAM;CACvB,CAAA;AAED,wFAAwF;AACxF,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;I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,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,uEAAuE;AACvE,eAAO,MAAM,SAAS,EAAE,UAAoG,CAAA;AAE5H;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,GAAG,SAAS,EAAE,GAAG,GAAE,MAAM,MAAiB,GAAG,UAAU,CAoD5G"}
|
package/dist/drafts.js
CHANGED
|
@@ -51,8 +51,11 @@ export const draftKeys = {
|
|
|
51
51
|
/** Writing into a container itself — a Peek topic, a DM — by the id a person navigates between. */
|
|
52
52
|
container: (id) => `container:${id}`,
|
|
53
53
|
};
|
|
54
|
+
const HEX_KEY = /^[0-9a-f]{64}$/;
|
|
55
|
+
/** The keys in a list, once each — what is written, and all that is read back. */
|
|
56
|
+
const keysIn = (list) => Array.isArray(list) ? [...new Set(list.filter((k) => typeof k === 'string' && HEX_KEY.test(k)))] : [];
|
|
54
57
|
/** A store that keeps nothing, for when there is no storage to use. */
|
|
55
|
-
export const NO_DRAFTS = { read: () => undefined, write: () => { }, clear: () => { } };
|
|
58
|
+
export const NO_DRAFTS = { read: () => undefined, readDraft: () => undefined, write: () => { }, clear: () => { } };
|
|
56
59
|
/**
|
|
57
60
|
* A draft store over some storage. **Every operation is guarded**: a private
|
|
58
61
|
* window, cleared site data, blocked storage or a full quota all surface as
|
|
@@ -69,36 +72,41 @@ export function createDraftStore(storage, now = Date.now) {
|
|
|
69
72
|
// The draft is already unreachable as far as anybody reading it is concerned.
|
|
70
73
|
}
|
|
71
74
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
if (now() - draft.at > DRAFT_MAX_AGE_MS) {
|
|
85
|
-
remove(key);
|
|
86
|
-
return undefined;
|
|
87
|
-
}
|
|
88
|
-
return draft.text;
|
|
75
|
+
const readDraft = (key) => {
|
|
76
|
+
try {
|
|
77
|
+
const raw = storage.getItem(PREFIX + key);
|
|
78
|
+
if (!raw)
|
|
79
|
+
return undefined;
|
|
80
|
+
const draft = JSON.parse(raw);
|
|
81
|
+
if (typeof draft?.text !== 'string' || typeof draft?.at !== 'number') {
|
|
82
|
+
// Another version's shape, or corrupted: better dropped than shown.
|
|
83
|
+
remove(key);
|
|
84
|
+
return undefined;
|
|
89
85
|
}
|
|
90
|
-
|
|
86
|
+
if (now() - draft.at > DRAFT_MAX_AGE_MS) {
|
|
87
|
+
remove(key);
|
|
91
88
|
return undefined;
|
|
92
89
|
}
|
|
93
|
-
|
|
94
|
-
|
|
90
|
+
// A malformed `urgent` costs the urgency, not the text: the words are what a person would miss.
|
|
91
|
+
const urgent = keysIn(draft.urgent);
|
|
92
|
+
return urgent.length > 0 ? { text: draft.text, urgent } : { text: draft.text };
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
read: (key) => readDraft(key)?.text,
|
|
100
|
+
readDraft,
|
|
101
|
+
write(key, text, urgent) {
|
|
95
102
|
// Whitespace is not a draft: emptying the field forgets it.
|
|
96
103
|
if (!text.trim())
|
|
97
104
|
return remove(key);
|
|
98
105
|
if (text.length > DRAFT_MAX_CHARS)
|
|
99
106
|
return remove(key);
|
|
100
107
|
try {
|
|
101
|
-
const
|
|
108
|
+
const picks = keysIn(urgent);
|
|
109
|
+
const draft = picks.length > 0 ? { text, at: now(), urgent: picks } : { text, at: now() };
|
|
102
110
|
storage.setItem(PREFIX + key, JSON.stringify(draft));
|
|
103
111
|
}
|
|
104
112
|
catch {
|
package/dist/drafts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drafts.js","sourceRoot":"","sources":["../src/drafts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6B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AE,EAAE,CAAA;gBACtG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;YACtD,CAAC;YAAC,MAAM,CAAC;gBACP,6DAA6D;YAC/D,CAAC;QACH,CAAC;QAED,KAAK,EAAE,MAAM;KACd,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* apps: it imports no app's data layer, opens no socket, and takes every
|
|
13
13
|
* environment touch — the relay read, the clock, storage — as a parameter.
|
|
14
14
|
*/
|
|
15
|
-
export declare const CONVERSATION_VERSION = "0.
|
|
15
|
+
export declare const CONVERSATION_VERSION = "0.10.0";
|
|
16
16
|
export { KIND_MESSAGE, KIND_COMMENT, KIND_EDIT, KIND_REACTION, KIND_DELETION, KIND_ASSERTION, isConversationKind, isEventId, } from './kinds.js';
|
|
17
17
|
export { trustedTs, orderingMs, byOrder } from './order.js';
|
|
18
18
|
export { namedInBody, isReply, anchorsOf, isCommentOn, referencesAddress, strengthOn, threadStrength, referenceTagsFor, mentionTagsFor, peopleNamedInBody, MAX_MENTIONED_PEOPLE, type Strength, } from './strength.js';
|
|
@@ -26,5 +26,5 @@ export { FILE_TIER, fileReference, MESSAGE_TIER, rankReferences, REFERENCE_CAPS,
|
|
|
26
26
|
export { KIND_CHANGE, MEMBER_FIELD_PREFIX, memberField, memberOfField, mentions, streamOf, membershipOf, membersOf, membershipFilters, candidateFilesOf, buildMembershipChange, MUTED_D_TAG, APPDATA_TAG, parseMutedBlob, serializeMutedBlob, buildMutedEvent, mutedFilter, mutedFromFollowed, type Membership, type MutedList, } from './membership.js';
|
|
27
27
|
export { READ_STATE_TAG, READ_STATE_D_PREFIX, MAX_CONTEXTS, MAX_CONTEXT_ID_BYTES, MAX_TIMESTAMP, MAX_CLIENT_ID_BYTES, MAX_BLOB_BYTES, MAX_CONTEXTS_BYTES, READ_STATE_HORIZON_DAYS, channelContext, fileContext, threadContext, messageContext, toContextSeconds, isPublishableContextId, loadSlotIdentity, rotateSlotId, readStateDTag, parseReadStateBlob, serializeReadStateBlob, capContextsToBytes, capReadStateContexts, THREAD_RULE_FROM, REPLY_FLOOR_CONTEXT, advanceContexts, buildReadStateEvent, allSlotsFilter, mergeSlots, classifyOwnSlots, effectiveReadAt, threadReadAt, belowReplyFloor, fetchReadState, createSlotCache, publishReadState, type SlotCache, type SlotIdentity, type SlotStorage, type SlotSource, type RandomBytes, type ReadStateBlob, type CappedContexts, type SlotBlob, type OwnSlotVerdict, type Nip44, type FetchedReadState, } from './readState.js';
|
|
28
28
|
export { unreadIn, isUnread, type StreamJudge } from './unread.js';
|
|
29
|
-
export { createDraftStore, draftKeys, NO_DRAFTS, DRAFT_MAX_AGE_MS, DRAFT_MAX_CHARS, type DraftStore, type DraftStorage, } from './drafts.js';
|
|
29
|
+
export { createDraftStore, draftKeys, NO_DRAFTS, DRAFT_MAX_AGE_MS, DRAFT_MAX_CHARS, type Draft, type DraftStore, type DraftStorage, } from './drafts.js';
|
|
30
30
|
//# 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;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,WAAW,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3D,OAAO,EACL,WAAW,EAC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,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,GACf,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,uBAAuB,EACvB,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAElE,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,aAAa,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* apps: it imports no app's data layer, opens no socket, and takes every
|
|
13
13
|
* environment touch — the relay read, the clock, storage — as a parameter.
|
|
14
14
|
*/
|
|
15
|
-
export const CONVERSATION_VERSION = '0.
|
|
15
|
+
export const CONVERSATION_VERSION = '0.10.0';
|
|
16
16
|
export { KIND_MESSAGE, KIND_COMMENT, KIND_EDIT, KIND_REACTION, KIND_DELETION, KIND_ASSERTION, isConversationKind, isEventId, } from './kinds.js';
|
|
17
17
|
export { trustedTs, orderingMs, byOrder } from './order.js';
|
|
18
18
|
export { namedInBody, isReply, anchorsOf, isCommentOn, referencesAddress, strengthOn, threadStrength, referenceTagsFor, mentionTagsFor, peopleNamedInBody, MAX_MENTIONED_PEOPLE, } from './strength.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,QAAQ,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3D,OAAO,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,GAErB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAiB,MAAM,cAAc,CAAA;AAEpE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAiB,MAAM,YAAY,CAAA;AAEnG,OA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,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAoB,MAAM,aAAa,CAAA;AAElE,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,eAAe,GAIhB,MAAM,aAAa,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estiva-app/conversation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "The conversation rules of the Estiva SPEC (§6.2–§6.8, §11): comment and mention strengths, threading, the edit, reaction and attachment folds, NIP-22 comment and reply builders, drafts, NIP-RS read state, membership and unread. A convenience an app adopts, never a requirement.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/builders.ts
CHANGED
|
@@ -116,16 +116,12 @@ export function buildReply(
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* Whether to offer Edit and Delete on a message — §6.5, decided 2026-
|
|
120
|
-
* (C14). Offered on the viewer's own message
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* `authorIsBot` is the author's `kind:0` `bot` field: `undefined` when the
|
|
125
|
-
* profile could not be read, which offers the control — never wrong, since
|
|
126
|
-
* the relay adjudicates and the app surfaces a refusal in its words.
|
|
119
|
+
* Whether to offer Edit and Delete on a message — §6.5, decided 2026-10-06
|
|
120
|
+
* (SHI-29, C14). Offered only on the viewer's own message: not on another
|
|
121
|
+
* person's, and not on an agent's, whose NIP-OA owner the relay accepts but
|
|
122
|
+
* no app can identify — offering it to everyone showed every other viewer a
|
|
123
|
+
* control the relay refuses. An unknown viewer is offered nothing.
|
|
127
124
|
*/
|
|
128
|
-
export function offersEditAndDelete(args: { viewer: string | null | undefined; author: string
|
|
129
|
-
|
|
130
|
-
return args.authorIsBot !== false
|
|
125
|
+
export function offersEditAndDelete(args: { viewer: string | null | undefined; author: string }): boolean {
|
|
126
|
+
return !!args.viewer && args.viewer === args.author
|
|
131
127
|
}
|
package/src/drafts.ts
CHANGED
|
@@ -63,23 +63,51 @@ export interface DraftStorage {
|
|
|
63
63
|
removeItem(key: string): void
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* A draft as a composer seeds from it: the marker text, and the keys of the
|
|
68
|
+
* people it names urgently (CON-31).
|
|
69
|
+
*
|
|
70
|
+
* The text cannot carry the urgency. An urgent mention of somebody with a key
|
|
71
|
+
* is written as the same `nostr:npub…` as an ordinary one, and the urgency is
|
|
72
|
+
* the `["urgent", <pubkey>]` tag the send adds (SPEC §13.1) — so a draft kept
|
|
73
|
+
* as text alone came back as an ordinary mention and was sent as one.
|
|
74
|
+
*/
|
|
75
|
+
export interface Draft {
|
|
76
|
+
text: string
|
|
77
|
+
/** Whom the urgent chips named, by key; absent when none did. What `urgentTagsFor` takes. */
|
|
78
|
+
urgent?: string[]
|
|
79
|
+
}
|
|
80
|
+
|
|
66
81
|
interface StoredDraft {
|
|
67
82
|
text: string
|
|
68
83
|
/** When it was last typed, for the age cap. */
|
|
69
84
|
at: number
|
|
85
|
+
/** Absent in a draft with no urgent mention, and in every draft kept before CON-31. */
|
|
86
|
+
urgent?: string[]
|
|
70
87
|
}
|
|
71
88
|
|
|
89
|
+
const HEX_KEY = /^[0-9a-f]{64}$/
|
|
90
|
+
|
|
91
|
+
/** The keys in a list, once each — what is written, and all that is read back. */
|
|
92
|
+
const keysIn = (list: unknown): string[] =>
|
|
93
|
+
Array.isArray(list) ? [...new Set(list.filter((k): k is string => typeof k === 'string' && HEX_KEY.test(k)))] : []
|
|
94
|
+
|
|
72
95
|
export interface DraftStore {
|
|
73
|
-
/** The draft for this key, or `undefined` — including when storage is unusable. */
|
|
96
|
+
/** The draft's text for this key, or `undefined` — including when storage is unusable. */
|
|
74
97
|
read(key: string): string | undefined
|
|
75
|
-
/**
|
|
76
|
-
|
|
98
|
+
/** The whole draft — its text and its urgent picks — or `undefined`, as {@link DraftStore.read}. */
|
|
99
|
+
readDraft(key: string): Draft | undefined
|
|
100
|
+
/**
|
|
101
|
+
* Keep this text, and whom it names urgently (the composer's urgent chips, by
|
|
102
|
+
* key). An empty or whitespace-only draft is a cleared one.
|
|
103
|
+
*/
|
|
104
|
+
write(key: string, text: string, urgent?: readonly string[]): void
|
|
77
105
|
/** Forget it — what a successful send calls. */
|
|
78
106
|
clear(key: string): void
|
|
79
107
|
}
|
|
80
108
|
|
|
81
109
|
/** A store that keeps nothing, for when there is no storage to use. */
|
|
82
|
-
export const NO_DRAFTS: DraftStore = { read: () => undefined, write: () => {}, clear: () => {} }
|
|
110
|
+
export const NO_DRAFTS: DraftStore = { read: () => undefined, readDraft: () => undefined, write: () => {}, clear: () => {} }
|
|
83
111
|
|
|
84
112
|
/**
|
|
85
113
|
* A draft store over some storage. **Every operation is guarded**: a private
|
|
@@ -97,33 +125,39 @@ export function createDraftStore(storage: DraftStorage | undefined, now: () => n
|
|
|
97
125
|
}
|
|
98
126
|
}
|
|
99
127
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
remove(key)
|
|
109
|
-
return undefined
|
|
110
|
-
}
|
|
111
|
-
if (now() - draft.at > DRAFT_MAX_AGE_MS) {
|
|
112
|
-
remove(key)
|
|
113
|
-
return undefined
|
|
114
|
-
}
|
|
115
|
-
return draft.text
|
|
116
|
-
} catch {
|
|
128
|
+
const readDraft = (key: string): Draft | undefined => {
|
|
129
|
+
try {
|
|
130
|
+
const raw = storage.getItem(PREFIX + key)
|
|
131
|
+
if (!raw) return undefined
|
|
132
|
+
const draft = JSON.parse(raw) as Partial<StoredDraft>
|
|
133
|
+
if (typeof draft?.text !== 'string' || typeof draft?.at !== 'number') {
|
|
134
|
+
// Another version's shape, or corrupted: better dropped than shown.
|
|
135
|
+
remove(key)
|
|
117
136
|
return undefined
|
|
118
137
|
}
|
|
119
|
-
|
|
138
|
+
if (now() - draft.at > DRAFT_MAX_AGE_MS) {
|
|
139
|
+
remove(key)
|
|
140
|
+
return undefined
|
|
141
|
+
}
|
|
142
|
+
// A malformed `urgent` costs the urgency, not the text: the words are what a person would miss.
|
|
143
|
+
const urgent = keysIn(draft.urgent)
|
|
144
|
+
return urgent.length > 0 ? { text: draft.text, urgent } : { text: draft.text }
|
|
145
|
+
} catch {
|
|
146
|
+
return undefined
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
read: (key) => readDraft(key)?.text,
|
|
152
|
+
readDraft,
|
|
120
153
|
|
|
121
|
-
write(key, text) {
|
|
154
|
+
write(key, text, urgent) {
|
|
122
155
|
// Whitespace is not a draft: emptying the field forgets it.
|
|
123
156
|
if (!text.trim()) return remove(key)
|
|
124
157
|
if (text.length > DRAFT_MAX_CHARS) return remove(key)
|
|
125
158
|
try {
|
|
126
|
-
const
|
|
159
|
+
const picks = keysIn(urgent)
|
|
160
|
+
const draft: StoredDraft = picks.length > 0 ? { text, at: now(), urgent: picks } : { text, at: now() }
|
|
127
161
|
storage.setItem(PREFIX + key, JSON.stringify(draft))
|
|
128
162
|
} catch {
|
|
129
163
|
// Quota, or storage refused. The text is still in the field.
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* apps: it imports no app's data layer, opens no socket, and takes every
|
|
13
13
|
* environment touch — the relay read, the clock, storage — as a parameter.
|
|
14
14
|
*/
|
|
15
|
-
export const CONVERSATION_VERSION = '0.
|
|
15
|
+
export const CONVERSATION_VERSION = '0.10.0'
|
|
16
16
|
|
|
17
17
|
export {
|
|
18
18
|
KIND_MESSAGE,
|
|
@@ -164,6 +164,7 @@ export {
|
|
|
164
164
|
NO_DRAFTS,
|
|
165
165
|
DRAFT_MAX_AGE_MS,
|
|
166
166
|
DRAFT_MAX_CHARS,
|
|
167
|
+
type Draft,
|
|
167
168
|
type DraftStore,
|
|
168
169
|
type DraftStorage,
|
|
169
170
|
} from './drafts.js'
|