@atproto/pds 0.3.16 → 0.3.17

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atproto/pds
2
2
 
3
+ ## 0.3.17
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`e4ec7af03`](https://github.com/bluesky-social/atproto/commit/e4ec7af03608949fc3b00a845f547a77599b5ad0)]:
8
+ - @atproto/api@0.9.6
9
+
3
10
  ## 0.3.16
4
11
 
5
12
  ### Patch Changes
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  Dual MIT/Apache-2.0 License
2
2
 
3
- Copyright (c) 2022-2023 Bluesky PBC, and Contributors
3
+ Copyright (c) 2022-2024 Bluesky PBC, and Contributors
4
4
 
5
5
  Except as otherwise noted in individual files, this software is licensed under the MIT license (<http://opensource.org/licenses/MIT>), or the Apache License, Version 2.0 (<http://www.apache.org/licenses/LICENSE-2.0>).
6
6
 
@@ -1,5 +1,6 @@
1
1
  import { AccountDb, EmailTokenPurpose } from '../db';
2
2
  export declare const createEmailToken: (db: AccountDb, did: string, purpose: EmailTokenPurpose) => Promise<string>;
3
3
  export declare const deleteEmailToken: (db: AccountDb, did: string, purpose: EmailTokenPurpose) => Promise<void>;
4
+ export declare const deleteAllEmailTokens: (db: AccountDb, did: string) => Promise<void>;
4
5
  export declare const assertValidToken: (db: AccountDb, did: string, purpose: EmailTokenPurpose, token: string, expirationLen?: number) => Promise<void>;
5
6
  export declare const assertValidTokenAndFindDid: (db: AccountDb, purpose: EmailTokenPurpose, token: string, expirationLen?: number) => Promise<string>;
@@ -73,7 +73,6 @@ export declare class AccountManager {
73
73
  updateEmail(opts: {
74
74
  did: string;
75
75
  email: string;
76
- token?: string;
77
76
  }): Promise<void>;
78
77
  resetPassword(opts: {
79
78
  password: string;
package/dist/index.js CHANGED
@@ -212622,7 +212622,8 @@ var schemaDict = {
212622
212622
  "lex:com.atproto.admin.defs#modEventAcknowledge",
212623
212623
  "lex:com.atproto.admin.defs#modEventEscalate",
212624
212624
  "lex:com.atproto.admin.defs#modEventMute",
212625
- "lex:com.atproto.admin.defs#modEventEmail"
212625
+ "lex:com.atproto.admin.defs#modEventEmail",
212626
+ "lex:com.atproto.admin.defs#modEventResolveAppeal"
212626
212627
  ]
212627
212628
  },
212628
212629
  subject: {
@@ -212679,6 +212680,7 @@ var schemaDict = {
212679
212680
  "lex:com.atproto.admin.defs#modEventAcknowledge",
212680
212681
  "lex:com.atproto.admin.defs#modEventEscalate",
212681
212682
  "lex:com.atproto.admin.defs#modEventMute",
212683
+ "lex:com.atproto.admin.defs#modEventEmail",
212682
212684
  "lex:com.atproto.admin.defs#modEventResolveAppeal"
212683
212685
  ]
212684
212686
  },
@@ -213968,6 +213970,16 @@ var schemaDict = {
213968
213970
  enum: ["asc", "desc"],
213969
213971
  description: "Sort direction for the events. Defaults to descending order of created at timestamp."
213970
213972
  },
213973
+ createdAfter: {
213974
+ type: "string",
213975
+ format: "datetime",
213976
+ description: "Retrieve events created after a given timestamp"
213977
+ },
213978
+ createdBefore: {
213979
+ type: "string",
213980
+ format: "datetime",
213981
+ description: "Retrieve events created before a given timestamp"
213982
+ },
213971
213983
  subject: {
213972
213984
  type: "string",
213973
213985
  format: "uri"
@@ -213983,6 +213995,34 @@ var schemaDict = {
213983
213995
  maximum: 100,
213984
213996
  default: 50
213985
213997
  },
213998
+ hasComment: {
213999
+ type: "boolean",
214000
+ description: "If true, only events with comments are returned"
214001
+ },
214002
+ comment: {
214003
+ type: "string",
214004
+ description: "If specified, only events with comments containing the keyword are returned"
214005
+ },
214006
+ addedLabels: {
214007
+ type: "array",
214008
+ items: {
214009
+ type: "string"
214010
+ },
214011
+ description: "If specified, only events where all of these labels were added are returned"
214012
+ },
214013
+ removedLabels: {
214014
+ type: "array",
214015
+ items: {
214016
+ type: "string"
214017
+ },
214018
+ description: "If specified, only events where all of these labels were removed are returned"
214019
+ },
214020
+ reportTypes: {
214021
+ type: "array",
214022
+ items: {
214023
+ type: "string"
214024
+ }
214025
+ },
213986
214026
  cursor: {
213987
214027
  type: "string"
213988
214028
  }
@@ -220547,54 +220587,6 @@ var schemaDict = {
220547
220587
  }
220548
220588
  }
220549
220589
  },
220550
- AppBskyUnspeccedGetTimelineSkeleton: {
220551
- lexicon: 1,
220552
- id: "app.bsky.unspecced.getTimelineSkeleton",
220553
- defs: {
220554
- main: {
220555
- type: "query",
220556
- description: "DEPRECATED: a skeleton of a timeline. Unspecced and will be unavailable soon.",
220557
- parameters: {
220558
- type: "params",
220559
- properties: {
220560
- limit: {
220561
- type: "integer",
220562
- minimum: 1,
220563
- maximum: 100,
220564
- default: 50
220565
- },
220566
- cursor: {
220567
- type: "string"
220568
- }
220569
- }
220570
- },
220571
- output: {
220572
- encoding: "application/json",
220573
- schema: {
220574
- type: "object",
220575
- required: ["feed"],
220576
- properties: {
220577
- cursor: {
220578
- type: "string"
220579
- },
220580
- feed: {
220581
- type: "array",
220582
- items: {
220583
- type: "ref",
220584
- ref: "lex:app.bsky.feed.defs#skeletonFeedPost"
220585
- }
220586
- }
220587
- }
220588
- }
220589
- },
220590
- errors: [
220591
- {
220592
- name: "UnknownFeed"
220593
- }
220594
- ]
220595
- }
220596
- }
220597
- },
220598
220590
  AppBskyUnspeccedSearchActorsSkeleton: {
220599
220591
  lexicon: 1,
220600
220592
  id: "app.bsky.unspecced.searchActorsSkeleton",
@@ -220862,7 +220854,6 @@ var ids = {
220862
220854
  AppBskyUnspeccedDefs: "app.bsky.unspecced.defs",
220863
220855
  AppBskyUnspeccedGetPopularFeedGenerators: "app.bsky.unspecced.getPopularFeedGenerators",
220864
220856
  AppBskyUnspeccedGetTaggedSuggestions: "app.bsky.unspecced.getTaggedSuggestions",
220865
- AppBskyUnspeccedGetTimelineSkeleton: "app.bsky.unspecced.getTimelineSkeleton",
220866
220857
  AppBskyUnspeccedSearchActorsSkeleton: "app.bsky.unspecced.searchActorsSkeleton",
220867
220858
  AppBskyUnspeccedSearchPostsSkeleton: "app.bsky.unspecced.searchPostsSkeleton"
220868
220859
  };
@@ -231715,7 +231706,7 @@ function sendEmail_default(server, ctx) {
231715
231706
  throw new InvalidRequestError("account does not have an email address");
231716
231707
  }
231717
231708
  await ctx.moderationMailer.send({ content }, { subject, to: account.email });
231718
- await ctx.appViewAgent.api.com.atproto.admin.emitModerationEvent({
231709
+ await ctx.moderationAgent.api.com.atproto.admin.emitModerationEvent({
231719
231710
  event: {
231720
231711
  $type: "com.atproto.admin.defs#modEventEmail",
231721
231712
  subjectLine: subject,
@@ -235715,6 +235706,18 @@ function reserveSigningKey_default(server, ctx) {
235715
235706
  // src/api/com/atproto/server/requestAccountDelete.ts
235716
235707
  function requestAccountDelete_default(server, ctx) {
235717
235708
  server.com.atproto.server.requestAccountDelete({
235709
+ rateLimit: [
235710
+ {
235711
+ durationMs: DAY,
235712
+ points: 15,
235713
+ calcKey: ({ auth }) => auth.credentials.did
235714
+ },
235715
+ {
235716
+ durationMs: HOUR,
235717
+ points: 5,
235718
+ calcKey: ({ auth }) => auth.credentials.did
235719
+ }
235720
+ ],
235718
235721
  auth: ctx.authVerifier.accessCheckTakedown,
235719
235722
  handler: async ({ auth, req }) => {
235720
235723
  const did2 = auth.credentials.did;
@@ -235767,18 +235770,30 @@ function deleteAccount_default2(server, ctx) {
235767
235770
 
235768
235771
  // src/api/com/atproto/server/requestPasswordReset.ts
235769
235772
  function requestPasswordReset_default(server, ctx) {
235770
- server.com.atproto.server.requestPasswordReset(async ({ input, req }) => {
235771
- const email = input.body.email.toLowerCase();
235772
- const account = await ctx.accountManager.getAccountByEmail(email);
235773
- if (!account?.email) {
235774
- if (ctx.entrywayAgent) {
235775
- await ctx.entrywayAgent.com.atproto.server.requestPasswordReset(input.body, authPassthru(req, true));
235776
- return;
235773
+ server.com.atproto.server.requestPasswordReset({
235774
+ rateLimit: [
235775
+ {
235776
+ durationMs: DAY,
235777
+ points: 50
235778
+ },
235779
+ {
235780
+ durationMs: HOUR,
235781
+ points: 15
235782
+ }
235783
+ ],
235784
+ handler: async ({ input, req }) => {
235785
+ const email = input.body.email.toLowerCase();
235786
+ const account = await ctx.accountManager.getAccountByEmail(email);
235787
+ if (!account?.email) {
235788
+ if (ctx.entrywayAgent) {
235789
+ await ctx.entrywayAgent.com.atproto.server.requestPasswordReset(input.body, authPassthru(req, true));
235790
+ return;
235791
+ }
235792
+ throw new InvalidRequestError("account does not have an email address");
235777
235793
  }
235778
- throw new InvalidRequestError("account does not have an email address");
235794
+ const token = await ctx.accountManager.createEmailToken(account.did, "reset_password");
235795
+ await ctx.mailer.sendResetPassword({ identifier: account.handle ?? account.email, token }, { to: account.email });
235779
235796
  }
235780
- const token = await ctx.accountManager.createEmailToken(account.did, "reset_password");
235781
- await ctx.mailer.sendResetPassword({ identifier: account.handle ?? account.email, token }, { to: account.email });
235782
235797
  });
235783
235798
  }
235784
235799
 
@@ -235805,6 +235820,18 @@ function resetPassword_default(server, ctx) {
235805
235820
  // src/api/com/atproto/server/requestEmailConfirmation.ts
235806
235821
  function requestEmailConfirmation_default(server, ctx) {
235807
235822
  server.com.atproto.server.requestEmailConfirmation({
235823
+ rateLimit: [
235824
+ {
235825
+ durationMs: DAY,
235826
+ points: 15,
235827
+ calcKey: ({ auth }) => auth.credentials.did
235828
+ },
235829
+ {
235830
+ durationMs: HOUR,
235831
+ points: 5,
235832
+ calcKey: ({ auth }) => auth.credentials.did
235833
+ }
235834
+ ],
235808
235835
  auth: ctx.authVerifier.accessCheckTakedown,
235809
235836
  handler: async ({ auth, req }) => {
235810
235837
  const did2 = auth.credentials.did;
@@ -235851,6 +235878,18 @@ function confirmEmail_default(server, ctx) {
235851
235878
  // src/api/com/atproto/server/requestEmailUpdate.ts
235852
235879
  function requestEmailUpdate_default(server, ctx) {
235853
235880
  server.com.atproto.server.requestEmailUpdate({
235881
+ rateLimit: [
235882
+ {
235883
+ durationMs: DAY,
235884
+ points: 15,
235885
+ calcKey: ({ auth }) => auth.credentials.did
235886
+ },
235887
+ {
235888
+ durationMs: HOUR,
235889
+ points: 5,
235890
+ calcKey: ({ auth }) => auth.credentials.did
235891
+ }
235892
+ ],
235854
235893
  auth: ctx.authVerifier.accessCheckTakedown,
235855
235894
  handler: async ({ auth, req }) => {
235856
235895
  const did2 = auth.credentials.did;
@@ -235995,7 +236034,7 @@ function updateEmail_default(server, ctx) {
235995
236034
  await ctx.accountManager.assertValidEmailToken(did2, "update_email", token);
235996
236035
  }
235997
236036
  try {
235998
- await ctx.accountManager.updateEmail({ did: did2, email, token });
236037
+ await ctx.accountManager.updateEmail({ did: did2, email });
235999
236038
  } catch (err) {
236000
236039
  if (err instanceof UserAlreadyExistsError) {
236001
236040
  throw new InvalidRequestError("This email address is already in use, please use a different email.");
@@ -236769,6 +236808,24 @@ function sync_default(server, ctx) {
236769
236808
  getHead_default(server, ctx);
236770
236809
  }
236771
236810
 
236811
+ // src/api/com/atproto/temp/checkSignupQueue.ts
236812
+ function checkSignupQueue_default(server, ctx) {
236813
+ server.com.atproto.temp.checkSignupQueue({
236814
+ auth: ctx.authVerifier.accessDeactived,
236815
+ handler: async ({ req }) => {
236816
+ if (!ctx.entrywayAgent) {
236817
+ return {
236818
+ encoding: "application/json",
236819
+ body: {
236820
+ activated: true
236821
+ }
236822
+ };
236823
+ }
236824
+ return resultPassthru(await ctx.entrywayAgent.com.atproto.temp.checkSignupQueue(void 0, authPassthru(req)));
236825
+ }
236826
+ });
236827
+ }
236828
+
236772
236829
  // src/api/com/atproto/temp/importRepo.ts
236773
236830
  var import_stream8 = require("stream");
236774
236831
  var import_assert4 = __toESM(require("assert"));
@@ -237032,6 +237089,7 @@ var verifyDidAndPlcOp = async (ctx, did2, handle2, signingKey, plcOp) => {
237032
237089
 
237033
237090
  // src/api/com/atproto/temp/index.ts
237034
237091
  function temp_default(server, ctx) {
237092
+ checkSignupQueue_default(server, ctx);
237035
237093
  importRepo_default(server, ctx);
237036
237094
  pushBlob_default(server, ctx);
237037
237095
  transferAccount_default(server, ctx);
@@ -237790,7 +237848,8 @@ var schemaDict2 = {
237790
237848
  "lex:com.atproto.admin.defs#modEventAcknowledge",
237791
237849
  "lex:com.atproto.admin.defs#modEventEscalate",
237792
237850
  "lex:com.atproto.admin.defs#modEventMute",
237793
- "lex:com.atproto.admin.defs#modEventEmail"
237851
+ "lex:com.atproto.admin.defs#modEventEmail",
237852
+ "lex:com.atproto.admin.defs#modEventResolveAppeal"
237794
237853
  ]
237795
237854
  },
237796
237855
  subject: {
@@ -237847,6 +237906,7 @@ var schemaDict2 = {
237847
237906
  "lex:com.atproto.admin.defs#modEventAcknowledge",
237848
237907
  "lex:com.atproto.admin.defs#modEventEscalate",
237849
237908
  "lex:com.atproto.admin.defs#modEventMute",
237909
+ "lex:com.atproto.admin.defs#modEventEmail",
237850
237910
  "lex:com.atproto.admin.defs#modEventResolveAppeal"
237851
237911
  ]
237852
237912
  },
@@ -239136,6 +239196,16 @@ var schemaDict2 = {
239136
239196
  enum: ["asc", "desc"],
239137
239197
  description: "Sort direction for the events. Defaults to descending order of created at timestamp."
239138
239198
  },
239199
+ createdAfter: {
239200
+ type: "string",
239201
+ format: "datetime",
239202
+ description: "Retrieve events created after a given timestamp"
239203
+ },
239204
+ createdBefore: {
239205
+ type: "string",
239206
+ format: "datetime",
239207
+ description: "Retrieve events created before a given timestamp"
239208
+ },
239139
239209
  subject: {
239140
239210
  type: "string",
239141
239211
  format: "uri"
@@ -239151,6 +239221,34 @@ var schemaDict2 = {
239151
239221
  maximum: 100,
239152
239222
  default: 50
239153
239223
  },
239224
+ hasComment: {
239225
+ type: "boolean",
239226
+ description: "If true, only events with comments are returned"
239227
+ },
239228
+ comment: {
239229
+ type: "string",
239230
+ description: "If specified, only events with comments containing the keyword are returned"
239231
+ },
239232
+ addedLabels: {
239233
+ type: "array",
239234
+ items: {
239235
+ type: "string"
239236
+ },
239237
+ description: "If specified, only events where all of these labels were added are returned"
239238
+ },
239239
+ removedLabels: {
239240
+ type: "array",
239241
+ items: {
239242
+ type: "string"
239243
+ },
239244
+ description: "If specified, only events where all of these labels were removed are returned"
239245
+ },
239246
+ reportTypes: {
239247
+ type: "array",
239248
+ items: {
239249
+ type: "string"
239250
+ }
239251
+ },
239154
239252
  cursor: {
239155
239253
  type: "string"
239156
239254
  }
@@ -245715,54 +245813,6 @@ var schemaDict2 = {
245715
245813
  }
245716
245814
  }
245717
245815
  },
245718
- AppBskyUnspeccedGetTimelineSkeleton: {
245719
- lexicon: 1,
245720
- id: "app.bsky.unspecced.getTimelineSkeleton",
245721
- defs: {
245722
- main: {
245723
- type: "query",
245724
- description: "DEPRECATED: a skeleton of a timeline. Unspecced and will be unavailable soon.",
245725
- parameters: {
245726
- type: "params",
245727
- properties: {
245728
- limit: {
245729
- type: "integer",
245730
- minimum: 1,
245731
- maximum: 100,
245732
- default: 50
245733
- },
245734
- cursor: {
245735
- type: "string"
245736
- }
245737
- }
245738
- },
245739
- output: {
245740
- encoding: "application/json",
245741
- schema: {
245742
- type: "object",
245743
- required: ["feed"],
245744
- properties: {
245745
- cursor: {
245746
- type: "string"
245747
- },
245748
- feed: {
245749
- type: "array",
245750
- items: {
245751
- type: "ref",
245752
- ref: "lex:app.bsky.feed.defs#skeletonFeedPost"
245753
- }
245754
- }
245755
- }
245756
- }
245757
- },
245758
- errors: [
245759
- {
245760
- name: "UnknownFeed"
245761
- }
245762
- ]
245763
- }
245764
- }
245765
- },
245766
245816
  AppBskyUnspeccedSearchActorsSkeleton: {
245767
245817
  lexicon: 1,
245768
245818
  id: "app.bsky.unspecced.searchActorsSkeleton",
@@ -247047,27 +247097,13 @@ function toKnownErr116(e) {
247047
247097
  return e;
247048
247098
  }
247049
247099
 
247050
- // ../api/src/client/types/app/bsky/unspecced/getTimelineSkeleton.ts
247051
- var UnknownFeedError3 = class extends XRPCError {
247052
- constructor(src3) {
247053
- super(src3.status, src3.error, src3.message, src3.headers);
247054
- }
247055
- };
247056
- function toKnownErr117(e) {
247057
- if (e instanceof XRPCError) {
247058
- if (e.error === "UnknownFeed")
247059
- return new UnknownFeedError3(e);
247060
- }
247061
- return e;
247062
- }
247063
-
247064
247100
  // ../api/src/client/types/app/bsky/unspecced/searchActorsSkeleton.ts
247065
247101
  var BadQueryStringError2 = class extends XRPCError {
247066
247102
  constructor(src3) {
247067
247103
  super(src3.status, src3.error, src3.message, src3.headers);
247068
247104
  }
247069
247105
  };
247070
- function toKnownErr118(e) {
247106
+ function toKnownErr117(e) {
247071
247107
  if (e instanceof XRPCError) {
247072
247108
  if (e.error === "BadQueryString")
247073
247109
  return new BadQueryStringError2(e);
@@ -247081,7 +247117,7 @@ var BadQueryStringError3 = class extends XRPCError {
247081
247117
  super(src3.status, src3.error, src3.message, src3.headers);
247082
247118
  }
247083
247119
  };
247084
- function toKnownErr119(e) {
247120
+ function toKnownErr118(e) {
247085
247121
  if (e instanceof XRPCError) {
247086
247122
  if (e.error === "BadQueryString")
247087
247123
  return new BadQueryStringError3(e);
@@ -248109,19 +248145,14 @@ var AppBskyUnspeccedNS = class {
248109
248145
  throw toKnownErr116(e);
248110
248146
  });
248111
248147
  }
248112
- getTimelineSkeleton(params2, opts) {
248113
- return this._service.xrpc.call("app.bsky.unspecced.getTimelineSkeleton", params2, void 0, opts).catch((e) => {
248114
- throw toKnownErr117(e);
248115
- });
248116
- }
248117
248148
  searchActorsSkeleton(params2, opts) {
248118
248149
  return this._service.xrpc.call("app.bsky.unspecced.searchActorsSkeleton", params2, void 0, opts).catch((e) => {
248119
- throw toKnownErr118(e);
248150
+ throw toKnownErr117(e);
248120
248151
  });
248121
248152
  }
248122
248153
  searchPostsSkeleton(params2, opts) {
248123
248154
  return this._service.xrpc.call("app.bsky.unspecced.searchPostsSkeleton", params2, void 0, opts).catch((e) => {
248124
- throw toKnownErr119(e);
248155
+ throw toKnownErr118(e);
248125
248156
  });
248126
248157
  }
248127
248158
  };
@@ -250500,10 +250531,6 @@ var AppBskyUnspeccedNS2 = class {
250500
250531
  const nsid2 = "app.bsky.unspecced.getTaggedSuggestions";
250501
250532
  return this._server.xrpc.method(nsid2, cfg);
250502
250533
  }
250503
- getTimelineSkeleton(cfg) {
250504
- const nsid2 = "app.bsky.unspecced.getTimelineSkeleton";
250505
- return this._server.xrpc.method(nsid2, cfg);
250506
- }
250507
250534
  searchActorsSkeleton(cfg) {
250508
250535
  const nsid2 = "app.bsky.unspecced.searchActorsSkeleton";
250509
250536
  return this._server.xrpc.method(nsid2, cfg);
@@ -251088,6 +251115,9 @@ var createEmailToken = async (db, did2, purpose) => {
251088
251115
  var deleteEmailToken = async (db, did2, purpose) => {
251089
251116
  await db.executeWithRetry(db.db.deleteFrom("email_token").where("did", "=", did2).where("purpose", "=", purpose));
251090
251117
  };
251118
+ var deleteAllEmailTokens = async (db, did2) => {
251119
+ await db.executeWithRetry(db.db.deleteFrom("email_token").where("did", "=", did2));
251120
+ };
251091
251121
  var assertValidToken = async (db, did2, purpose, token, expirationLen = 15 * MINUTE) => {
251092
251122
  const res = await db.db.selectFrom("email_token").selectAll().where("purpose", "=", purpose).where("did", "=", did2).where("token", "=", token.toUpperCase()).executeTakeFirst();
251093
251123
  if (!res) {
@@ -251296,15 +251326,11 @@ var AccountManager = class {
251296
251326
  ]));
251297
251327
  }
251298
251328
  async updateEmail(opts) {
251299
- const { did: did2, email, token } = opts;
251300
- if (token) {
251301
- await this.db.transaction((dbTxn) => Promise.all([
251302
- updateEmail(dbTxn, did2, email),
251303
- deleteEmailToken(dbTxn, did2, "update_email")
251304
- ]));
251305
- } else {
251306
- return updateEmail(this.db, did2, email);
251307
- }
251329
+ const { did: did2, email } = opts;
251330
+ await this.db.transaction((dbTxn) => Promise.all([
251331
+ updateEmail(dbTxn, did2, email),
251332
+ deleteAllEmailTokens(dbTxn, did2)
251333
+ ]));
251308
251334
  }
251309
251335
  async resetPassword(opts) {
251310
251336
  const did2 = await assertValidTokenAndFindDid(this.db, "reset_password", opts.token);