@sharadox/account-web-library 0.1.0-development.3 → 0.1.0-development.33

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 (392) hide show
  1. package/README.md +270 -8
  2. package/distribution/account-activity/index.d.ts +16 -0
  3. package/distribution/account-activity/index.d.ts.map +1 -0
  4. package/distribution/account-activity/index.js +18 -0
  5. package/distribution/account-activity/index.js.map +1 -0
  6. package/distribution/account-activity/type.d.ts +15 -0
  7. package/distribution/account-activity/type.d.ts.map +1 -0
  8. package/distribution/account-activity/type.js.map +1 -0
  9. package/distribution/account-ban/index.d.ts +67 -0
  10. package/distribution/account-ban/index.d.ts.map +1 -0
  11. package/distribution/account-ban/index.js +233 -0
  12. package/distribution/account-ban/index.js.map +1 -0
  13. package/distribution/account-ban/type.d.ts +44 -0
  14. package/distribution/account-ban/type.d.ts.map +1 -0
  15. package/distribution/account-ban/type.js +2 -0
  16. package/distribution/account-ban/type.js.map +1 -0
  17. package/distribution/account-database/type.d.ts +264 -0
  18. package/distribution/account-database/type.d.ts.map +1 -0
  19. package/distribution/account-database/type.js +2 -0
  20. package/distribution/account-database/type.js.map +1 -0
  21. package/distribution/account-deletion/index.d.ts +21 -0
  22. package/distribution/account-deletion/index.d.ts.map +1 -0
  23. package/distribution/account-deletion/index.js +66 -0
  24. package/distribution/account-deletion/index.js.map +1 -0
  25. package/distribution/account-export/index.d.ts +17 -0
  26. package/distribution/account-export/index.d.ts.map +1 -0
  27. package/distribution/account-export/index.js +87 -0
  28. package/distribution/account-export/index.js.map +1 -0
  29. package/distribution/account-export/type.d.ts +40 -0
  30. package/distribution/account-export/type.d.ts.map +1 -0
  31. package/distribution/account-export/type.js +2 -0
  32. package/distribution/account-export/type.js.map +1 -0
  33. package/distribution/account-inactivity/index.d.ts +25 -0
  34. package/distribution/account-inactivity/index.d.ts.map +1 -0
  35. package/distribution/account-inactivity/index.js +100 -0
  36. package/distribution/account-inactivity/index.js.map +1 -0
  37. package/distribution/account-migration/index.d.ts +18 -0
  38. package/distribution/account-migration/index.d.ts.map +1 -0
  39. package/distribution/account-migration/index.js +376 -0
  40. package/distribution/account-migration/index.js.map +1 -0
  41. package/distribution/account-name/index.d.ts +13 -0
  42. package/distribution/account-name/index.d.ts.map +1 -0
  43. package/distribution/account-name/index.js +22 -0
  44. package/distribution/account-name/index.js.map +1 -0
  45. package/distribution/account-name/type.d.ts +9 -0
  46. package/distribution/account-name/type.d.ts.map +1 -0
  47. package/distribution/account-name/type.js +2 -0
  48. package/distribution/account-name/type.js.map +1 -0
  49. package/distribution/account-name-change/index.d.ts +15 -0
  50. package/distribution/account-name-change/index.d.ts.map +1 -0
  51. package/distribution/account-name-change/index.js +26 -0
  52. package/distribution/account-name-change/index.js.map +1 -0
  53. package/distribution/account-name-change/type.d.ts +7 -0
  54. package/distribution/account-name-change/type.d.ts.map +1 -0
  55. package/distribution/account-name-change/type.js +2 -0
  56. package/distribution/account-name-change/type.js.map +1 -0
  57. package/distribution/account-notice/index.d.ts +15 -0
  58. package/distribution/account-notice/index.d.ts.map +1 -0
  59. package/distribution/account-notice/index.js +41 -0
  60. package/distribution/account-notice/index.js.map +1 -0
  61. package/distribution/account-permission/index.d.ts +14 -0
  62. package/distribution/account-permission/index.d.ts.map +1 -0
  63. package/distribution/account-permission/index.js +91 -0
  64. package/distribution/account-permission/index.js.map +1 -0
  65. package/distribution/account-permission/type.d.ts +12 -0
  66. package/distribution/account-permission/type.d.ts.map +1 -0
  67. package/distribution/account-permission/type.js +2 -0
  68. package/distribution/account-permission/type.js.map +1 -0
  69. package/distribution/account-picture-change/index.d.ts +30 -0
  70. package/distribution/account-picture-change/index.d.ts.map +1 -0
  71. package/distribution/account-picture-change/index.js +70 -0
  72. package/distribution/account-picture-change/index.js.map +1 -0
  73. package/distribution/account-picture-change/type.d.ts +11 -0
  74. package/distribution/account-picture-change/type.d.ts.map +1 -0
  75. package/distribution/account-picture-change/type.js +2 -0
  76. package/distribution/account-picture-change/type.js.map +1 -0
  77. package/distribution/account-server/index.d.ts +25 -0
  78. package/distribution/account-server/index.d.ts.map +1 -0
  79. package/distribution/account-server/index.js +34 -0
  80. package/distribution/account-server/index.js.map +1 -0
  81. package/distribution/account-server/type.d.ts +30 -0
  82. package/distribution/account-server/type.d.ts.map +1 -0
  83. package/distribution/account-server/type.js +2 -0
  84. package/distribution/account-server/type.js.map +1 -0
  85. package/distribution/account-session-end/index.d.ts +15 -0
  86. package/distribution/account-session-end/index.d.ts.map +1 -0
  87. package/distribution/account-session-end/index.js +21 -0
  88. package/distribution/account-session-end/index.js.map +1 -0
  89. package/distribution/account-session-list/index.d.ts +16 -0
  90. package/distribution/account-session-list/index.d.ts.map +1 -0
  91. package/distribution/account-session-list/index.js +33 -0
  92. package/distribution/account-session-list/index.js.map +1 -0
  93. package/distribution/account-session-list/type.d.ts +13 -0
  94. package/distribution/account-session-list/type.d.ts.map +1 -0
  95. package/distribution/account-session-list/type.js +2 -0
  96. package/distribution/account-session-list/type.js.map +1 -0
  97. package/distribution/account-session-revocation/index.d.ts +14 -0
  98. package/distribution/account-session-revocation/index.d.ts.map +1 -0
  99. package/distribution/account-session-revocation/index.js +25 -0
  100. package/distribution/account-session-revocation/index.js.map +1 -0
  101. package/distribution/account-sign-in/index.d.ts +15 -0
  102. package/distribution/account-sign-in/index.d.ts.map +1 -0
  103. package/distribution/account-sign-in/index.js +78 -0
  104. package/distribution/account-sign-in/index.js.map +1 -0
  105. package/distribution/account-sign-in/type.d.ts +24 -0
  106. package/distribution/account-sign-in/type.d.ts.map +1 -0
  107. package/distribution/account-sign-in/type.js +2 -0
  108. package/distribution/account-sign-in/type.js.map +1 -0
  109. package/distribution/account-sign-out/index.d.ts +16 -0
  110. package/distribution/account-sign-out/index.d.ts.map +1 -0
  111. package/distribution/account-sign-out/index.js +34 -0
  112. package/distribution/account-sign-out/index.js.map +1 -0
  113. package/distribution/application-sync/index.d.ts +14 -0
  114. package/distribution/application-sync/index.d.ts.map +1 -0
  115. package/distribution/application-sync/index.js +96 -0
  116. package/distribution/application-sync/index.js.map +1 -0
  117. package/distribution/application-sync/type.d.ts +29 -0
  118. package/distribution/application-sync/type.d.ts.map +1 -0
  119. package/distribution/application-sync/type.js +2 -0
  120. package/distribution/application-sync/type.js.map +1 -0
  121. package/distribution/audit-event/index.d.ts +12 -0
  122. package/distribution/audit-event/index.d.ts.map +1 -0
  123. package/distribution/audit-event/index.js +36 -0
  124. package/distribution/audit-event/index.js.map +1 -0
  125. package/distribution/audit-event/type.d.ts +16 -0
  126. package/distribution/audit-event/type.d.ts.map +1 -0
  127. package/distribution/audit-event/type.js +2 -0
  128. package/distribution/audit-event/type.js.map +1 -0
  129. package/distribution/banned-contact/index.d.ts +34 -0
  130. package/distribution/banned-contact/index.d.ts.map +1 -0
  131. package/distribution/banned-contact/index.js +52 -0
  132. package/distribution/banned-contact/index.js.map +1 -0
  133. package/distribution/browser-session-read/index.d.ts +17 -0
  134. package/distribution/browser-session-read/index.d.ts.map +1 -0
  135. package/distribution/browser-session-read/index.js +52 -0
  136. package/distribution/browser-session-read/index.js.map +1 -0
  137. package/distribution/browser-session-read/type.d.ts +18 -0
  138. package/distribution/browser-session-read/type.d.ts.map +1 -0
  139. package/distribution/browser-session-read/type.js +2 -0
  140. package/distribution/browser-session-read/type.js.map +1 -0
  141. package/distribution/challenge-issue/index.d.ts +13 -0
  142. package/distribution/challenge-issue/index.d.ts.map +1 -0
  143. package/distribution/challenge-issue/index.js +18 -0
  144. package/distribution/challenge-issue/index.js.map +1 -0
  145. package/distribution/code-request/index.d.ts +16 -0
  146. package/distribution/code-request/index.d.ts.map +1 -0
  147. package/distribution/code-request/index.js +52 -0
  148. package/distribution/code-request/index.js.map +1 -0
  149. package/distribution/code-request/type.d.ts +25 -0
  150. package/distribution/code-request/type.d.ts.map +1 -0
  151. package/distribution/code-request/type.js +2 -0
  152. package/distribution/code-request/type.js.map +1 -0
  153. package/distribution/code-request-prune/index.d.ts +13 -0
  154. package/distribution/code-request-prune/index.d.ts.map +1 -0
  155. package/distribution/code-request-prune/index.js +12 -0
  156. package/distribution/code-request-prune/index.js.map +1 -0
  157. package/distribution/code-sending/index.d.ts +14 -0
  158. package/distribution/code-sending/index.d.ts.map +1 -0
  159. package/distribution/code-sending/index.js +65 -0
  160. package/distribution/code-sending/index.js.map +1 -0
  161. package/distribution/code-sending/type.d.ts +31 -0
  162. package/distribution/code-sending/type.d.ts.map +1 -0
  163. package/distribution/code-sending/type.js +2 -0
  164. package/distribution/code-sending/type.js.map +1 -0
  165. package/distribution/code-verification/index.d.ts +14 -0
  166. package/distribution/code-verification/index.d.ts.map +1 -0
  167. package/distribution/code-verification/index.js +43 -0
  168. package/distribution/code-verification/index.js.map +1 -0
  169. package/distribution/code-verification/type.d.ts +22 -0
  170. package/distribution/code-verification/type.d.ts.map +1 -0
  171. package/distribution/code-verification/type.js +2 -0
  172. package/distribution/code-verification/type.js.map +1 -0
  173. package/distribution/contact-addition/index.d.ts +13 -0
  174. package/distribution/contact-addition/index.d.ts.map +1 -0
  175. package/distribution/contact-addition/index.js +48 -0
  176. package/distribution/contact-addition/index.js.map +1 -0
  177. package/distribution/contact-addition/type.d.ts +15 -0
  178. package/distribution/contact-addition/type.d.ts.map +1 -0
  179. package/distribution/contact-addition/type.js +2 -0
  180. package/distribution/contact-addition/type.js.map +1 -0
  181. package/distribution/contact-addition-flow/index.d.ts +32 -0
  182. package/distribution/contact-addition-flow/index.d.ts.map +1 -0
  183. package/distribution/contact-addition-flow/index.js +96 -0
  184. package/distribution/contact-addition-flow/index.js.map +1 -0
  185. package/distribution/contact-addition-flow/type.d.ts +25 -0
  186. package/distribution/contact-addition-flow/type.d.ts.map +1 -0
  187. package/distribution/contact-addition-flow/type.js +2 -0
  188. package/distribution/contact-addition-flow/type.js.map +1 -0
  189. package/distribution/contact-channel/type.d.ts +49 -0
  190. package/distribution/contact-channel/type.d.ts.map +1 -0
  191. package/distribution/contact-channel/type.js +2 -0
  192. package/distribution/contact-channel/type.js.map +1 -0
  193. package/distribution/contact-kind/index.d.ts +12 -0
  194. package/distribution/contact-kind/index.d.ts.map +1 -0
  195. package/distribution/contact-kind/index.js +18 -0
  196. package/distribution/contact-kind/index.js.map +1 -0
  197. package/distribution/contact-kind/type.d.ts +6 -0
  198. package/distribution/contact-kind/type.d.ts.map +1 -0
  199. package/distribution/contact-kind/type.js +2 -0
  200. package/distribution/contact-kind/type.js.map +1 -0
  201. package/distribution/contact-lookup/index.d.ts +16 -0
  202. package/distribution/contact-lookup/index.d.ts.map +1 -0
  203. package/distribution/contact-lookup/index.js +20 -0
  204. package/distribution/contact-lookup/index.js.map +1 -0
  205. package/distribution/contact-removal/index.d.ts +19 -0
  206. package/distribution/contact-removal/index.d.ts.map +1 -0
  207. package/distribution/contact-removal/index.js +35 -0
  208. package/distribution/contact-removal/index.js.map +1 -0
  209. package/distribution/contact-verification/index.d.ts +20 -0
  210. package/distribution/contact-verification/index.d.ts.map +1 -0
  211. package/distribution/contact-verification/index.js +37 -0
  212. package/distribution/contact-verification/index.js.map +1 -0
  213. package/distribution/database-error/index.d.ts +12 -0
  214. package/distribution/database-error/index.d.ts.map +1 -0
  215. package/distribution/database-error/index.js +14 -0
  216. package/distribution/database-error/index.js.map +1 -0
  217. package/distribution/email-channel/index.d.ts +13 -0
  218. package/distribution/email-channel/index.d.ts.map +1 -0
  219. package/distribution/email-channel/index.js +185 -0
  220. package/distribution/email-channel/index.js.map +1 -0
  221. package/distribution/email-channel/type.d.ts +17 -0
  222. package/distribution/email-channel/type.d.ts.map +1 -0
  223. package/distribution/email-channel/type.js +2 -0
  224. package/distribution/email-channel/type.js.map +1 -0
  225. package/distribution/identifier/index.d.ts +23 -0
  226. package/distribution/identifier/index.d.ts.map +1 -0
  227. package/distribution/identifier/index.js +32 -0
  228. package/distribution/identifier/index.js.map +1 -0
  229. package/distribution/identifier/type.d.ts +10 -0
  230. package/distribution/identifier/type.d.ts.map +1 -0
  231. package/distribution/identifier/type.js +2 -0
  232. package/distribution/identifier/type.js.map +1 -0
  233. package/distribution/identifier-availability/index.d.ts +11 -0
  234. package/distribution/identifier-availability/index.d.ts.map +1 -0
  235. package/distribution/identifier-availability/index.js +21 -0
  236. package/distribution/identifier-availability/index.js.map +1 -0
  237. package/distribution/identifier-change/index.d.ts +15 -0
  238. package/distribution/identifier-change/index.d.ts.map +1 -0
  239. package/distribution/identifier-change/index.js +43 -0
  240. package/distribution/identifier-change/index.js.map +1 -0
  241. package/distribution/identifier-change/type.d.ts +7 -0
  242. package/distribution/identifier-change/type.d.ts.map +1 -0
  243. package/distribution/identifier-change/type.js +2 -0
  244. package/distribution/identifier-change/type.js.map +1 -0
  245. package/distribution/memory-picture-storage/index.d.ts +15 -0
  246. package/distribution/memory-picture-storage/index.d.ts.map +1 -0
  247. package/distribution/memory-picture-storage/index.js +16 -0
  248. package/distribution/memory-picture-storage/index.js.map +1 -0
  249. package/distribution/one-time-code/index.d.ts +2 -2
  250. package/distribution/one-time-code/index.js +3 -3
  251. package/distribution/person-account/index.d.ts +18 -0
  252. package/distribution/person-account/index.d.ts.map +1 -0
  253. package/distribution/person-account/index.js +65 -0
  254. package/distribution/person-account/index.js.map +1 -0
  255. package/distribution/person-account/type.d.ts +22 -0
  256. package/distribution/person-account/type.d.ts.map +1 -0
  257. package/distribution/person-account/type.js +2 -0
  258. package/distribution/person-account/type.js.map +1 -0
  259. package/distribution/picture-key/index.d.ts +8 -0
  260. package/distribution/picture-key/index.d.ts.map +1 -0
  261. package/distribution/picture-key/index.js +10 -0
  262. package/distribution/picture-key/index.js.map +1 -0
  263. package/distribution/picture-preparation/index.d.ts +18 -0
  264. package/distribution/picture-preparation/index.d.ts.map +1 -0
  265. package/distribution/picture-preparation/index.js +86 -0
  266. package/distribution/picture-preparation/index.js.map +1 -0
  267. package/distribution/picture-preparation/type.d.ts +18 -0
  268. package/distribution/picture-preparation/type.d.ts.map +1 -0
  269. package/distribution/picture-preparation/type.js +2 -0
  270. package/distribution/picture-preparation/type.js.map +1 -0
  271. package/distribution/picture-storage/type.d.ts +11 -0
  272. package/distribution/picture-storage/type.d.ts.map +1 -0
  273. package/distribution/picture-storage/type.js +2 -0
  274. package/distribution/picture-storage/type.js.map +1 -0
  275. package/distribution/recovery-code-regeneration/index.d.ts +19 -0
  276. package/distribution/recovery-code-regeneration/index.d.ts.map +1 -0
  277. package/distribution/recovery-code-regeneration/index.js +34 -0
  278. package/distribution/recovery-code-regeneration/index.js.map +1 -0
  279. package/distribution/recovery-code-store/index.d.ts +25 -0
  280. package/distribution/recovery-code-store/index.d.ts.map +1 -0
  281. package/distribution/recovery-code-store/index.js +34 -0
  282. package/distribution/recovery-code-store/index.js.map +1 -0
  283. package/distribution/role-grant/index.d.ts +38 -0
  284. package/distribution/role-grant/index.d.ts.map +1 -0
  285. package/distribution/role-grant/index.js +142 -0
  286. package/distribution/role-grant/index.js.map +1 -0
  287. package/distribution/role-grant/type.d.ts +40 -0
  288. package/distribution/role-grant/type.d.ts.map +1 -0
  289. package/distribution/role-grant/type.js +2 -0
  290. package/distribution/role-grant/type.js.map +1 -0
  291. package/distribution/rule-sync/index.d.ts +28 -0
  292. package/distribution/rule-sync/index.d.ts.map +1 -0
  293. package/distribution/rule-sync/index.js +80 -0
  294. package/distribution/rule-sync/index.js.map +1 -0
  295. package/distribution/rule-sync/type.d.ts +17 -0
  296. package/distribution/rule-sync/type.d.ts.map +1 -0
  297. package/distribution/rule-sync/type.js +2 -0
  298. package/distribution/rule-sync/type.js.map +1 -0
  299. package/distribution/second-factor-finish/index.d.ts +13 -0
  300. package/distribution/second-factor-finish/index.d.ts.map +1 -0
  301. package/distribution/second-factor-finish/index.js +90 -0
  302. package/distribution/second-factor-finish/index.js.map +1 -0
  303. package/distribution/second-factor-finish/type.d.ts +30 -0
  304. package/distribution/second-factor-finish/type.d.ts.map +1 -0
  305. package/distribution/second-factor-finish/type.js +2 -0
  306. package/distribution/second-factor-finish/type.js.map +1 -0
  307. package/distribution/secret-derivation/index.d.ts +10 -0
  308. package/distribution/secret-derivation/index.d.ts.map +1 -0
  309. package/distribution/secret-derivation/index.js +15 -0
  310. package/distribution/secret-derivation/index.js.map +1 -0
  311. package/distribution/secret-encryption/index.d.ts +17 -0
  312. package/distribution/secret-encryption/index.d.ts.map +1 -0
  313. package/distribution/secret-encryption/index.js +37 -0
  314. package/distribution/secret-encryption/index.js.map +1 -0
  315. package/distribution/session-prune/index.d.ts +17 -0
  316. package/distribution/session-prune/index.d.ts.map +1 -0
  317. package/distribution/session-prune/index.js +30 -0
  318. package/distribution/session-prune/index.js.map +1 -0
  319. package/distribution/session-token/index.d.ts +19 -0
  320. package/distribution/session-token/index.d.ts.map +1 -0
  321. package/distribution/session-token/index.js +22 -0
  322. package/distribution/session-token/index.js.map +1 -0
  323. package/distribution/sign-in-finish/index.d.ts +13 -0
  324. package/distribution/sign-in-finish/index.d.ts.map +1 -0
  325. package/distribution/sign-in-finish/index.js +69 -0
  326. package/distribution/sign-in-finish/index.js.map +1 -0
  327. package/distribution/sign-in-finish/type.d.ts +44 -0
  328. package/distribution/sign-in-finish/type.d.ts.map +1 -0
  329. package/distribution/sign-in-finish/type.js +2 -0
  330. package/distribution/sign-in-finish/type.js.map +1 -0
  331. package/distribution/sign-in-start/index.d.ts +17 -0
  332. package/distribution/sign-in-start/index.d.ts.map +1 -0
  333. package/distribution/sign-in-start/index.js +45 -0
  334. package/distribution/sign-in-start/index.js.map +1 -0
  335. package/distribution/sign-in-start/type.d.ts +34 -0
  336. package/distribution/sign-in-start/type.d.ts.map +1 -0
  337. package/distribution/sign-in-start/type.js +2 -0
  338. package/distribution/sign-in-start/type.js.map +1 -0
  339. package/distribution/sign-up-finish/index.d.ts +13 -0
  340. package/distribution/sign-up-finish/index.d.ts.map +1 -0
  341. package/distribution/sign-up-finish/index.js +38 -0
  342. package/distribution/sign-up-finish/index.js.map +1 -0
  343. package/distribution/sign-up-finish/type.d.ts +28 -0
  344. package/distribution/sign-up-finish/type.d.ts.map +1 -0
  345. package/distribution/sign-up-finish/type.js +2 -0
  346. package/distribution/sign-up-finish/type.js.map +1 -0
  347. package/distribution/signed-ticket/index.d.ts +19 -0
  348. package/distribution/signed-ticket/index.d.ts.map +1 -0
  349. package/distribution/signed-ticket/index.js +35 -0
  350. package/distribution/signed-ticket/index.js.map +1 -0
  351. package/distribution/signed-ticket/type.d.ts +16 -0
  352. package/distribution/signed-ticket/type.d.ts.map +1 -0
  353. package/distribution/signed-ticket/type.js +2 -0
  354. package/distribution/signed-ticket/type.js.map +1 -0
  355. package/distribution/step-up/index.d.ts +48 -0
  356. package/distribution/step-up/index.d.ts.map +1 -0
  357. package/distribution/step-up/index.js +83 -0
  358. package/distribution/step-up/index.js.map +1 -0
  359. package/distribution/step-up/type.d.ts +15 -0
  360. package/distribution/step-up/type.d.ts.map +1 -0
  361. package/distribution/step-up/type.js +2 -0
  362. package/distribution/{username → step-up}/type.js.map +1 -1
  363. package/distribution/test-database/index.d.ts +13 -0
  364. package/distribution/test-database/index.d.ts.map +1 -0
  365. package/distribution/test-database/index.js +17 -0
  366. package/distribution/test-database/index.js.map +1 -0
  367. package/distribution/test-person/index.d.ts +14 -0
  368. package/distribution/test-person/index.d.ts.map +1 -0
  369. package/distribution/test-person/index.js +20 -0
  370. package/distribution/test-person/index.js.map +1 -0
  371. package/distribution/test-server/index.d.ts +10 -0
  372. package/distribution/test-server/index.d.ts.map +1 -0
  373. package/distribution/test-server/index.js +16 -0
  374. package/distribution/test-server/index.js.map +1 -0
  375. package/distribution/totp/type.d.ts +1 -1
  376. package/distribution/totp/type.d.ts.map +1 -1
  377. package/distribution/totp-setup/index.d.ts +50 -0
  378. package/distribution/totp-setup/index.d.ts.map +1 -0
  379. package/distribution/totp-setup/index.js +136 -0
  380. package/distribution/totp-setup/index.js.map +1 -0
  381. package/distribution/totp-setup/type.d.ts +24 -0
  382. package/distribution/totp-setup/type.d.ts.map +1 -0
  383. package/distribution/totp-setup/type.js +2 -0
  384. package/distribution/totp-setup/type.js.map +1 -0
  385. package/package.json +9 -2
  386. package/distribution/username/index.d.ts +0 -23
  387. package/distribution/username/index.d.ts.map +0 -1
  388. package/distribution/username/index.js +0 -32
  389. package/distribution/username/index.js.map +0 -1
  390. package/distribution/username/type.d.ts +0 -10
  391. package/distribution/username/type.d.ts.map +0 -1
  392. /package/distribution/{username → account-activity}/type.js +0 -0
