@atproto/pds 0.4.136 → 0.4.138

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/api/com/atproto/server/getSession.d.ts.map +1 -1
  3. package/dist/api/com/atproto/server/getSession.js +26 -4
  4. package/dist/api/com/atproto/server/getSession.js.map +1 -1
  5. package/dist/auth-verifier.d.ts +23 -18
  6. package/dist/auth-verifier.d.ts.map +1 -1
  7. package/dist/auth-verifier.js +14 -19
  8. package/dist/auth-verifier.js.map +1 -1
  9. package/dist/config/config.js +1 -1
  10. package/dist/config/config.js.map +1 -1
  11. package/dist/context.d.ts.map +1 -1
  12. package/dist/context.js +5 -1
  13. package/dist/context.js.map +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +13 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/lexicon/index.d.ts +2 -2
  18. package/dist/lexicon/index.d.ts.map +1 -1
  19. package/dist/lexicon/index.js +4 -4
  20. package/dist/lexicon/index.js.map +1 -1
  21. package/dist/lexicon/lexicons.d.ts +158 -82
  22. package/dist/lexicon/lexicons.d.ts.map +1 -1
  23. package/dist/lexicon/lexicons.js +80 -42
  24. package/dist/lexicon/lexicons.js.map +1 -1
  25. package/dist/lexicon/types/app/bsky/feed/defs.d.ts +4 -0
  26. package/dist/lexicon/types/app/bsky/feed/defs.d.ts.map +1 -1
  27. package/dist/lexicon/types/app/bsky/feed/defs.js.map +1 -1
  28. package/dist/lexicon/types/app/bsky/feed/getFeedSkeleton.d.ts +2 -0
  29. package/dist/lexicon/types/app/bsky/feed/getFeedSkeleton.d.ts.map +1 -1
  30. package/dist/lexicon/types/app/bsky/unspecced/getConfig.d.ts +9 -0
  31. package/dist/lexicon/types/app/bsky/unspecced/getConfig.d.ts.map +1 -1
  32. package/dist/lexicon/types/app/bsky/unspecced/getConfig.js +9 -0
  33. package/dist/lexicon/types/app/bsky/unspecced/getConfig.js.map +1 -1
  34. package/dist/pipethrough.d.ts.map +1 -1
  35. package/dist/pipethrough.js +1 -0
  36. package/dist/pipethrough.js.map +1 -1
  37. package/package.json +8 -8
  38. package/src/api/com/atproto/server/getSession.ts +44 -9
  39. package/src/auth-verifier.ts +44 -44
  40. package/src/config/config.ts +1 -1
  41. package/src/context.ts +5 -1
  42. package/src/index.ts +13 -1
  43. package/src/lexicon/index.ts +9 -9
  44. package/src/lexicon/lexicons.ts +84 -43
  45. package/src/lexicon/types/app/bsky/feed/defs.ts +4 -0
  46. package/src/lexicon/types/app/bsky/feed/getFeedSkeleton.ts +2 -0
  47. package/src/lexicon/types/app/bsky/unspecced/getConfig.ts +17 -0
  48. package/src/pipethrough.ts +1 -0
