@daffodil/auth 0.66.1 → 0.67.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 (237) hide show
  1. package/{esm2020 → esm2022}/driver/in-memory/backend/auth.service.mjs +4 -4
  2. package/{esm2020 → esm2022}/driver/in-memory/drivers/auth/auth.service.mjs +5 -5
  3. package/{esm2020 → esm2022}/driver/in-memory/drivers/auth-driver.module.mjs +5 -5
  4. package/{esm2020 → esm2022}/driver/in-memory/drivers/login/login.service.mjs +5 -5
  5. package/{esm2020 → esm2022}/driver/in-memory/drivers/register/register.service.mjs +5 -5
  6. package/{esm2020 → esm2022}/driver/in-memory/drivers/reset-password/service.mjs +5 -5
  7. package/{esm2020 → esm2022}/driver/magento/apollo-bearer-token-link-generator.mjs +5 -5
  8. package/{esm2020 → esm2022}/driver/magento/auth-driver.module.mjs +5 -5
  9. package/{esm2020 → esm2022}/driver/magento/auth.service.mjs +5 -5
  10. package/{esm2020 → esm2022}/driver/magento/login.service.mjs +5 -5
  11. package/{esm2020 → esm2022}/driver/magento/register.service.mjs +5 -5
  12. package/{esm2020 → esm2022}/driver/magento/reset-password.service.mjs +5 -5
  13. package/{esm2020 → esm2022}/driver/magento/transforms/auth-transformer.service.mjs +4 -4
  14. package/{esm2020 → esm2022}/driver/services/auth-check.service.mjs +6 -6
  15. package/{esm2020 → esm2022}/driver/testing/drivers/auth/auth.service.mjs +4 -4
  16. package/{esm2020 → esm2022}/driver/testing/drivers/auth-driver.module.mjs +5 -5
  17. package/{esm2020 → esm2022}/driver/testing/drivers/login/login.service.mjs +5 -5
  18. package/{esm2020 → esm2022}/driver/testing/drivers/register/register.service.mjs +5 -5
  19. package/{esm2020 → esm2022}/driver/testing/drivers/reset-password/service.mjs +5 -5
  20. package/{esm2020 → esm2022}/routing/effects/redirect.effects.mjs +6 -6
  21. package/{esm2020 → esm2022}/routing/guards/guest-only.guard.mjs +7 -7
  22. package/{esm2020 → esm2022}/routing/guards/member-only.guard.mjs +7 -7
  23. package/{esm2020 → esm2022}/routing/guards/reset-password.guard.mjs +6 -6
  24. package/{esm2020 → esm2022}/routing/module.mjs +9 -9
  25. package/esm2022/routing/redirect.module.mjs +40 -0
  26. package/esm2022/state/auth-state.module.mjs +88 -0
  27. package/{esm2020 → esm2022}/state/effects/auth.effects.mjs +6 -6
  28. package/{esm2020 → esm2022}/state/effects/login.effects.mjs +6 -6
  29. package/{esm2020 → esm2022}/state/effects/register.effects.mjs +6 -6
  30. package/{esm2020 → esm2022}/state/effects/reset-password.effects.mjs +6 -6
  31. package/{esm2020 → esm2022}/state/facades/auth/facade.mjs +5 -5
  32. package/{esm2020 → esm2022}/state/facades/login/facade.mjs +5 -5
  33. package/{esm2020 → esm2022}/state/facades/register/facade.mjs +5 -5
  34. package/{esm2020 → esm2022}/state/facades/reset-password/facade.mjs +5 -5
  35. package/{esm2020 → esm2022}/state/testing/auth-testing.module.mjs +10 -10
  36. package/{esm2020 → esm2022}/state/testing/mock-auth-facade.mjs +4 -4
  37. package/{esm2020 → esm2022}/state/testing/mock-login-facade.mjs +4 -4
  38. package/{esm2020 → esm2022}/state/testing/mock-register-facade.mjs +4 -4
  39. package/{esm2020 → esm2022}/state/testing/mock-reset-password-facade.mjs +4 -4
  40. package/{esm2020 → esm2022}/storage/auth-storage.service.mjs +6 -6
  41. package/{esm2020 → esm2022}/testing/factories/account-registration.factory.mjs +5 -5
  42. package/{esm2020 → esm2022}/testing/factories/auth-token.factory.mjs +5 -5
  43. package/{esm2020 → esm2022}/testing/factories/reset-password-info.factory.mjs +5 -5
  44. package/{fesm2020 → fesm2022}/daffodil-auth-driver-in-memory.mjs +23 -23
  45. package/{fesm2020 → fesm2022}/daffodil-auth-driver-in-memory.mjs.map +1 -1
  46. package/{fesm2020 → fesm2022}/daffodil-auth-driver-magento.mjs +27 -27
  47. package/{fesm2020 → fesm2022}/daffodil-auth-driver-magento.mjs.map +1 -1
  48. package/{fesm2020 → fesm2022}/daffodil-auth-driver-testing.mjs +19 -19
  49. package/{fesm2020 → fesm2022}/daffodil-auth-driver-testing.mjs.map +1 -1
  50. package/{fesm2020 → fesm2022}/daffodil-auth-driver.mjs +5 -5
  51. package/{fesm2020 → fesm2022}/daffodil-auth-driver.mjs.map +1 -1
  52. package/{fesm2020 → fesm2022}/daffodil-auth-routing.mjs +40 -40
  53. package/fesm2022/daffodil-auth-routing.mjs.map +1 -0
  54. package/fesm2022/daffodil-auth-state-testing.mjs +107 -0
  55. package/{fesm2020 → fesm2022}/daffodil-auth-state-testing.mjs.map +1 -1
  56. package/{fesm2020 → fesm2022}/daffodil-auth-state.mjs +64 -64
  57. package/{fesm2020 → fesm2022}/daffodil-auth-state.mjs.map +1 -1
  58. package/{fesm2020 → fesm2022}/daffodil-auth-testing.mjs +12 -12
  59. package/{fesm2020 → fesm2022}/daffodil-auth-testing.mjs.map +1 -1
  60. package/{fesm2020 → fesm2022}/daffodil-auth.mjs +5 -5
  61. package/{fesm2020 → fesm2022}/daffodil-auth.mjs.map +1 -1
  62. package/package.json +1 -1
  63. package/routing/guards/guest-only.guard.d.ts +2 -2
  64. package/routing/guards/member-only.guard.d.ts +2 -2
  65. package/routing/guards/reset-password.guard.d.ts +2 -2
  66. package/state/actions/auth.actions.d.ts +1 -1
  67. package/state/actions/login.actions.d.ts +1 -1
  68. package/state/actions/register.actions.d.ts +1 -1
  69. package/state/actions/reset-password.actions.d.ts +1 -1
  70. package/state/injection-tokens/unauthenticated/hook.type.d.ts +1 -1
  71. package/state/reducers/login/login-reducer-state.interface.d.ts +1 -1
  72. package/state/reducers/register/register-reducer-state.interface.d.ts +1 -1
  73. package/esm2020/routing/redirect.module.mjs +0 -40
  74. package/esm2020/state/auth-state.module.mjs +0 -88
  75. package/fesm2015/daffodil-auth-driver-in-memory.mjs +0 -256
  76. package/fesm2015/daffodil-auth-driver-in-memory.mjs.map +0 -1
  77. package/fesm2015/daffodil-auth-driver-magento.mjs +0 -372
  78. package/fesm2015/daffodil-auth-driver-magento.mjs.map +0 -1
  79. package/fesm2015/daffodil-auth-driver-testing.mjs +0 -139
  80. package/fesm2015/daffodil-auth-driver-testing.mjs.map +0 -1
  81. package/fesm2015/daffodil-auth-driver.mjs +0 -119
  82. package/fesm2015/daffodil-auth-driver.mjs.map +0 -1
  83. package/fesm2015/daffodil-auth-routing.mjs +0 -262
  84. package/fesm2015/daffodil-auth-routing.mjs.map +0 -1
  85. package/fesm2015/daffodil-auth-state-testing.mjs +0 -107
  86. package/fesm2015/daffodil-auth-state-testing.mjs.map +0 -1
  87. package/fesm2015/daffodil-auth-state.mjs +0 -853
  88. package/fesm2015/daffodil-auth-state.mjs.map +0 -1
  89. package/fesm2015/daffodil-auth-testing.mjs +0 -77
  90. package/fesm2015/daffodil-auth-testing.mjs.map +0 -1
  91. package/fesm2015/daffodil-auth.mjs +0 -63
  92. package/fesm2015/daffodil-auth.mjs.map +0 -1
  93. package/fesm2020/daffodil-auth-routing.mjs.map +0 -1
  94. package/fesm2020/daffodil-auth-state-testing.mjs +0 -107
  95. /package/{esm2020 → esm2022}/daffodil-auth.mjs +0 -0
  96. /package/{esm2020 → esm2022}/driver/constants/public_api.mjs +0 -0
  97. /package/{esm2020 → esm2022}/driver/constants/unauthenticated-error-codes.mjs +0 -0
  98. /package/{esm2020 → esm2022}/driver/daffodil-auth-driver.mjs +0 -0
  99. /package/{esm2020 → esm2022}/driver/errors/authentication-failed.mjs +0 -0
  100. /package/{esm2020 → esm2022}/driver/errors/codes.enum.mjs +0 -0
  101. /package/{esm2020 → esm2022}/driver/errors/invalid-api-response.mjs +0 -0
  102. /package/{esm2020 → esm2022}/driver/errors/map.mjs +0 -0
  103. /package/{esm2020 → esm2022}/driver/errors/public_api.mjs +0 -0
  104. /package/{esm2020 → esm2022}/driver/errors/registration-failed.mjs +0 -0
  105. /package/{esm2020 → esm2022}/driver/errors/unauthorized.mjs +0 -0
  106. /package/{esm2020 → esm2022}/driver/in-memory/daffodil-auth-driver-in-memory.mjs +0 -0
  107. /package/{esm2020 → esm2022}/driver/in-memory/drivers/public_api.mjs +0 -0
  108. /package/{esm2020 → esm2022}/driver/in-memory/index.mjs +0 -0
  109. /package/{esm2020 → esm2022}/driver/in-memory/models/db-customer.type.mjs +0 -0
  110. /package/{esm2020 → esm2022}/driver/in-memory/public_api.mjs +0 -0
  111. /package/{esm2020 → esm2022}/driver/index.mjs +0 -0
  112. /package/{esm2020 → esm2022}/driver/interfaces/auth-service.interface.mjs +0 -0
  113. /package/{esm2020 → esm2022}/driver/interfaces/login-service.interface.mjs +0 -0
  114. /package/{esm2020 → esm2022}/driver/interfaces/public_api.mjs +0 -0
  115. /package/{esm2020 → esm2022}/driver/interfaces/register-service.interface.mjs +0 -0
  116. /package/{esm2020 → esm2022}/driver/interfaces/reset-password-service.interface.mjs +0 -0
  117. /package/{esm2020 → esm2022}/driver/magento/daffodil-auth-driver-magento.mjs +0 -0
  118. /package/{esm2020 → esm2022}/driver/magento/errors/codes.mjs +0 -0
  119. /package/{esm2020 → esm2022}/driver/magento/errors/map.mjs +0 -0
  120. /package/{esm2020 → esm2022}/driver/magento/errors/transform.mjs +0 -0
  121. /package/{esm2020 → esm2022}/driver/magento/index.mjs +0 -0
  122. /package/{esm2020 → esm2022}/driver/magento/models/public_api.mjs +0 -0
  123. /package/{esm2020 → esm2022}/driver/magento/models/response/auth.mjs +0 -0
  124. /package/{esm2020 → esm2022}/driver/magento/models/response/register.type.mjs +0 -0
  125. /package/{esm2020 → esm2022}/driver/magento/models/response/reset-password.type.mjs +0 -0
  126. /package/{esm2020 → esm2022}/driver/magento/models/response/send-reset-email.type.mjs +0 -0
  127. /package/{esm2020 → esm2022}/driver/magento/public_api.mjs +0 -0
  128. /package/{esm2020 → esm2022}/driver/magento/queries/check-token.mjs +0 -0
  129. /package/{esm2020 → esm2022}/driver/magento/queries/create-customer.mjs +0 -0
  130. /package/{esm2020 → esm2022}/driver/magento/queries/generate-token.mjs +0 -0
  131. /package/{esm2020 → esm2022}/driver/magento/queries/public_api.mjs +0 -0
  132. /package/{esm2020 → esm2022}/driver/magento/queries/reset-password.mjs +0 -0
  133. /package/{esm2020 → esm2022}/driver/magento/queries/responses/check-token-response.mjs +0 -0
  134. /package/{esm2020 → esm2022}/driver/magento/queries/responses/generate-token-response.mjs +0 -0
  135. /package/{esm2020 → esm2022}/driver/magento/queries/responses/public_api.mjs +0 -0
  136. /package/{esm2020 → esm2022}/driver/magento/queries/responses/revoke-customer-token-response.mjs +0 -0
  137. /package/{esm2020 → esm2022}/driver/magento/queries/revoke-customer-token.mjs +0 -0
  138. /package/{esm2020 → esm2022}/driver/magento/queries/send-reset-email.mjs +0 -0
  139. /package/{esm2020 → esm2022}/driver/magento/validators/check-token.mjs +0 -0
  140. /package/{esm2020 → esm2022}/driver/magento/validators/generate-token.mjs +0 -0
  141. /package/{esm2020 → esm2022}/driver/magento/validators/public_api.mjs +0 -0
  142. /package/{esm2020 → esm2022}/driver/magento/validators/reset-password.mjs +0 -0
  143. /package/{esm2020 → esm2022}/driver/magento/validators/revoke-token.mjs +0 -0
  144. /package/{esm2020 → esm2022}/driver/magento/validators/send-reset-email.mjs +0 -0
  145. /package/{esm2020 → esm2022}/driver/public_api.mjs +0 -0
  146. /package/{esm2020 → esm2022}/driver/services/public_api.mjs +0 -0
  147. /package/{esm2020 → esm2022}/driver/testing/daffodil-auth-driver-testing.mjs +0 -0
  148. /package/{esm2020 → esm2022}/driver/testing/drivers/public_api.mjs +0 -0
  149. /package/{esm2020 → esm2022}/driver/testing/index.mjs +0 -0
  150. /package/{esm2020 → esm2022}/driver/testing/public_api.mjs +0 -0
  151. /package/{esm2020 → esm2022}/errors/codes.enum.mjs +0 -0
  152. /package/{esm2020 → esm2022}/errors/map.mjs +0 -0
  153. /package/{esm2020 → esm2022}/errors/missing-token.mjs +0 -0
  154. /package/{esm2020 → esm2022}/errors/public_api.mjs +0 -0
  155. /package/{esm2020 → esm2022}/index.mjs +0 -0
  156. /package/{esm2020 → esm2022}/models/account-registration.mjs +0 -0
  157. /package/{esm2020 → esm2022}/models/auth-token.mjs +0 -0
  158. /package/{esm2020 → esm2022}/models/login-info.mjs +0 -0
  159. /package/{esm2020 → esm2022}/models/public_api.mjs +0 -0
  160. /package/{esm2020 → esm2022}/models/reset-password-info.type.mjs +0 -0
  161. /package/{esm2020 → esm2022}/public_api.mjs +0 -0
  162. /package/{esm2020 → esm2022}/routing/config/default.mjs +0 -0
  163. /package/{esm2020 → esm2022}/routing/config/interface.mjs +0 -0
  164. /package/{esm2020 → esm2022}/routing/config/public_api.mjs +0 -0
  165. /package/{esm2020 → esm2022}/routing/config/token.mjs +0 -0
  166. /package/{esm2020 → esm2022}/routing/daffodil-auth-routing.mjs +0 -0
  167. /package/{esm2020 → esm2022}/routing/guards/guest-only-guard-redirect.token.mjs +0 -0
  168. /package/{esm2020 → esm2022}/routing/guards/member-only-guard-redirect.token.mjs +0 -0
  169. /package/{esm2020 → esm2022}/routing/guards/public_api.mjs +0 -0
  170. /package/{esm2020 → esm2022}/routing/helpers/public_api.mjs +0 -0
  171. /package/{esm2020 → esm2022}/routing/helpers/redirect-unauthenticated-hook-factory.mjs +0 -0
  172. /package/{esm2020 → esm2022}/routing/index.mjs +0 -0
  173. /package/{esm2020 → esm2022}/routing/public_api.mjs +0 -0
  174. /package/{esm2020 → esm2022}/state/actions/auth.actions.mjs +0 -0
  175. /package/{esm2020 → esm2022}/state/actions/login.actions.mjs +0 -0
  176. /package/{esm2020 → esm2022}/state/actions/public_api.mjs +0 -0
  177. /package/{esm2020 → esm2022}/state/actions/register.actions.mjs +0 -0
  178. /package/{esm2020 → esm2022}/state/actions/reset-password.actions.mjs +0 -0
  179. /package/{esm2020 → esm2022}/state/config/default.mjs +0 -0
  180. /package/{esm2020 → esm2022}/state/config/public_api.mjs +0 -0
  181. /package/{esm2020 → esm2022}/state/config/token.mjs +0 -0
  182. /package/{esm2020 → esm2022}/state/config/type.mjs +0 -0
  183. /package/{esm2020 → esm2022}/state/daffodil-auth-state.mjs +0 -0
  184. /package/{esm2020 → esm2022}/state/facades/auth/facade.interface.mjs +0 -0
  185. /package/{esm2020 → esm2022}/state/facades/auth/public_api.mjs +0 -0
  186. /package/{esm2020 → esm2022}/state/facades/login/facade.interface.mjs +0 -0
  187. /package/{esm2020 → esm2022}/state/facades/login/public_api.mjs +0 -0
  188. /package/{esm2020 → esm2022}/state/facades/public_api.mjs +0 -0
  189. /package/{esm2020 → esm2022}/state/facades/register/facade.interface.mjs +0 -0
  190. /package/{esm2020 → esm2022}/state/facades/register/public_api.mjs +0 -0
  191. /package/{esm2020 → esm2022}/state/facades/reset-password/facade.interface.mjs +0 -0
  192. /package/{esm2020 → esm2022}/state/facades/reset-password/public_api.mjs +0 -0
  193. /package/{esm2020 → esm2022}/state/index.mjs +0 -0
  194. /package/{esm2020 → esm2022}/state/injection-tokens/error-matcher.token.mjs +0 -0
  195. /package/{esm2020 → esm2022}/state/injection-tokens/public_api.mjs +0 -0
  196. /package/{esm2020 → esm2022}/state/injection-tokens/unauthenticated/hook.token.mjs +0 -0
  197. /package/{esm2020 → esm2022}/state/injection-tokens/unauthenticated/hook.type.mjs +0 -0
  198. /package/{esm2020 → esm2022}/state/injection-tokens/unauthenticated/hooks.token.mjs +0 -0
  199. /package/{esm2020 → esm2022}/state/injection-tokens/unauthenticated/public_api.mjs +0 -0
  200. /package/{esm2020 → esm2022}/state/public_api.mjs +0 -0
  201. /package/{esm2020 → esm2022}/state/reducers/auth/auth-initial-state.mjs +0 -0
  202. /package/{esm2020 → esm2022}/state/reducers/auth/auth-reducer-state.interface.mjs +0 -0
  203. /package/{esm2020 → esm2022}/state/reducers/auth/auth.reducer.mjs +0 -0
  204. /package/{esm2020 → esm2022}/state/reducers/auth/public_api.mjs +0 -0
  205. /package/{esm2020 → esm2022}/state/reducers/auth-feature-state.interface.mjs +0 -0
  206. /package/{esm2020 → esm2022}/state/reducers/auth-reducers.mjs +0 -0
  207. /package/{esm2020 → esm2022}/state/reducers/auth-store-feature-key.mjs +0 -0
  208. /package/{esm2020 → esm2022}/state/reducers/login/login-initial-state.mjs +0 -0
  209. /package/{esm2020 → esm2022}/state/reducers/login/login-reducer-state.interface.mjs +0 -0
  210. /package/{esm2020 → esm2022}/state/reducers/login/login.reducer.mjs +0 -0
  211. /package/{esm2020 → esm2022}/state/reducers/login/public_api.mjs +0 -0
  212. /package/{esm2020 → esm2022}/state/reducers/public_api.mjs +0 -0
  213. /package/{esm2020 → esm2022}/state/reducers/register/public_api.mjs +0 -0
  214. /package/{esm2020 → esm2022}/state/reducers/register/register-initial-state.mjs +0 -0
  215. /package/{esm2020 → esm2022}/state/reducers/register/register-reducer-state.interface.mjs +0 -0
  216. /package/{esm2020 → esm2022}/state/reducers/register/register.reducer.mjs +0 -0
  217. /package/{esm2020 → esm2022}/state/reducers/reset-password/initial-state.mjs +0 -0
  218. /package/{esm2020 → esm2022}/state/reducers/reset-password/public_api.mjs +0 -0
  219. /package/{esm2020 → esm2022}/state/reducers/reset-password/reducer.mjs +0 -0
  220. /package/{esm2020 → esm2022}/state/reducers/reset-password/state.interface.mjs +0 -0
  221. /package/{esm2020 → esm2022}/state/reducers/token/extra.token.mjs +0 -0
  222. /package/{esm2020 → esm2022}/state/reducers/token/public_api.mjs +0 -0
  223. /package/{esm2020 → esm2022}/state/reducers/token/reducers.token.mjs +0 -0
  224. /package/{esm2020 → esm2022}/state/selectors/auth/auth.selector.mjs +0 -0
  225. /package/{esm2020 → esm2022}/state/selectors/auth-all.selector.mjs +0 -0
  226. /package/{esm2020 → esm2022}/state/selectors/auth-feature.selector.mjs +0 -0
  227. /package/{esm2020 → esm2022}/state/selectors/login/login.selector.mjs +0 -0
  228. /package/{esm2020 → esm2022}/state/selectors/public_api.mjs +0 -0
  229. /package/{esm2020 → esm2022}/state/selectors/register/register.selector.mjs +0 -0
  230. /package/{esm2020 → esm2022}/state/selectors/reset-password/selector.mjs +0 -0
  231. /package/{esm2020 → esm2022}/state/testing/daffodil-auth-state-testing.mjs +0 -0
  232. /package/{esm2020 → esm2022}/state/testing/index.mjs +0 -0
  233. /package/{esm2020 → esm2022}/state/testing/public_api.mjs +0 -0
  234. /package/{esm2020 → esm2022}/testing/daffodil-auth-testing.mjs +0 -0
  235. /package/{esm2020 → esm2022}/testing/factories/public_api.mjs +0 -0
  236. /package/{esm2020 → esm2022}/testing/index.mjs +0 -0
  237. /package/{esm2020 → esm2022}/testing/public_api.mjs +0 -0
