@atproto/pds 0.4.81 → 0.4.83

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 CHANGED
@@ -1,5 +1,36 @@
1
1
  # @atproto/pds
2
2
 
3
+ ## 0.4.83
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`1abfd74ec`](https://github.com/bluesky-social/atproto/commit/1abfd74ec7114e5d8e2411f7a4fa10bdce97e277)]:
8
+ - @atproto/crypto@0.4.3
9
+ - @atproto/aws@0.2.12
10
+ - @atproto/identity@0.4.5
11
+ - @atproto/repo@0.6.2
12
+ - @atproto/xrpc-server@0.7.6
13
+ - @atproto-labs/xrpc-utils@0.0.2
14
+
15
+ ## 0.4.82
16
+
17
+ ### Patch Changes
18
+
19
+ - [#3177](https://github.com/bluesky-social/atproto/pull/3177) [`72eba67af`](https://github.com/bluesky-social/atproto/commit/72eba67af1af8320b5400bcb9319d5c3c8407d99) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Remove dependency on Axios
20
+
21
+ - Updated dependencies [[`72eba67af`](https://github.com/bluesky-social/atproto/commit/72eba67af1af8320b5400bcb9319d5c3c8407d99), [`72eba67af`](https://github.com/bluesky-social/atproto/commit/72eba67af1af8320b5400bcb9319d5c3c8407d99)]:
22
+ - @atproto-labs/xrpc-utils@0.0.1
23
+ - @atproto/identity@0.4.4
24
+ - @atproto/api@0.13.26
25
+ - @atproto/common@0.4.6
26
+ - @atproto/lexicon@0.4.5
27
+ - @atproto/repo@0.6.1
28
+ - @atproto/aws@0.2.11
29
+ - @atproto/crypto@0.4.2
30
+ - @atproto/oauth-provider@0.2.11
31
+ - @atproto/xrpc-server@0.7.5
32
+ - @atproto/xrpc@0.6.6
33
+
3
34
  ## 0.4.81
4
35
 
5
36
  ### Patch Changes
@@ -29,7 +29,7 @@ export declare function parseProxyInfo(ctx: AppContext, req: express.Request, lx
29
29
  url: string;
30
30
  did: string;
31
31
  }>;
32
- export declare const parseProxyHeader: (ctx: Pick<AppContext, "idResolver">, proxyTo: string) => Promise<{
32
+ export declare const parseProxyHeader: (ctx: Pick<AppContext, "cfg" | "idResolver">, proxyTo: string) => Promise<{
33
33
  did: string;
34
34
  url: string;
35
35
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"pipethrough.d.ts","sourceRoot":"","sources":["../src/pipethrough.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAe,QAAQ,EAAE,MAAM,aAAa,CAAA;AAUnD,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,wBAAwB,EAKzB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,UAAU,MAAM,WAAW,CAAA;AAIlC,eAAO,MAAM,YAAY,QAAS,UAAU,KAAG,eA2E9C,CAAA;AAgBD,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CACR,wBAAwB,GAAG;IACzB,MAAM,EAAE,QAAQ,CAAA;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,QAAQ,EAAE,MAAM,CAAA;CACjB,CACF,CAwDA;AAKD,wBAAsB,cAAc,CAClC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAUvC;AAED,eAAO,MAAM,gBAAgB,QAEtB,I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sB,cAAc,CAClC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,OAAO,CAAC,OAAO,EACpB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAUvC;AAED,eAAO,MAAM,gBAAgB,QAEtB,IAAI,CAAC,UAAU,EAAE,KAAK,GAAG,YAAY,CAAC,WAClC,MAAM,KACd,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CA4CtC,CAAA;AAyGD,wBAAgB,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAG3E;AAyDD,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,wBAAwB,GAC9B,OAAO,CAAC,wBAAwB,CAAC,CASnC;AA2CD,eAAO,MAAM,kBAAkB,aAgB7B,CAAA;AAKF,eAAO,MAAM,iBAAiB,aAgB5B,CAAA"}
@@ -6,6 +6,7 @@ exports.parseProxyInfo = parseProxyInfo;
6
6
  exports.isJsonContentType = isJsonContentType;
7
7
  exports.asPipeThroughBuffer = asPipeThroughBuffer;
8
8
  const node_stream_1 = require("node:stream");
9
+ const xrpc_utils_1 = require("@atproto-labs/xrpc-utils");
9
10
  const common_1 = require("@atproto/common");
10
11
  const xrpc_1 = require("@atproto/xrpc");
11
12
  const xrpc_server_1 = require("@atproto/xrpc-server");
@@ -72,18 +73,6 @@ const proxyHandler = (ctx) => {
72
73
  };
73
74
  };
74
75
  exports.proxyHandler = proxyHandler;
75
- const ACCEPT_ENCODING_COMPRESSED = [
76
- ['gzip', { q: 1.0 }],
77
- ['deflate', { q: 0.9 }],
78
- ['br', { q: 0.8 }],
79
- ['identity', { q: 0.1 }],
80
- ];
81
- const ACCEPT_ENCODING_UNCOMPRESSED = [
82
- ['identity', { q: 1.0 }],
83
- ['gzip', { q: 0.3 }],
84
- ['deflate', { q: 0.2 }],
85
- ['br', { q: 0.1 }],
86
- ];
87
76
  async function pipethrough(ctx, req, options) {
88
77
  if (req.method !== 'GET' && req.method !== 'HEAD') {
89
78
  // pipethrough() is used from within xrpcServer handlers, which means that
@@ -109,9 +98,7 @@ async function pipethrough(ctx, req, options) {
109
98
  // upstream server for an encoding that both the requester and the PDS can
110
99
  // understand. Since we might have to do the decoding ourselves, we will
111
100
  // use our own preferences (and weight) to negotiate the encoding.
112
- 'accept-encoding': negotiateContentEncoding(req.headers['accept-encoding'], ctx.cfg.proxy.preferCompressed
113
- ? ACCEPT_ENCODING_COMPRESSED
114
- : ACCEPT_ENCODING_UNCOMPRESSED),
101
+ 'accept-encoding': (0, xrpc_utils_1.buildProxiedContentEncoding)(req.headers['accept-encoding'], ctx.cfg.proxy.preferCompressed),
115
102
  authorization: options?.iss
116
103
  ? `Bearer ${await ctx.serviceAuthJwt(options.iss, options.aud ?? aud, options.lxm ?? lxm)}`
117
104
  : undefined,
@@ -169,6 +156,11 @@ ctx, proxyTo) => {
169
156
  if (!url) {
170
157
  throw new xrpc_server_1.InvalidRequestError('could not resolve proxy did service url');
171
158
  }
159
+ // Special case a configured appview, while still proxying correctly any other appview
160
+ if (ctx.cfg.bskyAppView &&
161
+ proxyTo === `${ctx.cfg.bskyAppView.did}#bsky_appview`) {
162
+ return { did, url: ctx.cfg.bskyAppView.url };
163
+ }
172
164
  return { did, url };
173
165
  };
174
166
  exports.parseProxyHeader = parseProxyHeader;
@@ -237,88 +229,8 @@ function handleUpstreamRequestError(err, message = 'Upstream service unreachable
237
229
  cause: err,
238
230
  });
239
231
  }
240
- // accept-encoding defaults to "identity with lowest priority"
241
- const ACCEPT_ENC_DEFAULT = ['identity', { q: 0.001 }];
242
- const ACCEPT_FORBID_STAR = ['*', { q: 0 }];
243
- function negotiateContentEncoding(acceptHeader, preferences) {
244
- const acceptMap = Object.fromEntries(parseAcceptEncoding(acceptHeader));
245
- // Make sure the default (identity) is covered by the preferences
246
- if (!preferences.some(coversIdentityAccept)) {
247
- preferences = [...preferences, ACCEPT_ENC_DEFAULT];
248
- }
249
- const common = preferences.filter(([name]) => {
250
- const acceptQ = (acceptMap[name] ?? acceptMap['*'])?.q;
251
- // Per HTTP/1.1, "identity" is always acceptable unless explicitly rejected
252
- if (name === 'identity') {
253
- return acceptQ == null || acceptQ > 0;
254
- }
255
- else {
256
- return acceptQ != null && acceptQ > 0;
257
- }
258
- });
259
- // Since "identity" was present in the preferences, a missing "identity" in
260
- // the common array means that the client explicitly rejected it. Let's reflect
261
- // this by adding it to the common array.
262
- if (!common.some(coversIdentityAccept)) {
263
- common.push(ACCEPT_FORBID_STAR);
264
- }
265
- // If no common encodings are acceptable, throw a 406 Not Acceptable error
266
- if (!common.some(isAllowedAccept)) {
267
- throw new xrpc_server_1.XRPCError(xrpc_1.ResponseType.NotAcceptable, 'this service does not support any of the requested encodings');
268
- }
269
- return formatAcceptHeader(common);
270
- }
271
- function coversIdentityAccept([name]) {
272
- return name === 'identity' || name === '*';
273
- }
274
- function isAllowedAccept([, flags]) {
275
- return flags.q > 0;
276
- }
277
- /**
278
- * @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Quality_values}
279
- */
280
- function formatAcceptHeader(accept) {
281
- return accept.map(formatAcceptPart).join(',');
282
- }
283
- function formatAcceptPart([name, flags]) {
284
- return `${name};q=${flags.q}`;
285
- }
286
- function parseAcceptEncoding(acceptEncodings) {
287
- if (!acceptEncodings?.length)
288
- return [];
289
- return Array.isArray(acceptEncodings)
290
- ? acceptEncodings.flatMap(parseAcceptEncoding)
291
- : acceptEncodings.split(',').map(parseAcceptEncodingDefinition);
292
- }
293
- function parseAcceptEncodingDefinition(def) {
294
- const { length, 0: encoding, 1: params } = def.trim().split(';', 3);
295
- if (length > 2) {
296
- throw new xrpc_server_1.InvalidRequestError(`Invalid accept-encoding: "${def}"`);
297
- }
298
- if (!encoding || encoding.includes('=')) {
299
- throw new xrpc_server_1.InvalidRequestError(`Invalid accept-encoding: "${def}"`);
300
- }
301
- const flags = { q: 1 };
302
- if (length === 2) {
303
- const { length, 0: key, 1: value } = params.split('=', 3);
304
- if (length !== 2) {
305
- throw new xrpc_server_1.InvalidRequestError(`Invalid accept-encoding: "${def}"`);
306
- }
307
- if (key === 'q' || key === 'Q') {
308
- const q = parseFloat(value);
309
- if (q === 0 || (Number.isFinite(q) && q <= 1 && q >= 0.001)) {
310
- flags.q = q;
311
- }
312
- else {
313
- throw new xrpc_server_1.InvalidRequestError(`Invalid accept-encoding: "${def}"`);
314
- }
315
- }
316
- else {
317
- throw new xrpc_server_1.InvalidRequestError(`Invalid accept-encoding: "${def}"`);
318
- }
319
- }
320
- return [encoding.toLowerCase(), flags];
321
- }
232
+ // Request parsing/forwarding
233
+ // -------------------
322
234
  function isJsonContentType(contentType) {
323
235
  if (!contentType)
324
236
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"pipethrough.js","sourceRoot":"","sources":["../src/pipethrough.ts"],"names":[],"mappings":";;;AAyIA,kCAkEC;AAKD,wCAcC;AAiQD,8CAGC;AAyDD,kDAWC;AApiBD,6CAAmD;AAGnD,4CAKwB;AACxB,wCAA0E;AAC1E,sDAQ6B;AAG7B,iDAAwC;AACxC,qCAAqC;AAE9B,MAAM,YAAY,GAAG,CAAC,GAAe,EAAmB,EAAE;IAC/D,MAAM,cAAc,GAAG,GAAG,CAAC,YAAY,CAAC,cAAc,EAAE,CAAA;IACxD,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC9B,eAAe;QACf,IAAI,CAAC;YACH,IACE,GAAG,CAAC,MAAM,KAAK,KAAK;gBACpB,GAAG,CAAC,MAAM,KAAK,MAAM;gBACrB,GAAG,CAAC,MAAM,KAAK,MAAM,EACrB,CAAC;gBACD,MAAM,IAAI,uBAAe,CACvB,mBAAY,CAAC,cAAc,EAC3B,0CAA0C,CAC3C,CAAA;YACH,CAAC;YAED,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,K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AAC,yBAAyB,CAAC;QACnC,KAAK,cAAG,CAAC,qCAAqC,CAAC;QAC/C,KAAK,cAAG,CAAC,qCAAqC,CAAC;QAC/C,KAAK,cAAG,CAAC,qCAAqC,CAAC;QAC/C,KAAK,cAAG,CAAC,oCAAoC,CAAC;QAC9C,KAAK,cAAG,CAAC,6BAA6B,CAAC;QACvC,KAAK,cAAG,CAAC,4BAA4B,CAAC;QACtC,KAAK,cAAG,CAAC,6BAA6B,CAAC;QACvC,KAAK,cAAG,CAAC,2BAA2B,CAAC;QACrC,KAAK,cAAG,CAAC,+BAA+B,CAAC;QACzC,KAAK,cAAG,CAAC,iCAAiC,CAAC;QAC3C,KAAK,cAAG,CAAC,+BAA+B;YACtC,OAAO,GAAG,CAAC,GAAG,CAAC,UAAU,CAAA;QAC3B,KAAK,cAAG,CAAC,gCAAgC;YACvC,OAAO,GAAG,CAAC,GAAG,CAAC,aAAa,CAAA;QAC9B;YACE,OAAO,GAAG,CAAC,GAAG,CAAC,WAAW,CAAA;IAC9B,CAAC;AACH,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,GAAY,EAAsB,EAAE;IACtD,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;AAClD,CAAC,CAAA;AAED,SAAS,gBAAgB,CAAuB,GAAY;IAC1D,mBAAU,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,oCAAoC,CAAC,CAAA;AAChE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/pds",
3
- "version": "0.4.81",
3
+ "version": "0.4.83",
4
4
  "license": "MIT",
5
5
  "description": "Reference implementation of atproto Personal Data Server (PDS)",
6
6
  "keywords": [
@@ -46,17 +46,18 @@
46
46
  "undici": "^6.19.8",
47
47
  "zod": "^3.23.8",
48
48
  "@atproto-labs/fetch-node": "0.1.4",
49
- "@atproto/api": "^0.13.25",
50
- "@atproto/aws": "^0.2.10",
51
- "@atproto/common": "^0.4.5",
52
- "@atproto/crypto": "^0.4.2",
53
- "@atproto/identity": "^0.4.3",
54
- "@atproto/lexicon": "^0.4.4",
55
- "@atproto/oauth-provider": "^0.2.10",
56
- "@atproto/repo": "^0.6.0",
49
+ "@atproto-labs/xrpc-utils": "0.0.2",
50
+ "@atproto/api": "^0.13.26",
51
+ "@atproto/aws": "^0.2.12",
52
+ "@atproto/common": "^0.4.6",
53
+ "@atproto/crypto": "^0.4.3",
54
+ "@atproto/identity": "^0.4.5",
55
+ "@atproto/lexicon": "^0.4.5",
56
+ "@atproto/oauth-provider": "^0.2.11",
57
+ "@atproto/repo": "^0.6.2",
57
58
  "@atproto/syntax": "^0.3.1",
58
- "@atproto/xrpc": "^0.6.5",
59
- "@atproto/xrpc-server": "^0.7.4"
59
+ "@atproto/xrpc": "^0.6.6",
60
+ "@atproto/xrpc-server": "^0.7.6"
60
61
  },
61
62
  "devDependencies": {
62
63
  "@atproto/pds-entryway": "npm:@atproto/pds@0.3.0-entryway.3",
@@ -66,7 +67,6 @@
66
67
  "@types/express-serve-static-core": "^4.17.36",
67
68
  "@types/nodemailer": "^6.4.6",
68
69
  "@types/qs": "^6.9.7",
69
- "axios": "^0.27.2",
70
70
  "esbuild": "^0.14.48",
71
71
  "esbuild-plugin-handlebars": "^1.0.3",
72
72
  "get-port": "^6.1.2",
@@ -75,9 +75,9 @@
75
75
  "ts-node": "^10.8.2",
76
76
  "typescript": "^5.6.3",
77
77
  "ws": "^8.12.0",
78
- "@atproto/api": "^0.13.25",
79
- "@atproto/bsky": "^0.0.103",
80
- "@atproto/lex-cli": "^0.5.4",
78
+ "@atproto/api": "^0.13.26",
79
+ "@atproto/bsky": "^0.0.105",
80
+ "@atproto/lex-cli": "^0.5.5",
81
81
  "@atproto/oauth-client-browser-example": "0.0.0"
82
82
  },
83
83
  "scripts": {
@@ -3,6 +3,7 @@ import { IncomingHttpHeaders, ServerResponse } from 'node:http'
3
3
  import { PassThrough, Readable } from 'node:stream'
4
4
  import { Dispatcher } from 'undici'
5
5
 
6
+ import { buildProxiedContentEncoding } from '@atproto-labs/xrpc-utils'
6
7
  import {
7
8
  decodeStream,
8
9
  getServiceEndpoint,
@@ -101,20 +102,6 @@ export const proxyHandler = (ctx: AppContext): CatchallHandler => {
101
102
  }
102
103
  }
103
104
 
104
- const ACCEPT_ENCODING_COMPRESSED = [
105
- ['gzip', { q: 1.0 }],
106
- ['deflate', { q: 0.9 }],
107
- ['br', { q: 0.8 }],
108
- ['identity', { q: 0.1 }],
109
- ] as const satisfies Accept[]
110
-
111
- const ACCEPT_ENCODING_UNCOMPRESSED = [
112
- ['identity', { q: 1.0 }],
113
- ['gzip', { q: 0.3 }],
114
- ['deflate', { q: 0.2 }],
115
- ['br', { q: 0.1 }],
116
- ] as const satisfies Accept[]
117
-
118
105
  export type PipethroughOptions = {
119
106
  /**
120
107
  * Specify the issuer (requester) for service auth. If not provided, no
@@ -176,11 +163,9 @@ export async function pipethrough(
176
163
  // upstream server for an encoding that both the requester and the PDS can
177
164
  // understand. Since we might have to do the decoding ourselves, we will
178
165
  // use our own preferences (and weight) to negotiate the encoding.
179
- 'accept-encoding': negotiateContentEncoding(
166
+ 'accept-encoding': buildProxiedContentEncoding(
180
167
  req.headers['accept-encoding'],
181
- ctx.cfg.proxy.preferCompressed
182
- ? ACCEPT_ENCODING_COMPRESSED
183
- : ACCEPT_ENCODING_UNCOMPRESSED,
168
+ ctx.cfg.proxy.preferCompressed,
184
169
  ),
185
170
 
186
171
  authorization: options?.iss
@@ -224,7 +209,7 @@ export async function parseProxyInfo(
224
209
 
225
210
  export const parseProxyHeader = async (
226
211
  // Using subset of AppContext for testing purposes
227
- ctx: Pick<AppContext, 'idResolver'>,
212
+ ctx: Pick<AppContext, 'cfg' | 'idResolver'>,
228
213
  proxyTo: string,
229
214
  ): Promise<{ did: string; url: string }> => {
230
215
  // /!\ Hot path
@@ -261,6 +246,14 @@ export const parseProxyHeader = async (
261
246
  throw new InvalidRequestError('could not resolve proxy did service url')
262
247
  }
263
248
 
249
+ // Special case a configured appview, while still proxying correctly any other appview
250
+ if (
251
+ ctx.cfg.bskyAppView &&
252
+ proxyTo === `${ctx.cfg.bskyAppView.did}#bsky_appview`
253
+ ) {
254
+ return { did, url: ctx.cfg.bskyAppView.url }
255
+ }
256
+
264
257
  return { did, url }
265
258
  }
266
259
 
@@ -367,116 +360,6 @@ function handleUpstreamRequestError(
367
360
  // Request parsing/forwarding
368
361
  // -------------------
369
362
 
370
- type AcceptFlags = { q: number }
371
- type Accept = [name: string, flags: AcceptFlags]
372
-
373
- // accept-encoding defaults to "identity with lowest priority"
374
- const ACCEPT_ENC_DEFAULT = ['identity', { q: 0.001 }] as const satisfies Accept
375
- const ACCEPT_FORBID_STAR = ['*', { q: 0 }] as const satisfies Accept
376
-
377
- function negotiateContentEncoding(
378
- acceptHeader: undefined | string | string[],
379
- preferences: readonly Accept[],
380
- ): string {
381
- const acceptMap = Object.fromEntries<undefined | AcceptFlags>(
382
- parseAcceptEncoding(acceptHeader),
383
- )
384
-
385
- // Make sure the default (identity) is covered by the preferences
386
- if (!preferences.some(coversIdentityAccept)) {
387
- preferences = [...preferences, ACCEPT_ENC_DEFAULT]
388
- }
389
-
390
- const common = preferences.filter(([name]) => {
391
- const acceptQ = (acceptMap[name] ?? acceptMap['*'])?.q
392
- // Per HTTP/1.1, "identity" is always acceptable unless explicitly rejected
393
- if (name === 'identity') {
394
- return acceptQ == null || acceptQ > 0
395
- } else {
396
- return acceptQ != null && acceptQ > 0
397
- }
398
- })
399
-
400
- // Since "identity" was present in the preferences, a missing "identity" in
401
- // the common array means that the client explicitly rejected it. Let's reflect
402
- // this by adding it to the common array.
403
- if (!common.some(coversIdentityAccept)) {
404
- common.push(ACCEPT_FORBID_STAR)
405
- }
406
-
407
- // If no common encodings are acceptable, throw a 406 Not Acceptable error
408
- if (!common.some(isAllowedAccept)) {
409
- throw new XRPCServerError(
410
- ResponseType.NotAcceptable,
411
- 'this service does not support any of the requested encodings',
412
- )
413
- }
414
-
415
- return formatAcceptHeader(common as [Accept, ...Accept[]])
416
- }
417
-
418
- function coversIdentityAccept([name]: Accept): boolean {
419
- return name === 'identity' || name === '*'
420
- }
421
-
422
- function isAllowedAccept([, flags]: Accept): boolean {
423
- return flags.q > 0
424
- }
425
-
426
- /**
427
- * @see {@link https://developer.mozilla.org/en-US/docs/Glossary/Quality_values}
428
- */
429
- function formatAcceptHeader(accept: readonly [Accept, ...Accept[]]): string {
430
- return accept.map(formatAcceptPart).join(',')
431
- }
432
-
433
- function formatAcceptPart([name, flags]: Accept): string {
434
- return `${name};q=${flags.q}`
435
- }
436
-
437
- function parseAcceptEncoding(
438
- acceptEncodings: undefined | string | string[],
439
- ): Accept[] {
440
- if (!acceptEncodings?.length) return []
441
-
442
- return Array.isArray(acceptEncodings)
443
- ? acceptEncodings.flatMap(parseAcceptEncoding)
444
- : acceptEncodings.split(',').map(parseAcceptEncodingDefinition)
445
- }
446
-
447
- function parseAcceptEncodingDefinition(def: string): Accept {
448
- const { length, 0: encoding, 1: params } = def.trim().split(';', 3)
449
-
450
- if (length > 2) {
451
- throw new InvalidRequestError(`Invalid accept-encoding: "${def}"`)
452
- }
453
-
454
- if (!encoding || encoding.includes('=')) {
455
- throw new InvalidRequestError(`Invalid accept-encoding: "${def}"`)
456
- }
457
-
458
- const flags = { q: 1 }
459
- if (length === 2) {
460
- const { length, 0: key, 1: value } = params.split('=', 3)
461
- if (length !== 2) {
462
- throw new InvalidRequestError(`Invalid accept-encoding: "${def}"`)
463
- }
464
-
465
- if (key === 'q' || key === 'Q') {
466
- const q = parseFloat(value)
467
- if (q === 0 || (Number.isFinite(q) && q <= 1 && q >= 0.001)) {
468
- flags.q = q
469
- } else {
470
- throw new InvalidRequestError(`Invalid accept-encoding: "${def}"`)
471
- }
472
- } else {
473
- throw new InvalidRequestError(`Invalid accept-encoding: "${def}"`)
474
- }
475
- }
476
-
477
- return [encoding.toLowerCase(), flags]
478
- }
479
-
480
363
  export function isJsonContentType(contentType?: string): boolean | undefined {
481
364
  if (!contentType) return undefined
482
365
  return /application\/(?:\w+\+)?json/i.test(contentType)
package/tests/_util.ts CHANGED
@@ -1,7 +1,10 @@
1
+ import { lexToJson } from '@atproto/lexicon'
1
2
  import { AtUri } from '@atproto/syntax'
3
+ import { type Express } from 'express'
2
4
  import { CID } from 'multiformats/cid'
5
+ import { Server } from 'node:http'
6
+ import { AddressInfo } from 'node:net'
3
7
  import { FeedViewPost } from '../src/lexicon/types/app/bsky/feed/defs'
4
- import { lexToJson } from '@atproto/lexicon'
5
8
 
6
9
  // Swap out identifiers and dates with stable
7
10
  // values for the purpose of snapshot testing
@@ -156,3 +159,46 @@ export const paginateAll = async <T extends { cursor?: string }>(
156
159
  } while (cursor && results.length < limit)
157
160
  return results
158
161
  }
162
+
163
+ export async function startServer(app: Express) {
164
+ return new Promise<{
165
+ origin: string
166
+ server: Server
167
+ stop: () => Promise<void>
168
+ }>((resolve, reject) => {
169
+ const onListen = () => {
170
+ const port = (server.address() as AddressInfo).port
171
+ resolve({
172
+ server,
173
+ origin: `http://localhost:${port}`,
174
+ stop: () => stopServer(server),
175
+ })
176
+ cleanup()
177
+ }
178
+ const onError = (err: Error) => {
179
+ reject(err)
180
+ cleanup()
181
+ }
182
+ const cleanup = () => {
183
+ server.removeListener('listening', onListen)
184
+ server.removeListener('error', onError)
185
+ }
186
+
187
+ const server = app
188
+ .listen(0)
189
+ .once('listening', onListen)
190
+ .once('error', onError)
191
+ })
192
+ }
193
+
194
+ export async function stopServer(server: Server) {
195
+ return new Promise<void>((resolve, reject) => {
196
+ server.close((err) => {
197
+ if (err) {
198
+ reject(err)
199
+ } else {
200
+ resolve()
201
+ }
202
+ })
203
+ })
204
+ }
@@ -1,14 +1,13 @@
1
- import http from 'node:http'
2
- import assert from 'node:assert'
3
- import express from 'express'
4
- import axios from 'axios'
5
- import * as plc from '@did-plc/lib'
6
- import { SeedClient, TestNetworkNoAppView, usersSeed } from '@atproto/dev-env'
7
1
  import { Keypair } from '@atproto/crypto'
2
+ import { SeedClient, TestNetworkNoAppView, usersSeed } from '@atproto/dev-env'
8
3
  import { verifyJwt } from '@atproto/xrpc-server'
9
- import { parseProxyHeader } from '../../src/pipethrough'
4
+ import * as plc from '@did-plc/lib'
5
+ import express from 'express'
6
+ import assert from 'node:assert'
10
7
  import { once } from 'node:events'
8
+ import http from 'node:http'
11
9
  import { AddressInfo } from 'node:net'
10
+ import { parseProxyHeader } from '../../src/pipethrough'
12
11
 
13
12
  describe('proxy header', () => {
14
13
  let network: TestNetworkNoAppView
@@ -40,19 +39,6 @@ describe('proxy header', () => {
40
39
  await network.close()
41
40
  })
42
41
 
43
- const assertAxiosErr = async (promise: Promise<unknown>, msg: string) => {
44
- try {
45
- await promise
46
- } catch (err) {
47
- if (!axios.isAxiosError(err)) {
48
- throw err
49
- }
50
- expect(err.response?.data?.['message']).toEqual(msg)
51
- return
52
- }
53
- throw new Error('no error thrown')
54
- }
55
-
56
42
  it('parses proxy header', async () => {
57
43
  expect(parseProxyHeader(network.pds.ctx, `#atproto_test`)).rejects.toThrow(
58
44
  'no did specified in proxy header',
@@ -84,7 +70,7 @@ describe('proxy header', () => {
84
70
 
85
71
  it('proxies requests based on header', async () => {
86
72
  const path = `/xrpc/app.bsky.actor.getProfile?actor=${alice}`
87
- await axios.get(`${network.pds.url}${path}`, {
73
+ await fetch(`${network.pds.url}${path}`, {
88
74
  headers: {
89
75
  ...sc.getHeaders(alice),
90
76
  'atproto-proxy': `${proxyServer.did}#atproto_test`,
@@ -106,37 +92,49 @@ describe('proxy header', () => {
106
92
 
107
93
  it('fails on a non-existant did', async () => {
108
94
  const path = `/xrpc/app.bsky.actor.getProfile?actor=${alice}`
109
- const attempt = axios.get(`${network.pds.url}${path}`, {
95
+ const response = await fetch(`${network.pds.url}${path}`, {
110
96
  headers: {
111
97
  ...sc.getHeaders(alice),
112
98
  'atproto-proxy': `did:plc:12345678123456781234578#atproto_test`,
113
99
  },
114
100
  })
115
- await assertAxiosErr(attempt, 'could not resolve proxy did')
101
+
102
+ await expect(response.json()).resolves.toMatchObject({
103
+ message: 'could not resolve proxy did',
104
+ })
105
+
116
106
  expect(proxyServer.requests.length).toBe(1)
117
107
  })
118
108
 
119
109
  it('fails when a service is not specified', async () => {
120
110
  const path = `/xrpc/app.bsky.actor.getProfile?actor=${alice}`
121
- const attempt = axios.get(`${network.pds.url}${path}`, {
111
+ const response = await fetch(`${network.pds.url}${path}`, {
122
112
  headers: {
123
113
  ...sc.getHeaders(alice),
124
114
  'atproto-proxy': proxyServer.did,
125
115
  },
126
116
  })
127
- await assertAxiosErr(attempt, 'no service id specified in proxy header')
117
+
118
+ await expect(response.json()).resolves.toMatchObject({
119
+ message: 'no service id specified in proxy header',
120
+ })
121
+
128
122
  expect(proxyServer.requests.length).toBe(1)
129
123
  })
130
124
 
131
125
  it('fails on a non-existant service', async () => {
132
126
  const path = `/xrpc/app.bsky.actor.getProfile?actor=${alice}`
133
- const attempt = axios.get(`${network.pds.url}${path}`, {
127
+ const response = await fetch(`${network.pds.url}${path}`, {
134
128
  headers: {
135
129
  ...sc.getHeaders(alice),
136
130
  'atproto-proxy': `${proxyServer.did}#atproto_bad`,
137
131
  },
138
132
  })
139
- await assertAxiosErr(attempt, 'could not resolve proxy did service url')
133
+
134
+ await expect(response.json()).resolves.toMatchObject({
135
+ message: 'could not resolve proxy did service url',
136
+ })
137
+
140
138
  expect(proxyServer.requests.length).toBe(1)
141
139
  })
142
140
  })
@@ -1,11 +1,12 @@
1
- import { AddressInfo } from 'net'
2
- import express from 'express'
3
- import axios, { AxiosError } from 'axios'
4
- import { SeedClient, TestNetworkNoAppView } from '@atproto/dev-env'
5
1
  import { AtpAgent, AtUri } from '@atproto/api'
2
+ import { randomStr } from '@atproto/crypto'
3
+ import { SeedClient, TestNetworkNoAppView } from '@atproto/dev-env'
4
+ import express from 'express'
5
+ import { finished } from 'node:stream/promises'
6
+ import { request } from 'undici'
6
7
  import { handler as errorHandler } from '../src/error'
8
+ import { startServer } from './_util'
7
9
  import basicSeed from './seeds/basic'
8
- import { randomStr } from '@atproto/crypto'
9
10
 
10
11
  describe('server', () => {
11
12
  let network: TestNetworkNoAppView
@@ -31,53 +32,42 @@ describe('server', () => {
31
32
  })
32
33
 
33
34
  it('preserves 404s.', async () => {
34
- const promise = axios.get(`${network.pds.url}/unknown`)
35
- await expect(promise).rejects.toThrow('failed with status code 404')
35
+ const res = await fetch(`${network.pds.url}/unknown`)
36
+ expect(res.status).toEqual(404)
36
37
  })
37
38
 
38
39
  it('error handler turns unknown errors into 500s.', async () => {
39
40
  const app = express()
40
- app.get('/oops', () => {
41
- throw new Error('Oops!')
42
- })
43
- app.use(errorHandler)
44
- const srv = app.listen()
45
- const port = (srv.address() as AddressInfo).port
46
- const promise = axios.get(`http://localhost:${port}/oops`)
47
- await expect(promise).rejects.toThrow('failed with status code 500')
48
- srv.close()
41
+ .get('/oops', () => {
42
+ throw new Error('Oops!')
43
+ })
44
+ .use(errorHandler)
45
+
46
+ const { origin, stop } = await startServer(app)
49
47
  try {
50
- await promise
51
- } catch (err: unknown) {
52
- const axiosError = err as AxiosError
53
- expect(axiosError.response?.status).toEqual(500)
54
- expect(axiosError.response?.data).toEqual({
48
+ const res = await fetch(new URL(`/oops`, origin))
49
+ expect(res.status).toEqual(500)
50
+ await expect(res.json()).resolves.toEqual({
55
51
  error: 'InternalServerError',
56
52
  message: 'Internal Server Error',
57
53
  })
54
+ } finally {
55
+ await stop()
58
56
  }
59
57
  })
60
58
 
61
59
  it('limits size of json input.', async () => {
62
- let error: AxiosError
63
- try {
64
- await axios.post(
65
- `${network.pds.url}/xrpc/com.atproto.repo.createRecord`,
66
- {
67
- data: 'x'.repeat(150 * 1024), // 150kb
68
- },
69
- { headers: sc.getHeaders(alice) },
70
- )
71
- throw new Error('Request should have failed')
72
- } catch (err) {
73
- if (axios.isAxiosError(err)) {
74
- error = err
75
- } else {
76
- throw err
77
- }
78
- }
79
- expect(error.response?.status).toEqual(413)
80
- expect(error.response?.data).toEqual({
60
+ const res = await fetch(
61
+ `${network.pds.url}/xrpc/com.atproto.repo.createRecord`,
62
+ {
63
+ method: 'POST',
64
+ body: 'x'.repeat(150 * 1024), // 150kb
65
+ headers: sc.getHeaders(alice),
66
+ },
67
+ )
68
+
69
+ expect(res.status).toEqual(413)
70
+ await expect(res.json()).resolves.toEqual({
81
71
  error: 'PayloadTooLargeError',
82
72
  message: 'request entity too large',
83
73
  })
@@ -102,56 +92,53 @@ describe('server', () => {
102
92
  )
103
93
  const uri = new AtUri(createRes.data.uri)
104
94
 
105
- const res = await axios.get(
95
+ const res = await request(
106
96
  `${network.pds.url}/xrpc/com.atproto.repo.getRecord?repo=${uri.host}&collection=${uri.collection}&rkey=${uri.rkey}`,
107
97
  {
108
- decompress: false,
109
98
  headers: { ...sc.getHeaders(alice), 'accept-encoding': 'gzip' },
110
99
  },
111
100
  )
112
101
 
102
+ await finished(res.body.resume())
103
+
113
104
  expect(res.headers['content-encoding']).toEqual('gzip')
114
105
  })
115
106
 
116
107
  it('compresses large car file responses', async () => {
117
- const res = await axios.get(
108
+ const res = await request(
118
109
  `${network.pds.url}/xrpc/com.atproto.sync.getRepo?did=${alice}`,
119
- { decompress: false, headers: { 'accept-encoding': 'gzip' } },
110
+ { headers: { 'accept-encoding': 'gzip' } },
120
111
  )
112
+
113
+ await finished(res.body.resume())
114
+
121
115
  expect(res.headers['content-encoding']).toEqual('gzip')
122
116
  })
123
117
 
124
118
  it('does not compress small payloads', async () => {
125
- const res = await axios.get(`${network.pds.url}/xrpc/_health`, {
126
- decompress: false,
119
+ const res = await request(`${network.pds.url}/xrpc/_health`, {
127
120
  headers: { 'accept-encoding': 'gzip' },
128
121
  })
122
+
123
+ await finished(res.body.resume())
124
+
129
125
  expect(res.headers['content-encoding']).toBeUndefined()
130
126
  })
131
127
 
132
128
  it('healthcheck succeeds when database is available.', async () => {
133
- const { data, status } = await axios.get(`${network.pds.url}/xrpc/_health`)
134
- expect(status).toEqual(200)
135
- expect(data).toEqual({ version: '0.0.0' })
129
+ const res = await fetch(`${network.pds.url}/xrpc/_health`)
130
+ expect(res.status).toEqual(200)
131
+ await expect(res.json()).resolves.toEqual({ version: '0.0.0' })
136
132
  })
137
133
 
138
134
  // @TODO this is hanging for some unknown reason
139
135
  it.skip('healthcheck fails when database is unavailable.', async () => {
140
136
  await network.pds.ctx.accountManager.db.close()
141
- let error: AxiosError
142
- try {
143
- await axios.get(`${network.pds.url}/xrpc/_health`)
144
- throw new Error('Healthcheck should have failed')
145
- } catch (err) {
146
- if (axios.isAxiosError(err)) {
147
- error = err
148
- } else {
149
- throw err
150
- }
151
- }
152
- expect(error.response?.status).toEqual(503)
153
- expect(error.response?.data).toEqual({
154
- version: '0.0.0',
137
+
138
+ const response = await fetch(`${network.pds.url}/xrpc/_health`)
139
+ expect(response.status).toEqual(503)
140
+ await expect(response.json()).resolves.toEqual({
141
+ version: 'unknown',
155
142
  error: 'Service Unavailable',
156
143
  })
157
144
  })