@kayjs/auth 0.0.0-stage → 1.104.1

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 (407) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +78 -2
  3. package/llms/admin-and-organizations.md +70 -0
  4. package/llms/admin-pages.md +30 -0
  5. package/llms/grouped-methods.md +106 -0
  6. package/llms/hardening-and-testing.md +108 -0
  7. package/llms/oauth-passkeys-two-factor.md +111 -0
  8. package/llms/oauth-providers.md +28 -0
  9. package/llms/oauth-server-and-tokens.md +76 -0
  10. package/llms/organization-pages.md +20 -0
  11. package/llms/passwords-and-mails.md +129 -0
  12. package/llms/sessions-and-guards.md +51 -0
  13. package/llms/setup.md +122 -0
  14. package/llms/signed-in-components.md +59 -0
  15. package/llms.txt +28 -0
  16. package/package.json +85 -4
  17. package/src/access.ts +31 -0
  18. package/src/account.ts +198 -0
  19. package/src/add.ts +70 -0
  20. package/src/address.ts +51 -0
  21. package/src/admin.ts +361 -0
  22. package/src/auditWording.ts +153 -0
  23. package/src/auth.ts +219 -0
  24. package/src/authorize/clients.ts +160 -0
  25. package/src/authorize/grants.ts +44 -0
  26. package/src/authorize/metadata.ts +72 -0
  27. package/src/authorize/register.ts +38 -0
  28. package/src/authorize/reply.ts +9 -0
  29. package/src/authorize/request.ts +253 -0
  30. package/src/authorize/resource.ts +34 -0
  31. package/src/authorize/revoke.ts +36 -0
  32. package/src/authorize/routes.ts +87 -0
  33. package/src/authorize/token.ts +213 -0
  34. package/src/authorize/uris.ts +76 -0
  35. package/src/bearer.ts +208 -0
  36. package/src/bearerHeader.ts +11 -0
  37. package/src/breached.ts +47 -0
  38. package/src/browser.ts +59 -0
  39. package/src/captcha.ts +196 -0
  40. package/src/cbor.ts +129 -0
  41. package/src/components/deletion-banner.kay +20 -0
  42. package/src/components/impersonation-banner.kay +21 -0
  43. package/src/components/signed-in.kay +8 -0
  44. package/src/components/signed-out.kay +6 -0
  45. package/src/components/user-menu.kay +21 -0
  46. package/src/context.ts +5 -0
  47. package/src/core.ts +308 -0
  48. package/src/createUserCommand.ts +217 -0
  49. package/src/decide.ts +45 -0
  50. package/src/deletion.ts +80 -0
  51. package/src/devTool.ts +104 -0
  52. package/src/device.ts +37 -0
  53. package/src/email.ts +594 -0
  54. package/src/erase.ts +237 -0
  55. package/src/events.ts +297 -0
  56. package/src/export.ts +101 -0
  57. package/src/failure.ts +63 -0
  58. package/src/forwardAuth.ts +55 -0
  59. package/src/forwardRoutes.ts +68 -0
  60. package/src/gate.ts +104 -0
  61. package/src/guard.ts +22 -0
  62. package/src/guards.ts +72 -0
  63. package/src/guesses.ts +99 -0
  64. package/src/index.ts +46 -0
  65. package/src/keys.ts +51 -0
  66. package/src/limits.ts +182 -0
  67. package/src/load.ts +18 -0
  68. package/src/locale.ts +15 -0
  69. package/src/log.ts +4 -0
  70. package/src/mail.ts +225 -0
  71. package/src/memoryStore.ts +599 -0
  72. package/src/messages/fr.ts +357 -0
  73. package/src/methods/account.ts +80 -0
  74. package/src/methods/admin.ts +63 -0
  75. package/src/methods/audit.ts +15 -0
  76. package/src/methods/email.ts +39 -0
  77. package/src/methods/magicLink.ts +32 -0
  78. package/src/methods/oauth.ts +35 -0
  79. package/src/methods/oauthServer.ts +31 -0
  80. package/src/methods/organizations.ts +96 -0
  81. package/src/methods/passkeys.ts +61 -0
  82. package/src/methods/password.ts +53 -0
  83. package/src/methods/sessions.ts +18 -0
  84. package/src/methods/tokens.ts +24 -0
  85. package/src/methods/twoFactor.ts +62 -0
  86. package/src/oauth/client.ts +324 -0
  87. package/src/oauth/flow.ts +350 -0
  88. package/src/oauth/index.ts +5 -0
  89. package/src/oauth/pkce.ts +20 -0
  90. package/src/oauth/providers.ts +490 -0
  91. package/src/oauth/refresher.ts +177 -0
  92. package/src/oauth/timeout.ts +2 -0
  93. package/src/oauth/types.ts +78 -0
  94. package/src/oauthTest.ts +112 -0
  95. package/src/organizations.ts +675 -0
  96. package/src/organizationsCore.ts +60 -0
  97. package/src/own.ts +313 -0
  98. package/src/pages/components/captcha.kay +16 -0
  99. package/src/pages/components/frame.kay +11 -0
  100. package/src/pages/components/message.kay +8 -0
  101. package/src/pages/components/panel.kay +12 -0
  102. package/src/pages/components/passkey-add.kay +48 -0
  103. package/src/pages/components/passkey-sign-in.kay +34 -0
  104. package/src/pages/components/passkey-two-factor.kay +33 -0
  105. package/src/pages/components/proof.kay +15 -0
  106. package/src/pages/components/provider-buttons.kay +25 -0
  107. package/src/pages/components/recovery-codes.kay +13 -0
  108. package/src/pages/components/separator.kay +4 -0
  109. package/src/pages/english.ts +82 -0
  110. package/src/pages/forms.ts +185 -0
  111. package/src/pages/index.ts +361 -0
  112. package/src/pages/organizationPage.ts +12 -0
  113. package/src/pages/routes/account/_guard.ts +15 -0
  114. package/src/pages/routes/account/_layout.kay +37 -0
  115. package/src/pages/routes/account/clients.kay +33 -0
  116. package/src/pages/routes/account/connections.kay +57 -0
  117. package/src/pages/routes/account/data.kay +106 -0
  118. package/src/pages/routes/account/index.kay +109 -0
  119. package/src/pages/routes/account/organizations/[org].kay +188 -0
  120. package/src/pages/routes/account/organizations/_guard.ts +8 -0
  121. package/src/pages/routes/account/organizations/index.kay +86 -0
  122. package/src/pages/routes/account/security.kay +164 -0
  123. package/src/pages/routes/account/sessions.kay +51 -0
  124. package/src/pages/routes/account/tokens.kay +84 -0
  125. package/src/pages/routes/admin/_layout.kay +43 -0
  126. package/src/pages/routes/admin/audit.kay +43 -0
  127. package/src/pages/routes/admin/index.kay +60 -0
  128. package/src/pages/routes/admin/users/[id].kay +181 -0
  129. package/src/pages/routes/confirm-email.kay +39 -0
  130. package/src/pages/routes/invitation.kay +104 -0
  131. package/src/pages/routes/magic-link.kay +42 -0
  132. package/src/pages/routes/oauth/authorize.kay +80 -0
  133. package/src/pages/routes/register.kay +83 -0
  134. package/src/pages/routes/reset-password.kay +73 -0
  135. package/src/pages/routes/sign-in.kay +128 -0
  136. package/src/pages/routes/two-factor.kay +61 -0
  137. package/src/pages/routes/verify-email.kay +83 -0
  138. package/src/passkeys.ts +373 -0
  139. package/src/password.ts +316 -0
  140. package/src/payloads.ts +22 -0
  141. package/src/pg.ts +705 -0
  142. package/src/profile.ts +43 -0
  143. package/src/proof.ts +110 -0
  144. package/src/prune.ts +123 -0
  145. package/src/rates.ts +82 -0
  146. package/src/request.ts +712 -0
  147. package/src/requiredTwoFactor.ts +71 -0
  148. package/src/requirement.ts +23 -0
  149. package/src/roles.ts +18 -0
  150. package/src/routes.ts +202 -0
  151. package/src/rules-check.ts +37 -0
  152. package/src/rules.ts +108 -0
  153. package/src/securityNotice.ts +45 -0
  154. package/src/sessions.ts +184 -0
  155. package/src/setup.ts +417 -0
  156. package/src/signInOptions.ts +9 -0
  157. package/src/state.ts +34 -0
  158. package/src/store.ts +410 -0
  159. package/src/storeHelpers.ts +23 -0
  160. package/src/test.ts +46 -0
  161. package/src/testCookies.ts +9 -0
  162. package/src/testHelpers.ts +58 -0
  163. package/src/testing.ts +113 -0
  164. package/src/text.ts +6 -0
  165. package/src/totp.ts +120 -0
  166. package/src/twoFactor.ts +200 -0
  167. package/src/types.ts +23 -0
  168. package/src/userData.ts +47 -0
  169. package/src/viewer-layout/_layout.kay +11 -0
  170. package/src/viewer.ts +116 -0
  171. package/src/wayIn.ts +40 -0
  172. package/src/webauthn.ts +375 -0
  173. package/src/wsAuth.ts +53 -0
  174. package/types/access.d.ts +12 -0
  175. package/types/access.d.ts.map +1 -0
  176. package/types/account.d.ts +32 -0
  177. package/types/account.d.ts.map +1 -0
  178. package/types/add.d.ts +29 -0
  179. package/types/add.d.ts.map +1 -0
  180. package/types/address.d.ts +2 -0
  181. package/types/address.d.ts.map +1 -0
  182. package/types/admin.d.ts +84 -0
  183. package/types/admin.d.ts.map +1 -0
  184. package/types/auditWording.d.ts +9 -0
  185. package/types/auditWording.d.ts.map +1 -0
  186. package/types/auth.d.ts +3475 -0
  187. package/types/auth.d.ts.map +1 -0
  188. package/types/authorize/clients.d.ts +15 -0
  189. package/types/authorize/clients.d.ts.map +1 -0
  190. package/types/authorize/grants.d.ts +15 -0
  191. package/types/authorize/grants.d.ts.map +1 -0
  192. package/types/authorize/metadata.d.ts +20 -0
  193. package/types/authorize/metadata.d.ts.map +1 -0
  194. package/types/authorize/register.d.ts +4 -0
  195. package/types/authorize/register.d.ts.map +1 -0
  196. package/types/authorize/reply.d.ts +6 -0
  197. package/types/authorize/reply.d.ts.map +1 -0
  198. package/types/authorize/request.d.ts +48 -0
  199. package/types/authorize/request.d.ts.map +1 -0
  200. package/types/authorize/resource.d.ts +4 -0
  201. package/types/authorize/resource.d.ts.map +1 -0
  202. package/types/authorize/revoke.d.ts +4 -0
  203. package/types/authorize/revoke.d.ts.map +1 -0
  204. package/types/authorize/routes.d.ts +5 -0
  205. package/types/authorize/routes.d.ts.map +1 -0
  206. package/types/authorize/token.d.ts +7 -0
  207. package/types/authorize/token.d.ts.map +1 -0
  208. package/types/authorize/uris.d.ts +5 -0
  209. package/types/authorize/uris.d.ts.map +1 -0
  210. package/types/bearer.d.ts +45 -0
  211. package/types/bearer.d.ts.map +1 -0
  212. package/types/bearerHeader.d.ts +3 -0
  213. package/types/bearerHeader.d.ts.map +1 -0
  214. package/types/breached.d.ts +5 -0
  215. package/types/breached.d.ts.map +1 -0
  216. package/types/browser.d.ts +11 -0
  217. package/types/browser.d.ts.map +1 -0
  218. package/types/captcha.d.ts +42 -0
  219. package/types/captcha.d.ts.map +1 -0
  220. package/types/cbor.d.ts +4 -0
  221. package/types/cbor.d.ts.map +1 -0
  222. package/types/context.d.ts +3 -0
  223. package/types/context.d.ts.map +1 -0
  224. package/types/core.d.ts +180 -0
  225. package/types/core.d.ts.map +1 -0
  226. package/types/createUserCommand.d.ts +11 -0
  227. package/types/createUserCommand.d.ts.map +1 -0
  228. package/types/decide.d.ts +12 -0
  229. package/types/decide.d.ts.map +1 -0
  230. package/types/deletion.d.ts +17 -0
  231. package/types/deletion.d.ts.map +1 -0
  232. package/types/devTool.d.ts +3 -0
  233. package/types/devTool.d.ts.map +1 -0
  234. package/types/device.d.ts +7 -0
  235. package/types/device.d.ts.map +1 -0
  236. package/types/email.d.ts +73 -0
  237. package/types/email.d.ts.map +1 -0
  238. package/types/erase.d.ts +31 -0
  239. package/types/erase.d.ts.map +1 -0
  240. package/types/events.d.ts +139 -0
  241. package/types/events.d.ts.map +1 -0
  242. package/types/export.d.ts +54 -0
  243. package/types/export.d.ts.map +1 -0
  244. package/types/failure.d.ts +19 -0
  245. package/types/failure.d.ts.map +1 -0
  246. package/types/forwardAuth.d.ts +12 -0
  247. package/types/forwardAuth.d.ts.map +1 -0
  248. package/types/forwardRoutes.d.ts +11 -0
  249. package/types/forwardRoutes.d.ts.map +1 -0
  250. package/types/gate.d.ts +31 -0
  251. package/types/gate.d.ts.map +1 -0
  252. package/types/guard.d.ts +10 -0
  253. package/types/guard.d.ts.map +1 -0
  254. package/types/guards.d.ts +37 -0
  255. package/types/guards.d.ts.map +1 -0
  256. package/types/guesses.d.ts +18 -0
  257. package/types/guesses.d.ts.map +1 -0
  258. package/types/index.d.ts +47 -0
  259. package/types/index.d.ts.map +1 -0
  260. package/types/keys.d.ts +11 -0
  261. package/types/keys.d.ts.map +1 -0
  262. package/types/limits.d.ts +133 -0
  263. package/types/limits.d.ts.map +1 -0
  264. package/types/load.d.ts +18 -0
  265. package/types/load.d.ts.map +1 -0
  266. package/types/locale.d.ts +4 -0
  267. package/types/locale.d.ts.map +1 -0
  268. package/types/log.d.ts +2 -0
  269. package/types/log.d.ts.map +1 -0
  270. package/types/mail.d.ts +51 -0
  271. package/types/mail.d.ts.map +1 -0
  272. package/types/memoryStore.d.ts +3 -0
  273. package/types/memoryStore.d.ts.map +1 -0
  274. package/types/messages/fr.d.ts +409 -0
  275. package/types/messages/fr.d.ts.map +1 -0
  276. package/types/methods/account.d.ts +24 -0
  277. package/types/methods/account.d.ts.map +1 -0
  278. package/types/methods/admin.d.ts +30 -0
  279. package/types/methods/admin.d.ts.map +1 -0
  280. package/types/methods/audit.d.ts +11 -0
  281. package/types/methods/audit.d.ts.map +1 -0
  282. package/types/methods/email.d.ts +14 -0
  283. package/types/methods/email.d.ts.map +1 -0
  284. package/types/methods/magicLink.d.ts +12 -0
  285. package/types/methods/magicLink.d.ts.map +1 -0
  286. package/types/methods/oauth.d.ts +16 -0
  287. package/types/methods/oauth.d.ts.map +1 -0
  288. package/types/methods/oauthServer.d.ts +13 -0
  289. package/types/methods/oauthServer.d.ts.map +1 -0
  290. package/types/methods/organizations.d.ts +30 -0
  291. package/types/methods/organizations.d.ts.map +1 -0
  292. package/types/methods/passkeys.d.ts +19 -0
  293. package/types/methods/passkeys.d.ts.map +1 -0
  294. package/types/methods/password.d.ts +17 -0
  295. package/types/methods/password.d.ts.map +1 -0
  296. package/types/methods/sessions.d.ts +9 -0
  297. package/types/methods/sessions.d.ts.map +1 -0
  298. package/types/methods/tokens.d.ts +11 -0
  299. package/types/methods/tokens.d.ts.map +1 -0
  300. package/types/methods/twoFactor.d.ts +20 -0
  301. package/types/methods/twoFactor.d.ts.map +1 -0
  302. package/types/oauth/client.d.ts +39 -0
  303. package/types/oauth/client.d.ts.map +1 -0
  304. package/types/oauth/flow.d.ts +38 -0
  305. package/types/oauth/flow.d.ts.map +1 -0
  306. package/types/oauth/index.d.ts +6 -0
  307. package/types/oauth/index.d.ts.map +1 -0
  308. package/types/oauth/pkce.d.ts +10 -0
  309. package/types/oauth/pkce.d.ts.map +1 -0
  310. package/types/oauth/providers.d.ts +100 -0
  311. package/types/oauth/providers.d.ts.map +1 -0
  312. package/types/oauth/refresher.d.ts +55 -0
  313. package/types/oauth/refresher.d.ts.map +1 -0
  314. package/types/oauth/timeout.d.ts +2 -0
  315. package/types/oauth/timeout.d.ts.map +1 -0
  316. package/types/oauth/types.d.ts +75 -0
  317. package/types/oauth/types.d.ts.map +1 -0
  318. package/types/oauthTest.d.ts +23 -0
  319. package/types/oauthTest.d.ts.map +1 -0
  320. package/types/organizations.d.ts +111 -0
  321. package/types/organizations.d.ts.map +1 -0
  322. package/types/organizationsCore.d.ts +29 -0
  323. package/types/organizationsCore.d.ts.map +1 -0
  324. package/types/own.d.ts +55 -0
  325. package/types/own.d.ts.map +1 -0
  326. package/types/pages/english.d.ts +80 -0
  327. package/types/pages/english.d.ts.map +1 -0
  328. package/types/pages/forms.d.ts +204 -0
  329. package/types/pages/forms.d.ts.map +1 -0
  330. package/types/pages/index.d.ts +166 -0
  331. package/types/pages/index.d.ts.map +1 -0
  332. package/types/pages/organizationPage.d.ts +7 -0
  333. package/types/pages/organizationPage.d.ts.map +1 -0
  334. package/types/pages/routes/account/_guard.d.ts +3 -0
  335. package/types/pages/routes/account/_guard.d.ts.map +1 -0
  336. package/types/pages/routes/account/organizations/_guard.d.ts +3 -0
  337. package/types/pages/routes/account/organizations/_guard.d.ts.map +1 -0
  338. package/types/passkeys.d.ts +61 -0
  339. package/types/passkeys.d.ts.map +1 -0
  340. package/types/password.d.ts +49 -0
  341. package/types/password.d.ts.map +1 -0
  342. package/types/payloads.d.ts +4 -0
  343. package/types/payloads.d.ts.map +1 -0
  344. package/types/pg.d.ts +303 -0
  345. package/types/pg.d.ts.map +1 -0
  346. package/types/profile.d.ts +11 -0
  347. package/types/profile.d.ts.map +1 -0
  348. package/types/proof.d.ts +33 -0
  349. package/types/proof.d.ts.map +1 -0
  350. package/types/prune.d.ts +5 -0
  351. package/types/prune.d.ts.map +1 -0
  352. package/types/rates.d.ts +15 -0
  353. package/types/rates.d.ts.map +1 -0
  354. package/types/request.d.ts +119 -0
  355. package/types/request.d.ts.map +1 -0
  356. package/types/requiredTwoFactor.d.ts +16 -0
  357. package/types/requiredTwoFactor.d.ts.map +1 -0
  358. package/types/requirement.d.ts +4 -0
  359. package/types/requirement.d.ts.map +1 -0
  360. package/types/roles.d.ts +9 -0
  361. package/types/roles.d.ts.map +1 -0
  362. package/types/routes.d.ts +31 -0
  363. package/types/routes.d.ts.map +1 -0
  364. package/types/rules-check.d.ts +3 -0
  365. package/types/rules-check.d.ts.map +1 -0
  366. package/types/rules.d.ts +38 -0
  367. package/types/rules.d.ts.map +1 -0
  368. package/types/securityNotice.d.ts +7 -0
  369. package/types/securityNotice.d.ts.map +1 -0
  370. package/types/sessions.d.ts +32 -0
  371. package/types/sessions.d.ts.map +1 -0
  372. package/types/setup.d.ts +18 -0
  373. package/types/setup.d.ts.map +1 -0
  374. package/types/signInOptions.d.ts +6 -0
  375. package/types/signInOptions.d.ts.map +1 -0
  376. package/types/state.d.ts +25 -0
  377. package/types/state.d.ts.map +1 -0
  378. package/types/store.d.ts +295 -0
  379. package/types/store.d.ts.map +1 -0
  380. package/types/storeHelpers.d.ts +4 -0
  381. package/types/storeHelpers.d.ts.map +1 -0
  382. package/types/test.d.ts +21 -0
  383. package/types/test.d.ts.map +1 -0
  384. package/types/testCookies.d.ts +3 -0
  385. package/types/testCookies.d.ts.map +1 -0
  386. package/types/testHelpers.d.ts +34 -0
  387. package/types/testHelpers.d.ts.map +1 -0
  388. package/types/testing.d.ts +12 -0
  389. package/types/testing.d.ts.map +1 -0
  390. package/types/text.d.ts +2 -0
  391. package/types/text.d.ts.map +1 -0
  392. package/types/totp.d.ts +12 -0
  393. package/types/totp.d.ts.map +1 -0
  394. package/types/twoFactor.d.ts +41 -0
  395. package/types/twoFactor.d.ts.map +1 -0
  396. package/types/types.d.ts +17 -0
  397. package/types/types.d.ts.map +1 -0
  398. package/types/userData.d.ts +9 -0
  399. package/types/userData.d.ts.map +1 -0
  400. package/types/viewer.d.ts +23 -0
  401. package/types/viewer.d.ts.map +1 -0
  402. package/types/wayIn.d.ts +12 -0
  403. package/types/wayIn.d.ts.map +1 -0
  404. package/types/webauthn.d.ts +111 -0
  405. package/types/webauthn.d.ts.map +1 -0
  406. package/types/wsAuth.d.ts +14 -0
  407. package/types/wsAuth.d.ts.map +1 -0
