@enbox/dwn-clients 0.0.6 → 0.0.8

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/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2025 Liran Cohen
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -27,6 +27,7 @@ export class DwnRegistrar {
27
27
  // fetch the terms-of-service
28
28
  const termsOfServiceGetResponse = yield fetch(termsOfUseEndpoint, {
29
29
  method: 'GET',
30
+ signal: AbortSignal.timeout(30000),
30
31
  });
31
32
  if (termsOfServiceGetResponse.status !== 200) {
32
33
  const statusCode = termsOfServiceGetResponse.status;
@@ -38,6 +39,7 @@ export class DwnRegistrar {
38
39
  // fetch the proof-of-work challenge
39
40
  const proofOfWorkChallengeGetResponse = yield fetch(proofOfWorkEndpoint, {
40
41
  method: 'GET',
42
+ signal: AbortSignal.timeout(30000),
41
43
  });
42
44
  const { challengeNonce, maximumAllowedHashValue } = yield proofOfWorkChallengeGetResponse.json();
43
45
  // create registration data based on the hash of the terms-of-service and the DID
@@ -63,6 +65,7 @@ export class DwnRegistrar {
63
65
  method: 'POST',
64
66
  headers: { 'Content-Type': 'application/json' },
65
67
  body: JSON.stringify(registrationRequest),
68
+ signal: AbortSignal.timeout(30000),
66
69
  });
67
70
  if (registrationResponse.status !== 200) {
68
71
  const statusCode = registrationResponse.status;
@@ -134,6 +137,7 @@ export class DwnRegistrar {
134
137
  code,
135
138
  redirectUri,
136
139
  }),
140
+ signal: AbortSignal.timeout(30000),
137
141
  });
138
142
  if (response.status !== 200) {
139
143
  const errorText = yield response.text();
@@ -158,6 +162,7 @@ export class DwnRegistrar {
158
162
  grantType: 'refresh_token',
159
163
  refreshToken,
160
164
  }),
165
+ signal: AbortSignal.timeout(30000),
161
166
  });
162
167
  if (response.status !== 200) {
163
168
  const errorText = yield response.text();
@@ -189,6 +194,7 @@ export class DwnRegistrar {
189
194
  method: 'POST',
190
195
  headers: { 'Content-Type': 'application/json' },
191
196
  body: JSON.stringify(registrationRequest),
197
+ signal: AbortSignal.timeout(30000),
192
198
  });
193
199
  if (response.status !== 200) {
194
200
  const errorText = yield response.text();
@@ -1 +1 @@
1
- {"version":3,"file":"dwn-registrar.js","sourceRoot":"","sources":["../../src/dwn-registrar.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB;;;;OAIG;IACI,MAAM,CAAO,cAAc,CAAC,WAAmB,EAAE,GAAW;;YAEjE,MAAM,oBAAoB,GAAG,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YACzE,MAAM,kBAAkB,GAAG,cAAc,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC;YACpF,MAAM,mBAAmB,GAAG,cAAc,CAAC,oBAAoB,EAAE,eAAe,CAAC,CAAC;YAElF,6BAA6B;YAC7B,MAAM,yBAAyB,GAAG,MAAM,KAAK,CAAC,kBAAkB,EAAE;gBAChE,MAAM,EAAE,KAAK;aACd,CAAC,CAAC;YAEH,IAAI,yBAAyB,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC7C,MAAM,UAAU,GAAG,yBAAyB,CAAC,MAAM,CAAC;gBACpD,MAAM,UAAU,GAAG,yBAAyB,CAAC,UAAU,CAAC;gBACxD,MAAM,SAAS,GAAG,MAAM,yBAAyB,CAAC,IAAI,EAAE,CAAC;gBACzD,MAAM,IAAI,KAAK,CAAC,qCAAqC,UAAU,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC,CAAC;YACjG,CAAC;YACD,MAAM,qBAAqB,GAAG,MAAM,yBAAyB,CAAC,IAAI,EAAE,CAAC;YAErE,oCAAoC;YACpC,MAAM,+B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mB,EACnB,GAAW,EACX,iBAAyB,EACzB,kBAA2B;;YAE3B,MAAM,oBAAoB,GAAG,cAAc,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;YAEzE,MAAM,mBAAmB,GAAwB;gBAC/C,YAAY,EAAO,EAAE,iBAAiB,EAAE;gBACxC,gBAAgB,EAAG;oBACjB,GAAG;oBACH,kBAAkB;iBACnB;aACF,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,oBAAoB,EAAE;gBACjD,MAAM,EAAI,MAAM;gBAChB,OAAO,EAAG,EAAE,cAAc,EAAE,kBAAkB,EAAE;gBAChD,IAAI,EAAM,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC;gBAC7C,MAAM,EAAI,WAAW,CAAC,OAAO,CAAC,KAAM,CAAC;aACtC,CAAC,CAAC;YAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACxC,MAAM,IAAI,KAAK,CAAC,oDAAoD,QAAQ,CAAC,MAAM,MAAM,SAAS,EAAE,CAAC,CAAC;YACxG,CAAC;QACH,CAAC;KAAA;CACF"}
@@ -59,6 +59,17 @@ export class DwnServerInfoCacheMemory {
59
59
  this.cache.clear();
60
60
  });
61
61
  }
