@atproto/pds 0.4.196 → 0.4.198

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 (80) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/account-manager/db/schema/lexicon.d.ts +2 -2
  3. package/dist/account-manager/db/schema/lexicon.d.ts.map +1 -1
  4. package/dist/account-manager/db/schema/lexicon.js.map +1 -1
  5. package/dist/api/com/atproto/admin/getInviteCodes.d.ts +1 -1
  6. package/dist/api/com/atproto/sync/listRepos.d.ts +1 -1
  7. package/dist/config/config.d.ts +1 -1
  8. package/dist/config/config.d.ts.map +1 -1
  9. package/dist/config/config.js +6 -3
  10. package/dist/config/config.js.map +1 -1
  11. package/dist/config/env.d.ts +100 -101
  12. package/dist/config/env.d.ts.map +1 -1
  13. package/dist/config/env.js +6 -5
  14. package/dist/config/env.js.map +1 -1
  15. package/dist/context.d.ts.map +1 -1
  16. package/dist/context.js +23 -39
  17. package/dist/context.js.map +1 -1
  18. package/dist/db/pagination.d.ts +1 -1
  19. package/dist/handle/index.d.ts +1 -1
  20. package/dist/handle/index.d.ts.map +1 -1
  21. package/dist/lexicon/index.d.ts +19 -0
  22. package/dist/lexicon/index.d.ts.map +1 -1
  23. package/dist/lexicon/index.js +48 -1
  24. package/dist/lexicon/index.js.map +1 -1
  25. package/dist/lexicon/lexicons.d.ts +668 -0
  26. package/dist/lexicon/lexicons.d.ts.map +1 -1
  27. package/dist/lexicon/lexicons.js +356 -0
  28. package/dist/lexicon/lexicons.js.map +1 -1
  29. package/dist/lexicon/types/app/bsky/contact/defs.d.ts +24 -0
  30. package/dist/lexicon/types/app/bsky/contact/defs.d.ts.map +1 -0
  31. package/dist/lexicon/types/app/bsky/contact/defs.js +25 -0
  32. package/dist/lexicon/types/app/bsky/contact/defs.js.map +1 -0
  33. package/dist/lexicon/types/app/bsky/contact/dismissMatch.d.ts +25 -0
  34. package/dist/lexicon/types/app/bsky/contact/dismissMatch.d.ts.map +1 -0
  35. package/dist/lexicon/types/app/bsky/contact/dismissMatch.js +7 -0
  36. package/dist/lexicon/types/app/bsky/contact/dismissMatch.js.map +1 -0
  37. package/dist/lexicon/types/app/bsky/contact/getMatches.d.ts +25 -0
  38. package/dist/lexicon/types/app/bsky/contact/getMatches.d.ts.map +1 -0
  39. package/dist/lexicon/types/app/bsky/contact/getMatches.js +7 -0
  40. package/dist/lexicon/types/app/bsky/contact/getMatches.js.map +1 -0
  41. package/dist/lexicon/types/app/bsky/contact/getSyncStatus.d.ts +21 -0
  42. package/dist/lexicon/types/app/bsky/contact/getSyncStatus.d.ts.map +1 -0
  43. package/dist/lexicon/types/app/bsky/contact/getSyncStatus.js +7 -0
  44. package/dist/lexicon/types/app/bsky/contact/getSyncStatus.js.map +1 -0
  45. package/dist/lexicon/types/app/bsky/contact/importContacts.d.ts +30 -0
  46. package/dist/lexicon/types/app/bsky/contact/importContacts.d.ts.map +1 -0
  47. package/dist/lexicon/types/app/bsky/contact/importContacts.js +7 -0
  48. package/dist/lexicon/types/app/bsky/contact/importContacts.js.map +1 -0
  49. package/dist/lexicon/types/app/bsky/contact/removeData.d.ts +23 -0
  50. package/dist/lexicon/types/app/bsky/contact/removeData.d.ts.map +1 -0
  51. package/dist/lexicon/types/app/bsky/contact/removeData.js +7 -0
  52. package/dist/lexicon/types/app/bsky/contact/removeData.js.map +1 -0
  53. package/dist/lexicon/types/app/bsky/contact/startPhoneVerification.d.ts +25 -0
  54. package/dist/lexicon/types/app/bsky/contact/startPhoneVerification.d.ts.map +1 -0
  55. package/dist/lexicon/types/app/bsky/contact/startPhoneVerification.js +7 -0
  56. package/dist/lexicon/types/app/bsky/contact/startPhoneVerification.js.map +1 -0
  57. package/dist/lexicon/types/app/bsky/contact/verifyPhone.d.ts +29 -0
  58. package/dist/lexicon/types/app/bsky/contact/verifyPhone.d.ts.map +1 -0
  59. package/dist/lexicon/types/app/bsky/contact/verifyPhone.js +7 -0
  60. package/dist/lexicon/types/app/bsky/contact/verifyPhone.js.map +1 -0
  61. package/dist/lexicon/types/app/bsky/graph/defs.d.ts +8 -0
  62. package/dist/lexicon/types/app/bsky/graph/defs.d.ts.map +1 -1
  63. package/dist/lexicon/types/app/bsky/graph/defs.js.map +1 -1
  64. package/package.json +16 -17
  65. package/src/account-manager/db/schema/lexicon.ts +2 -2
  66. package/src/config/config.ts +7 -3
  67. package/src/config/env.ts +6 -150
  68. package/src/context.ts +39 -47
  69. package/src/lexicon/index.ts +101 -0
  70. package/src/lexicon/lexicons.ts +377 -0
  71. package/src/lexicon/types/app/bsky/contact/defs.ts +52 -0
  72. package/src/lexicon/types/app/bsky/contact/dismissMatch.ts +43 -0
  73. package/src/lexicon/types/app/bsky/contact/getMatches.ts +43 -0
  74. package/src/lexicon/types/app/bsky/contact/getSyncStatus.ts +39 -0
  75. package/src/lexicon/types/app/bsky/contact/importContacts.ts +49 -0
  76. package/src/lexicon/types/app/bsky/contact/removeData.ts +40 -0
  77. package/src/lexicon/types/app/bsky/contact/startPhoneVerification.ts +43 -0
  78. package/src/lexicon/types/app/bsky/contact/verifyPhone.ts +48 -0
  79. package/src/lexicon/types/app/bsky/graph/defs.ts +8 -0
  80. package/tsconfig.build.tsbuildinfo +1 -1