@@ -0,0 +1,357 @@
1
+ import { defineMessages } from 'kay/i18n'
2
+
3
+ export default defineMessages({
4
+ auth: {
5
+ or: 'ou',
6
+ email: 'Adresse e-mail',
7
+ password: 'Mot de passe',
8
+ newPassword: 'Nouveau mot de passe',
9
+ passwordHint: 'Au moins {min} caractères',
10
+ code: 'Code',
11
+ remember: 'Rester connecté',
12
+ signIn: {
13
+ title: 'Connexion',
14
+ identifier: 'Adresse e-mail ou nom d’utilisateur',
15
+ submit: 'Se connecter',
16
+ provider: 'Continuer avec {provider}',
17
+ passkey: 'Se connecter avec une clé d’accès',
18
+ forgot: 'Mot de passe oublié ?',
19
+ noAccount: 'Pas encore de compte ?',
20
+ register: 'En créer un',
21
+ magic: 'Recevoir un lien de connexion',
22
+ magicCode: 'Recevoir un code de connexion',
23
+ sent: 'Si un compte utilise cette adresse, un e-mail est en route.',
24
+ codeSent: 'Saisissez le code envoyé à {email}.',
25
+ codeSubmit: 'Se connecter',
26
+ },
27
+ register: {
28
+ title: 'Créer un compte',
29
+ submit: 'Créer le compte',
30
+ haveAccount: 'Déjà un compte ?',
31
+ signIn: 'Se connecter',
32
+ checkMail: 'Consultez vos e-mails pour continuer.',
33
+ purpose: 'Votre adresse e-mail sert à créer et à protéger votre compte.',
34
+ privacy: 'Politique de confidentialité',
35
+ },
36
+ twoFactor: {
37
+ title: 'Validation en deux étapes',
38
+ intro: 'Saisissez le code affiché par votre application d’authentification, ou l’un de vos codes de secours.',
39
+ submit: 'Valider',
40
+ passkey: 'Utiliser plutôt une clé d’accès',
41
+ nothing: 'Aucune connexion n’attend de code.',
42
+ },
43
+ reset: {
44
+ title: 'Réinitialiser votre mot de passe',
45
+ intro: 'Nous vous enverrons un lien pour choisir un nouveau mot de passe.',
46
+ submit: 'Recevoir un lien',
47
+ sent: 'Si un compte utilise cette adresse, un lien pour réinitialiser son mot de passe est en route.',
48
+ choose: 'Choisissez un nouveau mot de passe',
49
+ save: 'Enregistrer le mot de passe',
50
+ },
51
+ verify: {
52
+ title: 'Vérifier votre adresse',
53
+ intro: 'Appuyez sur le bouton pour vérifier votre adresse.',
54
+ submit: 'Vérifier mon adresse',
55
+ confirm: 'Ce lien a été ouvert dans un autre navigateur : saisissez votre mot de passe pour confirmer que c’est bien vous.',
56
+ done: 'Votre adresse est vérifiée.',
57
+ codeIntro: 'Saisissez le code envoyé à {email}.',
58
+ resend: 'Recevoir un nouveau lien',
59
+ resent: 'Un nouveau lien est en route.',
60
+ unverified: 'Votre adresse {email} n’est pas encore vérifiée.',
61
+ },
62
+ consent: {
63
+ title: 'Autoriser l’accès',
64
+ intro: '{client} souhaite utiliser votre compte.',
65
+ from: 'Cette application se trouve sur {host}. Ne continuez que si vous avez lancé cette connexion.',
66
+ unverified: 'Cette application s’est nommée elle-même, rien ne vérifie ce nom. Ne continuez que si vous avez lancé cette connexion.',
67
+ returnsTo: 'Une fois votre choix fait, vous revenez sur {host}.',
68
+ scopes: 'Elle sera autorisée à',
69
+ everything: 'Faire tout ce que vous pouvez faire',
70
+ noScopes: 'Vous identifier, sans accès aux fonctions qui demandent une permission',
71
+ allow: 'Autoriser',
72
+ deny: 'Refuser',
73
+ client: 'Cette application est inconnue de ce site : rien ne lui a été transmis.',
74
+ redirectUri: 'Cette application a demandé à revenir à une adresse qu’elle n’a pas déclarée : rien ne lui a été transmis.',
75
+ signedOut: 'Vous êtes déconnecté : recommencez depuis l’application.',
76
+ },
77
+ magic: {
78
+ title: 'Connexion',
79
+ intro: 'Appuyez sur le bouton pour terminer la connexion.',
80
+ submit: 'Se connecter',
81
+ },
82
+ confirmEmail: {
83
+ title: 'Confirmer votre nouvelle adresse',
84
+ intro: 'Appuyez sur le bouton pour passer votre compte à cette adresse.',
85
+ submit: 'Confirmer l’adresse',
86
+ },
87
+ proof: {
88
+ password: 'Mot de passe actuel',
89
+ code: 'Code de votre application d’authentification',
90
+ stale: 'Par sécurité, reconnectez-vous avant de faire cela.',
91
+ signInAgain: 'Se reconnecter',
92
+ },
93
+ admin: {
94
+ title: 'Administration',
95
+ acting: 'Revenez à votre compte pour utiliser l’administration.',
96
+ nav: { label: 'Administration', users: 'Utilisateurs', audit: 'Journal d’audit' },
97
+ users: {
98
+ search: 'Rechercher',
99
+ searchLabel: 'Adresse, nom d’utilisateur ou identifiant',
100
+ none: 'Aucun utilisateur trouvé.',
101
+ total: { one: '{count} utilisateur', other: '{count} utilisateurs' },
102
+ banned: 'Suspendu',
103
+ guest: 'Invité',
104
+ noName: 'Sans adresse',
105
+ joined: 'Inscrit {date}',
106
+ pagination: 'Pages des utilisateurs',
107
+ },
108
+ user: {
109
+ back: 'Tous les utilisateurs',
110
+ roles: 'Rôles',
111
+ noRoles: 'Aucun rôle.',
112
+ grant: 'Donner le rôle',
113
+ grantRole: 'Rôle',
114
+ revoke: 'Retirer',
115
+ ban: 'Suspendre le compte',
116
+ banReason: 'Motif',
117
+ banUntil: 'Jusqu’au',
118
+ banUntilHint: 'La suspension prend fin à la fin de ce jour, en UTC. Laissez vide pour une suspension sans fin.',
119
+ banned: 'Suspendu depuis le {date}.',
120
+ bannedUntil: 'Suspendu jusqu’au {date}.',
121
+ unban: 'Lever la suspension',
122
+ delete: 'Supprimer le compte',
123
+ deleteConfirm: 'J’ai compris',
124
+ deleteIntro: 'Le compte et tout ce qui s’y rattache sont supprimés définitivement. Cela ne peut pas être annulé.',
125
+ impersonate: 'Agir comme cet utilisateur',
126
+ activity: 'Activité récente',
127
+ signInAgain: 'Se reconnecter',
128
+ },
129
+ audit: { title: 'Journal d’audit', off: 'Le journal d’audit est désactivé : donnez l’option audit pour en garder un.', none: 'Aucune entrée.', older: 'Plus anciennes' },
130
+ },
131
+ organizations: {
132
+ title: 'Organisations',
133
+ none: 'Vous n’appartenez encore à aucune organisation.',
134
+ joined: 'Membre depuis le {date}',
135
+ back: 'Toutes les organisations',
136
+ create: 'Créer une organisation',
137
+ name: 'Nom',
138
+ slug: 'Adresse',
139
+ slugHint: 'Minuscules, chiffres et tirets. Laissez vide pour n’en avoir aucune.',
140
+ invitationsForYou: 'Invitations pour vous',
141
+ accept: 'Rejoindre',
142
+ reject: 'Refuser',
143
+ expires: 'Expire le {date}',
144
+ you: 'Vous',
145
+ members: 'Membres',
146
+ remove: 'Retirer',
147
+ saveRoles: 'Enregistrer les rôles',
148
+ rolesOf: 'Rôles de {name}',
149
+ invitations: 'Invitations',
150
+ noInvitations: 'Aucune invitation en cours.',
151
+ revoke: 'Annuler',
152
+ inviteEmail: 'Adresse e-mail',
153
+ inviteRoles: 'Rôles',
154
+ invite: 'Inviter',
155
+ invited: 'Invitation envoyée à {email}.',
156
+ rename: 'Nom et adresse',
157
+ save: 'Enregistrer',
158
+ leave: 'Quitter l’organisation',
159
+ leaveConfirm: 'Je veux partir',
160
+ delete: 'Supprimer l’organisation',
161
+ deleteIntro: 'L’organisation, ses membres et ses invitations sont supprimés définitivement. Cela ne peut pas être annulé.',
162
+ deleteConfirm: 'J’ai compris',
163
+ },
164
+ invitation: {
165
+ title: 'Invitation',
166
+ invalid: 'Cette invitation est invalide, expirée ou déjà utilisée.',
167
+ intro: 'Vous êtes invité à rejoindre {organization}.',
168
+ sentTo: 'Envoyée à {email}.',
169
+ accept: 'Rejoindre',
170
+ reject: 'Refuser',
171
+ switch: 'Se connecter avec un autre compte',
172
+ signInFirst: 'Connectez-vous ou créez un compte avec cette adresse pour rejoindre.',
173
+ signIn: 'Se connecter',
174
+ register: 'Créer un compte',
175
+ },
176
+ impersonation: { banner: 'Vous agissez comme {user}.', stop: 'Revenir à mon compte' },
177
+ deletion: { banner: 'Votre compte sera supprimé le {date}.', cancel: 'Annuler la suppression' },
178
+ account: {
179
+ title: 'Votre compte',
180
+ nav: { label: 'Compte', profile: 'Profil', security: 'Sécurité', sessions: 'Sessions', connections: 'Comptes liés', tokens: 'Jetons', clients: 'Applications', organizations: 'Organisations', data: 'Vos données' },
181
+ signOut: 'Se déconnecter',
182
+ profile: {
183
+ title: 'Profil',
184
+ verified: 'Vérifiée',
185
+ unverified: 'Non vérifiée',
186
+ noEmail: 'Pas encore d’adresse',
187
+ resend: 'Recevoir un lien de vérification',
188
+ resent: 'Un lien de vérification est en route.',
189
+ username: 'Nom d’utilisateur',
190
+ saveUsername: 'Enregistrer le nom',
191
+ usernameSaved: 'Votre nom d’utilisateur est enregistré.',
192
+ saveProfile: 'Enregistrer le profil',
193
+ profileSaved: 'Votre profil est enregistré.',
194
+ changeEmail: 'Changer d’adresse',
195
+ newEmail: 'Nouvelle adresse',
196
+ sendChange: 'Envoyer un lien de confirmation',
197
+ changeSent: 'Ouvrez le lien envoyé à {email} pour la confirmer.',
198
+ },
199
+ password: {
200
+ title: 'Mot de passe',
201
+ set: 'Définir un mot de passe',
202
+ change: 'Changer le mot de passe',
203
+ changed: 'Votre mot de passe est enregistré. Vos autres sessions ont été déconnectées.',
204
+ none: 'Vous vous connectez sans mot de passe. Définissez-en un pour pouvoir aussi vous connecter avec votre adresse.',
205
+ },
206
+ twoFactor: {
207
+ title: 'Validation en deux étapes',
208
+ on: 'Activée',
209
+ off: 'Désactivée',
210
+ intro: 'Demander un code d’une application d’authentification à chaque connexion.',
211
+ setUp: 'Configurer la validation en deux étapes',
212
+ scan: 'Scannez ce code avec votre application d’authentification, ou saisissez la clé, puis saisissez le code qu’elle affiche.',
213
+ key: 'Clé',
214
+ qr: 'QR code pour votre application d’authentification',
215
+ enable: 'Activer',
216
+ disable: 'Désactiver',
217
+ codesLeft: { zero: 'Plus aucun code de secours', one: '{count} code de secours restant', other: '{count} codes de secours restants' },
218
+ regenerate: 'Générer de nouveaux codes de secours',
219
+ recoveryCodes: 'Codes de secours',
220
+ recoveryIntro: 'Gardez-les en lieu sûr : chacun vous connecte une fois si vous perdez votre application. Ils ne sont affichés que maintenant.',
221
+ copy: 'Copier les codes',
222
+ },
223
+ passkeys: {
224
+ title: 'Clés d’accès',
225
+ intro: 'Connectez-vous avec votre empreinte, votre visage ou le code de votre appareil au lieu d’un mot de passe.',
226
+ none: 'Aucune clé d’accès.',
227
+ add: 'Ajouter une clé d’accès',
228
+ name: 'Nom',
229
+ rename: 'Renommer',
230
+ remove: 'Supprimer',
231
+ created: 'Ajoutée le {date}',
232
+ unsupported: 'Ce navigateur ne peut pas créer de clé d’accès.',
233
+ failed: 'La clé d’accès n’a pas été ajoutée.',
234
+ },
235
+ sessions: {
236
+ title: 'Où vous êtes connecté',
237
+ current: 'Cet appareil',
238
+ unknown: 'Appareil inconnu',
239
+ mobile: 'mobile',
240
+ lastSeen: 'Vu {date}',
241
+ end: 'Déconnecter',
242
+ endOthers: 'Déconnecter partout ailleurs',
243
+ },
244
+ connections: {
245
+ title: 'Comptes liés',
246
+ intro: 'Connectez-vous avec ces comptes en plus du vôtre.',
247
+ connected: 'Lié',
248
+ connect: 'Lier',
249
+ disconnect: 'Délier',
250
+ none: 'Aucun fournisseur n’est configuré.',
251
+ },
252
+ clients: {
253
+ title: 'Applications connectées',
254
+ intro: 'Ces applications se sont connectées à votre compte. En révoquer une met fin à son accès immédiatement.',
255
+ none: 'Aucune application connectée.',
256
+ revoke: 'Révoquer',
257
+ allScopes: 'Tout',
258
+ lastUsed: 'Utilisée le {date}',
259
+ neverUsed: 'Jamais utilisée',
260
+ approved: 'Approuvée le {date}',
261
+ },
262
+ tokens: {
263
+ title: 'Jetons d’accès',
264
+ intro: 'Les jetons permettent à des scripts et à d’autres applications d’utiliser votre compte par l’API.',
265
+ none: 'Aucun jeton.',
266
+ label: 'Nom',
267
+ scopes: 'Autorisé à',
268
+ allScopes: 'Tout',
269
+ expiresIn: 'Expiration',
270
+ never: 'Jamais',
271
+ days: { one: 'Dans {count} jour', other: 'Dans {count} jours' },
272
+ create: 'Créer un jeton',
273
+ created: 'Copiez ce jeton maintenant : il ne sera plus affiché.',
274
+ copy: 'Copier le jeton',
275
+ revoke: 'Révoquer',
276
+ expired: 'Expiré',
277
+ expires: 'Expire le {date}',
278
+ lastUsed: 'Utilisé le {date}',
279
+ neverUsed: 'Jamais utilisé',
280
+ },
281
+ data: {
282
+ export: 'Télécharger vos données',
283
+ exportIntro: 'Tout ce que nous gardons sur votre compte, dans un fichier JSON.',
284
+ delete: 'Supprimer votre compte',
285
+ deleteIntro: 'Votre compte et tout ce qui s’y rattache sont supprimés définitivement. C’est irréversible.',
286
+ deleteGraceIntro: 'Votre compte et tout ce qui s’y rattache sont supprimés définitivement dans {after}. D’ici là, vous pouvez annuler : il suffit de vous connecter pour accéder au bouton.',
287
+ deletePending: 'Votre compte sera supprimé le {date}.',
288
+ deleteOrganizations: 'Ces organisations sont supprimées avec lui, car vous en êtes le seul membre : {names}.',
289
+ deleteBlocked: 'Vous êtes le seul propriétaire de {names} : nommez d’abord un autre propriétaire.',
290
+ confirmDelete: 'Supprimer mon compte',
291
+ confirmExport: 'Confirmer pour télécharger mes données',
292
+ },
293
+ },
294
+ errors: {
295
+ 'form': 'Vérifiez les champs et réessayez.',
296
+ 'credentials': 'Adresse, nom d’utilisateur ou mot de passe incorrect.',
297
+ 'limited': 'Trop de tentatives. Patientez un moment, puis réessayez.',
298
+ 'captcha': 'Terminez la vérification anti-robot.',
299
+ 'captchaAgain': 'La vérification dans votre navigateur n’a pas abouti : renvoyez le formulaire.',
300
+ 'captchaScript': 'Ce formulaire fait une vérification dans votre navigateur, qui demande JavaScript : activez-le, puis renvoyez-le.',
301
+ 'early': 'Patientez un instant, puis renvoyez-le.',
302
+ 'unverified': 'Vérifiez d’abord votre adresse : ouvrez le lien reçu par e-mail.',
303
+ 'banned': 'Ce compte est suspendu.',
304
+ 'unavailable': 'L’envoi d’e-mails n’est pas configuré sur ce site.',
305
+ 'link': 'Ce lien est invalide ou a déjà servi.',
306
+ 'code': 'Code incorrect.',
307
+ 'expired': 'Le délai est dépassé : recommencez.',
308
+ 'signed-out': 'Connectez-vous d’abord.',
309
+ 'verified': 'Votre adresse est déjà vérifiée.',
310
+ 'proof': 'Mot de passe ou code incorrect.',
311
+ 'stale': 'Par sécurité, reconnectez-vous avant de faire cela.',
312
+ 'impersonating': 'Impossible en agissant pour un autre utilisateur.',
313
+ 'enabled': 'La validation en deux étapes est déjà activée.',
314
+ 'not-set-up': 'Configurez d’abord la validation en deux étapes.',
315
+ 'not-enabled': 'La validation en deux étapes est désactivée.',
316
+ 'off': 'Cette fonction est désactivée sur ce site.',
317
+ 'not-linked': 'Ce compte n’est pas lié.',
318
+ 'last-way-in': 'C’est votre seul moyen de connexion : ajoutez-en un autre d’abord.',
319
+ 'self': 'Impossible sur votre propre compte.',
320
+ 'last-admin': 'Vous êtes le seul administrateur : nommez-en un autre d’abord.',
321
+ 'last-owner': 'Vous êtes le seul propriétaire d’une organisation qui a d’autres membres : nommez d’abord un autre propriétaire.',
322
+ 'refused': 'Ce compte ne peut pas être supprimé pour le moment.',
323
+ 'not-found': 'Introuvable.',
324
+ 'label': 'Donnez un nom au jeton.',
325
+ 'scope': 'Choisissez ce que le jeton peut faire.',
326
+ 'expiry': 'Choisissez quand le jeton expire.',
327
+ 'invalid': 'Cela n’a pas fonctionné.',
328
+ 'none': 'Aucune clé d’accès à utiliser.',
329
+ 'forbidden': 'Vous n’avez pas le droit de faire cela.',
330
+ 'two-factor-required': 'Activez d’abord la validation en deux étapes dans votre compte.',
331
+ 'unknown-role': 'Ce rôle n’existe pas.',
332
+ 'admin': 'Un administrateur ne peut pas être modifié ainsi : retirez-lui d’abord le rôle d’administrateur.',
333
+ 'until': 'Choisissez une date à venir.',
334
+ 'invalid-name': 'Utilisez de 1 à 100 caractères pour le nom, sans saut de ligne.',
335
+ 'invalid-slug': 'Utilisez des minuscules, des chiffres et des tirets pour l’adresse.',
336
+ 'slug-taken': 'Une autre organisation utilise déjà cette adresse.',
337
+ 'invalid-email': 'Saisissez une adresse valide.',
338
+ 'member': 'Cette personne est déjà membre.',
339
+ 'wrong-account': 'Cette invitation est pour une autre adresse : connectez-vous avec celle à laquelle elle a été envoyée.',
340
+ },
341
+ oauth: {
342
+ 'oauth': 'La connexion avec ce fournisseur a échoué. Réessayez.',
343
+ 'cancelled': 'La connexion a été annulée.',
344
+ 'refused': 'Ce compte n’est pas autorisé à se connecter ici.',
345
+ 'taken': 'Un autre compte utilise déjà cette adresse : connectez-vous à celui-ci, puis liez ce fournisseur.',
346
+ 'unavailable': 'La connexion avec ce fournisseur n’est pas disponible.',
347
+ 'signed-out': 'Connectez-vous d’abord.',
348
+ 'banned': 'Ce compte est suspendu.',
349
+ },
350
+ fields: {
351
+ email: { invalid: 'Saisissez une adresse valide.', taken: 'Un compte utilise déjà cette adresse.', unchanged: 'C’est déjà votre adresse.' },
352
+ password: { 'too-short': 'Utilisez au moins {min} caractères.', 'too-long': 'Utilisez au plus {max} caractères.', 'breached': 'Ce mot de passe figure dans une fuite de données : choisissez-en un autre.' },
353
+ username: { 'length': 'Utilisez entre {min} et {max} caractères.', 'characters': 'Utilisez des lettres, chiffres, espaces, points, tirets et tirets bas.', 'mixed-scripts': 'Utilisez un seul alphabet.', 'taken': 'Ce nom d’utilisateur est pris.', 'unchanged': 'C’est déjà votre nom d’utilisateur.' },
354
+ profile: { 'required': 'Renseignez ce champ.', 'too-long': 'Utilisez {max} caractères au plus.' },
355
+ },
356
+ },
357
+ })
@@ -0,0 +1,80 @@
1
+ import type { ChangeUsernameResult, DeleteAccountResult, UpdateLocaleResult } from '../account'
2
+ import type { CancelDeletionResult } from '../deletion'
3
+ import type { DeletionImpact } from '../erase'
4
+ import type { ExportResult } from '../export'
5
+ import type { ProfileFieldView } from '../pages'
6
+ import type { SaveProfileResult } from '../profile'
7
+ import type { Proof } from '../proof'
8
+ import type { RequestState } from '../state'
9
+ import { publicUser } from '../core'
10
+ import { failed } from '../failure'
11
+ import { load } from '../load'
12
+
13
+ // `auth.account`: the signed-in user's own account.
14
+ export class AccountMethods {
15
+ constructor(private readonly state: RequestState) {}
16
+
17
+ // Names the signed-in user, or renames them, under the rules register checks; no proof, a name being no credential.
18
+ async changeUsername(username: string): Promise<ChangeUsernameResult> {
19
+ return (await load.account()).changeUsername(this.state, username)
20
+ }
21
+
22
+ // Sets the language the signed-in user's mails are written in, a BCP 47 tag such as `fr`; refused with `signed-out`, or `invalid-locale` for anything else than a tag.
23
+ async updateLocale(locale: string): Promise<UpdateLocaleResult> {
24
+ return (await load.account()).updateLocale(this.state, locale)
25
+ }
26
+
27
+ // Deletes the signed-in user, calling `beforeDelete` for the app's own records, and signs this session out, or with `account.deleteAfter` only marks the account pending (`{ ok: true, deleteAt }`) and stays signed in, the prune deleting it once the period ends; the last admin and the only owner of an organization with other members are refused, an organization they are alone in is deleted with them.
28
+ async delete(proof: Proof): Promise<DeleteAccountResult> {
29
+ return (await load.account()).deleteAccount(this.state, proof, this.state.signOut)
30
+ }
31
+
32
+ // With `account.deleteAfter`, takes the pending deletion off the signed-in user's account and tells them; refused with `signed-out`, or `not-pending` when the account is not pending deletion.
33
+ async cancelDeletion(): Promise<CancelDeletionResult> {
34
+ return (await load.deletion()).cancelDeletion(this.state)
35
+ }
36
+
37
+ // When the signed-in user's account is deleted if they do nothing, or null when it is not pending deletion: what a banner or an app's own page shows beside the way to `cancelDeletion`.
38
+ async deletion(): Promise<{ deleteAt: Date } | null> {
39
+ const record = await this.state.current()
40
+
41
+ return record?.deleteAt == null ? null : { deleteAt: record.deleteAt }
42
+ }
43
+
44
+ // The organizations deleting the signed-in user's account touches, by name: `deleted` are the ones they are the only member of, which go with them, `blocked` the ones they solely own with other members, which refuse the deletion (`last-owner`) until another owner is named.
45
+ async deletionImpact(): Promise<DeletionImpact> {
46
+ return (await load.erase()).deletionImpact(this.state)
47
+ }
48
+
49
+ // The fields of the profile form the account page shows beside the username, with what this user holds in each, or null when `pages.profile` is not set or the user is not signed in with a session.
50
+ async profile(locale?: string): Promise<ProfileFieldView[] | null> {
51
+ const profile = this.state.core.pages?.profile
52
+ const record = profile && await this.state.current()
53
+
54
+ if (!profile || !record || this.state.via() !== 'session')
55
+ return null
56
+
57
+ return (await load.profile()).profileFields(profile, publicUser(record), locale)
58
+ }
59
+
60
+ // Stores the values posted from that form through `pages.profile.save`, once trimmed and checked against each field's `required` and `maxLength`: names that are no field are dropped, and nothing is stored while any field is refused.
61
+ async saveProfile(values: Record<string, unknown>): Promise<SaveProfileResult> {
62
+ const profile = this.state.core.pages?.profile
63
+
64
+ if (!profile)
65
+ throw new Error('kayjs-auth: account.saveProfile needs `pages.profile` in authCore')
66
+
67
+ const record = await this.state.current()
68
+
69
+ // A device's token cannot edit the profile of the account it was given for, as it cannot rename it.
70
+ if (!record || this.state.via() !== 'session')
71
+ return failed('signed-out')
72
+
73
+ return (await load.profile()).saveProfile(profile, publicUser(record), values)
74
+ }
75
+
76
+ // Everything kayjs-auth keeps about the signed-in user, secrets left out, with the app's own from `exportData`: for a download of their data.
77
+ async export(): Promise<ExportResult> {
78
+ return (await load.exports()).exportData(this.state)
79
+ }
80
+ }
@@ -0,0 +1,63 @@
1
+ import type { AdminAuditLogResult, BanResult, DeleteResult, GetUserResult, ImpersonateResult, ListUsersResult, RoleResult, UnbanResult } from '../admin'
2
+ import type { AuditCursorInput } from '../events'
3
+ import type { RequestState } from '../state'
4
+ import { load } from '../load'
5
+
6
+ // `auth.admin`: what the `admin` option's users may do to other users, every method answering `forbidden` for anyone else.
7
+ export class AdminMethods<Role extends string = string> {
8
+ constructor(private readonly state: RequestState) {}
9
+
10
+ // The users, newest first, a page of `limit` (50 by default) from `offset`; `search` matches part of an email or a username, or a whole id.
11
+ async listUsers(query: { search?: string, offset?: number, limit?: number } = {}): Promise<ListUsersResult> {
12
+ return (await load.admin()).listUsers(this.state, query)
13
+ }
14
+
15
+ // One user; `admin` tells whether they meet the `admin` option, whom an admin can neither ban, impersonate nor delete.
16
+ async getUser(userId: string): Promise<GetUserResult> {
17
+ return (await load.admin()).getUser(this.state, userId)
18
+ }
19
+
20
+ // The roles an admin may give, those `roles` declares; none without it.
21
+ roles(): string[] {
22
+ return [...this.state.core.roles ?? []]
23
+ }
24
+
25
+ // Gives a user a role the app declares, effective on their next request.
26
+ async grantRole(userId: string, role: Role): Promise<RoleResult> {
27
+ return (await load.admin()).changeRole(this.state, userId, role, true)
28
+ }
29
+
30
+ // Takes a role back; one that would leave the admin asking no longer an admin is refused (`self`), and one that races another admin's revoke and would leave none is undone (`last-admin`).
31
+ async revokeRole(userId: string, role: Role): Promise<RoleResult> {
32
+ return (await load.admin()).changeRole(this.state, userId, role, false)
33
+ }
34
+
35
+ // Bars a user from signing in, for good or `until` then, and signs them out everywhere; another admin is refused.
36
+ async ban(userId: string, options: { reason?: string, until?: Date } = {}): Promise<BanResult> {
37
+ return (await load.admin()).banUser(this.state, userId, options)
38
+ }
39
+
40
+ async unban(userId: string): Promise<UnbanResult> {
41
+ return (await load.admin()).unbanUser(this.state, userId)
42
+ }
43
+
44
+ // Deletes a user with everything kayjs-auth keeps for them, calling `onDelete` and mailing them the account-deleted notice; oneself and another admin are refused.
45
+ async deleteUser(userId: string): Promise<DeleteResult> {
46
+ return (await load.admin()).deleteUser(this.state, userId)
47
+ }
48
+
49
+ // Everyone's audit log, or `userId`'s, newest first.
50
+ async auditLog(query: { userId?: string, before?: AuditCursorInput, limit?: number } = {}): Promise<AdminAuditLogResult> {
51
+ return (await load.admin()).adminAuditLog(this.state, query)
52
+ }
53
+
54
+ // Signs this browser in as `userId`, the admin's own sign-in kept for `admin.stopImpersonating`; 'stale' unless the admin signed in or re-proved lately. Nothing that takes a proof works meanwhile, and another admin cannot be impersonated.
55
+ async impersonate(userId: string): Promise<ImpersonateResult> {
56
+ return (await load.admin()).impersonate(this.state, userId)
57
+ }
58
+
59
+ // Signs the admin back in as themselves; signed out when their own sign-in ended meanwhile. False when not impersonating.
60
+ async stopImpersonating(): Promise<boolean> {
61
+ return (await load.admin()).stopImpersonating(this.state)
62
+ }
63
+ }
@@ -0,0 +1,15 @@
1
+ import type { AuditCursorInput, AuditEntry } from '../events'
2
+ import type { RequestState } from '../state'
3
+ import { auditEntries } from '../events'
4
+
5
+ // `auth.audit`: what the audit log kept about the signed-in user.
6
+ export class AuditMethods {
7
+ constructor(private readonly state: RequestState) {}
8
+
9
+ // The signed-in user's own audit log, newest first, a page of `limit` (50 by default) before `before`, an instant or the last entry of the page (which tells entries of one millisecond apart); empty without the `audit` option.
10
+ async list(options: { before?: AuditCursorInput, limit?: number } = {}): Promise<AuditEntry[]> {
11
+ const record = await this.state.current()
12
+
13
+ return record ? auditEntries(this.state.core, { ...options, userId: record.id }) : []
14
+ }
15
+ }
@@ -0,0 +1,39 @@
1
+ import type { ChangeEmailResult, CodeResult, LinkResult, PendingEmailCode, SendVerificationResult, VerifyEmailResult } from '../email'
2
+ import type { Proof } from '../proof'
3
+ import type { RequestState } from '../state'
4
+ import { load } from '../load'
5
+
6
+ // `auth.email`: verifying the address and changing it.
7
+ export class EmailMethods {
8
+ constructor(private readonly state: RequestState) {}
9
+
10
+ // Mails a new link verifying the address to the signed-in user or, with nobody signed in, to the account this browser registered or proved the password of with an 'unverified' answer.
11
+ async sendVerification(): Promise<SendVerificationResult> {
12
+ return (await load.email()).sendVerification(this.state)
13
+ }
14
+
15
+ // Spends a verification link's token in the browser signed in as the account, that registered it or that proved its password, or given the account's password: `{ ok: false, error: { code: 'confirm' } }` asks for one of them, the link still usable.
16
+ async verify(token: string, password?: string): Promise<VerifyEmailResult> {
17
+ return (await load.email()).verifyEmail(this.state, token, password)
18
+ }
19
+
20
+ // Verifies the address with the code its verification mail carried, typed in the browser that asked for it.
21
+ async verifyCode(code: string): Promise<CodeResult> {
22
+ return (await load.email()).verifyEmailCode(this.state, code)
23
+ }
24
+
25
+ // The code this browser waits for, sign-in or verification, and the address it went to; null when none.
26
+ async pendingCode(): Promise<PendingEmailCode> {
27
+ return (await load.email()).pendingCode(this.state)
28
+ }
29
+
30
+ // Mails the signed-in user's new address a link confirming it.
31
+ async change(proof: Proof, email: string): Promise<ChangeEmailResult> {
32
+ return (await load.email()).changeEmail(this.state, proof, email)
33
+ }
34
+
35
+ // Spends an email change link's token: the account moves to the new address, and the user's other sessions end.
36
+ async confirmChange(token: string): Promise<LinkResult> {
37
+ return (await load.email()).confirmEmailChange(this.state, token)
38
+ }
39
+ }
@@ -0,0 +1,32 @@
1
+ import type { Off } from '../core'
2
+ import type { CodeResult, LinkResult, MailRequestResult } from '../email'
3
+ import type { SignInOptions } from '../signInOptions'
4
+ import type { RequestState } from '../state'
5
+ import { OFF } from '../core'
6
+ import { load } from '../load'
7
+ import { chooseRemember } from '../sessions'
8
+
9
+ // `auth.magicLink`: sign-in links and codes mailed to the address; each answers `off` with `magicLink: false`.
10
+ export class MagicLinkMethods {
11
+ constructor(private readonly state: RequestState) {}
12
+
13
+ // Mails a sign-in link to that address when an account has it; answers alike when none does. `remember` holds for the link opened in this browser, or the code typed in it.
14
+ async request(email: string, options: SignInOptions = {}): Promise<MailRequestResult | Off> {
15
+ if (!this.state.core.switches.magicLink)
16
+ return OFF
17
+
18
+ await chooseRemember(this.state, options.remember)
19
+
20
+ return (await load.email()).requestMagicLink(this.state, email, options.redirect, options.captcha)
21
+ }
22
+
23
+ // Spends a magic link's token, signing its user in.
24
+ async signIn(token: string): Promise<LinkResult | Off> {
25
+ return !this.state.core.switches.magicLink ? OFF : (await load.email()).signInWithMagicLink(this.state, token)
26
+ }
27
+
28
+ // Signs in with the code a magic link mail carried, typed in the browser that asked for it.
29
+ async signInWithCode(code: string): Promise<CodeResult | Off> {
30
+ return !this.state.core.switches.magicLink ? OFF : (await load.email()).signInWithEmailCode(this.state, code)
31
+ }
32
+ }
@@ -0,0 +1,35 @@
1
+ import type { UnlinkResult } from '../account'
2
+ import type { LinkProviderResult } from '../oauth/flow'
3
+ import type { Proof } from '../proof'
4
+ import type { RequestState } from '../state'
5
+ import { failed } from '../failure'
6
+ import { load } from '../load'
7
+
8
+ // `auth.oauth`: the providers the signed-in user signs in with.
9
+ export class OAuthMethods {
10
+ constructor(private readonly state: RequestState, private readonly forget: () => void) {}
11
+
12
+ // Where to send the browser to link `provider` to the signed-in user once `proof` re-proves them, the second factor when it is on; it comes back to `redirect`.
13
+ async link(provider: string, proof: Proof, options: { redirect?: string } = {}): Promise<LinkProviderResult> {
14
+ return this.state.core.oauth.has(provider) ? (await load.flow()).startLink(this.state, provider, proof, options.redirect) : failed('not-found')
15
+ }
16
+
17
+ // Unlinks a provider from the signed-in user, unless it is their last way in.
18
+ async unlink(provider: string, proof: Proof): Promise<UnlinkResult> {
19
+ this.forget()
20
+
21
+ return (await load.account()).unlink(this.state, provider, proof)
22
+ }
23
+
24
+ // The providers the signed-in user has linked.
25
+ async identities(): Promise<string[]> {
26
+ const record = await this.state.current()
27
+
28
+ return record ? (await this.state.core.store.identities.listByUser(record.id)).map(identity => identity.provider) : []
29
+ }
30
+
31
+ // A fresh access token for the signed-in user's account at `provider`, refreshed when about to expire; null without one, or once the provider refuses a refresh.
32
+ async providerToken(provider: string): Promise<string | null> {
33
+ return (await load.flow()).providerToken(this.state, provider)
34
+ }
35
+ }
@@ -0,0 +1,31 @@
1
+ import type { ApprovedClient, RevokeGrantResult } from '../authorize/grants'
2
+ import type { AuthorizeOutcome, AuthorizeParams, DecideResult } from '../authorize/request'
3
+ import type { RequestState } from '../state'
4
+ import { siteRoot } from '../authorize/metadata'
5
+ import { failed } from '../failure'
6
+ import { load } from '../load'
7
+
8
+ // `auth.oauthServer`: the consent page MCP clients send the user to, and the apps they approved.
9
+ export class OAuthServerMethods {
10
+ constructor(private readonly state: RequestState, private readonly request: Request) {}
11
+
12
+ // What the authorization endpoint does with an MCP client's request: send the visitor to sign in, show the consent page, or go back to the client with a code once they approved it for these scopes.
13
+ async authorize(params: AuthorizeParams): Promise<AuthorizeOutcome> {
14
+ return this.state.core.oauthServer ? (await load.request()).authorize(this.state, params, siteRoot(this.state.core, this.request)) : { kind: 'error', error: 'client' }
15
+ }
16
+
17
+ // The user's answer on the consent page, checked again as the request is: where the browser goes next.
18
+ async decide(fields: AuthorizeParams, allow: boolean): Promise<DecideResult> {
19
+ return this.state.core.oauthServer ? (await load.request()).decide(this.state, fields, allow, siteRoot(this.state.core, this.request)) : failed('client')
20
+ }
21
+
22
+ // The apps the signed-in user approved to act as them.
23
+ async clients(): Promise<ApprovedClient[]> {
24
+ return (await load.grants()).approvedClients(this.state)
25
+ }
26
+
27
+ // Takes an app's approval back with every token it was given; refused with `not-found` when there was none, and `signed-out` outside the user's own session.
28
+ async revokeGrant(clientId: string): Promise<RevokeGrantResult> {
29
+ return (await load.grants()).revokeClient(this.state, clientId)
30
+ }
31
+ }