@celljs/security 3.0.0

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 (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/cell.yml +36 -0
  4. package/lib/browser/index.d.ts +2 -0
  5. package/lib/browser/index.d.ts.map +1 -0
  6. package/lib/browser/index.js +18 -0
  7. package/lib/browser/index.js.map +1 -0
  8. package/lib/browser/module.d.ts +4 -0
  9. package/lib/browser/module.d.ts.map +1 -0
  10. package/lib/browser/module.js +6 -0
  11. package/lib/browser/module.js.map +1 -0
  12. package/lib/browser/user/index.d.ts +3 -0
  13. package/lib/browser/user/index.d.ts.map +1 -0
  14. package/lib/browser/user/index.js +19 -0
  15. package/lib/browser/user/index.js.map +1 -0
  16. package/lib/browser/user/user-manager.d.ts +23 -0
  17. package/lib/browser/user/user-manager.d.ts.map +1 -0
  18. package/lib/browser/user/user-manager.js +125 -0
  19. package/lib/browser/user/user-manager.js.map +1 -0
  20. package/lib/browser/user/user-protocol.d.ts +10 -0
  21. package/lib/browser/user/user-protocol.d.ts.map +1 -0
  22. package/lib/browser/user/user-protocol.js +5 -0
  23. package/lib/browser/user/user-protocol.js.map +1 -0
  24. package/lib/common/index.d.ts +2 -0
  25. package/lib/common/index.d.ts.map +1 -0
  26. package/lib/common/index.js +18 -0
  27. package/lib/common/index.js.map +1 -0
  28. package/lib/common/security-protocol.d.ts +60 -0
  29. package/lib/common/security-protocol.d.ts.map +1 -0
  30. package/lib/common/security-protocol.js +33 -0
  31. package/lib/common/security-protocol.js.map +1 -0
  32. package/lib/node/access/access-decision-manager.d.ts +9 -0
  33. package/lib/node/access/access-decision-manager.d.ts.map +1 -0
  34. package/lib/node/access/access-decision-manager.js +56 -0
  35. package/lib/node/access/access-decision-manager.js.map +1 -0
  36. package/lib/node/access/access-decision-utils.d.ts +5 -0
  37. package/lib/node/access/access-decision-utils.d.ts.map +1 -0
  38. package/lib/node/access/access-decision-utils.js +23 -0
  39. package/lib/node/access/access-decision-utils.js.map +1 -0
  40. package/lib/node/access/access-decision-voter.d.ts +14 -0
  41. package/lib/node/access/access-decision-voter.d.ts.map +1 -0
  42. package/lib/node/access/access-decision-voter.js +86 -0
  43. package/lib/node/access/access-decision-voter.js.map +1 -0
  44. package/lib/node/access/access-protocol.d.ts +75 -0
  45. package/lib/node/access/access-protocol.d.ts.map +1 -0
  46. package/lib/node/access/access-protocol.js +20 -0
  47. package/lib/node/access/access-protocol.js.map +1 -0
  48. package/lib/node/access/action-name-resolver.d.ts +5 -0
  49. package/lib/node/access/action-name-resolver.d.ts.map +1 -0
  50. package/lib/node/access/action-name-resolver.js +30 -0
  51. package/lib/node/access/action-name-resolver.js.map +1 -0
  52. package/lib/node/access/index.d.ts +12 -0
  53. package/lib/node/access/index.d.ts.map +1 -0
  54. package/lib/node/access/index.js +28 -0
  55. package/lib/node/access/index.js.map +1 -0
  56. package/lib/node/access/jexl-engine-provider.d.ts +6 -0
  57. package/lib/node/access/jexl-engine-provider.d.ts.map +1 -0
  58. package/lib/node/access/jexl-engine-provider.js +25 -0
  59. package/lib/node/access/jexl-engine-provider.js.map +1 -0
  60. package/lib/node/access/method-advice.d.ts +17 -0
  61. package/lib/node/access/method-advice.d.ts.map +1 -0
  62. package/lib/node/access/method-advice.js +81 -0
  63. package/lib/node/access/method-advice.js.map +1 -0
  64. package/lib/node/access/policy-provider.d.ts +17 -0
  65. package/lib/node/access/policy-provider.d.ts.map +1 -0
  66. package/lib/node/access/policy-provider.js +84 -0
  67. package/lib/node/access/policy-provider.js.map +1 -0
  68. package/lib/node/access/policy-resolver.d.ts +15 -0
  69. package/lib/node/access/policy-resolver.d.ts.map +1 -0
  70. package/lib/node/access/policy-resolver.js +91 -0
  71. package/lib/node/access/policy-resolver.js.map +1 -0
  72. package/lib/node/access/resource-name-resolver.d.ts +7 -0
  73. package/lib/node/access/resource-name-resolver.d.ts.map +1 -0
  74. package/lib/node/access/resource-name-resolver.js +57 -0
  75. package/lib/node/access/resource-name-resolver.js.map +1 -0
  76. package/lib/node/access/security-metadata-source.d.ts +7 -0
  77. package/lib/node/access/security-metadata-source.d.ts.map +1 -0
  78. package/lib/node/access/security-metadata-source.js +58 -0
  79. package/lib/node/access/security-metadata-source.js.map +1 -0
  80. package/lib/node/annotation/action.d.ts +2 -0
  81. package/lib/node/annotation/action.d.ts.map +1 -0
  82. package/lib/node/annotation/action.js +11 -0
  83. package/lib/node/annotation/action.js.map +1 -0
  84. package/lib/node/annotation/anonymous.d.ts +2 -0
  85. package/lib/node/annotation/anonymous.d.ts.map +1 -0
  86. package/lib/node/annotation/anonymous.js +10 -0
  87. package/lib/node/annotation/anonymous.js.map +1 -0
  88. package/lib/node/annotation/authenticated.d.ts +2 -0
  89. package/lib/node/annotation/authenticated.d.ts.map +1 -0
  90. package/lib/node/annotation/authenticated.js +10 -0
  91. package/lib/node/annotation/authenticated.js.map +1 -0
  92. package/lib/node/annotation/authorize.d.ts +11 -0
  93. package/lib/node/annotation/authorize.d.ts.map +1 -0
  94. package/lib/node/annotation/authorize.js +40 -0
  95. package/lib/node/annotation/authorize.js.map +1 -0
  96. package/lib/node/annotation/index.d.ts +8 -0
  97. package/lib/node/annotation/index.d.ts.map +1 -0
  98. package/lib/node/annotation/index.js +24 -0
  99. package/lib/node/annotation/index.js.map +1 -0
  100. package/lib/node/annotation/post-authorize.d.ts +2 -0
  101. package/lib/node/annotation/post-authorize.d.ts.map +1 -0
  102. package/lib/node/annotation/post-authorize.js +10 -0
  103. package/lib/node/annotation/post-authorize.js.map +1 -0
  104. package/lib/node/annotation/pre-authorize.d.ts +2 -0
  105. package/lib/node/annotation/pre-authorize.d.ts.map +1 -0
  106. package/lib/node/annotation/pre-authorize.js +10 -0
  107. package/lib/node/annotation/pre-authorize.js.map +1 -0
  108. package/lib/node/annotation/resource.d.ts +2 -0
  109. package/lib/node/annotation/resource.d.ts.map +1 -0
  110. package/lib/node/annotation/resource.js +16 -0
  111. package/lib/node/annotation/resource.js.map +1 -0
  112. package/lib/node/authentication/authentication-manager.d.ts +10 -0
  113. package/lib/node/authentication/authentication-manager.d.ts.map +1 -0
  114. package/lib/node/authentication/authentication-manager.js +81 -0
  115. package/lib/node/authentication/authentication-manager.js.map +1 -0
  116. package/lib/node/authentication/authentication-middleware.d.ts +8 -0
  117. package/lib/node/authentication/authentication-middleware.d.ts.map +1 -0
  118. package/lib/node/authentication/authentication-middleware.js +36 -0
  119. package/lib/node/authentication/authentication-middleware.js.map +1 -0
  120. package/lib/node/authentication/authentication-protocol.d.ts +30 -0
  121. package/lib/node/authentication/authentication-protocol.d.ts.map +1 -0
  122. package/lib/node/authentication/authentication-protocol.js +12 -0
  123. package/lib/node/authentication/authentication-protocol.js.map +1 -0
  124. package/lib/node/authentication/authentication-provider.d.ts +33 -0
  125. package/lib/node/authentication/authentication-provider.d.ts.map +1 -0
  126. package/lib/node/authentication/authentication-provider.js +174 -0
  127. package/lib/node/authentication/authentication-provider.js.map +1 -0
  128. package/lib/node/authentication/authentication-success-handler.d.ts +16 -0
  129. package/lib/node/authentication/authentication-success-handler.d.ts.map +1 -0
  130. package/lib/node/authentication/authentication-success-handler.js +97 -0
  131. package/lib/node/authentication/authentication-success-handler.js.map +1 -0
  132. package/lib/node/authentication/index.d.ts +6 -0
  133. package/lib/node/authentication/index.d.ts.map +1 -0
  134. package/lib/node/authentication/index.js +22 -0
  135. package/lib/node/authentication/index.js.map +1 -0
  136. package/lib/node/cache/cache-protocol.d.ts +16 -0
  137. package/lib/node/cache/cache-protocol.d.ts.map +1 -0
  138. package/lib/node/cache/cache-protocol.js +6 -0
  139. package/lib/node/cache/cache-protocol.js.map +1 -0
  140. package/lib/node/cache/index.d.ts +3 -0
  141. package/lib/node/cache/index.d.ts.map +1 -0
  142. package/lib/node/cache/index.js +19 -0
  143. package/lib/node/cache/index.js.map +1 -0
  144. package/lib/node/cache/request-cache.d.ts +10 -0
  145. package/lib/node/cache/request-cache.d.ts.map +1 -0
  146. package/lib/node/cache/request-cache.js +52 -0
  147. package/lib/node/cache/request-cache.js.map +1 -0
  148. package/lib/node/constants.d.ts +6 -0
  149. package/lib/node/constants.d.ts.map +1 -0
  150. package/lib/node/constants.js +9 -0
  151. package/lib/node/constants.js.map +1 -0
  152. package/lib/node/context/context-protocol.d.ts +22 -0
  153. package/lib/node/context/context-protocol.d.ts.map +1 -0
  154. package/lib/node/context/context-protocol.js +30 -0
  155. package/lib/node/context/context-protocol.js.map +1 -0
  156. package/lib/node/context/index.d.ts +5 -0
  157. package/lib/node/context/index.d.ts.map +1 -0
  158. package/lib/node/context/index.js +21 -0
  159. package/lib/node/context/index.js.map +1 -0
  160. package/lib/node/context/security-context-middleware.d.ts +9 -0
  161. package/lib/node/context/security-context-middleware.d.ts.map +1 -0
  162. package/lib/node/context/security-context-middleware.js +44 -0
  163. package/lib/node/context/security-context-middleware.js.map +1 -0
  164. package/lib/node/context/security-context-store.d.ts +8 -0
  165. package/lib/node/context/security-context-store.d.ts.map +1 -0
  166. package/lib/node/context/security-context-store.js +40 -0
  167. package/lib/node/context/security-context-store.js.map +1 -0
  168. package/lib/node/context/security-context-strategy.d.ts +9 -0
  169. package/lib/node/context/security-context-strategy.d.ts.map +1 -0
  170. package/lib/node/context/security-context-strategy.js +32 -0
  171. package/lib/node/context/security-context-strategy.js.map +1 -0
  172. package/lib/node/crypto/index.d.ts +3 -0
  173. package/lib/node/crypto/index.d.ts.map +1 -0
  174. package/lib/node/crypto/index.js +19 -0
  175. package/lib/node/crypto/index.js.map +1 -0
  176. package/lib/node/crypto/keygen/base64-string-key-generator.d.ts +6 -0
  177. package/lib/node/crypto/keygen/base64-string-key-generator.d.ts.map +1 -0
  178. package/lib/node/crypto/keygen/base64-string-key-generator.js +30 -0
  179. package/lib/node/crypto/keygen/base64-string-key-generator.js.map +1 -0
  180. package/lib/node/crypto/keygen/index.d.ts +3 -0
  181. package/lib/node/crypto/keygen/index.d.ts.map +1 -0
  182. package/lib/node/crypto/keygen/index.js +19 -0
  183. package/lib/node/crypto/keygen/index.js.map +1 -0
  184. package/lib/node/crypto/keygen/keygen-protocol.d.ts +5 -0
  185. package/lib/node/crypto/keygen/keygen-protocol.d.ts.map +1 -0
  186. package/lib/node/crypto/keygen/keygen-protocol.js +5 -0
  187. package/lib/node/crypto/keygen/keygen-protocol.js.map +1 -0
  188. package/lib/node/crypto/password/index.d.ts +3 -0
  189. package/lib/node/crypto/password/index.d.ts.map +1 -0
  190. package/lib/node/crypto/password/index.js +19 -0
  191. package/lib/node/crypto/password/index.js.map +1 -0
  192. package/lib/node/crypto/password/password-encoder.d.ts +9 -0
  193. package/lib/node/crypto/password/password-encoder.d.ts.map +1 -0
  194. package/lib/node/crypto/password/password-encoder.js +51 -0
  195. package/lib/node/crypto/password/password-encoder.js.map +1 -0
  196. package/lib/node/crypto/password/password-protocol.d.ts +6 -0
  197. package/lib/node/crypto/password/password-protocol.d.ts.map +1 -0
  198. package/lib/node/crypto/password/password-protocol.js +5 -0
  199. package/lib/node/crypto/password/password-protocol.js.map +1 -0
  200. package/lib/node/error/error-handler.d.ts +19 -0
  201. package/lib/node/error/error-handler.d.ts.map +1 -0
  202. package/lib/node/error/error-handler.js +81 -0
  203. package/lib/node/error/error-handler.js.map +1 -0
  204. package/lib/node/error/error-protocol.d.ts +3 -0
  205. package/lib/node/error/error-protocol.d.ts.map +1 -0
  206. package/lib/node/error/error-protocol.js +7 -0
  207. package/lib/node/error/error-protocol.js.map +1 -0
  208. package/lib/node/error/error.d.ts +21 -0
  209. package/lib/node/error/error.d.ts.map +1 -0
  210. package/lib/node/error/error.js +35 -0
  211. package/lib/node/error/error.js.map +1 -0
  212. package/lib/node/error/index.d.ts +4 -0
  213. package/lib/node/error/index.d.ts.map +1 -0
  214. package/lib/node/error/index.js +20 -0
  215. package/lib/node/error/index.js.map +1 -0
  216. package/lib/node/index.d.ts +11 -0
  217. package/lib/node/index.d.ts.map +1 -0
  218. package/lib/node/index.js +27 -0
  219. package/lib/node/index.js.map +1 -0
  220. package/lib/node/logout/index.d.ts +5 -0
  221. package/lib/node/logout/index.d.ts.map +1 -0
  222. package/lib/node/logout/index.js +21 -0
  223. package/lib/node/logout/index.js.map +1 -0
  224. package/lib/node/logout/logout-handler.d.ts +5 -0
  225. package/lib/node/logout/logout-handler.d.ts.map +1 -0
  226. package/lib/node/logout/logout-handler.js +22 -0
  227. package/lib/node/logout/logout-handler.js.map +1 -0
  228. package/lib/node/logout/logout-middleware.d.ts +16 -0
  229. package/lib/node/logout/logout-middleware.d.ts.map +1 -0
  230. package/lib/node/logout/logout-middleware.js +66 -0
  231. package/lib/node/logout/logout-middleware.js.map +1 -0
  232. package/lib/node/logout/logout-protocol.d.ts +12 -0
  233. package/lib/node/logout/logout-protocol.d.ts.map +1 -0
  234. package/lib/node/logout/logout-protocol.js +9 -0
  235. package/lib/node/logout/logout-protocol.js.map +1 -0
  236. package/lib/node/logout/logout-success-handler-provider.d.ts +8 -0
  237. package/lib/node/logout/logout-success-handler-provider.d.ts.map +1 -0
  238. package/lib/node/logout/logout-success-handler-provider.js +35 -0
  239. package/lib/node/logout/logout-success-handler-provider.js.map +1 -0
  240. package/lib/node/logout/logout-success-handler.d.ts +9 -0
  241. package/lib/node/logout/logout-success-handler.d.ts.map +1 -0
  242. package/lib/node/logout/logout-success-handler.js +39 -0
  243. package/lib/node/logout/logout-success-handler.js.map +1 -0
  244. package/lib/node/module.d.ts +5 -0
  245. package/lib/node/module.d.ts.map +1 -0
  246. package/lib/node/module.js +7 -0
  247. package/lib/node/module.js.map +1 -0
  248. package/lib/node/user/index.d.ts +6 -0
  249. package/lib/node/user/index.d.ts.map +1 -0
  250. package/lib/node/user/index.js +22 -0
  251. package/lib/node/user/index.js.map +1 -0
  252. package/lib/node/user/user-checker.d.ts +8 -0
  253. package/lib/node/user/user-checker.d.ts.map +1 -0
  254. package/lib/node/user/user-checker.js +44 -0
  255. package/lib/node/user/user-checker.js.map +1 -0
  256. package/lib/node/user/user-mapper.d.ts +9 -0
  257. package/lib/node/user/user-mapper.d.ts.map +1 -0
  258. package/lib/node/user/user-mapper.js +40 -0
  259. package/lib/node/user/user-mapper.js.map +1 -0
  260. package/lib/node/user/user-middleware.d.ts +11 -0
  261. package/lib/node/user/user-middleware.d.ts.map +1 -0
  262. package/lib/node/user/user-middleware.js +55 -0
  263. package/lib/node/user/user-middleware.js.map +1 -0
  264. package/lib/node/user/user-protocol.d.ts +15 -0
  265. package/lib/node/user/user-protocol.d.ts.map +1 -0
  266. package/lib/node/user/user-protocol.js +9 -0
  267. package/lib/node/user/user-protocol.js.map +1 -0
  268. package/lib/node/user/user-service.d.ts +7 -0
  269. package/lib/node/user/user-service.d.ts.map +1 -0
  270. package/lib/node/user/user-service.js +42 -0
  271. package/lib/node/user/user-service.js.map +1 -0
  272. package/lib/package.spec.d.ts +1 -0
  273. package/lib/package.spec.d.ts.map +1 -0
  274. package/lib/package.spec.js +4 -0
  275. package/lib/package.spec.js.map +1 -0
  276. package/package.json +53 -0
  277. package/src/browser/index.ts +1 -0
  278. package/src/browser/module.ts +4 -0
  279. package/src/browser/user/index.ts +2 -0
  280. package/src/browser/user/user-manager.ts +103 -0
  281. package/src/browser/user/user-protocol.ts +11 -0
  282. package/src/common/index.ts +1 -0
  283. package/src/common/security-protocol.ts +65 -0
  284. package/src/node/access/access-decision-manager.ts +43 -0
  285. package/src/node/access/access-decision-utils.ts +18 -0
  286. package/src/node/access/access-decision-voter.ts +73 -0
  287. package/src/node/access/access-protocol.ts +93 -0
  288. package/src/node/access/action-name-resolver.ts +19 -0
  289. package/src/node/access/index.ts +11 -0
  290. package/src/node/access/jexl-engine-provider.ts +18 -0
  291. package/src/node/access/method-advice.ts +64 -0
  292. package/src/node/access/policy-provider.ts +64 -0
  293. package/src/node/access/policy-resolver.ts +79 -0
  294. package/src/node/access/resource-name-resolver.ts +41 -0
  295. package/src/node/access/security-metadata-source.ts +47 -0
  296. package/src/node/annotation/action.ts +8 -0
  297. package/src/node/annotation/anonymous.ts +6 -0
  298. package/src/node/annotation/authenticated.ts +6 -0
  299. package/src/node/annotation/authorize.ts +39 -0
  300. package/src/node/annotation/index.ts +7 -0
  301. package/src/node/annotation/post-authorize.ts +6 -0
  302. package/src/node/annotation/pre-authorize.ts +6 -0
  303. package/src/node/annotation/resource.ts +12 -0
  304. package/src/node/authentication/authentication-manager.ts +61 -0
  305. package/src/node/authentication/authentication-middleware.ts +21 -0
  306. package/src/node/authentication/authentication-protocol.ts +37 -0
  307. package/src/node/authentication/authentication-provider.ts +155 -0
  308. package/src/node/authentication/authentication-success-handler.ts +83 -0
  309. package/src/node/authentication/index.ts +5 -0
  310. package/src/node/cache/cache-protocol.ts +17 -0
  311. package/src/node/cache/index.ts +2 -0
  312. package/src/node/cache/request-cache.ts +38 -0
  313. package/src/node/constants.ts +5 -0
  314. package/src/node/context/context-protocol.ts +43 -0
  315. package/src/node/context/index.ts +4 -0
  316. package/src/node/context/security-context-middleware.ts +28 -0
  317. package/src/node/context/security-context-store.ts +25 -0
  318. package/src/node/context/security-context-strategy.ts +24 -0
  319. package/src/node/crypto/index.ts +2 -0
  320. package/src/node/crypto/keygen/base64-string-key-generator.ts +15 -0
  321. package/src/node/crypto/keygen/index.ts +2 -0
  322. package/src/node/crypto/keygen/keygen-protocol.ts +7 -0
  323. package/src/node/crypto/password/index.ts +2 -0
  324. package/src/node/crypto/password/password-encoder.ts +39 -0
  325. package/src/node/crypto/password/password-protocol.ts +6 -0
  326. package/src/node/error/error-handler.ts +58 -0
  327. package/src/node/error/error-protocol.ts +5 -0
  328. package/src/node/error/error.ts +41 -0
  329. package/src/node/error/index.ts +3 -0
  330. package/src/node/index.ts +10 -0
  331. package/src/node/logout/index.ts +4 -0
  332. package/src/node/logout/logout-handler.ts +12 -0
  333. package/src/node/logout/logout-middleware.ts +49 -0
  334. package/src/node/logout/logout-protocol.ts +17 -0
  335. package/src/node/logout/logout-success-handler-provider.ts +21 -0
  336. package/src/node/logout/logout-success-handler.ts +22 -0
  337. package/src/node/module.ts +5 -0
  338. package/src/node/user/index.ts +6 -0
  339. package/src/node/user/user-checker.ts +37 -0
  340. package/src/node/user/user-mapper.ts +26 -0
  341. package/src/node/user/user-middleware.ts +40 -0
  342. package/src/node/user/user-protocol.ts +20 -0
  343. package/src/node/user/user-service.ts +28 -0
  344. package/src/package.spec.ts +4 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-middleware.d.ts","sourceRoot":"","sources":["../../../src/node/authentication/authentication-middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAkC,MAAM,2BAA2B,CAAC;AAElG,qBACa,wBAAyB,YAAW,UAAU;IAGvD,SAAS,CAAC,QAAQ,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;IAE1D,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAkC;CAE9D"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AuthenticationMiddleware = void 0;
13
+ const node_1 = require("@celljs/web/lib/node");
14
+ const core_1 = require("@celljs/core");
15
+ const authentication_protocol_1 = require("./authentication-protocol");
16
+ let AuthenticationMiddleware = class AuthenticationMiddleware {
17
+ constructor() {
18
+ this.priority = authentication_protocol_1.AUTHENTICATION_MIDDLE_PRIORITY;
19
+ }
20
+ async handle(ctx, next) {
21
+ if (await this.authenticationManager.support()) {
22
+ await this.authenticationManager.authenticate(next);
23
+ return;
24
+ }
25
+ await next();
26
+ }
27
+ };
28
+ __decorate([
29
+ (0, core_1.Autowired)(authentication_protocol_1.AuthenticationManager),
30
+ __metadata("design:type", Object)
31
+ ], AuthenticationMiddleware.prototype, "authenticationManager", void 0);
32
+ AuthenticationMiddleware = __decorate([
33
+ (0, core_1.Component)(node_1.Middleware)
34
+ ], AuthenticationMiddleware);
35
+ exports.AuthenticationMiddleware = AuthenticationMiddleware;
36
+ //# sourceMappingURL=authentication-middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-middleware.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA2D;AAC3D,uCAAoD;AACpD,uEAAkG;AAG3F,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAA9B;QAaM,aAAQ,GAAW,wDAA8B,CAAC;IAE/D,CAAC;IAVG,KAAK,CAAC,MAAM,CAAC,GAAY,EAAE,IAAyB;QAChD,IAAI,MAAM,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,EAAE;YAC5C,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACpD,OAAO;SACV;QACD,MAAM,IAAI,EAAE,CAAC;IACjB,CAAC;CAIJ,CAAA;AAbG;IAAC,IAAA,gBAAS,EAAC,+CAAqB,CAAC;;uEAC+B;AAHvD,wBAAwB;IADpC,IAAA,gBAAS,EAAC,iBAAU,CAAC;GACT,wBAAwB,CAepC;AAfY,4DAAwB"}
@@ -0,0 +1,30 @@
1
+ import { Policy } from '../../common';
2
+ export declare const AuthenticationProvider: unique symbol;
3
+ export declare const AuthenticationManager: unique symbol;
4
+ export declare const AuthenticationSuccessHandler: unique symbol;
5
+ export declare const AUTHENTICATION_SCHEME_BASIC = "Basic";
6
+ export declare const AUTHENTICATION_MIDDLE_PRIORITY: number;
7
+ export declare const USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY = 2000;
8
+ export declare const BASE_AUTHENTICATION_PROVIDER_PRIORITY: number;
9
+ export interface AuthenticationManager {
10
+ authenticate(next: () => Promise<void>): Promise<void>;
11
+ support(): Promise<boolean>;
12
+ }
13
+ export interface AuthenticationProvider {
14
+ readonly priority: number;
15
+ authenticate(): Promise<Authentication | undefined>;
16
+ support(): Promise<boolean>;
17
+ }
18
+ export interface Authentication {
19
+ name: string;
20
+ policies: Policy[];
21
+ credentials: any;
22
+ details?: any;
23
+ principal: any;
24
+ next?: boolean;
25
+ authenticated: boolean;
26
+ }
27
+ export interface AuthenticationSuccessHandler {
28
+ onAuthenticationSuccess(authentication: Authentication): Promise<void>;
29
+ }
30
+ //# sourceMappingURL=authentication-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/authentication/authentication-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,eAAO,MAAM,sBAAsB,eAAmC,CAAC;AACvE,eAAO,MAAM,qBAAqB,eAAkC,CAAC;AACrE,eAAO,MAAM,4BAA4B,eAAyC,CAAC;AACnF,eAAO,MAAM,2BAA2B,UAAU,CAAC;AAEnD,eAAO,MAAM,8BAA8B,QAA6C,CAAC;AAEzF,eAAO,MAAM,kDAAkD,OAAQ,CAAC;AACxE,eAAO,MAAM,qCAAqC,QAA4D,CAAC;AAE/G,MAAM,WAAW,qBAAqB;IAClC,YAAY,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,sBAAsB;IACnC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,YAAY,IAAI,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,CAAC;IACpD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,SAAS,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,4BAA4B;IACzC,uBAAuB,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1E"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASE_AUTHENTICATION_PROVIDER_PRIORITY = exports.USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY = exports.AUTHENTICATION_MIDDLE_PRIORITY = exports.AUTHENTICATION_SCHEME_BASIC = exports.AuthenticationSuccessHandler = exports.AuthenticationManager = exports.AuthenticationProvider = void 0;
4
+ const context_1 = require("../context");
5
+ exports.AuthenticationProvider = Symbol('AuthenticationProvider');
6
+ exports.AuthenticationManager = Symbol('AuthenticationManager');
7
+ exports.AuthenticationSuccessHandler = Symbol('AuthenticationSuccessHandler');
8
+ exports.AUTHENTICATION_SCHEME_BASIC = 'Basic';
9
+ exports.AUTHENTICATION_MIDDLE_PRIORITY = context_1.SECURITY_CONTEXT_MIDDLEWARE_PRIORITY - 100;
10
+ exports.USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY = 2000;
11
+ exports.BASE_AUTHENTICATION_PROVIDER_PRIORITY = exports.USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY - 100;
12
+ //# sourceMappingURL=authentication-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-protocol.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-protocol.ts"],"names":[],"mappings":";;;AACA,wCAAkE;AAErD,QAAA,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAC1D,QAAA,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AACxD,QAAA,4BAA4B,GAAG,MAAM,CAAC,8BAA8B,CAAC,CAAC;AACtE,QAAA,2BAA2B,GAAG,OAAO,CAAC;AAEtC,QAAA,8BAA8B,GAAG,8CAAoC,GAAG,GAAG,CAAC;AAE5E,QAAA,kDAAkD,GAAI,IAAI,CAAC;AAC3D,QAAA,qCAAqC,GAAI,0DAAkD,GAAG,GAAG,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { AuthenticationProvider, Authentication } from './authentication-protocol';
2
+ import { RequestMatcher, RedirectStrategy } from '@celljs/web/lib/node';
3
+ import { PasswordEncoder } from '../crypto';
4
+ import { UserService, UserChecker, UserMapper } from '../user';
5
+ import { PathResolver } from '@celljs/web';
6
+ import { User } from '../../common';
7
+ export declare class UsernamePasswordAuthenticationProvider implements AuthenticationProvider {
8
+ protected readonly options: any;
9
+ protected readonly passwordEncoder: PasswordEncoder;
10
+ protected readonly userService: UserService<string, User>;
11
+ protected readonly userChecker: UserChecker;
12
+ protected readonly userMapper: UserMapper;
13
+ protected readonly requestMatcher: RequestMatcher;
14
+ protected readonly pathResolver: PathResolver;
15
+ protected readonly redirectStrategy: RedirectStrategy;
16
+ priority: number;
17
+ authenticate(): Promise<Authentication | undefined>;
18
+ protected doGetValue(key: string): string;
19
+ support(): Promise<boolean>;
20
+ }
21
+ export declare class BasicAuthenticationProvider implements AuthenticationProvider {
22
+ protected readonly passwordEncoder: PasswordEncoder;
23
+ protected readonly userService: UserService<string, User>;
24
+ protected readonly userChecker: UserChecker;
25
+ protected readonly userMapper: UserMapper;
26
+ protected readonly requestMatcher: RequestMatcher;
27
+ protected readonly pathResolver: PathResolver;
28
+ protected readonly redirectStrategy: RedirectStrategy;
29
+ priority: number;
30
+ authenticate(): Promise<Authentication | undefined>;
31
+ support(): Promise<boolean>;
32
+ }
33
+ //# sourceMappingURL=authentication-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-provider.d.ts","sourceRoot":"","sources":["../../../src/node/authentication/authentication-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,cAAc,EACyB,MAAM,2BAA2B,CAAC;AAC1G,OAAO,EAAW,cAAc,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG/D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,qBACa,sCAAuC,YAAW,sBAAsB;IAGjF,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC;IAGhC,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAGpD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAG1D,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAG5C,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAG1C,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAGlD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAG9C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAEtD,QAAQ,SAAsD;IAExD,YAAY,IAAI,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAsBzD,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IASnC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;CAIpC;AAED,qBACa,2BAA4B,YAAW,sBAAsB;IAGtE,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAGpD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAG1D,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAG5C,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAG1C,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IAGlD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAG9C,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAEtD,QAAQ,SAAyC;IAE3C,YAAY,IAAI,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC;IAoCnD,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;CAapC"}
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BasicAuthenticationProvider = exports.UsernamePasswordAuthenticationProvider = void 0;
13
+ const core_1 = require("@celljs/core");
14
+ const authentication_protocol_1 = require("./authentication-protocol");
15
+ const node_1 = require("@celljs/web/lib/node");
16
+ const crypto_1 = require("../crypto");
17
+ const user_1 = require("../user");
18
+ const error_1 = require("../error");
19
+ const http_1 = require("@celljs/http");
20
+ const web_1 = require("@celljs/web");
21
+ let UsernamePasswordAuthenticationProvider = class UsernamePasswordAuthenticationProvider {
22
+ constructor() {
23
+ this.priority = authentication_protocol_1.USERNAME_PASSWORD_AUTHENTICATION_PROVIDER_PRIORITY;
24
+ }
25
+ async authenticate() {
26
+ const username = this.doGetValue(this.options.usernameKey);
27
+ const password = this.doGetValue(this.options.passwordKey);
28
+ if (!password || !username) {
29
+ throw new error_1.BadCredentialsError('Bad credentials');
30
+ }
31
+ const user = await this.userService.load(username);
32
+ await this.userChecker.check(user);
33
+ if (!await this.passwordEncoder.matches(password, user.password)) {
34
+ throw new error_1.BadCredentialsError('Bad credentials');
35
+ }
36
+ await this.userMapper.map(user);
37
+ return {
38
+ name: user.username,
39
+ principal: user,
40
+ credentials: '',
41
+ policies: user.policies,
42
+ authenticated: true
43
+ };
44
+ }
45
+ doGetValue(key) {
46
+ const request = node_1.Context.getRequest();
47
+ if (request.body) {
48
+ return request.body[key];
49
+ }
50
+ else {
51
+ return request.query[key];
52
+ }
53
+ }
54
+ async support() {
55
+ return !!await this.requestMatcher.match(await this.pathResolver.resolve(this.options.loginUrl), this.options.loginMethod);
56
+ }
57
+ };
58
+ __decorate([
59
+ (0, core_1.Value)('cell.security'),
60
+ __metadata("design:type", Object)
61
+ ], UsernamePasswordAuthenticationProvider.prototype, "options", void 0);
62
+ __decorate([
63
+ (0, core_1.Autowired)(crypto_1.PasswordEncoder),
64
+ __metadata("design:type", Object)
65
+ ], UsernamePasswordAuthenticationProvider.prototype, "passwordEncoder", void 0);
66
+ __decorate([
67
+ (0, core_1.Autowired)(user_1.UserService),
68
+ __metadata("design:type", Object)
69
+ ], UsernamePasswordAuthenticationProvider.prototype, "userService", void 0);
70
+ __decorate([
71
+ (0, core_1.Autowired)(user_1.UserChecker),
72
+ __metadata("design:type", Object)
73
+ ], UsernamePasswordAuthenticationProvider.prototype, "userChecker", void 0);
74
+ __decorate([
75
+ (0, core_1.Autowired)(user_1.UserMapper),
76
+ __metadata("design:type", Object)
77
+ ], UsernamePasswordAuthenticationProvider.prototype, "userMapper", void 0);
78
+ __decorate([
79
+ (0, core_1.Autowired)(node_1.RequestMatcher),
80
+ __metadata("design:type", Object)
81
+ ], UsernamePasswordAuthenticationProvider.prototype, "requestMatcher", void 0);
82
+ __decorate([
83
+ (0, core_1.Autowired)(web_1.PathResolver),
84
+ __metadata("design:type", Object)
85
+ ], UsernamePasswordAuthenticationProvider.prototype, "pathResolver", void 0);
86
+ __decorate([
87
+ (0, core_1.Autowired)(node_1.RedirectStrategy),
88
+ __metadata("design:type", Object)
89
+ ], UsernamePasswordAuthenticationProvider.prototype, "redirectStrategy", void 0);
90
+ UsernamePasswordAuthenticationProvider = __decorate([
91
+ (0, core_1.Component)(authentication_protocol_1.AuthenticationProvider)
92
+ ], UsernamePasswordAuthenticationProvider);
93
+ exports.UsernamePasswordAuthenticationProvider = UsernamePasswordAuthenticationProvider;
94
+ let BasicAuthenticationProvider = class BasicAuthenticationProvider {
95
+ constructor() {
96
+ this.priority = authentication_protocol_1.BASE_AUTHENTICATION_PROVIDER_PRIORITY;
97
+ }
98
+ async authenticate() {
99
+ const request = node_1.Context.getRequest();
100
+ const header = request.get(http_1.HttpHeaders.AUTHORIZATION).trim();
101
+ const token = Buffer.from(header.substring(6), 'base64').toString('utf8');
102
+ if (!token) {
103
+ throw new error_1.BadCredentialsError('Empty basic authentication token');
104
+ }
105
+ const delim = token.indexOf(':');
106
+ if (delim === -1) {
107
+ throw new error_1.BadCredentialsError('Invalid basic authentication token');
108
+ }
109
+ const username = token.substring(0, delim);
110
+ const password = token.substring(delim);
111
+ if (!password || !username) {
112
+ throw new error_1.BadCredentialsError('Bad credentials');
113
+ }
114
+ const user = await this.userService.load(username);
115
+ await this.userChecker.check(user);
116
+ if (!await this.passwordEncoder.matches(password, user.password)) {
117
+ throw new error_1.BadCredentialsError('Bad credentials');
118
+ }
119
+ await this.userMapper.map(user);
120
+ return {
121
+ name: user.username,
122
+ principal: user,
123
+ credentials: '',
124
+ policies: user.policies,
125
+ authenticated: true,
126
+ next: true
127
+ };
128
+ }
129
+ async support() {
130
+ const request = node_1.Context.getRequest();
131
+ let header = request.get(http_1.HttpHeaders.AUTHORIZATION);
132
+ if (!header) {
133
+ return false;
134
+ }
135
+ header = header.trim();
136
+ if (header.toLowerCase().startsWith(authentication_protocol_1.AUTHENTICATION_SCHEME_BASIC.toLowerCase())) {
137
+ return true;
138
+ }
139
+ return false;
140
+ }
141
+ };
142
+ __decorate([
143
+ (0, core_1.Autowired)(crypto_1.PasswordEncoder),
144
+ __metadata("design:type", Object)
145
+ ], BasicAuthenticationProvider.prototype, "passwordEncoder", void 0);
146
+ __decorate([
147
+ (0, core_1.Autowired)(user_1.UserService),
148
+ __metadata("design:type", Object)
149
+ ], BasicAuthenticationProvider.prototype, "userService", void 0);
150
+ __decorate([
151
+ (0, core_1.Autowired)(user_1.UserChecker),
152
+ __metadata("design:type", Object)
153
+ ], BasicAuthenticationProvider.prototype, "userChecker", void 0);
154
+ __decorate([
155
+ (0, core_1.Autowired)(user_1.UserMapper),
156
+ __metadata("design:type", Object)
157
+ ], BasicAuthenticationProvider.prototype, "userMapper", void 0);
158
+ __decorate([
159
+ (0, core_1.Autowired)(node_1.RequestMatcher),
160
+ __metadata("design:type", Object)
161
+ ], BasicAuthenticationProvider.prototype, "requestMatcher", void 0);
162
+ __decorate([
163
+ (0, core_1.Autowired)(web_1.PathResolver),
164
+ __metadata("design:type", Object)
165
+ ], BasicAuthenticationProvider.prototype, "pathResolver", void 0);
166
+ __decorate([
167
+ (0, core_1.Autowired)(node_1.RedirectStrategy),
168
+ __metadata("design:type", Object)
169
+ ], BasicAuthenticationProvider.prototype, "redirectStrategy", void 0);
170
+ BasicAuthenticationProvider = __decorate([
171
+ (0, core_1.Component)(authentication_protocol_1.AuthenticationProvider)
172
+ ], BasicAuthenticationProvider);
173
+ exports.BasicAuthenticationProvider = BasicAuthenticationProvider;
174
+ //# sourceMappingURL=authentication-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-provider.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-provider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAA2D;AAC3D,uEAC0G;AAC1G,+CAAiF;AACjF,sCAA4C;AAC5C,kCAA+D;AAC/D,oCAA+C;AAC/C,uCAA2C;AAC3C,qCAA2C;AAKpC,IAAM,sCAAsC,GAA5C,MAAM,sCAAsC;IAA5C;QA0BH,aAAQ,GAAG,4EAAkD,CAAC;IAqClE,CAAC;IAnCG,KAAK,CAAC,YAAY;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC3D,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,EAAE;YACxB,MAAM,IAAI,2BAAmB,CAAC,iBAAiB,CAAC,CAAC;SACpD;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACnD,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,EAAE;YAC9D,MA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ACrB,2BAA2B,CA0EvC;AA1EY,kEAA2B"}
@@ -0,0 +1,16 @@
1
+ import { AuthenticationSuccessHandler, Authentication } from './authentication-protocol';
2
+ import { Logger } from '@celljs/core';
3
+ import { RedirectStrategy } from '@celljs/web/lib/node';
4
+ import { RequestCache } from '../cache';
5
+ export declare class DefaultAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
6
+ protected readonly targetUrlParameter: string;
7
+ protected readonly loginSuccessUrl: string;
8
+ protected readonly alwaysUseLoginSuccessUrl: boolean;
9
+ protected readonly useReferer: boolean;
10
+ protected readonly logger: Logger;
11
+ protected readonly redirectStrategy: RedirectStrategy;
12
+ protected readonly requestCache: RequestCache;
13
+ onAuthenticationSuccess(authentication: Authentication): Promise<void>;
14
+ protected determineTargetUrl(authentication: Authentication): Promise<string>;
15
+ }
16
+ //# sourceMappingURL=authentication-success-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-success-handler.d.ts","sourceRoot":"","sources":["../../../src/node/authentication/authentication-success-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACzF,OAAO,EAA+B,MAAM,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAW,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,qBACa,mCAAoC,YAAW,4BAA4B;IAGpF,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAG9C,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAG3C,SAAS,CAAC,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAC;IAGrD,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAGvC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAGlC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAGtD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAExC,uBAAuB,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;cAgB5D,kBAAkB,CAAC,cAAc,EAAE,cAAc;CAoCpE"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DefaultAuthenticationSuccessHandler = void 0;
13
+ const authentication_protocol_1 = require("./authentication-protocol");
14
+ const core_1 = require("@celljs/core");
15
+ const node_1 = require("@celljs/web/lib/node");
16
+ const http_1 = require("@celljs/http");
17
+ const cache_1 = require("../cache");
18
+ let DefaultAuthenticationSuccessHandler = class DefaultAuthenticationSuccessHandler {
19
+ async onAuthenticationSuccess(authentication) {
20
+ const response = node_1.Context.getResponse();
21
+ if (node_1.Context.getRequest().get(http_1.HttpHeaders.X_REQUESTED_WITH) === http_1.XML_HTTP_REQUEST) {
22
+ return;
23
+ }
24
+ if (!this.loginSuccessUrl) {
25
+ return;
26
+ }
27
+ const targetUrl = await this.determineTargetUrl(authentication);
28
+ if (response.writableEnded) {
29
+ this.logger.debug(`Response has already been committed. Unable to redirect to ${targetUrl}`);
30
+ return;
31
+ }
32
+ await this.redirectStrategy.send(targetUrl);
33
+ }
34
+ async determineTargetUrl(authentication) {
35
+ if (this.alwaysUseLoginSuccessUrl) {
36
+ return this.loginSuccessUrl;
37
+ }
38
+ let targetUrl;
39
+ const request = node_1.Context.getRequest();
40
+ if (this.targetUrlParameter) {
41
+ targetUrl = request.query[this.targetUrlParameter];
42
+ if (targetUrl) {
43
+ this.logger.debug(`Found targetUrlParameter in request: ${targetUrl}`);
44
+ return targetUrl;
45
+ }
46
+ }
47
+ if (this.useReferer) {
48
+ const referer = request.get(http_1.HttpHeaders.REFERER);
49
+ targetUrl = (referer === null || referer === void 0 ? void 0 : referer.length) ? referer[0] : '';
50
+ this.logger.debug(`Using Referer header: ${targetUrl}`);
51
+ }
52
+ const savedRequest = await this.requestCache.get();
53
+ if (savedRequest) {
54
+ await this.requestCache.remove();
55
+ targetUrl = savedRequest.redirectUrl;
56
+ this.logger.debug(`Redirecting to SavedRequest Url: ${targetUrl}`);
57
+ }
58
+ if (!targetUrl) {
59
+ targetUrl = this.loginSuccessUrl;
60
+ this.logger.debug(`Using default Url: ${targetUrl}`);
61
+ }
62
+ return targetUrl;
63
+ }
64
+ };
65
+ __decorate([
66
+ (0, core_1.Value)('cell.security.targetUrlParameter'),
67
+ __metadata("design:type", String)
68
+ ], DefaultAuthenticationSuccessHandler.prototype, "targetUrlParameter", void 0);
69
+ __decorate([
70
+ (0, core_1.Value)('cell.security.loginSuccessUrl'),
71
+ __metadata("design:type", String)
72
+ ], DefaultAuthenticationSuccessHandler.prototype, "loginSuccessUrl", void 0);
73
+ __decorate([
74
+ (0, core_1.Value)('cell.security.alwaysUseLoginSuccessUrl'),
75
+ __metadata("design:type", Boolean)
76
+ ], DefaultAuthenticationSuccessHandler.prototype, "alwaysUseLoginSuccessUrl", void 0);
77
+ __decorate([
78
+ (0, core_1.Value)('cell.security.useReferer'),
79
+ __metadata("design:type", Boolean)
80
+ ], DefaultAuthenticationSuccessHandler.prototype, "useReferer", void 0);
81
+ __decorate([
82
+ (0, core_1.Autowired)(core_1.Logger),
83
+ __metadata("design:type", Object)
84
+ ], DefaultAuthenticationSuccessHandler.prototype, "logger", void 0);
85
+ __decorate([
86
+ (0, core_1.Autowired)(node_1.RedirectStrategy),
87
+ __metadata("design:type", Object)
88
+ ], DefaultAuthenticationSuccessHandler.prototype, "redirectStrategy", void 0);
89
+ __decorate([
90
+ (0, core_1.Autowired)(cache_1.RequestCache),
91
+ __metadata("design:type", Object)
92
+ ], DefaultAuthenticationSuccessHandler.prototype, "requestCache", void 0);
93
+ DefaultAuthenticationSuccessHandler = __decorate([
94
+ (0, core_1.Component)(authentication_protocol_1.AuthenticationSuccessHandler)
95
+ ], DefaultAuthenticationSuccessHandler);
96
+ exports.DefaultAuthenticationSuccessHandler = DefaultAuthenticationSuccessHandler;
97
+ //# sourceMappingURL=authentication-success-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-success-handler.js","sourceRoot":"","sources":["../../../src/node/authentication/authentication-success-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAAyF;AACzF,uCAAmE;AACnE,+CAAiE;AACjE,uCAA6D;AAC7D,oCAAwC;AAGjC,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IAuB5C,KAAK,CAAC,uBAAuB,CAAC,cAA8B;QACxD,MAAM,QAAQ,GAAG,cAAO,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,cAAO,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,kBAAW,CAAC,gBAAgB,CAAC,KAAK,uBAAgB,EAAE;YAC7E,OAAO;SACV;QACD,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;YACvB,OAAO;SACV;QACD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;QAChE,IAAI,QAAQ,CAAC,aAAa,EAAE;YACxB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8DAA8D,SAAS,EAAE,CAAC,CAAC;YAC7F,OAAO;SACV;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AAM,CAAC,KAAK,CAAC,sBAAsB,SAAS,EAAE,CAAC,CAAC;SACxD;QAED,OAAO,SAAS,CAAC;IACrB,CAAC;CAEJ,CAAA;AAzEG;IAAC,IAAA,YAAK,EAAC,kCAAkC,CAAC;;+EACI;AAE9C;IAAC,IAAA,YAAK,EAAC,+BAA+B,CAAC;;4EACI;AAE3C;IAAC,IAAA,YAAK,EAAC,wCAAwC,CAAC;;qFACK;AAErD;IAAC,IAAA,YAAK,EAAC,0BAA0B,CAAC;;uEACK;AAEvC;IAAC,IAAA,gBAAS,EAAC,aAAM,CAAC;;mEACgB;AAElC;IAAC,IAAA,gBAAS,EAAC,uBAAgB,CAAC;;6EAC0B;AAEtD;IAAC,IAAA,gBAAS,EAAC,oBAAY,CAAC;;yEACsB;AArBrC,mCAAmC;IAD/C,IAAA,gBAAS,EAAC,sDAA4B,CAAC;GAC3B,mCAAmC,CA2E/C;AA3EY,kFAAmC"}
@@ -0,0 +1,6 @@
1
+ export * from './authentication-protocol';
2
+ export * from './authentication-manager';
3
+ export * from './authentication-provider';
4
+ export * from './authentication-middleware';
5
+ export * from './authentication-success-handler';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/authentication/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./authentication-protocol"), exports);
18
+ __exportStar(require("./authentication-manager"), exports);
19
+ __exportStar(require("./authentication-provider"), exports);
20
+ __exportStar(require("./authentication-middleware"), exports);
21
+ __exportStar(require("./authentication-success-handler"), exports);
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/authentication/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA0C;AAC1C,2DAAyC;AACzC,4DAA0C;AAC1C,8DAA4C;AAC5C,mEAAiD"}
@@ -0,0 +1,16 @@
1
+ import { HttpMethod } from '@celljs/http';
2
+ export declare const RequestCache: unique symbol;
3
+ export declare const SAVED_REQUEST = "MALAGU_SECURITY_SAVED_REQUEST";
4
+ export interface SavedRequest {
5
+ redirectUrl: string;
6
+ method: HttpMethod;
7
+ query: {
8
+ [key: string]: string;
9
+ };
10
+ }
11
+ export interface RequestCache {
12
+ save(savedRequest?: SavedRequest): Promise<void>;
13
+ get(): Promise<SavedRequest | undefined>;
14
+ remove(): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=cache-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/cache/cache-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,eAAO,MAAM,YAAY,eAAyB,CAAC;AACnD,eAAO,MAAM,aAAa,kCAAkC,CAAC;AAE7D,MAAM,WAAW,YAAY;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,GAAG,IAAI,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC;IACzC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAE3B"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SAVED_REQUEST = exports.RequestCache = void 0;
4
+ exports.RequestCache = Symbol('RequestCache');
5
+ exports.SAVED_REQUEST = 'MALAGU_SECURITY_SAVED_REQUEST';
6
+ //# sourceMappingURL=cache-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-protocol.js","sourceRoot":"","sources":["../../../src/node/cache/cache-protocol.ts"],"names":[],"mappings":";;;AAEa,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AACtC,QAAA,aAAa,GAAG,+BAA+B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './cache-protocol';
2
+ export * from './request-cache';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/cache/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./cache-protocol"), exports);
18
+ __exportStar(require("./request-cache"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/node/cache/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,kDAAgC"}
@@ -0,0 +1,10 @@
1
+ import { RequestCache, SavedRequest } from './cache-protocol';
2
+ import { PathResolver } from '@celljs/web';
3
+ export declare class HttpSessionRequestCache implements RequestCache {
4
+ protected readonly endpoint: string;
5
+ protected readonly pathResolver: PathResolver;
6
+ save(savedRequest?: SavedRequest): Promise<void>;
7
+ get(): Promise<SavedRequest | undefined>;
8
+ remove(): Promise<void>;
9
+ }
10
+ //# sourceMappingURL=request-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-cache.d.ts","sourceRoot":"","sources":["../../../src/node/cache/request-cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAiB,MAAM,kBAAkB,CAAC;AAG7E,OAAO,EAAY,YAAY,EAAE,MAAM,aAAa,CAAC;AAGrD,qBACa,uBAAwB,YAAW,YAAY;IAGxD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAGpC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAExC,IAAI,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAUhD,GAAG,IAAI,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAMxC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;CAMhC"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.HttpSessionRequestCache = void 0;
13
+ const cache_protocol_1 = require("./cache-protocol");
14
+ const node_1 = require("@celljs/web/lib/node");
15
+ const core_1 = require("@celljs/core");
16
+ const web_1 = require("@celljs/web");
17
+ const qs = require("qs");
18
+ let HttpSessionRequestCache = class HttpSessionRequestCache {
19
+ async save(savedRequest) {
20
+ if (node_1.Context.getSession()) {
21
+ const request = node_1.Context.getRequest();
22
+ node_1.Context.setAttr(cache_protocol_1.SAVED_REQUEST, savedRequest || {
23
+ redirectUrl: await this.pathResolver.resolve(this.endpoint, request.path, qs.stringify(request.query)),
24
+ method: request.method.toUpperCase(),
25
+ query: Object.assign({}, request.query)
26
+ }, node_1.AttributeScope.Session);
27
+ }
28
+ }
29
+ async get() {
30
+ if (node_1.Context.getSession()) {
31
+ return node_1.Context.getAttr(cache_protocol_1.SAVED_REQUEST, node_1.AttributeScope.Session);
32
+ }
33
+ }
34
+ async remove() {
35
+ if (node_1.Context.getSession()) {
36
+ node_1.Context.setAttr(cache_protocol_1.SAVED_REQUEST, undefined, node_1.AttributeScope.Session);
37
+ }
38
+ }
39
+ };
40
+ __decorate([
41
+ (0, core_1.Value)(web_1.ENDPOINT),
42
+ __metadata("design:type", String)
43
+ ], HttpSessionRequestCache.prototype, "endpoint", void 0);
44
+ __decorate([
45
+ (0, core_1.Autowired)(web_1.PathResolver),
46
+ __metadata("design:type", Object)
47
+ ], HttpSessionRequestCache.prototype, "pathResolver", void 0);
48
+ HttpSessionRequestCache = __decorate([
49
+ (0, core_1.Component)(cache_protocol_1.RequestCache)
50
+ ], HttpSessionRequestCache);
51
+ exports.HttpSessionRequestCache = HttpSessionRequestCache;
52
+ //# sourceMappingURL=request-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-cache.js","sourceRoot":"","sources":["../../../src/node/cache/request-cache.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA6E;AAC7E,+CAA+D;AAC/D,uCAA2D;AAC3D,qCAAqD;AACrD,yBAAyB;AAGlB,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAQhC,KAAK,CAAC,IAAI,CAAC,YAA2B;QAClC,IAAI,cAAO,CAAC,UAAU,EAAE,EAAE;YACtB,MAAM,OAAO,GAAG,cAAO,CAAC,UAAU,EAAE,CAAC;YACrC,cAAO,CAAC,OAAO,CAAC,8BAAa,EAAE,YAAY,IAAI;gBAC3C,WAAW,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBACtG,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE;gBACpC,KAAK,oBAAO,OAAO,CAAC,KAAK,CAAE;aAC9B,EAAE,qBAAc,CAAC,OAAO,CAAC,CAAC;SAC9B;IACL,CAAC;IACD,KAAK,CAAC,GAAG;QACL,IAAI,cAAO,CAAC,UAAU,EAAE,EAAE;YACtB,OAAO,cAAO,CAAC,OAAO,CAAe,8BAAa,EAAE,qBAAc,CAAC,OAAO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