package/src/index.ts CHANGED
@@ -122,7 +122,14 @@ export class PDS {
122
122
  server = API(server, ctx)
123
123
 
124
124
  const app = express()
125
- app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal'])
125
+ app.set('trust proxy', [
126
+ // e.g. load balancer
127
+ 'loopback',
128
+ 'linklocal',
129
+ 'uniquelocal',
130
+ // e.g. trust x-forwarded-for via entryway ip
131
+ ...getTrustedIps(cfg),
132
+ ])
126
133
  app.use(loggerMiddleware)
127
134
  app.use(compression())
128
135
  app.use(authRoutes.createRouter(ctx)) // Before CORS
@@ -161,3 +168,8 @@ export class PDS {
161
168
  }
162
169
 
163
170
  export default PDS
171
+
172
+ const getTrustedIps = (cfg: ServerConfig) => {
173
+ if (!cfg.rateLimits.enabled) return []
174
+ return cfg.rateLimits.bypassIps ?? []
175
+ }
@@ -108,8 +108,8 @@ import * as AppBskyFeedGetFeedGenerators from './types/app/bsky/feed/getFeedGene
108
108
  import * as AppBskyFeedGetFeedSkeleton from './types/app/bsky/feed/getFeedSkeleton.js'
109
109
  import * as AppBskyFeedGetLikes from './types/app/bsky/feed/getLikes.js'
110
110
  import * as AppBskyFeedGetListFeed from './types/app/bsky/feed/getListFeed.js'
111
- import * as AppBskyFeedGetPostThread from './types/app/bsky/feed/getPostThread.js'
112
111
  import * as AppBskyFeedGetPosts from './types/app/bsky/feed/getPosts.js'
112
+ import * as AppBskyFeedGetPostThread from './types/app/bsky/feed/getPostThread.js'
113
113
  import * as AppBskyFeedGetQuotes from './types/app/bsky/feed/getQuotes.js'
114
114
  import * as AppBskyFeedGetRepostedBy from './types/app/bsky/feed/getRepostedBy.js'
115
115
  import * as AppBskyFeedGetSuggestedFeeds from './types/app/bsky/feed/getSuggestedFeeds.js'
@@ -1547,25 +1547,25 @@ export class AppBskyFeedNS {
1547
1547
  return this._server.xrpc.method(nsid, cfg)
1548
1548
  }
1549
1549
 
1550
- getPostThread<AV extends AuthVerifier>(
1550
+ getPosts<AV extends AuthVerifier>(
1551
1551
  cfg: ConfigOf<
1552
1552
  AV,
1553
- AppBskyFeedGetPostThread.Handler<ExtractAuth<AV>>,
1554
- AppBskyFeedGetPostThread.HandlerReqCtx<ExtractAuth<AV>>
1553
+ AppBskyFeedGetPosts.Handler<ExtractAuth<AV>>,
1554
+ AppBskyFeedGetPosts.HandlerReqCtx<ExtractAuth<AV>>
1555
1555
  >,
1556
1556
  ) {
1557
- const nsid = 'app.bsky.feed.getPostThread' // @ts-ignore
1557
+ const nsid = 'app.bsky.feed.getPosts' // @ts-ignore
1558
1558
  return this._server.xrpc.method(nsid, cfg)
1559
1559
  }
1560
1560
 
1561
- getPosts<AV extends AuthVerifier>(
1561
+ getPostThread<AV extends AuthVerifier>(
1562
1562
  cfg: ConfigOf<
1563
1563
  AV,
1564
- AppBskyFeedGetPosts.Handler<ExtractAuth<AV>>,
1565
- AppBskyFeedGetPosts.HandlerReqCtx<ExtractAuth<AV>>
1564
+ AppBskyFeedGetPostThread.Handler<ExtractAuth<AV>>,
1565
+ AppBskyFeedGetPostThread.HandlerReqCtx<ExtractAuth<AV>>
1566
1566
  >,
1567
1567
  ) {
1568
- const nsid = 'app.bsky.feed.getPosts' // @ts-ignore
1568
+ const nsid = 'app.bsky.feed.getPostThread' // @ts-ignore
1569
1569
  return this._server.xrpc.method(nsid, cfg)
1570
1570
  }
1571
1571
 
@@ -6221,6 +6221,12 @@ export const schemaDict = {
6221
6221
  'Context provided by feed generator that may be passed back alongside interactions.',
6222
6222
  maxLength: 2000,
6223
6223
  },
6224
+ reqId: {
6225
+ type: 'string',
6226
+ description:
6227
+ 'Unique identifier per request that may be passed back alongside interactions.',
6228
+ maxLength: 100,
6229
+ },
6224
6230
  },
6225
6231
  },
6226
6232
  replyRef: {
@@ -6517,6 +6523,12 @@ export const schemaDict = {
6517
6523
  'Context on a feed item that was originally supplied by the feed generator on getFeedSkeleton.',
6518
6524
  maxLength: 2000,
6519
6525
  },
6526
+ reqId: {
6527
+ type: 'string',
6528
+ description:
6529
+ 'Unique identifier per request that may be passed back alongside interactions.',
6530
+ maxLength: 100,
6531
+ },
6520
6532
  },
6521
6533
  },
6522
6534
  requestLess: {
@@ -7065,6 +7077,12 @@ export const schemaDict = {
7065
7077
  ref: 'lex:app.bsky.feed.defs#skeletonFeedPost',
7066
7078
  },
7067
7079
  },