@@ -1,853 +0,0 @@
1
- import { daffOperationInitialState, daffOperationFailed, daffCompleteOperation, daffStartResolution, daffStartMutation, daffOperationStateSelectorFactory, daffTransformErrorToStateError, daffComposeReducers } from '@daffodil/core/state';
2
- import * as i0 from '@angular/core';
3
- import { InjectionToken, Injectable, inject, Inject, NgModule } from '@angular/core';
4
- import * as i1 from '@ngrx/store';
5
- import { createFeatureSelector, createSelector, select, combineReducers, StoreModule } from '@ngrx/store';
6
- import * as i1$1 from '@ngrx/effects';
7
- import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
8
- import { combineLatest, of, EMPTY, iif, defer } from 'rxjs';
9
- import * as i2$1 from '@daffodil/auth';
10
- import { DaffAuthStorageService } from '@daffodil/auth';
11
- import { switchMap, map, catchError, repeat, filter, tap } from 'rxjs/operators';
12
- import * as i2 from '@daffodil/auth/driver';
13
- import { DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES, DaffLoginDriver, DaffRegisterDriver, DaffResetPasswordDriver } from '@daffodil/auth/driver';
14
- import { DaffStorageServiceError, DaffServerSideStorageError } from '@daffodil/core';
15
- import { DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE } from '@daffodil/driver';
16
-
17
- var DaffAuthActionTypes;
18
- (function (DaffAuthActionTypes) {
19
- DaffAuthActionTypes["ResetToUnauthenticatedAction"] = "[@daffodil/auth] Reset To Unauthenticated Action";
20
- DaffAuthActionTypes["AuthStorageFailureAction"] = "[@daffodil/auth] Auth Storage Failure Action";
21
- DaffAuthActionTypes["AuthGuardLogoutAction"] = "[@daffodil/auth] Auth Guard Logout Action";
22
- DaffAuthActionTypes["AuthServerSideAction"] = "[@daffodil/auth] Auth Server Side Action";
23
- DaffAuthActionTypes["AuthCheckAction"] = "[@daffodil/auth] Auth Check Action";
24
- DaffAuthActionTypes["AuthCheckSuccessAction"] = "[@daffodil/auth] Auth Check Success Action";
25
- DaffAuthActionTypes["AuthCheckFailureAction"] = "[@daffodil/auth] Auth Check Failure Action";
26
- })(DaffAuthActionTypes || (DaffAuthActionTypes = {}));
27
- /*
28
- * An action triggered when the authenicated status of the user is invalidated for some reason.
29
- * That reason could be a logout, auth token check failure, or an unauthorized error.
30
- */
31
- class DaffAuthResetToUnauthenticated {
32
- constructor(reason) {
33
- this.reason = reason;
34
- this.type = DaffAuthActionTypes.ResetToUnauthenticatedAction;
35
- }
36
- }
37
- /*
38
- * An action triggered upon a failed auth storage operation.
39
- */
40
- class DaffAuthStorageFailure {
41
- constructor(errorMessage) {
42
- this.errorMessage = errorMessage;
43
- this.type = DaffAuthActionTypes.AuthStorageFailureAction;
44
- }
45
- }
46
- /*
47
- * An action triggered when an auth token is cleared from storage by a routing guard.
48
- */
49
- class DaffAuthGuardLogout {
50
- constructor(errorMessage) {
51
- this.errorMessage = errorMessage;
52
- this.type = DaffAuthActionTypes.AuthGuardLogoutAction;
53
- }
54
- }
55
- /*
56
- * An action triggered when an invalid operation is performed in the server environment.
57
- * A common example is trying to access the auth token from storage.
58
- */
59
- class DaffAuthServerSide {
60
- constructor(errorMessage) {
61
- this.errorMessage = errorMessage;
62
- this.type = DaffAuthActionTypes.AuthServerSideAction;
63
- }
64
- }
65
- /**
66
- * An action triggered to initialize an auth check request.
67
- */
68
- class DaffAuthCheck {
69
- constructor() {
70
- this.type = DaffAuthActionTypes.AuthCheckAction;
71
- }
72
- }
73
- /**
74
- * An action triggered upon a successful auth check.
75
- *
76
- * @param token - the customer access token
77
- */
78
- class DaffAuthCheckSuccess {
79
- constructor() {
80
- this.type = DaffAuthActionTypes.AuthCheckSuccessAction;
81
- }
82
- }
83
- /**
84
- * An action triggered upon a failed auth check request.
85
- *
86
- * @param errorMessage - an error message
87
- */
88
- class DaffAuthCheckFailure {
89
- constructor(errorMessage) {
90
- this.errorMessage = errorMessage;
91
- this.type = DaffAuthActionTypes.AuthCheckFailureAction;
92
- }
93
- }
94
-
95
- var DaffAuthLoginActionTypes;
96
- (function (DaffAuthLoginActionTypes) {
97
- DaffAuthLoginActionTypes["LoginAction"] = "[@daffodil/auth] Login Action";
98
- DaffAuthLoginActionTypes["LoginSuccessAction"] = "[@daffodil/auth] Login Success Action";
99
- DaffAuthLoginActionTypes["LoginFailureAction"] = "[@daffodil/auth] Login Failure Action";
100
- DaffAuthLoginActionTypes["LogoutAction"] = "[@daffodil/auth] Logout Action";
101
- DaffAuthLoginActionTypes["LogoutSuccessAction"] = "[@daffodil/auth] Logout Success Action";
102
- DaffAuthLoginActionTypes["LogoutFailureAction"] = "[@daffodil/auth] Logout Failure Action";
103
- })(DaffAuthLoginActionTypes || (DaffAuthLoginActionTypes = {}));
104
- /**
105
- * An action triggered to initialize a auth login request.
106
- */
107
- class DaffAuthLogin {
108
- constructor(loginInfo) {
109
- this.loginInfo = loginInfo;
110
- this.type = DaffAuthLoginActionTypes.LoginAction;
111
- }
112
- }
113
- /**
114
- * An action triggered upon a successful auth login.
115
- *
116
- * @param token - the customer access token
117
- */
118
- class DaffAuthLoginSuccess {
119
- constructor(auth) {
120
- this.auth = auth;
121
- this.type = DaffAuthLoginActionTypes.LoginSuccessAction;
122
- }
123
- }
124
- /**
125
- * An action triggered upon a failed auth login request.
126
- *
127
- * @param errorMessage - an error message
128
- */
129
- class DaffAuthLoginFailure {
130
- constructor(errorMessage) {
131
- this.errorMessage = errorMessage;
132
- this.type = DaffAuthLoginActionTypes.LoginFailureAction;
133
- }
134
- }
135
- /**
136
- * An action triggered to initialize a logout request.
137
- */
138
- class DaffAuthLogout {
139
- constructor() {
140
- this.type = DaffAuthLoginActionTypes.LogoutAction;
141
- }
142
- }
143
- /**
144
- * An action triggered upon a successful logout.
145
- *
146
- * @param token - the customer access token
147
- */
148
- class DaffAuthLogoutSuccess {
149
- constructor() {
150
- this.type = DaffAuthLoginActionTypes.LogoutSuccessAction;
151
- }
152
- }
153
- /**
154
- * An action triggered upon a failed logout request.
155
- *
156
- * @param errorMessage - an error message
157
- */
158
- class DaffAuthLogoutFailure {
159
- constructor(errorMessage) {
160
- this.errorMessage = errorMessage;
161
- this.type = DaffAuthLoginActionTypes.LogoutFailureAction;
162
- }
163
- }
164
-
165
- var DaffAuthRegisterActionTypes;
166
- (function (DaffAuthRegisterActionTypes) {
167
- DaffAuthRegisterActionTypes["RegisterAction"] = "[@daffodil/auth] Register Action";
168
- DaffAuthRegisterActionTypes["RegisterSuccessAction"] = "[@daffodil/auth] Register Success Action";
169
- DaffAuthRegisterActionTypes["RegisterFailureAction"] = "[@daffodil/auth] Register Failure Action";
170
- })(DaffAuthRegisterActionTypes || (DaffAuthRegisterActionTypes = {}));
171
- /**
172
- * An action triggered to initialize a auth register request.
173
- *
174
- * @param registration
175
- */
176
- class DaffAuthRegister {
177
- constructor(registration, autoLogin = true) {
178
- this.registration = registration;
179
- this.autoLogin = autoLogin;
180
- this.type = DaffAuthRegisterActionTypes.RegisterAction;
181
- }
182
- }
183
- /**
184
- * An action triggered upon a successful auth register request.
185
- *
186
- * @param token - the customer access token
187
- */
188
- class DaffAuthRegisterSuccess {
189
- constructor(token) {
190
- this.token = token;
191
- this.type = DaffAuthRegisterActionTypes.RegisterSuccessAction;
192
- }
193
- }
194
- /**
195
- * An action triggered upon a failed auth request.
196
- *
197
- * @param errorMessage - an error message
198
- */
199
- class DaffAuthRegisterFailure {
200
- constructor(errorMessage) {
201
- this.errorMessage = errorMessage;
202
- this.type = DaffAuthRegisterActionTypes.RegisterFailureAction;
203
- }
204
- }
205
-
206
- var DaffAuthResetPasswordActionTypes;
207
- (function (DaffAuthResetPasswordActionTypes) {
208
- DaffAuthResetPasswordActionTypes["SendResetEmailAction"] = "[@daffodil/auth] Send Reset Email Action";
209
- DaffAuthResetPasswordActionTypes["SendResetEmailSuccessAction"] = "[@daffodil/auth] Send Reset Email Success Action";
210
- DaffAuthResetPasswordActionTypes["SendResetEmailFailureAction"] = "[@daffodil/auth] Send Reset Email Failure Action";
211
- DaffAuthResetPasswordActionTypes["ResetPasswordAction"] = "[@daffodil/auth] Reset Password Action";
212
- DaffAuthResetPasswordActionTypes["ResetPasswordSuccessAction"] = "[@daffodil/auth] Reset Password Success Action";
213
- DaffAuthResetPasswordActionTypes["ResetPasswordFailureAction"] = "[@daffodil/auth] Reset Password Failure Action";
214
- DaffAuthResetPasswordActionTypes["ResetPasswordLandingAction"] = "[@daffodil/auth] Reset Password Landing Action";
215
- })(DaffAuthResetPasswordActionTypes || (DaffAuthResetPasswordActionTypes = {}));
216
- /**
217
- * An action triggered to send the specified customer an email to reset their password.
218
- */
219
- class DaffSendResetEmail {
220
- constructor(email) {
221
- this.email = email;
222
- this.type = DaffAuthResetPasswordActionTypes.SendResetEmailAction;
223
- }
224
- }
225
- /**
226
- * An action triggered upon a successfully sent reset password email.
227
- */
228
- class DaffSendResetEmailSuccess {
229
- constructor() {
230
- this.type = DaffAuthResetPasswordActionTypes.SendResetEmailSuccessAction;
231
- }
232
- }
233
- /**
234
- * An action triggered upon a failure to send the reset password email.
235
- *
236
- * @param errorMessage - an error message
237
- */
238
- class DaffSendResetEmailFailure {
239
- constructor(errorMessage) {
240
- this.errorMessage = errorMessage;
241
- this.type = DaffAuthResetPasswordActionTypes.SendResetEmailFailureAction;
242
- }
243
- }
244
- /**
245
- * An action triggered to initialize a logout request.
246
- */
247
- class DaffResetPassword {
248
- constructor(info, autoLogin = true) {
249
- this.info = info;
250
- this.autoLogin = autoLogin;
251
- this.type = DaffAuthResetPasswordActionTypes.ResetPasswordAction;
252
- }
253
- }
254
- /**
255
- * An action triggered upon a successful logout.
256
- */
257
- class DaffResetPasswordSuccess {
258
- constructor(token) {
259
- this.token = token;
260
- this.type = DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction;
261
- }
262
- }
263
- /**
264
- * An action triggered upon a failed logout request.
265
- *
266
- * @param errorMessage - an error message
267
- */
268
- class DaffResetPasswordFailure {
269
- constructor(errorMessage) {
270
- this.errorMessage = errorMessage;
271
- this.type = DaffAuthResetPasswordActionTypes.ResetPasswordFailureAction;
272
- }
273
- }
274
- /**
275
- * An action triggered upon the user navigating to the reset password page from the link in their email.
276
- *
277
- * @param token - The token with which the password can be reset
278
- */
279
- class DaffResetPasswordLanding {
280
- constructor(token) {
281
- this.token = token;
282
- this.type = DaffAuthResetPasswordActionTypes.ResetPasswordLandingAction;
283
- }
284
- }
285
-
286
- const daffAuthInitialState = Object.assign(Object.assign({}, daffOperationInitialState), { loggedIn: false });
287
-
288
- function daffAuthReducer(state = daffAuthInitialState, action) {
289
- switch (action.type) {
290
- case DaffAuthActionTypes.AuthCheckAction:
291
- return daffStartResolution(state);
292
- case DaffAuthActionTypes.AuthCheckSuccessAction:
293
- return Object.assign(Object.assign({}, daffCompleteOperation(state)), { loggedIn: true });
294
- case DaffAuthActionTypes.AuthCheckFailureAction:
295
- case DaffAuthActionTypes.AuthGuardLogoutAction:
296
- return Object.assign(Object.assign({}, daffOperationFailed([action.errorMessage], state)), { loggedIn: false });
297
- case DaffAuthActionTypes.AuthServerSideAction:
298
- case DaffAuthActionTypes.AuthStorageFailureAction:
299
- return daffOperationFailed([action.errorMessage], state);
300
- case DaffAuthLoginActionTypes.LoginSuccessAction:
301
- return Object.assign(Object.assign({}, state), { loggedIn: true });
302
- case DaffAuthRegisterActionTypes.RegisterSuccessAction:
303
- case DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction:
304
- return action.token ? Object.assign(Object.assign({}, state), { loggedIn: true }) : state;
305
- case DaffAuthLoginActionTypes.LogoutSuccessAction:
306
- return Object.assign(Object.assign({}, state), { loggedIn: false });
307
- default:
308
- return state;
309
- }
310
- }
311
-
312
- const daffAuthLoginInitialState = daffOperationInitialState;
313
-
314
- function daffAuthLoginReducer(state = daffAuthLoginInitialState, action) {
315
- switch (action.type) {
316
- case DaffAuthLoginActionTypes.LoginAction:
317
- case DaffAuthLoginActionTypes.LogoutAction:
318
- return daffStartMutation(state);
319
- case DaffAuthLoginActionTypes.LoginSuccessAction:
320
- case DaffAuthLoginActionTypes.LogoutSuccessAction:
321
- return daffCompleteOperation(state);
322
- case DaffAuthLoginActionTypes.LoginFailureAction:
323
- case DaffAuthLoginActionTypes.LogoutFailureAction:
324
- return daffOperationFailed([action.errorMessage], state);
325
- default:
326
- return state;
327
- }
328
- }
329
-
330
- const daffAuthRegisterInitialState = daffOperationInitialState;
331
-
332
- function daffAuthRegisterReducer(state = daffAuthRegisterInitialState, action) {
333
- switch (action.type) {
334
- case DaffAuthRegisterActionTypes.RegisterAction:
335
- return daffStartMutation(state);
336
- case DaffAuthRegisterActionTypes.RegisterSuccessAction:
337
- return daffCompleteOperation(state);
338
- case DaffAuthRegisterActionTypes.RegisterFailureAction:
339
- return daffOperationFailed([action.errorMessage], state);
340
- default:
341
- return state;
342
- }
343
- }
344
-
345
- const daffAuthResetPasswordInitialState = Object.assign(Object.assign({}, daffOperationInitialState), { token: null });
346
-
347
- function daffAuthResetPasswordReducer(state = daffAuthResetPasswordInitialState, action) {
348
- switch (action.type) {
349
- case DaffAuthResetPasswordActionTypes.ResetPasswordAction:
350
- case DaffAuthResetPasswordActionTypes.SendResetEmailAction:
351
- return daffStartMutation(state);
352
- case DaffAuthResetPasswordActionTypes.ResetPasswordSuccessAction:
353
- case DaffAuthResetPasswordActionTypes.SendResetEmailSuccessAction:
354
- return daffCompleteOperation(state);
355
- case DaffAuthResetPasswordActionTypes.ResetPasswordFailureAction:
356
- case DaffAuthResetPasswordActionTypes.SendResetEmailFailureAction:
357
- return daffOperationFailed([action.errorMessage], state);
358
- case DaffAuthResetPasswordActionTypes.ResetPasswordLandingAction:
359
- return Object.assign(Object.assign({}, state), { token: action.token });
360
- default:
361
- return state;
362
- }
363
- }
364
-
365
- /**
366
- * A token to hold the injectable extra reducers.
367
- *
368
- * Prefer using {@link daffAuthProvideExtraReducers}.
369
- */
370
- const DAFF_AUTH_EXTRA_REDUCERS = new InjectionToken('DAFF_AUTH_EXTRA_REDUCERS', { factory: () => [] });
371
- /**
372
- * Provides additional reducers that run after the standard Daffodil auth reducers.
373
- *
374
- * ```ts
375
- * providers: [
376
- * ...daffAuthProvideExtraReducers(
377
- * myReducer1,
378
- * myReducer2
379
- * )
380
- * ]
381
- * ```
382
- */
383
- function daffAuthProvideExtraReducers(...reducers) {
384
- return reducers.map(reducer => ({
385
- provide: DAFF_AUTH_EXTRA_REDUCERS,
386
- useValue: reducer,
387
- multi: true,
388
- }));
389
- }
390
-
391
- const DAFF_AUTH_STORE_FEATURE_KEY = 'daffAuth';
392
-
393
- const daffAuthReducers = {
394
- auth: daffAuthReducer,
395
- login: daffAuthLoginReducer,
396
- register: daffAuthRegisterReducer,
397
- resetPassword: daffAuthResetPasswordReducer,
398
- };
399
-
400
- /**
401
- * Feature State Selector
402
- */
403
- const getDaffAuthFeatureStateSelector = (() => {
404
- let cache;
405
- return () => cache = cache || createFeatureSelector(DAFF_AUTH_STORE_FEATURE_KEY);
406
- })();
407
-
408
- const createAuthSelectors = () => {
409
- const selectAuthState = createSelector(getDaffAuthFeatureStateSelector(), state => state.auth);
410
- const selectAuthLoggedIn = createSelector(selectAuthState, state => state.loggedIn);
411
- return Object.assign(Object.assign({}, daffOperationStateSelectorFactory(selectAuthState)), { selectAuthState,
412
- selectAuthLoggedIn });
413
- };
414
- const daffAuthSelectorFactory = (() => {
415
- let cache;
416
- return () => cache = cache || createAuthSelectors();
417
- })();
418
-
419
- const createLoginSelectors = () => {
420
- const selectAuthLoginState = createSelector(getDaffAuthFeatureStateSelector(), state => state.login);
421
- return Object.assign(Object.assign({}, daffOperationStateSelectorFactory(selectAuthLoginState)), { selectAuthLoginState });
422
- };
423
- const daffAuthLoginSelectorFactory = (() => {
424
- let cache;
425
- return () => cache = cache || createLoginSelectors();
426
- })();
427
-
428
- const createRegisterSelectors = () => {
429
- const selectAuthRegisterState = createSelector(getDaffAuthFeatureStateSelector(), state => state.register);
430
- return Object.assign(Object.assign({}, daffOperationStateSelectorFactory(selectAuthRegisterState)), { selectAuthRegisterState });
431
- };
432
- const daffAuthRegisterSelectorFactory = (() => {
433
- let cache;
434
- return () => cache = cache || createRegisterSelectors();
435
- })();
436
-
437
- const createResetPasswordSelectors = () => {
438
- const selectAuthResetPasswordState = createSelector(getDaffAuthFeatureStateSelector(), state => state.resetPassword);
439
- const selectAuthResetPasswordToken = createSelector(selectAuthResetPasswordState, state => state.token);
440
- return Object.assign(Object.assign({}, daffOperationStateSelectorFactory(selectAuthResetPasswordState)), { selectAuthResetPasswordState,
441
- selectAuthResetPasswordToken });
442
- };
443
- const daffAuthResetPasswordSelectorFactory = (() => {
444
- let cache;
445
- return () => cache = cache || createResetPasswordSelectors();
446
- })();
447
-
448
- const getDaffAuthSelectors = (() => {
449
- let cache;
450
- return () => cache = cache || Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, daffAuthSelectorFactory()), daffAuthLoginSelectorFactory()), daffAuthRegisterSelectorFactory()), daffAuthResetPasswordSelectorFactory()), { selectAuthFeatureState: getDaffAuthFeatureStateSelector() });
451
- })();
452
-
453
- /**
454
- * @inheritdoc
455
- */
456
- class DaffAuthFacade {
457
- constructor(store) {
458
- this.store = store;
459
- const { selectLoading, selectErrors, selectAuthLoggedIn, } = daffAuthSelectorFactory();
460
- this.loading$ = this.store.pipe(select(selectLoading));
461
- this.errors$ = this.store.pipe(select(selectErrors));
462
- this.loggedIn$ = this.store.pipe(select(selectAuthLoggedIn));
463
- }
464
- dispatch(action) {
465
- this.store.dispatch(action);
466
- }
467
- }
468
- /** @nocollapse */ DaffAuthFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable });
469
- /** @nocollapse */ DaffAuthFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthFacade, providedIn: 'root' });
470
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthFacade, decorators: [{
471
- type: Injectable,
472
- args: [{
473
- providedIn: 'root',
474
- }]
475
- }], ctorParameters: function () { return [{ type: i1.Store }]; } });
476
-
477
- /**
478
- * @inheritdoc
479
- */
480
- class DaffAuthLoginFacade {
481
- constructor(store) {
482
- this.store = store;
483
- const { selectLoading, selectErrors, } = daffAuthLoginSelectorFactory();
484
- this.loading$ = this.store.pipe(select(selectLoading));
485
- this.errors$ = this.store.pipe(select(selectErrors));
486
- }
487
- dispatch(action) {
488
- this.store.dispatch(action);
489
- }
490
- }
491
- /** @nocollapse */ DaffAuthLoginFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthLoginFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable });
492
- /** @nocollapse */ DaffAuthLoginFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthLoginFacade, providedIn: 'root' });
493
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthLoginFacade, decorators: [{
494
- type: Injectable,
495
- args: [{
496
- providedIn: 'root',
497
- }]
498
- }], ctorParameters: function () { return [{ type: i1.Store }]; } });
499
-
500
- /**
501
- * @inheritdoc
502
- */
503
- class DaffAuthRegisterFacade {
504
- constructor(store) {
505
- this.store = store;
506
- const { selectLoading, selectErrors, } = daffAuthRegisterSelectorFactory();
507
- this.loading$ = this.store.pipe(select(selectLoading));
508
- this.errors$ = this.store.pipe(select(selectErrors));
509
- }
510
- dispatch(action) {
511
- this.store.dispatch(action);
512
- }
513
- }
514
- /** @nocollapse */ DaffAuthRegisterFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthRegisterFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable });
515
- /** @nocollapse */ DaffAuthRegisterFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthRegisterFacade, providedIn: 'root' });
516
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthRegisterFacade, decorators: [{
517
- type: Injectable,
518
- args: [{
519
- providedIn: 'root',
520
- }]
521
- }], ctorParameters: function () { return [{ type: i1.Store }]; } });
522
-
523
- /**
524
- * @inheritdoc
525
- */
526
- class DaffAuthResetPasswordFacade {
527
- constructor(store) {
528
- this.store = store;
529
- const { selectLoading, selectErrors, selectAuthResetPasswordToken, } = daffAuthResetPasswordSelectorFactory();
530
- this.token$ = this.store.pipe(select(selectAuthResetPasswordToken));
531
- this.loading$ = this.store.pipe(select(selectLoading));
532
- this.errors$ = this.store.pipe(select(selectErrors));
533
- }
534
- dispatch(action) {
535
- this.store.dispatch(action);
536
- }
537
- }
538
- /** @nocollapse */ DaffAuthResetPasswordFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthResetPasswordFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable });
539
- /** @nocollapse */ DaffAuthResetPasswordFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthResetPasswordFacade, providedIn: 'root' });
540
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthResetPasswordFacade, decorators: [{
541
- type: Injectable,
542
- args: [{
543
- providedIn: 'root',
544
- }]
545
- }], ctorParameters: function () { return [{ type: i1.Store }]; } });
546
-
547
- const TWENTY_MINUTES = 1.2e6;
548
- const daffAuthStateDefaultConfig = {
549
- checkInterval: TWENTY_MINUTES,
550
- };
551
-
552
- const DAFF_AUTH_STATE_CONFIG = new InjectionToken('DAFF_AUTH_STATE_CONFIG', { factory: () => daffAuthStateDefaultConfig });
553
- const provideDaffAuthStateConfig = (config) => ({
554
- provide: DAFF_AUTH_STATE_CONFIG,
555
- useValue: config,
556
- });
557
-
558
- /**
559
- * A token to hold the unauthenticated hooks.
560
- * See {@link DaffAuthUnauthenticatedHook}.
561
- *
562
- * Prefer using {@link daffAuthProvideUnauthenticatedHooks}.
563
- */
564
- const DAFF_AUTH_UNAUTHENTICATED_HOOKS = new InjectionToken('DAFF_AUTH_UNAUTHENTICATED_HOOKS', { factory: () => [] });
565
- /**
566
- * Provides {@link DAFF_AUTH_UNAUTHENTICATED_HOOKS}.
567
- *
568
- * ```ts
569
- * providers: [
570
- * ...daffAuthProvideUnauthenticatedHooks(
571
- * myReducer1,
572
- * myReducer2
573
- * )
574
- * ]
575
- * ```
576
- */
577
- function daffAuthProvideUnauthenticatedHooks(...hooks) {
578
- return hooks.map(hook => ({
579
- provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
580
- useValue: hook,
581
- multi: true,
582
- }));
583
- }
584
-
585
- /**
586
- * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
587
- * Can be used to further refine Daffodil errors into more specific app errors.
588
- */
589
- const DAFF_AUTH_ERROR_MATCHER = new InjectionToken('DAFF_AUTH_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
590
-
591
- /**
592
- * An internal token to hold the unauthenticated hook.
593
- * Combines the multi provided hooks into a single function.
594
- *
595
- * @docs-private
596
- */
597
- const DAFF_AUTH_UNAUTHENTICATED_HOOK = new InjectionToken('DAFF_AUTH_UNAUTHENTICATED_HOOK', {
598
- factory: () => {
599
- const hooks = inject(DAFF_AUTH_UNAUTHENTICATED_HOOKS);
600
- return (action) => combineLatest(hooks.map((hook) => hook(action)));
601
- },
602
- });
603
-
604
- class DaffAuthEffects {
605
- constructor(actions$, tokenCheck, errorMatcher, storage, config, clientCache, unauthenticatedHook) {
606
- this.actions$ = actions$;
607
- this.tokenCheck = tokenCheck;
608
- this.errorMatcher = errorMatcher;
609
- this.storage = storage;
610
- this.config = config;
611
- this.clientCache = clientCache;
612
- this.unauthenticatedHook = unauthenticatedHook;
613
- this.check$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.AuthCheckAction), switchMap((action) => this.tokenCheck.check().pipe(map(() => new DaffAuthCheckSuccess()), catchError((error) => of(new DaffAuthCheckFailure(this.errorMatcher(error))))))));
614
- // this needs to be defined after `check$` or else the driver call won't be run
615
- this.authCheckInterval$ = createEffect(() => of(new DaffAuthCheck()).pipe(repeat({ delay: this.config.checkInterval }), filter(() => !!this.storage.getAuthToken()), catchError((error) => {
616
- switch (true) {
617
- case error instanceof DaffServerSideStorageError:
618
- return of(new DaffAuthServerSide(this.errorMatcher(error)));
619
- case error instanceof DaffStorageServiceError:
620
- return of(new DaffAuthStorageFailure(this.errorMatcher(error)));
621
- default:
622
- return EMPTY;
623
- }
624
- })));
625
- this.resetToUnauthenticated$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.AuthCheckFailureAction, DaffAuthActionTypes.AuthGuardLogoutAction, DaffAuthLoginActionTypes.LogoutSuccessAction), filter((action) => {
626
- // if the auth check failure is for any reason other than auth failure,
627
- // such as a network failure, don't reset
628
- if (action.type === DaffAuthActionTypes.AuthCheckFailureAction
629
- && !DAFF_AUTH_UNAUTHENTICATED_ERROR_CODES[action.errorMessage.code]) {
630
- return false;
631
- }
632
- return true;
633
- }), map((action) => new DaffAuthResetToUnauthenticated(action.type))));
634
- this.clearClientCache$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthActionTypes.ResetToUnauthenticatedAction), switchMap((action) => this.unauthenticatedHook(action.reason)), tap(() => {
635
- this.clientCache.reset();
636
- }), switchMap(() => EMPTY)), { dispatch: false });
637
- }
638
- }
639
- /** @nocollapse */ DaffAuthEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthEffects, deps: [{ token: i1$1.Actions }, { token: i2.DaffAuthDriverTokenCheck }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: i2$1.DaffAuthStorageService }, { token: DAFF_AUTH_STATE_CONFIG }, { token: DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE }, { token: DAFF_AUTH_UNAUTHENTICATED_HOOK }], target: i0.ɵɵFactoryTarget.Injectable });
640
- /** @nocollapse */ DaffAuthEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthEffects });
641
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthEffects, decorators: [{
642
- type: Injectable
643
- }], ctorParameters: function () {
644
- return [{ type: i1$1.Actions }, { type: i2.DaffAuthDriverTokenCheck }, { type: undefined, decorators: [{
645
- type: Inject,
646
- args: [DAFF_AUTH_ERROR_MATCHER]
647
- }] }, { type: i2$1.DaffAuthStorageService }, { type: undefined, decorators: [{
648
- type: Inject,
649
- args: [DAFF_AUTH_STATE_CONFIG]
650
- }] }, { type: undefined, decorators: [{
651
- type: Inject,
652
- args: [DAFF_DRIVER_HTTP_CLIENT_CACHE_SERVICE]
653
- }] }, { type: undefined, decorators: [{
654
- type: Inject,
655
- args: [DAFF_AUTH_UNAUTHENTICATED_HOOK]
656
- }] }];
657
- } });
658
-
659
- class DaffAuthLoginEffects {
660
- constructor(actions$, loginDriver, errorMatcher, storage) {
661
- this.actions$ = actions$;
662
- this.loginDriver = loginDriver;
663
- this.errorMatcher = errorMatcher;
664
- this.storage = storage;
665
- this.login$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LoginAction), switchMap((action) => this.loginDriver.login(action.loginInfo)
666
- .pipe(map((resp) => new DaffAuthLoginSuccess(resp)), tap((success) => this.storage.setAuthToken(success.auth.token)), catchError((error) => {
667
- switch (true) {
668
- case error instanceof DaffServerSideStorageError:
669
- return of(new DaffAuthServerSide(this.errorMatcher(error)));
670
- case error instanceof DaffStorageServiceError:
671
- default:
672
- return of(new DaffAuthLoginFailure(this.errorMatcher(error)));
673
- }
674
- })))));
675
- this.logout$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthLoginActionTypes.LogoutAction), switchMap((action) => this.loginDriver.logout().pipe(map(() => new DaffAuthLogoutSuccess()), catchError((error) => {
676
- switch (true) {
677
- case error instanceof DaffServerSideStorageError:
678
- return of(new DaffAuthServerSide(this.errorMatcher(error)));
679
- case error instanceof DaffStorageServiceError:
680
- return of(new DaffAuthStorageFailure(this.errorMatcher(error)));
681
- default:
682
- return of(new DaffAuthLogoutFailure(this.errorMatcher(error)));
683
- }
684
- })))));
685
- }
686
- }
687
- /** @nocollapse */ DaffAuthLoginEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthLoginEffects, deps: [{ token: i1$1.Actions }, { token: DaffLoginDriver }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: i2$1.DaffAuthStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
688
- /** @nocollapse */ DaffAuthLoginEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthLoginEffects });
689
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthLoginEffects, decorators: [{
690
- type: Injectable
691
- }], ctorParameters: function () {
692
- return [{ type: i1$1.Actions }, { type: undefined, decorators: [{
693
- type: Inject,
694
- args: [DaffLoginDriver]
695
- }] }, { type: undefined, decorators: [{
696
- type: Inject,
697
- args: [DAFF_AUTH_ERROR_MATCHER]
698
- }] }, { type: i2$1.DaffAuthStorageService }];
699
- } });
700
-
701
- class DaffAuthRegisterEffects {
702
- constructor(actions$, registerDriver, errorMatcher, storage) {
703
- this.actions$ = actions$;
704
- this.registerDriver = registerDriver;
705
- this.errorMatcher = errorMatcher;
706
- this.storage = storage;
707
- this.register$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthRegisterActionTypes.RegisterAction), switchMap((action) => iif(() => action.autoLogin, defer(() => this.registerDriver.register(action.registration).pipe(tap(token => this.storage.setAuthToken(token)), map((token) => new DaffAuthRegisterSuccess(token)))), defer(() => this.registerDriver.registerOnly(action.registration).pipe(map(() => new DaffAuthRegisterSuccess())))).pipe(catchError((error) => {
708
- switch (true) {
709
- case error instanceof DaffServerSideStorageError:
710
- return of(new DaffAuthServerSide(this.errorMatcher(error)), new DaffAuthRegisterFailure(this.errorMatcher(error)));
711
- case error instanceof DaffStorageServiceError:
712
- return of(new DaffAuthStorageFailure(this.errorMatcher(error)), new DaffAuthRegisterFailure(this.errorMatcher(error)));
713
- default:
714
- return of(new DaffAuthRegisterFailure(this.errorMatcher(error)));
715
- }
716
- })))));
717
- }
718
- }
719
- /** @nocollapse */ DaffAuthRegisterEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthRegisterEffects, deps: [{ token: i1$1.Actions }, { token: DaffRegisterDriver }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: i2$1.DaffAuthStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
720
- /** @nocollapse */ DaffAuthRegisterEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthRegisterEffects });
721
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthRegisterEffects, decorators: [{
722
- type: Injectable
723
- }], ctorParameters: function () {
724
- return [{ type: i1$1.Actions }, { type: undefined, decorators: [{
725
- type: Inject,
726
- args: [DaffRegisterDriver]
727
- }] }, { type: undefined, decorators: [{
728
- type: Inject,
729
- args: [DAFF_AUTH_ERROR_MATCHER]
730
- }] }, { type: i2$1.DaffAuthStorageService }];
731
- } });
732
-
733
- class DaffAuthResetPasswordEffects {
734
- constructor(actions$, driver, errorMatcher, storage) {
735
- this.actions$ = actions$;
736
- this.driver = driver;
737
- this.errorMatcher = errorMatcher;
738
- this.storage = storage;
739
- this.sendResetEmail$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthResetPasswordActionTypes.SendResetEmailAction), switchMap((action) => this.driver.sendResetEmail(action.email).pipe(map(() => new DaffSendResetEmailSuccess()), catchError((error) => of(new DaffSendResetEmailFailure(this.errorMatcher(error))))))));
740
- this.resetPassword$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthResetPasswordActionTypes.ResetPasswordAction), switchMap((action) => iif(() => action.autoLogin, defer(() => this.driver.resetPassword(action.info).pipe(tap(token => this.storage.setAuthToken(token)), map((token) => new DaffResetPasswordSuccess(token)))), defer(() => this.driver.resetPasswordOnly(action.info).pipe(map(() => new DaffResetPasswordSuccess())))).pipe(catchError((error) => {
741
- switch (true) {
742
- case error instanceof DaffServerSideStorageError:
743
- return of(new DaffAuthServerSide(this.errorMatcher(error)), new DaffResetPasswordFailure(this.errorMatcher(error)));
744
- case error instanceof DaffStorageServiceError:
745
- return of(new DaffAuthStorageFailure(this.errorMatcher(error)), new DaffResetPasswordFailure(this.errorMatcher(error)));
746
- default:
747
- return of(new DaffResetPasswordFailure(this.errorMatcher(error)));
748
- }
749
- })))));
750
- }
751
- }
752
- /** @nocollapse */ DaffAuthResetPasswordEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthResetPasswordEffects, deps: [{ token: i1$1.Actions }, { token: DaffResetPasswordDriver }, { token: DAFF_AUTH_ERROR_MATCHER }, { token: i2$1.DaffAuthStorageService }], target: i0.ɵɵFactoryTarget.Injectable });
753
- /** @nocollapse */ DaffAuthResetPasswordEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthResetPasswordEffects });
754
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthResetPasswordEffects, decorators: [{
755
- type: Injectable
756
- }], ctorParameters: function () {
757
- return [{ type: i1$1.Actions }, { type: undefined, decorators: [{
758
- type: Inject,
759
- args: [DaffResetPasswordDriver]
760
- }] }, { type: undefined, decorators: [{
761
- type: Inject,
762
- args: [DAFF_AUTH_ERROR_MATCHER]
763
- }] }, { type: i2$1.DaffAuthStorageService }];
764
- } });
765
-
766
- /**
767
- * An internal token to hold the Daffodil auth reducers.
768
- * Includes the extra and standard reducers.
769
- *
770
- * @docs-private
771
- */
772
- const DAFF_AUTH_REDUCERS = new InjectionToken('DAFF_AUTH_REDUCERS', {
773
- factory: () => daffComposeReducers([
774
- combineReducers(daffAuthReducers),
775
- ...inject(DAFF_AUTH_EXTRA_REDUCERS),
776
- ]),
777
- });
778
-
779
- class DaffAuthStateModule {
780
- static withConfig(config = {}) {
781
- return {
782
- ngModule: DaffAuthStateModule,
783
- providers: [
784
- provideDaffAuthStateConfig(Object.assign(Object.assign({}, daffAuthStateDefaultConfig), config)),
785
- ],
786
- };
787
- }
788
- }
789
- /** @nocollapse */ DaffAuthStateModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
790
- /** @nocollapse */ DaffAuthStateModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthStateModule, imports: [i1.StoreFeatureModule, i1$1.EffectsFeatureModule] });
791
- /** @nocollapse */ DaffAuthStateModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthStateModule, providers: [
792
- {
793
- provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
794
- useFactory: (() => {
795
- const storage = inject(DaffAuthStorageService);
796
- const hook = (() => {
797
- try {
798
- return of(storage.removeAuthToken());
799
- }
800
- catch (_a) {
801
- return of(null);
802
- }
803
- });
804
- return hook;
805
- }),
806
- multi: true,
807
- },
808
- ], imports: [StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS),
809
- EffectsModule.forFeature([
810
- DaffAuthEffects,
811
- DaffAuthLoginEffects,
812
- DaffAuthRegisterEffects,
813
- DaffAuthResetPasswordEffects,
814
- ])] });
815
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DaffAuthStateModule, decorators: [{
816
- type: NgModule,
817
- args: [{
818
- imports: [
819
- StoreModule.forFeature(DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_REDUCERS),
820
- EffectsModule.forFeature([
821
- DaffAuthEffects,
822
- DaffAuthLoginEffects,
823
- DaffAuthRegisterEffects,
824
- DaffAuthResetPasswordEffects,
825
- ]),
826
- ],
827
- providers: [
828
- {
829
- provide: DAFF_AUTH_UNAUTHENTICATED_HOOKS,
830
- useFactory: (() => {
831
- const storage = inject(DaffAuthStorageService);
832
- const hook = (() => {
833
- try {
834
- return of(storage.removeAuthToken());
835
- }
836
- catch (_a) {
837
- return of(null);
838
- }
839
- });
840
- return hook;
841
- }),
842
- multi: true,
843
- },
844
- ],
845
- }]
846
- }] });
847
-
848
- /**
849
- * Generated bundle index. Do not edit.
850
- */
851
-
852
- export { DAFF_AUTH_ERROR_MATCHER, DAFF_AUTH_EXTRA_REDUCERS, DAFF_AUTH_STATE_CONFIG, DAFF_AUTH_STORE_FEATURE_KEY, DAFF_AUTH_UNAUTHENTICATED_HOOKS, DaffAuthActionTypes, DaffAuthCheck, DaffAuthCheckFailure, DaffAuthCheckSuccess, DaffAuthFacade, DaffAuthGuardLogout, DaffAuthLogin, DaffAuthLoginActionTypes, DaffAuthLoginFacade, DaffAuthLoginFailure, DaffAuthLoginSuccess, DaffAuthLogout, DaffAuthLogoutFailure, DaffAuthLogoutSuccess, DaffAuthRegister, DaffAuthRegisterActionTypes, DaffAuthRegisterFacade, DaffAuthRegisterFailure, DaffAuthRegisterSuccess, DaffAuthResetPasswordActionTypes, DaffAuthResetPasswordFacade, DaffAuthResetToUnauthenticated, DaffAuthServerSide, DaffAuthStateModule, DaffAuthStorageFailure, DaffResetPassword, DaffResetPasswordFailure, DaffResetPasswordLanding, DaffResetPasswordSuccess, DaffSendResetEmail, DaffSendResetEmailFailure, DaffSendResetEmailSuccess, daffAuthInitialState, daffAuthLoginInitialState, daffAuthLoginReducer, daffAuthLoginSelectorFactory, daffAuthProvideExtraReducers, daffAuthProvideUnauthenticatedHooks, daffAuthReducer, daffAuthReducers, daffAuthRegisterInitialState, daffAuthRegisterReducer, daffAuthRegisterSelectorFactory, daffAuthResetPasswordInitialState, daffAuthResetPasswordReducer, daffAuthResetPasswordSelectorFactory, daffAuthSelectorFactory, daffAuthStateDefaultConfig, getDaffAuthSelectors, provideDaffAuthStateConfig };
853
- //# sourceMappingURL=daffodil-auth-state.mjs.map