@atproto/pds 0.4.28 → 0.4.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/account-manager/helpers/account.d.ts +7 -0
  3. package/dist/account-manager/helpers/account.d.ts.map +1 -1
  4. package/dist/account-manager/helpers/account.js +9 -1
  5. package/dist/account-manager/helpers/account.js.map +1 -1
  6. package/dist/account-manager/index.d.ts +3 -1
  7. package/dist/account-manager/index.d.ts.map +1 -1
  8. package/dist/account-manager/index.js +22 -6
  9. package/dist/account-manager/index.js.map +1 -1
  10. package/dist/api/com/atproto/admin/deleteAccount.d.ts.map +1 -1
  11. package/dist/api/com/atproto/admin/deleteAccount.js +4 -2
  12. package/dist/api/com/atproto/admin/deleteAccount.js.map +1 -1
  13. package/dist/api/com/atproto/admin/updateAccountHandle.js +1 -1
  14. package/dist/api/com/atproto/admin/updateAccountHandle.js.map +1 -1
  15. package/dist/api/com/atproto/admin/updateSubjectStatus.d.ts.map +1 -1
  16. package/dist/api/com/atproto/admin/updateSubjectStatus.js +2 -0
  17. package/dist/api/com/atproto/admin/updateSubjectStatus.js.map +1 -1
  18. package/dist/api/com/atproto/identity/submitPlcOperation.d.ts.map +1 -1
  19. package/dist/api/com/atproto/identity/submitPlcOperation.js.map +1 -1
  20. package/dist/api/com/atproto/identity/updateHandle.js +1 -1
  21. package/dist/api/com/atproto/identity/updateHandle.js.map +1 -1
  22. package/dist/api/com/atproto/repo/describeRepo.d.ts.map +1 -1
  23. package/dist/api/com/atproto/repo/describeRepo.js +2 -4
  24. package/dist/api/com/atproto/repo/describeRepo.js.map +1 -1
  25. package/dist/api/com/atproto/server/activateAccount.d.ts.map +1 -1
  26. package/dist/api/com/atproto/server/activateAccount.js +2 -1
  27. package/dist/api/com/atproto/server/activateAccount.js.map +1 -1
  28. package/dist/api/com/atproto/server/createAccount.d.ts.map +1 -1
  29. package/dist/api/com/atproto/server/createAccount.js +4 -2
  30. package/dist/api/com/atproto/server/createAccount.js.map +1 -1
  31. package/dist/api/com/atproto/server/deactivateAccount.d.ts.map +1 -1
  32. package/dist/api/com/atproto/server/deactivateAccount.js +2 -0
  33. package/dist/api/com/atproto/server/deactivateAccount.js.map +1 -1
  34. package/dist/api/com/atproto/server/deleteAccount.d.ts.map +1 -1
  35. package/dist/api/com/atproto/server/deleteAccount.js +4 -3
  36. package/dist/api/com/atproto/server/deleteAccount.js.map +1 -1
  37. package/dist/api/com/atproto/server/util.d.ts +1 -0
  38. package/dist/api/com/atproto/server/util.d.ts.map +1 -1
  39. package/dist/api/com/atproto/server/util.js +9 -6
  40. package/dist/api/com/atproto/server/util.js.map +1 -1
  41. package/dist/api/com/atproto/sync/deprecated/getCheckout.d.ts.map +1 -1
  42. package/dist/api/com/atproto/sync/deprecated/getCheckout.js +2 -8
  43. package/dist/api/com/atproto/sync/deprecated/getCheckout.js.map +1 -1
  44. package/dist/api/com/atproto/sync/deprecated/getHead.d.ts.map +1 -1
  45. package/dist/api/com/atproto/sync/deprecated/getHead.js +2 -7
  46. package/dist/api/com/atproto/sync/deprecated/getHead.js.map +1 -1
  47. package/dist/api/com/atproto/sync/getBlob.d.ts.map +1 -1
  48. package/dist/api/com/atproto/sync/getBlob.js +3 -6
  49. package/dist/api/com/atproto/sync/getBlob.js.map +1 -1
  50. package/dist/api/com/atproto/sync/getBlocks.d.ts.map +1 -1
  51. package/dist/api/com/atproto/sync/getBlocks.js +2 -7
  52. package/dist/api/com/atproto/sync/getBlocks.js.map +1 -1
  53. package/dist/api/com/atproto/sync/getLatestCommit.d.ts.map +1 -1
  54. package/dist/api/com/atproto/sync/getLatestCommit.js +2 -7
  55. package/dist/api/com/atproto/sync/getLatestCommit.js.map +1 -1
  56. package/dist/api/com/atproto/sync/getRecord.d.ts.map +1 -1
  57. package/dist/api/com/atproto/sync/getRecord.js +2 -7
  58. package/dist/api/com/atproto/sync/getRecord.js.map +1 -1
  59. package/dist/api/com/atproto/sync/getRepo.d.ts.map +1 -1
  60. package/dist/api/com/atproto/sync/getRepo.js +2 -7
  61. package/dist/api/com/atproto/sync/getRepo.js.map +1 -1
  62. package/dist/api/com/atproto/sync/getRepoStatus.d.ts +4 -0
  63. package/dist/api/com/atproto/sync/getRepoStatus.d.ts.map +1 -0
  64. package/dist/api/com/atproto/sync/getRepoStatus.js +28 -0
  65. package/dist/api/com/atproto/sync/getRepoStatus.js.map +1 -0
  66. package/dist/api/com/atproto/sync/index.d.ts.map +1 -1
  67. package/dist/api/com/atproto/sync/index.js +2 -0
  68. package/dist/api/com/atproto/sync/index.js.map +1 -1
  69. package/dist/api/com/atproto/sync/listBlobs.d.ts.map +1 -1
  70. package/dist/api/com/atproto/sync/listBlobs.js +2 -8
  71. package/dist/api/com/atproto/sync/listBlobs.js.map +1 -1
  72. package/dist/api/com/atproto/sync/listRepos.d.ts.map +1 -1
  73. package/dist/api/com/atproto/sync/listRepos.js +13 -8
  74. package/dist/api/com/atproto/sync/listRepos.js.map +1 -1
  75. package/dist/api/com/atproto/sync/subscribeRepos.d.ts.map +1 -1
  76. package/dist/api/com/atproto/sync/subscribeRepos.js +8 -0
  77. package/dist/api/com/atproto/sync/subscribeRepos.js.map +1 -1
  78. package/dist/api/com/atproto/sync/util.d.ts +11 -0
  79. package/dist/api/com/atproto/sync/util.d.ts.map +1 -0
  80. package/dist/api/com/atproto/sync/util.js +41 -0
  81. package/dist/api/com/atproto/sync/util.js.map +1 -0
  82. package/dist/index.d.ts +1 -0
  83. package/dist/index.d.ts.map +1 -1
  84. package/dist/index.js +3 -1
  85. package/dist/index.js.map +1 -1
  86. package/dist/lexicon/index.d.ts +2 -0
  87. package/dist/lexicon/index.d.ts.map +1 -1
  88. package/dist/lexicon/index.js +4 -0
  89. package/dist/lexicon/index.js.map +1 -1
  90. package/dist/lexicon/lexicons.d.ts +105 -0
  91. package/dist/lexicon/lexicons.d.ts.map +1 -1
  92. package/dist/lexicon/lexicons.js +185 -4
  93. package/dist/lexicon/lexicons.js.map +1 -1
  94. package/dist/lexicon/types/chat/bsky/convo/defs.d.ts +1 -1
  95. package/dist/lexicon/types/com/atproto/sync/getBlob.d.ts +1 -0
  96. package/dist/lexicon/types/com/atproto/sync/getBlob.d.ts.map +1 -1
  97. package/dist/lexicon/types/com/atproto/sync/getBlocks.d.ts +1 -0
  98. package/dist/lexicon/types/com/atproto/sync/getBlocks.d.ts.map +1 -1
  99. package/dist/lexicon/types/com/atproto/sync/getLatestCommit.d.ts +1 -1
  100. package/dist/lexicon/types/com/atproto/sync/getLatestCommit.d.ts.map +1 -1
  101. package/dist/lexicon/types/com/atproto/sync/getRecord.d.ts +1 -0
  102. package/dist/lexicon/types/com/atproto/sync/getRecord.d.ts.map +1 -1
  103. package/dist/lexicon/types/com/atproto/sync/getRepo.d.ts +1 -0
  104. package/dist/lexicon/types/com/atproto/sync/getRepo.d.ts.map +1 -1
  105. package/dist/lexicon/types/com/atproto/sync/getRepoStatus.d.ts +42 -0
  106. package/dist/lexicon/types/com/atproto/sync/getRepoStatus.d.ts.map +1 -0
  107. package/dist/lexicon/types/com/atproto/sync/getRepoStatus.js +3 -0
  108. package/dist/lexicon/types/com/atproto/sync/getRepoStatus.js.map +1 -0
  109. package/dist/lexicon/types/com/atproto/sync/listBlobs.d.ts +1 -0
  110. package/dist/lexicon/types/com/atproto/sync/listBlobs.d.ts.map +1 -1
  111. package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +3 -0
  112. package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts.map +1 -1
  113. package/dist/lexicon/types/com/atproto/sync/listRepos.js.map +1 -1
  114. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.d.ts +19 -4
  115. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.d.ts.map +1 -1
  116. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.js +11 -1
  117. package/dist/lexicon/types/com/atproto/sync/subscribeRepos.js.map +1 -1
  118. package/dist/scripts/index.d.ts +4 -0
  119. package/dist/scripts/index.d.ts.map +1 -0
  120. package/dist/scripts/index.js +8 -0
  121. package/dist/scripts/index.js.map +1 -0
  122. package/dist/scripts/rebuild-repo.d.ts +3 -0
  123. package/dist/scripts/rebuild-repo.d.ts.map +1 -0
  124. package/dist/scripts/rebuild-repo.js +121 -0
  125. package/dist/scripts/rebuild-repo.js.map +1 -0
  126. package/dist/sequencer/db/schema.d.ts +1 -1
  127. package/dist/sequencer/db/schema.d.ts.map +1 -1
  128. package/dist/sequencer/events.d.ts +27 -2
  129. package/dist/sequencer/events.d.ts.map +1 -1
  130. package/dist/sequencer/events.js +35 -2
  131. package/dist/sequencer/events.js.map +1 -1
  132. package/dist/sequencer/sequencer.d.ts +8 -6
  133. package/dist/sequencer/sequencer.d.ts.map +1 -1
  134. package/dist/sequencer/sequencer.js +22 -9
  135. package/dist/sequencer/sequencer.js.map +1 -1
  136. package/package.json +4 -4
  137. package/src/account-manager/helpers/account.ts +8 -0
  138. package/src/account-manager/index.ts +19 -6
  139. package/src/api/com/atproto/admin/deleteAccount.ts +7 -2
  140. package/src/api/com/atproto/admin/updateAccountHandle.ts +1 -1
  141. package/src/api/com/atproto/admin/updateSubjectStatus.ts +2 -0
  142. package/src/api/com/atproto/identity/submitPlcOperation.ts +1 -0
  143. package/src/api/com/atproto/identity/updateHandle.ts +1 -1
  144. package/src/api/com/atproto/repo/describeRepo.ts +2 -4
  145. package/src/api/com/atproto/server/activateAccount.ts +2 -1
  146. package/src/api/com/atproto/server/createAccount.ts +6 -3
  147. package/src/api/com/atproto/server/deactivateAccount.ts +2 -0
  148. package/src/api/com/atproto/server/deleteAccount.ts +7 -3
  149. package/src/api/com/atproto/server/util.ts +12 -5
  150. package/src/api/com/atproto/sync/deprecated/getCheckout.ts +6 -8
  151. package/src/api/com/atproto/sync/deprecated/getHead.ts +7 -10
  152. package/src/api/com/atproto/sync/getBlob.ts +8 -6
  153. package/src/api/com/atproto/sync/getBlocks.ts +6 -7
  154. package/src/api/com/atproto/sync/getLatestCommit.ts +7 -10
  155. package/src/api/com/atproto/sync/getRecord.ts +7 -7
  156. package/src/api/com/atproto/sync/getRepo.ts +6 -7
  157. package/src/api/com/atproto/sync/getRepoStatus.ts +31 -0
  158. package/src/api/com/atproto/sync/index.ts +2 -0
  159. package/src/api/com/atproto/sync/listBlobs.ts +6 -8
  160. package/src/api/com/atproto/sync/listRepos.ts +13 -8
  161. package/src/api/com/atproto/sync/subscribeRepos.ts +7 -0
  162. package/src/api/com/atproto/sync/util.ts +59 -0
  163. package/src/index.ts +1 -0
  164. package/src/lexicon/index.ts +12 -0
  165. package/src/lexicon/lexicons.ts +193 -7
  166. package/src/lexicon/types/chat/bsky/convo/defs.ts +1 -1
  167. package/src/lexicon/types/com/atproto/sync/getBlob.ts +6 -0
  168. package/src/lexicon/types/com/atproto/sync/getBlocks.ts +6 -0
  169. package/src/lexicon/types/com/atproto/sync/getLatestCommit.ts +1 -1
  170. package/src/lexicon/types/com/atproto/sync/getRecord.ts +6 -0
  171. package/src/lexicon/types/com/atproto/sync/getRepo.ts +1 -0
  172. package/src/lexicon/types/com/atproto/sync/getRepoStatus.ts +52 -0
  173. package/src/lexicon/types/com/atproto/sync/listBlobs.ts +1 -0
  174. package/src/lexicon/types/com/atproto/sync/listRepos.ts +3 -0
  175. package/src/lexicon/types/com/atproto/sync/subscribeRepos.ts +30 -3
  176. package/src/scripts/index.ts +5 -0
  177. package/src/scripts/rebuild-repo.ts +143 -0
  178. package/src/sequencer/db/schema.ts +1 -0
  179. package/src/sequencer/events.ts +47 -0
  180. package/src/sequencer/sequencer.ts +35 -14
  181. package/tests/account-deactivation.test.ts +36 -10
  182. package/tests/account-deletion.test.ts +10 -2
  183. package/tests/moderation.test.ts +2 -2
  184. package/tests/proxied/notif.test.ts +1 -0
  185. package/tests/sequencer.test.ts +2 -2
  186. package/tests/sync/list.test.ts +1 -0
  187. package/tests/sync/subscribe-repos.test.ts +224 -40
  188. package/tests/sync/sync.test.ts +48 -4
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tombstoneEvt = exports.identityEvt = exports.handleEvt = exports.commitEvt = exports.commitEvtOp = exports.formatSeqTombstone = exports.formatSeqIdentityEvt = exports.formatSeqHandleUpdate = exports.formatSeqCommit = void 0;
3
+ exports.tombstoneEvt = exports.accountEvt = exports.identityEvt = exports.handleEvt = exports.commitEvt = exports.commitEvtOp = exports.formatSeqTombstone = exports.formatSeqAccountEvt = exports.formatSeqIdentityEvt = exports.formatSeqHandleUpdate = exports.formatSeqCommit = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const common_1 = require("@atproto/common");
6
6
  const repo_1 = require("@atproto/repo");
