@atproto/xrpc-server 0.3.1 → 0.3.3

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,21 @@
1
1
  # @atproto/xrpc-server
2
2
 
3
+ ## 0.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atproto/common@0.3.2
9
+ - @atproto/lexicon@0.2.3
10
+
11
+ ## 0.3.2
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies []:
16
+ - @atproto/common@0.3.1
17
+ - @atproto/lexicon@0.2.2
18
+
3
19
  ## 0.3.1
4
20
 
5
21
  ### 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
@@ -44909,6 +44909,25 @@ var validateLanguage = (langTag) => {
44909
44909
  };
44910
44910
  var bcp47Regexp = /^((?<grandfathered>(en-GB-oed|i-ami|i-bnn|i-default|i-enochian|i-hak|i-klingon|i-lux|i-mingo|i-navajo|i-pwn|i-tao|i-tay|i-tsu|sgn-BE-FR|sgn-BE-NL|sgn-CH-DE)|(art-lojban|cel-gaulish|no-bok|no-nyn|zh-guoyu|zh-hakka|zh-min|zh-min-nan|zh-xiang))|((?<language>([A-Za-z]{2,3}(-(?<extlang>[A-Za-z]{3}(-[A-Za-z]{3}){0,2}))?)|[A-Za-z]{4}|[A-Za-z]{5,8})(-(?<script>[A-Za-z]{4}))?(-(?<region>[A-Za-z]{2}|[0-9]{3}))?(-(?<variant>[A-Za-z0-9]{5,8}|[0-9][A-Za-z0-9]{3}))*(-(?<extension>[0-9A-WY-Za-wy-z](-[A-Za-z0-9]{2,8})+))*(-(?<privateUseA>x(-[A-Za-z0-9]{1,8})+))?)|(?<privateUseB>x(-[A-Za-z0-9]{1,8})+))$/;
44911
44911
 
44912
+ // ../common-web/src/did-doc.ts
44913
+ var verificationMethod = z.object({
44914
+ id: z.string(),
44915
+ type: z.string(),
44916
+ controller: z.string(),
44917
+ publicKeyMultibase: z.string().optional()
44918
+ });
44919
+ var service = z.object({
44920
+ id: z.string(),
44921
+ type: z.string(),
44922
+ serviceEndpoint: z.union([z.string(), z.record(z.unknown())])
44923
+ });
44924
+ var didDocument = z.object({
44925
+ id: z.string(),
44926
+ alsoKnownAs: z.array(z.string()).optional(),
44927
+ verificationMethod: z.array(verificationMethod).optional(),
44928
+ service: z.array(service).optional()
44929
+ });
44930
+
44912
44931
  // ../lexicon/src/validators/formats.ts
44913
44932
  var import_iso_datestring_validator = __toESM(require_dist());
44914
44933
  function datetime(path, value) {
@@ -45621,7 +45640,7 @@ var lexObject = z.object({
45621
45640
  description: z.string().optional(),
45622
45641
  required: z.string().array().optional(),
45623
45642
  nullable: z.string().array().optional(),
45624
- properties: z.record(z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive])).optional()
45643
+ properties: z.record(z.union([lexRefVariant, lexIpldType, lexArray, lexBlob, lexPrimitive]))
45625
45644
  }).strict().superRefine(requiredPropertiesRefinement);
45626
45645
  var lexXrpcParameters = z.object({
45627
45646
  type: z.literal("params"),
@@ -46316,7 +46335,7 @@ var XRPCError2 = class extends Error {
46316
46335
  }
46317
46336
  };
46318
46337
  function isHandlerError(v) {
46319
- return handlerError.safeParse(v).success;
46338
+ 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
46339
  }
46321
46340
  var InvalidRequestError = class extends XRPCError2 {
46322
46341
  constructor(errorMessage, customErrorName) {
@@ -46365,6 +46384,9 @@ var MethodNotImplementedError = class extends XRPCError2 {
46365
46384
  }
46366
46385
  };
46367
46386
 
46387
+ // ../common/src/dates.ts
46388
+ var import_iso_datestring_validator2 = __toESM(require_dist());
46389
+
46368
46390
  // ../../node_modules/.pnpm/cborg@1.10.2/node_modules/cborg/esm/lib/is.js
46369
46391
  var typeofs = [
46370
46392
  "string",
@@ -52646,7 +52668,8 @@ var import_rate_limiter_flexible = __toESM(require_rate_limiter_flexible());
52646
52668
  var RateLimiter = class {
52647
52669
  constructor(limiter, opts) {
52648
52670
  this.limiter = limiter;
52649
- this.byPassSecret = opts.bypassSecret;
52671
+ this.bypassSecret = opts.bypassSecret;
52672
+ this.bypassIps = opts.bypassIps;
52650
52673
  this.calcKey = opts.calcKey ?? defaultKey;
52651
52674
  this.calcPoints = opts.calcPoints ?? defaultPoints;
52652
52675
  }
@@ -52668,7 +52691,10 @@ var RateLimiter = class {
52668
52691
  return new RateLimiter(limiter, opts);
52669
52692
  }
52670
52693
  async consume(ctx, opts) {
52671
- if (this.byPassSecret && ctx.req.header("x-ratelimit-bypass") === this.byPassSecret) {
52694
+ if (this.bypassSecret && ctx.req.header("x-ratelimit-bypass") === this.bypassSecret) {
52695
+ return null;
52696
+ }
52697
+ if (this.bypassIps && this.bypassIps.includes(ctx.req.ip)) {
52672
52698
  return null;
52673
52699
  }
52674
52700
  const key = opts?.calcKey ? opts.calcKey(ctx) : this.calcKey(ctx);
@@ -52989,7 +53015,8 @@ var Server = class {
52989
53015
  if (config2.rateLimit) {
52990
53016
  const limits = Array.isArray(config2.rateLimit) ? config2.rateLimit : [config2.rateLimit];
52991
53017
  this.routeRateLimiterFns[nsid2] = [];
52992
- for (const limit of limits) {
53018
+ for (let i = 0; i < limits.length; i++) {
53019
+ const limit = limits[i];
52993
53020
  const { calcKey, calcPoints } = limit;
52994
53021
  if (isShared(limit)) {
52995
53022
  const rateLimiter = this.sharedRateLimiters[limit.name];
@@ -53003,7 +53030,7 @@ var Server = class {
53003
53030
  } else {
53004
53031
  const { durationMs, points } = limit;
53005
53032
  const rateLimiter = this.options.rateLimits?.creator({
53006
- keyPrefix: nsid2,
53033
+ keyPrefix: `nsid-${i}`,
53007
53034
  durationMs,
53008
53035
  points,
53009
53036
  calcKey,