libp2r2p 0.12.5 → 0.12.6

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/README.md CHANGED
@@ -1102,25 +1102,24 @@ Local authentication denials, invalid events and unknown errors qualify for
1102
1102
  neither policy. Predicates classify individual native errors; callers decide
1103
1103
  how to handle mixed per-relay outcomes and application-specific aggregates.
1104
1104
  `parseRelayRetryAdvice(reason, params, { now = Date.now() })`, exported by
1105
- `libp2r2p/relay`, returns `{ retryAt, retryAfterMs? }` or `null`. It only interprets
1105
+ `libp2r2p/relay`, returns `{ retryAt, retryAfterMs }` or `null`. It only interprets
1106
1106
  leading `rate-limited:` refusals. The optional string `params` is relative
1107
- milliseconds (e.g. "2500") or an absolute Unix timestamp in milliseconds
1108
- prefixed with `@` (e.g. "@1791738154332"). Values must be positive safe integers
1109
- in canonical decimal form, without signs, whitespace, fractions or leading zeros.
1110
- Relative values produce both `retryAfterMs` and `retryAt`; absolute values produce
1111
- only `retryAt` and retain an expired deadline without starting a new wait.
1112
- Future waits are capped at five minutes. Missing or invalid params are ignored
1113
- and do not instruct clients to retry immediately. Schedulers wait until
1107
+ milliseconds (e.g. "2500"). Values must be positive safe integers in canonical
1108
+ decimal form, without signs, whitespace, fractions, leading zeros or prefixes.
1109
+ Valid values produce both `retryAfterMs` and `retryAt`. Future waits are capped
1110
+ at five minutes. Missing or invalid params are ignored and do not instruct
1111
+ clients to retry immediately. Schedulers wait until
1114
1112
  max(local backoff deadline, retryAt), never sum the two or renew the deadline on
1115
1113
  online notifications.
1116
1114
 
1117
1115
  Rate limits apply only to the client message type that triggered the refusal:
1118
1116
  `EVENT`, `AUTH`, `REQ` and `COUNT` have independent connection cooldowns. Responses
1119
1117
  are correlated with pending operations; unknown IDs never create cooldowns.
1120
- CLOSE cleanup remains immediate. The launcher can replace valid relative params
1121
- with `@` timestamps before queueing bridge delivery because its consumers share
1122
- its clock. No legacy timing objects are interpreted. Params never supply provenance
1123
- or retry eligibility; native messages, causes and codes remain intact.
1118
+ CLOSE cleanup remains immediate. A launcher-owned bridge may store the absolute
1119
+ deadline internally, but it refreshes the standard relative `params` immediately
1120
+ before consumer delivery; the private `@` syntax never crosses the WebSocket wire.
1121
+ No legacy timing objects are interpreted. Params never supply provenance or retry
1122
+ eligibility; native messages, causes and codes remain intact.
1124
1123
 
1125
1124
  ## Binary encodings
1126
1125
 
@@ -1287,9 +1286,9 @@ Nym broadcasts intentionally remain a single carrier union.
1287
1286
 
1288
1287
  ### Relay backpressure and bounded synchronization (0.11.7)
1289
1288
 
1290
- Optional decimal `params` milliseconds or `@` Unix milliseconds on relay `CLOSED`
1291
- and rejected `OK` responses are preserved as normalized `retryAt` (and
1292
- `retryAfterMs` for relative params) on native relay errors. Only `rate-limited:`
1289
+ Optional decimal `params` milliseconds on relay `CLOSED` and rejected `OK`
1290
+ responses are preserved as normalized `retryAt` and `retryAfterMs` on native relay
1291
+ errors. Only `rate-limited:`
1293
1292
  responses apply this advice; invalid values are ignored
1294
1293
  and delays are capped at five minutes. New operations of the refused type wait
1295
1294
  within their existing deadlines; active subscriptions remain live and `CLOSE`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libp2r2p",
3
- "version": "0.12.5",
3
+ "version": "0.12.6",
4
4
  "description": "Peer-to-relay-to-peer",
5
5
  "keywords": [
6
6
  "p2r2p",
@@ -31,8 +31,8 @@ export function relayCloseError (event, category, cause) {
31
31
  return categorizeRelayError(error, category)
32
32
  }
33
33
 
34
- // Keep native diagnostics and attach only bounded timing advice. An absolute
35
- // deadline survives delayed delivery through a launcher-owned relay bridge.
34
+ // Keep native diagnostics and attach only bounded timing advice. The launcher
35
+ // bridge refreshes the standard relative value immediately before delivery.
36
36
  export function relayRejectionError (reason, params, fallback) {
37
37
  const error = categorizeRelayError(reason, 'relay', fallback)
38
38
  Object.assign(error, parseRelayRetryAdvice(error.message, params))
@@ -1,13 +1,11 @@
1
- // Nostr params use relative milliseconds or @Unix milliseconds. Advice never
2
- // supplies an error category, provenance or a routing/retry policy.
1
+ // Nostr params use relative milliseconds. Advice never supplies an error
2
+ // category, provenance or a routing/retry policy.
3
3
  export function parseRelayRetryAdvice (reason, params, { now = Date.now() } = {}) {
4
4
  if (typeof reason !== 'string' || !reason.startsWith('rate-limited:') ||
5
- typeof params !== 'string' || params.match(/^@?[1-9]\d*$/)?.[0] !== params || !Number.isFinite(now)) return null
5
+ typeof params !== 'string' || params.match(/^[1-9]\d*$/)?.[0] !== params || !Number.isFinite(now)) return null
6
6
 
7
- const absolute = params.startsWith('@')
8
- const value = Number(absolute ? params.slice(1) : params)
7
+ const value = Number(params)
9
8
  if (!Number.isSafeInteger(value)) return null
10
- if (absolute) return { retryAt: Math.min(value, now + 300000) }
11
9
  const retryAfterMs = Math.min(value, 300000)
12
10
  return { retryAfterMs, retryAt: now + retryAfterMs }
13
11
  }