@@ -0,0 +1,91 @@
1
+ import { effectivePermissions } from "@sharadox/account-web-library/effective-permissions";
2
+ /**
3
+ * What an account may do in one application now, from the database: the application's default role, the account's
4
+ * active grants (an active exclusive one, a ban, leaving only its own permissions), limited to `scope`, and for an
5
+ * agent to what its owner may do right now. An unknown application gives nothing.
6
+ *
7
+ * @example
8
+ * const permissions = await accountPermissions(database, { accountId, application: "platform" });
9
+ * if (!permissions.has("platform.job.create")) return forbidden();
10
+ */
11
+ export async function accountPermissions(database, { accountId, application, resource, scope, now = Date.now() }) {
12
+ const app = await database.selectFrom("application").select("id").where("key", "=", application).executeTakeFirst();
13
+ if (!app)
14
+ return new Set();
15
+ const rows = await database
16
+ .selectFrom("role")
17
+ .leftJoin("application", "application.id", "role.application_id")
18
+ .leftJoin("role_permission", "role_permission.role_id", "role.id")
19
+ .leftJoin("permission", "permission.id", "role_permission.permission_id")
20
+ .select([
21
+ "role.id",
22
+ "application.key as application",
23
+ "role.exclusive",
24
+ "role.is_default",
25
+ "permission.key as permission",
26
+ ])
27
+ .where((where) => where.or([where("role.application_id", "=", app.id), where("role.application_id", "is", null)]))
28
+ .execute();
29
+ const roles = new Map();
30
+ for (const row of rows) {
31
+ const role = roles.get(row.id) ?? {
32
+ id: row.id,
33
+ application: row.application,
34
+ permissions: [],
35
+ exclusive: row.exclusive,
36
+ isDefault: row.is_default,
37
+ };
38
+ if (row.permission)
39
+ role.permissions.push(row.permission);
40
+ roles.set(row.id, role);
41
+ }
42
+ const grants = (await database
43
+ .selectFrom("role_grant")
44
+ .innerJoin("role", "role.id", "role_grant.role_id")
45
+ .leftJoin("application", "application.id", "role.application_id")
46
+ .select([
47
+ "role_grant.role_id",
48
+ "application.key as application",
49
+ "role_grant.resource",
50
+ "role_grant.starts_at",
51
+ "role_grant.ends_at",
52
+ ])
53
+ .where("role_grant.account_id", "=", accountId)
54
+ .execute()).map((grant) => ({
55
+ roleId: grant.role_id,
56
+ application: grant.application,
57
+ resource: grant.resource,
58
+ startsAt: grant.starts_at.getTime(),
59
+ endsAt: grant.ends_at ? grant.ends_at.getTime() : null,
60
+ }));
61
+ const account = await database
62
+ .selectFrom("account")
63
+ .select("owner_id")
64
+ .where("id", "=", accountId)
65
+ .executeTakeFirst();
66
+ const ownerPermissions = account?.owner_id
67
+ ? await accountPermissions(database, {
68
+ accountId: account.owner_id,
69
+ application,
70
+ ...(resource ? { resource } : {}),
71
+ now,
72
+ })
73
+ : undefined;
74
+ const defaultRole = [...roles.values()].find((role) => role.isDefault) ?? {
75
+ id: "",
76
+ application,
77
+ permissions: [],
78
+ exclusive: false,
79
+ };
80
+ return effectivePermissions({
81
+ application,
82
+ ...(resource ? { resource } : {}),
83
+ now,
84
+ defaultRole,
85
+ roles: [...roles.values()],
86
+ grants,
87
+ ...(scope ? { scope } : {}),
88
+ ...(ownerPermissions ? { ownerPermissions } : {}),
89
+ });
90
+ }
91
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/account-permission/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAG3F;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,QAAiC,EACjC,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAA6B;IAExF,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EA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G,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI;QACxE,EAAE,EAAE,EAAE;QACN,WAAW;QACX,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,KAAK;KACjB,CAAC;IACF,OAAO,oBAAoB,CAAC;QAC1B,WAAW;QACX,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,GAAG;QACH,WAAW;QACX,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1B,MAAM;QACN,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface AccountPermissionQuestion {
2
+ accountId: string;
3
+ /** The application's key (`platform`). */
4
+ application: string;
5
+ /** The resource the action is on (`platform:project:42`), for roles limited to one. */
6
+ resource?: string;
7
+ /** A token's or key's scope: at most these. */
8
+ scope?: string[];
9
+ /** Milliseconds since 1970 (now by default). */
10
+ now?: number;
11
+ }
12
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/account-permission/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/account-permission/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,30 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
3
+ import type { AccountPictureChangeResult } from "@sharadox/account-web-library/account-picture-change/type";
4
+ import type { PictureStorage } from "@sharadox/account-web-library/picture-storage/type";
5
+ /**
6
+ * Sets an account's picture from an uploaded file (checked and made safe by `preparePicture`): the new file is
7
+ * stored first, then the database points to it, then the old file is deleted, so the account is never left without
8
+ * a working picture and replaced files never stay behind.
9
+ *
10
+ * @example
11
+ * const result = await setAccountPicture(database, storage, { accountId, bytes });
12
+ * if (result.changed) revalidate(result.pictureId);
13
+ */
14
+ export declare function setAccountPicture(database: Kysely<AccountDatabase>, storage: PictureStorage, { accountId, bytes, now }: {
15
+ accountId: string;
16
+ bytes: Uint8Array;
17
+ now?: number;
18
+ }): Promise<AccountPictureChangeResult>;
19
+ /**
20
+ * Removes an account's picture and deletes its file.
21
+ *
22
+ * @example
23
+ * await removeAccountPicture(database, storage, { accountId }); // { removed: true }
24
+ */
25
+ export declare function removeAccountPicture(database: Kysely<AccountDatabase>, storage: PictureStorage, { accountId }: {
26
+ accountId: string;
27
+ }): Promise<{
28
+ removed: boolean;
29
+ }>;
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/account-picture-change/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,2DAA2D,CAAC;AAI5G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAEzF;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,OAAO,EAAE,cAAc,EACvB,EAAE,SAAS,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7F,OAAO,CAAC,0BAA0B,CAAC,CA8BrC;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,OAAO,EAAE,cAAc,EACvB,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GACnC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAa/B"}
@@ -0,0 +1,70 @@
1
+ import { uuidVersion7 } from "@sharadox/web-library/identifier/uuid-version-7";
2
+ import { recordAuditEvent } from "@sharadox/account-web-library/audit-event";
3
+ import { pictureKey } from "@sharadox/account-web-library/picture-key";
4
+ import { preparePicture } from "@sharadox/account-web-library/picture-preparation";
5
+ /**
6
+ * Sets an account's picture from an uploaded file (checked and made safe by `preparePicture`): the new file is
7
+ * stored first, then the database points to it, then the old file is deleted, so the account is never left without
8
+ * a working picture and replaced files never stay behind.
9
+ *
10
+ * @example
11
+ * const result = await setAccountPicture(database, storage, { accountId, bytes });
12
+ * if (result.changed) revalidate(result.pictureId);
13
+ */
14
+ export async function setAccountPicture(database, storage, { accountId, bytes, now = Date.now() }) {
15
+ const prepared = await preparePicture(bytes);
16
+ if (!prepared.valid)
17
+ return { changed: false, reason: prepared.reason };
18
+ const account = await database.selectFrom("account").select("id").where("id", "=", accountId).executeTakeFirst();
19
+ if (!account)
20
+ return { changed: false, reason: "no-account" };
21
+ const pictureId = uuidVersion7({ now });
22
+ await storage.put(pictureKey(pictureId), prepared.bytes, "image/webp");
23
+ const old = await database.transaction().execute(async (transaction) => {
24
+ const previous = await transaction
25
+ .deleteFrom("account_picture")
26
+ .where("account_id", "=", accountId)
27
+ .returning("id")
28
+ .executeTakeFirst();
29
+ await transaction
30
+ .insertInto("account_picture")
31
+ .values({
32
+ id: pictureId,
33
+ account_id: accountId,
34
+ content_type: "image/webp",
35
+ byte_size: prepared.bytes.length,
36
+ width: prepared.width,
37
+ height: prepared.height,
38
+ created_at: new Date(now),
39
+ })
40
+ .execute();
41
+ await recordAuditEvent(transaction, { accountId, action: "account.picture-changed", detail: { pictureId }, now });
42
+ return previous;
43
+ });
44
+ if (old)
45
+ await storage.remove(pictureKey(old.id));
46
+ return { changed: true, pictureId };
47
+ }
48
+ /**
49
+ * Removes an account's picture and deletes its file.
50
+ *
51
+ * @example
52
+ * await removeAccountPicture(database, storage, { accountId }); // { removed: true }
53
+ */
54
+ export async function removeAccountPicture(database, storage, { accountId }) {
55
+ const removed = await database.transaction().execute(async (transaction) => {
56
+ const picture = await transaction
57
+ .deleteFrom("account_picture")
58
+ .where("account_id", "=", accountId)
59
+ .returning("id")
60
+ .executeTakeFirst();
61
+ if (picture)
62
+ await recordAuditEvent(transaction, { accountId, action: "account.picture-removed" });
63
+ return picture;
64
+ });
65
+ if (!removed)
66
+ return { removed: false };
67
+ await storage.remove(pictureKey(removed.id));
68
+ return { removed: true };
69
+ }
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/account-picture-change/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAG/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mDAAmD,CAAC;AAGnF;;;;;;;;GAQG;AAC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CAAC,CAAC,CAAC;IAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { PreparedPicture } from "@sharadox/account-web-library/picture-preparation/type";
2
+ export type AccountPictureChangeResult = {
3
+ changed: true;
4
+ pictureId: string;
5
+ } | {
6
+ changed: false;
7
+ reason: Extract<PreparedPicture, {
8
+ valid: false;
9
+ }>["reason"] | "no-account";
10
+ };
11
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/account-picture-change/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wDAAwD,CAAC;AAE9F,MAAM,MAAM,0BAA0B,GAClC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,YAAY,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/account-picture-change/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
3
+ import type { AccountServer, SignInLimits } from "@sharadox/account-web-library/account-server/type";
4
+ /**
5
+ * The limits used when a company's configuration doesn't set them: 3 codes per contact then one per 5 minutes; 10
6
+ * per address group then one a minute; 200 for everyone then one a second; 20 typed codes per address group then
7
+ * one per 30 seconds; 5 two-factor codes per account then one a minute; 2,000 sends per channel per UTC day; proof of work of 14 bits.
8
+ */
9
+ export declare const DEFAULT_SIGN_IN_LIMITS: SignInLimits;
10
+ /**
11
+ * A server's limits: its own where set, the defaults elsewhere.
12
+ *
13
+ * @example
14
+ * const { perContact } = signInLimits(server);
15
+ */
16
+ export declare function signInLimits(server: AccountServer): SignInLimits;
17
+ /**
18
+ * The server's database seen through the account tables alone, for helpers that take `Kysely<AccountDatabase>`
19
+ * (its transactions then have that type too).
20
+ *
21
+ * @example
22
+ * await accountTables(server).transaction().execute((transaction) => removeTotp(transaction, { accountId }));
23
+ */
24
+ export declare function accountTables(server: AccountServer): Kysely<AccountDatabase>;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/account-server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mDAAmD,CAAC;AAErG;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,YAQpC,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,YAAY,CAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAE5E"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The limits used when a company's configuration doesn't set them: 3 codes per contact then one per 5 minutes; 10
3
+ * per address group then one a minute; 200 for everyone then one a second; 20 typed codes per address group then
4
+ * one per 30 seconds; 5 two-factor codes per account then one a minute; 2,000 sends per channel per UTC day; proof of work of 14 bits.
5
+ */
6
+ export const DEFAULT_SIGN_IN_LIMITS = {
7
+ perContact: { capacity: 3, refillPerSecond: 1 / 300 },
8
+ perAddress: { capacity: 10, refillPerSecond: 1 / 60 },
9
+ global: { capacity: 200, refillPerSecond: 1 },
10
+ verificationsPerAddress: { capacity: 20, refillPerSecond: 1 / 30 },
11
+ secondFactorPerAccount: { capacity: 5, refillPerSecond: 1 / 60 },
12
+ dailySendsPerChannel: 2_000,
13
+ difficulty: 14,
14
+ };
15
+ /**
16
+ * A server's limits: its own where set, the defaults elsewhere.
17
+ *
18
+ * @example
19
+ * const { perContact } = signInLimits(server);
20
+ */
21
+ export function signInLimits(server) {
22
+ return { ...DEFAULT_SIGN_IN_LIMITS, ...server.limits };
23
+ }
24
+ /**
25
+ * The server's database seen through the account tables alone, for helpers that take `Kysely<AccountDatabase>`
26
+ * (its transactions then have that type too).
27
+ *
28
+ * @example
29
+ * await accountTables(server).transaction().execute((transaction) => removeTotp(transaction, { accountId }));
30
+ */
31
+ export function accountTables(server) {
32
+ return server.database;
33
+ }
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/account-server/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAiB;IAClD,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,GAAG,GAAG,EAAE;IACrD,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE;IACrD,MAAM,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC,EAAE;IAC7C,uBAAuB,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE;IAClE,sBAAsB,EAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE;IAChE,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE,EAAE;CACf,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAqB;IAChD,OAAO,EAAE,GAAG,sBAAsB,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;AACzD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,MAAqB;IACjD,OAAO,MAAM,CAAC,QAAQ,CAAC;AACzB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { TokenBucketRule } from "@sharadox/protection-web-library/token-bucket/type";
3
+ import type { AccountServerDatabase } from "@sharadox/account-web-library/account-database/type";
4
+ import type { ContactChannel } from "@sharadox/account-web-library/contact-channel/type";
5
+ /** How fast each kind of visitor may go. Every field has a default (see `DEFAULT_SIGN_IN_LIMITS`). */
6
+ export interface SignInLimits {
7
+ /** Codes sent to one contact. */
8
+ perContact: TokenBucketRule;
9
+ /** Codes requested from one address group (an IPv4 address, an IPv6 /64). */
10
+ perAddress: TokenBucketRule;
11
+ /** Codes requested by everyone together. */
12
+ global: TokenBucketRule;
13
+ /** Codes typed from one address group. */
14
+ verificationsPerAddress: TokenBucketRule;
15
+ /** Two-factor codes typed for one account. */
16
+ secondFactorPerAccount: TokenBucketRule;
17
+ /** The most codes each channel may send in a UTC day; past it, sending pauses (never spends). */
18
+ dailySendsPerChannel: number;
19
+ /** Leading zero bits of the proof of work. */
20
+ difficulty: number;
21
+ }
22
+ /** What every sign-in step needs: the database, the channels, and one root secret every key is derived from. */
23
+ export interface AccountServer {
24
+ database: Kysely<AccountServerDatabase>;
25
+ channels: ContactChannel[];
26
+ /** At least 32 random characters, server only (`ACCOUNT_SECRET`). */
27
+ secret: string;
28
+ limits?: Partial<SignInLimits>;
29
+ }
30
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/account-server/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oDAAoD,CAAC;AAC1F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAEzF,sGAAsG;AACtG,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,UAAU,EAAE,eAAe,CAAC;IAC5B,6EAA6E;IAC7E,UAAU,EAAE,eAAe,CAAC;IAC5B,4CAA4C;IAC5C,MAAM,EAAE,eAAe,CAAC;IACxB,0CAA0C;IAC1C,uBAAuB,EAAE,eAAe,CAAC;IACzC,8CAA8C;IAC9C,sBAAsB,EAAE,eAAe,CAAC;IACxC,iGAAiG;IACjG,oBAAoB,EAAE,MAAM,CAAC;IAC7B,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,gHAAgH;AAChH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACxC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,qEAAqE;IACrE,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CAChC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/account-server/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
3
+ /**
4
+ * Signs an account out on one device (from its list of devices); only its own sessions can be ended.
5
+ *
6
+ * @example
7
+ * await endAccountSession(database, { accountId, accountSessionId }); // { ended: true }
8
+ */
9
+ export declare function endAccountSession(database: Kysely<AccountDatabase>, { accountId, accountSessionId }: {
10
+ accountId: string;
11
+ accountSessionId: string;
12
+ }): Promise<{
13
+ ended: boolean;
14
+ }>;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/account-session-end/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAG3F;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,EAAE,SAAS,EAAE,gBAAgB,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,GAC/E,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAW7B"}
@@ -0,0 +1,21 @@
1
+ import { recordAuditEvent } from "@sharadox/account-web-library/audit-event";
2
+ /**
3
+ * Signs an account out on one device (from its list of devices); only its own sessions can be ended.
4
+ *
5
+ * @example
6
+ * await endAccountSession(database, { accountId, accountSessionId }); // { ended: true }
7
+ */
8
+ export async function endAccountSession(database, { accountId, accountSessionId }) {
9
+ return database.transaction().execute(async (transaction) => {
10
+ const ended = await transaction
11
+ .deleteFrom("account_session")
12
+ .where("id", "=", accountSessionId)
13
+ .where("account_id", "=", accountId)
14
+ .executeTakeFirst();
15
+ if (ended.numDeletedRows === 0n)
16
+ return { ended: false };
17
+ await recordAuditEvent(transaction, { accountId, action: "session.ended", detail: { accountSessionId } });
18
+ return { ended: true };
19
+ });
20
+ }
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/account-session-end/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAE7E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAiC,EACjC,EAAE,SAAS,EAAE,gBAAgB,EAAmD;IAEhF,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;QAC1D,MAAM,KAAK,GAAG,MAAM,WAAW;aAC5B,UAAU,CAAC,iBAAiB,CAAC;aAC7B,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,gBAAgB,CAAC;aAClC,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,SAAS,CAAC;aACnC,gBAAgB,EAAE,CAAC;QACtB,IAAI,KAAK,CAAC,cAAc,KAAK,EAAE;YAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACzD,MAAM,gBAAgB,CAAC,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAC1G,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
3
+ import type { AccountDevice } from "@sharadox/account-web-library/account-session-list/type";
4
+ /**
5
+ * The devices an account is signed in on, most recently seen first, without sessions that ended; the browser whose
6
+ * token is given is marked `current`.
7
+ *
8
+ * @example
9
+ * const devices = await listAccountSessions(database, { accountId, token: cookies.get("__Host-account")?.value });
10
+ */
11
+ export declare function listAccountSessions(database: Kysely<AccountDatabase>, { accountId, token, now }: {
12
+ accountId: string;
13
+ token: string | undefined;
14
+ now?: number;
15
+ }): Promise<AccountDevice[]>;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/account-session-list/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yDAAyD,CAAC;AAG7F;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,EAAE,SAAS,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GACrG,OAAO,CAAC,aAAa,EAAE,CAAC,CAuB1B"}
@@ -0,0 +1,33 @@
1
+ import { hashSessionToken } from "@sharadox/account-web-library/session-token";
2
+ /**
3
+ * The devices an account is signed in on, most recently seen first, without sessions that ended; the browser whose
4
+ * token is given is marked `current`.
5
+ *
6
+ * @example
7
+ * const devices = await listAccountSessions(database, { accountId, token: cookies.get("__Host-account")?.value });
8
+ */
9
+ export async function listAccountSessions(database, { accountId, token, now = Date.now() }) {
10
+ const asking = token ? hashSessionToken(token) : "";
11
+ const rows = await database
12
+ .selectFrom("account_session")
13
+ .innerJoin("browser_session", "browser_session.id", "account_session.browser_session_id")
14
+ .select([
15
+ "account_session.id as accountSessionId",
16
+ "browser_session.user_agent as userAgent",
17
+ "account_session.created_at as signedInAt",
18
+ "account_session.last_seen_at as lastSeenAt",
19
+ "account_session.second_factor_at as secondFactorAt",
20
+ "browser_session.token_hash as tokenHash",
21
+ ])
22
+ .where("account_session.account_id", "=", accountId)
23
+ .where("account_session.expires_at", ">", new Date(now))
24
+ .orderBy("account_session.last_seen_at", "desc")
25
+ .orderBy("account_session.id", "desc")
26
+ .execute();
27
+ return rows.map(({ secondFactorAt, tokenHash, ...device }) => ({
28
+ ...device,
29
+ secondFactor: secondFactorAt !== null,
30
+ current: tokenHash === asking,
31
+ }));
32
+ }
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/account-session-list/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAE/E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAiC,EACjC,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAkE;IAEtG,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpD,MAAM,IAAI,GAAG,MAAM,QAAQ;SACxB,UAAU,CAAC,iBAAiB,CAAC;SAC7B,SAAS,CAAC,iBAAiB,EAAE,oBAAoB,EAAE,oCAAoC,CAAC;SACxF,MAAM,CAAC;QACN,wCAAwC;QACxC,yCAAyC;QACzC,0CAA0C;QAC1C,4CAA4C;QAC5C,oDAAoD;QACpD,yCAAyC;KAC1C,CAAC;SACD,KAAK,CAAC,4BAA4B,EAAE,GAAG,EAAE,SAAS,CAAC;SACnD,KAAK,CAAC,4BAA4B,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;SACvD,OAAO,CAAC,8BAA8B,EAAE,MAAM,CAAC;SAC/C,OAAO,CAAC,oBAAoB,EAAE,MAAM,CAAC;SACrC,OAAO,EAAE,CAAC;IACb,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7D,GAAG,MAAM;QACT,YAAY,EAAE,cAAc,KAAK,IAAI;QACrC,OAAO,EAAE,SAAS,KAAK,MAAM;KAC9B,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** One device (browser) the account is signed in on. */
2
+ export interface AccountDevice {
3
+ accountSessionId: string;
4
+ /** The browser's description when it signed in; null when unknown. */
5
+ userAgent: string | null;
6
+ signedInAt: Date;
7
+ lastSeenAt: Date;
8
+ /** Whether two-factor was passed in this session. */
9
+ secondFactor: boolean;
10
+ /** Whether it is the browser asking. */
11
+ current: boolean;
12
+ }
13
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/account-session-list/type.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;IACjB,qDAAqD;IACrD,YAAY,EAAE,OAAO,CAAC;IACtB,wCAAwC;IACxC,OAAO,EAAE,OAAO,CAAC;CAClB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/account-session-list/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
3
+ /**
4
+ * Signs an account out on every browser at once: after a ban, a lost device, a recovery, or when its owner asks.
5
+ * Records who did it. Returns how many sessions ended.
6
+ *
7
+ * @example
8
+ * await revokeAccountSessions(database, { accountId, actorAccountId: moderatorId });
9
+ */
10
+ export declare function revokeAccountSessions(database: Kysely<AccountDatabase>, { accountId, actorAccountId }: {
11
+ accountId: string;
12
+ actorAccountId?: string | null;
13
+ }): Promise<number>;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/account-session-revocation/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAG3F;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,EAAE,SAAS,EAAE,cAAqB,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC1F,OAAO,CAAC,MAAM,CAAC,CAejB"}
@@ -0,0 +1,25 @@
1
+ import { recordAuditEvent } from "@sharadox/account-web-library/audit-event";
2
+ /**
3
+ * Signs an account out on every browser at once: after a ban, a lost device, a recovery, or when its owner asks.
4
+ * Records who did it. Returns how many sessions ended.
5
+ *
6
+ * @example
7
+ * await revokeAccountSessions(database, { accountId, actorAccountId: moderatorId });
8
+ */
9
+ export async function revokeAccountSessions(database, { accountId, actorAccountId = null }) {
10
+ return database.transaction().execute(async (transaction) => {
11
+ const removed = await transaction
12
+ .deleteFrom("account_session")
13
+ .where("account_id", "=", accountId)
14
+ .returning("id")
15
+ .execute();
16
+ await recordAuditEvent(transaction, {
17
+ accountId,
18
+ actorAccountId,
19
+ action: "session.revoked",
20
+ detail: { sessions: removed.length },
21
+ });
22
+ return removed.length;
23
+ });
24
+ }
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/account-session-revocation/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,QAAiC,EACjC,EAAE,SAAS,EAAE,cAAc,GAAG,IAAI,EAAyD;IAE3F,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE;QAC1D,MAAM,OAAO,GAAG,MAAM,WAAW;aAC9B,UAAU,CAAC,iBAAiB,CAAC;aAC7B,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,SAAS,CAAC;aACnC,SAAS,CAAC,IAAI,CAAC;aACf,OAAO,EAAE,CAAC;QACb,MAAM,gBAAgB,CAAC,WAAW,EAAE;YAClC,SAAS;YACT,cAAc;YACd,MAAM,EAAE,iBAAiB;YACzB,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE;SACrC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,MAAM,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Kysely } from "kysely";
2
+ import type { AccountDatabase } from "@sharadox/account-web-library/account-database/type";
3
+ import type { SignInOptions, SignInResult } from "@sharadox/account-web-library/account-sign-in/type";
4
+ /**
5
+ * Signs an account in on a browser, after its code (and two-factor, when it has it) passed: the account joins the
6
+ * accounts already signed in there (the account selector has no limit), or a new browser session starts. The browser
7
+ * gets a new token every time, so a token planted before sign-in is worthless. Signing in again with the same account
8
+ * replaces its session there.
9
+ *
10
+ * @example
11
+ * const { token } = await signIn(database, { accountId, token: cookies.get("__Host-account")?.value });
12
+ * cookies.set("__Host-account", token, { httpOnly: true, secure: true, sameSite: "lax", path: "/" });
13
+ */
14
+ export declare function signIn(database: Kysely<AccountDatabase>, { accountId, token, secondFactor, userAgent, accountSessionSeconds, browserSessionSeconds, now, }: SignInOptions): Promise<SignInResult>;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/account-sign-in/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oDAAoD,CAAC;AAMtG;;;;;;;;;GASG;AACH,wBAAsB,MAAM,CAC1B,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,EACjC,EACE,SAAS,EACT,KAAK,EACL,YAAoB,EACpB,SAAgB,EAChB,qBAAgC,EAChC,qBAAiC,EACjC,GAAgB,GACjB,EAAE,aAAa,GACf,OAAO,CAAC,YAAY,CAAC,CA6DvB"}