@atproto/pds 0.5.55 → 0.5.56
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 +24 -0
- package/dist/api/app/bsky/actor/putPreferences.d.ts.map +1 -1
- package/dist/api/app/bsky/actor/putPreferences.js +3 -0
- package/dist/api/app/bsky/actor/putPreferences.js.map +1 -1
- package/dist/api/com/atproto/admin/deleteAccount.js +1 -1
- package/dist/api/com/atproto/admin/deleteAccount.js.map +1 -1
- package/dist/api/com/atproto/admin/getSubjectStatus.js +1 -1
- package/dist/api/com/atproto/admin/getSubjectStatus.js.map +1 -1
- package/dist/api/com/atproto/admin/updateAccountHandle.js +1 -1
- package/dist/api/com/atproto/admin/updateAccountHandle.js.map +1 -1
- package/dist/api/com/atproto/admin/updateSubjectStatus.js +1 -1
- package/dist/api/com/atproto/admin/updateSubjectStatus.js.map +1 -1
- package/dist/api/com/atproto/server/createAccount.d.ts.map +1 -1
- package/dist/api/com/atproto/server/createAccount.js +13 -2
- package/dist/api/com/atproto/server/createAccount.js.map +1 -1
- package/dist/api/com/atproto/server/reserveSigningKey.d.ts.map +1 -1
- package/dist/api/com/atproto/server/reserveSigningKey.js +3 -0
- package/dist/api/com/atproto/server/reserveSigningKey.js.map +1 -1
- package/dist/auth-output.d.ts +6 -0
- package/dist/auth-output.d.ts.map +1 -1
- package/dist/auth-output.js.map +1 -1
- package/dist/auth-verifier.d.ts +21 -2
- package/dist/auth-verifier.d.ts.map +1 -1
- package/dist/auth-verifier.js +98 -0
- package/dist/auth-verifier.js.map +1 -1
- package/dist/config/config.d.ts +11 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +2 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/env.d.ts +2 -0
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +2 -0
- package/dist/config/env.js.map +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +8 -2
- package/dist/context.js.map +1 -1
- package/dist/entryway-attribution.d.ts +39 -0
- package/dist/entryway-attribution.d.ts.map +1 -0
- package/dist/entryway-attribution.js +101 -0
- package/dist/entryway-attribution.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +8 -1
- package/dist/logger.js.map +1 -1
- package/dist/rate-limits.d.ts +2 -2
- package/dist/rate-limits.d.ts.map +1 -1
- package/dist/rate-limits.js +6 -6
- package/dist/rate-limits.js.map +1 -1
- package/dist/util/ip.d.ts +8 -0
- package/dist/util/ip.d.ts.map +1 -0
- package/dist/util/ip.js +34 -0
- package/dist/util/ip.js.map +1 -0
- package/package.json +9 -9
package/dist/rate-limits.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { DAY, HOUR, MINUTE } from '@atproto/common';
|
|
2
2
|
import { MemoryRateLimiter, RedisRateLimiter } from '@atproto/xrpc-server';
|
|
3
3
|
const SYNC_GET_REPO_PATH = '/xrpc/com.atproto.sync.getRepo';
|
|
4
|
-
export const buildRateLimitsConfig = (rateLimits, redisScratch) => {
|
|
4
|
+
export const buildRateLimitsConfig = (rateLimits, redisScratch, bypass) => {
|
|
5
5
|
if (!rateLimits.enabled)
|
|
6
6
|
return undefined;
|
|
7
|
+
const { bypassKey, bypassIps } = rateLimits;
|
|
7
8
|
return {
|
|
8
9
|
creator: redisScratch
|
|
9
10
|
? (opts) => new RedisRateLimiter(redisScratch, opts)
|
|
10
11
|
: (opts) => new MemoryRateLimiter(opts),
|
|
11
|
-
bypass: (
|
|
12
|
-
|
|
13
|
-
if (bypassKey && bypassKey === req.headers['x-ratelimit-bypass']) {
|
|
12
|
+
bypass: (ctx) => {
|
|
13
|
+
if (bypassKey && bypassKey === ctx.req.headers['x-ratelimit-bypass']) {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
|
-
if (bypassIps && bypassIps.includes(req.ip)) {
|
|
16
|
+
if (bypassIps && bypassIps.includes(ctx.req.ip)) {
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
|
-
return false;
|
|
19
|
+
return bypass ? bypass(ctx) : false;
|
|
20
20
|
},
|
|
21
21
|
global: [
|
|
22
22
|
{
|
package/dist/rate-limits.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limits.js","sourceRoot":"","sources":["../src/rate-limits.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAM1E,MAAM,kBAAkB,GAAG,gCAAgC,CAAA;AAE3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,UAA4B,EAC5B,YAAoB,
|
|
1
|
+
{"version":3,"file":"rate-limits.js","sourceRoot":"","sources":["../src/rate-limits.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAM1E,MAAM,kBAAkB,GAAG,gCAAgC,CAAA;AAE3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,UAA4B,EAC5B,YAAoB,EACpB,MAAyC,EACN,EAAE;IACrC,IAAI,CAAC,UAAU,CAAC,OAAO;QAAE,OAAO,SAAS,CAAA;IACzC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,UAAU,CAAA;IAE3C,OAAO;QACL,OAAO,EAAE,YAAY;YACnB,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,YAAY,EAAE,IAAI,CAAC;YACpD,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC;QACzC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE;YACd,IAAI,SAAS,IAAI,SAAS,KAAK,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;gBACrE,OAAO,IAAI,CAAA;YACb,CAAC;YACD,IAAI,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBAChD,OAAO,IAAI,CAAA;YACb,CAAC;YACD,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QACrC,CAAC;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,WAAW;gBACjB,UAAU,EAAE,CAAC,GAAG,MAAM;gBACtB,MAAM,EAAE,IAAI;gBACZ,qEAAqE;gBACrE,8DAA8D;gBAC9D,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;oBACnB,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;wBACpC,OAAO,IAAI,CAAA;oBACb,CAAC;oBACD,OAAO,GAAG,CAAC,EAAE,CAAA;gBACf,CAAC;aACF;SACF;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,iBAAiB;gBACvB,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE,IAAI,EAAE,+BAA+B;aAC9C;YACD;gBACE,IAAI,EAAE,gBAAgB;gBACtB,UAAU,EAAE,GAAG;gBACf,MAAM,EAAE,KAAK,EAAE,+BAA+B;aAC/C;SACF;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type { Redis } from 'ioredis'\nimport { DAY, HOUR, MINUTE } from '@atproto/common'\nimport { MemoryRateLimiter, RedisRateLimiter } from '@atproto/xrpc-server'\nimport type { HandlerContext, Options } from '@atproto/xrpc-server'\nimport type { RateLimitsConfig } from './config/index.js'\n\ntype RateLimitDescriptions = NonNullable<Options['rateLimits']>\n\nconst SYNC_GET_REPO_PATH = '/xrpc/com.atproto.sync.getRepo'\n\nexport const buildRateLimitsConfig = (\n rateLimits: RateLimitsConfig,\n redisScratch?: Redis,\n bypass?: (ctx: HandlerContext) => boolean,\n): RateLimitDescriptions | undefined => {\n if (!rateLimits.enabled) return undefined\n const { bypassKey, bypassIps } = rateLimits\n\n return {\n creator: redisScratch\n ? (opts) => new RedisRateLimiter(redisScratch, opts)\n : (opts) => new MemoryRateLimiter(opts),\n bypass: (ctx) => {\n if (bypassKey && bypassKey === ctx.req.headers['x-ratelimit-bypass']) {\n return true\n }\n if (bypassIps && bypassIps.includes(ctx.req.ip)) {\n return true\n }\n return bypass ? bypass(ctx) : false\n },\n global: [\n {\n name: 'global-ip',\n durationMs: 5 * MINUTE,\n points: 3000,\n // getRepo can be a high-volume sync path, so it has its own endpoint\n // limit and should not consume the shared global read bucket.\n calcKey: ({ req }) => {\n if (req.path === SYNC_GET_REPO_PATH) {\n return null\n }\n return req.ip\n },\n },\n ],\n shared: [\n {\n name: 'repo-write-hour',\n durationMs: HOUR,\n points: 5000, // creates=3, puts=2, deletes=1\n },\n {\n name: 'repo-write-day',\n durationMs: DAY,\n points: 35000, // creates=3, puts=2, deletes=1\n },\n ],\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the canonical spelling of an IP address, so that one address always
|
|
3
|
+
* yields one rate limit key: IPv4-mapped IPv6 becomes plain IPv4, and other
|
|
4
|
+
* IPv6 addresses lose any zone ID and are lowercased and compressed as in RFC
|
|
5
|
+
* 5952. Returns null for anything that is not an IP address.
|
|
6
|
+
*/
|
|
7
|
+
export declare function canonicalIp(ip: string): string | null;
|
|
8
|
+
//# sourceMappingURL=ip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ip.d.ts","sourceRoot":"","sources":["../../src/util/ip.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAyBrD"}
|
package/dist/util/ip.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isIP } from 'node:net';
|
|
2
|
+
const IPV4_MAPPED = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/;
|
|
3
|
+
/**
|
|
4
|
+
* Returns the canonical spelling of an IP address, so that one address always
|
|
5
|
+
* yields one rate limit key: IPv4-mapped IPv6 becomes plain IPv4, and other
|
|
6
|
+
* IPv6 addresses lose any zone ID and are lowercased and compressed as in RFC
|
|
7
|
+
* 5952. Returns null for anything that is not an IP address.
|
|
8
|
+
*/
|
|
9
|
+
export function canonicalIp(ip) {
|
|
10
|
+
const family = isIP(ip);
|
|
11
|
+
// node:net refuses leading zeros, so its IPv4 addresses are canonical.
|
|
12
|
+
if (family === 4)
|
|
13
|
+
return ip;
|
|
14
|
+
if (family !== 6)
|
|
15
|
+
return null;
|
|
16
|
+
const zoneIdx = ip.indexOf('%');
|
|
17
|
+
const address = zoneIdx === -1 ? ip : ip.slice(0, zoneIdx);
|
|
18
|
+
// The WHATWG URL parser serializes IPv6 hosts in RFC 5952 form.
|
|
19
|
+
let canonical;
|
|
20
|
+
try {
|
|
21
|
+
canonical = new URL(`http://[${address}]`).hostname.slice(1, -1);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const mapped = IPV4_MAPPED.exec(canonical);
|
|
27
|
+
if (mapped) {
|
|
28
|
+
const hi = parseInt(mapped[1], 16);
|
|
29
|
+
const lo = parseInt(mapped[2], 16);
|
|
30
|
+
canonical = `${hi >> 8}.${hi & 0xff}.${lo >> 8}.${lo & 0xff}`;
|
|
31
|
+
}
|
|
32
|
+
return isIP(canonical) === 0 ? null : canonical;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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AC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACjD,CAAC","sourcesContent":["import { isIP } from 'node:net'\n\nconst IPV4_MAPPED = /^::ffff:([0-9a-f]{1,4}):([0-9a-f]{1,4})$/\n\n/**\n * Returns the canonical spelling of an IP address, so that one address always\n * yields one rate limit key: IPv4-mapped IPv6 becomes plain IPv4, and other\n * IPv6 addresses lose any zone ID and are lowercased and compressed as in RFC\n * 5952. Returns null for anything that is not an IP address.\n */\nexport function canonicalIp(ip: string): string | null {\n const family = isIP(ip)\n // node:net refuses leading zeros, so its IPv4 addresses are canonical.\n if (family === 4) return ip\n if (family !== 6) return null\n\n const zoneIdx = ip.indexOf('%')\n const address = zoneIdx === -1 ? ip : ip.slice(0, zoneIdx)\n\n // The WHATWG URL parser serializes IPv6 hosts in RFC 5952 form.\n let canonical: string\n try {\n canonical = new URL(`http://[${address}]`).hostname.slice(1, -1)\n } catch {\n return null\n }\n\n const mapped = IPV4_MAPPED.exec(canonical)\n if (mapped) {\n const hi = parseInt(mapped[1], 16)\n const lo = parseInt(mapped[2], 16)\n canonical = `${hi >> 8}.${hi & 0xff}.${lo >> 8}.${lo & 0xff}`\n }\n\n return isIP(canonical) === 0 ? null : canonical\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/pds",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.56",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Reference implementation of atproto Personal Data Server (PDS)",
|
|
6
6
|
"keywords": [
|
|
@@ -40,23 +40,23 @@
|
|
|
40
40
|
"@atproto-labs/simple-store": "^0.5.1",
|
|
41
41
|
"@atproto-labs/simple-store-memory": "^0.2.6",
|
|
42
42
|
"@atproto-labs/simple-store-redis": "^0.1.6",
|
|
43
|
-
"@atproto-labs/xrpc-utils": "^0.1.
|
|
44
|
-
"@atproto/aws": "^0.3.
|
|
45
|
-
"@atproto/common": "^0.8.
|
|
43
|
+
"@atproto-labs/xrpc-utils": "^0.1.31",
|
|
44
|
+
"@atproto/aws": "^0.3.24",
|
|
45
|
+
"@atproto/common": "^0.8.10",
|
|
46
46
|
"@atproto/crypto": "^0.5.7",
|
|
47
47
|
"@atproto/did": "^0.5.6",
|
|
48
48
|
"@atproto/identity": "^0.5.23",
|
|
49
|
-
"@atproto/lex-cbor": "^0.1.
|
|
49
|
+
"@atproto/lex-cbor": "^0.1.10",
|
|
50
50
|
"@atproto/lex-client": "^0.4.2",
|
|
51
51
|
"@atproto/lex-data": "^0.1.10",
|
|
52
52
|
"@atproto/lex-document": "^0.1.16",
|
|
53
53
|
"@atproto/lex-json": "^0.1.9",
|
|
54
54
|
"@atproto/lex-schema": "^0.2.11",
|
|
55
|
-
"@atproto/oauth-provider": "^0.25.
|
|
55
|
+
"@atproto/oauth-provider": "^0.25.6",
|
|
56
56
|
"@atproto/oauth-scopes": "^0.5.14",
|
|
57
|
-
"@atproto/repo": "^0.11.
|
|
57
|
+
"@atproto/repo": "^0.11.5",
|
|
58
58
|
"@atproto/syntax": "^0.7.7",
|
|
59
|
-
"@atproto/xrpc-server": "^0.13.
|
|
59
|
+
"@atproto/xrpc-server": "^0.13.10",
|
|
60
60
|
"@did-plc/lib": "^0.0.4",
|
|
61
61
|
"@hapi/address": "^5.1.1",
|
|
62
62
|
"@noble/curves": "^1.7.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"@atproto/api": "^0.30.3",
|
|
90
|
-
"@atproto/lex": "^0.4.
|
|
90
|
+
"@atproto/lex": "^0.4.8",
|
|
91
91
|
"@atproto/oauth-client-browser-example": "^0.2.1",
|
|
92
92
|
"@atproto/oauth-client-node": "^0.5.16",
|
|
93
93
|
"@did-plc/server": "^0.0.1",
|