62
+ /**
63
+ * This method is a no-op but exists to be consistent with other DWN ServerInfo Cache
64
+ * implementations.
65
+ *
66
+ * @returns A promise that resolves immediately.
67
+ */
68
+ open() {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ // No-op since there is no underlying store to open.
71
+ });
72
+ }
62
73
  /**
63
74
  * This method is a no-op but exists to be consistent with other DWN ServerInfo Cache
64
75
  * implementations.
@@ -1 +1 @@
1
- {"version":3,"file":"dwn-server-info-cache-memory.js","sourceRoot":"","sources":["../../src/dwn-server-info-cache-memory.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,MAAM,IAAI,CAAC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c;;YAC7B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAChC,CAAC;KAAA;IAED;;;;;;OAMG;IACU,GAAG,CAAC,MAAc,EAAE,KAAiB;;YAChD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAChC,CAAC;KAAA;IAED;;;;;OAKG;IACU,MAAM,CAAC,MAAc;;YAChC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC5B,CAAC;KAAA;IAED;;;;OAIG;IACU,KAAK;;YAChB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;KAAA;IAED;;;;;OAKG;IACU,IAAI;;YACf,oDAAoD;QACtD,CAAC;KAAA;IAED;;;;;OAKG;IACU,KAAK;;YAChB,qDAAqD;QACvD,CAAC;KAAA;CACF"}
@@ -10,17 +10,88 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { CryptoUtils } from '@enbox/crypto';
11
11
  import { DataStream } from '@enbox/dwn-sdk-js';
12
12
  import { DwnServerInfoCacheMemory } from './dwn-server-info-cache-memory.js';
13
- import { createJsonRpcRequest, parseJson } from './json-rpc.js';
13
+ import { RateLimitError } from './rate-limit-error.js';
14
+ import { createJsonRpcRequest, JsonRpcErrorCodes, parseJson } from './json-rpc.js';
15
+ // ---------------------------------------------------------------------------
16
+ // Retry configuration
17
+ // ---------------------------------------------------------------------------
18
+ /** Default number of retry attempts for transient HTTP failures. */
19
+ const DEFAULT_MAX_RETRIES = 3;
20
+ /** Base delay in milliseconds for exponential backoff. */
21
+ const DEFAULT_BASE_DELAY_MS = 500;
22
+ /** Maximum backoff delay in milliseconds. */
23
+ const DEFAULT_MAX_DELAY_MS = 10000;
24
+ /** Per-request timeout in milliseconds (prevents hung connections / SSRF). */
25
+ const DEFAULT_REQUEST_TIMEOUT_MS = 30000;
26
+ /** HTTP status codes that are considered retryable. */
27
+ const RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504]);
14
28
  /**
15
- * HTTP client that can be used to communicate with Dwn Servers
29
+ * Determines whether a fetch error or HTTP response warrants a retry.
30
+ * Network errors (TypeError from fetch) and specific HTTP status codes are retryable.
31
+ */
32
+ function isRetryable(error, response) {
33
+ if (error instanceof TypeError) {
34
+ // TypeError is thrown by fetch for network-level failures (DNS, connection refused, etc.).
35
+ return true;
36
+ }
37
+ if (response) {
38
+ return RETRYABLE_STATUS_CODES.has(response.status);
39
+ }
40
+ return false;
41
+ }
42
+ /**
43
+ * Computes the backoff delay with jitter for a given attempt.
44
+ * Uses exponential backoff: `min(baseDelay * 2^attempt, maxDelay) * jitter`.
45
+ */
46
+ function computeBackoffDelay(attempt, baseDelayMs, maxDelayMs) {
47
+ const exponentialDelay = Math.min(baseDelayMs * Math.pow(2, attempt), maxDelayMs);
48
+ const jitter = 0.5 + Math.random() * 0.5;
49
+ return exponentialDelay * jitter;
50
+ }
51
+ /**
52
+ * Parses a `retry-after` header value into milliseconds.
53
+ * Supports both delay-seconds (e.g. "120") and HTTP-date formats.
54
+ * Returns `undefined` if the header is absent or unparseable.
55
+ */
56
+ function parseRetryAfterMs(response) {
57
+ const retryAfter = response.headers.get('retry-after');
58
+ if (retryAfter === null) {
59
+ return undefined;
60
+ }
61
+ // Try as integer seconds first.
62
+ const seconds = Number(retryAfter);
63
+ if (!Number.isNaN(seconds) && seconds >= 0) {
64
+ return seconds * 1000;
65
+ }
66
+ // Try as HTTP-date.
67
+ const date = new Date(retryAfter);
68
+ if (!Number.isNaN(date.getTime())) {
69
+ const delayMs = date.getTime() - Date.now();
70
+ return delayMs > 0 ? delayMs : 0;
71
+ }
72
+ return undefined;
73
+ }
74
+ /**
75
+ * HTTP client that can be used to communicate with Dwn Servers.
76
+ *
77
+ * Supports automatic retry with exponential backoff and jitter for transient
78
+ * network errors and retryable HTTP status codes (408, 429, 500, 502, 503, 504).
79
+ * Respects the `Retry-After` response header when present.
16
80
  */
