@atproto/xrpc-server 0.3.1 → 0.3.2

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,13 @@
1
1
  # @atproto/xrpc-server
2
2
 
3
+ ## 0.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atproto/common@0.3.1
9
+ - @atproto/lexicon@0.2.2
10
+
3
11
  ## 0.3.1
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -1,4 +1,9 @@
1
- # XRPC Server API
1
+ # @atproto/xrpc-server: atproto HTTP API server library
2
+
3
+ TypeScript library for implementing [atproto](https://atproto.com) HTTP API services, with Lexicon schema validation.
4
+
5
+ [![NPM](https://img.shields.io/npm/v/@atproto/xrpc-server)](https://www.npmjs.com/package/@atproto/xrpc-server)
6
+ [![Github CI Status](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml/badge.svg)](https://github.com/bluesky-social/atproto/actions/workflows/repo.yaml)
2
7
 
3
8
  ## Usage
4
9
 
package/dist/index.js CHANGED
@@ -45621,7 +45621,7 @@ var lexObject = z.object({
45621
45621
  description: z.string().optional(),
45622
45622
  required: z.string().array().optional(),
45623
45623
  nullable: z.string().array().optional(),
45624
- properties: z.record(z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive])).optional()
45624
+ properties: z.record(z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive]))
45625
45625
  }).strict().superRefine(requiredPropertiesRefinement);
45626
45626
  var lexXrpcParameters = z.object({
45627
45627
  type: z.literal("params"),
@@ -46316,7 +46316,7 @@ var XRPCError2 = class extends Error {
46316
46316
  }
46317
46317
  };
46318
46318
  function isHandlerError(v) {
46319
- return handlerError.safeParse(v).success;
46319
+ return !!v && typeof v === "object" && typeof v["status"] === "number" && (v["error"] === void 0 || typeof v["error"] === "string") && (v["message"] === void 0 || typeof v["message"] === "string");
46320
46320
  }
46321
46321
  var InvalidRequestError = class extends XRPCError2 {
46322
46322
  constructor(errorMessage, customErrorName) {
@@ -46365,6 +46365,9 @@ var MethodNotImplementedError = class extends XRPCError2 {
46365
46365
  }
46366
46366
  };
46367
46367
 
46368
+ // ../common/src/dates.ts
46369
+ var import_iso_datestring_validator2 = __toESM(require_dist());
46370
+
46368
46371
  // ../../node_modules/.pnpm/cborg@1.10.2/node_modules/cborg/esm/lib/is.js
46369
46372
  var typeofs = [
46370
46373
  "string",
@@ -52646,7 +52649,8 @@ var import_rate_limiter_flexible = __toESM(require_rate_limiter_flexible());
52646
52649
  var RateLimiter = class {
52647
52650
  constructor(limiter, opts) {
52648
52651
  this.limiter = limiter;
52649
- this.byPassSecret = opts.bypassSecret;
52652
+ this.bypassSecret = opts.bypassSecret;
52653
+ this.bypassIps = opts.bypassIps;
52650
52654
  this.calcKey = opts.calcKey ?? defaultKey;
52651
52655
  this.calcPoints = opts.calcPoints ?? defaultPoints;
52652
52656
  }
@@ -52668,7 +52672,10 @@ var RateLimiter = class {
52668
52672
  return new RateLimiter(limiter, opts);
52669
52673
  }
52670
52674
  async consume(ctx, opts) {
52671
- if (this.byPassSecret && ctx.req.header("x-ratelimit-bypass") === this.byPassSecret) {
52675
+ if (this.bypassSecret && ctx.req.header("x-ratelimit-bypass") === this.bypassSecret) {
52676
+ return null;
52677
+ }
52678
+ if (this.bypassIps && this.bypassIps.includes(ctx.req.ip)) {
52672
52679
  return null;
52673
52680
  }
52674
52681
  const key = opts?.calcKey ? opts.calcKey(ctx) : this.calcKey(ctx);
@@ -52989,7 +52996,8 @@ var Server = class {
52989
52996
  if (config2.rateLimit) {
52990
52997
  const limits = Array.isArray(config2.rateLimit) ? config2.rateLimit : [config2.rateLimit];
52991
52998
  this.routeRateLimiterFns[nsid2] = [];
52992
- for (const limit of limits) {
52999
+ for (let i = 0; i < limits.length; i++) {
53000
+ const limit = limits[i];
52993
53001
  const { calcKey, calcPoints } = limit;
52994
53002
  if (isShared(limit)) {
52995
53003
  const rateLimiter = this.sharedRateLimiters[limit.name];
@@ -53003,7 +53011,7 @@ var Server = class {
53003
53011
  } else {
53004
53012
  const { durationMs, points } = limit;
53005
53013
  const rateLimiter = this.options.rateLimits?.creator({
53006
- keyPrefix: nsid2,
53014
+ keyPrefix: `nsid-${i}`,
53007
53015
  durationMs,
53008
53016
  points,
53009
53017
  calcKey,