@atproto/bsky 0.0.10 → 0.0.12

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 (173) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/api/com/atproto/admin/util.d.ts +5 -0
  3. package/dist/config.d.ts +2 -0
  4. package/dist/context.d.ts +8 -0
  5. package/dist/db/index.js +51 -2
  6. package/dist/db/index.js.map +3 -3
  7. package/dist/db/migrations/20230929T192920807Z-record-cursor-indexes.d.ts +3 -0
  8. package/dist/db/migrations/index.d.ts +1 -0
  9. package/dist/did-cache.d.ts +2 -2
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.js +1818 -580
  12. package/dist/index.js.map +3 -3
  13. package/dist/lexicon/index.d.ts +16 -0
  14. package/dist/lexicon/lexicons.d.ts +330 -3
  15. package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -0
  16. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +28 -0
  17. package/dist/lexicon/types/com/atproto/admin/getAccountInfo.d.ts +29 -0
  18. package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +39 -0
  19. package/dist/lexicon/types/com/atproto/admin/searchRepos.d.ts +0 -1
  20. package/dist/lexicon/types/com/atproto/admin/updateSubjectStatus.d.ts +46 -0
  21. package/dist/lexicon/types/com/atproto/server/confirmEmail.d.ts +27 -0
  22. package/dist/lexicon/types/com/atproto/server/createAccount.d.ts +2 -0
  23. package/dist/lexicon/types/com/atproto/server/createSession.d.ts +2 -0
  24. package/dist/lexicon/types/com/atproto/server/getSession.d.ts +1 -0
  25. package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +1 -0
  26. package/dist/lexicon/types/com/atproto/server/requestEmailConfirmation.d.ts +19 -0
  27. package/dist/lexicon/types/com/atproto/server/requestEmailUpdate.d.ts +30 -0
  28. package/dist/lexicon/types/com/atproto/server/reserveSigningKey.d.ts +30 -0
  29. package/dist/lexicon/types/com/atproto/server/updateEmail.d.ts +27 -0
  30. package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +1 -0
  31. package/dist/services/actor/index.d.ts +2 -2
  32. package/dist/services/actor/types.d.ts +1 -0
  33. package/dist/services/graph/index.d.ts +2 -0
  34. package/dist/services/moderation/index.d.ts +13 -3
  35. package/dist/services/util/search.d.ts +3 -3
  36. package/package.json +13 -14
  37. package/src/api/app/bsky/actor/searchActors.ts +36 -22
  38. package/src/api/app/bsky/actor/searchActorsTypeahead.ts +24 -17
  39. package/src/api/app/bsky/feed/getAuthorFeed.ts +2 -2
  40. package/src/api/app/bsky/feed/getPostThread.ts +2 -2
  41. package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +1 -0
  42. package/src/api/app/bsky/notification/listNotifications.ts +33 -22
  43. package/src/api/com/atproto/admin/getModerationAction.ts +28 -2
  44. package/src/api/com/atproto/admin/getModerationReport.ts +27 -2
  45. package/src/api/com/atproto/admin/getRecord.ts +14 -2
  46. package/src/api/com/atproto/admin/getRepo.ts +13 -2
  47. package/src/api/com/atproto/admin/reverseModerationAction.ts +31 -5
  48. package/src/api/com/atproto/admin/searchRepos.ts +6 -12
  49. package/src/api/com/atproto/admin/takeModerationAction.ts +41 -7
  50. package/src/api/com/atproto/admin/util.ts +50 -0
  51. package/src/api/well-known.ts +8 -0
  52. package/src/auth.ts +12 -5
  53. package/src/auto-moderator/index.ts +1 -0
  54. package/src/config.ts +7 -0
  55. package/src/context.ts +30 -0
  56. package/src/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +40 -0
  57. package/src/db/migrations/index.ts +1 -0
  58. package/src/did-cache.ts +29 -14
  59. package/src/feed-gen/with-friends.ts +2 -2
  60. package/src/index.ts +9 -1
  61. package/src/indexer/subscription.ts +1 -21
  62. package/src/lexicon/index.ts +96 -0
  63. package/src/lexicon/lexicons.ts +368 -4
  64. package/src/lexicon/types/app/bsky/actor/defs.ts +1 -0
  65. package/src/lexicon/types/com/atproto/admin/defs.ts +61 -0
  66. package/src/lexicon/types/com/atproto/admin/getAccountInfo.ts +41 -0
  67. package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +54 -0
  68. package/src/lexicon/types/com/atproto/admin/searchRepos.ts +0 -1
  69. package/src/lexicon/types/com/atproto/admin/updateSubjectStatus.ts +61 -0
  70. package/src/lexicon/types/com/atproto/server/confirmEmail.ts +40 -0
  71. package/src/lexicon/types/com/atproto/server/createAccount.ts +2 -0
  72. package/src/lexicon/types/com/atproto/server/createSession.ts +2 -0
  73. package/src/lexicon/types/com/atproto/server/getSession.ts +1 -0
  74. package/src/lexicon/types/com/atproto/server/refreshSession.ts +1 -0
  75. package/src/lexicon/types/com/atproto/server/requestEmailConfirmation.ts +31 -0
  76. package/src/lexicon/types/com/atproto/server/requestEmailUpdate.ts +43 -0
  77. package/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +44 -0
  78. package/src/lexicon/types/com/atproto/server/updateEmail.ts +41 -0
  79. package/src/lexicon/types/com/atproto/sync/listRepos.ts +1 -0
  80. package/src/logger.ts +8 -0
  81. package/src/services/actor/index.ts +16 -10
  82. package/src/services/actor/types.ts +1 -0
  83. package/src/services/actor/views.ts +26 -8
  84. package/src/services/graph/index.ts +26 -7
  85. package/src/services/indexing/index.ts +15 -17
  86. package/src/services/moderation/index.ts +94 -14
  87. package/src/services/moderation/views.ts +1 -0
  88. package/src/services/util/search.ts +24 -23
  89. package/tests/__snapshots__/feed-generation.test.ts.snap +12 -12
  90. package/tests/__snapshots__/indexing.test.ts.snap +4 -4
  91. package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +172 -0
  92. package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +178 -0
  93. package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +177 -0
  94. package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +307 -0
  95. package/tests/admin/__snapshots__/get-record.test.ts.snap +275 -0
  96. package/tests/admin/__snapshots__/get-repo.test.ts.snap +103 -0
  97. package/tests/admin/get-moderation-action.test.ts +100 -0
  98. package/tests/admin/get-moderation-actions.test.ts +164 -0
  99. package/tests/admin/get-moderation-report.test.ts +100 -0
  100. package/tests/admin/get-moderation-reports.test.ts +332 -0
  101. package/tests/admin/get-record.test.ts +115 -0
  102. package/tests/admin/get-repo.test.ts +101 -0
  103. package/tests/{moderation.test.ts → admin/moderation.test.ts} +107 -9
  104. package/tests/admin/repo-search.test.ts +124 -0
  105. package/tests/algos/hot-classic.test.ts +3 -5
  106. package/tests/algos/whats-hot.test.ts +3 -5
  107. package/tests/algos/with-friends.test.ts +2 -4
  108. package/tests/auth.test.ts +64 -0
  109. package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -3
  110. package/tests/auto-moderator/labeler.test.ts +5 -7
  111. package/tests/auto-moderator/takedowns.test.ts +11 -12
  112. package/tests/blob-resolver.test.ts +1 -3
  113. package/tests/did-cache.test.ts +2 -5
  114. package/tests/feed-generation.test.ts +8 -6
  115. package/tests/handle-invalidation.test.ts +2 -3
  116. package/tests/image/server.test.ts +1 -4
  117. package/tests/image/sharp.test.ts +1 -1
  118. package/tests/indexing.test.ts +4 -4
  119. package/tests/notification-server.test.ts +2 -3
  120. package/tests/pipeline/backpressure.test.ts +2 -3
  121. package/tests/pipeline/reingest.test.ts +7 -4
  122. package/tests/pipeline/repartition.test.ts +2 -3
  123. package/tests/reprocessing.test.ts +2 -6
  124. package/tests/seeds/basic.ts +4 -4
  125. package/tests/seeds/follows.ts +1 -1
  126. package/tests/seeds/likes.ts +1 -1
  127. package/tests/seeds/reposts.ts +1 -1
  128. package/tests/seeds/users-bulk.ts +1 -1
  129. package/tests/seeds/users.ts +1 -1
  130. package/tests/server.test.ts +1 -3
  131. package/tests/subscription/repo.test.ts +2 -4
  132. package/tests/views/__snapshots__/author-feed.test.ts.snap +24 -24
  133. package/tests/views/__snapshots__/block-lists.test.ts.snap +42 -7
  134. package/tests/views/__snapshots__/blocks.test.ts.snap +2 -2
  135. package/tests/views/__snapshots__/list-feed.test.ts.snap +6 -6
  136. package/tests/views/__snapshots__/mute-lists.test.ts.snap +15 -4
  137. package/tests/views/__snapshots__/mutes.test.ts.snap +2 -2
  138. package/tests/views/__snapshots__/notifications.test.ts.snap +2 -2
  139. package/tests/views/__snapshots__/posts.test.ts.snap +8 -8
  140. package/tests/views/__snapshots__/thread.test.ts.snap +10 -10
  141. package/tests/views/__snapshots__/timeline.test.ts.snap +58 -58
  142. package/tests/views/actor-likes.test.ts +2 -3
  143. package/tests/views/actor-search.test.ts +5 -5
  144. package/tests/views/admin/repo-search.test.ts +2 -4
  145. package/tests/views/author-feed.test.ts +2 -4
  146. package/tests/views/block-lists.test.ts +34 -7
  147. package/tests/views/blocks.test.ts +6 -3
  148. package/tests/views/follows.test.ts +2 -4
  149. package/tests/views/likes.test.ts +2 -5
  150. package/tests/views/list-feed.test.ts +2 -4
  151. package/tests/views/mute-lists.test.ts +23 -5
  152. package/tests/views/mutes.test.ts +2 -5
  153. package/tests/views/notifications.test.ts +2 -4
  154. package/tests/views/posts.test.ts +2 -5
  155. package/tests/views/profile.test.ts +4 -5
  156. package/tests/views/reposts.test.ts +2 -4
  157. package/tests/views/suggested-follows.test.ts +2 -3
  158. package/tests/views/suggestions.test.ts +2 -4
  159. package/tests/views/thread.test.ts +2 -4
  160. package/tests/views/threadgating.test.ts +2 -3
  161. package/tests/views/timeline.test.ts +2 -4
  162. package/dist/env.d.ts +0 -1
  163. package/example.dev.env +0 -5
  164. package/src/env.ts +0 -9
  165. package/tests/seeds/client.ts +0 -466
  166. /package/tests/{__snapshots__ → admin/__snapshots__}/moderation.test.ts.snap +0 -0
  167. /package/tests/{image/fixtures → sample-img}/at.png +0 -0
  168. /package/tests/{image/fixtures → sample-img}/hd-key.jpg +0 -0
  169. /package/tests/{image/fixtures → sample-img}/key-alt.jpg +0 -0
  170. /package/tests/{image/fixtures → sample-img}/key-landscape-large.jpg +0 -0
  171. /package/tests/{image/fixtures → sample-img}/key-landscape-small.jpg +0 -0
  172. /package/tests/{image/fixtures → sample-img}/key-portrait-large.jpg +0 -0
  173. /package/tests/{image/fixtures → sample-img}/key-portrait-small.jpg +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @atproto/bsky