package/src/config/env.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { envBool, envInt, envList, envStr } from '@atproto/common'
2
2
 
3
- export const readEnv = (): ServerEnvironment => {
3
+ export function readEnv() {
4
4
  return {
5
5
  // service
6
6
  port: envInt('PDS_PORT'),
@@ -73,7 +73,7 @@ export const readEnv = (): ServerEnvironment => {
73
73
  didCacheMaxTTL: envInt('PDS_DID_CACHE_MAX_TTL'),
74
74
  resolverTimeout: envInt('PDS_ID_RESOLVER_TIMEOUT'),
75
75
  recoveryDidKey: envStr('PDS_RECOVERY_DID_KEY'),
76
- serviceHandleDomains: envList('PDS_SERVICE_HANDLE_DOMAINS'),
76
+ serviceHandleDomains: envList('PDS_SERVICE_HANDLE_DOMAINS'), // public hostname by default
77
77
  handleBackupNameservers: envList('PDS_HANDLE_BACKUP_NAMESERVERS'),
78
78
  enableDidDocWithSession: envBool('PDS_ENABLE_DID_DOC_WITH_SESSION'),
79
79
 
@@ -151,154 +151,10 @@ export const readEnv = (): ServerEnvironment => {
151
151
  proxyMaxResponseSize: envInt('PDS_PROXY_MAX_RESPONSE_SIZE'),
152
152
  proxyMaxRetries: envInt('PDS_PROXY_MAX_RETRIES'),
153
153
  proxyPreferCompressed: envBool('PDS_PROXY_PREFER_COMPRESSED'),
154
+
155
+ // lexicon resolution
156
+ lexiconDidAuthority: envStr('PDS_LEXICON_AUTHORITY_DID'),
154
157
  }
155
158
  }
156
159
 
157
- export type ServerEnvironment = {
158
- // service
159
- port?: number
160
- hostname?: string
161
- serviceDid?: string
162
- serviceName?: string
163
- version?: string
164
- homeUrl?: string
165
- logoUrl?: string
166
- privacyPolicyUrl?: string
167
- supportUrl?: string
168
- termsOfServiceUrl?: string
169
- contactEmailAddress?: string
170
- acceptingImports?: boolean
171
- maxImportSize?: number
172
- blobUploadLimit?: number
173
- devMode?: boolean
174
-
175
- // OAuth
176
- hcaptchaSiteKey?: string
177
- hcaptchaSecretKey?: string
178
- hcaptchaTokenSalt?: string
179
- trustedOAuthClients?: string[]
180
-
181
- // branding
182
- lightColor?: string
183
- darkColor?: string
184
- primaryColor?: string
185
- primaryColorContrast?: string
186
- primaryColorHue?: number
187
- errorColor?: string
188
- errorColorContrast?: string
189
- errorColorHue?: number
190
- warningColor?: string
191
- warningColorContrast?: string
192
- warningColorHue?: number
193
- successColor?: string
194
- successColorContrast?: string
195
- successColorHue?: number
196
-
197
- // database
198
- dataDirectory?: string
199
- disableWalAutoCheckpoint?: boolean
200
- accountDbLocation?: string
201
- sequencerDbLocation?: string
202
- didCacheDbLocation?: string
203
-
204
- // actor store
205
- actorStoreDirectory?: string
206
- actorStoreCacheSize?: number
207
-
208
- // blobstore: one required
209
- blobstoreS3Bucket?: string
210
- blobstoreDiskLocation?: string
211
- blobstoreDiskTmpLocation?: string
212
-
213
- // -- optional s3 parameters
214
- blobstoreS3Region?: string
215
- blobstoreS3Endpoint?: string
216
- blobstoreS3ForcePathStyle?: boolean
217
- blobstoreS3AccessKeyId?: string
218
- blobstoreS3SecretAccessKey?: string
219
- blobstoreS3UploadTimeoutMs?: number
220
-
221
- // identity
222
- didPlcUrl?: string
223
- didCacheStaleTTL?: number
224
- didCacheMaxTTL?: number
225
- resolverTimeout?: number
226
- recoveryDidKey?: string
227
- serviceHandleDomains?: string[] // public hostname by default
228
- handleBackupNameservers?: string[]
229
- enableDidDocWithSession?: boolean
230
-
231
- // entryway
232
- entrywayUrl?: string
233
- entrywayDid?: string
234
- entrywayJwtVerifyKeyK256PublicKeyHex?: string
235
- entrywayPlcRotationKey?: string
236
-
237
- // invites
238
- inviteRequired?: boolean
239
- inviteInterval?: number
240
- inviteEpoch?: number
241
-
242
- // email
243
- emailSmtpUrl?: string
244
- emailFromAddress?: string
245
- moderationEmailSmtpUrl?: string
246
- moderationEmailAddress?: string
247
-
248
- // subscription
249
- maxSubscriptionBuffer?: number
250
- repoBackfillLimitMs?: number
251
-
252
- // appview
253
- bskyAppViewUrl?: string
254
- bskyAppViewDid?: string
255
- bskyAppViewCdnUrlPattern?: string
256
-
257
- // mod service
258
- modServiceUrl?: string
259
- modServiceDid?: string
260
-
261
- // report service
262
- reportServiceUrl?: string
263
- reportServiceDid?: string
264
-
265
- // rate limits
266
- rateLimitsEnabled?: boolean
267
- rateLimitBypassKey?: string
268
- rateLimitBypassIps?: string[]
269
-
270
- // redis
271
- redisScratchAddress?: string
272
- redisScratchPassword?: string
273
-
274
- // crawler
275
- crawlers?: string[]
276
-
277
- // secrets
278
- dpopSecret?: string
279
- jwtSecret?: string
280
- adminPassword?: string
281
- entrywayAdminToken?: string
282
-
283
- // keys
284
- plcRotationKeyKmsKeyId?: string
285
- plcRotationKeyK256PrivateKeyHex?: string
286
-
287
- // user provided url http requests
288
- disableSsrfProtection?: boolean
289
-
290
- // fetch
291
- fetchForceLogging?: boolean
292
- fetchMaxResponseSize?: number
293
-
294
- // lexicon resolver
295
- lexiconDidAuthority?: string
296
-
297
- // proxy
298
- proxyAllowHTTP2?: boolean
299
- proxyHeadersTimeout?: number
300
- proxyBodyTimeout?: number
301
- proxyMaxResponseSize?: number
302
- proxyMaxRetries?: number
303
- proxyPreferCompressed?: boolean
304
- }
160
+ export type ServerEnvironment = Partial<ReturnType<typeof readEnv>>
package/src/context.ts CHANGED
@@ -9,13 +9,10 @@ import { AtpAgent } from '@atproto/api'
9
9
  import { KmsKeypair, S3BlobStore } from '@atproto/aws'
10
10
  import * as crypto from '@atproto/crypto'
11
11
  import { IdResolver } from '@atproto/identity'
12
- import {
13
- LexiconResolver,
14
- buildLexiconResolver,
15
- } from '@atproto/lexicon-resolver'
16
12
  import {
17
13
  AccessTokenMode,
18
14
  JoseKey,
15
+ LexResolver,
19
16
  OAuthProvider,
20
17
  OAuthVerifier,
21
18
  } from '@atproto/oauth-provider'
@@ -328,48 +325,6 @@ export class AppContext {
328
325
  },
329
326
  })
330
327
 
331
- const baseLexiconResolver = buildLexiconResolver({
332
- idResolver,
333
- rpc: { fetch: safeFetch },
334
- })
335
-
336
- const getLexiconAuthority = (_nsid: string): string | undefined => {
337
- // At the moment, only a single override strategy is supported by
338
- // specifying a did through which all the lexicons will be resolved. We
339
- // might need more granular control in the future (e.g. per-nsid
340
- // overrides)
341
- return cfg.lexicon.didAuthority
342
- }
343
-
344
- const lexiconResolver: LexiconResolver = async (input) => {
345
- const nsid: string = String(input)
346
- try {
347
- const result = await baseLexiconResolver(input, {
348
- didAuthority: getLexiconAuthority(nsid),
349
- // Right now, the lexicon resolver is only used by the oauth-provider,
350
- // which caches the responses internally (through the LexiconStore).
351
- // Since the `LexiconResolver` does not allow specifying a
352
- // `forceRefresh` option, we hard code it here. Should PDSs need to
353
- // resolve lexicons for other purposes (e.g. record validation), we'd
354
- // probably want to either implement caching as built into the
355
- // lexiconResolver here, or allow the caller (oauth-provider, etc.) to
356
- // specify a `forceRefresh` option by altering the LexiconResolver
357
- // interface.
358
- forceRefresh: true,
359
- })
360
-
361
- const cid = result.cid.toString()
362
- const uri = result.uri.toString()
363
- lexiconResolverLogger.info({ nsid, uri, cid }, 'Resolved lexicon')
364
-
365
- return result
366
- } catch (err) {
367
- lexiconResolverLogger.error({ nsid, err }, 'Lexicon resolution failed')
368
-
369
- throw err
370
- }
371
- }
372
-
373
328
  const oauthProvider = cfg.oauth.provider
374
329
  ? new OAuthProvider({
375
330
  issuer: cfg.oauth.issuer,
@@ -393,7 +348,44 @@ export class AppContext {
393
348
  hcaptcha: cfg.oauth.provider.hcaptcha,
394
349
  branding: cfg.oauth.provider.branding,
395
350
  safeFetch,
396
- lexiconResolver,
351
+ lexResolver: new LexResolver({
352
+ fetch: safeFetch,
353
+ plcDirectoryUrl: cfg.identity.plcUrl,
354
+ hooks: {
355
+ onResolveAuthority: ({ nsid }) => {
356
+ lexiconResolverLogger.debug(
357
+ { nsid: nsid.toString() },
358
+ 'Resolving lexicon DID authority',
359
+ )
360
+ // Override the lexicon did resolution to point to a custom PDS
361
+ return cfg.lexicon.didAuthority
362
+ },
363
+ onResolveAuthorityResult({ nsid, did }) {
364
+ lexiconResolverLogger.info(
365
+ { nsid: nsid.toString(), did },
366
+ 'Resolved lexicon DID',
367
+ )
368
+ },
369
+ onResolveAuthorityError({ nsid, err }) {
370
+ lexiconResolverLogger.error(
371
+ { nsid: nsid.toString(), err },
372
+ 'Lexicon DID resolution error',
373
+ )
374
+ },
375
+ onFetchResult({ uri, cid }) {
376
+ lexiconResolverLogger.info(
377
+ { uri: uri.toString(), cid: cid.toString() },
378
+ 'Fetched lexicon',
379
+ )
380
+ },
381
+ onFetchError({ err, uri }) {
382
+ lexiconResolverLogger.error(
383
+ { uri: uri.toString(), err },
384
+ 'Lexicon fetch error',
385
+ )
386
+ },
387
+ },
388
+ }),
397
389
  metadata: {
398
390
  protected_resources: [new URL(cfg.oauth.issuer).origin],
399
391
  },
@@ -23,6 +23,13 @@ import * as AppBskyAgeassuranceGetState from './types/app/bsky/ageassurance/getS
23
23
  import * as AppBskyBookmarkCreateBookmark from './types/app/bsky/bookmark/createBookmark.js'
24
24
  import * as AppBskyBookmarkDeleteBookmark from './types/app/bsky/bookmark/deleteBookmark.js'
25
25
  import * as AppBskyBookmarkGetBookmarks from './types/app/bsky/bookmark/getBookmarks.js'
26
+ import * as AppBskyContactDismissMatch from './types/app/bsky/contact/dismissMatch.js'
27
+ import * as AppBskyContactGetMatches from './types/app/bsky/contact/getMatches.js'
28
+ import * as AppBskyContactGetSyncStatus from './types/app/bsky/contact/getSyncStatus.js'
29
+ import * as AppBskyContactImportContacts from './types/app/bsky/contact/importContacts.js'
30
+ import * as AppBskyContactRemoveData from './types/app/bsky/contact/removeData.js'
31
+ import * as AppBskyContactStartPhoneVerification from './types/app/bsky/contact/startPhoneVerification.js'
32
+ import * as AppBskyContactVerifyPhone from './types/app/bsky/contact/verifyPhone.js'
26
33
  import * as AppBskyFeedDescribeFeedGenerator from './types/app/bsky/feed/describeFeedGenerator.js'
27
34
  import * as AppBskyFeedGetActorFeeds from './types/app/bsky/feed/getActorFeeds.js'
28
35
  import * as AppBskyFeedGetActorLikes from './types/app/bsky/feed/getActorLikes.js'
@@ -397,6 +404,7 @@ export class AppBskyNS {
397
404
  actor: AppBskyActorNS
398
405
  ageassurance: AppBskyAgeassuranceNS
399
406
  bookmark: AppBskyBookmarkNS
407
+ contact: AppBskyContactNS
400
408
  embed: AppBskyEmbedNS
401
409
  feed: AppBskyFeedNS
402
410
  graph: AppBskyGraphNS
@@ -411,6 +419,7 @@ export class AppBskyNS {
411
419
  this.actor = new AppBskyActorNS(server)
412
420
  this.ageassurance = new AppBskyAgeassuranceNS(server)
413
421
  this.bookmark = new AppBskyBookmarkNS(server)
422
+ this.contact = new AppBskyContactNS(server)
414
423
  this.embed = new AppBskyEmbedNS(server)
415
424
  this.feed = new AppBskyFeedNS(server)
416
425
  this.graph = new AppBskyGraphNS(server)
@@ -602,6 +611,98 @@ export class AppBskyBookmarkNS {
602
611
  }
603
612
  }
604
613
 
614
+ export class AppBskyContactNS {
615
+ _server: Server
616
+
617
+ constructor(server: Server) {
618
+ this._server = server
619
+ }
620
+
621
+ dismissMatch<A extends Auth = void>(
622
+ cfg: MethodConfigOrHandler<
623
+ A,
624
+ AppBskyContactDismissMatch.QueryParams,
625
+ AppBskyContactDismissMatch.HandlerInput,
626
+ AppBskyContactDismissMatch.HandlerOutput
627
+ >,
628
+ ) {
629
+ const nsid = 'app.bsky.contact.dismissMatch' // @ts-ignore
630
+ return this._server.xrpc.method(nsid, cfg)
631
+ }
632
+
633
+ getMatches<A extends Auth = void>(
634
+ cfg: MethodConfigOrHandler<
635
+ A,
636
+ AppBskyContactGetMatches.QueryParams,
637
+ AppBskyContactGetMatches.HandlerInput,
638
+ AppBskyContactGetMatches.HandlerOutput
639
+ >,
640
+ ) {
641
+ const nsid = 'app.bsky.contact.getMatches' // @ts-ignore
642
+ return this._server.xrpc.method(nsid, cfg)
643
+ }
644
+
645
+ getSyncStatus<A extends Auth = void>(
646
+ cfg: MethodConfigOrHandler<
647
+ A,
648
+ AppBskyContactGetSyncStatus.QueryParams,
649
+ AppBskyContactGetSyncStatus.HandlerInput,
650
+ AppBskyContactGetSyncStatus.HandlerOutput
651
+ >,
652
+ ) {
653
+ const nsid = 'app.bsky.contact.getSyncStatus' // @ts-ignore
654
+ return this._server.xrpc.method(nsid, cfg)
655
+ }
656
+
657
+ importContacts<A extends Auth = void>(
658
+ cfg: MethodConfigOrHandler<
659
+ A,
660
+ AppBskyContactImportContacts.QueryParams,
661
+ AppBskyContactImportContacts.HandlerInput,
662
+ AppBskyContactImportContacts.HandlerOutput
663
+ >,
664
+ ) {
665
+ const nsid = 'app.bsky.contact.importContacts' // @ts-ignore
666
+ return this._server.xrpc.method(nsid, cfg)
667
+ }
668
+
669
+ removeData<A extends Auth = void>(
670
+ cfg: MethodConfigOrHandler<
671
+ A,
672
+ AppBskyContactRemoveData.QueryParams,
673
+ AppBskyContactRemoveData.HandlerInput,
674
+ AppBskyContactRemoveData.HandlerOutput
675
+ >,
676
+ ) {
677
+ const nsid = 'app.bsky.contact.removeData' // @ts-ignore
678
+ return this._server.xrpc.method(nsid, cfg)
679
+ }
680
+
681
+ startPhoneVerification<A extends Auth = void>(
682
+ cfg: MethodConfigOrHandler<
683
+ A,
684
+ AppBskyContactStartPhoneVerification.QueryParams,
685
+ AppBskyContactStartPhoneVerification.HandlerInput,
686
+ AppBskyContactStartPhoneVerification.HandlerOutput
687
+ >,
688
+ ) {
689
+ const nsid = 'app.bsky.contact.startPhoneVerification' // @ts-ignore
690
+ return this._server.xrpc.method(nsid, cfg)
691
+ }
692
+
693
+ verifyPhone<A extends Auth = void>(
694
+ cfg: MethodConfigOrHandler<
695
+ A,
696
+ AppBskyContactVerifyPhone.QueryParams,
697
+ AppBskyContactVerifyPhone.HandlerInput,
698
+ AppBskyContactVerifyPhone.HandlerOutput
699
+ >,
700
+ ) {
701
+ const nsid = 'app.bsky.contact.verifyPhone' // @ts-ignore
702
+ return this._server.xrpc.method(nsid, cfg)
703
+ }
704
+ }
705
+
605
706
  export class AppBskyEmbedNS {
606
707
  _server: Server
607
708