@atproto/pds 0.5.34 → 0.5.35

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 (45) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/actor-store/actor-store-reader.d.ts +3 -2
  3. package/dist/actor-store/actor-store-reader.d.ts.map +1 -1
  4. package/dist/actor-store/actor-store-reader.js +2 -2
  5. package/dist/actor-store/actor-store-reader.js.map +1 -1
  6. package/dist/actor-store/actor-store-transactor.d.ts +3 -2
  7. package/dist/actor-store/actor-store-transactor.d.ts.map +1 -1
  8. package/dist/actor-store/actor-store-transactor.js +1 -1
  9. package/dist/actor-store/actor-store-transactor.js.map +1 -1
  10. package/dist/actor-store/actor-store.d.ts +5 -4
  11. package/dist/actor-store/actor-store.d.ts.map +1 -1
  12. package/dist/actor-store/actor-store.js.map +1 -1
  13. package/dist/actor-store/record/reader.d.ts +5 -3
  14. package/dist/actor-store/record/reader.d.ts.map +1 -1
  15. package/dist/actor-store/record/reader.js +19 -8
  16. package/dist/actor-store/record/reader.js.map +1 -1
  17. package/dist/actor-store/record/transactor.d.ts +3 -1
  18. package/dist/actor-store/record/transactor.d.ts.map +1 -1
  19. package/dist/actor-store/record/transactor.js +3 -2
  20. package/dist/actor-store/record/transactor.js.map +1 -1
  21. package/dist/actor-store/repo/reader.d.ts +3 -1
  22. package/dist/actor-store/repo/reader.d.ts.map +1 -1
  23. package/dist/actor-store/repo/reader.js +3 -2
  24. package/dist/actor-store/repo/reader.js.map +1 -1
  25. package/dist/actor-store/repo/transactor.d.ts +3 -2
  26. package/dist/actor-store/repo/transactor.d.ts.map +1 -1
  27. package/dist/actor-store/repo/transactor.js +2 -2
  28. package/dist/actor-store/repo/transactor.js.map +1 -1
  29. package/dist/api/com/atproto/admin/getSubjectStatus.js +1 -1
  30. package/dist/api/com/atproto/admin/getSubjectStatus.js.map +1 -1
  31. package/dist/api/com/atproto/admin/updateSubjectStatus.js +1 -1
  32. package/dist/api/com/atproto/admin/updateSubjectStatus.js.map +1 -1
  33. package/dist/api/com/atproto/server/activateAccount.d.ts.map +1 -1
  34. package/dist/api/com/atproto/server/activateAccount.js +3 -1
  35. package/dist/api/com/atproto/server/activateAccount.js.map +1 -1
  36. package/dist/api/com/atproto/server/deactivateAccount.d.ts +1 -1
  37. package/dist/api/com/atproto/server/deactivateAccount.d.ts.map +1 -1
  38. package/dist/api/com/atproto/server/deactivateAccount.js +11 -5
  39. package/dist/api/com/atproto/server/deactivateAccount.js.map +1 -1
  40. package/dist/context.d.ts.map +1 -1
  41. package/dist/context.js +60 -24
  42. package/dist/context.js.map +1 -1
  43. package/dist/read-after-write/util.d.ts.map +1 -1
  44. package/dist/read-after-write/util.js.map +1 -1
  45. package/package.json +16 -17
@@ -1,4 +1,5 @@
1
1
  import type * as crypto from '@atproto/crypto';
2
+ import type { DidString } from '@atproto/lex';
2
3
  import { type Cid } from '@atproto/lex-data';
3
4
  import { type BlobStore, Repo } from '@atproto/repo';
4
5
  import type { AtUri } from '@atproto/syntax';