17
81
  export class HttpDwnRpcClient {
18
- constructor(serverInfoCache) {
82
+ constructor(serverInfoCache, retryOptions) {
83
+ var _a, _b, _c;
19
84
  this.serverInfoCache = serverInfoCache !== null && serverInfoCache !== void 0 ? serverInfoCache : new DwnServerInfoCacheMemory();
85
+ this._retryOptions = {
86
+ maxRetries: (_a = retryOptions === null || retryOptions === void 0 ? void 0 : retryOptions.maxRetries) !== null && _a !== void 0 ? _a : DEFAULT_MAX_RETRIES,
87
+ baseDelayMs: (_b = retryOptions === null || retryOptions === void 0 ? void 0 : retryOptions.baseDelayMs) !== null && _b !== void 0 ? _b : DEFAULT_BASE_DELAY_MS,
88
+ maxDelayMs: (_c = retryOptions === null || retryOptions === void 0 ? void 0 : retryOptions.maxDelayMs) !== null && _c !== void 0 ? _c : DEFAULT_MAX_DELAY_MS,
89
+ };
20
90
  }
21
91
  get transportProtocols() { return ['http:', 'https:']; }
22
92
  sendDwnRequest(request) {
23
93
  return __awaiter(this, void 0, void 0, function* () {
94
+ var _a, _b, _c;
24
95
  const requestId = CryptoUtils.randomUuid();
25
96
  const jsonRpcRequest = createJsonRpcRequest(requestId, 'dwn.processMessage', {
26
97
  target: request.targetDid,
@@ -41,7 +112,14 @@ export class HttpDwnRpcClient {
41
112
  // TypeScript's built-in RequestInit does not include `duplex` yet.
42
113
  fetchOpts.duplex = 'half';
43
114
  }
44
- const resp = yield fetch(request.dwnUrl, fetchOpts);
115
+ const resp = yield this.fetchWithRetry(request.dwnUrl, fetchOpts);
116
+ // After retries are exhausted, a 429 means we're still rate-limited.
117
+ // Per-IP 429s return plain JSON (not a JSON-RPC envelope), so we must
118
+ // check the status before attempting JSON-RPC parsing.
119
+ if (resp.status === 429) {
120
+ const retryAfter = parseInt((_a = resp.headers.get('retry-after')) !== null && _a !== void 0 ? _a : '1', 10);
121
+ throw new RateLimitError(retryAfter);
122
+ }
45
123
  let dwnRpcResponse;
46
124
  // When the server streams record data back, the JSON-RPC envelope is in the
47
125
  // `dwn-response` header and the body is the raw data stream. Otherwise the
@@ -64,6 +142,10 @@ export class HttpDwnRpcClient {
64
142
  }
65
143
  if (dwnRpcResponse.error) {
66
144
  const { code, message } = dwnRpcResponse.error;
145
+ if (code === JsonRpcErrorCodes.TooManyRequests) {
146
+ const retryAfter = (_c = (_b = dwnRpcResponse.error.data) === null || _b === void 0 ? void 0 : _b.retryAfterSec) !== null && _c !== void 0 ? _c : 1;
147
+ throw new RateLimitError(retryAfter);
148
+ }
67
149
  throw new Error(`(${code}) - ${message}`);
68
150
  }
69
151
  // Materialise the response body before attaching to the reply.
@@ -88,6 +170,7 @@ export class HttpDwnRpcClient {
88
170
  }
89
171
  getServerInfo(dwnUrl) {
90
172
  return __awaiter(this, void 0, void 0, function* () {
173
+ var _a;
91
174
  const serverInfo = yield this.serverInfoCache.get(dwnUrl);
92
175
  if (serverInfo) {
93
176
  return serverInfo;
@@ -96,7 +179,11 @@ export class HttpDwnRpcClient {
96
179
  // add `/info` to the dwn server url path
97
180
  url.pathname.endsWith('/') ? url.pathname += 'info' : url.pathname += '/info';
98
181
  try {
99
- const response = yield fetch(url.toString());
182
+ const response = yield this.fetchWithRetry(url.toString());
183
+ if (response.status === 429) {
184
+ const retryAfter = parseInt((_a = response.headers.get('retry-after')) !== null && _a !== void 0 ? _a : '1', 10);
185
+ throw new RateLimitError(retryAfter);
186
+ }
100
187
  if (response.ok) {
101
188
  const results = yield response.json();
102
189
  const serverInfo = {
@@ -120,5 +207,53 @@ export class HttpDwnRpcClient {
120
207
  }
121
208
  });
122
209
  }
210
+ // ---------------------------------------------------------------------------
211
+ // Retry logic
212
+ // ---------------------------------------------------------------------------
213
+ /**
214
+ * Wrapper around `fetch()` that retries on transient network errors and
215
+ * retryable HTTP status codes with exponential backoff and jitter.
216
+ * Honours the `Retry-After` response header when present.
217
+ */
218
+ fetchWithRetry(url, init) {
219
+ return __awaiter(this, void 0, void 0, function* () {
220
+ const { maxRetries, baseDelayMs, maxDelayMs } = this._retryOptions;
221
+ let lastError;
222
+ let lastResponse;
223
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
224
+ try {
225
+ // Apply a per-attempt timeout to prevent hung connections / SSRF.
226
+ // If the caller already supplied a signal, combine it with the timeout
227
+ // via AbortSignal.any(); otherwise create a fresh timeout signal.
228
+ const timeoutSignal = AbortSignal.timeout(DEFAULT_REQUEST_TIMEOUT_MS);
229
+ const attemptInit = Object.assign(Object.assign({}, init), { signal: (init === null || init === void 0 ? void 0 : init.signal)
230
+ ? AbortSignal.any([init.signal, timeoutSignal])
231
+ : timeoutSignal });
232
+ const response = yield fetch(url, attemptInit);
233
+ if (!RETRYABLE_STATUS_CODES.has(response.status) || attempt === maxRetries) {
234
+ return response;
235
+ }
236
+ // Retryable status — back off and try again.
237
+ lastResponse = response;
238
+ }
239
+ catch (error) {
240
+ if (!isRetryable(error) || attempt === maxRetries) {
241
+ throw error;
242
+ }
243
+ lastError = error;
244
+ }
245
+ // Compute the delay, preferring Retry-After when available.
246
+ const retryAfterMs = lastResponse ? parseRetryAfterMs(lastResponse) : undefined;
247
+ const backoffMs = computeBackoffDelay(attempt, baseDelayMs, maxDelayMs);
248
+ const delayMs = retryAfterMs !== undefined ? Math.max(retryAfterMs, backoffMs) : backoffMs;
249
+ yield new Promise((resolve) => { setTimeout(resolve, delayMs); });
250
+ }
251
+ // Should not reach here, but satisfy the compiler.
252
+ if (lastResponse) {
253
+ return lastResponse;
254
+ }
255
+ throw lastError;
256
+ });
257
+ }
123
258
  }
124
259
  //# sourceMappingURL=http-dwn-rpc-client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"http-dwn-rpc-client.js","sourceRoot":"","sources":["../../src/http-dwn-rpc-client.ts"],"names":[],"mappings":";;;;;;;;;AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAm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C,OAAO,KAAc,EAAE,CAAC;oBACxB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;wBAClD,MAAM,KAAK,CAAC;oBACd,CAAC;oBACD,SAAS,GAAG,KAAK,CAAC;gBACpB,CAAC;gBAED,4DAA4D;gBAC5D,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBAChF,MAAM,SAAS,GAAG,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;gBACxE,MAAM,OAAO,GAAG,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;gBAE3F,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAQ,EAAE,GAAG,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChF,CAAC;YAED,mDAAmD;YACnD,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,YAAY,CAAC;YACtB,CAAC;YACD,MAAM,SAAS,CAAC;QAClB,CAAC;KAAA;CACF"}
package/dist/esm/index.js CHANGED
@@ -5,6 +5,7 @@ export * from './http-dwn-rpc-client.js';
5
5
  export * from './json-rpc.js';
6
6
  export * from './json-rpc-socket.js';
7
7
  export * from './provider-directory-types.js';
8
+ export * from './rate-limit-error.js';
8
9
  export * from './registration-types.js';
9
10
  export * from './rpc-client.js';
10
11
  export * from './server-info-types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC"}
@@ -12,6 +12,7 @@ export var JsonRpcErrorCodes;
12
12
  JsonRpcErrorCodes[JsonRpcErrorCodes["Unauthorized"] = -50401] = "Unauthorized";
13
13
  JsonRpcErrorCodes[JsonRpcErrorCodes["Forbidden"] = -50403] = "Forbidden";
14
14
  JsonRpcErrorCodes[JsonRpcErrorCodes["Conflict"] = -50409] = "Conflict";
15
+ JsonRpcErrorCodes[JsonRpcErrorCodes["TooManyRequests"] = -50429] = "TooManyRequests";
15
16
  })(JsonRpcErrorCodes || (JsonRpcErrorCodes = {}));
16
17
  export const createJsonRpcErrorResponse = (id, code, message, data) => {
17
18
  const error = { code, message };
@@ -1 +1 @@
1
- {"version":3,"file":"json-rpc.js","sourceRoot":"","sources":["../../src/json-rpc.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAN,IAAY,iBAcX;AAdD,WAAY,iBAAiB;IAC3B,kCAAkC;IAClC,kFAAuB,CAAA;IACvB,kFAAuB,CAAA;IACvB,gFAAsB,CAAA;IACtB,gFAAsB,CAAA;IACtB,0EAA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C;AAEF;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,WAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Thrown when a DWN server rejects a request due to rate limiting (HTTP 429).
3
+ *
4
+ * Consumers can catch this error to implement retry logic using the
5
+ * {@link retryAfterSec} value provided by the server.
6
+ */
7
+ export class RateLimitError extends Error {
8
+ constructor(retryAfterSec, message) {
9
+ super(message !== null && message !== void 0 ? message : `Rate limit exceeded, retry after ${retryAfterSec}s`);
10
+ this.name = 'RateLimitError';
11
+ this.retryAfterSec = retryAfterSec;
12
+ }
13
+ }
14
+ //# sourceMappingURL=rate-limit-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit-error.js","sourceRoot":"","sources":["../../src/rate-limit-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAIvC,YAAY,aAAqB,EAAE,OAAgB;QACjD,KAAK,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,oCAAoC,aAAa,GAAG,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF"}
@@ -88,7 +88,7 @@ export class HttpWeb5RpcClient extends HttpDwnRpcClient {
88
88
  });
89
89
  let jsonRpcResponse;
90
90
  try {
91
- const response = yield fetch(httpRequest);
91
+ const response = yield fetch(httpRequest, { signal: AbortSignal.timeout(30000) });
92
92
  if (response.ok) {
93
93
  jsonRpcResponse = yield response.json();
94
94
  // If the response is an error, throw an error.
@@ -1 +1 @@
1
- {"version":3,"file":"rpc-client.js","sourceRoot":"","sources":["../../src/rpc-client.ts"],"names":[],"mappings":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ACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,CAAC;IAoBjC;;;;;;OAMG;WACiB,wBAAwB,CAC1C,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,qBAAqB,CAAC;IAmBjC;;;;;;;;OAQG;WACiB,uBAAuB,CACzC,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,MAAM,EACX,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,IAAI,CAAC;CAuBjB"}
@@ -46,6 +46,13 @@ export declare class DwnServerInfoCacheMemory implements DwnServerInfoCache {
46
46
  * @returns A promise that resolves when the operation is complete.
47
47
  */
48
48
  clear(): Promise<void>;
49
+ /**
50
+ * This method is a no-op but exists to be consistent with other DWN ServerInfo Cache
51
+ * implementations.
52
+ *
53
+ * @returns A promise that resolves immediately.
54
+ */
55
+ open(): Promise<void>;
49
56
  /**
50
57
  * This method is a no-op but exists to be consistent with other DWN ServerInfo Cache
51
58
  * implementations.
@@ -1 +1 @@
1
- {"version":3,"file":"dwn-server-info-cache-memory.d.ts","sourceRoot":"","sources":["../../src/dwn-server-info-cache-memory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE7E;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAAa,wBAAyB,YAAW,kBAAkB;IACjE,OAAO,CAAC,KAAK,CAA+B;gBAEhC,EAAE,GAAW,EAAE,GAAE,8BAAkC;IAI/D;;;;;;;OAOG;IACU,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAE,SAAS,CAAC;IAIhE;;;;;;OAMG;IACU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlE;;;;;OAKG;IACU,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;;;OAIG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC;;;;;OAKG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
1
+ {"version":3,"file":"dwn-server-info-cache-memory.d.ts","sourceRoot":"","sources":["../../src/dwn-server-info-cache-memory.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE7E;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,qBAAa,wBAAyB,YAAW,kBAAkB;IACjE,OAAO,CAAC,KAAK,CAA+B;gBAEhC,EAAE,GAAW,EAAE,GAAE,8BAAkC;IAI/D;;;;;;;OAOG;IACU,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAE,SAAS,CAAC;IAIhE;;;;;;OAMG;IACU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlE;;;;;OAKG;IACU,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlD;;;;OAIG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC;;;;;OAKG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAIlC;;;;;OAKG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
@@ -1,13 +1,35 @@
1
1
  import type { DwnRpc, DwnRpcRequest, DwnRpcResponse } from './dwn-rpc-types.js';
2
2
  import type { DwnServerInfoCache, ServerInfo } from './server-info-types.js';
3
3
  /**
4
- * HTTP client that can be used to communicate with Dwn Servers
4
+ * Options for controlling HTTP retry behaviour.
5
+ */
6
+ export type HttpRetryOptions = {
7
+ /** Maximum number of retry attempts (0 = no retries). Default: 3. */
8
+ maxRetries?: number;
9
+ /** Base delay in milliseconds for exponential backoff. Default: 500. */
10
+ baseDelayMs?: number;
11
+ /** Maximum backoff delay in milliseconds. Default: 10 000. */
12
+ maxDelayMs?: number;
13
+ };
14
+ /**
15
+ * HTTP client that can be used to communicate with Dwn Servers.
16
+ *
17
+ * Supports automatic retry with exponential backoff and jitter for transient
18
+ * network errors and retryable HTTP status codes (408, 429, 500, 502, 503, 504).
19
+ * Respects the `Retry-After` response header when present.
5
20
  */
6
21
  export declare class HttpDwnRpcClient implements DwnRpc {
7
22
  private serverInfoCache;
8
- constructor(serverInfoCache?: DwnServerInfoCache);
23
+ private _retryOptions;
24
+ constructor(serverInfoCache?: DwnServerInfoCache, retryOptions?: HttpRetryOptions);
9
25
  get transportProtocols(): string[];
10
26
  sendDwnRequest(request: DwnRpcRequest): Promise<DwnRpcResponse>;
11
27
  getServerInfo(dwnUrl: string): Promise<ServerInfo>;
28
+ /**
29
+ * Wrapper around `fetch()` that retries on transient network errors and
30
+ * retryable HTTP status codes with exponential backoff and jitter.
31
+ * Honours the `Retry-After` response header when present.
32
+ */
33
+ private fetchWithRetry;
12
34
  }
13
35
  //# sourceMappingURL=http-dwn-rpc-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http-dwn-rpc-client.d.ts","sourceRoot":"","sources":["../../src/http-dwn-rpc-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAO7E;;GAEG;AACH,qBAAa,gBAAiB,YAAW,MAAM;IAC7C,OAAO,CAAC,eAAe,CAAqB;gBAChC,eAAe,CAAC,EAAE,kBAAkB;IAIhD,IAAI,kBAAkB,IAAI,MAAM,EAAE,CAAgC;IAE5D,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IA8E/D,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAmCzD"}
1
+ {"version":3,"file":"http-dwn-rpc-client.d.ts","sourceRoot":"","sources":["../../src/http-dwn-rpc-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AA2B7E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAsDF;;;;;;GAMG;AACH,qBAAa,gBAAiB,YAAW,MAAM;IAC7C,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,aAAa,CAA6B;gBAEtC,eAAe,CAAC,EAAE,kBAAkB,EAAE,YAAY,CAAC,EAAE,gBAAgB;IASjF,IAAI,kBAAkB,IAAI,MAAM,EAAE,CAAgC;IAE5D,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;IA2F/D,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IA4CxD;;;;OAIG;YACW,cAAc;CAgD7B"}
@@ -5,6 +5,7 @@ export * from './http-dwn-rpc-client.js';
5
5
  export * from './json-rpc.js';
6
6
  export * from './json-rpc-socket.js';
7
7
  export * from './provider-directory-types.js';
8
+ export * from './rate-limit-error.js';
8
9
  export * from './registration-types.js';
9
10
  export * from './rpc-client.js';
10
11
  export * from './server-info-types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC"}
@@ -31,7 +31,8 @@ export declare enum JsonRpcErrorCodes {
31
31
  BadRequest = -50400,// equivalent to HTTP Status 400
32
32
  Unauthorized = -50401,// equivalent to HTTP Status 401
33
33
  Forbidden = -50403,// equivalent to HTTP Status 403
34
- Conflict = -50409
34
+ Conflict = -50409,// equivalent to HTTP Status 409
35
+ TooManyRequests = -50429
35
36
  }
36
37
  export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
37
38
  export interface JsonRpcSuccessResponse {
@@ -1 +1 @@
1
- {"version":3,"file":"json-rpc.d.ts","sourceRoot":"","sources":["../../src/json-rpc.ts"],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AAM,4BAA4B,OACnC,SAAS,WACJ,GAAG,KACX,sBAMF,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMrD"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Thrown when a DWN server rejects a request due to rate limiting (HTTP 429).
3
+ *
4
+ * Consumers can catch this error to implement retry logic using the
5
+ * {@link retryAfterSec} value provided by the server.
6
+ */
7
+ export declare class RateLimitError extends Error {
8
+ /** Seconds the client should wait before retrying, as reported by the server. */
9
+ readonly retryAfterSec: number;
10
+ constructor(retryAfterSec: number, message?: string);
11
+ }
12
+ //# sourceMappingURL=rate-limit-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit-error.d.ts","sourceRoot":"","sources":["../../src/rate-limit-error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,iFAAiF;IACjF,SAAgB,aAAa,EAAE,MAAM,CAAC;gBAE1B,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAKpD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enbox/dwn-clients",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -46,9 +46,9 @@
46
46
  "bun": ">=1.0.0"
47
47
  },
48
48
  "dependencies": {
49
- "@enbox/common": "0.0.4",
50
- "@enbox/crypto": "0.0.5",
51
- "@enbox/dwn-sdk-js": "0.0.8",
49
+ "@enbox/common": "0.0.6",
50
+ "@enbox/crypto": "0.0.7",
51
+ "@enbox/dwn-sdk-js": "0.1.1",
52
52
  "ms": "2.1.3"
53
53
  },
54
54
  "devDependencies": {
@@ -21,7 +21,8 @@ export class DwnRegistrar {
21
21
 
22
22
  // fetch the terms-of-service
23
23
  const termsOfServiceGetResponse = await fetch(termsOfUseEndpoint, {
24
- method: 'GET',
24
+ method : 'GET',
25
+ signal : AbortSignal.timeout(30_000),
25
26
  });
26
27
 
27
28
  if (termsOfServiceGetResponse.status !== 200) {
@@ -34,7 +35,8 @@ export class DwnRegistrar {
34
35
 
35
36
  // fetch the proof-of-work challenge
36
37
  const proofOfWorkChallengeGetResponse = await fetch(proofOfWorkEndpoint, {
37
- method: 'GET',
38
+ method : 'GET',
39
+ signal : AbortSignal.timeout(30_000),
38
40
  });
39
41
  const { challengeNonce, maximumAllowedHashValue }: ProofOfWorkChallengeModel =
40
42
  await proofOfWorkChallengeGetResponse.json();
@@ -65,6 +67,7 @@ export class DwnRegistrar {
65
67
  method : 'POST',
66
68
  headers : { 'Content-Type': 'application/json' },
67
69
  body : JSON.stringify(registrationRequest),
70
+ signal : AbortSignal.timeout(30_000),
68
71
  });
69
72
 
70
73
  if (registrationResponse.status !== 200) {
@@ -149,6 +152,7 @@ export class DwnRegistrar {
149
152
  code,
150
153
  redirectUri,
151
154
  }),
155
+ signal: AbortSignal.timeout(30_000),
152
156
  });
153
157
 
154
158
  if (response.status !== 200) {
@@ -177,6 +181,7 @@ export class DwnRegistrar {
177
181
  grantType: 'refresh_token',
178
182
  refreshToken,
179
183
  }),
184
+ signal: AbortSignal.timeout(30_000),
180
185
  });
181
186
 
182
187
  if (response.status !== 200) {
@@ -216,6 +221,7 @@ export class DwnRegistrar {
216
221
  method : 'POST',
217
222
  headers : { 'Content-Type': 'application/json' },
218
223
  body : JSON.stringify(registrationRequest),
224
+ signal : AbortSignal.timeout(30_000),
219
225
  });
220
226
 
221
227
  if (response.status !== 200) {
@@ -68,6 +68,16 @@ export class DwnServerInfoCacheMemory implements DwnServerInfoCache {
68
68
  this.cache.clear();
69
69
  }
70
70
 
71
+ /**
72
+ * This method is a no-op but exists to be consistent with other DWN ServerInfo Cache
73
+ * implementations.
74
+ *
75
+ * @returns A promise that resolves immediately.
76
+ */
77
+ public async open(): Promise<void> {
78
+ // No-op since there is no underlying store to open.
79
+ }
80
+
71
81
  /**
72
82
  * This method is a no-op but exists to be consistent with other DWN ServerInfo Cache
73
83
  * implementations.
@@ -5,15 +5,110 @@ import type { DwnServerInfoCache, ServerInfo } from './server-info-types.js';
5
5
  import { CryptoUtils } from '@enbox/crypto';
6
6
  import { DataStream } from '@enbox/dwn-sdk-js';
7
7
  import { DwnServerInfoCacheMemory } from './dwn-server-info-cache-memory.js';
8
- import { createJsonRpcRequest, parseJson } from './json-rpc.js';
8
+ import { RateLimitError } from './rate-limit-error.js';
9
+ import { createJsonRpcRequest, JsonRpcErrorCodes, parseJson } from './json-rpc.js';
10
+
11
+ // ---------------------------------------------------------------------------
12
+ // Retry configuration
13
+ // ---------------------------------------------------------------------------
14
+
15
+ /** Default number of retry attempts for transient HTTP failures. */
16
+ const DEFAULT_MAX_RETRIES = 3;
17
+
18
+ /** Base delay in milliseconds for exponential backoff. */
19
+ const DEFAULT_BASE_DELAY_MS = 500;
20
+
21
+ /** Maximum backoff delay in milliseconds. */
22
+ const DEFAULT_MAX_DELAY_MS = 10_000;
23
+
24
+ /** Per-request timeout in milliseconds (prevents hung connections / SSRF). */
25
+ const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
26
+
27
+ /** HTTP status codes that are considered retryable. */
28
+ const RETRYABLE_STATUS_CODES = new Set([408, 429, 500, 502, 503, 504]);
29
+
30
+ /**
31
+ * Options for controlling HTTP retry behaviour.
32
+ */
33
+ export type HttpRetryOptions = {
34
+ /** Maximum number of retry attempts (0 = no retries). Default: 3. */
35
+ maxRetries?: number;
36
+ /** Base delay in milliseconds for exponential backoff. Default: 500. */
37
+ baseDelayMs?: number;
38
+ /** Maximum backoff delay in milliseconds. Default: 10 000. */
39
+ maxDelayMs?: number;
40
+ };
41
+
42
+ /**
43
+ * Determines whether a fetch error or HTTP response warrants a retry.
44
+ * Network errors (TypeError from fetch) and specific HTTP status codes are retryable.
45
+ */
46
+ function isRetryable(error?: unknown, response?: Response): boolean {
47
+ if (error instanceof TypeError) {
48
+ // TypeError is thrown by fetch for network-level failures (DNS, connection refused, etc.).
49
+ return true;
50
+ }
51
+ if (response) {
52
+ return RETRYABLE_STATUS_CODES.has(response.status);
53
+ }
54
+ return false;
55
+ }
9
56
 
10
57
  /**
11
- * HTTP client that can be used to communicate with Dwn Servers
58
+ * Computes the backoff delay with jitter for a given attempt.
59
+ * Uses exponential backoff: `min(baseDelay * 2^attempt, maxDelay) * jitter`.
60
+ */
61
+ function computeBackoffDelay(attempt: number, baseDelayMs: number, maxDelayMs: number): number {
62
+ const exponentialDelay = Math.min(baseDelayMs * Math.pow(2, attempt), maxDelayMs);
63
+ const jitter = 0.5 + Math.random() * 0.5;
64
+ return exponentialDelay * jitter;
65
+ }
66
+
67
+ /**
68
+ * Parses a `retry-after` header value into milliseconds.
69
+ * Supports both delay-seconds (e.g. "120") and HTTP-date formats.
70
+ * Returns `undefined` if the header is absent or unparseable.
71
+ */
72
+ function parseRetryAfterMs(response: Response): number | undefined {
73
+ const retryAfter = response.headers.get('retry-after');
74
+ if (retryAfter === null) {
75
+ return undefined;
76
+ }
77
+
78
+ // Try as integer seconds first.
79
+ const seconds = Number(retryAfter);
80
+ if (!Number.isNaN(seconds) && seconds >= 0) {
81
+ return seconds * 1000;
82
+ }
83
+
84
+ // Try as HTTP-date.
85
+ const date = new Date(retryAfter);
86
+ if (!Number.isNaN(date.getTime())) {
87
+ const delayMs = date.getTime() - Date.now();
88
+ return delayMs > 0 ? delayMs : 0;
89
+ }
90
+
91
+ return undefined;
92
+ }
93
+
94
+ /**
95
+ * HTTP client that can be used to communicate with Dwn Servers.
96
+ *
97
+ * Supports automatic retry with exponential backoff and jitter for transient
98
+ * network errors and retryable HTTP status codes (408, 429, 500, 502, 503, 504).
99
+ * Respects the `Retry-After` response header when present.
12
100
  */
13
101
  export class HttpDwnRpcClient implements DwnRpc {
14
102
  private serverInfoCache: DwnServerInfoCache;
15
- constructor(serverInfoCache?: DwnServerInfoCache) {
103
+ private _retryOptions: Required<HttpRetryOptions>;
104
+
105
+ constructor(serverInfoCache?: DwnServerInfoCache, retryOptions?: HttpRetryOptions) {
16
106
  this.serverInfoCache = serverInfoCache ?? new DwnServerInfoCacheMemory();
107
+ this._retryOptions = {
108
+ maxRetries : retryOptions?.maxRetries ?? DEFAULT_MAX_RETRIES,
109
+ baseDelayMs : retryOptions?.baseDelayMs ?? DEFAULT_BASE_DELAY_MS,
110
+ maxDelayMs : retryOptions?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS,
111
+ };
17
112
  }
18
113
 
19
114
  get transportProtocols(): string[] { return ['http:', 'https:']; }
@@ -44,7 +139,16 @@ export class HttpDwnRpcClient implements DwnRpc {
44
139
  (fetchOpts as Record<string, unknown>).duplex = 'half';
45
140
  }
46
141
 
47
- const resp = await fetch(request.dwnUrl, fetchOpts);
142
+ const resp = await this.fetchWithRetry(request.dwnUrl, fetchOpts);
143
+
144
+ // After retries are exhausted, a 429 means we're still rate-limited.
145
+ // Per-IP 429s return plain JSON (not a JSON-RPC envelope), so we must
146
+ // check the status before attempting JSON-RPC parsing.
147
+ if (resp.status === 429) {
148
+ const retryAfter = parseInt(resp.headers.get('retry-after') ?? '1', 10);
149
+ throw new RateLimitError(retryAfter);
150
+ }
151
+
48
152
  let dwnRpcResponse: JsonRpcResponse;
49
153
 
50
154
  // When the server streams record data back, the JSON-RPC envelope is in the
@@ -73,6 +177,10 @@ export class HttpDwnRpcClient implements DwnRpc {
73
177
 
74
178
  if (dwnRpcResponse.error) {
75
179
  const { code, message } = dwnRpcResponse.error;
180
+ if (code === JsonRpcErrorCodes.TooManyRequests) {
181
+ const retryAfter = dwnRpcResponse.error.data?.retryAfterSec ?? 1;
182
+ throw new RateLimitError(retryAfter);
183
+ }
76
184
  throw new Error(`(${code}) - ${message}`);
77
185
  }
78
186
 
@@ -108,7 +216,11 @@ export class HttpDwnRpcClient implements DwnRpc {
108
216
  url.pathname.endsWith('/') ? url.pathname += 'info' : url.pathname += '/info';
109
217
 
110
218
  try {
111
- const response = await fetch(url.toString());
219
+ const response = await this.fetchWithRetry(url.toString());
220
+ if (response.status === 429) {
221
+ const retryAfter = parseInt(response.headers.get('retry-after') ?? '1', 10);
222
+ throw new RateLimitError(retryAfter);
223
+ }
112
224
  if (response.ok) {
113
225
  const results = await response.json() as ServerInfo;
114
226
 
@@ -131,4 +243,62 @@ export class HttpDwnRpcClient implements DwnRpc {
131
243
  throw new Error(`Error encountered while processing response from ${url.toString()}: ${error.message}`);
132
244
  }
133
245
  }
246
+
247
+ // ---------------------------------------------------------------------------
248
+ // Retry logic
249
+ // ---------------------------------------------------------------------------
250
+
251
+ /**
252
+ * Wrapper around `fetch()` that retries on transient network errors and
253
+ * retryable HTTP status codes with exponential backoff and jitter.
254
+ * Honours the `Retry-After` response header when present.
255
+ */
256
+ private async fetchWithRetry(url: string, init?: RequestInit): Promise<Response> {
257
+ const { maxRetries, baseDelayMs, maxDelayMs } = this._retryOptions;
258
+
259
+ let lastError: unknown;
260
+ let lastResponse: Response | undefined;
261
+
262
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
263
+ try {
264
+ // Apply a per-attempt timeout to prevent hung connections / SSRF.
265
+ // If the caller already supplied a signal, combine it with the timeout
266
+ // via AbortSignal.any(); otherwise create a fresh timeout signal.
267
+ const timeoutSignal = AbortSignal.timeout(DEFAULT_REQUEST_TIMEOUT_MS);
268
+ const attemptInit: RequestInit = {
269
+ ...init,
270
+ signal: init?.signal
271
+ ? AbortSignal.any([init.signal, timeoutSignal])
272
+ : timeoutSignal,
273
+ };
274
+
275
+ const response = await fetch(url, attemptInit);
276
+
277
+ if (!RETRYABLE_STATUS_CODES.has(response.status) || attempt === maxRetries) {
278
+ return response;
279
+ }
280
+
281
+ // Retryable status — back off and try again.
282
+ lastResponse = response;
283
+ } catch (error: unknown) {
284
+ if (!isRetryable(error) || attempt === maxRetries) {
285
+ throw error;
286
+ }
287
+ lastError = error;
288
+ }
289
+
290
+ // Compute the delay, preferring Retry-After when available.
291
+ const retryAfterMs = lastResponse ? parseRetryAfterMs(lastResponse) : undefined;
292
+ const backoffMs = computeBackoffDelay(attempt, baseDelayMs, maxDelayMs);
293
+ const delayMs = retryAfterMs !== undefined ? Math.max(retryAfterMs, backoffMs) : backoffMs;
294
+
295
+ await new Promise<void>((resolve): void => { setTimeout(resolve, delayMs); });
296
+ }
297
+
298
+ // Should not reach here, but satisfy the compiler.
299
+ if (lastResponse) {
300
+ return lastResponse;
301
+ }
302
+ throw lastError;
303
+ }
134
304
  }
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export * from './http-dwn-rpc-client.js';
5
5
  export * from './json-rpc.js';
6
6
  export * from './json-rpc-socket.js';
7
7
  export * from './provider-directory-types.js';
8
+ export * from './rate-limit-error.js';
8
9
  export * from './registration-types.js';
9
10
  export * from './rpc-client.js';
10
11
  export * from './server-info-types.js';
package/src/json-rpc.ts CHANGED
@@ -37,6 +37,7 @@ export enum JsonRpcErrorCodes {
37
37
  Unauthorized = -50401, // equivalent to HTTP Status 401
38
38
  Forbidden = -50403, // equivalent to HTTP Status 403
39
39
  Conflict = -50409, // equivalent to HTTP Status 409
40
+ TooManyRequests = -50429, // equivalent to HTTP Status 429
40
41
  }
41
42
 
42
43
  export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Thrown when a DWN server rejects a request due to rate limiting (HTTP 429).
3
+ *
4
+ * Consumers can catch this error to implement retry logic using the
5
+ * {@link retryAfterSec} value provided by the server.
6
+ */
7
+ export class RateLimitError extends Error {
8
+ /** Seconds the client should wait before retrying, as reported by the server. */
9
+ public readonly retryAfterSec: number;
10
+
11
+ constructor(retryAfterSec: number, message?: string) {
12
+ super(message ?? `Rate limit exceeded, retry after ${retryAfterSec}s`);
13
+ this.name = 'RateLimitError';
14
+ this.retryAfterSec = retryAfterSec;
15
+ }
16
+ }
package/src/rpc-client.ts CHANGED
@@ -128,7 +128,7 @@ export class HttpWeb5RpcClient extends HttpDwnRpcClient implements Web5Rpc {
128
128
  let jsonRpcResponse: JsonRpcResponse;
129
129
 
130
130
  try {
131
- const response = await fetch(httpRequest);
131
+ const response = await fetch(httpRequest, { signal: AbortSignal.timeout(30_000) });
132
132
 
133
133
  if (response.ok) {
134
134
  jsonRpcResponse = await response.json();