7080
+ reqId: {
7081
+ type: 'string',
7082
+ description:
7083
+ 'Unique identifier per request that may be passed back alongside interactions.',
7084
+ maxLength: 100,
7085
+ },
7068
7086
  },
7069
7087
  },
7070
7088
  },
@@ -7213,6 +7231,48 @@ export const schemaDict = {
7213
7231
  },
7214
7232
  },
7215
7233
  },
7234
+ AppBskyFeedGetPosts: {
7235
+ lexicon: 1,
7236
+ id: 'app.bsky.feed.getPosts',
7237
+ defs: {
7238
+ main: {
7239
+ type: 'query',
7240
+ description:
7241
+ "Gets post views for a specified list of posts (by AT-URI). This is sometimes referred to as 'hydrating' a 'feed skeleton'.",
7242
+ parameters: {
7243
+ type: 'params',
7244
+ required: ['uris'],
7245
+ properties: {
7246
+ uris: {
7247
+ type: 'array',
7248
+ description: 'List of post AT-URIs to return hydrated views for.',
7249
+ items: {
7250
+ type: 'string',
7251
+ format: 'at-uri',
7252
+ },
7253
+ maxLength: 25,
7254
+ },
7255
+ },
7256
+ },
7257
+ output: {
7258
+ encoding: 'application/json',
7259
+ schema: {
7260
+ type: 'object',
7261
+ required: ['posts'],
7262
+ properties: {
7263
+ posts: {
7264
+ type: 'array',
7265
+ items: {
7266
+ type: 'ref',
7267
+ ref: 'lex:app.bsky.feed.defs#postView',
7268
+ },
7269
+ },
7270
+ },
7271
+ },
7272
+ },
7273
+ },
7274
+ },
7275
+ },
7216
7276
  AppBskyFeedGetPostThread: {
7217
7277
  lexicon: 1,
7218
7278
  id: 'app.bsky.feed.getPostThread',
@@ -7277,48 +7337,6 @@ export const schemaDict = {
7277
7337
  },
7278
7338
  },
7279
7339
  },