7
+ const account_manager_1 = require("../account-manager");
7
8
  const formatSeqCommit = async (did, commitData, writes) => {
8
9
  let tooBig;
9
10
  const ops = [];
@@ -67,10 +68,13 @@ const formatSeqHandleUpdate = async (did, handle) => {
67
68
  };
68
69
  };
69
70
  exports.formatSeqHandleUpdate = formatSeqHandleUpdate;
70
- const formatSeqIdentityEvt = async (did) => {
71
+ const formatSeqIdentityEvt = async (did, handle) => {
71
72
  const evt = {
72
73
  did,
73
74
  };
75
+ if (handle) {
76
+ evt.handle = handle;
77
+ }
74
78
  return {
75
79
  did,
76
80
  eventType: 'identity',
@@ -79,6 +83,22 @@ const formatSeqIdentityEvt = async (did) => {
79
83
  };
80
84
  };
81
85
  exports.formatSeqIdentityEvt = formatSeqIdentityEvt;
86
+ const formatSeqAccountEvt = async (did, status) => {
87
+ const evt = {
88
+ did,
89
+ active: status === 'active',
90
+ };
91
+ if (status !== account_manager_1.AccountStatus.Active) {
92
+ evt.status = status;
93
+ }
94
+ return {
95
+ did,
96
+ eventType: 'account',
97
+ event: (0, common_1.cborEncode)(evt),
98
+ sequencedAt: new Date().toISOString(),
99
+ };
100
+ };
101
+ exports.formatSeqAccountEvt = formatSeqAccountEvt;
82
102
  const formatSeqTombstone = async (did) => {
83
103
  const evt = {
84
104
  did,
@@ -118,6 +138,19 @@ exports.handleEvt = zod_1.z.object({
118
138
  });
119
139
  exports.identityEvt = zod_1.z.object({
120
140
  did: zod_1.z.string(),
141
+ handle: zod_1.z.string().optional(),
142
+ });
143
+ exports.accountEvt = zod_1.z.object({
144
+ did: zod_1.z.string(),
145
+ active: zod_1.z.boolean(),
146
+ status: zod_1.z
147
+ .enum([
148
+ account_manager_1.AccountStatus.Takendown,
149
+ account_manager_1.AccountStatus.Suspended,
150
+ account_manager_1.AccountStatus.Deleted,
151
+ account_manager_1.AccountStatus.Deactivated,
152
+ ])
153
+ .optional(),
121
154
  });
122
155
  exports.tombstoneEvt = zod_1.z.object({
123
156
  did: zod_1.z.string(),
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/sequencer/events.ts"],"names":[],"mappings":";;;AAAA,6BAAuB;AACvB,4CAAoD;AACpD,wCAMsB;AAKf,MAAM,eAAe,GAAG,KAAK,EAClC,GAAW,EACX,UAAsB,EACtB,MAAuB,EACC,EAAE;IAC1B,IAAI,MAAe,CAAA;IACnB,MAAM,GAAG,GAAkB,EAAE,CAAA;IAC7B,MAAM,KAAK,GAAG,IAAI,aAAM,EAAE,CAAA;IAC1B,IAAI,QAAoB,CAAA;IAExB,6BAA6B;IAC7B,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,QAAQ,GAAG,OAAO,EAAE,CAAC;QACnE,MAAM,GAAG,IAAI,CAAA;QACb,MAAM,QAAQ,GAAG,IAAI,eAAQ,EAAE,CAAA;QAC/B,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAA;QACtD,QAAQ,GAAG,MAAM,IAAA,sBAAe,EAAC,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;IAC5D,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,KAAK,CAAA;QACd,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,IAAI,GAA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"}
@@ -4,6 +4,7 @@ import { SeqEvt } from './events';
4
4
  import { SequencerDb, RepoSeqEntry, RepoSeqInsert } from './db';
5
5
  import { PreparedWrite } from '../repo';
6
6
  import { Crawlers } from '../crawlers';
7
+ import { AccountStatus } from '../account-manager/helpers/account';
7
8
  export * from './events';
8
9
  declare const Sequencer_base: new () => SequencerEmitter;
9
10
  export declare class Sequencer extends Sequencer_base {
@@ -27,12 +28,13 @@ export declare class Sequencer extends Sequencer_base {
27
28
  }): Promise<SeqEvt[]>;
28
29
  private pollDb;
29
30
  private exponentialBackoff;
30
- sequenceEvt(evt: RepoSeqInsert): Promise<void>;
31
- sequenceCommit(did: string, commitData: CommitData, writes: PreparedWrite[]): Promise<void>;
32
- sequenceHandleUpdate(did: string, handle: string): Promise<void>;
33
- sequenceIdentityEvt(did: string): Promise<void>;
34
- sequenceTombstone(did: string): Promise<void>;
35
- deleteAllForUser(did: string): Promise<void>;
31
+ sequenceEvt(evt: RepoSeqInsert): Promise<number>;
32
+ sequenceCommit(did: string, commitData: CommitData, writes: PreparedWrite[]): Promise<number>;
33
+ sequenceHandleUpdate(did: string, handle: string): Promise<number>;
34
+ sequenceIdentityEvt(did: string, handle?: string): Promise<number>;
35
+ sequenceAccountEvt(did: string, status: AccountStatus): Promise<number>;
36
+ sequenceTombstone(did: string): Promise<number>;
37
+ deleteAllForUser(did: string, excludingSeqs?: number[]): Promise<void>;
36
38
  }
37
39
  type SeqRow = RepoSeqEntry;
38
40
  type SequencerEvents = {
@@ -1 +1 @@
1
- {"version":3,"file":"sequencer.d.ts","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,eAAe,CAAA;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAIL,MAAM,EAMP,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,WAAW,EAEX,YAAY,EACZ,aAAa,EAEd,MAAM,MAAM,CAAA;AACb,OA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
171
+ seqEvts.push({
172
+ type: 'account',
173
+ seq: row.seq,
174
+ time: row.sequencedAt,
175
+ evt: evt,
176
+ });
177
+ }
170
178
  else if (row.eventType === 'tombstone') {
171
179
  seqEvts.push({
172
180
  type: 'tombstone',
@@ -210,30 +218,35 @@ class Sequencer extends events_1.default {
210
218
  await (0, common_1.wait)(waitTime);
211
219
  }
212
220
  async sequenceEvt(evt) {
213
- await this.db.executeWithRetry(this.db.db.insertInto('repo_seq').values(evt));
221
+ const res = await this.db.executeWithRetry(this.db.db.insertInto('repo_seq').values(evt).returningAll());
214
222
  this.crawlers.notifyOfUpdate();
223
+ return res[0].seq;
215
224
  }
216
225
  async sequenceCommit(did, commitData, writes) {
217
226
  const evt = await (0, events_2.formatSeqCommit)(did, commitData, writes);
218
- await this.sequenceEvt(evt);
227
+ return await this.sequenceEvt(evt);
219
228
  }
220
229
  async sequenceHandleUpdate(did, handle) {
221
230
  const evt = await (0, events_2.formatSeqHandleUpdate)(did, handle);
222
- await this.sequenceEvt(evt);
231
+ return await this.sequenceEvt(evt);
232
+ }
233
+ async sequenceIdentityEvt(did, handle) {
234
+ const evt = await (0, events_2.formatSeqIdentityEvt)(did, handle);
235
+ return await this.sequenceEvt(evt);
223
236
  }
224
- async sequenceIdentityEvt(did) {
225
- const evt = await (0, events_2.formatSeqIdentityEvt)(did);
226
- await this.sequenceEvt(evt);
237
+ async sequenceAccountEvt(did, status) {
238
+ const evt = await (0, events_2.formatSeqAccountEvt)(did, status);
239
+ return await this.sequenceEvt(evt);
227
240
  }
228
241
  async sequenceTombstone(did) {
229
242
  const evt = await (0, events_2.formatSeqTombstone)(did);
230
- await this.sequenceEvt(evt);
243
+ return await this.sequenceEvt(evt);
231
244
  }
232
- async deleteAllForUser(did) {
245
+ async deleteAllForUser(did, excludingSeqs = []) {
233
246
  await this.db.executeWithRetry(this.db.db
234
247
  .deleteFrom('repo_seq')
235
248
  .where('did', '=', did)
236
- .where('eventType', '!=', 'tombstone'));
249
+ .if(excludingSeqs.length > 0, (qb) => qb.where('seq', 'not in', excludingSeqs)));
237
250
  }
238
251
  }
239
252
  exports.Sequencer = Sequencer;
@@ -1 +1 @@
1
- {"version":3,"file":"sequencer.js","sourceRoot":"","sources":["../../src/sequencer/sequencer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,oDAAiC;AAEjC,sCAA4C;AAC5C,4CAA0D;AAE1D,qCAUiB;AACjB,6BAMa;AAIb,2CAAwB;AAExB,MAAa,SAAU,SAAS,gBAA2C;IAMzE,YACE,UAAkB,EACX,QAAkB,EAClB,WAAW,CAAC,EACnB,wBAAwB,GAAG,KAAK;QAEhC,KAAK,EAAE,CAAA;QAJP;;;;mBAAO,QAAQ;WAAU;QACzB;;;;mBAAO,QAAQ;WAAI;QARrB;;;;;WAAe;QACf;;;;mBAAY,KAAK;WAAA;QACjB;;;;mBAAoC,IAAI;WAAA;QACxC;;;;mBAAqB,CAAC;WAAA;QASpB,0EAA0E;QAC1E,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;QACzB,IAAI,CAAC,EAAE,GAAG,IAAA,UAAK,EAAC,UAAU,EAAE,wBAAwB,CAAC,CAAA;IACvD,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAA;QACzB,MAAM,QAAQ,GAAG,IAAA,gBAAW,EAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACrC,MAAM,QAAQ,CAAC,sBAAsB,EAAE,CAAA;QACvC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,IAAI,CAAC,CAAA;QACzB,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;YAC9B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QAClC,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CA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AC,EAAE,CAAC,EAAE;aACP,UAAU,CAAC,UAAU,CAAC;aACtB,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC;aACtB,EAAE,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CACnC,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,aAAa,CAAC,CACzC,CACJ,CAAA;IACH,CAAC;CACF;AApOD,8BAoOC;AAWD,kBAAe,SAAS,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/pds",
3
- "version": "0.4.28",
3
+ "version": "0.4.29",
4
4
  "license": "MIT",
5
5
  "description": "Reference implementation of atproto Personal Data Server (PDS)",
6
6
  "keywords": [
@@ -43,7 +43,7 @@
43
43
  "typed-emitter": "^2.1.0",
44
44
  "uint8arrays": "3.0.0",
45
45
  "zod": "^3.21.4",
46
- "@atproto/api": "^0.12.13",
46
+ "@atproto/api": "^0.12.14",
47
47
  "@atproto/aws": "^0.2.0",
48
48
  "@atproto/common": "^0.4.0",
49
49
  "@atproto/crypto": "^0.4.0",
@@ -70,8 +70,8 @@
70
70
  "jest": "^28.1.2",
71
71
  "ts-node": "^10.8.2",
72
72
  "ws": "^8.12.0",
73
- "@atproto/api": "^0.12.13",
74
- "@atproto/bsky": "^0.0.56",
73
+ "@atproto/api": "^0.12.14",
74
+ "@atproto/bsky": "^0.0.57",
75
75
  "@atproto/lex-cli": "^0.4.0"
76
76
  },
77
77
  "scripts": {
@@ -16,6 +16,14 @@ export type AvailabilityFlags = {
16
16
  includeDeactivated?: boolean
17
17
  }
18
18
 
19
+ export enum AccountStatus {
20
+ Active = 'active',
21
+ Takendown = 'takendown',
22
+ Suspended = 'suspended',
23
+ Deleted = 'deleted',
24
+ Deactivated = 'deactivated',
25
+ }
26
+
19
27
  const selectAccountQB = (db: AccountDb, flags?: AvailabilityFlags) => {
20
28
  const { includeTakenDown = false, includeDeactivated = false } = flags ?? {}
21
29
  const { ref } = db.db.dynamic
@@ -4,6 +4,7 @@ import { CID } from 'multiformats/cid'
4
4
  import { AccountDb, EmailTokenPurpose, getDb, getMigrator } from './db'
5
5
  import * as scrypt from './helpers/scrypt'
6
6
  import * as account from './helpers/account'
7
+ import { AccountStatus } from './helpers/account'
7
8
  import { ActorAccount } from './helpers/account'
8
9
  import * as repo from './helpers/repo'
9
10
  import * as auth from './helpers/auth'
@@ -13,6 +14,8 @@ import * as emailToken from './helpers/email-token'
13
14
  import { AuthScope } from '../auth-verifier'
14
15
  import { StatusAttr } from '../lexicon/types/com/atproto/admin/defs'
15
16
 
17
+ export { AccountStatus } from './helpers/account'
18
+
16
19
  export class AccountManager {
17
20
  db: AccountDb
18
21
 
@@ -51,12 +54,6 @@ export class AccountManager {
51
54
  return account.getAccountByEmail(this.db, email, flags)
52
55
  }
53
56
 
54
- // Repo exists and is not taken-down
55
- async isRepoAvailable(did: string) {
56
- const got = await this.getAccount(did)
57
- return !!got
58
- }
59
-
60
57
  async isAccountActivated(did: string): Promise<boolean> {
61
58
  const account = await this.getAccount(did, { includeDeactivated: true })
62
59
  if (!account) return false
@@ -71,6 +68,22 @@ export class AccountManager {
71
68
  return got?.did ?? null
72
69
  }
73
70
 
71
+ async getAccountStatus(handleOrDid: string): Promise<AccountStatus> {
72
+ const got = await this.getAccount(handleOrDid, {
73
+ includeDeactivated: true,
74
+ includeTakenDown: true,
75
+ })
76
+ if (!got) {
77
+ return AccountStatus.Deleted
78
+ } else if (got.takedownRef) {
79
+ return AccountStatus.Takendown
80
+ } else if (got.deactivatedAt) {
81
+ return AccountStatus.Deactivated
82
+ } else {
83
+ return AccountStatus.Active
84
+ }
85
+ }
86
+
74
87
  async createAccount(opts: {
75
88
  did: string
76
89
  handle: string
@@ -1,5 +1,6 @@
1
1
  import { Server } from '../../../../lexicon'
2
2
  import AppContext from '../../../../context'
3
+ import { AccountStatus } from '../../../../account-manager'
3
4
 
4
5
  export default function (server: Server, ctx: AppContext) {
5
6
  server.com.atproto.admin.deleteAccount({
@@ -8,8 +9,12 @@ export default function (server: Server, ctx: AppContext) {
8
9
  const { did } = input.body
9
10
  await ctx.actorStore.destroy(did)
10
11
  await ctx.accountManager.deleteAccount(did)
11
- await ctx.sequencer.sequenceTombstone(did)
12
- await ctx.sequencer.deleteAllForUser(did)
12
+ const tombstoneSeq = await ctx.sequencer.sequenceTombstone(did)
13
+ const accountSeq = await ctx.sequencer.sequenceAccountEvt(
14
+ did,
15
+ AccountStatus.Deleted,
16
+ )
17
+ await ctx.sequencer.deleteAllForUser(did, [accountSeq, tombstoneSeq])
13
18
  },
14
19
  })
15
20
  }
@@ -45,7 +45,7 @@ export default function (server: Server, ctx: AppContext) {
45
45
 
46
46
  try {
47
47
  await ctx.sequencer.sequenceHandleUpdate(did, handle)
48
- await ctx.sequencer.sequenceIdentityEvt(did)
48
+ await ctx.sequencer.sequenceIdentityEvt(did, handle)
49
49
  } catch (err) {
50
50
  httpLogger.error(
51
51
  { err, did, handle },
@@ -17,6 +17,8 @@ export default function (server: Server, ctx: AppContext) {
17
17
  if (takedown) {
18
18
  if (isRepoRef(subject)) {
19
19
  await ctx.accountManager.takedownAccount(subject.did, takedown)
20
+ const status = await ctx.accountManager.getAccountStatus(subject.did)
21
+ await ctx.sequencer.sequenceAccountEvt(subject.did, status)
20
22
  } else if (isStrongRef(subject)) {
21
23
  const uri = new AtUri(subject.uri)
22
24
  await ctx.actorStore.transact(uri.hostname, (store) =>
@@ -47,6 +47,7 @@ export default function (server: Server, ctx: AppContext) {
47
47
 
48
48
  await ctx.plcClient.sendOperation(requester, op)
49
49
  await ctx.sequencer.sequenceIdentityEvt(requester)
50
+
50
51
  try {
51
52
  await ctx.idResolver.did.resolve(requester, true)
52
53
  } catch (err) {
@@ -57,7 +57,7 @@ export default function (server: Server, ctx: AppContext) {
57
57
 
58
58
  try {
59
59
  await ctx.sequencer.sequenceHandleUpdate(requester, handle)
60
- await ctx.sequencer.sequenceIdentityEvt(requester)
60
+ await ctx.sequencer.sequenceIdentityEvt(requester, handle)
61
61
  } catch (err) {
62
62
  httpLogger.error(
63
63
  { err, did: requester, handle },
@@ -3,15 +3,13 @@ import * as id from '@atproto/identity'
3
3
  import { Server } from '../../../../lexicon'
4
4
  import AppContext from '../../../../context'
5
5
  import { INVALID_HANDLE } from '@atproto/syntax'
6
+ import { assertRepoAvailability } from '../sync/util'
6
7
 
7
8
  export default function (server: Server, ctx: AppContext) {
8
9
  server.com.atproto.repo.describeRepo(async ({ params }) => {
9
10
  const { repo } = params
10
11
 
11
- const account = await ctx.accountManager.getAccount(repo)
12
- if (account === null) {
13
- throw new InvalidRequestError(`Could not find user: ${repo}`)
14
- }
12
+ const account = await assertRepoAvailability(ctx, repo, false)
15
13
 
16
14
  let didDoc
17
15
  try {
@@ -36,7 +36,8 @@ export default function (server: Server, ctx: AppContext) {
36
36
  })
37
37
 
38
38
  // @NOTE: we're over-emitting for now for backwards compatibility, can reduce this in the future
39
- await ctx.sequencer.sequenceIdentityEvt(requester)
39
+ const status = await ctx.accountManager.getAccountStatus(requester)
40
+ await ctx.sequencer.sequenceAccountEvt(requester, status)
40
41
  await ctx.sequencer.sequenceHandleUpdate(
41
42
  requester,
42
43
  account.handle ?? INVALID_HANDLE,
@@ -11,7 +11,8 @@ import {
11
11
  import { Server } from '../../../../lexicon'
12
12
  import { InputSchema as CreateAccountInput } from '../../../../lexicon/types/com/atproto/server/createAccount'
13
13
  import AppContext from '../../../../context'
14
- import { didDocForSession } from './util'
14
+ import { safeResolveDidDoc } from './util'
15
+ import { AccountStatus } from '../../../../account-manager'
15
16
 
16
17
  export default function (server: Server, ctx: AppContext) {
17
18
  server.com.atproto.server.createAccount({
@@ -56,6 +57,8 @@ export default function (server: Server, ctx: AppContext) {
56
57
  }
57
58
  }
58
59
 
60
+ didDoc = await safeResolveDidDoc(ctx, did, true)
61
+
59
62
  creds = await ctx.accountManager.createAccount({
60
63
  did,
61
64
  handle,
@@ -68,11 +71,11 @@ export default function (server: Server, ctx: AppContext) {
68
71
  })
69
72
 
70
73
  if (!deactivated) {
74
+ await ctx.sequencer.sequenceIdentityEvt(did, handle)
75
+ await ctx.sequencer.sequenceAccountEvt(did, AccountStatus.Active)
71
76
  await ctx.sequencer.sequenceCommit(did, commit, [])
72
- await ctx.sequencer.sequenceIdentityEvt(did)
73
77
  }
74
78
  await ctx.accountManager.updateRepoRoot(did, commit.cid, commit.rev)
75
- didDoc = await didDocForSession(ctx, did, true)
76
79
  await ctx.actorStore.clearReservedKeypair(signingKey.did(), did)
77
80
  } catch (err) {
78
81
  // this will only be reached if the actor store _did not_ exist before
@@ -10,6 +10,8 @@ export default function (server: Server, ctx: AppContext) {
10
10
  requester,
11
11
  input.body.deleteAfter ?? null,
12
12
  )
13
+ const status = await ctx.accountManager.getAccountStatus(requester)
14
+ await ctx.sequencer.sequenceAccountEvt(requester, status)
13
15
  },
14
16
  })
15
17
  }
@@ -3,6 +3,7 @@ import { AuthRequiredError, InvalidRequestError } from '@atproto/xrpc-server'
3
3
  import { Server } from '../../../../lexicon'
4
4
  import AppContext from '../../../../context'
5
5
  import { authPassthru } from '../../../proxy'
6
+ import { AccountStatus } from '../../../../account-manager'
6
7
 
7
8
  export default function (server: Server, ctx: AppContext) {
8
9
  server.com.atproto.server.deleteAccount({
@@ -44,9 +45,12 @@ export default function (server: Server, ctx: AppContext) {
44
45
  )
45
46
  await ctx.actorStore.destroy(did)
46
47
  await ctx.accountManager.deleteAccount(did)
47
- await ctx.sequencer.sequenceIdentityEvt(did)
48
- await ctx.sequencer.sequenceTombstone(did)
49
- await ctx.sequencer.deleteAllForUser(did)
48
+ const accountSeq = await ctx.sequencer.sequenceAccountEvt(
49
+ did,
50
+ AccountStatus.Deleted,
51
+ )
52
+ const tombstoneSeq = await ctx.sequencer.sequenceTombstone(did)
53
+ await ctx.sequencer.deleteAllForUser(did, [accountSeq, tombstoneSeq])
50
54
  },
51
55
  })
52
56
  }
@@ -2,7 +2,7 @@ import * as crypto from '@atproto/crypto'
2
2
  import { DidDocument } from '@atproto/identity'
3
3
  import { ServerConfig } from '../../../../config'
4
4
  import AppContext from '../../../../context'
5
- import { dbLogger } from '../../../../logger'
5
+ import { httpLogger } from '../../../../logger'
6
6
  import { InvalidRequestError } from '@atproto/xrpc-server'
7
7
  import { getPdsEndpoint, getSigningDidKey } from '@atproto/common'
8
8
 
@@ -28,21 +28,28 @@ export const getRandomToken = () => {
28
28
  return token.slice(0, 5) + '-' + token.slice(5, 10)
29
29
  }
30
30
 
31
- // @TODO once supporting multiple pdses, validate pds in did doc based on allow-list.
32
- export const didDocForSession = async (
31
+ export const safeResolveDidDoc = async (
33
32
  ctx: AppContext,
34
33
  did: string,
35
34
  forceRefresh?: boolean,
36
35
  ): Promise<DidDocument | undefined> => {
37
- if (!ctx.cfg.identity.enableDidDocWithSession) return
38
36
  try {
39
37
  const didDoc = await ctx.idResolver.did.resolve(did, forceRefresh)
40
38
  return didDoc ?? undefined
41
39
  } catch (err) {
42
- dbLogger.warn({ err, did }, 'failed to resolve did doc')
40
+ httpLogger.warn({ err, did }, 'failed to resolve did doc')
43
41
  }
44
42
  }
45
43
 
44
+ export const didDocForSession = async (
45
+ ctx: AppContext,
46
+ did: string,
47
+ forceRefresh?: boolean,
48
+ ): Promise<DidDocument | undefined> => {
49
+ if (!ctx.cfg.identity.enableDidDocWithSession) return
50
+ return safeResolveDidDoc(ctx, did, forceRefresh)
51
+ }
52
+
46
53
  export const isValidDidDocForService = async (
47
54
  ctx: AppContext,
48
55
  did: string,
@@ -1,20 +1,18 @@
1
- import { InvalidRequestError } from '@atproto/xrpc-server'
2
1
  import { Server } from '../../../../../lexicon'
3
2
  import AppContext from '../../../../../context'
4
3
  import { getCarStream } from '../getRepo'
4
+ import { assertRepoAvailability } from '../util'
5
5
 
6
6
  export default function (server: Server, ctx: AppContext) {
7
7
  server.com.atproto.sync.getCheckout({
8
8
  auth: ctx.authVerifier.optionalAccessOrAdminToken,
9
9
  handler: async ({ params, auth }) => {
10
10
  const { did } = params
11
- // takedown check for anyone other than an admin or the user
12
- if (!ctx.authVerifier.isUserOrAdmin(auth, did)) {
13
- const available = await ctx.accountManager.isRepoAvailable(did)
14
- if (!available) {
15
- throw new InvalidRequestError(`Could not find repo for DID: ${did}`)
16
- }
17
- }
11
+ await assertRepoAvailability(
12
+ ctx,
13
+ did,
14
+ ctx.authVerifier.isUserOrAdmin(auth, did),
15
+ )
18
16
 
19
17
  const carStream = await getCarStream(ctx, did)
20
18
 
@@ -1,22 +1,19 @@
1
1
  import { InvalidRequestError } from '@atproto/xrpc-server'
2
2
  import { Server } from '../../../../../lexicon'
3
3
  import AppContext from '../../../../../context'
4
+ import { assertRepoAvailability } from '../util'
4
5
 
5
6
  export default function (server: Server, ctx: AppContext) {
6
7
  server.com.atproto.sync.getHead({
7
8
  auth: ctx.authVerifier.optionalAccessOrAdminToken,
8
9
  handler: async ({ params, auth }) => {
9
10
  const { did } = params
10
- // takedown check for anyone other than an admin or the user
11
- if (!ctx.authVerifier.isUserOrAdmin(auth, did)) {
12
- const available = await ctx.accountManager.isRepoAvailable(did)
13
- if (!available) {
14
- throw new InvalidRequestError(
15
- `Could not find root for DID: ${did}`,
16
- 'HeadNotFound',
17
- )
18
- }
19
- }
11
+ await assertRepoAvailability(
12
+ ctx,
13
+ did,
14
+ ctx.authVerifier.isUserOrAdmin(auth, did),
15
+ )
16
+
20
17
  const root = await ctx.actorStore.read(did, (store) =>
21
18
  store.repo.storage.getRoot(),
22
19
  )
@@ -3,17 +3,19 @@ import { Server } from '../../../../lexicon'
3
3
  import AppContext from '../../../../context'
4
4
  import { InvalidRequestError } from '@atproto/xrpc-server'
5
5
  import { BlobNotFoundError } from '@atproto/repo'
6
+ import { assertRepoAvailability } from './util'
6
7
 
7
8
  export default function (server: Server, ctx: AppContext) {
8
9
  server.com.atproto.sync.getBlob({
9
10
  auth: ctx.authVerifier.optionalAccessOrAdminToken,
10
11
  handler: async ({ params, res, auth }) => {
11
- if (!ctx.authVerifier.isUserOrAdmin(auth, params.did)) {
12
- const available = await ctx.accountManager.isRepoAvailable(params.did)
13
- if (!available) {
14
- throw new InvalidRequestError('Blob not found')
15
- }
16
- }
12
+ const { did } = params
13
+ await assertRepoAvailability(
14
+ ctx,
15
+ did,
16
+ ctx.authVerifier.isUserOrAdmin(auth, did),
17
+ )
18
+
17
19
  const cid = CID.parse(params.cid)
18
20
  const found = await ctx.actorStore.read(params.did, async (store) => {
19
21
  try {
@@ -4,19 +4,18 @@ import { byteIterableToStream } from '@atproto/common'
4
4
  import { blocksToCarStream } from '@atproto/repo'
5
5
  import { Server } from '../../../../lexicon'
6
6
  import AppContext from '../../../../context'
7
+ import { assertRepoAvailability } from './util'
7
8
 
8
9
  export default function (server: Server, ctx: AppContext) {
9
10
  server.com.atproto.sync.getBlocks({
10
11
  auth: ctx.authVerifier.optionalAccessOrAdminToken,
11
12
  handler: async ({ params, auth }) => {
12
13
  const { did } = params
13
- // takedown check for anyone other than an admin or the user
14
- if (!ctx.authVerifier.isUserOrAdmin(auth, did)) {
15
- const available = await ctx.accountManager.isRepoAvailable(did)
16
- if (!available) {
17
- throw new InvalidRequestError(`Could not find repo for DID: ${did}`)
18
- }
19
- }
14
+ await assertRepoAvailability(
15
+ ctx,
16
+ did,
17
+ ctx.authVerifier.isUserOrAdmin(auth, did),
18
+ )
20
19
 
21
20
  const cids = params.cids.map((c) => CID.parse(c))
22
21
  const got = await ctx.actorStore.read(did, (store) =>