@atproto/pds 0.5.55 → 0.5.56

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 (55) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/api/app/bsky/actor/putPreferences.d.ts.map +1 -1
  3. package/dist/api/app/bsky/actor/putPreferences.js +3 -0
  4. package/dist/api/app/bsky/actor/putPreferences.js.map +1 -1
  5. package/dist/api/com/atproto/admin/deleteAccount.js +1 -1
  6. package/dist/api/com/atproto/admin/deleteAccount.js.map +1 -1
  7. package/dist/api/com/atproto/admin/getSubjectStatus.js +1 -1
  8. package/dist/api/com/atproto/admin/getSubjectStatus.js.map +1 -1
  9. package/dist/api/com/atproto/admin/updateAccountHandle.js +1 -1
  10. package/dist/api/com/atproto/admin/updateAccountHandle.js.map +1 -1
  11. package/dist/api/com/atproto/admin/updateSubjectStatus.js +1 -1
  12. package/dist/api/com/atproto/admin/updateSubjectStatus.js.map +1 -1
  13. package/dist/api/com/atproto/server/createAccount.d.ts.map +1 -1
  14. package/dist/api/com/atproto/server/createAccount.js +13 -2
  15. package/dist/api/com/atproto/server/createAccount.js.map +1 -1
  16. package/dist/api/com/atproto/server/reserveSigningKey.d.ts.map +1 -1
  17. package/dist/api/com/atproto/server/reserveSigningKey.js +3 -0
  18. package/dist/api/com/atproto/server/reserveSigningKey.js.map +1 -1
  19. package/dist/auth-output.d.ts +6 -0
  20. package/dist/auth-output.d.ts.map +1 -1
  21. package/dist/auth-output.js.map +1 -1
  22. package/dist/auth-verifier.d.ts +21 -2
  23. package/dist/auth-verifier.d.ts.map +1 -1
  24. package/dist/auth-verifier.js +98 -0
  25. package/dist/auth-verifier.js.map +1 -1
  26. package/dist/config/config.d.ts +11 -0
  27. package/dist/config/config.d.ts.map +1 -1
  28. package/dist/config/config.js +2 -0
  29. package/dist/config/config.js.map +1 -1
  30. package/dist/config/env.d.ts +2 -0
  31. package/dist/config/env.d.ts.map +1 -1
  32. package/dist/config/env.js +2 -0
  33. package/dist/config/env.js.map +1 -1
  34. package/dist/context.d.ts.map +1 -1
  35. package/dist/context.js +8 -2
  36. package/dist/context.js.map +1 -1
  37. package/dist/entryway-attribution.d.ts +39 -0
  38. package/dist/entryway-attribution.d.ts.map +1 -0
  39. package/dist/entryway-attribution.js +101 -0
  40. package/dist/entryway-attribution.js.map +1 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +10 -1
  43. package/dist/index.js.map +1 -1
  44. package/dist/logger.d.ts.map +1 -1
  45. package/dist/logger.js +8 -1
  46. package/dist/logger.js.map +1 -1
  47. package/dist/rate-limits.d.ts +2 -2
  48. package/dist/rate-limits.d.ts.map +1 -1
  49. package/dist/rate-limits.js +6 -6
  50. package/dist/rate-limits.js.map +1 -1
  51. package/dist/util/ip.d.ts +8 -0
  52. package/dist/util/ip.d.ts.map +1 -0
  53. package/dist/util/ip.js +34 -0
  54. package/dist/util/ip.js.map +1 -0
  55. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atproto/pds
2
2
 