2
2
 
3
+ ## 0.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`9c98a5ba`](https://github.com/bluesky-social/atproto/commit/9c98a5baaf503b02238a6afe4f6e2b79c5181693), [`bb039d8e`](https://github.com/bluesky-social/atproto/commit/bb039d8e4ce5b7f70c4f3e86d1327e210ef24dc3), [`35d108ce`](https://github.com/bluesky-social/atproto/commit/35d108ce94866ce1b3d147cd0620a0ba1c4ebcd7)]:
8
+ - @atproto/api@0.6.21
9
+ - @atproto/identity@0.3.0
10
+ - @atproto/repo@0.3.3
11
+ - @atproto/common@0.3.2
12
+ - @atproto/lexicon@0.2.3
13
+ - @atproto/syntax@0.1.3
14
+ - @atproto/xrpc-server@0.3.3
15
+
16
+ ## 0.0.11
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [[`41ee177f`](https://github.com/bluesky-social/atproto/commit/41ee177f5a440490280d17acd8a89bcddaffb23b)]:
21
+ - @atproto/api@0.6.20
22
+ - @atproto/common@0.3.1
23
+ - @atproto/identity@0.2.1
24
+ - @atproto/lexicon@0.2.2
25
+ - @atproto/repo@0.3.2
26
+ - @atproto/syntax@0.1.2
27
+ - @atproto/xrpc-server@0.3.2
28
+
3
29
  ## 0.0.10
4
30
 
5
31
  ### Patch Changes
@@ -0,0 +1,5 @@
1
+ import AppContext from '../../../../context';
2
+ import { RepoView, RepoViewDetail, AccountView } from '../../../../lexicon/types/com/atproto/admin/defs';
3
+ export declare const getPdsAccountInfo: (ctx: AppContext, did: string) => Promise<AccountView | null>;
4
+ export declare const addAccountInfoToRepoViewDetail: (repoView: RepoViewDetail, accountInfo: AccountView | null, includeEmail?: boolean) => RepoViewDetail;
5
+ export declare const addAccountInfoToRepoView: (repoView: RepoView, accountInfo: AccountView | null, includeEmail?: boolean) => RepoView;
package/dist/config.d.ts CHANGED
@@ -15,6 +15,7 @@ export interface ServerConfigValues {
15
15
  handleResolveNameservers?: string[];
16
16
  imgUriEndpoint?: string;
17
17
  blobCacheLocation?: string;
18
+ searchEndpoint?: string;
18
19
  labelerDid: string;
19
20
  adminPassword: string;
20
21
  moderatorPassword?: string;
@@ -44,6 +45,7 @@ export declare class ServerConfig {
44
45
  get didPlcUrl(): string;
45
46
  get imgUriEndpoint(): string | undefined;
46
47
  get blobCacheLocation(): string | undefined;
48
+ get searchEndpoint(): string | undefined;
47
49
  get labelerDid(): string;
48
50
  get adminPassword(): string;
49
51
  get moderatorPassword(): string | undefined;
package/dist/context.d.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  /// <reference types="express" />
3
3
  import * as plc from '@did-plc/lib';
4
4
  import { IdResolver } from '@atproto/identity';
5
+ import { AtpAgent } from '@atproto/api';
6
+ import { Keypair } from '@atproto/crypto';
5
7
  import { DatabaseCoordinator } from './db';
6
8
  import { ServerConfig } from './config';
7
9
  import { ImageUriBuilder } from './image/uri';
@@ -18,10 +20,12 @@ export declare class AppContext {
18
20
  imgUriBuilder: ImageUriBuilder;
19
21
  cfg: ServerConfig;
20
22
  services: Services;
23
+ signingKey: Keypair;
21
24
  idResolver: IdResolver;
22
25
  didCache: DidSqlCache;
23
26
  labelCache: LabelCache;
24
27
  backgroundQueue: BackgroundQueue;
28
+ searchAgent?: AtpAgent;
25
29
  algos: MountedAlgos;
26
30
  notifServer: NotificationServer;
27
31
  });
@@ -29,11 +33,13 @@ export declare class AppContext {
29
33
  get imgUriBuilder(): ImageUriBuilder;
30
34
  get cfg(): ServerConfig;
31
35
  get services(): Services;
36
+ get signingKey(): Keypair;
32
37
  get plcClient(): plc.Client;
33
38
  get idResolver(): IdResolver;
34
39
  get didCache(): DidSqlCache;
35
40
  get labelCache(): LabelCache;
36
41
  get notifServer(): NotificationServer;
42
+ get searchAgent(): AtpAgent | undefined;
37
43
  get authVerifier(): (reqCtx: {
38
44
  req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
39
45
  res: import("express").Response<any, Record<string, any>>;
@@ -107,6 +113,8 @@ export declare class AppContext {
107
113
  triage: boolean;
108
114
  };
109
115
  }>;
116
+ serviceAuthJwt(aud: string): Promise<string>;
117
+ pdsAdminAgent(did: string): Promise<AtpAgent>;
110
118
  get backgroundQueue(): BackgroundQueue;
111
119
  get algos(): MountedAlgos;
112
120
  }
package/dist/db/index.js CHANGED
@@ -29909,6 +29909,25 @@ var DAY = HOUR * 24;
29909
29909
  // ../common-web/src/strings.ts
29910
29910
  var import_graphemer = __toESM(require_lib());
29911
29911
 
29912
+ // ../common-web/src/did-doc.ts
29913
+ var verificationMethod = z.object({
29914
+ id: z.string(),
29915
+ type: z.string(),
29916
+ controller: z.string(),
29917
+ publicKeyMultibase: z.string().optional()
29918
+ });
29919
+ var service = z.object({
29920
+ id: z.string(),
29921
+ type: z.string(),
29922
+ serviceEndpoint: z.union([z.string(), z.record(z.unknown())])
29923
+ });
29924
+ var didDocument = z.object({
29925
+ id: z.string(),
29926
+ alsoKnownAs: z.array(z.string()).optional(),
29927
+ verificationMethod: z.array(verificationMethod).optional(),
29928
+ service: z.array(service).optional()
29929
+ });
29930
+
29912
29931
  // ../common/src/dates.ts
29913
29932
  var import_iso_datestring_validator = __toESM(require_dist());
29914
29933
 
@@ -33482,7 +33501,8 @@ __export(migrations_exports, {
33482
33501
  _20230830T205507322Z: () => T205507322Z_suggested_feeds_exports,
33483
33502
  _20230904T211011773Z: () => T211011773Z_block_lists_exports,
33484
33503
  _20230906T222220386Z: () => T222220386Z_thread_gating_exports,
33485
- _20230920T213858047Z: () => T213858047Z_add_tags_to_post_exports
33504
+ _20230920T213858047Z: () => T213858047Z_add_tags_to_post_exports,
33505
+ _20230929T192920807Z: () => T192920807Z_record_cursor_indexes_exports
33486
33506
  });
33487
33507
 
33488
33508
  // src/db/migrations/20230309T045948368Z-init.ts
@@ -33960,6 +33980,27 @@ async function down27(db) {
33960
33980
  await db.schema.alterTable("post").dropColumn("tags").execute();
33961
33981
  }
33962
33982
 
33983
+ // src/db/migrations/20230929T192920807Z-record-cursor-indexes.ts
33984
+ var T192920807Z_record_cursor_indexes_exports = {};
33985
+ __export(T192920807Z_record_cursor_indexes_exports, {
33986
+ down: () => down28,
33987
+ up: () => up28
33988
+ });
33989
+ async function up28(db) {
33990
+ await db.schema.createIndex("like_creator_cursor_idx").on("like").columns(["creator", "sortAt", "cid"]).execute();
33991
+ await db.schema.createIndex("follow_creator_cursor_idx").on("follow").columns(["creator", "sortAt", "cid"]).execute();
33992
+ await db.schema.createIndex("follow_subject_cursor_idx").on("follow").columns(["subjectDid", "sortAt", "cid"]).execute();
33993
+ await db.schema.dropIndex("like_creator_idx").execute();
33994
+ await db.schema.dropIndex("follow_subjectdid_idx").execute();
33995
+ }
33996
+ async function down28(db) {
33997
+ await db.schema.createIndex("like_creator_idx").on("like").column("creator").execute();
33998
+ await db.schema.createIndex("follow_subjectdid_idx").on("follow").column("subjectDid").execute();
33999
+ await db.schema.dropIndex("like_creator_cursor_idx").execute();
34000
+ await db.schema.dropIndex("follow_creator_cursor_idx").execute();
34001
+ await db.schema.dropIndex("follow_subject_cursor_idx").execute();
34002
+ }
34003
+
33963
34004
  // src/db/migrations/provider.ts
33964
34005
  var CtxMigrationProvider = class {
33965
34006
  constructor(migrations, ctx) {
@@ -33985,7 +34026,15 @@ var subLogger = subsystemLogger("bsky:sub");
33985
34026
  var labelerLogger = subsystemLogger("bsky:labeler");
33986
34027
  var httpLogger = subsystemLogger("bsky");
33987
34028
  var loggerMiddleware = (0, import_pino_http.default)({
33988
- logger: httpLogger
34029
+ logger: httpLogger,
34030
+ serializers: {
34031
+ err: (err) => {
34032
+ return {
34033
+ code: err?.code,
34034
+ message: err?.message
34035
+ };
34036
+ }
34037
+ }
33989
34038
  });
33990
34039
 
33991
34040
  // src/db/db.ts