@estiva-app/protocol 0.1.2 → 0.2.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/dist/bridge.d.ts CHANGED
@@ -18,6 +18,25 @@ export interface PublishResult {
18
18
  * is not decoration: once no app can sign locally, an identity-service outage
19
19
  * looks exactly like nothing happening.
20
20
  */
21
+ /**
22
+ * The most events one `/query` will return, however large a `limit` the filter
23
+ * names.
24
+ *
25
+ * Buzz clamps a REQ to the NIP-11 `limitation.max_limit` it advertises. That
26
+ * value **halved from 10000 to 1000** when the fork caught up with upstream
27
+ * (upstream #3635 aligned the advertised limit with the REQ ceiling), and
28
+ * **NIP-01 has no truncation signal** — a caller asking for more receives a
29
+ * short list and no indication why. Peek loses old history, Ship loses issues,
30
+ * and every local signal stays green.
31
+ *
32
+ * It lives here because the number is a property of the *relay*, and had been
33
+ * copied as a literal into four call sites across two apps and the agent, none
34
+ * of which could know when the relay changed it.
35
+ *
36
+ * A page size, not a promise: {@link Relay.queryAll} never assumes this value
37
+ * is the relay's real ceiling — see its note on why.
38
+ */
39
+ export declare const RELAY_PAGE_CEILING = 1000;
21
40
  export declare function parsePublishResponse(status: number, text: string): PublishResult;
22
41
  export interface QueryResult {
23
42
  ok: boolean;
@@ -87,5 +106,35 @@ export declare class Relay {
87
106
  * a caller that cannot tell them apart renders an empty screen either way.
88
107
  */
89
108
  query(filters: Record<string, unknown>[]): Promise<SignedEvent[]>;
109
+ /**
110
+ * Every event matching `filters`, paged, rather than the first page.
111
+ *
112
+ * `query` returns whatever one request yielded, which is a trap the moment a
113
+ * kind grows past the relay's ceiling: the caller cannot distinguish "that is
114
+ * all of them" from "that is as many as I will give you".
115
+ *
116
+ * **Why this does not stop at a short page.** The obvious loop — page until a
117
+ * page comes back smaller than the page size — is wrong, because it trusts
118
+ * {@link RELAY_PAGE_CEILING} to equal the relay's real limit. If the relay's
119
+ * were ever *lower*, every page would look short and the first one would be
120
+ * mistaken for the whole set: the original bug, reintroduced. So the rule is
121
+ * **whether the `until` cursor still advances**, which holds whatever the true
122
+ * ceiling is, at the cost of one extra round trip at the end.
123
+ *
124
+ * `until` is inclusive in NIP-01, so the boundary event repeats on the next
125
+ * page; dedup by id absorbs that. Dedup is deliberately *not* the termination
126
+ * signal — under two filters matching the same events, a page of already-seen
127
+ * ids means "this filter overlaps the last one", not "stop".
128
+ *
129
+ * **Throws rather than truncating** when the cursor cannot advance and the
130
+ * page is full: more than `pageSize` events then share one `created_at`, no
131
+ * value of `until` reaches past them without skipping some, and no correct
132
+ * answer exists from this API — so it says so instead of returning a
133
+ * plausible subset.
134
+ */
135
+ queryAll(filters: Record<string, unknown>[], options?: {
136
+ pageSize?: number;
137
+ maxPages?: number;
138
+ }): Promise<SignedEvent[]>;
90
139
  }
91
140
  //# sourceMappingURL=bridge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAehF;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AA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AAM,MAAM,YAAY,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;AAEzF,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB,iEAAiE;IACjE,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED;;;;;;GAMG;AACH,qBAAa,KAAK;IAChB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAuB;gBAErC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,YAAY,GAAG,YAAiB;YAWpE,IAAI;IAwBZ,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAKzD;;;;;;OAMG;IACG,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAOvE;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,QAAQ,CACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAClC,OAAO,GAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAO,GACrD,OAAO,CAAC,WAAW,EAAE,CAAC;CAqC1B"}
package/dist/bridge.js CHANGED
@@ -34,6 +34,25 @@ import { authorizationHeader } from './nip98.js';
34
34
  * is not decoration: once no app can sign locally, an identity-service outage
35
35
  * looks exactly like nothing happening.
36
36
  */
37
+ /**
38
+ * The most events one `/query` will return, however large a `limit` the filter
39
+ * names.
40
+ *
41
+ * Buzz clamps a REQ to the NIP-11 `limitation.max_limit` it advertises. That
42
+ * value **halved from 10000 to 1000** when the fork caught up with upstream
43
+ * (upstream #3635 aligned the advertised limit with the REQ ceiling), and
44
+ * **NIP-01 has no truncation signal** — a caller asking for more receives a
45
+ * short list and no indication why. Peek loses old history, Ship loses issues,
46
+ * and every local signal stays green.
47
+ *
48
+ * It lives here because the number is a property of the *relay*, and had been
49
+ * copied as a literal into four call sites across two apps and the agent, none
50
+ * of which could know when the relay changed it.
51
+ *
52
+ * A page size, not a promise: {@link Relay.queryAll} never assumes this value
53
+ * is the relay's real ceiling — see its note on why.
54
+ */
55
+ export const RELAY_PAGE_CEILING = 1000;
37
56
  export function parsePublishResponse(status, text) {
38
57
  let parsed;
39
58
  try {
@@ -134,5 +153,65 @@ export class Relay {
134
153
  throw new Error(`query failed: ${result.reason}`);
135
154
  return result.events;
136
155
  }
156
+ /**
157
+ * Every event matching `filters`, paged, rather than the first page.
158
+ *
159
+ * `query` returns whatever one request yielded, which is a trap the moment a
160
+ * kind grows past the relay's ceiling: the caller cannot distinguish "that is
161
+ * all of them" from "that is as many as I will give you".
162
+ *
163
+ * **Why this does not stop at a short page.** The obvious loop — page until a
164
+ * page comes back smaller than the page size — is wrong, because it trusts
165
+ * {@link RELAY_PAGE_CEILING} to equal the relay's real limit. If the relay's
166
+ * were ever *lower*, every page would look short and the first one would be
167
+ * mistaken for the whole set: the original bug, reintroduced. So the rule is
168
+ * **whether the `until` cursor still advances**, which holds whatever the true
169
+ * ceiling is, at the cost of one extra round trip at the end.
170
+ *
171
+ * `until` is inclusive in NIP-01, so the boundary event repeats on the next
172
+ * page; dedup by id absorbs that. Dedup is deliberately *not* the termination
173
+ * signal — under two filters matching the same events, a page of already-seen
174
+ * ids means "this filter overlaps the last one", not "stop".
175
+ *
176
+ * **Throws rather than truncating** when the cursor cannot advance and the
177
+ * page is full: more than `pageSize` events then share one `created_at`, no
178
+ * value of `until` reaches past them without skipping some, and no correct
179
+ * answer exists from this API — so it says so instead of returning a
180
+ * plausible subset.
181
+ */
182
+ async queryAll(filters, options = {}) {
183
+ const pageSize = options.pageSize ?? RELAY_PAGE_CEILING;
184
+ const maxPages = options.maxPages ?? 100;
185
+ const seen = new Set();
186
+ const out = [];
187
+ for (const filter of filters) {
188
+ let until;
189
+ for (let page = 0;; page++) {
190
+ if (page >= maxPages) {
191
+ throw new Error(`queryAll: gave up after ${maxPages} pages — refusing to return a partial set`);
192
+ }
193
+ const events = await this.query([
194
+ { ...filter, limit: pageSize, ...(until === undefined ? {} : { until }) },
195
+ ]);
196
+ if (events.length === 0)
197
+ break;
198
+ for (const e of events) {
199
+ if (seen.has(e.id))
200
+ continue;
201
+ seen.add(e.id);
202
+ out.push(e);
203
+ }
204
+ const oldest = Math.min(...events.map((e) => e.created_at));
205
+ if (until !== undefined && oldest >= until) {
206
+ if (events.length >= pageSize) {
207
+ throw new Error(`queryAll: more than ${pageSize} events share created_at=${until} — cannot page without skipping`);
208
+ }
209
+ break;
210
+ }
211
+ until = oldest;
212
+ }
213
+ }
214
+ return out;
215
+ }
137
216
  }
138
217
  //# sourceMappingURL=bridge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAchD;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc,EAAE,IAAY;IAC/D,IAAI,MAAmF,CAAA;IACvF,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,yBAAyB,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,C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AI,IAAI,IAAI,QAAQ,EAAE,CAAC;oBACrB,MAAM,IAAI,KAAK,CACb,2BAA2B,QAAQ,2CAA2C,CAC/E,CAAA;gBACH,CAAC;gBACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC;oBAC9B,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE;iBAC1E,CAAC,CAAA;gBACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;oBAAE,MAAK;gBAC9B,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;oBACvB,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;wBAAE,SAAQ;oBAC5B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;oBACd,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;gBACb,CAAC;gBACD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;gBAC3D,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;oBAC3C,IAAI,MAAM,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;wBAC9B,MAAM,IAAI,KAAK,CACb,uBAAuB,QAAQ,4BAA4B,KAAK,iCAAiC,CAClG,CAAA;oBACH,CAAC;oBACD,MAAK;gBACP,CAAC;gBACD,KAAK,GAAG,MAAM,CAAA;YAChB,CAAC;QACH,CAAC;QACD,OAAO,GAAG,CAAA;IACZ,CAAC;CACF"}
package/dist/index.d.ts CHANGED
@@ -46,12 +46,12 @@
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.1.2";
49
+ export declare const PROTOCOL_VERSION = "0.2.0";
50
50
  export { type NostrTag, type UnsignedEvent, type SignedEvent, type Profile, type ThreadRef, type ChannelVisibility, type ChannelKind, type MemberRole, type Label, type ResolutionAction, KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE, computeEventId, toNostrSeconds, canonicalChannelName, threadTags, addr, relayAuthUrl, buildProfile, parseProfile, buildCreateChannel, buildDeleteChannel, buildEditChannelMetadata, buildAddMember, buildReaction, buildDeletion, buildMessage, buildResolution, buildFile, buildComponent, buildHighlight, buildUnsignedRelayAuthEvent, } from './events.js';
51
51
  export { type AddressPointer, convertBits, bech32Encode, bech32Decode, encodeNaddr, decodeNaddr, pointerToAddress, addressToPointer, addrToNaddr, naddrToAddr, referenceToPointer, NADDR_RE, findNaddrs, stripNaddrs, } from './nip19.js';
52
52
  export { type AuthEventArgs, TIMESTAMP_TOLERANCE_SECS, normalizeUrl, buildUnsignedAuthEvent, base64, authorizationHeaderFor, authorizationHeader, } from './nip98.js';
53
53
  export { type Signer, type SignerKind, publicKeyFromSecret, signEvent, secretKeySigner, } from './sign.js';
54
- export { type PublishResult, type QueryResult, type RelayHeaders, type RelayOptions, type FetchLike, parsePublishResponse, parseQueryResponse, Relay, } from './bridge.js';
54
+ export { type PublishResult, type QueryResult, type RelayHeaders, type RelayOptions, type FetchLike, parsePublishResponse, parseQueryResponse, RELAY_PAGE_CEILING, Relay, } from './bridge.js';
55
55
  export { type RelayState, type SocketLike, type RelayCredential, type LiveRelayOptions, type Subscription, type LiveRelay, toWebSocketUrl, parseFrame, createLiveRelay, } from './live.js';
56
56
  export { type ChannelEventHandler, type ChannelSubscription, type ChannelSubscriptions, createChannelSubscriptions, } from './subscriptions.js';
57
57
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,eAAO,MAAM,gBAAgB,UAAU,CAAA;AAEvC,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,KAAK,EACV,KAAK,gBAAgB,EAErB,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,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,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,cAAc,EACnB,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,GACZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,aAAa,EAClB,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,MAAM,EACN,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,MAAM,EACX,KAAK,UAAU,EACf,mBAAmB,EACnB,SAAS,EACT,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,oBAAoB,EACpB,kBAAkB,EAClB,KAAK,GACN,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,0BAA0B,GAC3B,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH;;4EAE4E;AAC5E,eAAO,MAAM,gBAAgB,UAAU,CAAA;AAEvC,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,KAAK,EACV,KAAK,gBAAgB,EAErB,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,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,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,cAAc,EACnB,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,GACZ,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,aAAa,EAClB,wBAAwB,EACxB,YAAY,EACZ,sBAAsB,EACtB,MAAM,EACN,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,KAAK,MAAM,EACX,KAAK,UAAU,EACf,mBAAmB,EACnB,SAAS,EACT,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,GACN,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,0BAA0B,GAC3B,MAAM,oBAAoB,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.1.2';
49
+ export const PROTOCOL_VERSION = '0.2.0';
50
50
  export {
51
51
  // constants
52
52
  KIND, MAX_EMOJI_CHARS, MAX_MESSAGE_BYTES, MAX_MENTIONS, MAX_RATIONALE_BYTES, RELAY_AUTH_TOLERANCE_SECS, ASSERTION_SUBTYPE,
@@ -57,7 +57,7 @@ buildProfile, parseProfile, buildCreateChannel, buildDeleteChannel, buildEditCha
57
57
  export { convertBits, bech32Encode, bech32Decode, encodeNaddr, decodeNaddr, pointerToAddress, addressToPointer, addrToNaddr, naddrToAddr, referenceToPointer, NADDR_RE, findNaddrs, stripNaddrs, } from './nip19.js';
58
58
  export { TIMESTAMP_TOLERANCE_SECS, normalizeUrl, buildUnsignedAuthEvent, base64, authorizationHeaderFor, authorizationHeader, } from './nip98.js';
59
59
  export { publicKeyFromSecret, signEvent, secretKeySigner, } from './sign.js';
60
- export { parsePublishResponse, parseQueryResponse, Relay, } from './bridge.js';
60
+ export { parsePublishResponse, parseQueryResponse, RELAY_PAGE_CEILING, Relay, } from './bridge.js';
61
61
  export { toWebSocketUrl, parseFrame, createLiveRelay, } from './live.js';
62
62
  export { createChannelSubscriptions, } from './subscriptions.js';
63
63
  //# 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,OAAO,CAAA;AAEvC,OAAO;AAYL,YAAY;AACZ,IAAI,EACJ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,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,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,cAAc,EACd,cAAc,EACd,2BAA2B,GAC5B,MAAM,aAAa,CAAA;A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,YAAY,EACZ,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,WAAW,GACZ,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,EAML,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,GACN,MAAM,aAAa,CAAA;AAEpB,OAAO,EAOL,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,WAAW,CAAA;AAElB,OAAO,EAIL,0BAA0B,GAC3B,MAAM,oBAAoB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/protocol",
3
- "version": "0.1.2",
3
+ "version": "0.2.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/bridge.ts CHANGED
@@ -47,6 +47,26 @@ export interface PublishResult {
47
47
  * is not decoration: once no app can sign locally, an identity-service outage
48
48
  * looks exactly like nothing happening.
49
49
  */
50
+ /**
51
+ * The most events one `/query` will return, however large a `limit` the filter
52
+ * names.
53
+ *
54
+ * Buzz clamps a REQ to the NIP-11 `limitation.max_limit` it advertises. That
55
+ * value **halved from 10000 to 1000** when the fork caught up with upstream
56
+ * (upstream #3635 aligned the advertised limit with the REQ ceiling), and
57
+ * **NIP-01 has no truncation signal** — a caller asking for more receives a
58
+ * short list and no indication why. Peek loses old history, Ship loses issues,
59
+ * and every local signal stays green.
60
+ *
61
+ * It lives here because the number is a property of the *relay*, and had been
62
+ * copied as a literal into four call sites across two apps and the agent, none
63
+ * of which could know when the relay changed it.
64
+ *
65
+ * A page size, not a promise: {@link Relay.queryAll} never assumes this value
66
+ * is the relay's real ceiling — see its note on why.
67
+ */
68
+ export const RELAY_PAGE_CEILING = 1000
69
+
50
70
  export function parsePublishResponse(status: number, text: string): PublishResult {
51
71
  let parsed: { accepted?: boolean; event_id?: string; message?: string; error?: string }
52
72
  try {
@@ -195,4 +215,71 @@ export class Relay {
195
215
  if (!result.ok) throw new Error(`query failed: ${result.reason}`)
196
216
  return result.events
197
217
  }
218
+
219
+ /**
220
+ * Every event matching `filters`, paged, rather than the first page.
221
+ *
222
+ * `query` returns whatever one request yielded, which is a trap the moment a
223
+ * kind grows past the relay's ceiling: the caller cannot distinguish "that is
224
+ * all of them" from "that is as many as I will give you".
225
+ *
226
+ * **Why this does not stop at a short page.** The obvious loop — page until a
227
+ * page comes back smaller than the page size — is wrong, because it trusts
228
+ * {@link RELAY_PAGE_CEILING} to equal the relay's real limit. If the relay's
229
+ * were ever *lower*, every page would look short and the first one would be
230
+ * mistaken for the whole set: the original bug, reintroduced. So the rule is
231
+ * **whether the `until` cursor still advances**, which holds whatever the true
232
+ * ceiling is, at the cost of one extra round trip at the end.
233
+ *
234
+ * `until` is inclusive in NIP-01, so the boundary event repeats on the next
235
+ * page; dedup by id absorbs that. Dedup is deliberately *not* the termination
236
+ * signal — under two filters matching the same events, a page of already-seen
237
+ * ids means "this filter overlaps the last one", not "stop".
238
+ *
239
+ * **Throws rather than truncating** when the cursor cannot advance and the
240
+ * page is full: more than `pageSize` events then share one `created_at`, no
241
+ * value of `until` reaches past them without skipping some, and no correct
242
+ * answer exists from this API — so it says so instead of returning a
243
+ * plausible subset.
244
+ */
245
+ async queryAll(
246
+ filters: Record<string, unknown>[],
247
+ options: { pageSize?: number; maxPages?: number } = {},
248
+ ): Promise<SignedEvent[]> {
249
+ const pageSize = options.pageSize ?? RELAY_PAGE_CEILING
250
+ const maxPages = options.maxPages ?? 100
251
+ const seen = new Set<string>()
252
+ const out: SignedEvent[] = []
253
+
254
+ for (const filter of filters) {
255
+ let until: number | undefined
256
+ for (let page = 0; ; page++) {
257
+ if (page >= maxPages) {
258
+ throw new Error(
259
+ `queryAll: gave up after ${maxPages} pages — refusing to return a partial set`,
260
+ )
261
+ }
262
+ const events = await this.query([
263
+ { ...filter, limit: pageSize, ...(until === undefined ? {} : { until }) },
264
+ ])
265
+ if (events.length === 0) break
266
+ for (const e of events) {
267
+ if (seen.has(e.id)) continue
268
+ seen.add(e.id)
269
+ out.push(e)
270
+ }
271
+ const oldest = Math.min(...events.map((e) => e.created_at))
272
+ if (until !== undefined && oldest >= until) {
273
+ if (events.length >= pageSize) {
274
+ throw new Error(
275
+ `queryAll: more than ${pageSize} events share created_at=${until} — cannot page without skipping`,
276
+ )
277
+ }
278
+ break
279
+ }
280
+ until = oldest
281
+ }
282
+ }
283
+ return out
284
+ }
198
285
  }
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.1.2'
50
+ export const PROTOCOL_VERSION = '0.2.0'
51
51
 
52
52
  export {
53
53
  // types
@@ -136,6 +136,7 @@ export {
136
136
  type FetchLike,
137
137
  parsePublishResponse,
138
138
  parseQueryResponse,
139
+ RELAY_PAGE_CEILING,
139
140
  Relay,
140
141
  } from './bridge.js'
141
142