7280
- AppBskyFeedGetPosts: {
7281
- lexicon: 1,
7282
- id: 'app.bsky.feed.getPosts',
7283
- defs: {
7284
- main: {
7285
- type: 'query',
7286
- description:
7287
- "Gets post views for a specified list of posts (by AT-URI). This is sometimes referred to as 'hydrating' a 'feed skeleton'.",
7288
- parameters: {
7289
- type: 'params',
7290
- required: ['uris'],
7291
- properties: {
7292
- uris: {
7293
- type: 'array',
7294
- description: 'List of post AT-URIs to return hydrated views for.',
7295
- items: {
7296
- type: 'string',
7297
- format: 'at-uri',
7298
- },
7299
- maxLength: 25,
7300
- },
7301
- },
7302
- },
7303
- output: {
7304
- encoding: 'application/json',
7305
- schema: {
7306
- type: 'object',
7307
- required: ['posts'],
7308
- properties: {
7309
- posts: {
7310
- type: 'array',
7311
- items: {
7312
- type: 'ref',
7313
- ref: 'lex:app.bsky.feed.defs#postView',
7314
- },
7315
- },
7316
- },
7317
- },
7318
- },
7319
- },
7320
- },
7321
- },
7322
7340
  AppBskyFeedGetQuotes: {
7323
7341
  lexicon: 1,
7324
7342
  id: 'app.bsky.feed.getQuotes',
@@ -10183,6 +10201,29 @@ export const schemaDict = {
10183
10201
  checkEmailConfirmed: {
10184
10202
  type: 'boolean',
10185
10203
  },
10204
+ liveNow: {
10205
+ type: 'array',
10206
+ items: {
10207
+ type: 'ref',
10208
+ ref: 'lex:app.bsky.unspecced.getConfig#liveNowConfig',
10209
+ },
10210
+ },
10211
+ },
10212
+ },
10213
+ },
10214
+ },
10215
+ liveNowConfig: {
10216
+ type: 'object',
10217
+ required: ['did', 'domains'],
10218
+ properties: {
10219
+ did: {
10220
+ type: 'string',
10221
+ format: 'did',
10222
+ },
10223
+ domains: {
10224
+ type: 'array',
10225
+ items: {
10226
+ type: 'string',
10186
10227
  },
10187
10228
  },
10188
10229
  },
@@ -16216,8 +16257,8 @@ export const ids = {
16216
16257
  AppBskyFeedGetFeedSkeleton: 'app.bsky.feed.getFeedSkeleton',
16217
16258
  AppBskyFeedGetLikes: 'app.bsky.feed.getLikes',
16218
16259
  AppBskyFeedGetListFeed: 'app.bsky.feed.getListFeed',
16219
- AppBskyFeedGetPostThread: 'app.bsky.feed.getPostThread',
16220
16260
  AppBskyFeedGetPosts: 'app.bsky.feed.getPosts',
16261
+ AppBskyFeedGetPostThread: 'app.bsky.feed.getPostThread',
16221
16262
  AppBskyFeedGetQuotes: 'app.bsky.feed.getQuotes',
16222
16263
  AppBskyFeedGetRepostedBy: 'app.bsky.feed.getRepostedBy',
16223
16264
  AppBskyFeedGetSuggestedFeeds: 'app.bsky.feed.getSuggestedFeeds',
@@ -100,6 +100,8 @@ export interface FeedViewPost {
100
100
  reason?: $Typed<ReasonRepost> | $Typed<ReasonPin> | { $type: string }
101
101
  /** Context provided by feed generator that may be passed back alongside interactions. */
102
102
  feedContext?: string
103
+ /** Unique identifier per request that may be passed back alongside interactions. */
104
+ reqId?: string
103
105
  }
104
106
 
105
107
  const hashFeedViewPost = 'feedViewPost'
@@ -376,6 +378,8 @@ export interface Interaction {
376
378
  | (string & {})
377
379
  /** Context on a feed item that was originally supplied by the feed generator on getFeedSkeleton. */
378
380
  feedContext?: string
381
+ /** Unique identifier per request that may be passed back alongside interactions. */
382
+ reqId?: string
379
383
  }
380
384
 
381
385
  const hashInteraction = 'interaction'
@@ -29,6 +29,8 @@ export type InputSchema = undefined
29
29
  export interface OutputSchema {
30
30
  cursor?: string
31
31
  feed: AppBskyFeedDefs.SkeletonFeedPost[]
32
+ /** Unique identifier per request that may be passed back alongside interactions. */
33
+ reqId?: string
32
34
  }
33
35
 
34
36
  export type HandlerInput = undefined
@@ -22,6 +22,7 @@ export type InputSchema = undefined
22
22
 
23
23
  export interface OutputSchema {
24
24
  checkEmailConfirmed?: boolean
25
+ liveNow?: LiveNowConfig[]
25
26
  }
26
27
 
27
28
  export type HandlerInput = undefined
@@ -49,3 +50,19 @@ export type HandlerReqCtx<HA extends HandlerAuth = never> = {
49
50
  export type Handler<HA extends HandlerAuth = never> = (
50
51
  ctx: HandlerReqCtx<HA>,
51
52
  ) => Promise<HandlerOutput> | HandlerOutput
53
+
54
+ export interface LiveNowConfig {
55
+ $type?: 'app.bsky.unspecced.getConfig#liveNowConfig'
56
+ did: string
57
+ domains: string[]
58
+ }
59
+
60
+ const hashLiveNowConfig = 'liveNowConfig'
61
+
62
+ export function isLiveNowConfig<V>(v: V) {
63
+ return is$typed(v, id, hashLiveNowConfig)
64
+ }
65
+
66
+ export function validateLiveNowConfig<V>(v: V) {
67
+ return validate<LiveNowConfig & V>(v, id, hashLiveNowConfig)
68
+ }
@@ -503,6 +503,7 @@ export const PROTECTED_METHODS = new Set<string>([
503
503
  ids.ComAtprotoServerCreateAppPassword,
504
504
  ids.ComAtprotoServerDeactivateAccount,
505
505
  ids.ComAtprotoServerGetAccountInviteCodes,
506
+ ids.ComAtprotoServerGetSession,
506
507
  ids.ComAtprotoServerListAppPasswords,
507
508
  ids.ComAtprotoServerRequestAccountDelete,
508
509
  ids.ComAtprotoServerRequestEmailConfirmation,