@atproto/pds 0.5.34 → 0.5.36

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 (187) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/account-manager/account-manager.d.ts +58 -7
  3. package/dist/account-manager/account-manager.d.ts.map +1 -1
  4. package/dist/account-manager/account-manager.js +152 -19
  5. package/dist/account-manager/account-manager.js.map +1 -1
  6. package/dist/account-manager/db/migrations/008-account-email-auth-factor.d.ts +9 -0
  7. package/dist/account-manager/db/migrations/008-account-email-auth-factor.d.ts.map +1 -0
  8. package/dist/account-manager/db/migrations/008-account-email-auth-factor.js +16 -0
  9. package/dist/account-manager/db/migrations/008-account-email-auth-factor.js.map +1 -0
  10. package/dist/account-manager/db/migrations/index.d.ts +2 -0
  11. package/dist/account-manager/db/migrations/index.d.ts.map +1 -1
  12. package/dist/account-manager/db/migrations/index.js +2 -0
  13. package/dist/account-manager/db/migrations/index.js.map +1 -1
  14. package/dist/account-manager/db/schema/account-email-auth-factor.d.ts +20 -0
  15. package/dist/account-manager/db/schema/account-email-auth-factor.d.ts.map +1 -0
  16. package/dist/account-manager/db/schema/account-email-auth-factor.js +2 -0
  17. package/dist/account-manager/db/schema/account-email-auth-factor.js.map +1 -0
  18. package/dist/account-manager/db/schema/email-token.d.ts +1 -1
  19. package/dist/account-manager/db/schema/email-token.d.ts.map +1 -1
  20. package/dist/account-manager/db/schema/email-token.js.map +1 -1
  21. package/dist/account-manager/db/schema/index.d.ts +2 -1
  22. package/dist/account-manager/db/schema/index.d.ts.map +1 -1
  23. package/dist/account-manager/db/schema/index.js.map +1 -1
  24. package/dist/account-manager/helpers/account-device.d.ts +4 -2
  25. package/dist/account-manager/helpers/account-device.d.ts.map +1 -1
  26. package/dist/account-manager/helpers/account.d.ts +4 -1
  27. package/dist/account-manager/helpers/account.d.ts.map +1 -1
  28. package/dist/account-manager/helpers/account.js +4 -1
  29. package/dist/account-manager/helpers/account.js.map +1 -1
  30. package/dist/account-manager/helpers/email-auth-factor.d.ts +46 -0
  31. package/dist/account-manager/helpers/email-auth-factor.d.ts.map +1 -0
  32. package/dist/account-manager/helpers/email-auth-factor.js +77 -0
  33. package/dist/account-manager/helpers/email-auth-factor.js.map +1 -0
  34. package/dist/account-manager/helpers/invite.d.ts +1 -0
  35. package/dist/account-manager/helpers/invite.d.ts.map +1 -1
  36. package/dist/account-manager/helpers/token.d.ts +4 -2
  37. package/dist/account-manager/helpers/token.d.ts.map +1 -1
  38. package/dist/account-manager/oauth-store.d.ts +4 -2
  39. package/dist/account-manager/oauth-store.d.ts.map +1 -1
  40. package/dist/account-manager/oauth-store.js +48 -14
  41. package/dist/account-manager/oauth-store.js.map +1 -1
  42. package/dist/actor-store/actor-store-reader.d.ts +3 -2
  43. package/dist/actor-store/actor-store-reader.d.ts.map +1 -1
  44. package/dist/actor-store/actor-store-reader.js +2 -2
  45. package/dist/actor-store/actor-store-reader.js.map +1 -1
  46. package/dist/actor-store/actor-store-transactor.d.ts +3 -2
  47. package/dist/actor-store/actor-store-transactor.d.ts.map +1 -1
  48. package/dist/actor-store/actor-store-transactor.js +1 -1
  49. package/dist/actor-store/actor-store-transactor.js.map +1 -1
  50. package/dist/actor-store/actor-store.d.ts +5 -4
  51. package/dist/actor-store/actor-store.d.ts.map +1 -1
  52. package/dist/actor-store/actor-store.js.map +1 -1
  53. package/dist/actor-store/record/reader.d.ts +5 -3
  54. package/dist/actor-store/record/reader.d.ts.map +1 -1
  55. package/dist/actor-store/record/reader.js +19 -8
  56. package/dist/actor-store/record/reader.js.map +1 -1
  57. package/dist/actor-store/record/transactor.d.ts +3 -1
  58. package/dist/actor-store/record/transactor.d.ts.map +1 -1
  59. package/dist/actor-store/record/transactor.js +3 -2
  60. package/dist/actor-store/record/transactor.js.map +1 -1
  61. package/dist/actor-store/repo/reader.d.ts +3 -1
  62. package/dist/actor-store/repo/reader.d.ts.map +1 -1
  63. package/dist/actor-store/repo/reader.js +3 -2
  64. package/dist/actor-store/repo/reader.js.map +1 -1
  65. package/dist/actor-store/repo/transactor.d.ts +3 -2
  66. package/dist/actor-store/repo/transactor.d.ts.map +1 -1
  67. package/dist/actor-store/repo/transactor.js +2 -2
  68. package/dist/actor-store/repo/transactor.js.map +1 -1
  69. package/dist/api/com/atproto/admin/getSubjectStatus.js +1 -1
  70. package/dist/api/com/atproto/admin/getSubjectStatus.js.map +1 -1
  71. package/dist/api/com/atproto/admin/updateAccountEmail.d.ts.map +1 -1
  72. package/dist/api/com/atproto/admin/updateAccountEmail.js +1 -4
  73. package/dist/api/com/atproto/admin/updateAccountEmail.js.map +1 -1
  74. package/dist/api/com/atproto/admin/updateSubjectStatus.js +1 -1
  75. package/dist/api/com/atproto/admin/updateSubjectStatus.js.map +1 -1
  76. package/dist/api/com/atproto/server/activateAccount.d.ts.map +1 -1
  77. package/dist/api/com/atproto/server/activateAccount.js +3 -1
  78. package/dist/api/com/atproto/server/activateAccount.js.map +1 -1
  79. package/dist/api/com/atproto/server/createAccount.js +7 -2
  80. package/dist/api/com/atproto/server/createAccount.js.map +1 -1
  81. package/dist/api/com/atproto/server/createSession.d.ts.map +1 -1
  82. package/dist/api/com/atproto/server/createSession.js +8 -1
  83. package/dist/api/com/atproto/server/createSession.js.map +1 -1
  84. package/dist/api/com/atproto/server/deactivateAccount.d.ts +1 -1
  85. package/dist/api/com/atproto/server/deactivateAccount.d.ts.map +1 -1
  86. package/dist/api/com/atproto/server/deactivateAccount.js +11 -5
  87. package/dist/api/com/atproto/server/deactivateAccount.js.map +1 -1
  88. package/dist/api/com/atproto/server/getSession.d.ts.map +1 -1
  89. package/dist/api/com/atproto/server/getSession.js +1 -0
  90. package/dist/api/com/atproto/server/getSession.js.map +1 -1
  91. package/dist/api/com/atproto/server/refreshSession.d.ts.map +1 -1
  92. package/dist/api/com/atproto/server/refreshSession.js +1 -0
  93. package/dist/api/com/atproto/server/refreshSession.js.map +1 -1
  94. package/dist/api/com/atproto/server/updateEmail.d.ts.map +1 -1
  95. package/dist/api/com/atproto/server/updateEmail.js +45 -1
  96. package/dist/api/com/atproto/server/updateEmail.js.map +1 -1
  97. package/dist/auth-verifier.d.ts +1 -0
  98. package/dist/auth-verifier.d.ts.map +1 -1
  99. package/dist/auth-verifier.js +1 -0
  100. package/dist/auth-verifier.js.map +1 -1
  101. package/dist/config/secrets.d.ts +2 -1
  102. package/dist/config/secrets.d.ts.map +1 -1
  103. package/dist/config/secrets.js +25 -18
  104. package/dist/config/secrets.js.map +1 -1
  105. package/dist/context.d.ts +1 -1
  106. package/dist/context.d.ts.map +1 -1
  107. package/dist/context.js +82 -32
  108. package/dist/context.js.map +1 -1
  109. package/dist/index.d.ts +3 -3
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +2 -2
  112. package/dist/index.js.map +1 -1
  113. package/dist/lexicons/app/bsky/authFullApp.defs.d.ts.map +1 -1
  114. package/dist/lexicons/app/bsky/authFullApp.defs.js +10 -0
  115. package/dist/lexicons/app/bsky/authFullApp.defs.js.map +1 -1
  116. package/dist/lexicons/app/bsky/feed/defs.defs.d.ts +8 -0
  117. package/dist/lexicons/app/bsky/feed/defs.defs.d.ts.map +1 -1
  118. package/dist/lexicons/app/bsky/feed/defs.defs.js +2 -0
  119. package/dist/lexicons/app/bsky/feed/defs.defs.js.map +1 -1
  120. package/dist/lexicons/app/bsky/feed/getQuotes.defs.d.ts +6 -0
  121. package/dist/lexicons/app/bsky/feed/getQuotes.defs.d.ts.map +1 -1
  122. package/dist/lexicons/app/bsky/feed/getQuotes.defs.js +2 -0
  123. package/dist/lexicons/app/bsky/feed/getQuotes.defs.js.map +1 -1
  124. package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.d.ts +3 -0
  125. package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.d.ts.map +1 -0
  126. package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.d.ts +65 -0
  127. package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.d.ts.map +1 -0
  128. package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.js +49 -0
  129. package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.defs.js.map +1 -0
  130. package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.js +6 -0
  131. package/dist/lexicons/tools/ozone/inbox/appealActionedSubject.js.map +1 -0
  132. package/dist/lexicons/tools/ozone/inbox/defs.d.ts +2 -0
  133. package/dist/lexicons/tools/ozone/inbox/defs.d.ts.map +1 -0
  134. package/dist/lexicons/tools/ozone/inbox/defs.defs.d.ts +89 -0
  135. package/dist/lexicons/tools/ozone/inbox/defs.defs.d.ts.map +1 -0
  136. package/dist/lexicons/tools/ozone/inbox/defs.defs.js +73 -0
  137. package/dist/lexicons/tools/ozone/inbox/defs.defs.js.map +1 -0
  138. package/dist/lexicons/tools/ozone/inbox/defs.js +5 -0
  139. package/dist/lexicons/tools/ozone/inbox/defs.js.map +1 -0
  140. package/dist/lexicons/tools/ozone/inbox.d.ts +3 -0
  141. package/dist/lexicons/tools/ozone/inbox.d.ts.map +1 -0
  142. package/dist/lexicons/tools/ozone/inbox.js +6 -0
  143. package/dist/lexicons/tools/ozone/inbox.js.map +1 -0
  144. package/dist/lexicons/tools/ozone/queue/createQueue.defs.d.ts +2 -0
  145. package/dist/lexicons/tools/ozone/queue/createQueue.defs.d.ts.map +1 -1
  146. package/dist/lexicons/tools/ozone/queue/createQueue.defs.js +2 -0
  147. package/dist/lexicons/tools/ozone/queue/createQueue.defs.js.map +1 -1
  148. package/dist/lexicons/tools/ozone/queue/defs.defs.d.ts +4 -0
  149. package/dist/lexicons/tools/ozone/queue/defs.defs.d.ts.map +1 -1
  150. package/dist/lexicons/tools/ozone/queue/defs.defs.js +2 -0
  151. package/dist/lexicons/tools/ozone/queue/defs.defs.js.map +1 -1
  152. package/dist/lexicons/tools/ozone/queue/updateQueue.defs.d.ts +3 -1
  153. package/dist/lexicons/tools/ozone/queue/updateQueue.defs.d.ts.map +1 -1
  154. package/dist/lexicons/tools/ozone/queue/updateQueue.defs.js +3 -0
  155. package/dist/lexicons/tools/ozone/queue/updateQueue.defs.js.map +1 -1
  156. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts +89 -9
  157. package/dist/lexicons/tools/ozone/report/defs.defs.d.ts.map +1 -1
  158. package/dist/lexicons/tools/ozone/report/defs.defs.js +20 -0
  159. package/dist/lexicons/tools/ozone/report/defs.defs.js.map +1 -1
  160. package/dist/lexicons/tools/ozone/report/getLiveStats.defs.d.ts +1 -1
  161. package/dist/lexicons/tools/ozone/report/getLiveStats.defs.d.ts.map +1 -1
  162. package/dist/lexicons/tools/ozone/report/getLiveStats.defs.js +1 -1
  163. package/dist/lexicons/tools/ozone/report/getLiveStats.defs.js.map +1 -1
  164. package/dist/lexicons/tools/ozone/report/refreshStats.defs.d.ts +1 -1
  165. package/dist/lexicons/tools/ozone/report/refreshStats.defs.d.ts.map +1 -1
  166. package/dist/lexicons/tools/ozone/report/refreshStats.defs.js +1 -1
  167. package/dist/lexicons/tools/ozone/report/refreshStats.defs.js.map +1 -1
  168. package/dist/lexicons/tools/ozone.d.ts +1 -0
  169. package/dist/lexicons/tools/ozone.d.ts.map +1 -1
  170. package/dist/lexicons/tools/ozone.js +1 -0
  171. package/dist/lexicons/tools/ozone.js.map +1 -1
  172. package/dist/mailer/index.d.ts +7 -1
  173. package/dist/mailer/index.d.ts.map +1 -1
  174. package/dist/mailer/index.js +12 -1
  175. package/dist/mailer/index.js.map +1 -1
  176. package/dist/mailer/templates/sign-in-auth-factor.js +43 -0
  177. package/dist/mailer/templates/sign-in-auth-factor.js.map +1 -0
  178. package/dist/mailer/templates.d.ts +2 -0
  179. package/dist/mailer/templates.d.ts.map +1 -1
  180. package/dist/mailer/templates.js +1 -0
  181. package/dist/mailer/templates.js.map +1 -1
  182. package/dist/pipethrough.d.ts.map +1 -1
  183. package/dist/pipethrough.js +9 -2
  184. package/dist/pipethrough.js.map +1 -1
  185. package/dist/read-after-write/util.d.ts.map +1 -1
  186. package/dist/read-after-write/util.js.map +1 -1
  187. package/package.json +19 -20