@@ -12,14 +13,14 @@ import { SqlRepoTransactor } from './sql-repo-transactor.js';
12
13
  export declare class RepoTransactor extends RepoReader {
13
14
  db: ActorDb;
14
15
  blobstore: BlobStore;
15
- did: string;
16
+ did: DidString;
16
17
  signingKey: crypto.Keypair;
17
18
  backgroundQueue: BackgroundQueue;
18
19
  now: string;
19
20
  blob: BlobTransactor;
20
21
  record: RecordTransactor;
21
22
  storage: SqlRepoTransactor;
22
- constructor(db: ActorDb, blobstore: BlobStore, did: string, signingKey: crypto.Keypair, backgroundQueue: BackgroundQueue, now?: string);
23
+ constructor(db: ActorDb, blobstore: BlobStore, did: DidString, signingKey: crypto.Keypair, backgroundQueue: BackgroundQueue, now?: string);
23
24
  maybeLoadRepo(): Promise<Repo | null>;
24
25
  createRepo(writes: PreparedCreate[]): Promise<CommitDataWithOps>;
25
26
  processWrites(writes: PreparedWrite[], swapCommitCid?: Cid): Promise<CommitDataWithOps>;
@@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AE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,qBAAa,cAAe,SAAQ,UAAU;IAMnC,EAAE,EAAE,OAAO;IACX,SAAS,EAAE,SAAS;IACpB,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,MAAM,CAAC,OAAO;IAC1B,eAAe,EAAE,eAAe;IAChC,GAAG,EAAE,MAAM;IAVpB,IAAI,EAAE,cAAc,CAAA;IACpB,MAAM,EAAE,gBAAgB,CAAA;IACxB,OAAO,EAAE,iBAAiB,CAAA;IAE1B,YACS,EAAE,EAAE,OAAO,EACX,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,SAAS,EACd,UAAU,EAAE,MAAM,CAAC,OAAO,EAC1B,eAAe,EAAE,eAAe,EAChC,GAAG,GAAE,MAAiC,EAM9C;IAEK,aAAa,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,CAO1C;IAEK,UAAU,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAsBrE;IAEK,aAAa,CACjB,MAAM,EAAE,aAAa,EAAE,EACvB,aAAa,CAAC,EAAE,GAAG,GAClB,OAAO,CAAC,iBAAiB,CAAC,CAoB5B;IAEK,YAAY,CAChB,MAAM,EAAE,aAAa,EAAE,EACvB,UAAU,CAAC,EAAE,GAAG,GACf,OAAO,CAAC,iBAAiB,CAAC,CAoF5B;IAEK,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,GAAG,EAAE,MAAM,iBAoBrD;IAEK,sBAAsB,CAC1B,IAAI,EAAE,GAAG,EAAE,EACX,WAAW,EAAE,KAAK,EAAE,GACnB,OAAO,CAAC,GAAG,EAAE,CAAC,CAahB;CACF"}
@@ -9,7 +9,7 @@ import { RepoReader } from './reader.js';
9
9
  import { SqlRepoTransactor } from './sql-repo-transactor.js';
10
10
  export class RepoTransactor extends RepoReader {
11
11
  constructor(db, blobstore, did, signingKey, backgroundQueue, now = new Date().toISOString()) {
12
- super(db, blobstore);
12
+ super(db, blobstore, did);
13
13
  this.db = db;
14
14
  this.blobstore = blobstore;
15
15
  this.did = did;
@@ -17,7 +17,7 @@ export class RepoTransactor extends RepoReader {
17
17
  this.backgroundQueue = backgroundQueue;
18
18
  this.now = now;
19
19
  this.blob = new BlobTransactor(db, blobstore, backgroundQueue);
20
- this.record = new RecordTransactor(db, blobstore);
20
+ this.record = new RecordTransactor(db, did, blobstore);
21
21
  this.storage = new SqlRepoTransactor(db, did, now);
22
22
  }
23
23
  async maybeLoadRepo() {
@@ -1 +1 @@
1
- {"version":3,"file":"transactor.js","sourceRoot":"","sources":["../../../src/actor-store/repo/transactor.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAEL,IAAI,EACJ,aAAa,EACb,aAAa,GACd,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAKnB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,MAAM,OAAO,cAAe,SAAQ,UAAU;IAK5C,YACS,EAAW,EACX,SAAoB,EACpB,GAAW,EACX,UAA0B,EAC1B,eAAgC,EAChC,GAAG,GAAW,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QAE7C,KAAK,CAAC,EAAE,EAAE,SAAS,CAAC,CAAA;kBAPb,EAAE;yBACF,SAAS;mBACT,GAAG;0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G,EACH,IAAI,CAAC,GAAG,CACT,CAAA;YACH,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,KAAK,aAAa,CAAC,MAAM,EAAE,CAAC;gBACjD,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,sBAAsB,CAC1B,IAAW,EACX,WAAoB;QAEpB,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClD,OAAO,EAAE,CAAA;QACX,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;QAC7C,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;QACpD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,EAAE;aACzB,UAAU,CAAC,QAAQ,CAAC;aACpB,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC;aAC3B,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC;aAC/B,MAAM,CAAC,KAAK,CAAC;aACb,OAAO,EAAE,CAAA;QACZ,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IAC5C,CAAC;CACF","sourcesContent":["import type * as crypto from '@atproto/crypto'\nimport { type Cid, parseCid } from '@atproto/lex-data'\nimport {\n type BlobStore,\n Repo,\n WriteOpAction,\n formatDataKey,\n} from '@atproto/repo'\nimport type { AtUri } from '@atproto/syntax'\nimport { InvalidRequestError } from '@atproto/xrpc-server'\nimport type { BackgroundQueue } from '../../background.js'\nimport { createWriteToOp, writeToOp } from '../../repo/index.js'\nimport {\n BadCommitSwapError,\n BadRecordSwapError,\n type CommitDataWithOps,\n type CommitOp,\n type PreparedCreate,\n type PreparedWrite,\n} from '../../repo/types.js'\nimport { BlobTransactor } from '../blob/transactor.js'\nimport type { ActorDb } from '../db/index.js'\nimport { RecordTransactor } from '../record/transactor.js'\nimport { RepoReader } from './reader.js'\nimport { SqlRepoTransactor } from './sql-repo-transactor.js'\n\nexport class RepoTransactor extends RepoReader {\n blob: BlobTransactor\n record: RecordTransactor\n storage: SqlRepoTransactor\n\n constructor(\n public db: ActorDb,\n public blobstore: BlobStore,\n public did: string,\n public signingKey: crypto.Keypair,\n public backgroundQueue: BackgroundQueue,\n public now: string = new Date().toISOString(),\n ) {\n super(db, blobstore)\n this.blob = new BlobTransactor(db, blobstore, backgroundQueue)\n this.record = new RecordTransactor(db, blobstore)\n this.storage = new SqlRepoTransactor(db, did, now)\n }\n\n async maybeLoadRepo(): Promise<Repo | null> {\n const res = await this.db.db\n .selectFrom('repo_root')\n .select('cid')\n .limit(1)\n .executeTakeFirst()\n return res ? Repo.load(this.storage, parseCid(res.cid)) : null\n }\n\n async createRepo(writes: PreparedCreate[]): Promise<CommitDataWithOps> {\n this.db.assertTransaction()\n const commit = await Repo.formatInitCommit(\n this.storage,\n this.did,\n this.signingKey,\n writes.map(createWriteToOp),\n )\n await this.storage.applyCommit(commit, true)\n await this.indexWrites(writes, commit.rev)\n await this.blob.processWriteBlobs(commit.rev, writes)\n\n const ops = writes.map((w) => ({\n action: 'create' as const,\n path: formatDataKey(w.uri.collection, w.uri.rkey),\n cid: w.cid,\n }))\n return {\n ...commit,\n ops,\n prevData: null,\n }\n }\n\n async processWrites(\n writes: PreparedWrite[],\n swapCommitCid?: Cid,\n ): Promise<CommitDataWithOps> {\n this.db.assertTransaction()\n if (writes.length > 200) {\n throw new InvalidRequestError('Too many writes. Max: 200')\n }\n\n const commit = await this.formatCommit(writes, swapCommitCid)\n // Do not allow commits > 2MB\n if (commit.relevantBlocks.byteSize > 2000000) {\n throw new InvalidRequestError('Too many writes. Max event size: 2MB')\n }\n\n // persist the commit to repo storage\n await this.storage.applyCommit(commit)\n // & send to indexing\n await this.indexWrites(writes, commit.rev)\n // process blobs\n await this.blob.processWriteBlobs(commit.rev, writes)\n\n return commit\n }\n\n async formatCommit(\n writes: PreparedWrite[],\n swapCommit?: Cid,\n ): Promise<CommitDataWithOps> {\n // this is not in a txn, so this won't actually hold the lock,\n // we just check if it is currently held by another txn\n const currRoot = await this.storage.getRootDetailed()\n if (!currRoot) {\n throw new InvalidRequestError(`No repo root found for ${this.did}`)\n }\n if (swapCommit && !currRoot.cid.equals(swapCommit)) {\n throw new BadCommitSwapError(currRoot.cid)\n }\n // cache last commit since there's likely overlap\n await this.storage.cacheRev(currRoot.rev)\n const newRecordCids: Cid[] = []\n const delAndUpdateUris: AtUri[] = []\n const commitOps: CommitOp[] = []\n for (const write of writes) {\n const { action, uri, swapCid } = write\n if (action !== WriteOpAction.Delete) {\n newRecordCids.push(write.cid)\n }\n if (action !== WriteOpAction.Create) {\n delAndUpdateUris.push(uri)\n }\n const record = await this.record.getRecord(uri, null, true)\n const currRecord = record ? parseCid(record.cid) : null\n\n const op: CommitOp = {\n action,\n path: formatDataKey(uri.collection, uri.rkey),\n cid: write.action === WriteOpAction.Delete ? null : write.cid,\n }\n if (currRecord) {\n op.prev = currRecord\n }\n commitOps.push(op)\n if (swapCid !== undefined) {\n if (action === WriteOpAction.Create && swapCid !== null) {\n throw new BadRecordSwapError(currRecord) // There should be no current record for a create\n }\n if (action === WriteOpAction.Update && swapCid === null) {\n throw new BadRecordSwapError(currRecord) // There should be a current record for an update\n }\n if (action === WriteOpAction.Delete && swapCid === null) {\n throw new BadRecordSwapError(currRecord) // There should be a current record for a delete\n }\n if (\n // If we have either a current CID or a swap CID\n (currRecord || swapCid) &&\n // We make sure that both are provided and equal\n !(swapCid && currRecord && currRecord.equals(swapCid))\n ) {\n throw new BadRecordSwapError(currRecord)\n }\n }\n }\n\n const repo = await Repo.load(this.storage, currRoot.cid)\n const prevData = repo.commit.data\n const writeOps = writes.map(writeToOp)\n const commit = await repo.formatCommit(writeOps, this.signingKey)\n\n // find blocks that would be deleted but are referenced by another record\n const dupeRecordCids = await this.getDuplicateRecordCids(\n commit.removedCids.toList(),\n delAndUpdateUris,\n )\n for (const cid of dupeRecordCids) {\n commit.removedCids.delete(cid)\n }\n\n // find blocks that are relevant to ops but not included in diff\n // (for instance a record that was moved but cid stayed the same)\n const newRecordBlocks = commit.relevantBlocks.getMany(newRecordCids)\n if (newRecordBlocks.missing.length > 0) {\n const missingBlocks = await this.storage.getBlocks(\n newRecordBlocks.missing,\n )\n commit.relevantBlocks.addMap(missingBlocks.blocks)\n }\n return {\n ...commit,\n ops: commitOps,\n prevData,\n }\n }\n\n async indexWrites(writes: PreparedWrite[], rev: string) {\n this.db.assertTransaction()\n\n for (const write of writes) {\n if (\n write.action === WriteOpAction.Create ||\n write.action === WriteOpAction.Update\n ) {\n await this.record.indexRecord(\n write.uri,\n write.cid,\n write.record,\n write.action,\n rev,\n this.now,\n )\n } else if (write.action === WriteOpAction.Delete) {\n await this.record.deleteRecord(write.uri)\n }\n }\n }\n\n async getDuplicateRecordCids(\n cids: Cid[],\n touchedUris: AtUri[],\n ): Promise<Cid[]> {\n if (touchedUris.length === 0 || cids.length === 0) {\n return []\n }\n const cidStrs = cids.map((c) => c.toString())\n const uriStrs = touchedUris.map((u) => u.toString())\n const res = await this.db.db\n .selectFrom('record')\n .where('cid', 'in', cidStrs)\n .where('uri', 'not in', uriStrs)\n .select('cid')\n .execute()\n return res.map((row) => parseCid(row.cid))\n }\n}\n"]}
1
+ {"version":3,"file":"transactor.js","sourceRoot":"","sources":["../../../src/actor-store/repo/transactor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAEL,IAAI,EACJ,aAAa,EACb,aAAa,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AG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;QACpD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,EAAE;aACzB,UAAU,CAAC,QAAQ,CAAC;aACpB,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC;aAC3B,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC;aAC/B,MAAM,CAAC,KAAK,CAAC;aACb,OAAO,EAAE,CAAA;QACZ,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IAC5C,CAAC;CACF","sourcesContent":["import type * as crypto from '@atproto/crypto'\nimport type { DidString } from '@atproto/lex'\nimport { type Cid, parseCid } from '@atproto/lex-data'\nimport {\n type BlobStore,\n Repo,\n WriteOpAction,\n formatDataKey,\n} from '@atproto/repo'\nimport type { AtUri } from '@atproto/syntax'\nimport { InvalidRequestError } from '@atproto/xrpc-server'\nimport type { BackgroundQueue } from '../../background.js'\nimport { createWriteToOp, writeToOp } from '../../repo/index.js'\nimport {\n BadCommitSwapError,\n BadRecordSwapError,\n type CommitDataWithOps,\n type CommitOp,\n type PreparedCreate,\n type PreparedWrite,\n} from '../../repo/types.js'\nimport { BlobTransactor } from '../blob/transactor.js'\nimport type { ActorDb } from '../db/index.js'\nimport { RecordTransactor } from '../record/transactor.js'\nimport { RepoReader } from './reader.js'\nimport { SqlRepoTransactor } from './sql-repo-transactor.js'\n\nexport class RepoTransactor extends RepoReader {\n blob: BlobTransactor\n record: RecordTransactor\n storage: SqlRepoTransactor\n\n constructor(\n public db: ActorDb,\n public blobstore: BlobStore,\n public did: DidString,\n public signingKey: crypto.Keypair,\n public backgroundQueue: BackgroundQueue,\n public now: string = new Date().toISOString(),\n ) {\n super(db, blobstore, did)\n this.blob = new BlobTransactor(db, blobstore, backgroundQueue)\n this.record = new RecordTransactor(db, did, blobstore)\n this.storage = new SqlRepoTransactor(db, did, now)\n }\n\n async maybeLoadRepo(): Promise<Repo | null> {\n const res = await this.db.db\n .selectFrom('repo_root')\n .select('cid')\n .limit(1)\n .executeTakeFirst()\n return res ? Repo.load(this.storage, parseCid(res.cid)) : null\n }\n\n async createRepo(writes: PreparedCreate[]): Promise<CommitDataWithOps> {\n this.db.assertTransaction()\n const commit = await Repo.formatInitCommit(\n this.storage,\n this.did,\n this.signingKey,\n writes.map(createWriteToOp),\n )\n await this.storage.applyCommit(commit, true)\n await this.indexWrites(writes, commit.rev)\n await this.blob.processWriteBlobs(commit.rev, writes)\n\n const ops = writes.map((w) => ({\n action: 'create' as const,\n path: formatDataKey(w.uri.collection, w.uri.rkey),\n cid: w.cid,\n }))\n return {\n ...commit,\n ops,\n prevData: null,\n }\n }\n\n async processWrites(\n writes: PreparedWrite[],\n swapCommitCid?: Cid,\n ): Promise<CommitDataWithOps> {\n this.db.assertTransaction()\n if (writes.length > 200) {\n throw new InvalidRequestError('Too many writes. Max: 200')\n }\n\n const commit = await this.formatCommit(writes, swapCommitCid)\n // Do not allow commits > 2MB\n if (commit.relevantBlocks.byteSize > 2000000) {\n throw new InvalidRequestError('Too many writes. Max event size: 2MB')\n }\n\n // persist the commit to repo storage\n await this.storage.applyCommit(commit)\n // & send to indexing\n await this.indexWrites(writes, commit.rev)\n // process blobs\n await this.blob.processWriteBlobs(commit.rev, writes)\n\n return commit\n }\n\n async formatCommit(\n writes: PreparedWrite[],\n swapCommit?: Cid,\n ): Promise<CommitDataWithOps> {\n // this is not in a txn, so this won't actually hold the lock,\n // we just check if it is currently held by another txn\n const currRoot = await this.storage.getRootDetailed()\n if (!currRoot) {\n throw new InvalidRequestError(`No repo root found for ${this.did}`)\n }\n if (swapCommit && !currRoot.cid.equals(swapCommit)) {\n throw new BadCommitSwapError(currRoot.cid)\n }\n // cache last commit since there's likely overlap\n await this.storage.cacheRev(currRoot.rev)\n const newRecordCids: Cid[] = []\n const delAndUpdateUris: AtUri[] = []\n const commitOps: CommitOp[] = []\n for (const write of writes) {\n const { action, uri, swapCid } = write\n if (action !== WriteOpAction.Delete) {\n newRecordCids.push(write.cid)\n }\n if (action !== WriteOpAction.Create) {\n delAndUpdateUris.push(uri)\n }\n const record = await this.record.getRecord(uri, null, true)\n const currRecord = record ? parseCid(record.cid) : null\n\n const op: CommitOp = {\n action,\n path: formatDataKey(uri.collection, uri.rkey),\n cid: write.action === WriteOpAction.Delete ? null : write.cid,\n }\n if (currRecord) {\n op.prev = currRecord\n }\n commitOps.push(op)\n if (swapCid !== undefined) {\n if (action === WriteOpAction.Create && swapCid !== null) {\n throw new BadRecordSwapError(currRecord) // There should be no current record for a create\n }\n if (action === WriteOpAction.Update && swapCid === null) {\n throw new BadRecordSwapError(currRecord) // There should be a current record for an update\n }\n if (action === WriteOpAction.Delete && swapCid === null) {\n throw new BadRecordSwapError(currRecord) // There should be a current record for a delete\n }\n if (\n // If we have either a current CID or a swap CID\n (currRecord || swapCid) &&\n // We make sure that both are provided and equal\n !(swapCid && currRecord && currRecord.equals(swapCid))\n ) {\n throw new BadRecordSwapError(currRecord)\n }\n }\n }\n\n const repo = await Repo.load(this.storage, currRoot.cid)\n const prevData = repo.commit.data\n const writeOps = writes.map(writeToOp)\n const commit = await repo.formatCommit(writeOps, this.signingKey)\n\n // find blocks that would be deleted but are referenced by another record\n const dupeRecordCids = await this.getDuplicateRecordCids(\n commit.removedCids.toList(),\n delAndUpdateUris,\n )\n for (const cid of dupeRecordCids) {\n commit.removedCids.delete(cid)\n }\n\n // find blocks that are relevant to ops but not included in diff\n // (for instance a record that was moved but cid stayed the same)\n const newRecordBlocks = commit.relevantBlocks.getMany(newRecordCids)\n if (newRecordBlocks.missing.length > 0) {\n const missingBlocks = await this.storage.getBlocks(\n newRecordBlocks.missing,\n )\n commit.relevantBlocks.addMap(missingBlocks.blocks)\n }\n return {\n ...commit,\n ops: commitOps,\n prevData,\n }\n }\n\n async indexWrites(writes: PreparedWrite[], rev: string) {\n this.db.assertTransaction()\n\n for (const write of writes) {\n if (\n write.action === WriteOpAction.Create ||\n write.action === WriteOpAction.Update\n ) {\n await this.record.indexRecord(\n write.uri,\n write.cid,\n write.record,\n write.action,\n rev,\n this.now,\n )\n } else if (write.action === WriteOpAction.Delete) {\n await this.record.deleteRecord(write.uri)\n }\n }\n }\n\n async getDuplicateRecordCids(\n cids: Cid[],\n touchedUris: AtUri[],\n ): Promise<Cid[]> {\n if (touchedUris.length === 0 || cids.length === 0) {\n return []\n }\n const cidStrs = cids.map((c) => c.toString())\n const uriStrs = touchedUris.map((u) => u.toString())\n const res = await this.db.db\n .selectFrom('record')\n .where('cid', 'in', cidStrs)\n .where('uri', 'not in', uriStrs)\n .select('cid')\n .execute()\n return res.map((row) => parseCid(row.cid))\n }\n}\n"]}
@@ -26,7 +26,7 @@ export default function (server, ctx) {
26
26
  }
27
27
  else if (uri) {
28
28
  const parsedUri = new AtUri(uri);
29
- const [takedown, cid] = await ctx.actorStore.read(parsedUri.hostname, (store) => Promise.all([
29
+ const [takedown, cid] = await ctx.actorStore.read(parsedUri.did, (store) => Promise.all([
30
30
  store.record.getRecordTakedownStatus(parsedUri),
31
31
  store.record.getCurrentRecordCid(parsedUri),
32
32
  ]));
@@ -1 +1 @@
1
- {"version":3,"file":"getSubjectStatus.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/admin/getSubjectStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AAEvE,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAEnD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,C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C;oBACpB,IAAI,GAAG;wBACL,OAAO,EAAE;4BACP,KAAK,EAAE,4BAA4B;4BACnC,GAAG,EAAE,SAAS,CAAC,QAAQ,EAAE;4BACzB,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE;yBACpB;wBACD,QAAQ;qBACT,CAAA;gBACH,CAAC;YACH,CAAC;iBAAM,IAAI,GAAG,EAAE,CAAC;gBACf,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;gBAClE,IAAI,MAAM,EAAE,CAAC;oBACX,IAAI,GAAG;wBACL,OAAO,EAAE;4BACP,KAAK,EAAE,gCAAgC;4BACvC,GAAG,EAAE,GAAG;yBACT;wBACD,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,WAAW,EAAE,MAAM,CAAC,WAAW;qBAChC,CAAA;gBACH,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,mBAAmB,CAAC,qBAAqB,CAAC,CAAA;YACtD,CAAC;YACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAClB,MAAM,IAAI,mBAAmB,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAA;YAChE,CAAC;YACD,OAAO;gBACL,QAAQ,EAAE,kBAA2B;gBACrC,IAAI;aACL,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { parseCid } from '@atproto/lex-data'\nimport { AtUri } from '@atproto/syntax'\nimport { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.admin.getSubjectStatus, {\n auth: ctx.authVerifier.moderator,\n handler: async ({ params }) => {\n const { did, uri, blob } = params\n let body: com.atproto.admin.getSubjectStatus.$OutputBody | null = null\n if (blob) {\n if (!did) {\n throw new InvalidRequestError(\n 'Must provide a did to request blob state',\n )\n }\n const takedown = await ctx.actorStore.read(did, (store) =>\n store.repo.blob.getBlobTakedownStatus(parseCid(blob)),\n )\n if (takedown) {\n body = {\n subject: {\n $type: 'com.atproto.admin.defs#repoBlobRef',\n did: did,\n cid: blob,\n },\n takedown,\n }\n }\n } else if (uri) {\n const parsedUri = new AtUri(uri)\n const [takedown, cid] = await ctx.actorStore.read(\n parsedUri.hostname,\n (store) =>\n Promise.all([\n store.record.getRecordTakedownStatus(parsedUri),\n store.record.getCurrentRecordCid(parsedUri),\n ]),\n )\n if (cid && takedown) {\n body = {\n subject: {\n $type: 'com.atproto.repo.strongRef',\n uri: parsedUri.toString(),\n cid: cid.toString(),\n },\n takedown,\n }\n }\n } else if (did) {\n const status = await ctx.accountManager.getAccountAdminStatus(did)\n if (status) {\n body = {\n subject: {\n $type: 'com.atproto.admin.defs#repoRef',\n did: did,\n },\n takedown: status.takedown,\n deactivated: status.deactivated,\n }\n }\n } else {\n throw new InvalidRequestError('No provided subject')\n }\n if (body === null) {\n throw new InvalidRequestError('Subject not found', 'NotFound')\n }\n return {\n encoding: 'application/json' as const,\n body,\n }\n },\n })\n}\n"]}
1
+ {"version":3,"file":"getSubjectStatus.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/admin/getSubjectStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AAEvE,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAEnD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE;QAC7C,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,SAAS;QAChC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE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GAAG,CAAC,QAAQ,EAAE;yBACpB;wBACD,QAAQ;qBACT,CAAA;gBACH,CAAC;YACH,CAAC;iBAAM,IAAI,GAAG,EAAE,CAAC;gBACf,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;gBAClE,IAAI,MAAM,EAAE,CAAC;oBACX,IAAI,GAAG;wBACL,OAAO,EAAE;4BACP,KAAK,EAAE,gCAAgC;4BACvC,GAAG,EAAE,GAAG;yBACT;wBACD,QAAQ,EAAE,MAAM,CAAC,QAAQ;wBACzB,WAAW,EAAE,MAAM,CAAC,WAAW;qBAChC,CAAA;gBACH,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,mBAAmB,CAAC,qBAAqB,CAAC,CAAA;YACtD,CAAC;YACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAClB,MAAM,IAAI,mBAAmB,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAA;YAChE,CAAC;YACD,OAAO;gBACL,QAAQ,EAAE,kBAA2B;gBACrC,IAAI;aACL,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { parseCid } from '@atproto/lex-data'\nimport { AtUri } from '@atproto/syntax'\nimport { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.admin.getSubjectStatus, {\n auth: ctx.authVerifier.moderator,\n handler: async ({ params }) => {\n const { did, uri, blob } = params\n let body: com.atproto.admin.getSubjectStatus.$OutputBody | null = null\n if (blob) {\n if (!did) {\n throw new InvalidRequestError(\n 'Must provide a did to request blob state',\n )\n }\n const takedown = await ctx.actorStore.read(did, (store) =>\n store.repo.blob.getBlobTakedownStatus(parseCid(blob)),\n )\n if (takedown) {\n body = {\n subject: {\n $type: 'com.atproto.admin.defs#repoBlobRef',\n did: did,\n cid: blob,\n },\n takedown,\n }\n }\n } else if (uri) {\n const parsedUri = new AtUri(uri)\n const [takedown, cid] = await ctx.actorStore.read(\n parsedUri.did,\n (store) =>\n Promise.all([\n store.record.getRecordTakedownStatus(parsedUri),\n store.record.getCurrentRecordCid(parsedUri),\n ]),\n )\n if (cid && takedown) {\n body = {\n subject: {\n $type: 'com.atproto.repo.strongRef',\n uri: parsedUri.toString(),\n cid: cid.toString(),\n },\n takedown,\n }\n }\n } else if (did) {\n const status = await ctx.accountManager.getAccountAdminStatus(did)\n if (status) {\n body = {\n subject: {\n $type: 'com.atproto.admin.defs#repoRef',\n did: did,\n },\n takedown: status.takedown,\n deactivated: status.deactivated,\n }\n }\n } else {\n throw new InvalidRequestError('No provided subject')\n }\n if (body === null) {\n throw new InvalidRequestError('Subject not found', 'NotFound')\n }\n return {\n encoding: 'application/json' as const,\n body,\n }\n },\n })\n}\n"]}
@@ -16,7 +16,7 @@ export default function (server, ctx) {
16
16
  }
17
17
  else if (com.atproto.repo.strongRef.$isTypeOf(subject)) {
18
18
  const uri = new AtUri(subject.uri);
19
- await ctx.actorStore.transact(uri.hostname, async (store) => {
19
+ await ctx.actorStore.transact(uri.did, async (store) => {
20
20
  await store.record.updateRecordTakedownStatus(uri, takedown);
21
21
  });
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"updateSubjectStatus.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/admin/updateSubjectStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AAEvE,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAEnD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KA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Error, type Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.admin.updateSubjectStatus, {\n auth: ctx.authVerifier.moderator,\n handler: async ({ input }) => {\n const { subject, takedown, deactivated } = input.body\n\n if (takedown?.applied && deactivated != null && !deactivated.applied) {\n throw new InvalidRequestError(\n `Cannot activate and takedown an account at the same time`,\n )\n }\n\n if (takedown) {\n if (com.atproto.admin.defs.repoRef.$isTypeOf(subject)) {\n await ctx.accountManager.takedownAccount(subject.did, takedown)\n } else if (com.atproto.repo.strongRef.$isTypeOf(subject)) {\n const uri = new AtUri(subject.uri)\n await ctx.actorStore.transact(uri.hostname, async (store) => {\n await store.record.updateRecordTakedownStatus(uri, takedown)\n })\n } else if (com.atproto.admin.defs.repoBlobRef.$isTypeOf(subject)) {\n await ctx.actorStore.transact(subject.did, async (store) => {\n await store.repo.blob.updateBlobTakedownStatus(\n parseCid(subject.cid),\n takedown,\n )\n })\n } else {\n throw new InvalidRequestError(`Invalid subject (${subject.$type})`)\n }\n }\n\n if (deactivated) {\n if (com.atproto.admin.defs.repoRef.$isTypeOf(subject)) {\n if (deactivated.applied) {\n await ctx.accountManager.deactivateAccount(subject.did)\n } else {\n await ctx.accountManager.activateAccount(subject.did)\n }\n }\n }\n\n // @NOTE accountManager will sequence an account status when updating the\n // status, so we don't *need* to sequence the account status here.\n // However, this endpoint historically has always sequenced the account\n // status.\n if (!takedown && !deactivated) {\n if (com.atproto.admin.defs.repoRef.$isTypeOf(subject)) {\n await ctx.accountManager.sequenceAccountStatus(subject.did)\n }\n }\n\n return {\n encoding: 'application/json' as const,\n body: {\n subject,\n takedown,\n },\n }\n },\n })\n}\n"]}
1
+ {"version":3,"file":"updateSubjectStatus.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/admin/updateSubjectStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,m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AAC,OAAO,CAAC,GAAG,CAAC,CAAA;gBAC7D,CAAC;YACH,CAAC;YAED,OAAO;gBACL,QAAQ,EAAE,kBAA2B;gBACrC,IAAI,EAAE;oBACJ,OAAO;oBACP,QAAQ;iBACT;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { parseCid } from '@atproto/lex-data'\nimport { AtUri } from '@atproto/syntax'\nimport { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.admin.updateSubjectStatus, {\n auth: ctx.authVerifier.moderator,\n handler: async ({ input }) => {\n const { subject, takedown, deactivated } = input.body\n\n if (takedown?.applied && deactivated != null && !deactivated.applied) {\n throw new InvalidRequestError(\n `Cannot activate and takedown an account at the same time`,\n )\n }\n\n if (takedown) {\n if (com.atproto.admin.defs.repoRef.$isTypeOf(subject)) {\n await ctx.accountManager.takedownAccount(subject.did, takedown)\n } else if (com.atproto.repo.strongRef.$isTypeOf(subject)) {\n const uri = new AtUri(subject.uri)\n await ctx.actorStore.transact(uri.did, async (store) => {\n await store.record.updateRecordTakedownStatus(uri, takedown)\n })\n } else if (com.atproto.admin.defs.repoBlobRef.$isTypeOf(subject)) {\n await ctx.actorStore.transact(subject.did, async (store) => {\n await store.repo.blob.updateBlobTakedownStatus(\n parseCid(subject.cid),\n takedown,\n )\n })\n } else {\n throw new InvalidRequestError(`Invalid subject (${subject.$type})`)\n }\n }\n\n if (deactivated) {\n if (com.atproto.admin.defs.repoRef.$isTypeOf(subject)) {\n if (deactivated.applied) {\n await ctx.accountManager.deactivateAccount(subject.did)\n } else {\n await ctx.accountManager.activateAccount(subject.did)\n }\n }\n }\n\n // @NOTE accountManager will sequence an account status when updating the\n // status, so we don't *need* to sequence the account status here.\n // However, this endpoint historically has always sequenced the account\n // status.\n if (!takedown && !deactivated) {\n if (com.atproto.admin.defs.repoRef.$isTypeOf(subject)) {\n await ctx.accountManager.sequenceAccountStatus(subject.did)\n }\n }\n\n return {\n encoding: 'application/json' as const,\n body: {\n subject,\n takedown,\n },\n }\n },\n })\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"activateAccount.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/activateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QA+BvD"}
1
+ {"version":3,"file":"activateAccount.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/activateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAiCvD"}
@@ -5,8 +5,10 @@ export default function (server, ctx) {
5
5
  const { entrywayClient } = ctx;
6
6
  const auth = ctx.authVerifier.authorization({
7
7
  scopes: ACCESS_FULL,
8
+ // OAuth authorization flows are refused for deactivated accounts, so a
9
+ // client cannot obtain fresh credentials to reactivate an account with.
8
10
  authorize: () => {
9
- throw new ForbiddenError('OAuth credentials are not supported for this endpoint');
11
+ throw new ForbiddenError('Account reactivation is not available with OAuth credentials. Sign in to your account management page to reactivate.');
10
12
  },
11
13
  });
12
14
  if (entrywayClient) {
@@ -1 +1 @@
1
- {"version":3,"file":"activateAccount.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/activateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAe,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAEnD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;IAE9B,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;QAC1C,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,GAAG,EAAE;YACd,MAAM,IAAI,cAAc,CACtB,uDAAuD,CACxD,CAAA;QACH,CAAC;KACF,CAAC,CAAA;IAEF,IAAI,cAAc,EAAE,CAAC;QACnB,4HAA4H;QAC5H,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE;YAC7C,IAAI;YACJ,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBACzB,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAA;gBACpD,MAAM,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE;oBAC5D,OAAO;iBACR,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE;YAC7C,IAAI;YACJ,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC1B,MAAM,GAAG,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;YAChE,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { ForbiddenError, type Server } from '@atproto/xrpc-server'\nimport { ACCESS_FULL } from '../../../../auth-scope.js'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { entrywayClient } = ctx\n\n const auth = ctx.authVerifier.authorization({\n scopes: ACCESS_FULL,\n authorize: () => {\n throw new ForbiddenError(\n 'OAuth credentials are not supported for this endpoint',\n )\n },\n })\n\n if (entrywayClient) {\n // in the case of entryway, the full flow is activateAccount (PDS) -> activateAccount (Entryway) -> updateSubjectStatus(PDS)\n server.add(com.atproto.server.activateAccount, {\n auth,\n handler: async ({ req }) => {\n const { headers } = ctx.entrywayPassthruHeaders(req)\n await entrywayClient.xrpc(com.atproto.server.activateAccount, {\n headers,\n })\n },\n })\n } else {\n server.add(com.atproto.server.activateAccount, {\n auth,\n handler: async ({ auth }) => {\n await ctx.accountManager.activateAccount(auth.credentials.did)\n },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"activateAccount.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/activateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAe,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAEvD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAEnD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;IAE9B,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;QAC1C,MAAM,EAAE,WAAW;QACnB,uEAAuE;QACvE,wEAAwE;QACxE,SAAS,EAAE,GAAG,EAAE;YACd,MAAM,IAAI,cAAc,CACtB,sHAAsH,CACvH,CAAA;QACH,CAAC;KACF,CAAC,CAAA;IAEF,IAAI,cAAc,EAAE,CAAC;QACnB,4HAA4H;QAC5H,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE;YAC7C,IAAI;YACJ,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBACzB,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAA;gBACpD,MAAM,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE;oBAC5D,OAAO;iBACR,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE;YAC7C,IAAI;YACJ,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC1B,MAAM,GAAG,CAAC,cAAc,CAAC,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;YAChE,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { ForbiddenError, type Server } from '@atproto/xrpc-server'\nimport { ACCESS_FULL } from '../../../../auth-scope.js'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { entrywayClient } = ctx\n\n const auth = ctx.authVerifier.authorization({\n scopes: ACCESS_FULL,\n // OAuth authorization flows are refused for deactivated accounts, so a\n // client cannot obtain fresh credentials to reactivate an account with.\n authorize: () => {\n throw new ForbiddenError(\n 'Account reactivation is not available with OAuth credentials. Sign in to your account management page to reactivate.',\n )\n },\n })\n\n if (entrywayClient) {\n // in the case of entryway, the full flow is activateAccount (PDS) -> activateAccount (Entryway) -> updateSubjectStatus(PDS)\n server.add(com.atproto.server.activateAccount, {\n auth,\n handler: async ({ req }) => {\n const { headers } = ctx.entrywayPassthruHeaders(req)\n await entrywayClient.xrpc(com.atproto.server.activateAccount, {\n headers,\n })\n },\n })\n } else {\n server.add(com.atproto.server.activateAccount, {\n auth,\n handler: async ({ auth }) => {\n await ctx.accountManager.activateAccount(auth.credentials.did)\n },\n })\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type Server } from '@atproto/xrpc-server';
1
+ import type { Server } from '@atproto/xrpc-server';
2
2
  import type { AppContext } from '../../../../context.js';
3
3
  export default function (server: Server, ctx: AppContext): void;
4
4
  //# sourceMappingURL=deactivateAccount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deactivateAccount.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/deactivateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAmCvD"}
1
+ {"version":3,"file":"deactivateAccount.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/deactivateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QA6CvD"}
@@ -1,4 +1,3 @@
1
- import { ForbiddenError } from '@atproto/xrpc-server';
2
1
  import { ACCESS_FULL, AuthScope } from '../../../../auth-scope.js';
3
2
  import { com } from '../../../../lexicons/index.js';
4
3
  export default function (server, ctx) {
@@ -6,16 +5,18 @@ export default function (server, ctx) {
6
5
  const auth = ctx.authVerifier.authorization({
7
6
  additional: [AuthScope.Takendown],
8
7
  scopes: ACCESS_FULL,
9
- authorize: () => {
10
- throw new ForbiddenError('OAuth credentials are not supported for this endpoint');
8
+ authorize: (permissions) => {
9
+ permissions.assertAccount({ attr: 'status', action: 'manage' });
11
10
  },
12
11
  });
13
12
  if (entrywayClient) {
14
13
  server.add(com.atproto.server.deactivateAccount, {
15
14
  auth,
16
15
  // in the case of entryway, the full flow is deactivateAccount (PDS) -> deactivateAccount (Entryway) -> updateSubjectStatus(PDS)
17
- handler: async ({ input: { body }, req }) => {
18
- const { headers } = ctx.entrywayPassthruHeaders(req);
16
+ handler: async ({ input: { body }, auth, req }) => {
17
+ // DPoP bound credentials cannot be forwarded as-is, so OAuth callers
18
+ // are authenticated towards the entryway using entryway auth instead.
19
+ const { headers } = await ctx.entrywayAuthHeaders(req, auth.credentials.did, com.atproto.server.deactivateAccount.$lxm);
19
20
  await entrywayClient.xrpc(com.atproto.server.deactivateAccount, {
20
21
  headers,
21
22
  body,
@@ -28,6 +29,11 @@ export default function (server, ctx) {
28
29
  auth,
29
30
  handler: async ({ input: { body }, auth }) => {
30
31
  await ctx.accountManager.deactivateAccount(auth.credentials.did, {
32
+ // For legacy reasons we check if it's an oauth credential before passing
33
+ // deleteCredentials since it did not before.
34
+ // @TODO Investiage why the deleteCredentials was not passed previously and
35
+ // address it in a different line of work
36
+ deleteCredentials: auth.credentials.type === 'oauth',
31
37
  deleteAfter: body.deleteAfter ?? null,
32
38
  });
33
39
  },
@@ -1 +1 @@
1
- {"version":3,"file":"deactivateAccount.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/deactivateAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAe,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAEnD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;IAE9B,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;QAC1C,UAAU,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC;QACjC,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,GAAG,EAAE;YACd,MAAM,IAAI,cAAc,CACtB,uDAAuD,CACxD,CAAA;QACH,CAAC;KACF,CAAC,CAAA;IAEF,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE;YAC/C,IAAI;YACJ,gIAAgI;YAChI,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAA;gBACpD,MAAM,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE;oBAC9D,OAAO;oBACP,IAAI;iBACL,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE;YAC/C,IAAI;YACJ,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC3C,MAAM,GAAG,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE;oBAC/D,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI;iBACtC,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { ForbiddenError, type Server } from '@atproto/xrpc-server'\nimport { ACCESS_FULL, AuthScope } from '../../../../auth-scope.js'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { entrywayClient } = ctx\n\n const auth = ctx.authVerifier.authorization({\n additional: [AuthScope.Takendown],\n scopes: ACCESS_FULL,\n authorize: () => {\n throw new ForbiddenError(\n 'OAuth credentials are not supported for this endpoint',\n )\n },\n })\n\n if (entrywayClient) {\n server.add(com.atproto.server.deactivateAccount, {\n auth,\n // in the case of entryway, the full flow is deactivateAccount (PDS) -> deactivateAccount (Entryway) -> updateSubjectStatus(PDS)\n handler: async ({ input: { body }, req }) => {\n const { headers } = ctx.entrywayPassthruHeaders(req)\n await entrywayClient.xrpc(com.atproto.server.deactivateAccount, {\n headers,\n body,\n })\n },\n })\n } else {\n server.add(com.atproto.server.deactivateAccount, {\n auth,\n handler: async ({ input: { body }, auth }) => {\n await ctx.accountManager.deactivateAccount(auth.credentials.did, {\n deleteAfter: body.deleteAfter ?? null,\n })\n },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"deactivateAccount.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/deactivateAccount.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAElE,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AAEnD,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;IAE9B,MAAM,IAAI,GAAG,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;QAC1C,UAAU,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC;QACjC,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE;YACzB,WAAW,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;QACjE,CAAC;KACF,CAAC,CAAA;IAEF,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE;YAC/C,IAAI;YACJ,gIAAgI;YAChI,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE;gBAChD,qEAAqE;gBACrE,sEAAsE;gBACtE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,GAAG,CAAC,mBAAmB,CAC/C,GAAG,EACH,IAAI,CAAC,WAAW,CAAC,GAAG,EACpB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAC1C,CAAA;gBAED,MAAM,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE;oBAC9D,OAAO;oBACP,IAAI;iBACL,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE;YAC/C,IAAI;YACJ,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;gBAC3C,MAAM,GAAG,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE;oBAC/D,yEAAyE;oBACzE,6CAA6C;oBAC7C,2EAA2E;oBAC3E,yCAAyC;oBACzC,iBAAiB,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,KAAK,OAAO;oBACpD,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI;iBACtC,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { Server } from '@atproto/xrpc-server'\nimport { ACCESS_FULL, AuthScope } from '../../../../auth-scope.js'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { entrywayClient } = ctx\n\n const auth = ctx.authVerifier.authorization({\n additional: [AuthScope.Takendown],\n scopes: ACCESS_FULL,\n authorize: (permissions) => {\n permissions.assertAccount({ attr: 'status', action: 'manage' })\n },\n })\n\n if (entrywayClient) {\n server.add(com.atproto.server.deactivateAccount, {\n auth,\n // in the case of entryway, the full flow is deactivateAccount (PDS) -> deactivateAccount (Entryway) -> updateSubjectStatus(PDS)\n handler: async ({ input: { body }, auth, req }) => {\n // DPoP bound credentials cannot be forwarded as-is, so OAuth callers\n // are authenticated towards the entryway using entryway auth instead.\n const { headers } = await ctx.entrywayAuthHeaders(\n req,\n auth.credentials.did,\n com.atproto.server.deactivateAccount.$lxm,\n )\n\n await entrywayClient.xrpc(com.atproto.server.deactivateAccount, {\n headers,\n body,\n })\n },\n })\n } else {\n server.add(com.atproto.server.deactivateAccount, {\n auth,\n handler: async ({ input: { body }, auth }) => {\n await ctx.accountManager.deactivateAccount(auth.credentials.did, {\n // For legacy reasons we check if it's an oauth credential before passing\n // deleteCredentials since it did not before.\n // @TODO Investiage why the deleteCredentials was not passed previously and\n // address it in a different line of work\n deleteCredentials: auth.credentials.type === 'oauth',\n deleteAfter: body.deleteAfter ?? null,\n })\n },\n })\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,OAAO,MAAM,SAAS,CAAA;AAClC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAGpC,OAAO,KAAK,KAAK,MAAM,MAAM,QAAQ,CAAA;AAErC,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAIL,aAAa,EACd,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAK9C,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+6,8 @@ import { KmsKeypair, S3BlobStore } from '@atproto/aws';
6
6
  import * as crypto from '@atproto/crypto';
7
7
  import { IdResolver } from '@atproto/identity';
8
8
  import { Client } from '@atproto/lex';
9
- import { AccessTokenMode, JoseKey, LexResolver, OAuthProvider, } from '@atproto/oauth-provider/provider';
9
+ import { parseCid } from '@atproto/lex-data';
10
+ import { AccessTokenMode, JoseKey, LexResolver, LexResolverError, OAuthProvider, } from '@atproto/oauth-provider/provider';
10
11
  import { OAuthVerifier } from '@atproto/oauth-provider/verifier';
11
12
  import { createServiceAuthHeaders, createServiceJwt, } from '@atproto/xrpc-server';
12
13
  import { safeFetchWrap } from '@atproto-labs/fetch-node';
@@ -176,6 +177,63 @@ export class AppContext {
176
177
  : await crypto.Secp256k1Keypair.import(secrets.plcRotationKey.privateKeyHex);
177
178
  const accountManager = new AccountManager(cfg, actorStore, idResolver, jwtSecretKey, mailer, sequencer, plcClient, plcRotationKey);
178
179
  await accountManager.migrateOrThrow();
180
+ // @TODO Use this lexResolver instance to implement validation of records
181
+ // created with the "validate" option. Before doing so, ensure that 1) a
182
+ // didCache is provided, and 2) that nsid->lexicon are cached.
183
+ const lexResolver = new LexResolver({
184
+ fetch: safeFetch,
185
+ didCache: undefined, // @TODO provide a dedicated cache
186
+ plcDirectoryUrl: cfg.identity.plcUrl,
187
+ hooks: {
188
+ // @NOTE Lexicons hosted by this PDS are read straight from the
189
+ // actor store. Fetching them over the network would require this
190
+ // server to reach its own public endpoint, which is not
191
+ // guaranteed to work (SSRF protection, missing NAT hairpin,
192
+ // internal reverse proxies, ...).
193
+ onFetch: async ({ uri, did, nsid, signal }) => {
194
+ const account = await accountManager.getAccount(did, {
195
+ includeDeactivated: true,
196
+ includeTakenDown: true,
197
+ });
198
+ signal?.throwIfAborted();
199
+ // Mirror what com.atproto.sync.getRecord would answer to an
200
+ // unauthenticated requester
201
+ if (account?.takedownRef) {
202
+ throw new LexResolverError(nsid, `Repo is not available: ${did}`);
203
+ }
204
+ // Not hosted here: fall back to the network resolution
205
+ if (!account || account.deactivatedAt)
206
+ return undefined;
207
+ const record = await actorStore.read(account.did, (store) => {
208
+ return store.record.getRecord(uri, null);
209
+ });
210
+ if (!record || record.takedownRef != null) {
211
+ throw new LexResolverError(nsid, `Lexicon record not found at ${uri}`);
212
+ }
213
+ return {
214
+ cid: parseCid(record.cid),
215
+ record: record.value,
216
+ };
217
+ },
218
+ onFetchResult({ uri, cid, source }) {
219
+ lexiconResolverLogger.info({ uri: uri.toString(), cid: cid.toString(), source }, 'Fetched lexicon');
220
+ },
221
+ onFetchError({ err, uri }) {
222
+ lexiconResolverLogger.error({ uri: uri.toString(), err }, 'Lexicon fetch error');
223
+ },
224
+ onResolveAuthority: ({ nsid }) => {
225
+ lexiconResolverLogger.debug({ nsid: nsid.toString() }, 'Resolving lexicon DID authority');
226
+ // Override the lexicon did resolution to point to a custom PDS
227
+ return cfg.lexicon.didAuthority;
228
+ },
229
+ onResolveAuthorityResult({ nsid, did, source }) {
230
+ lexiconResolverLogger.info({ nsid: nsid.toString(), did, source }, 'Resolved lexicon DID');
231
+ },
232
+ onResolveAuthorityError({ nsid, err }) {
233
+ lexiconResolverLogger.error({ nsid: nsid.toString(), err }, 'Lexicon DID resolution error');
234
+ },
235
+ },
236
+ });
179
237
  const localViewer = LocalViewer.creator(accountManager, imageUrlBuilder, bskyAppView);
180
238
  // An agent for performing HTTP requests based on user provided URLs.
181
239
  const proxyAgent = buildProxyAgent(cfg.proxy);
@@ -191,29 +249,7 @@ export class AppContext {
191
249
  hcaptcha: cfg.oauth.provider.hcaptcha,
192
250
  branding: cfg.oauth.provider.branding,
193
251
  safeFetch,
194
- lexResolver: new LexResolver({
195
- fetch: safeFetch,
196
- plcDirectoryUrl: cfg.identity.plcUrl,
197
- hooks: {
198
- onResolveAuthority: ({ nsid }) => {
199
- lexiconResolverLogger.debug({ nsid: nsid.toString() }, 'Resolving lexicon DID authority');
200
- // Override the lexicon did resolution to point to a custom PDS
201
- return cfg.lexicon.didAuthority;
202
- },
203
- onResolveAuthorityResult({ nsid, did }) {
204
- lexiconResolverLogger.info({ nsid: nsid.toString(), did }, 'Resolved lexicon DID');
205
- },
206
- onResolveAuthorityError({ nsid, err }) {
207
- lexiconResolverLogger.error({ nsid: nsid.toString(), err }, 'Lexicon DID resolution error');
208
- },
209
- onFetchResult({ uri, cid }) {
210
- lexiconResolverLogger.info({ uri: uri.toString(), cid: cid.toString() }, 'Fetched lexicon');
211
- },
212
- onFetchError({ err, uri }) {
213
- lexiconResolverLogger.error({ uri: uri.toString(), err }, 'Lexicon fetch error');
214
- },
215
- },
216
- }),
252
+ lexResolver,
217
253
  metadata: {
218
254
  protected_resources: [new URL(cfg.oauth.issuer).origin],
219
255
  },