3
+ ## 0.5.56
4
+
5
+ ### Patch Changes
6
+
7
+ - [#5846](https://github.com/bluesky-social/atproto/pull/5846) [`39d702c`](https://github.com/bluesky-social/atproto/commit/39d702c851d469d7340fc0c5946959063769f849) Thanks [@amckinley](https://github.com/amckinley)! - Add `PDS_ENTRYWAY_API_URL`, the URL this PDS uses for its own requests to the entryway, e.g. a local proxy that adds mTLS. It defaults to `PDS_ENTRYWAY_URL`, which remains the entryway's public URL: the OAuth issuer and the authorization server the PDS advertises.
8
+
9
+ - [#5847](https://github.com/bluesky-social/atproto/pull/5847) [`0849c24`](https://github.com/bluesky-social/atproto/commit/0849c24d492a9286e90c1734f2483d6ed7423d73) Thanks [@amckinley](https://github.com/amckinley)! - Accept the entryway's service JWT on `com.atproto.server.createAccount` when the PDS runs behind an entryway, on the same terms as the other entryway-called routes (`lxm` `com.atproto.server.createAccount`, `aud` this PDS's service DID); a valid one bypasses rate limits. Behind an entryway, a bearer token on this route must be such a JWT: other bearer tokens are no longer verified as user service auth. Unauthenticated calls are still accepted, even with `PDS_ENTRYWAY_REQUIRE_SERVICE_AUTH=true`, so that the entryway can start signing this call; enforcement under that setting follows in a later release, once it does. PDSes without entryway configuration are unaffected.
10
+
11
+ - [#5845](https://github.com/bluesky-social/atproto/pull/5845) [`7f619af`](https://github.com/bluesky-social/atproto/commit/7f619aff86f452f1ac2320b6926d88a8968b319d) Thanks [@amckinley](https://github.com/amckinley)! - Attribute entryway traffic for rate limiting by signed tokens instead of by IP address. A request that a route authenticates with the entryway service JWT bypasses rate limits; routes that do not authenticate apply them as usual. A user request the entryway proxies may carry an `x-entryway-relay` token (ES256K, `typ: "JWT"`, issued by `PDS_ENTRYWAY_DID` for this PDS's service DID, no `lxm`, at most 120 seconds long, signed with the `PDS_ENTRYWAY_JWT_VERIFY_KEY_K256_PUBLIC_KEY_HEX` key); when it verifies, the request's IP address (`req.ip`) becomes the token's `client_ip`, in canonical form, so rate limits key on the end user. Invalid relay tokens are ignored and logged at debug level with a short reason code, and request logs redact the `x-entryway-relay` header. `com.atproto.admin.getSubjectStatus` now also accepts the entryway service JWT. `PDS_RATE_LIMIT_BYPASS_IPS` keeps working as before, and PDSes without entryway configuration are unaffected.
12
+
13
+ - [#5844](https://github.com/bluesky-social/atproto/pull/5844) [`1033419`](https://github.com/bluesky-social/atproto/commit/103341946f8bdb2abb5409866b234ad17812f7b8) Thanks [@amckinley](https://github.com/amckinley)! - Accept short-lived service JWTs from the entryway on `com.atproto.admin.deleteAccount`, `com.atproto.admin.updateAccountHandle`, `com.atproto.admin.updateSubjectStatus` and `com.atproto.server.reserveSigningKey`. Tokens must be ES256K with `typ: "JWT"`, issued by `PDS_ENTRYWAY_DID` for this PDS's service DID, bound to the called method through `lxm`, live at most 5 minutes, and be signed with the `PDS_ENTRYWAY_JWT_VERIFY_KEY_K256_PUBLIC_KEY_HEX` key. Setting `PDS_ENTRYWAY_REQUIRE_SERVICE_AUTH=true` makes these routes refuse the admin password and unauthenticated callers; `updateSubjectStatus` still accepts the moderation service. PDSes without entryway configuration are unaffected.
14
+
15
+ - [#5852](https://github.com/bluesky-social/atproto/pull/5852) [`870a534`](https://github.com/bluesky-social/atproto/commit/870a5346d0e9374cb99e60bf88a98c27d3d34cfe) Thanks [@estrattonbailey](https://github.com/estrattonbailey)! - Increase the app.bsky.actor.putPreferences JSON request-body limit from 150 KiB to 300 KiB without changing the global PDS limit.
16
+
17
+ - [#5762](https://github.com/bluesky-social/atproto/pull/5762) [`7a46712`](https://github.com/bluesky-social/atproto/commit/7a467120982d9ff1559afeb3a26989dad5877d17) Thanks [@haileyok](https://github.com/haileyok)! - Redact cookie and set-cookie headers in HTTP request and response logs.
18
+ - Updated dependencies [[`ac78dcf`](https://github.com/bluesky-social/atproto/commit/ac78dcf2cba6505f822b6db093a14d489eee1c49), [`7a46712`](https://github.com/bluesky-social/atproto/commit/7a467120982d9ff1559afeb3a26989dad5877d17)]:
19
+ - @atproto/lex-cbor@0.1.10
20
+ - @atproto/common@0.8.10
21
+ - @atproto/repo@0.11.5
22
+ - @atproto/xrpc-server@0.13.10
23
+ - @atproto/aws@0.3.24
24
+ - @atproto/oauth-provider@0.25.6
25
+ - @atproto-labs/xrpc-utils@0.1.31
26
+
3
27
  ## 0.5.55
4
28
 
5
29
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"putPreferences.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/actor/putPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAGvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAQxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAkDvD"}
1
+ {"version":3,"file":"putPreferences.d.ts","sourceRoot":"","sources":["../../../../../src/api/app/bsky/actor/putPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAGvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAQxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAqDvD"}
@@ -15,6 +15,9 @@ export default function (server, ctx) {
15
15
  permissions.assertRpc({ aud, lxm });
16
16
  },
17
17
  }),
18
+ opts: {
19
+ jsonLimit: 300 * 1024,
20
+ },
18
21
  handler: async ({ req, auth, input }) => {
19
22
  const { did } = auth.credentials;
20
23
  // If the request has a proxy header different from the bsky app view,
@@ -1 +1 @@
1
- {"version":3,"file":"putPreferences.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/actor/putPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,4BAA4B,CAAA;AAEnC,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,CAAA;IAC3B,IAAI,CAAC,WAAW;QAAE,OAAM;IAExB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;QACxC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;YACnC,aAAa,EAAE,IAAI;YACnB,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBAClC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAA;gBAC9C,MAAM,GAAG,GAAG,cAAc,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AAU,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;gBACpD,MAAM,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,UAAU,EAAE;oBACjE,aAAa;iBACd,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport type { AccountPreference } from '../../../../actor-store/preference/reader.js'\nimport { isAccessFull } from '../../../../auth-scope.js'\nimport type { AppContext } from '../../../../context.js'\nimport { app } from '../../../../lexicons/index.js'\nimport {\n bareDidFromProxyTo,\n computeProxyTo,\n pipethrough,\n} from '../../../../pipethrough.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { bskyAppView } = ctx\n if (!bskyAppView) return\n\n server.add(app.bsky.actor.putPreferences, {\n auth: ctx.authVerifier.authorization({\n checkTakedown: true,\n authorize: (permissions, { req }) => {\n const lxm = app.bsky.actor.putPreferences.$lxm\n const aud = computeProxyTo(ctx, req, lxm)\n permissions.assertRpc({ aud, lxm })\n },\n }),\n handler: async ({ req, auth, input }) => {\n const { did } = auth.credentials\n\n // If the request has a proxy header different from the bsky app view,\n // we need to proxy the request to the requested app view.\n // @TODO This behavior should not be implemented as part of the XRPC framework\n const lxm = app.bsky.actor.putPreferences.$lxm\n const aud = computeProxyTo(ctx, req, lxm)\n if (aud !== `${bskyAppView.did}#bsky_appview`) {\n // Phase 1 of service auth updates: outbound JWT keeps bare-DID aud.\n return pipethrough(ctx, req, {\n iss: did,\n aud: bareDidFromProxyTo(aud),\n lxm,\n })\n }\n\n const checkedPreferences: AccountPreference[] = []\n for (const pref of input.body.preferences) {\n if (typeof pref.$type === 'string') {\n checkedPreferences.push(pref as AccountPreference)\n } else {\n throw new InvalidRequestError('Preference is missing a $type')\n }\n }\n\n const hasAccessFull =\n auth.credentials.type === 'access' &&\n isAccessFull(auth.credentials.scope)\n\n await ctx.actorStore.transact(did, async (actorTxn) => {\n await actorTxn.pref.putPreferences(checkedPreferences, 'app.bsky', {\n hasAccessFull,\n })\n })\n },\n })\n}\n"]}
1
+ {"version":3,"file":"putPreferences.js","sourceRoot":"","sources":["../../../../../src/api/app/bsky/actor/putPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,WAAW,GACZ,MAAM,4BAA4B,CAAA;AAEnC,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,CAAA;IAC3B,IAAI,CAAC,WAAW;QAAE,OAAM;IAExB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;QACxC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;YACnC,aAAa,EAAE,IAAI;YACnB,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE;gBAClC,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAA;gBAC9C,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;gBACzC,WAAW,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAA;YACrC,CAAC;SACF,CAAC;QACF,IAAI,EAAE;YACJ,SAAS,EAAE,GAAG,GAAG,IAAI;SACtB;QACD,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE;YACtC,MAAM,EAAE,GAAG,EAAE,GAAG,IA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server } from '@atproto/xrpc-server'\nimport type { AccountPreference } from '../../../../actor-store/preference/reader.js'\nimport { isAccessFull } from '../../../../auth-scope.js'\nimport type { AppContext } from '../../../../context.js'\nimport { app } from '../../../../lexicons/index.js'\nimport {\n bareDidFromProxyTo,\n computeProxyTo,\n pipethrough,\n} from '../../../../pipethrough.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { bskyAppView } = ctx\n if (!bskyAppView) return\n\n server.add(app.bsky.actor.putPreferences, {\n auth: ctx.authVerifier.authorization({\n checkTakedown: true,\n authorize: (permissions, { req }) => {\n const lxm = app.bsky.actor.putPreferences.$lxm\n const aud = computeProxyTo(ctx, req, lxm)\n permissions.assertRpc({ aud, lxm })\n },\n }),\n opts: {\n jsonLimit: 300 * 1024,\n },\n handler: async ({ req, auth, input }) => {\n const { did } = auth.credentials\n\n // If the request has a proxy header different from the bsky app view,\n // we need to proxy the request to the requested app view.\n // @TODO This behavior should not be implemented as part of the XRPC framework\n const lxm = app.bsky.actor.putPreferences.$lxm\n const aud = computeProxyTo(ctx, req, lxm)\n if (aud !== `${bskyAppView.did}#bsky_appview`) {\n // Phase 1 of service auth updates: outbound JWT keeps bare-DID aud.\n return pipethrough(ctx, req, {\n iss: did,\n aud: bareDidFromProxyTo(aud),\n lxm,\n })\n }\n\n const checkedPreferences: AccountPreference[] = []\n for (const pref of input.body.preferences) {\n if (typeof pref.$type === 'string') {\n checkedPreferences.push(pref as AccountPreference)\n } else {\n throw new InvalidRequestError('Preference is missing a $type')\n }\n }\n\n const hasAccessFull =\n auth.credentials.type === 'access' &&\n isAccessFull(auth.credentials.scope)\n\n await ctx.actorStore.transact(did, async (actorTxn) => {\n await actorTxn.pref.putPreferences(checkedPreferences, 'app.bsky', {\n hasAccessFull,\n })\n })\n },\n })\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { com } from '../../../../lexicons/index.js';
2
2
  export default function (server, ctx) {
3
3
  server.add(com.atproto.admin.deleteAccount, {
4
- auth: ctx.authVerifier.adminToken,
4
+ auth: ctx.authVerifier.adminTokenOrEntrywayService,
5
5
  handler: async ({ input }) => {
6
6
  const { did } = input.body;
7
7
  // @NOTE Order matters here: first "unlink" the account by removing it
@@ -1 +1 @@
1
- {"version":3,"file":"deleteAccount.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/admin/deleteAccount.ts"],"names":[],"mappings":"AAEA,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,aAAa,EAAE;QAC1C,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,UAAU;QACjC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YAC3B,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,CAAA;YAE1B,sEAAsE;YACtE,yEAAyE;YACzE,6DAA6D;YAC7D,MAAM,GAAG,CAAC,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;YAC3C,IAAI,CAAC;gBACH,MAAM,GAAG,CAAC,SAAS,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAA;YAClD,CAAC;oBAAS,CAAC;gBACT,MAAM,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YACnC,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import 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.deleteAccount, {\n auth: ctx.authVerifier.adminToken,\n handler: async ({ input }) => {\n const { did } = input.body\n\n // @NOTE Order matters here: first \"unlink\" the account by removing it\n // from the account manager database (\"source of truth\"), then notify the\n // sequencer, and finally cleanup files from the file system.\n await ctx.accountManager.deleteAccount(did)\n try {\n await ctx.sequencer.sequenceAccountDeletion(did)\n } finally {\n await ctx.actorStore.destroy(did)\n }\n },\n })\n}\n"]}
1
+ {"version":3,"file":"deleteAccount.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/admin/deleteAccount.ts"],"names":[],"mappings":"AAEA,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,aAAa,EAAE;QAC1C,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,2BAA2B;QAClD,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YAC3B,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,IAAI,CAAA;YAE1B,sEAAsE;YACtE,yEAAyE;YACzE,6DAA6D;YAC7D,MAAM,GAAG,CAAC,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;YAC3C,IAAI,CAAC;gBACH,MAAM,GAAG,CAAC,SAAS,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAA;YAClD,CAAC;oBAAS,CAAC;gBACT,MAAM,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;YACnC,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import 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.deleteAccount, {\n auth: ctx.authVerifier.adminTokenOrEntrywayService,\n handler: async ({ input }) => {\n const { did } = input.body\n\n // @NOTE Order matters here: first \"unlink\" the account by removing it\n // from the account manager database (\"source of truth\"), then notify the\n // sequencer, and finally cleanup files from the file system.\n await ctx.accountManager.deleteAccount(did)\n try {\n await ctx.sequencer.sequenceAccountDeletion(did)\n } finally {\n await ctx.actorStore.destroy(did)\n }\n },\n })\n}\n"]}
@@ -4,7 +4,7 @@ import { InvalidRequestError } from '@atproto/xrpc-server';
4
4
  import { com } from '../../../../lexicons/index.js';
5
5
  export default function (server, ctx) {
6
6
  server.add(com.atproto.admin.getSubjectStatus, {
7
- auth: ctx.authVerifier.moderator,
7
+ auth: ctx.authVerifier.moderatorOrEntrywayService,
8
8
  handler: async ({ params }) => {
9
9
  const { did, uri, blob } = params;
10
10
  let body = null;
@@ -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,CAAC,KAAK,CAAC,gBAAgB,EAAE;QAC7C,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,SAAS;QAChC,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC5B,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;YACjC,IAAI,IAAI,GAA0D,IAAI,CAAA;YACtE,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,CAAC,GAAG,EAAE,CAAC;oBACT,MAAM,IAAI,mBAAmB,CAC3B,0CAA0C,CAC3C,CAAA;gBACH,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CACxD,KAAK,CAAC,IAAI,CAAC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AC,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"]}
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,0BAA0B;QACjD,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC5B,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;YACjC,IAAI,IAAI,GAA0D,IAAI,CAAA;YACtE,IAAI,IAAI,EAAE,CAAC;gBACT,IAAI,CAAC,GAAG,EAAE,CAAC;oBACT,MAAM,IAAI,mBAAmB,CAC3B,0CAA0C,CAC3C,CAAA;gBACH,CAAC;gBACD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CACxD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACtD,CAAA;gBACD,IAAI,QAAQ,EAAE,CAAC;oBACb,IAAI,GAAG;wBACL,OAA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AAI,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.moderatorOrEntrywayService,\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"]}
@@ -4,7 +4,7 @@ export default function (server, ctx) {
4
4
  const { entrywayClient } = ctx;
5
5
  if (entrywayClient) {
6
6
  server.add(com.atproto.admin.updateAccountHandle, {
7
- auth: ctx.authVerifier.adminToken,
7
+ auth: ctx.authVerifier.adminTokenOrEntrywayService,
8
8
  handler: async ({ input: { body } }) => {
9
9
  const { did, handle } = await ctx.accountManager.validateHandleUpdate(body.did, body.handle, { allowAnyValid: true });
10
10
  // the pds defers to the entryway for updating the handle in the user's
@@ -1 +1 @@
1
- {"version":3,"file":"updateAccountHandle.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/admin/updateAccountHandle.ts"],"names":[],"mappings":"AAAA,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,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;IAE9B,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE;YAChD,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,UAAU;YACjC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBACrC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,oBAAoB,CACnE,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,MAAM,EACX,EAAE,aAAa,EAAE,IAAI,EAAE,CACxB,CAAA;gBAED,uEAAuE;gBACvE,0DAA0D;gBAC1D,6BAA6B;gBAC7B,EAAE;gBACF,oEAAoE;gBACpE,4EAA4E;gBAC5E,EAAE;gBACF,0EAA0E;gBAC1E,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,GAAG;qBACjC,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC;qBAC7B,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;gBAEzB,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;oBAClC,MAAM,IAAI,mBAAmB,CAAC,+BAA+B,CAAC,CAAA;gBAChE,CAAC;gBAED,MAAM,GAAG,CAAC,cAAc,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YAC3D,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE;YAChD,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,UAAU;YACjC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBACrC,MAAM,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE;oBAC3D,aAAa,EAAE,IAAI;iBACpB,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { 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 const { entrywayClient } = ctx\n\n if (entrywayClient) {\n server.add(com.atproto.admin.updateAccountHandle, {\n auth: ctx.authVerifier.adminToken,\n handler: async ({ input: { body } }) => {\n const { did, handle } = await ctx.accountManager.validateHandleUpdate(\n body.did,\n body.handle,\n { allowAnyValid: true },\n )\n\n // the pds defers to the entryway for updating the handle in the user's\n // did doc. here was just check that the handle is already\n // bidirectionally confirmed.\n //\n // -> entryway(identity.updateHandle) [update handle, submit plc op]\n // -> pds(admin.updateAccountHandle) [track handle, sequence handle update]\n //\n // @TODO if handle is taken according to this PDS, should we force-update?\n const doc = await ctx.idResolver.did\n .resolveAtprotoData(did, true)\n .catch(() => undefined)\n\n if (!doc || doc.handle !== handle) {\n throw new InvalidRequestError('Handle does not match DID doc')\n }\n\n await ctx.accountManager.updateAccountHandle(did, handle)\n },\n })\n } else {\n server.add(com.atproto.admin.updateAccountHandle, {\n auth: ctx.authVerifier.adminToken,\n handler: async ({ input: { body } }) => {\n await ctx.accountManager.updateHandle(body.did, body.handle, {\n allowAnyValid: true,\n })\n },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"updateAccountHandle.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/admin/updateAccountHandle.ts"],"names":[],"mappings":"AAAA,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,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;IAE9B,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE;YAChD,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,2BAA2B;YAClD,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBACrC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,oBAAoB,CACnE,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,MAAM,EACX,EAAE,aAAa,EAAE,IAAI,EAAE,CACxB,CAAA;gBAED,uEAAuE;gBACvE,0DAA0D;gBAC1D,6BAA6B;gBAC7B,EAAE;gBACF,oEAAoE;gBACpE,4EAA4E;gBAC5E,EAAE;gBACF,0EAA0E;gBAC1E,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,GAAG;qBACjC,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC;qBAC7B,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;gBAEzB,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;oBAClC,MAAM,IAAI,mBAAmB,CAAC,+BAA+B,CAAC,CAAA;gBAChE,CAAC;gBAED,MAAM,GAAG,CAAC,cAAc,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;YAC3D,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE;YAChD,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,UAAU;YACjC,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE;gBACrC,MAAM,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE;oBAC3D,aAAa,EAAE,IAAI;iBACpB,CAAC,CAAA;YACJ,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { 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 const { entrywayClient } = ctx\n\n if (entrywayClient) {\n server.add(com.atproto.admin.updateAccountHandle, {\n auth: ctx.authVerifier.adminTokenOrEntrywayService,\n handler: async ({ input: { body } }) => {\n const { did, handle } = await ctx.accountManager.validateHandleUpdate(\n body.did,\n body.handle,\n { allowAnyValid: true },\n )\n\n // the pds defers to the entryway for updating the handle in the user's\n // did doc. here was just check that the handle is already\n // bidirectionally confirmed.\n //\n // -> entryway(identity.updateHandle) [update handle, submit plc op]\n // -> pds(admin.updateAccountHandle) [track handle, sequence handle update]\n //\n // @TODO if handle is taken according to this PDS, should we force-update?\n const doc = await ctx.idResolver.did\n .resolveAtprotoData(did, true)\n .catch(() => undefined)\n\n if (!doc || doc.handle !== handle) {\n throw new InvalidRequestError('Handle does not match DID doc')\n }\n\n await ctx.accountManager.updateAccountHandle(did, handle)\n },\n })\n } else {\n server.add(com.atproto.admin.updateAccountHandle, {\n auth: ctx.authVerifier.adminToken,\n handler: async ({ input: { body } }) => {\n await ctx.accountManager.updateHandle(body.did, body.handle, {\n allowAnyValid: true,\n })\n },\n })\n }\n}\n"]}
@@ -4,7 +4,7 @@ import { InvalidRequestError } from '@atproto/xrpc-server';
4
4
  import { com } from '../../../../lexicons/index.js';
5
5
  export default function (server, ctx) {
6
6
  server.add(com.atproto.admin.updateSubjectStatus, {
7
- auth: ctx.authVerifier.moderator,
7
+ auth: ctx.authVerifier.moderatorOrEntrywayService,
8
8
  handler: async ({ input }) => {
9
9
  const { subject, takedown, deactivated } = input.body;
10
10
  if (takedown?.applied && deactivated != null && !deactivated.applied) {
@@ -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,KAAK,CAAC,mBAAmB,EAAE;QAChD,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,SAAS;QAChC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Q,CAAC,OAAO,CAAC,GAAG,CAAC,EACrB,QAAQ,CACT,CAAA;oBACH,CAAC,CAAC,CAAA;gBACJ,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,mBAAmB,CAAC,oBAAoB,OAAO,CAAC,KAAK,GAAG,CAAC,CAAA;gBACrE,CAAC;YACH,CAAC;YAED,IAAI,WAAW,EAAE,CAAC;gBAChB,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;oBACtD,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;wBACxB,MAAM,GAAG,CAAC,cAAc,CAAC,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;oBACzD,CAAC;yBAAM,CAAC;wBACN,MAAM,GAAG,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;oBACvD,CAAC;gBACH,CAAC;YACH,CAAC;YAED,yEAAyE;YACzE,kEAAkE;YAClE,uEAAuE;YACvE,UAAU;YACV,IAAI,CAAC,QAAQ,IAAI,CAAC,WAAW,EAAE,CAAC;gBAC9B,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;oBACtD,MAAM,GAAG,CAAC,cAAc,CAAC,qBAAqB,CAAC,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
+ {"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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AQ,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.moderatorOrEntrywayService,\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":"createAccount.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/createAccount.ts"],"names":[],"mappings":"AAWA,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,sBAAsB,CAAA;AAE7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAMxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAyHvD"}
1
+ {"version":3,"file":"createAccount.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/createAccount.ts"],"names":[],"mappings":"AAWA,OAAO,EAIL,KAAK,MAAM,EACZ,MAAM,sBAAsB,CAAA;AAQ7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAMxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAwIvD"}
@@ -6,21 +6,32 @@ import { Secp256k1Keypair, } from '@atproto/crypto';
6
6
  import { ensureAtpDocument } from '@atproto/identity';
7
7
  import { AuthRequiredError, InvalidRequestError, } from '@atproto/xrpc-server';
8
8
  import { NEW_PASSWORD_MAX_LENGTH } from '../../../../account-manager/helpers/scrypt.js';
9
+ import { bearerTokenFromReq } from '../../../../auth-verifier.js';
9
10
  import { events } from '../../../../events.js';
10
11
  import { baseNormalizeAndValidate } from '../../../../handle/index.js';
11
12
  import { com } from '../../../../lexicons/index.js';
12
13
  import { safeResolveDidDoc } from './util.js';
13
14
  export default function (server, ctx) {
15
+ // Like entrywayServiceOptional, but PDS_ENTRYWAY_REQUIRE_SERVICE_AUTH does
16
+ // not apply yet: the entryway can only start signing createAccount once
17
+ // PDSes accept a signed call. Enforcement follows once it does.
18
+ const auth = ctx.cfg.entryway
19
+ ? (authCtx) => bearerTokenFromReq(authCtx.req) !== null
20
+ ? ctx.authVerifier.entrywayService(authCtx)
21
+ : ctx.authVerifier.unauthenticated(authCtx)
22
+ : ctx.authVerifier.userServiceAuthOptional;
14
23
  server.add(com.atproto.server.createAccount, {
15
24
  rateLimit: {
16
25
  durationMs: 5 * MINUTE,
17
26
  points: 100,
18
27
  },
19
- auth: ctx.authVerifier.userServiceAuthOptional,
28
+ auth,
20
29
  handler: async ({ input, auth, req, }) => {
21
30
  // @NOTE Until this code and the OAuthStore's `createAccount` are
22
31
  // refactored together, any change made here must be reflected over there.
23
- const requester = auth.credentials?.did ?? null;
32
+ const requester = auth.credentials?.type === 'user_service_auth'
33
+ ? auth.credentials.did
34
+ : null;
24
35
  const { did, handle, email, password, inviteCode, signingKey, plcOp, deactivated, } = ctx.entrywayClient
25
36
  ? await validateInputsForEntrywayPds(ctx, input.body)
26
37
  : await validateInputsForLocalPds(ctx, input.body, requester);
@@ -1 +1 @@
1
- {"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/createAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAGL,gBAAgB,GACjB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAoB,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAEvE,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,GAAG,EAAE,MAAM,+BA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;QAClB,UAAU,EAAE,UAAU,CAAC,GAAG,EAAE;QAC5B,YAAY;QACZ,MAAM;QACN,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS;QAC9B,MAAM,EAAE,GAAG,CAAC,cAAc;KAC3B,CAAC,CAAA;AACJ,CAAC,CAAA;AACD,MAAM,mBAAmB,GAAG,CAC1B,IAAiB,EACjB,QAIC,EACD,EAAE;IACF,yCAAyC;IACzC,qEAAqE;IACrE,mEAAmE;IACnE,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,MAAM,IAAI,mBAAmB,CAC3B,oDAAoD,EACpD,oBAAoB,CACrB,CAAA;IACH,CAAC;SAAM,IAAI,IAAI,CAAC,GAAG,KAAK,QAAQ,CAAC,GAAG,EAAE,CAAC;QACrC,MAAM,IAAI,mBAAmB,CAC3B,2DAA2D,EAC3D,oBAAoB,CACrB,CAAA;IACH,CAAC;SAAM,IAAI,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC;QACnD,MAAM,IAAI,mBAAmB,CAC3B,6DAA6D,EAC7D,oBAAoB,CACrB,CAAA;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import * as plc from '@did-plc/lib'\nimport { isEmailValid } from '@hapi/address'\nimport { isDisposableEmail } from 'disposable-email-domains-js'\nimport { MINUTE, check } from '@atproto/common'\nimport {\n type ExportableKeypair,\n type Keypair,\n Secp256k1Keypair,\n} from '@atproto/crypto'\nimport { type AtprotoData, ensureAtpDocument } from '@atproto/identity'\nimport type { DidString } from '@atproto/syntax'\nimport {\n AuthRequiredError,\n InvalidRequestError,\n type Server,\n} from '@atproto/xrpc-server'\nimport { NEW_PASSWORD_MAX_LENGTH } from '../../../../account-manager/helpers/scrypt.js'\nimport type { AppContext } from '../../../../context.js'\nimport { events } from '../../../../events.js'\nimport { baseNormalizeAndValidate } from '../../../../handle/index.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { safeResolveDidDoc } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.server.createAccount, {\n rateLimit: {\n durationMs: 5 * MINUTE,\n points: 100,\n },\n auth: ctx.authVerifier.userServiceAuthOptional,\n handler: async ({\n input,\n auth,\n req,\n }): Promise<com.atproto.server.createAccount.$Output> => {\n // @NOTE Until this code and the OAuthStore's `createAccount` are\n // refactored together, any change made here must be reflected over there.\n\n const requester = auth.credentials?.did ?? null\n const {\n did,\n handle,\n email,\n password,\n inviteCode,\n signingKey,\n plcOp,\n deactivated,\n } = ctx.entrywayClient\n ? await validateInputsForEntrywayPds(ctx, input.body)\n : await validateInputsForLocalPds(ctx, input.body, requester)\n\n await ctx.actorStore.create(did, signingKey)\n\n try {\n const commit = await ctx.actorStore.transact(did, (actorTxn) => {\n return actorTxn.repo.createRepo([])\n })\n\n const canTombstone =\n // @NOTE IMPORTANT Because the user may be bringing their own did, we\n // must make sure not to tombstone their did on failure if we didn't\n // create it here.\n !ctx.entrywayClient && !input.body.did && !!plcOp\n\n // Generate a real did with PLC\n if (plcOp) {\n await ctx.plcClient.sendOperation(did, plcOp)\n }\n\n try {\n const didDoc = await safeResolveDidDoc(ctx, did, true)\n\n const creds = await ctx.accountManager.createAccountAndSession({\n did,\n handle,\n email,\n password,\n repoCid: commit.cid,\n repoRev: commit.rev,\n inviteCode,\n deactivated,\n })\n\n try {\n const sequenceEvt = !deactivated\n if (sequenceEvt) {\n await ctx.sequencer.sequenceAccountCreation(did, handle, commit)\n }\n\n try {\n await ctx.actorStore\n .clearReservedKeypair(signingKey.did(), did)\n .catch((err) => {\n // @NOTE This is a cleanup operation so we won't fail the whole\n // flow if it fails, but we log it just in case\n req.log.error(\n { did, signingKeyDid: signingKey.did(), err },\n 'Failed to clear reserved keypair',\n )\n })\n\n events.accountCreated({\n source: com.atproto.server.createAccount.$lxm,\n did,\n invited: !!inviteCode,\n deactivated,\n })\n events.sessionCreated({\n source: com.atproto.server.createAccount.$lxm,\n did,\n })\n\n return {\n encoding: 'application/json' as const,\n body: {\n handle,\n did: did,\n // @ts-expect-error https://github.com/bluesky-social/atproto/pull/4406\n didDoc,\n accessJwt: creds.accessJwt,\n refreshJwt: creds.refreshJwt,\n },\n }\n } catch (err) {\n if (sequenceEvt) await ctx.sequencer.sequenceAccountDeletion(did)\n throw err\n }\n } catch (err) {\n await ctx.accountManager.deleteAccount(did)\n throw err\n }\n } catch (err) {\n if (canTombstone) {\n await ctx.plcClient.tombstone(did, ctx.plcRotationKey)\n }\n throw err\n }\n } catch (err) {\n await ctx.actorStore.destroy(did)\n throw err\n }\n },\n })\n}\n\nconst validateInputsForEntrywayPds = async (\n ctx: AppContext,\n input: com.atproto.server.createAccount.$InputBody,\n) => {\n const handle = baseNormalizeAndValidate(input.handle)\n\n const { did, plcOp } = input\n if (!did || !plcOp) {\n throw new InvalidRequestError(\n 'non-entryway pds requires bringing a DID and plcOp',\n )\n }\n if (!check.is(plcOp, plc.def.operation)) {\n throw new InvalidRequestError('invalid plc operation', 'IncompatibleDidDoc')\n }\n const plcRotationKey = ctx.cfg.entryway?.plcRotationKey\n if (!plcRotationKey || !plcOp.rotationKeys.includes(plcRotationKey)) {\n throw new InvalidRequestError(\n 'PLC DID does not include service rotation key',\n 'IncompatibleDidDoc',\n )\n }\n try {\n await plc.assureValidOp(plcOp)\n await plc.assureValidSig([plcRotationKey], plcOp)\n } catch (err) {\n throw new InvalidRequestError('invalid plc operation', 'IncompatibleDidDoc')\n }\n const doc = plc.formatDidDoc({ did, ...plcOp })\n const data = ensureAtpDocument(doc)\n\n let signingKey: ExportableKeypair | undefined\n if (input.did) {\n signingKey = await ctx.actorStore.getReservedKeypair(input.did)\n }\n if (!signingKey) {\n signingKey = await ctx.actorStore.getReservedKeypair(data.signingKey)\n }\n if (!signingKey) {\n throw new InvalidRequestError('reserved signing key does not exist')\n }\n\n validateAtprotoData(data, {\n handle,\n pds: ctx.cfg.service.publicUrl,\n signingKey: signingKey.did(),\n })\n\n return {\n did,\n handle,\n email: undefined,\n password: undefined,\n inviteCode: undefined,\n signingKey,\n plcOp,\n deactivated: false,\n }\n}\n\nconst validateInputsForLocalPds = async (\n ctx: AppContext,\n input: com.atproto.server.createAccount.$InputBody,\n requester: string | null,\n) => {\n const { email, password, inviteCode } = input\n if (input.plcOp) {\n throw new InvalidRequestError('Unsupported input: \"plcOp\"')\n }\n\n if (password && password.length > NEW_PASSWORD_MAX_LENGTH) {\n throw new InvalidRequestError(\n `Password too long. Maximum length is ${NEW_PASSWORD_MAX_LENGTH} characters.`,\n )\n }\n\n if (ctx.cfg.invites.required && !inviteCode) {\n throw new InvalidRequestError(\n 'No invite code provided',\n 'InvalidInviteCode',\n )\n }\n\n if (!email) {\n throw new InvalidRequestError('Email is required')\n } else if (!isEmailValid(email) || isDisposableEmail(email)) {\n throw new InvalidRequestError(\n 'This email address is not supported, please use a different email.',\n )\n }\n\n // normalize & ensure valid handle\n const handle = await ctx.accountManager.normalizeAndValidateHandle(\n input.handle,\n { did: input.did },\n )\n\n // check that the invite code still has uses\n if (ctx.cfg.invites.required && inviteCode) {\n await ctx.accountManager.ensureInviteIsAvailable(inviteCode)\n }\n\n // check that the handle and email are available\n //\n // `actor_handle_lower_idx` and `account_email_lower_idx` enforce handle and\n // email uniqueness across taken down and deactivated accounts as well, so we\n // must check for them when surfacing handle availability.\n const availability = { includeTakenDown: true, includeDeactivated: true }\n const [handleAccnt, emailAcct] = await Promise.all([\n ctx.accountManager.getAccount(handle, availability),\n ctx.accountManager.getAccountByEmail(email, availability),\n ])\n if (handleAccnt) {\n throw new InvalidRequestError(`Handle already taken: ${handle}`)\n } else if (emailAcct) {\n throw new InvalidRequestError(`Email already taken: ${email}`)\n }\n\n // determine the did & any plc ops we need to send\n // if the provided did document is poorly setup, we throw\n const signingKey = await Secp256k1Keypair.create({ exportable: true })\n\n let did: DidString\n let plcOp: plc.Operation | null\n let deactivated = false\n if (input.did) {\n if (input.did !== requester) {\n throw new AuthRequiredError(\n `Missing auth to create account with did: ${input.did}`,\n )\n }\n did = input.did\n plcOp = null\n deactivated = true\n } else {\n const formatted = await formatDidAndPlcOp(ctx, handle, input, signingKey)\n did = formatted.did as DidString\n plcOp = formatted.op\n }\n\n return {\n did,\n handle,\n email,\n password,\n inviteCode,\n signingKey,\n plcOp,\n deactivated,\n }\n}\n\nconst formatDidAndPlcOp = async (\n ctx: AppContext,\n handle: string,\n input: com.atproto.server.createAccount.$InputBody,\n signingKey: Keypair,\n) => {\n // if the user is not bringing a DID, then we format a create op for PLC\n const rotationKeys = [ctx.plcRotationKey.did()]\n if (ctx.cfg.identity.recoveryDidKey) {\n rotationKeys.unshift(ctx.cfg.identity.recoveryDidKey)\n }\n if (input.recoveryKey) {\n rotationKeys.unshift(input.recoveryKey)\n }\n return plc.createOp({\n signingKey: signingKey.did(),\n rotationKeys,\n handle,\n pds: ctx.cfg.service.publicUrl,\n signer: ctx.plcRotationKey,\n })\n}\nconst validateAtprotoData = (\n data: AtprotoData,\n expected: {\n handle: string\n pds: string\n signingKey: string\n },\n) => {\n // if the user is bringing their own did:\n // resolve the user's did doc data, including rotationKeys if did:plc\n // determine if we have the capability to make changes to their DID\n if (data.handle !== expected.handle) {\n throw new InvalidRequestError(\n 'provided handle does not match DID document handle',\n 'IncompatibleDidDoc',\n )\n } else if (data.pds !== expected.pds) {\n throw new InvalidRequestError(\n 'DID document pds endpoint does not match service endpoint',\n 'IncompatibleDidDoc',\n )\n } else if (data.signingKey !== expected.signingKey) {\n throw new InvalidRequestError(\n 'DID document signing key does not match service signing key',\n 'IncompatibleDidDoc',\n )\n }\n}\n"]}
1
+ {"version":3,"file":"createAccount.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/createAccount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;A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AI,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpC,MAAM,IAAI,mBAAmB,CAC3B,oDAAoD,EACpD,oBAAoB,CACrB,CAAA;IACH,CAAC;SAAM,IAAI,IAAI,CAAC,GAAG,KAAK,QAAQ,CAAC,GAAG,EAAE,CAAC;QACrC,MAAM,IAAI,mBAAmB,CAC3B,2DAA2D,EAC3D,oBAAoB,CACrB,CAAA;IACH,CAAC;SAAM,IAAI,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC;QACnD,MAAM,IAAI,mBAAmB,CAC3B,6DAA6D,EAC7D,oBAAoB,CACrB,CAAA;IACH,CAAC;AACH,CAAC,CAAA","sourcesContent":["import * as plc from '@did-plc/lib'\nimport { isEmailValid } from '@hapi/address'\nimport { isDisposableEmail } from 'disposable-email-domains-js'\nimport { MINUTE, check } from '@atproto/common'\nimport {\n type ExportableKeypair,\n type Keypair,\n Secp256k1Keypair,\n} from '@atproto/crypto'\nimport { type AtprotoData, ensureAtpDocument } from '@atproto/identity'\nimport type { DidString } from '@atproto/syntax'\nimport {\n AuthRequiredError,\n InvalidRequestError,\n type MethodAuthVerifier,\n type Server,\n} from '@atproto/xrpc-server'\nimport { NEW_PASSWORD_MAX_LENGTH } from '../../../../account-manager/helpers/scrypt.js'\nimport type {\n EntrywayServiceOutput,\n UnauthenticatedOutput,\n UserServiceAuthOutput,\n} from '../../../../auth-output.js'\nimport { bearerTokenFromReq } from '../../../../auth-verifier.js'\nimport type { AppContext } from '../../../../context.js'\nimport { events } from '../../../../events.js'\nimport { baseNormalizeAndValidate } from '../../../../handle/index.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { safeResolveDidDoc } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n // Like entrywayServiceOptional, but PDS_ENTRYWAY_REQUIRE_SERVICE_AUTH does\n // not apply yet: the entryway can only start signing createAccount once\n // PDSes accept a signed call. Enforcement follows once it does.\n const auth: MethodAuthVerifier<\n EntrywayServiceOutput | UserServiceAuthOutput | UnauthenticatedOutput\n > = ctx.cfg.entryway\n ? (authCtx) =>\n bearerTokenFromReq(authCtx.req) !== null\n ? ctx.authVerifier.entrywayService(authCtx)\n : ctx.authVerifier.unauthenticated(authCtx)\n : ctx.authVerifier.userServiceAuthOptional\n\n server.add(com.atproto.server.createAccount, {\n rateLimit: {\n durationMs: 5 * MINUTE,\n points: 100,\n },\n auth,\n handler: async ({\n input,\n auth,\n req,\n }): Promise<com.atproto.server.createAccount.$Output> => {\n // @NOTE Until this code and the OAuthStore's `createAccount` are\n // refactored together, any change made here must be reflected over there.\n\n const requester =\n auth.credentials?.type === 'user_service_auth'\n ? auth.credentials.did\n : null\n const {\n did,\n handle,\n email,\n password,\n inviteCode,\n signingKey,\n plcOp,\n deactivated,\n } = ctx.entrywayClient\n ? await validateInputsForEntrywayPds(ctx, input.body)\n : await validateInputsForLocalPds(ctx, input.body, requester)\n\n await ctx.actorStore.create(did, signingKey)\n\n try {\n const commit = await ctx.actorStore.transact(did, (actorTxn) => {\n return actorTxn.repo.createRepo([])\n })\n\n const canTombstone =\n // @NOTE IMPORTANT Because the user may be bringing their own did, we\n // must make sure not to tombstone their did on failure if we didn't\n // create it here.\n !ctx.entrywayClient && !input.body.did && !!plcOp\n\n // Generate a real did with PLC\n if (plcOp) {\n await ctx.plcClient.sendOperation(did, plcOp)\n }\n\n try {\n const didDoc = await safeResolveDidDoc(ctx, did, true)\n\n const creds = await ctx.accountManager.createAccountAndSession({\n did,\n handle,\n email,\n password,\n repoCid: commit.cid,\n repoRev: commit.rev,\n inviteCode,\n deactivated,\n })\n\n try {\n const sequenceEvt = !deactivated\n if (sequenceEvt) {\n await ctx.sequencer.sequenceAccountCreation(did, handle, commit)\n }\n\n try {\n await ctx.actorStore\n .clearReservedKeypair(signingKey.did(), did)\n .catch((err) => {\n // @NOTE This is a cleanup operation so we won't fail the whole\n // flow if it fails, but we log it just in case\n req.log.error(\n { did, signingKeyDid: signingKey.did(), err },\n 'Failed to clear reserved keypair',\n )\n })\n\n events.accountCreated({\n source: com.atproto.server.createAccount.$lxm,\n did,\n invited: !!inviteCode,\n deactivated,\n })\n events.sessionCreated({\n source: com.atproto.server.createAccount.$lxm,\n did,\n })\n\n return {\n encoding: 'application/json' as const,\n body: {\n handle,\n did: did,\n // @ts-expect-error https://github.com/bluesky-social/atproto/pull/4406\n didDoc,\n accessJwt: creds.accessJwt,\n refreshJwt: creds.refreshJwt,\n },\n }\n } catch (err) {\n if (sequenceEvt) await ctx.sequencer.sequenceAccountDeletion(did)\n throw err\n }\n } catch (err) {\n await ctx.accountManager.deleteAccount(did)\n throw err\n }\n } catch (err) {\n if (canTombstone) {\n await ctx.plcClient.tombstone(did, ctx.plcRotationKey)\n }\n throw err\n }\n } catch (err) {\n await ctx.actorStore.destroy(did)\n throw err\n }\n },\n })\n}\n\nconst validateInputsForEntrywayPds = async (\n ctx: AppContext,\n input: com.atproto.server.createAccount.$InputBody,\n) => {\n const handle = baseNormalizeAndValidate(input.handle)\n\n const { did, plcOp } = input\n if (!did || !plcOp) {\n throw new InvalidRequestError(\n 'non-entryway pds requires bringing a DID and plcOp',\n )\n }\n if (!check.is(plcOp, plc.def.operation)) {\n throw new InvalidRequestError('invalid plc operation', 'IncompatibleDidDoc')\n }\n const plcRotationKey = ctx.cfg.entryway?.plcRotationKey\n if (!plcRotationKey || !plcOp.rotationKeys.includes(plcRotationKey)) {\n throw new InvalidRequestError(\n 'PLC DID does not include service rotation key',\n 'IncompatibleDidDoc',\n )\n }\n try {\n await plc.assureValidOp(plcOp)\n await plc.assureValidSig([plcRotationKey], plcOp)\n } catch (err) {\n throw new InvalidRequestError('invalid plc operation', 'IncompatibleDidDoc')\n }\n const doc = plc.formatDidDoc({ did, ...plcOp })\n const data = ensureAtpDocument(doc)\n\n let signingKey: ExportableKeypair | undefined\n if (input.did) {\n signingKey = await ctx.actorStore.getReservedKeypair(input.did)\n }\n if (!signingKey) {\n signingKey = await ctx.actorStore.getReservedKeypair(data.signingKey)\n }\n if (!signingKey) {\n throw new InvalidRequestError('reserved signing key does not exist')\n }\n\n validateAtprotoData(data, {\n handle,\n pds: ctx.cfg.service.publicUrl,\n signingKey: signingKey.did(),\n })\n\n return {\n did,\n handle,\n email: undefined,\n password: undefined,\n inviteCode: undefined,\n signingKey,\n plcOp,\n deactivated: false,\n }\n}\n\nconst validateInputsForLocalPds = async (\n ctx: AppContext,\n input: com.atproto.server.createAccount.$InputBody,\n requester: string | null,\n) => {\n const { email, password, inviteCode } = input\n if (input.plcOp) {\n throw new InvalidRequestError('Unsupported input: \"plcOp\"')\n }\n\n if (password && password.length > NEW_PASSWORD_MAX_LENGTH) {\n throw new InvalidRequestError(\n `Password too long. Maximum length is ${NEW_PASSWORD_MAX_LENGTH} characters.`,\n )\n }\n\n if (ctx.cfg.invites.required && !inviteCode) {\n throw new InvalidRequestError(\n 'No invite code provided',\n 'InvalidInviteCode',\n )\n }\n\n if (!email) {\n throw new InvalidRequestError('Email is required')\n } else if (!isEmailValid(email) || isDisposableEmail(email)) {\n throw new InvalidRequestError(\n 'This email address is not supported, please use a different email.',\n )\n }\n\n // normalize & ensure valid handle\n const handle = await ctx.accountManager.normalizeAndValidateHandle(\n input.handle,\n { did: input.did },\n )\n\n // check that the invite code still has uses\n if (ctx.cfg.invites.required && inviteCode) {\n await ctx.accountManager.ensureInviteIsAvailable(inviteCode)\n }\n\n // check that the handle and email are available\n //\n // `actor_handle_lower_idx` and `account_email_lower_idx` enforce handle and\n // email uniqueness across taken down and deactivated accounts as well, so we\n // must check for them when surfacing handle availability.\n const availability = { includeTakenDown: true, includeDeactivated: true }\n const [handleAccnt, emailAcct] = await Promise.all([\n ctx.accountManager.getAccount(handle, availability),\n ctx.accountManager.getAccountByEmail(email, availability),\n ])\n if (handleAccnt) {\n throw new InvalidRequestError(`Handle already taken: ${handle}`)\n } else if (emailAcct) {\n throw new InvalidRequestError(`Email already taken: ${email}`)\n }\n\n // determine the did & any plc ops we need to send\n // if the provided did document is poorly setup, we throw\n const signingKey = await Secp256k1Keypair.create({ exportable: true })\n\n let did: DidString\n let plcOp: plc.Operation | null\n let deactivated = false\n if (input.did) {\n if (input.did !== requester) {\n throw new AuthRequiredError(\n `Missing auth to create account with did: ${input.did}`,\n )\n }\n did = input.did\n plcOp = null\n deactivated = true\n } else {\n const formatted = await formatDidAndPlcOp(ctx, handle, input, signingKey)\n did = formatted.did as DidString\n plcOp = formatted.op\n }\n\n return {\n did,\n handle,\n email,\n password,\n inviteCode,\n signingKey,\n plcOp,\n deactivated,\n }\n}\n\nconst formatDidAndPlcOp = async (\n ctx: AppContext,\n handle: string,\n input: com.atproto.server.createAccount.$InputBody,\n signingKey: Keypair,\n) => {\n // if the user is not bringing a DID, then we format a create op for PLC\n const rotationKeys = [ctx.plcRotationKey.did()]\n if (ctx.cfg.identity.recoveryDidKey) {\n rotationKeys.unshift(ctx.cfg.identity.recoveryDidKey)\n }\n if (input.recoveryKey) {\n rotationKeys.unshift(input.recoveryKey)\n }\n return plc.createOp({\n signingKey: signingKey.did(),\n rotationKeys,\n handle,\n pds: ctx.cfg.service.publicUrl,\n signer: ctx.plcRotationKey,\n })\n}\nconst validateAtprotoData = (\n data: AtprotoData,\n expected: {\n handle: string\n pds: string\n signingKey: string\n },\n) => {\n // if the user is bringing their own did:\n // resolve the user's did doc data, including rotationKeys if did:plc\n // determine if we have the capability to make changes to their DID\n if (data.handle !== expected.handle) {\n throw new InvalidRequestError(\n 'provided handle does not match DID document handle',\n 'IncompatibleDidDoc',\n )\n } else if (data.pds !== expected.pds) {\n throw new InvalidRequestError(\n 'DID document pds endpoint does not match service endpoint',\n 'IncompatibleDidDoc',\n )\n } else if (data.signingKey !== expected.signingKey) {\n throw new InvalidRequestError(\n 'DID document signing key does not match service signing key',\n 'IncompatibleDidDoc',\n )\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reserveSigningKey.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/reserveSigningKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAUvD"}
1
+ {"version":3,"file":"reserveSigningKey.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/reserveSigningKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAavD"}
@@ -1,6 +1,9 @@
1
1
  import { com } from '../../../../lexicons/index.js';
2
2
  export default function (server, ctx) {
3
3
  server.add(com.atproto.server.reserveSigningKey, {
4
+ auth: ctx.cfg.entryway
5
+ ? ctx.authVerifier.entrywayServiceOptional
6
+ : undefined,
4
7
  handler: async ({ input }) => {
5
8
  const signingKey = await ctx.actorStore.reserveKeypair(input.body.did);
6
9
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"reserveSigningKey.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/reserveSigningKey.ts"],"names":[],"mappings":"AAEA,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,MAAM,CAAC,iBAAiB,EAAE;QAC/C,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YAC3B,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACtE,OAAO;gBACL,QAAQ,EAAE,kBAA2B;gBACrC,IAAI,EAAE,EAAE,UAAU,EAAE;aACrB,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import 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.server.reserveSigningKey, {\n handler: async ({ input }) => {\n const signingKey = await ctx.actorStore.reserveKeypair(input.body.did)\n return {\n encoding: 'application/json' as const,\n body: { signingKey },\n }\n },\n })\n}\n"]}
1
+ {"version":3,"file":"reserveSigningKey.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/reserveSigningKey.ts"],"names":[],"mappings":"AAEA,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,MAAM,CAAC,iBAAiB,EAAE;QAC/C,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,QAAQ;YACpB,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,uBAAuB;YAC1C,CAAC,CAAC,SAAS;QACb,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YAC3B,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACtE,OAAO;gBACL,QAAQ,EAAE,kBAA2B;gBACrC,IAAI,EAAE,EAAE,UAAU,EAAE;aACrB,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import 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.server.reserveSigningKey, {\n auth: ctx.cfg.entryway\n ? ctx.authVerifier.entrywayServiceOptional\n : undefined,\n handler: async ({ input }) => {\n const signingKey = await ctx.actorStore.reserveKeypair(input.body.did)\n return {\n encoding: 'application/json' as const,\n body: { signingKey },\n }\n },\n })\n}\n"]}
@@ -15,6 +15,12 @@ export type ModServiceOutput = {
15
15
  did: DidString;
16
16
  };
17
17
  };
18
+ export type EntrywayServiceOutput = {
19
+ credentials: {
20
+ type: 'entryway_service';
21
+ did: DidString;
22
+ };
23
+ };
18
24
  export type AccessOutput<S extends AuthScope = AuthScope> = {
19
25
  credentials: {
20
26
  type: 'access';
@@ -1 +1 @@
1
- {"version":3,"file":"auth-output.d.ts","sourceRoot":"","sources":["../src/auth-output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,IAAI,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE;QACX,IAAI,EAAE,aAAa,CAAA;KACpB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,EAAE;QACX,IAAI,EAAE,aAAa,CAAA;QACnB,GAAG,EAAE,SAAS,CAAA;KACf,CAAA;CACF,CAAA;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI;IAC1D,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAA;QACd,GAAG,EAAE,SAAS,CAAA;QACd,KAAK,EAAE,CAAC,CAAA;KACT,CAAA;CACF,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE;QACX,IAAI,EAAE,OAAO,CAAA;QACb,GAAG,EAAE,SAAS,C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AK,EAAE,CAAC,CAAA;KACT,CAAA;CACF,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE;QACX,IAAI,EAAE,OAAO,CAAA;QACb,GAAG,EAAE,SAAS,CAAA;QACd,WAAW,EAAE,gBAAgB,CAAA;KAC9B,CAAA;CACF,CAAA;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE;QACX,IAAI,EAAE,SAAS,CAAA;QACf,GAAG,EAAE,SAAS,CAAA;QACd,KAAK,EAAE,SAAS,CAAC,OAAO,CAAA;QACxB,OAAO,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE;QACX,IAAI,EAAE,mBAAmB,CAAA;QACzB,GAAG,EAAE,SAAS,CAAA;KACf,CAAA;CACF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"auth-output.js","sourceRoot":"","sources":["../src/auth-output.ts"],"names":[],"mappings":"","sourcesContent":["import type { ScopePermissions } from '@atproto/oauth-scopes'\nimport type { DidString } from '@atproto/syntax'\nimport type { AuthScope } from './auth-scope.js'\n\nexport type UnauthenticatedOutput = {\n credentials: null\n}\n\nexport type AdminTokenOutput = {\n credentials: {\n type: 'admin_token'\n }\n}\n\nexport type ModServiceOutput = {\n credentials: {\n type: 'mod_service'\n did: DidString\n }\n}\n\nexport type AccessOutput<S extends AuthScope = AuthScope> = {\n credentials: {\n type: 'access'\n did: DidString\n scope: S\n }\n}\n\nexport type OAuthOutput = {\n credentials: {\n type: 'oauth'\n did: DidString\n permissions: ScopePermissions\n }\n}\n\nexport type RefreshOutput = {\n credentials: {\n type: 'refresh'\n did: DidString\n scope: AuthScope.Refresh\n tokenId: string\n }\n}\n\nexport type UserServiceAuthOutput = {\n credentials: {\n type: 'user_service_auth'\n did: DidString\n }\n}\n"]}
1
+ {"version":3,"file":"auth-output.js","sourceRoot":"","sources":["../src/auth-output.ts"],"names":[],"mappings":"","sourcesContent":["import type { ScopePermissions } from '@atproto/oauth-scopes'\nimport type { DidString } from '@atproto/syntax'\nimport type { AuthScope } from './auth-scope.js'\n\nexport type UnauthenticatedOutput = {\n credentials: null\n}\n\nexport type AdminTokenOutput = {\n credentials: {\n type: 'admin_token'\n }\n}\n\nexport type ModServiceOutput = {\n credentials: {\n type: 'mod_service'\n did: DidString\n }\n}\n\nexport type EntrywayServiceOutput = {\n credentials: {\n type: 'entryway_service'\n did: DidString\n }\n}\n\nexport type AccessOutput<S extends AuthScope = AuthScope> = {\n credentials: {\n type: 'access'\n did: DidString\n scope: S\n }\n}\n\nexport type OAuthOutput = {\n credentials: {\n type: 'oauth'\n did: DidString\n permissions: ScopePermissions\n }\n}\n\nexport type RefreshOutput = {\n credentials: {\n type: 'refresh'\n did: DidString\n scope: AuthScope.Refresh\n tokenId: string\n }\n}\n\nexport type UserServiceAuthOutput = {\n credentials: {\n type: 'user_service_auth'\n did: DidString\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type KeyObject } from 'node:crypto';
2
- import type { IncomingMessage } from 'node:http';
2
+ import type { IncomingMessage, ServerResponse } from 'node:http';
3
3
  import * as jose from 'jose';
4
4
  import { type IdResolver } from '@atproto/identity';
5
5
  import { type AtIdentifierString, type DidString } from '@atproto/lex-schema';
@@ -8,7 +8,7 @@ import { type ScopePermissions } from '@atproto/oauth-scopes';
8
8
  import { type Awaitable, type MethodAuthContext, type MethodAuthVerifier, type Params } from '@atproto/xrpc-server';
9
9
  import type { AccountManager } from './account-manager/account-manager.js';
10
10
  import type { ActorAccount } from './account-manager/helpers/account.js';
11
- import type { AccessOutput, AdminTokenOutput, ModServiceOutput, OAuthOutput, RefreshOutput, UnauthenticatedOutput, UserServiceAuthOutput } from './auth-output.js';
11
+ import type { AccessOutput, AdminTokenOutput, EntrywayServiceOutput, ModServiceOutput, OAuthOutput, RefreshOutput, UnauthenticatedOutput, UserServiceAuthOutput } from './auth-output.js';
12
12
  import { AuthScope } from './auth-scope.js';
13
13
  import type { WithRequired } from './util/types.js';
14
14
  export type VerifiedOptions = {
@@ -33,6 +33,11 @@ export type AuthVerifierOpts = {
33
33
  entryway?: string;
34
34
  modService?: string;
35
35
  };
36
+ entrywayServiceAuth?: {
37
+ /** did:key form of the entryway's JWT verify key */
38
+ didKey: string;
39
+ required: boolean;
40
+ };
36
41
  };
37
42
  export type VerifyBearerJwtOptions<S extends AuthScope = AuthScope> = WithRequired<Omit<jose.JWTVerifyOptions, 'scopes'> & {
38
43
  scopes: readonly S[];
@@ -50,6 +55,7 @@ export declare class AuthVerifier {
50
55
  private _publicUrl;
51
56
  private _jwtKey;
52
57
  private _adminPass;
58
+ private _entrywayServiceAuth;
53
59
  dids: AuthVerifierOpts['dids'];
54
60
  constructor(accountManager: AccountManager, idResolver: IdResolver, oauthVerifier: OAuthVerifier, opts: AuthVerifierOpts);
55
61
  unauthenticated: MethodAuthVerifier<UnauthenticatedOutput>;
@@ -58,6 +64,10 @@ export declare class AuthVerifier {
58
64
  modService: MethodAuthVerifier<ModServiceOutput>;
59
65
  /** @deprecated We are steering away from {@link adminToken} auth. Use {@link modService} instead. */
60
66
  moderator: MethodAuthVerifier<AdminTokenOutput | ModServiceOutput>;
67
+ entrywayService: MethodAuthVerifier<EntrywayServiceOutput>;
68
+ entrywayServiceOptional: MethodAuthVerifier<EntrywayServiceOutput | UnauthenticatedOutput>;
69
+ adminTokenOrEntrywayService: MethodAuthVerifier<AdminTokenOutput | EntrywayServiceOutput>;
70
+ moderatorOrEntrywayService: MethodAuthVerifier<AdminTokenOutput | ModServiceOutput | EntrywayServiceOutput>;
61
71
  protected access<S extends AuthScope>(options: VerifiedOptions & Required<ScopedOptions<S>>): MethodAuthVerifier<AccessOutput<S>>;
62
72
  refresh(options?: {
63
73
  allowExpired?: boolean;
@@ -90,6 +100,15 @@ export declare class AuthVerifier {
90
100
  lxm?: string;
91
101
  jti?: string;
92
102
  }>;
103
+ protected verifyEntrywayServiceJwt(req: IncomingMessage): Promise<{
104
+ iss: DidString | `${DidString}#${string}`;
105
+ aud: string;
106
+ exp: number;
107
+ lxm?: string;
108
+ jti?: string;
109
+ }>;
110
+ protected isEntrywayIssuedJwt(req: IncomingMessage): boolean;
111
+ protected assertEntrywayServiceAuthNotRequired(res: ServerResponse): void;
93
112
  }
94
113
  export declare function isUserOrAdmin(auth: AccessOutput | OAuthOutput | AdminTokenOutput | UnauthenticatedOutput, did: string): boolean;
95
114
  export declare const bearerTokenFromReq: (req: IncomingMessage) => string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"auth-verifier.d.ts","sourceRoot":"","sources":["../src/auth-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAoC,MAAM,aAAa,CAAA;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAkB,MAAM,WAAW,CAAA;AAEhE,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,KAAK,UAAU,EAA0B,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,SAAS,EAEf,MAAM,qBAAqB,CAAA;AAK5B,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAEL,KAAK,SAAS,EAGd,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,MAAM,EAIZ,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAmB,SAAS,EAAe,MAAM,iBAAiB,CAAA;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