@@ -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,+BAA+B,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE7C,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE;QAC3C,SAAS,EAAE;YACT,UAAU,EAAE,CAAC,GAAG,MAAM;YACtB,MAAM,EAAE,GAAG;SACZ;QACD,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,uBAAuB;QAC9C,OAAO,EAAE,KAAK,EAAE,EACd,KAAK,EACL,IAAI,EACJ,GAAG,GACJ,EAAqD,EAAE;YACtD,iEAAiE;YACjE,0EAA0E;YAE1E,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,GAAG,IAAI,IAAI,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,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 const [handleAccnt, emailAcct] = await Promise.all([\n ctx.accountManager.getAccount(handle),\n ctx.accountManager.getAccountByEmail(email),\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;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,+BAA+B,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE7C,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE;QAC3C,SAAS,EAAE;YACT,UAAU,EAAE,CAAC,GAAG,MAAM;YACtB,MAAM,EAAE,GAAG;SACZ;QACD,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,uBAAuB;QAC9C,OAAO,EAAE,KAAK,EAAE,EACd,KAAK,EACL,I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AC;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 +1 @@
1
- {"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/createSession.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,sBAAsB,CAAA;AAG7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAKxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAwFvD"}
1
+ {"version":3,"file":"createSession.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/createSession.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,MAAM,EACZ,MAAM,sBAAsB,CAAA;AAG7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAKxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAgGvD"}
@@ -39,7 +39,13 @@ export default function (server, ctx) {
39
39
  if (body.password.length > OLD_PASSWORD_MAX_LENGTH) {
40
40
  throw new AuthRequiredError('Password too long. Consider resetting your password.');
41
41
  }
42
- const { user, isSoftDeleted, appPassword } = await ctx.accountManager.login(body);
42
+ // @TODO get the locale somehow (either by adding a field in the request
43
+ // body, or by using the `Accept-Language` header).
44
+ const locale = undefined;
45
+ // @NOTE No translation needed for the second-factor challenge: `login()`
46
+ // throws `AuthFactorRequiredError`, already an `AuthRequiredError`
47
+ // carrying this method's declared `AuthFactorTokenRequired` error name.
48
+ const { user, isSoftDeleted, appPassword } = await ctx.accountManager.login({ ...body, locale });
43
49
  if (!body.allowTakendown && isSoftDeleted) {
44
50
  throw new AuthRequiredError('Account has been taken down', 'AccountTakedown');
45
51
  }
@@ -63,6 +69,7 @@ export default function (server, ctx) {
63
69
  handle: (user.handle ?? INVALID_HANDLE),
64
70
  email: user.email ?? undefined,
65
71
  emailConfirmed: !!user.emailConfirmedAt,
72
+ emailAuthFactor: !!user.emailAuthFactorAt,
66
73
  active,
67
74
  status,
68
75
  },
@@ -1 +1 @@
1
- {"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAGL,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,iBAAiB,GAGlB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,G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H,CAAC","sourcesContent":["import { DAY, MINUTE } from '@atproto/common'\nimport {\n type DidString,\n type HandleString,\n INVALID_HANDLE,\n} from '@atproto/syntax'\nimport {\n AuthRequiredError,\n type MethodRateLimit,\n type Server,\n} from '@atproto/xrpc-server'\nimport { formatAccountStatus } from '../../../../account-manager/account-manager.js'\nimport { OLD_PASSWORD_MAX_LENGTH } from '../../../../account-manager/helpers/scrypt.js'\nimport type { AppContext } from '../../../../context.js'\nimport { events } from '../../../../events.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { didDocForSession } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { entrywayClient } = ctx\n\n const rateLimit: MethodRateLimit<\n void,\n com.atproto.server.createSession.$Params,\n com.atproto.server.createSession.$Input\n > = [\n {\n durationMs: DAY,\n points: 300,\n calcKey: ({ input, req }) => `${input.body.identifier}-${req.ip}`,\n },\n {\n durationMs: 5 * MINUTE,\n points: 30,\n calcKey: ({ input, req }) => `${input.body.identifier}-${req.ip}`,\n },\n ]\n\n if (entrywayClient) {\n server.add(com.atproto.server.createSession, {\n rateLimit,\n handler: async ({ input: { body }, req }) => {\n const { headers } = ctx.entrywayPassthruHeaders(req)\n return entrywayClient.xrpc(com.atproto.server.createSession, {\n headers,\n body,\n })\n },\n })\n } else {\n server.add(com.atproto.server.createSession, {\n rateLimit,\n handler: async ({\n input: { body },\n }): Promise<com.atproto.server.createSession.$Output> => {\n if (body.password.length > OLD_PASSWORD_MAX_LENGTH) {\n throw new AuthRequiredError(\n 'Password too long. Consider resetting your password.',\n )\n }\n\n const { user, isSoftDeleted, appPassword } =\n await ctx.accountManager.login(body)\n\n if (!body.allowTakendown && isSoftDeleted) {\n throw new AuthRequiredError(\n 'Account has been taken down',\n 'AccountTakedown',\n )\n }\n\n const [{ accessJwt, refreshJwt }, didDoc] = await Promise.all([\n ctx.accountManager.createSession(\n user.did,\n appPassword,\n isSoftDeleted,\n ),\n didDocForSession(ctx, user.did),\n ])\n\n const { status, active } = formatAccountStatus(user)\n\n events.sessionCreated({\n source: com.atproto.server.createSession.$lxm,\n did: user.did,\n })\n\n return {\n encoding: 'application/json',\n body: {\n accessJwt,\n refreshJwt,\n\n did: user.did as DidString,\n // @ts-expect-error https://github.com/bluesky-social/atproto/pull/4406\n didDoc,\n handle: (user.handle ?? INVALID_HANDLE) as HandleString,\n email: user.email ?? undefined,\n emailConfirmed: !!user.emailConfirmedAt,\n active,\n status,\n },\n }\n },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"createSession.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/createSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAGL,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,iBAAiB,GAGlB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,+CAA+C,CAAA;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,EAAE,cAAc,EAAE,GAAG,GAAG,CAAA;IAE9B,MAAM,SAAS,GAIX;QACF;YACE,UAAU,EAAE,GAAG;YACf,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC,EAAE,EAAE;SAClE;QACD;YACE,UAAU,EAAE,CAAC,GAAG,MAAM;YACtB,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,GAAG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1C,MAAM,IAAI,iBAAiB,CACzB,6BAA6B,EAC7B,iBAAiB,CAClB,CAAA;gBACH,CAAC;gBAED,MAAM,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;oBAC5D,GAAG,CAAC,cAAc,CAAC,aAAa,CAC9B,IAAI,CAAC,GAAG,EACR,WAAW,EACX,aAAa,CACd;oBACD,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;iBAChC,CAAC,CAAA;gBAEF,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAA;gBAEpD,MAAM,CAAC,cAAc,CAAC;oBACpB,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI;oBAC7C,GAAG,EAAE,IAAI,CAAC,GAAG;iBACd,CAAC,CAAA;gBAEF,OAAO;oBACL,QAAQ,EAAE,kBAAkB;oBAC5B,IAAI,EAAE;wBACJ,SAAS;wBACT,UAAU;wBAEV,GAAG,EAAE,IAAI,CAAC,GAAgB;wBAC1B,uEAAuE;wBACvE,MAAM;wBACN,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,cAAc,CAAiB;wBACvD,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;wBAC9B,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB;wBACvC,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,iBAAiB;wBACzC,MAAM;wBACN,MAAM;qBACP;iBACF,CAAA;YACH,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { DAY, MINUTE } from '@atproto/common'\nimport {\n type DidString,\n type HandleString,\n INVALID_HANDLE,\n} from '@atproto/syntax'\nimport {\n AuthRequiredError,\n type MethodRateLimit,\n type Server,\n} from '@atproto/xrpc-server'\nimport { formatAccountStatus } from '../../../../account-manager/account-manager.js'\nimport { OLD_PASSWORD_MAX_LENGTH } from '../../../../account-manager/helpers/scrypt.js'\nimport type { AppContext } from '../../../../context.js'\nimport { events } from '../../../../events.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { didDocForSession } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { entrywayClient } = ctx\n\n const rateLimit: MethodRateLimit<\n void,\n com.atproto.server.createSession.$Params,\n com.atproto.server.createSession.$Input\n > = [\n {\n durationMs: DAY,\n points: 300,\n calcKey: ({ input, req }) => `${input.body.identifier}-${req.ip}`,\n },\n {\n durationMs: 5 * MINUTE,\n points: 30,\n calcKey: ({ input, req }) => `${input.body.identifier}-${req.ip}`,\n },\n ]\n\n if (entrywayClient) {\n server.add(com.atproto.server.createSession, {\n rateLimit,\n handler: async ({ input: { body }, req }) => {\n const { headers } = ctx.entrywayPassthruHeaders(req)\n return entrywayClient.xrpc(com.atproto.server.createSession, {\n headers,\n body,\n })\n },\n })\n } else {\n server.add(com.atproto.server.createSession, {\n rateLimit,\n handler: async ({\n input: { body },\n }): Promise<com.atproto.server.createSession.$Output> => {\n if (body.password.length > OLD_PASSWORD_MAX_LENGTH) {\n throw new AuthRequiredError(\n 'Password too long. Consider resetting your password.',\n )\n }\n\n // @TODO get the locale somehow (either by adding a field in the request\n // body, or by using the `Accept-Language` header).\n const locale = undefined\n\n // @NOTE No translation needed for the second-factor challenge: `login()`\n // throws `AuthFactorRequiredError`, already an `AuthRequiredError`\n // carrying this method's declared `AuthFactorTokenRequired` error name.\n const { user, isSoftDeleted, appPassword } =\n await ctx.accountManager.login({ ...body, locale })\n\n if (!body.allowTakendown && isSoftDeleted) {\n throw new AuthRequiredError(\n 'Account has been taken down',\n 'AccountTakedown',\n )\n }\n\n const [{ accessJwt, refreshJwt }, didDoc] = await Promise.all([\n ctx.accountManager.createSession(\n user.did,\n appPassword,\n isSoftDeleted,\n ),\n didDocForSession(ctx, user.did),\n ])\n\n const { status, active } = formatAccountStatus(user)\n\n events.sessionCreated({\n source: com.atproto.server.createSession.$lxm,\n did: user.did,\n })\n\n return {\n encoding: 'application/json',\n body: {\n accessJwt,\n refreshJwt,\n\n did: user.did as DidString,\n // @ts-expect-error https://github.com/bluesky-social/atproto/pull/4406\n didDoc,\n handle: (user.handle ?? INVALID_HANDLE) as HandleString,\n email: user.email ?? undefined,\n emailConfirmed: !!user.emailConfirmedAt,\n emailAuthFactor: !!user.emailAuthFactorAt,\n active,\n status,\n },\n }\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,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C;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,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tC,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":"getSession.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/getSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAIvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAuDvD"}
1
+ {"version":3,"file":"getSession.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/getSession.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAIvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QAwDvD"}
@@ -39,6 +39,7 @@ export default function (server, ctx) {
39
39
  handle: (user.handle ?? INVALID_HANDLE),
40
40
  email: user.email ?? undefined,
41
41
  emailConfirmed: !!user.emailConfirmedAt,
42
+ emailAuthFactor: !!user.emailAuthFactorAt,
42
43
  active,
43
44
  status,
44
45
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"getSession.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/getSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AAEpF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE;QACxC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;YACnC,UAAU,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC;YACpC,SAAS,EAAE,GAAG,EAAE;gBACd,4DAA4D;YAC9D,CAAC;SAC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c,CAAiB;oBACvD,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;oBAC9B,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB;oBACvC,MAAM;oBACN,MAAM;iBACP,CAAC;aACH,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,MAAM,CACb,EAAE,WAAW,EAA8B,EAC3C,IAA+C;IAE/C,IACE,WAAW,CAAC,IAAI,KAAK,OAAO;QAC5B,CAAC,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EACzE,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;QAChE,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import {\n type DidString,\n type HandleString,\n INVALID_HANDLE,\n} from '@atproto/syntax'\nimport { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport { formatAccountStatus } from '../../../../account-manager/account-manager.js'\nimport type { AccessOutput, OAuthOutput } from '../../../../auth-output.js'\nimport { AuthScope } from '../../../../auth-scope.js'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { didDocForSession } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.server.getSession, {\n auth: ctx.authVerifier.authorization({\n additional: [AuthScope.SignupQueued],\n authorize: () => {\n // Always allowed. \"email\" access is checked in the handler.\n },\n }),\n handler: async ({ auth, req }) => {\n if (ctx.entrywayClient) {\n const { headers } = await ctx.entrywayAuthHeaders(\n req,\n auth.credentials.did,\n 'com.atproto.server.getSession',\n )\n\n const { body } = await ctx.entrywayClient.xrpc(\n com.atproto.server.getSession,\n { headers },\n )\n\n return {\n encoding: 'application/json' as const,\n body: output(auth, body),\n }\n }\n\n const did = auth.credentials.did\n const [user, didDoc] = await Promise.all([\n ctx.accountManager.getAccount(did, { includeDeactivated: true }),\n didDocForSession(ctx, did),\n ])\n if (!user) {\n throw new InvalidRequestError(\n `Could not find user info for account: ${did}`,\n )\n }\n\n const { status, active } = formatAccountStatus(user)\n\n return {\n encoding: 'application/json' as const,\n body: output(auth, {\n did: user.did as DidString,\n // @ts-expect-error https://github.com/bluesky-social/atproto/pull/4406\n didDoc,\n handle: (user.handle ?? INVALID_HANDLE) as HandleString,\n email: user.email ?? undefined,\n emailConfirmed: !!user.emailConfirmedAt,\n active,\n status,\n }),\n }\n },\n })\n}\n\nfunction output(\n { credentials }: OAuthOutput | AccessOutput,\n data: com.atproto.server.getSession.$OutputBody,\n): com.atproto.server.getSession.$OutputBody {\n if (\n credentials.type === 'oauth' &&\n !credentials.permissions.allowsAccount({ attr: 'email', action: 'read' })\n ) {\n const { email, emailAuthFactor, emailConfirmed, ...rest } = data\n return rest\n }\n\n return data\n}\n"]}
1
+ {"version":3,"file":"getSession.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/getSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AAEpF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAErD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE;QACxC,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC;YACnC,UAAU,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC;YACpC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AM;oBACN,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,cAAc,CAAiB;oBACvD,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;oBAC9B,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB;oBACvC,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,iBAAiB;oBACzC,MAAM;oBACN,MAAM;iBACP,CAAC;aACH,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,MAAM,CACb,EAAE,WAAW,EAA8B,EAC3C,IAA+C;IAE/C,IACE,WAAW,CAAC,IAAI,KAAK,OAAO;QAC5B,CAAC,WAAW,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EACzE,CAAC;QACD,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;QAChE,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import {\n type DidString,\n type HandleString,\n INVALID_HANDLE,\n} from '@atproto/syntax'\nimport { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport { formatAccountStatus } from '../../../../account-manager/account-manager.js'\nimport type { AccessOutput, OAuthOutput } from '../../../../auth-output.js'\nimport { AuthScope } from '../../../../auth-scope.js'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { didDocForSession } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.server.getSession, {\n auth: ctx.authVerifier.authorization({\n additional: [AuthScope.SignupQueued],\n authorize: () => {\n // Always allowed. \"email\" access is checked in the handler.\n },\n }),\n handler: async ({ auth, req }) => {\n if (ctx.entrywayClient) {\n const { headers } = await ctx.entrywayAuthHeaders(\n req,\n auth.credentials.did,\n 'com.atproto.server.getSession',\n )\n\n const { body } = await ctx.entrywayClient.xrpc(\n com.atproto.server.getSession,\n { headers },\n )\n\n return {\n encoding: 'application/json' as const,\n body: output(auth, body),\n }\n }\n\n const did = auth.credentials.did\n const [user, didDoc] = await Promise.all([\n ctx.accountManager.getAccount(did, { includeDeactivated: true }),\n didDocForSession(ctx, did),\n ])\n if (!user) {\n throw new InvalidRequestError(\n `Could not find user info for account: ${did}`,\n )\n }\n\n const { status, active } = formatAccountStatus(user)\n\n return {\n encoding: 'application/json' as const,\n body: output(auth, {\n did: user.did as DidString,\n // @ts-expect-error https://github.com/bluesky-social/atproto/pull/4406\n didDoc,\n handle: (user.handle ?? INVALID_HANDLE) as HandleString,\n email: user.email ?? undefined,\n emailConfirmed: !!user.emailConfirmedAt,\n emailAuthFactor: !!user.emailAuthFactorAt,\n active,\n status,\n }),\n }\n },\n })\n}\n\nfunction output(\n { credentials }: OAuthOutput | AccessOutput,\n data: com.atproto.server.getSession.$OutputBody,\n): com.atproto.server.getSession.$OutputBody {\n if (\n credentials.type === 'oauth' &&\n !credentials.permissions.allowsAccount({ attr: 'email', action: 'read' })\n ) {\n const { email, emailAuthFactor, emailConfirmed, ...rest } = data\n return rest\n }\n\n return data\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"refreshSession.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/refreshSession.ts"],"names":[],"mappings":"AAKA,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,QAgEvD"}
1
+ {"version":3,"file":"refreshSession.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/refreshSession.ts"],"names":[],"mappings":"AAKA,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,QAiEvD"}
@@ -49,6 +49,7 @@ export default function (server, ctx) {
49
49
  handle: (user.handle ?? INVALID_HANDLE),
50
50
  email: user.email ?? undefined,
51
51
  emailConfirmed: !!user.emailConfirmedAt,
52
+ emailAuthFactor: !!user.emailAuthFactorAt,
52
53
  active,
53
54
  status,
54
55
  },
@@ -1 +1 @@
1
- {"version":3,"file":"refreshSession.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/refreshSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE;QAC5C,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE;QAChC,OAAO,EAAE,KAAK,EAAE,EACd,IAAI,EACJ,GAAG,GACJ,EAAsD,EAAE;YACvD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA;YAChC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE;gBACpD,kBAAkB,EAAE,IAAI;gBACxB,gBAAgB,EAAE,IAAI;aACvB,CAAC,CAA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,UAAU;oBAE9B,GAAG,EAAE,IAAI,CAAC,GAAgB;oBAC1B,uEAAuE;oBACvE,MAAM;oBACN,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,cAAc,CAAiB;oBACvD,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;oBAC9B,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB;oBACvC,MAAM;oBACN,MAAM;iBACP;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n type DidString,\n type HandleString,\n INVALID_HANDLE,\n} from '@atproto/syntax'\nimport {\n AuthRequiredError,\n InvalidRequestError,\n type Server,\n} from '@atproto/xrpc-server'\nimport { formatAccountStatus } from '../../../../account-manager/account-manager.js'\nimport type { AppContext } from '../../../../context.js'\nimport { softDeleted } from '../../../../db/util.js'\nimport { events } from '../../../../events.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { didDocForSession } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.server.refreshSession, {\n auth: ctx.authVerifier.refresh(),\n handler: async ({\n auth,\n req,\n }): Promise<com.atproto.server.refreshSession.$Output> => {\n const did = auth.credentials.did\n const user = await ctx.accountManager.getAccount(did, {\n includeDeactivated: true,\n includeTakenDown: true,\n })\n if (!user) {\n throw new InvalidRequestError(\n `Could not find user info for account: ${did}`,\n )\n }\n if (softDeleted(user)) {\n throw new AuthRequiredError(\n 'Account has been taken down',\n 'AccountTakedown',\n )\n }\n\n if (ctx.entrywayClient) {\n const { headers } = ctx.entrywayPassthruHeaders(req)\n return ctx.entrywayClient.xrpc(com.atproto.server.refreshSession, {\n headers,\n })\n }\n\n const [didDoc, rotated] = await Promise.all([\n didDocForSession(ctx, user.did),\n ctx.accountManager.rotateRefreshToken(auth.credentials.tokenId),\n ])\n if (rotated === null) {\n throw new InvalidRequestError('Token has been revoked', 'ExpiredToken')\n }\n\n const { status, active } = formatAccountStatus(user)\n\n events.sessionRefreshed({\n source: com.atproto.server.refreshSession.$lxm,\n did: user.did,\n })\n\n return {\n encoding: 'application/json' as const,\n body: {\n accessJwt: rotated.accessJwt,\n refreshJwt: rotated.refreshJwt,\n\n did: user.did as DidString,\n // @ts-expect-error https://github.com/bluesky-social/atproto/pull/4406\n didDoc,\n handle: (user.handle ?? INVALID_HANDLE) as HandleString,\n email: user.email ?? undefined,\n emailConfirmed: !!user.emailConfirmedAt,\n active,\n status,\n },\n }\n },\n })\n}\n"]}
1
+ {"version":3,"file":"refreshSession.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/refreshSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,GAEpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAA;AAEpF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,CAAC,OAAO,WAAW,MAAc,EAAE,GAAe;IACtD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE;QAC5C,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE;QAChC,OAAO,EAAE,KAAK,EAAE,EACd,IAAI,EACJ,GAAG,GACJ,EAAsD,EAAE;YACvD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA;YAChC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,EAAE;gBACpD,kBAAkB,EAAE,IAAI;gBACxB,gBAAgB,EAAE,IAAI;aACvB,CAAC,C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AC,UAAU;oBAE9B,GAAG,EAAE,IAAI,CAAC,GAAgB;oBAC1B,uEAAuE;oBACvE,MAAM;oBACN,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,cAAc,CAAiB;oBACvD,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;oBAC9B,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB;oBACvC,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,iBAAiB;oBACzC,MAAM;oBACN,MAAM;iBACP;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n type DidString,\n type HandleString,\n INVALID_HANDLE,\n} from '@atproto/syntax'\nimport {\n AuthRequiredError,\n InvalidRequestError,\n type Server,\n} from '@atproto/xrpc-server'\nimport { formatAccountStatus } from '../../../../account-manager/account-manager.js'\nimport type { AppContext } from '../../../../context.js'\nimport { softDeleted } from '../../../../db/util.js'\nimport { events } from '../../../../events.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { didDocForSession } from './util.js'\n\nexport default function (server: Server, ctx: AppContext) {\n server.add(com.atproto.server.refreshSession, {\n auth: ctx.authVerifier.refresh(),\n handler: async ({\n auth,\n req,\n }): Promise<com.atproto.server.refreshSession.$Output> => {\n const did = auth.credentials.did\n const user = await ctx.accountManager.getAccount(did, {\n includeDeactivated: true,\n includeTakenDown: true,\n })\n if (!user) {\n throw new InvalidRequestError(\n `Could not find user info for account: ${did}`,\n )\n }\n if (softDeleted(user)) {\n throw new AuthRequiredError(\n 'Account has been taken down',\n 'AccountTakedown',\n )\n }\n\n if (ctx.entrywayClient) {\n const { headers } = ctx.entrywayPassthruHeaders(req)\n return ctx.entrywayClient.xrpc(com.atproto.server.refreshSession, {\n headers,\n })\n }\n\n const [didDoc, rotated] = await Promise.all([\n didDocForSession(ctx, user.did),\n ctx.accountManager.rotateRefreshToken(auth.credentials.tokenId),\n ])\n if (rotated === null) {\n throw new InvalidRequestError('Token has been revoked', 'ExpiredToken')\n }\n\n const { status, active } = formatAccountStatus(user)\n\n events.sessionRefreshed({\n source: com.atproto.server.refreshSession.$lxm,\n did: user.did,\n })\n\n return {\n encoding: 'application/json' as const,\n body: {\n accessJwt: rotated.accessJwt,\n refreshJwt: rotated.refreshJwt,\n\n did: user.did as DidString,\n // @ts-expect-error https://github.com/bluesky-social/atproto/pull/4406\n didDoc,\n handle: (user.handle ?? INVALID_HANDLE) as HandleString,\n email: user.email ?? undefined,\n emailConfirmed: !!user.emailConfirmedAt,\n emailAuthFactor: !!user.emailAuthFactorAt,\n active,\n status,\n },\n }\n },\n })\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"updateEmail.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/updateEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QA6CvD"}
1
+ {"version":3,"file":"updateEmail.d.ts","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/updateEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAIxD,MAAM,CAAC,OAAO,WAAW,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,QA6FvD"}
@@ -23,10 +23,54 @@ export default function (server, ctx) {
23
23
  auth,
24
24
  handler: async ({ auth, input: { body } }) => {
25
25
  const did = auth.credentials.did;
26
- const { token, email } = body;
26
+ const account = await ctx.accountManager.getAccount(did, {
27
+ includeDeactivated: true,
28
+ includeTakenDown: true,
29
+ });
30
+ if (!account) {
31
+ throw new InvalidRequestError(`Could not find user info for account: ${did}`);
32
+ }
33
+ const { token } = body;
34
+ const email = body.email.toLowerCase();
27
35
  // @TODO get the locale somehow (either by adding a field in the request
28
36
  // body, or by using the `Accept-Language` header).
29
37
  const locale = undefined;
38
+ // @NOTE Handle explicit toggles even when the factor already matches:
39
+ // updating the email would clear its confirmation and disable 2FA.
40
+ if (body.emailAuthFactor != null) {
41
+ if (body.emailAuthFactor) {
42
+ // User is trying to enable email OTP
43
+ if (account.emailConfirmedAt && account.email === email) {
44
+ // Enabling only adds protection: immediate, no token required.
45
+ await ctx.accountManager.enableEmailAuthFactor({ did });
46
+ return; // no need to continue to email change since email is not being changed
47
+ }
48
+ else {
49
+ // @NOTE updating the user email address has the effect of resetting the
50
+ // email OTP status, reverting any action we would be performing here.
51
+ // Instead of silently ignoring a request to enable email OTP while updating
52
+ // the email, we provide an error message.
53
+ throw new InvalidRequestError('Please change and verify your email before enabling OTP');
54
+ }
55
+ }
56
+ else {
57
+ // User is trying to disable email OTP
58
+ if (account.email === email) {
59
+ // Disabling removes a second factor, so it's gated by an
60
+ // `update_email` OTP: the first call (no token) emails a code and
61
+ // makes no change; the second (with token) verifies and disables.
62
+ await ctx.accountManager.disableEmailAuthFactor({
63
+ did,
64
+ token,
65
+ locale,
66
+ });
67
+ return; // no need to continue to email change since email is not being changed
68
+ }
69
+ else {
70
+ // No-op: changing email address always disables OTP
71
+ }
72
+ }
73
+ }
30
74
  try {
31
75
  await ctx.accountManager.updateEmail(did, email, token, { locale });
32
76
  }
@@ -1 +1 @@
1
- {"version":3,"file":"updateEmail.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/updateEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAe,MAAM,sBAAsB,CAAA;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAA;AAEvF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAA;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,MAAM,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EAAE,MAAM,EAAE,CAAC,CAAA;gBACrE,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAI,KAAK,YAAY,sBAAsB,EAAE,CAAC;wBAC5C,MAAM,IAAI,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;oBACpE,CAAC;oBAED,MAAM,KAAK,CAAA;gBACb,CAAC;YACH,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport { UserAlreadyExistsError } from '../../../../account-manager/helpers/account.js'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { requestEmailUpdateAuth } from './requestEmailUpdate.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { entrywayClient } = ctx\n\n // @NOTE Ensure that both endpoints use the same authentication logic\n const auth = requestEmailUpdateAuth(ctx)\n\n if (entrywayClient) {\n server.add(com.atproto.server.updateEmail, {\n auth,\n handler: async ({ auth, input: { body }, req }) => {\n const { headers } = await ctx.entrywayAuthHeaders(\n req,\n auth.credentials.did,\n com.atproto.server.updateEmail.$lxm,\n )\n\n await entrywayClient.xrpc(com.atproto.server.updateEmail, {\n headers,\n body,\n })\n },\n })\n } else {\n server.add(com.atproto.server.updateEmail, {\n auth,\n handler: async ({ auth, input: { body } }) => {\n const did = auth.credentials.did\n const { token, email } = body\n\n // @TODO get the locale somehow (either by adding a field in the request\n // body, or by using the `Accept-Language` header).\n const locale = undefined\n\n try {\n await ctx.accountManager.updateEmail(did, email, token, { locale })\n } catch (cause) {\n if (cause instanceof UserAlreadyExistsError) {\n throw new InvalidRequestError(cause.message, undefined, { cause })\n }\n\n throw cause\n }\n },\n })\n }\n}\n"]}
1
+ {"version":3,"file":"updateEmail.js","sourceRoot":"","sources":["../../../../../src/api/com/atproto/server/updateEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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BAAM,CAAC;4BACN,oDAAoD;wBACtD,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,IAAI,CAAC;oBACH,MAAM,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;gBACrE,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAI,KAAK,YAAY,sBAAsB,EAAE,CAAC;wBAC5C,MAAM,IAAI,mBAAmB,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;oBACpE,CAAC;oBAED,MAAM,KAAK,CAAA;gBACb,CAAC;YACH,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;AACH,CAAC","sourcesContent":["import { InvalidRequestError, type Server } from '@atproto/xrpc-server'\nimport { UserAlreadyExistsError } from '../../../../account-manager/helpers/account.js'\nimport type { AppContext } from '../../../../context.js'\nimport { com } from '../../../../lexicons/index.js'\nimport { requestEmailUpdateAuth } from './requestEmailUpdate.js'\n\nexport default function (server: Server, ctx: AppContext) {\n const { entrywayClient } = ctx\n\n // @NOTE Ensure that both endpoints use the same authentication logic\n const auth = requestEmailUpdateAuth(ctx)\n\n if (entrywayClient) {\n server.add(com.atproto.server.updateEmail, {\n auth,\n handler: async ({ auth, input: { body }, req }) => {\n const { headers } = await ctx.entrywayAuthHeaders(\n req,\n auth.credentials.did,\n com.atproto.server.updateEmail.$lxm,\n )\n\n await entrywayClient.xrpc(com.atproto.server.updateEmail, {\n headers,\n body,\n })\n },\n })\n } else {\n server.add(com.atproto.server.updateEmail, {\n auth,\n handler: async ({ auth, input: { body } }) => {\n const did = auth.credentials.did\n const account = await ctx.accountManager.getAccount(did, {\n includeDeactivated: true,\n includeTakenDown: true,\n })\n if (!account) {\n throw new InvalidRequestError(\n `Could not find user info for account: ${did}`,\n )\n }\n\n const { token } = body\n const email = body.email.toLowerCase()\n // @TODO get the locale somehow (either by adding a field in the request\n // body, or by using the `Accept-Language` header).\n const locale = undefined\n\n // @NOTE Handle explicit toggles even when the factor already matches:\n // updating the email would clear its confirmation and disable 2FA.\n if (body.emailAuthFactor != null) {\n if (body.emailAuthFactor) {\n // User is trying to enable email OTP\n if (account.emailConfirmedAt && account.email === email) {\n // Enabling only adds protection: immediate, no token required.\n await ctx.accountManager.enableEmailAuthFactor({ did })\n\n return // no need to continue to email change since email is not being changed\n } else {\n // @NOTE updating the user email address has the effect of resetting the\n // email OTP status, reverting any action we would be performing here.\n // Instead of silently ignoring a request to enable email OTP while updating\n // the email, we provide an error message.\n throw new InvalidRequestError(\n 'Please change and verify your email before enabling OTP',\n )\n }\n } else {\n // User is trying to disable email OTP\n if (account.email === email) {\n // Disabling removes a second factor, so it's gated by an\n // `update_email` OTP: the first call (no token) emails a code and\n // makes no change; the second (with token) verifies and disables.\n await ctx.accountManager.disableEmailAuthFactor({\n did,\n token,\n locale,\n })\n\n return // no need to continue to email change since email is not being changed\n } else {\n // No-op: changing email address always disables OTP\n }\n }\n }\n\n try {\n await ctx.accountManager.updateEmail(did, email, token, { locale })\n } catch (cause) {\n if (cause instanceof UserAlreadyExistsError) {\n throw new InvalidRequestError(cause.message, undefined, { cause })\n }\n\n throw cause\n }\n },\n })\n }\n}\n"]}
@@ -93,6 +93,7 @@ export declare class AuthVerifier {
93
93
  }
94
94
  export declare function isUserOrAdmin(auth: AccessOutput | OAuthOutput | AdminTokenOutput | UnauthenticatedOutput, did: string): boolean;
95
95
  export declare const bearerTokenFromReq: (req: IncomingMessage) => string | null;
96
+ export { type KeyObject };
96
97
  export declare const createSecretKeyObject: (secret: string) => KeyObject;
97
98
  export declare const createPublicKeyObject: (publicKeyHex: string) => KeyObject;
98
99
  //# sourceMappingURL=auth-verifier.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-verifier.d.ts","sourceRoot":"","sources":["../src/auth-verifier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EA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;;OA4C1B;CACF;AAKD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,YAAY,GAAG,WAAW,GAAG,gBAAgB,GAAG,qBAAqB,EAC3E,GAAG,EAAE,MAAM,GACV,OAAO,CAQT;AAmDD,eAAO,MAAM,kBAAkB,QAAS,eAAe,kBAGtD,CAAA;AAoBD,OAAO,EAAE,KAAK,SAAS,EAAE,CAAA;AAEzB,eAAO,MAAM,qBAAqB,WAAY,MAAM,KAAG,SAEtD,CAAA;AAED,eAAO,MAAM,qBAAqB,iBAAkB,MAAM,KAAG,SAa5D,CAAA"}
@@ -430,6 +430,7 @@ const parseBasicAuth = (req) => {
430
430
  return null;
431
431
  }
432
432
  };
433
+ export {};
433
434
  export const createSecretKeyObject = (secret) => {
434
435
  return createSecretKey(Buffer.from(secret));
435
436
  };