ngx-firebase 1.1.12 → 22.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 (274) hide show
  1. package/README.md +51 -11
  2. package/fesm2022/ngx-firebase.mjs +158 -0
  3. package/fesm2022/ngx-firebase.mjs.map +1 -0
  4. package/package.json +40 -30
  5. package/types/ngx-firebase.d.ts +55 -0
  6. package/bundles/ngx-firebase-capacitor.umd.js +0 -763
  7. package/bundles/ngx-firebase-capacitor.umd.js.map +0 -1
  8. package/bundles/ngx-firebase-capacitor.umd.min.js +0 -16
  9. package/bundles/ngx-firebase-capacitor.umd.min.js.map +0 -1
  10. package/bundles/ngx-firebase-iap.umd.js +0 -718
  11. package/bundles/ngx-firebase-iap.umd.js.map +0 -1
  12. package/bundles/ngx-firebase-iap.umd.min.js +0 -2
  13. package/bundles/ngx-firebase-iap.umd.min.js.map +0 -1
  14. package/bundles/ngx-firebase-ionic-auth-ui.umd.js +0 -2116
  15. package/bundles/ngx-firebase-ionic-auth-ui.umd.js.map +0 -1
  16. package/bundles/ngx-firebase-ionic-auth-ui.umd.min.js +0 -16
  17. package/bundles/ngx-firebase-ionic-auth-ui.umd.min.js.map +0 -1
  18. package/bundles/ngx-firebase-ionic.umd.js +0 -979
  19. package/bundles/ngx-firebase-ionic.umd.js.map +0 -1
  20. package/bundles/ngx-firebase-ionic.umd.min.js +0 -16
  21. package/bundles/ngx-firebase-ionic.umd.min.js.map +0 -1
  22. package/bundles/ngx-firebase-testing.umd.js +0 -801
  23. package/bundles/ngx-firebase-testing.umd.js.map +0 -1
  24. package/bundles/ngx-firebase-testing.umd.min.js +0 -2
  25. package/bundles/ngx-firebase-testing.umd.min.js.map +0 -1
  26. package/bundles/ngx-firebase.umd.js +0 -2271
  27. package/bundles/ngx-firebase.umd.js.map +0 -1
  28. package/bundles/ngx-firebase.umd.min.js +0 -2
  29. package/bundles/ngx-firebase.umd.min.js.map +0 -1
  30. package/capacitor/capacitor.module.d.ts +0 -9
  31. package/capacitor/interfaces/config.d.ts +0 -12
  32. package/capacitor/interfaces/index.d.ts +0 -1
  33. package/capacitor/ngx-firebase-capacitor.d.ts +0 -5
  34. package/capacitor/ngx-firebase-capacitor.metadata.json +0 -1
  35. package/capacitor/package.json +0 -25
  36. package/capacitor/public-api.d.ts +0 -3
  37. package/capacitor/services/analytics-firebase-capacitor.service.d.ts +0 -9
  38. package/capacitor/services/crashlytics-firebase-capacitor.service.d.ts +0 -8
  39. package/capacitor/services/credential-factory-capacitor.service.d.ts +0 -18
  40. package/capacitor/services/index.d.ts +0 -3
  41. package/esm2015/capacitor/capacitor.module.js +0 -78
  42. package/esm2015/capacitor/interfaces/config.js +0 -3
  43. package/esm2015/capacitor/interfaces/index.js +0 -2
  44. package/esm2015/capacitor/ngx-firebase-capacitor.js +0 -6
  45. package/esm2015/capacitor/public-api.js +0 -4
  46. package/esm2015/capacitor/services/analytics-firebase-capacitor.service.js +0 -43
  47. package/esm2015/capacitor/services/crashlytics-firebase-capacitor.service.js +0 -40
  48. package/esm2015/capacitor/services/credential-factory-capacitor.service.js +0 -182
  49. package/esm2015/capacitor/services/index.js +0 -4
  50. package/esm2015/iap/iap.module.js +0 -32
  51. package/esm2015/iap/interfaces/index.js +0 -5
  52. package/esm2015/iap/ngx-firebase-iap.js +0 -5
  53. package/esm2015/iap/public-api.js +0 -5
  54. package/esm2015/iap/services/iap.service.js +0 -317
  55. package/esm2015/iap/tokens/index.js +0 -4
  56. package/esm2015/ionic/animations/index.js +0 -30
  57. package/esm2015/ionic/components/avatar/avatar.component.js +0 -98
  58. package/esm2015/ionic/components/avatar/index.js +0 -2
  59. package/esm2015/ionic/components/index.js +0 -3
  60. package/esm2015/ionic/components/popover-menu/index.js +0 -3
  61. package/esm2015/ionic/components/popover-menu/interface.js +0 -2
  62. package/esm2015/ionic/components/popover-menu/popover-menu.component.js +0 -34
  63. package/esm2015/ionic/ionic.module.js +0 -46
  64. package/esm2015/ionic/ngx-firebase-ionic.js +0 -5
  65. package/esm2015/ionic/public-api.js +0 -5
  66. package/esm2015/ionic/services/alerts-ionic.service.js +0 -107
  67. package/esm2015/ionic/services/index.js +0 -6
  68. package/esm2015/ionic/services/legality-dialog-ionic.service.js +0 -85
  69. package/esm2015/ionic/services/loading-ionic.service.js +0 -46
  70. package/esm2015/ionic/services/picker-ionic.service.js +0 -44
  71. package/esm2015/ionic/services/toast-ionic.service.js +0 -49
  72. package/esm2015/ionic-auth-ui/animations/index.js +0 -30
  73. package/esm2015/ionic-auth-ui/components/email-confirmation/email-confirmation.component.js +0 -99
  74. package/esm2015/ionic-auth-ui/components/email-field/email-field.component.js +0 -25
  75. package/esm2015/ionic-auth-ui/components/form-field/form-field.component.js +0 -82
  76. package/esm2015/ionic-auth-ui/components/index.js +0 -12
  77. package/esm2015/ionic-auth-ui/components/name-field/name-field.component.js +0 -30
  78. package/esm2015/ionic-auth-ui/components/or-divider/or-divider.component.js +0 -11
  79. package/esm2015/ionic-auth-ui/components/password-field/password-field.component.js +0 -138
  80. package/esm2015/ionic-auth-ui/components/password-field/passwordValidatorFunctions.js +0 -62
  81. package/esm2015/ionic-auth-ui/components/providers/providers.component.js +0 -70
  82. package/esm2015/ionic-auth-ui/components/reauthenticate/reauthenticate.component.js +0 -99
  83. package/esm2015/ionic-auth-ui/components/register/register.component.js +0 -142
  84. package/esm2015/ionic-auth-ui/components/register-with-email/register-with-email.component.js +0 -60
  85. package/esm2015/ionic-auth-ui/components/register-with-email-popover/register-with-email-popover.component.js +0 -26
  86. package/esm2015/ionic-auth-ui/components/signin/signin.component.js +0 -92
  87. package/esm2015/ionic-auth-ui/components/terms-field/terms-field.component.js +0 -99
  88. package/esm2015/ionic-auth-ui/components/user/user.component.js +0 -195
  89. package/esm2015/ionic-auth-ui/ionic-auth-ui.module.js +0 -92
  90. package/esm2015/ionic-auth-ui/ngx-firebase-ionic-auth-ui.js +0 -23
  91. package/esm2015/ionic-auth-ui/pages/index.js +0 -5
  92. package/esm2015/ionic-auth-ui/pages/register/index.js +0 -2
  93. package/esm2015/ionic-auth-ui/pages/register/register.page.js +0 -56
  94. package/esm2015/ionic-auth-ui/pages/signin/index.js +0 -2
  95. package/esm2015/ionic-auth-ui/pages/signin/signin.page.js +0 -78
  96. package/esm2015/ionic-auth-ui/pages/user/index.js +0 -2
  97. package/esm2015/ionic-auth-ui/pages/user/user.page.js +0 -11
  98. package/esm2015/ionic-auth-ui/pages/verifyemail/index.js +0 -2
  99. package/esm2015/ionic-auth-ui/pages/verifyemail/verifyemail.page.js +0 -85
  100. package/esm2015/ionic-auth-ui/public-api.js +0 -5
  101. package/esm2015/ngx-firebase.js +0 -6
  102. package/esm2015/public-api.js +0 -6
  103. package/esm2015/shared/guards/index.js +0 -3
  104. package/esm2015/shared/guards/logged-in.guard.js +0 -60
  105. package/esm2015/shared/guards/verify-email.guard.js +0 -41
  106. package/esm2015/shared/interfaces/accounts.enum.js +0 -9
  107. package/esm2015/shared/interfaces/authprovider.enum.js +0 -15
  108. package/esm2015/shared/interfaces/config.interface.js +0 -61
  109. package/esm2015/shared/interfaces/index.js +0 -8
  110. package/esm2015/shared/interfaces/main.interface.js +0 -7
  111. package/esm2015/shared/interfaces/providers.interface.js +0 -2
  112. package/esm2015/shared/interfaces/tokens.js +0 -19
  113. package/esm2015/shared/interfaces/ui-providers.interface.js +0 -2
  114. package/esm2015/shared/services/analytics.service.js +0 -24
  115. package/esm2015/shared/services/auth-process.service.js +0 -752
  116. package/esm2015/shared/services/crashlytics.service.js +0 -42
  117. package/esm2015/shared/services/device-info.service.js +0 -14
  118. package/esm2015/shared/services/firebase.service.js +0 -37
  119. package/esm2015/shared/services/firestore-sync.service.js +0 -60
  120. package/esm2015/shared/services/index.js +0 -10
  121. package/esm2015/shared/services/performance.service.js +0 -28
  122. package/esm2015/shared/services/remoteconfig.service.js +0 -49
  123. package/esm2015/shared/services/ui.service.js +0 -45
  124. package/esm2015/shared/shared.module.js +0 -175
  125. package/esm2015/shared/types/DisplayWidth.js +0 -9
  126. package/esm2015/shared/types/Location.js +0 -2
  127. package/esm2015/shared/types/ValueAccessorControlComponent.js +0 -85
  128. package/esm2015/shared/types/ValueAccessorValueComponent.js +0 -40
  129. package/esm2015/shared/types/index.js +0 -5
  130. package/esm2015/testing/fakeavatar.module.js +0 -22
  131. package/esm2015/testing/fakes/FakeAuthProcessService.js +0 -31
  132. package/esm2015/testing/fakes/FakeAvatarComponent.js +0 -13
  133. package/esm2015/testing/fakes/FakeFireService.js +0 -21
  134. package/esm2015/testing/fakes/FakeFirestoreSyncService.js +0 -11
  135. package/esm2015/testing/fakes/FakeIAPurchaseService.js +0 -11
  136. package/esm2015/testing/fakes/FakePickerService.js +0 -9
  137. package/esm2015/testing/fakes/FakeRemoteConfigService.js +0 -44
  138. package/esm2015/testing/fakes/FakeTranslateService.js +0 -21
  139. package/esm2015/testing/fakes/FakeUiService.js +0 -26
  140. package/esm2015/testing/fakes/angular-fire/FakeAngularFireAuth.js +0 -30
  141. package/esm2015/testing/fakes/angular-fire/FakeAngularFireFunctions.js +0 -17
  142. package/esm2015/testing/fakes/angular-fire/FakeAngularFirePerformance.js +0 -17
  143. package/esm2015/testing/fakes/angular-fire/FakeAngularFireStorage.js +0 -8
  144. package/esm2015/testing/fakes/angular-fire/FakeAngularFirestore.js +0 -8
  145. package/esm2015/testing/fakes/angular-fire/FakeUserCredential.js +0 -18
  146. package/esm2015/testing/fakes/index.js +0 -19
  147. package/esm2015/testing/ngx-firebase-testing.js +0 -6
  148. package/esm2015/testing/public-api.js +0 -5
  149. package/esm2015/testing/test.module.js +0 -66
  150. package/esm2015/testing/utils/index.js +0 -17
  151. package/esm2015/testing/utils/patchConsole.js +0 -14
  152. package/fesm2015/ngx-firebase-capacitor.js +0 -328
  153. package/fesm2015/ngx-firebase-capacitor.js.map +0 -1
  154. package/fesm2015/ngx-firebase-iap.js +0 -354
  155. package/fesm2015/ngx-firebase-iap.js.map +0 -1
  156. package/fesm2015/ngx-firebase-ionic-auth-ui.js +0 -1482
  157. package/fesm2015/ngx-firebase-ionic-auth-ui.js.map +0 -1
  158. package/fesm2015/ngx-firebase-ionic.js +0 -495
  159. package/fesm2015/ngx-firebase-ionic.js.map +0 -1
  160. package/fesm2015/ngx-firebase-testing.js +0 -388
  161. package/fesm2015/ngx-firebase-testing.js.map +0 -1
  162. package/fesm2015/ngx-firebase.js +0 -1482
  163. package/fesm2015/ngx-firebase.js.map +0 -1
  164. package/iap/iap.module.d.ts +0 -5
  165. package/iap/interfaces/index.d.ts +0 -11
  166. package/iap/ngx-firebase-iap.d.ts +0 -4
  167. package/iap/ngx-firebase-iap.metadata.json +0 -1
  168. package/iap/package.json +0 -23
  169. package/iap/public-api.d.ts +0 -4
  170. package/iap/services/iap.service.d.ts +0 -47
  171. package/iap/tokens/index.d.ts +0 -3
  172. package/ionic/animations/index.d.ts +0 -1
  173. package/ionic/components/avatar/avatar.component.d.ts +0 -27
  174. package/ionic/components/avatar/index.d.ts +0 -1
  175. package/ionic/components/index.d.ts +0 -2
  176. package/ionic/components/popover-menu/index.d.ts +0 -2
  177. package/ionic/components/popover-menu/interface.d.ts +0 -6
  178. package/ionic/components/popover-menu/popover-menu.component.d.ts +0 -10
  179. package/ionic/ionic.module.d.ts +0 -2
  180. package/ionic/ngx-firebase-ionic.d.ts +0 -4
  181. package/ionic/ngx-firebase-ionic.metadata.json +0 -1
  182. package/ionic/package.json +0 -30
  183. package/ionic/public-api.d.ts +0 -4
  184. package/ionic/services/alerts-ionic.service.d.ts +0 -13
  185. package/ionic/services/index.d.ts +0 -5
  186. package/ionic/services/legality-dialog-ionic.service.d.ts +0 -10
  187. package/ionic/services/loading-ionic.service.d.ts +0 -17
  188. package/ionic/services/picker-ionic.service.d.ts +0 -9
  189. package/ionic/services/toast-ionic.service.d.ts +0 -11
  190. package/ionic-auth-ui/animations/index.d.ts +0 -1
  191. package/ionic-auth-ui/components/email-confirmation/email-confirmation.component.d.ts +0 -31
  192. package/ionic-auth-ui/components/email-field/email-field.component.d.ts +0 -7
  193. package/ionic-auth-ui/components/form-field/form-field.component.d.ts +0 -28
  194. package/ionic-auth-ui/components/index.d.ts +0 -11
  195. package/ionic-auth-ui/components/name-field/name-field.component.d.ts +0 -8
  196. package/ionic-auth-ui/components/or-divider/or-divider.component.d.ts +0 -2
  197. package/ionic-auth-ui/components/password-field/password-field.component.d.ts +0 -34
  198. package/ionic-auth-ui/components/password-field/passwordValidatorFunctions.d.ts +0 -4
  199. package/ionic-auth-ui/components/providers/providers.component.d.ts +0 -26
  200. package/ionic-auth-ui/components/reauthenticate/reauthenticate.component.d.ts +0 -30
  201. package/ionic-auth-ui/components/register/register.component.d.ts +0 -26
  202. package/ionic-auth-ui/components/register-with-email/register-with-email.component.d.ts +0 -24
  203. package/ionic-auth-ui/components/register-with-email-popover/register-with-email-popover.component.d.ts +0 -7
  204. package/ionic-auth-ui/components/signin/signin.component.d.ts +0 -28
  205. package/ionic-auth-ui/components/terms-field/terms-field.component.d.ts +0 -27
  206. package/ionic-auth-ui/components/user/user.component.d.ts +0 -45
  207. package/ionic-auth-ui/ionic-auth-ui.module.d.ts +0 -32
  208. package/ionic-auth-ui/ngx-firebase-ionic-auth-ui.d.ts +0 -22
  209. package/ionic-auth-ui/ngx-firebase-ionic-auth-ui.metadata.json +0 -1
  210. package/ionic-auth-ui/package.json +0 -30
  211. package/ionic-auth-ui/pages/index.d.ts +0 -4
  212. package/ionic-auth-ui/pages/register/index.d.ts +0 -1
  213. package/ionic-auth-ui/pages/register/register.page.d.ts +0 -16
  214. package/ionic-auth-ui/pages/signin/index.d.ts +0 -1
  215. package/ionic-auth-ui/pages/signin/signin.page.d.ts +0 -22
  216. package/ionic-auth-ui/pages/user/index.d.ts +0 -1
  217. package/ionic-auth-ui/pages/user/user.page.d.ts +0 -3
  218. package/ionic-auth-ui/pages/verifyemail/index.d.ts +0 -1
  219. package/ionic-auth-ui/pages/verifyemail/verifyemail.page.d.ts +0 -19
  220. package/ionic-auth-ui/public-api.d.ts +0 -4
  221. package/ngx-firebase.d.ts +0 -5
  222. package/ngx-firebase.metadata.json +0 -1
  223. package/public-api.d.ts +0 -5
  224. package/shared/guards/index.d.ts +0 -2
  225. package/shared/guards/logged-in.guard.d.ts +0 -13
  226. package/shared/guards/verify-email.guard.d.ts +0 -11
  227. package/shared/interfaces/accounts.enum.d.ts +0 -7
  228. package/shared/interfaces/authprovider.enum.d.ts +0 -13
  229. package/shared/interfaces/config.interface.d.ts +0 -63
  230. package/shared/interfaces/index.d.ts +0 -7
  231. package/shared/interfaces/main.interface.d.ts +0 -13
  232. package/shared/interfaces/providers.interface.d.ts +0 -63
  233. package/shared/interfaces/tokens.d.ts +0 -16
  234. package/shared/interfaces/ui-providers.interface.d.ts +0 -65
  235. package/shared/services/analytics.service.d.ts +0 -10
  236. package/shared/services/auth-process.service.d.ts +0 -172
  237. package/shared/services/crashlytics.service.d.ts +0 -11
  238. package/shared/services/device-info.service.d.ts +0 -3
  239. package/shared/services/firebase.service.d.ts +0 -16
  240. package/shared/services/firestore-sync.service.d.ts +0 -16
  241. package/shared/services/index.d.ts +0 -9
  242. package/shared/services/performance.service.d.ts +0 -12
  243. package/shared/services/remoteconfig.service.d.ts +0 -18
  244. package/shared/services/ui.service.d.ts +0 -22
  245. package/shared/shared.module.d.ts +0 -14
  246. package/shared/types/DisplayWidth.d.ts +0 -7
  247. package/shared/types/Location.d.ts +0 -8
  248. package/shared/types/ValueAccessorControlComponent.d.ts +0 -27
  249. package/shared/types/ValueAccessorValueComponent.d.ts +0 -19
  250. package/shared/types/index.d.ts +0 -4
  251. package/testing/fakeavatar.module.d.ts +0 -2
  252. package/testing/fakes/FakeAuthProcessService.d.ts +0 -28
  253. package/testing/fakes/FakeAvatarComponent.d.ts +0 -3
  254. package/testing/fakes/FakeFireService.d.ts +0 -20
  255. package/testing/fakes/FakeFirestoreSyncService.d.ts +0 -9
  256. package/testing/fakes/FakeIAPurchaseService.d.ts +0 -9
  257. package/testing/fakes/FakePickerService.d.ts +0 -6
  258. package/testing/fakes/FakeRemoteConfigService.d.ts +0 -19
  259. package/testing/fakes/FakeTranslateService.d.ts +0 -15
  260. package/testing/fakes/FakeUiService.d.ts +0 -25
  261. package/testing/fakes/angular-fire/FakeAngularFireAuth.d.ts +0 -52
  262. package/testing/fakes/angular-fire/FakeAngularFireFunctions.d.ts +0 -11
  263. package/testing/fakes/angular-fire/FakeAngularFirePerformance.d.ts +0 -10
  264. package/testing/fakes/angular-fire/FakeAngularFireStorage.d.ts +0 -5
  265. package/testing/fakes/angular-fire/FakeAngularFirestore.d.ts +0 -5
  266. package/testing/fakes/angular-fire/FakeUserCredential.d.ts +0 -9
  267. package/testing/fakes/index.d.ts +0 -16
  268. package/testing/ngx-firebase-testing.d.ts +0 -5
  269. package/testing/ngx-firebase-testing.metadata.json +0 -1
  270. package/testing/package.json +0 -29
  271. package/testing/public-api.d.ts +0 -4
  272. package/testing/test.module.d.ts +0 -4
  273. package/testing/utils/index.d.ts +0 -5
  274. package/testing/utils/patchConsole.d.ts +0 -4
@@ -1,1482 +0,0 @@
1
- import { ɵɵdefineInjectable, Injectable, ɵɵinject, INJECTOR, Optional, Injector, InjectionToken, Inject, forwardRef, EventEmitter, Input, Output, isDevMode, NgZone, PLATFORM_ID, NgModule } from '@angular/core';
2
- import { __awaiter } from 'tslib';
3
- import { DEFAULTS, mapToObject, AngularFireRemoteConfig, SETTINGS } from '@angular/fire/remote-config';
4
- import { of, BehaviorSubject, Subject, Observable, ReplaySubject } from 'rxjs';
5
- import { AngularFirePerformance, DATA_COLLECTION_ENABLED, INSTRUMENTATION_ENABLED } from '@angular/fire/performance';
6
- import { AngularFirestore, AngularFirestoreModule, USE_EMULATOR as USE_EMULATOR$1 } from '@angular/fire/firestore';
7
- import { map, distinctUntilChanged, filter, take, takeUntil } from 'rxjs/operators';
8
- import { firebase } from '@firebase/app';
9
- import 'firebase/auth';
10
- import { AngularFireAuth, AngularFireAuthModule, USE_EMULATOR } from '@angular/fire/auth';
11
- import { NgControl } from '@angular/forms';
12
- import { Router } from '@angular/router';
13
- import { HttpClientModule } from '@angular/common/http';
14
- import { TranslateModule } from '@ngx-translate/core';
15
- import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, FirebaseApp, AngularFireModule } from '@angular/fire';
16
- import { AngularFireFunctionsModule, USE_EMULATOR as USE_EMULATOR$2, REGION } from '@angular/fire/functions';
17
-
18
- class MalDeviceInfoService {
19
- get dateFormat() {
20
- return 'dd/MM/yyyy';
21
- }
22
- }
23
- MalDeviceInfoService.ɵprov = ɵɵdefineInjectable({ factory: function MalDeviceInfoService_Factory() { return new MalDeviceInfoService(); }, token: MalDeviceInfoService, providedIn: "root" });
24
- MalDeviceInfoService.decorators = [
25
- { type: Injectable, args: [{
26
- providedIn: 'root',
27
- },] }
28
- ];
29
-
30
- class StaticValue {
31
- constructor(value) {
32
- this.value = value;
33
- }
34
- asBoolean() { return this.value; }
35
- asString() { return this.value; }
36
- asNumber() { return this.value; }
37
- getSource() { return 'static'; }
38
- }
39
- class RemoteConfigService {
40
- constructor(remoteConfigProvider, injector) {
41
- this.injector = injector;
42
- this.defaults = this.injector.get(DEFAULTS) || {};
43
- this.remoteConfig$ = of(this.defaults);
44
- this.parameters = of([]);
45
- if (remoteConfigProvider) {
46
- this.getBoolean = remoteConfigProvider.getBoolean;
47
- this.getNumber = remoteConfigProvider.getNumber;
48
- this.getString = remoteConfigProvider.getString;
49
- this.getValue = remoteConfigProvider.getValue;
50
- this.remoteConfig$ = remoteConfigProvider.parameters.pipe(mapToObject(this.defaults));
51
- }
52
- }
53
- getBoolean(key) {
54
- return __awaiter(this, void 0, void 0, function* () { return (yield this.getValue(key)).asBoolean(); });
55
- }
56
- getNumber(key) {
57
- return __awaiter(this, void 0, void 0, function* () { return (yield this.getValue(key)).asNumber(); });
58
- }
59
- getString(key) {
60
- return __awaiter(this, void 0, void 0, function* () { return (yield this.getValue(key)).asString(); });
61
- }
62
- getValue(key) { return Promise.resolve(new StaticValue(this.defaults[key])); }
63
- }
64
- RemoteConfigService.ɵprov = ɵɵdefineInjectable({ factory: function RemoteConfigService_Factory() { return new RemoteConfigService(ɵɵinject(AngularFireRemoteConfig, 8), ɵɵinject(INJECTOR)); }, token: RemoteConfigService, providedIn: "root" });
65
- RemoteConfigService.decorators = [
66
- { type: Injectable, args: [{ providedIn: 'root' },] }
67
- ];
68
- RemoteConfigService.ctorParameters = () => [
69
- { type: AngularFireRemoteConfig, decorators: [{ type: Optional }] },
70
- { type: Injector }
71
- ];
72
-
73
- var AuthProvider;
74
- (function (AuthProvider) {
75
- AuthProvider["ALL"] = "all";
76
- AuthProvider["ANONYMOUS"] = "anonymous";
77
- AuthProvider["EmailAndPassword"] = "firebase";
78
- AuthProvider["Google"] = "google";
79
- AuthProvider["Apple"] = "apple";
80
- AuthProvider["Facebook"] = "facebook";
81
- AuthProvider["Twitter"] = "twitter";
82
- AuthProvider["Github"] = "github";
83
- AuthProvider["Microsoft"] = "microsoft";
84
- AuthProvider["Yahoo"] = "yahoo";
85
- AuthProvider["PhoneNumber"] = "phoneNumber";
86
- })(AuthProvider || (AuthProvider = {}));
87
-
88
- var Accounts;
89
- (function (Accounts) {
90
- Accounts["NONE"] = "account";
91
- Accounts["CHECK"] = "account-check";
92
- Accounts["EDIT"] = "account-edit";
93
- Accounts["OFF"] = "account-off";
94
- Accounts["REMOVE"] = "account-remove";
95
- })(Accounts || (Accounts = {}));
96
-
97
- // import * as firebase from 'firebase';
98
- var MalServiceEnabled;
99
- (function (MalServiceEnabled) {
100
- MalServiceEnabled[MalServiceEnabled["emulate"] = 2] = "emulate";
101
- MalServiceEnabled[MalServiceEnabled["enabled"] = 1] = "enabled";
102
- MalServiceEnabled[MalServiceEnabled["disabled"] = 0] = "disabled";
103
- })(MalServiceEnabled || (MalServiceEnabled = {}));
104
- const defaultAuthFirebaseUIConfig = {
105
- services: {
106
- firebaseAnalytics: true,
107
- firebaseCrashlytics: true,
108
- firebasePerformance: true,
109
- firebaseRemoteConfig: true,
110
- inAppPurchase: true,
111
- firebaseAuth: true,
112
- firebaseFirestore: true,
113
- firebaseFunctions: true
114
- },
115
- authUi: {
116
- enableFirestoreSync: true,
117
- toastMessageOnAuthSuccess: true,
118
- toastMessageOnAuthError: true,
119
- toastDefaultDurationMil: 3000,
120
- authGuardFallbackURL: '/',
121
- authGuardLoggedInURL: '/',
122
- authGuardVerifyEmailURL: undefined,
123
- reSignInUrl: '/auth/signin',
124
- // Password length min/max in forms independently of each componenet min/max.
125
- // `min/max` input parameters in components should be within this range.
126
- passwordMaxLength: 60,
127
- passwordMinLength: 8,
128
- passwordRequireLowercase: true,
129
- passwordRequireUppercase: true,
130
- passwordRequireSpecial: true,
131
- passwordRequireNumbers: true,
132
- // Same as password but for the name
133
- nameMaxLength: 50,
134
- nameMinLength: 2,
135
- supportedProviders: AuthProvider.ALL,
136
- guestEnabled: false,
137
- allowAccountEdit: true,
138
- allowAccountDelete: true,
139
- allowAccountLogout: true,
140
- // If set, sign-in/up form is not available until email has been verified.
141
- // Plus protected routes are still protected even though user is connected.
142
- guardProtectedRoutesUntilEmailIsVerified: true,
143
- // Default to email verification on
144
- enableEmailVerification: true
145
- }
146
- };
147
- // Merge default config with user provided config.
148
- function malSharedConfigFactory(userProvidedConfig) {
149
- return {
150
- firebase: userProvidedConfig.firebase,
151
- services: Object.assign({}, defaultAuthFirebaseUIConfig.services, userProvidedConfig.services || {}),
152
- authUi: Object.assign({}, defaultAuthFirebaseUIConfig.authUi, userProvidedConfig.authUi || {}),
153
- configDefaults: userProvidedConfig.configDefaults || {}
154
- };
155
- }
156
-
157
- // tslint:disable-next-line max-len
158
- const PHONE_NUMBER_REGEX = new RegExp(['^[+]{0,1}[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\.]{0,1}[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\./0-9]{4,12}$'].join(''));
159
- var FirebaseErrorCodes;
160
- (function (FirebaseErrorCodes) {
161
- FirebaseErrorCodes["requiresRecentLogin"] = "auth/requires-recent-login";
162
- })(FirebaseErrorCodes || (FirebaseErrorCodes = {}));
163
-
164
- // This token is the official token containing the final configuration; ie. the merge between default and user provided configurations
165
- // Firebase Functional Areas
166
- const MalAnalyticsProviderToken = new InjectionToken('MalAnalyticsProviderToken');
167
- const MalCrashlyticsProviderToken = new InjectionToken('MalCrashlyticsProviderToken');
168
- const MalAuthServiceProviderToken = new InjectionToken('MalAuthServiceProviderToken');
169
- // Auth Process Service
170
- const MalMergeUserServiceToken = new InjectionToken('MalMergeUserServiceToken');
171
- const MalCredentialFactoryProviderToken = new InjectionToken('MalCredentialFactoryProviderToken');
172
- // Configuration
173
- const MalUserProvidedConfigToken = new InjectionToken('MalUserProvidedConfigToken');
174
- const MalSharedConfigToken = new InjectionToken('MalSharedConfigToken');
175
- // UI Providers
176
- const MalLoadingUIProviderToken = new InjectionToken('MalLoadingUIProviderToken');
177
- const MalAlertsUIProviderToken = new InjectionToken('MalAlertsUIProviderToken');
178
- const MalPickerUIProviderToken = new InjectionToken('MalPickerMalPickerUIProviderTokenUIProvider');
179
- const MalToastUIProviderToken = new InjectionToken('MalToastUIProviderToken');
180
- const MalLegaliyDialogUIProiderToken = new InjectionToken("MalLegaliyDialogUIProiderToken");
181
-
182
- class AnalyticsService {
183
- constructor(analytics) {
184
- this.analytics = analytics;
185
- // Analytics NoOp
186
- this.logEvent = (name, params) => __awaiter(this, void 0, void 0, function* () { console.log('NotLogged:LogEvent ' + name, params); });
187
- this.setScreenName = (screenName, screenClass) => Promise.resolve();
188
- this.setUserId = (userId) => { };
189
- if (this.analytics) {
190
- this.logEvent = this.analytics.logEvent;
191
- this.setScreenName = this.analytics.setScreenName;
192
- this.setUserId = this.analytics.setUserId;
193
- }
194
- }
195
- }
196
- AnalyticsService.decorators = [
197
- { type: Injectable }
198
- ];
199
- AnalyticsService.ctorParameters = () => [
200
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [forwardRef(() => MalAnalyticsProviderToken),] }] }
201
- ];
202
-
203
- class CrashlyticsService {
204
- constructor(crashlyticsProvider) {
205
- this.crashlyticsProvider = crashlyticsProvider;
206
- // Crashlyitcs
207
- this._recordException = (_options) => Promise.resolve();
208
- this._addLogMessage = (message) => Promise.resolve();
209
- this._setUserId = (uid) => { };
210
- if (this.crashlyticsProvider) {
211
- this._recordException = this.crashlyticsProvider.recordException;
212
- this._addLogMessage = this.crashlyticsProvider.addLogMessage;
213
- }
214
- }
215
- setUserId(uid) {
216
- this._setUserId(uid);
217
- }
218
- recordException(options) {
219
- let e = { message: 'An unknown error occured' };
220
- if ('string' === typeof options) {
221
- e.message = options;
222
- }
223
- else if (options instanceof Error) {
224
- e.message = options.message;
225
- }
226
- else if (e.message) {
227
- e = options;
228
- }
229
- return this._recordException(e);
230
- }
231
- addLogMessage(message) {
232
- console.log('addLogMessage ' + message);
233
- return this._addLogMessage(message);
234
- }
235
- }
236
- CrashlyticsService.decorators = [
237
- { type: Injectable }
238
- ];
239
- CrashlyticsService.ctorParameters = () => [
240
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [forwardRef(() => MalCrashlyticsProviderToken),] }] }
241
- ];
242
-
243
- class PerformanceTraceNoop {
244
- start() { }
245
- stop() { }
246
- putAttribute(key, value) { }
247
- }
248
- class PerformanceService {
249
- constructor(performanceProvider) {
250
- this.dataCollectionEnabled = Promise.resolve(false);
251
- if (performanceProvider) {
252
- this.createTrace = performanceProvider.trace;
253
- }
254
- }
255
- createTrace(label) {
256
- return Promise.resolve(new PerformanceTraceNoop());
257
- }
258
- }
259
- PerformanceService.ɵprov = ɵɵdefineInjectable({ factory: function PerformanceService_Factory() { return new PerformanceService(ɵɵinject(AngularFirePerformance, 8)); }, token: PerformanceService, providedIn: "root" });
260
- PerformanceService.decorators = [
261
- { type: Injectable, args: [{ providedIn: 'root' },] }
262
- ];
263
- PerformanceService.ctorParameters = () => [
264
- { type: AngularFirePerformance, decorators: [{ type: Optional }] }
265
- ];
266
-
267
- class FirebaseService {
268
- constructor(crashlyticsService, analyticsService, performanceService) {
269
- this.crashlyticsService = crashlyticsService;
270
- this.analyticsService = analyticsService;
271
- this.performanceService = performanceService;
272
- this.recordException = this.crashlyticsService.recordException.bind(this.crashlyticsService);
273
- this.addLogMessage = this.crashlyticsService.addLogMessage.bind(this.crashlyticsService);
274
- this.setScreenName = this.analyticsService.setScreenName.bind(this.analyticsService);
275
- this.logEvent = this.analyticsService.logEvent.bind(this.analyticsService);
276
- this.createTrace = this.performanceService.createTrace;
277
- }
278
- setUserId(userId) {
279
- return __awaiter(this, void 0, void 0, function* () {
280
- this.analyticsService.setUserId(userId);
281
- this.crashlyticsService.setUserId(userId);
282
- });
283
- }
284
- }
285
- FirebaseService.ɵprov = ɵɵdefineInjectable({ factory: function FirebaseService_Factory() { return new FirebaseService(ɵɵinject(CrashlyticsService), ɵɵinject(AnalyticsService), ɵɵinject(PerformanceService)); }, token: FirebaseService, providedIn: "root" });
286
- FirebaseService.decorators = [
287
- { type: Injectable, args: [{ providedIn: 'root' },] }
288
- ];
289
- FirebaseService.ctorParameters = () => [
290
- { type: CrashlyticsService },
291
- { type: AnalyticsService },
292
- { type: PerformanceService }
293
- ];
294
-
295
- const USER_COLLECTION = '/users';
296
- class FirestoreSyncService {
297
- constructor(afs, fire) {
298
- this.afs = afs;
299
- this.fire = fire;
300
- }
301
- getUserData(uid) {
302
- return __awaiter(this, void 0, void 0, function* () {
303
- try {
304
- const doc = yield this.getUserDocRefByUID(uid).get().toPromise();
305
- return doc.data() || null;
306
- }
307
- catch (error) {
308
- this.fire.recordException(error);
309
- return null;
310
- }
311
- });
312
- }
313
- getUserDocRefByUID(uid) {
314
- return this.afs.doc(`${USER_COLLECTION}/${uid}`);
315
- }
316
- setUserData(uid, user, options) {
317
- return __awaiter(this, void 0, void 0, function* () {
318
- try {
319
- return this.afs.doc(`${USER_COLLECTION}/${uid}`).set(user, options);
320
- }
321
- catch (error) {
322
- this.fire.recordException(error);
323
- }
324
- });
325
- }
326
- updateUserData(uid, user) {
327
- return __awaiter(this, void 0, void 0, function* () {
328
- try {
329
- return this.getUserDocRefByUID(uid).update(Object.assign(Object.assign({}, user), { uid }));
330
- }
331
- catch (error) {
332
- this.fire.recordException(error);
333
- }
334
- });
335
- }
336
- }
337
- FirestoreSyncService.ɵprov = ɵɵdefineInjectable({ factory: function FirestoreSyncService_Factory() { return new FirestoreSyncService(ɵɵinject(AngularFirestore), ɵɵinject(FirebaseService)); }, token: FirestoreSyncService, providedIn: "root" });
338
- FirestoreSyncService.decorators = [
339
- { type: Injectable, args: [{
340
- providedIn: 'root'
341
- },] }
342
- ];
343
- FirestoreSyncService.ctorParameters = () => [
344
- { type: AngularFirestore },
345
- { type: FirebaseService }
346
- ];
347
-
348
- class UiService {
349
- constructor(toastService, alertService, loadingService, legalityDialog, fire) {
350
- this.toastService = toastService;
351
- this.alertService = alertService;
352
- this.loadingService = loadingService;
353
- this.legalityDialog = legalityDialog;
354
- this.fire = fire;
355
- this.toast = this.toastService.toast.bind(this.toastService);
356
- this.createToast = this.toastService.createToast.bind(this.toastService);
357
- this.errorToast = this.toastService.errorToast.bind(this.toastService);
358
- this.okAlert = this.alertService.okAlert.bind(this.alertService);
359
- this.infoAlert = this.alertService.infoAlert.bind(this.alertService);
360
- this.errorAlert = this.alertService.errorAlert.bind(this.alertService);
361
- this.textboxInputAlert = this.alertService.textboxInputAlert.bind(this.alertService);
362
- this.yesNoAlert = this.alertService.yesNoAlert.bind(this.alertService);
363
- this.createLoading = this.loadingService.createLoading.bind(this.loadingService);
364
- this.watchLoading = this.loadingService.watchLoading.bind(this.loadingService);
365
- this.confirmTos = this.legalityDialog.confirmTos.bind(this.legalityDialog);
366
- }
367
- logError(error, messagePrefix) {
368
- console.log(error);
369
- this.fire.recordException(error);
370
- if (messagePrefix !== null) {
371
- this.toastService.errorToast(error, messagePrefix);
372
- }
373
- }
374
- }
375
- UiService.ɵprov = ɵɵdefineInjectable({ factory: function UiService_Factory() { return new UiService(ɵɵinject(MalToastUIProviderToken), ɵɵinject(MalAlertsUIProviderToken), ɵɵinject(MalLoadingUIProviderToken), ɵɵinject(MalLegaliyDialogUIProiderToken), ɵɵinject(FirebaseService)); }, token: UiService, providedIn: "root" });
376
- UiService.decorators = [
377
- { type: Injectable, args: [{ providedIn: 'root' },] }
378
- ];
379
- UiService.ctorParameters = () => [
380
- { type: undefined, decorators: [{ type: Inject, args: [forwardRef(() => MalToastUIProviderToken),] }] },
381
- { type: undefined, decorators: [{ type: Inject, args: [forwardRef(() => MalAlertsUIProviderToken),] }] },
382
- { type: undefined, decorators: [{ type: Inject, args: [forwardRef(() => MalLoadingUIProviderToken),] }] },
383
- { type: undefined, decorators: [{ type: Inject, args: [forwardRef(() => MalLegaliyDialogUIProiderToken),] }] },
384
- { type: FirebaseService }
385
- ];
386
-
387
- class AuthProcessService {
388
- constructor(config, mergeService, credFactory, fireStoreService, afa, // TODO should be private
389
- fire, ui) {
390
- this.config = config;
391
- this.mergeService = mergeService;
392
- this.credFactory = credFactory;
393
- this.fireStoreService = fireStoreService;
394
- this.afa = afa;
395
- this.fire = fire;
396
- this.ui = ui;
397
- this.onErrorEmitter = new EventEmitter();
398
- this.onSignInEmitter = new EventEmitter();
399
- this.onRegisterEmitter = new EventEmitter();
400
- this.onSignOutEmitter = new EventEmitter();
401
- this.onUserUpdatedEmitter = new EventEmitter();
402
- this.onUserDeletedEmitter = new EventEmitter();
403
- this.showProfileDialog = new EventEmitter();
404
- /**
405
- * Useful to know about auth state even between reloads.
406
- *
407
- **/
408
- this._user$ = new BehaviorSubject(null);
409
- this.user$ = this.afa.user;
410
- /**
411
- * Useful to know about auth state even between reloads.
412
- **/
413
- this._authState$ = new BehaviorSubject(null);
414
- this.authState$ = this.afa.authState;
415
- /**
416
- * Obersable for current user - that only emits when the uid changes
417
- * Useful to reset session info when user changes.
418
- */
419
- this.uid$ = this.user$.pipe(map(user => (user === null || user === void 0 ? void 0 : user.uid) || null), distinctUntilChanged());
420
- /**
421
- * UserInterface helper observables - indicating what user actions are currently permitted and
422
- * the current status of authentication.
423
- */
424
- this.isLoggedIn$ = this.user$.pipe(map(user => null !== user));
425
- this.isAnonymous$ = this.user$.pipe(map(user => null !== user && user.isAnonymous));
426
- this.isNamedUser$ = this.user$.pipe(map(user => null !== user && !user.isAnonymous));
427
- this.isNotNamedUser$ = this.user$.pipe(map(user => null === user || user.isAnonymous));
428
- this.canEdit$ = this.isLoggedIn$;
429
- this.canRegister$ = this.isNotNamedUser$;
430
- this.canSignIn$ = this.isLoggedIn$.pipe(map(isLoggedIn => !isLoggedIn));
431
- this.canSignInAsGuest$ = this.isLoggedIn$.pipe(map(isLoggedIn => !isLoggedIn && this.config.authUi.guestEnabled));
432
- this.canSignOut$ = this.isNamedUser$;
433
- /**
434
- * Observable. Emits whenever currentUser signsOut
435
- */
436
- this.onSignOut$ = this.authState$.pipe(filter(user => user === null), map(() => { return; }));
437
- /**
438
- * Observable emits whenever a new user signsIn
439
- */
440
- this.onSignIn$ = this.authState$.pipe(filter(user => null !== user), map(user => user));
441
- this.tokenRefreshed$ = new Subject();
442
- this.afa.user.subscribe(user => this._user$.next(user));
443
- this.afa.authState.subscribe(authState => this._authState$.next(authState));
444
- this.authState$.subscribe(user => {
445
- this.fire.setUserId((user === null || user === void 0 ? void 0 : user.uid) || null);
446
- });
447
- this.onSignOut$.subscribe(() => this.onSignOutEmitter.emit());
448
- }
449
- get user() {
450
- return this._user$.value;
451
- }
452
- get reauthenticateProviders$() {
453
- return this.user$.pipe(map(user => ((user === null || user === void 0 ? void 0 : user.providerData) || [])
454
- .map(item => {
455
- switch (item === null || item === void 0 ? void 0 : item.providerId) {
456
- case 'google.com': return AuthProvider.Google;
457
- default:
458
- console.log('NO MATCH', item);
459
- return;
460
- }
461
- })
462
- .filter(item => !!item)));
463
- }
464
- /**
465
- * Returns true if current platform is webplatform supported by @angular/fire
466
- */
467
- get isWebPlatform() {
468
- return ['https:', 'http:', 'chrome-extension'].includes(location.protocol);
469
- }
470
- /**
471
- * Indicates if the specified provider is supported on the current platform
472
- */
473
- isProviderSupported(provider) {
474
- return __awaiter(this, void 0, void 0, function* () {
475
- return (this.config.authUi.supportedProviders === AuthProvider.ALL || this.config.authUi.supportedProviders.includes(provider))
476
- && (this.isWebPlatform || (this.credFactory && (yield this.credFactory.isProviderSupported(provider))));
477
- });
478
- }
479
- refreshToken() {
480
- return __awaiter(this, void 0, void 0, function* () {
481
- const user = yield this.afa.currentUser;
482
- if (user) {
483
- yield user.getIdToken(true);
484
- yield this.tokenRefreshed$.next();
485
- }
486
- });
487
- }
488
- selectCurrentUserClaim(claim) {
489
- return new Observable(subscriber => {
490
- const handleTokenRefresh = (user) => __awaiter(this, void 0, void 0, function* () {
491
- if (user) {
492
- const token = yield user.getIdTokenResult();
493
- subscriber.next(token.claims[claim]);
494
- }
495
- else {
496
- subscriber.next(null);
497
- }
498
- });
499
- this.tokenRefreshed$.subscribe(() => __awaiter(this, void 0, void 0, function* () {
500
- const user = yield this.afa.currentUser;
501
- yield handleTokenRefresh(user);
502
- }));
503
- this.afa.user.subscribe((user) => __awaiter(this, void 0, void 0, function* () {
504
- yield handleTokenRefresh(user);
505
- }));
506
- });
507
- }
508
- getCurrentUserClaim(claim) {
509
- return this.selectCurrentUserClaim(claim).pipe(take(1)).toPromise();
510
- }
511
- /**
512
- * Reset the password of currently authenticated user via email
513
- *
514
- * @param email - the email to reset
515
- */
516
- resetPassword(email) {
517
- return __awaiter(this, void 0, void 0, function* () {
518
- try {
519
- this.fire.addLogMessage('Password reset email sent');
520
- this.afa.sendPasswordResetEmail(email);
521
- this.ui.toast('auth.resetPassword.onResetRequestedTo', { duration: this.config.authUi.toastDefaultDurationMil, interpolateParams: { email }, position: 'bottom' });
522
- }
523
- catch (error) {
524
- yield this.handleError(error);
525
- }
526
- });
527
- }
528
- /**
529
- * General sign in mechanism to authenticate the users with a firebase project
530
- * using a traditional way, via username and password or by using an authentication provider
531
- * like google, facebook, twitter and github
532
- *
533
- * [Current State -> Target State]
534
- * Null -> Anon/named: OK
535
- * Anon -> Anon: Throws Error
536
- * Anon -> Named: Triggers MergeService
537
- * Named -> Any: Throws Error
538
- *
539
- * @param provider - the provider to authenticate with (google, facebook, twitter, github)
540
- * @param credentials optional email and password
541
- */
542
- signInWith(provider, options) {
543
- return __awaiter(this, void 0, void 0, function* () {
544
- this.fire.addLogMessage(`SignInWithProvider; provider=${provider}`);
545
- const loading = yield this.ui.createLoading();
546
- try {
547
- let userCred = null;
548
- const currentUser = yield this.afa.currentUser;
549
- // Only merge an anonymous user >>> non-anonymous user
550
- // Don't catch any errors, so they are caught by function and trigger a login abort.
551
- let mergeContext = null;
552
- if (currentUser && currentUser.isAnonymous && this.mergeService && provider !== AuthProvider.ANONYMOUS) {
553
- mergeContext = yield this.mergeService.prepareSource(currentUser);
554
- }
555
- switch (provider) {
556
- case AuthProvider.ANONYMOUS:
557
- if (currentUser) {
558
- throw new Error('Cannot signIn anonymously whilst already signedIn, SignOut first');
559
- }
560
- if (yield this.confirmTos(null, options)) {
561
- loading.present();
562
- userCred = yield this.afa.signInAnonymously();
563
- yield loading.dismiss();
564
- yield this.confirmTos(userCred, { skipTosCheck: true }); // Save tosAcceptance in firestore
565
- }
566
- break;
567
- case AuthProvider.EmailAndPassword:
568
- if (currentUser && !currentUser.isAnonymous) {
569
- throw new Error('Cannot signIn whilst already signedIn, SignOut first');
570
- }
571
- if (!(options === null || options === void 0 ? void 0 : options.credentials)) {
572
- throw new Error('Credentials are required when signing in with AuthProvider.EmailAndPassword');
573
- }
574
- loading.present();
575
- userCred = yield this.afa.signInWithEmailAndPassword(options.credentials.email, options.credentials.password);
576
- yield loading.dismiss();
577
- if (!(yield this.confirmTos(userCred, options))) {
578
- yield this.signOut();
579
- userCred = null;
580
- }
581
- ;
582
- break;
583
- case AuthProvider.PhoneNumber:
584
- // coming soon - see feature/sms branch
585
- break;
586
- default:
587
- if (currentUser && !currentUser.isAnonymous) {
588
- throw new Error('Cannot signIn whilst already signedIn, SignOut first');
589
- }
590
- if (this.credFactory && (yield this.credFactory.isProviderSupported(provider))) {
591
- loading.present();
592
- const factoryCred = yield this.credFactory.getCredential(provider);
593
- if (factoryCred) {
594
- userCred = yield this.afa.signInWithCredential(factoryCred);
595
- }
596
- yield loading.dismiss();
597
- }
598
- else if (this.isWebPlatform) {
599
- loading.present();
600
- userCred = yield this.afa.signInWithPopup(this.getAuthProvider(provider));
601
- yield loading.dismiss();
602
- /*
603
- a: null
604
- code: "auth/popup-closed-by-user"
605
- message: "The popup has been closed by the user before finalizing the operation."
606
- __proto__: Error
607
- */
608
- }
609
- else {
610
- throw new Error('A CredentialFactory is required to use AuthProcessService on a non-web platform');
611
- }
612
- yield loading.dismiss();
613
- if (!(yield this.confirmTos(userCred, options))) {
614
- yield this.signOut();
615
- userCred = null;
616
- }
617
- ;
618
- break;
619
- }
620
- // Will be null if user cancels operation
621
- if (userCred) {
622
- yield this.handleSignInSuccess(userCred);
623
- if (userCred.user && mergeContext && this.mergeService) {
624
- try {
625
- yield this.mergeService.applyToTarget(userCred.user, mergeContext);
626
- }
627
- catch (error) {
628
- // If a failure occurs in merge applyToTarget we can't do much about it (we are already logged in as new user)
629
- // but we should at least log it. The onus is really on the applyToTarget function to handle it's own errors.
630
- this.fire.recordException(error);
631
- }
632
- }
633
- this.onSignInEmitter.emit(userCred.user);
634
- }
635
- yield loading.dismiss();
636
- return userCred || null;
637
- }
638
- catch (error) {
639
- // code auth/user-not-found
640
- yield this.handleError(error);
641
- yield loading.dismiss();
642
- return null;
643
- }
644
- });
645
- }
646
- /**
647
- */
648
- reauthenicateWithProvider(provider, options) {
649
- return __awaiter(this, void 0, void 0, function* () {
650
- this.fire.addLogMessage(`reauthenicateWithProvider; provider=${provider}`);
651
- const loading = yield this.ui.createLoading();
652
- try {
653
- let userCred = null;
654
- // Throw error if reauthentication attempted whilst signed in as guest, nor not signed in.
655
- const currentUser = yield this.afa.currentUser;
656
- if (!currentUser || currentUser.isAnonymous) {
657
- throw new Error('Caanot reauthticate if no currentUser or currentUser is anonymous');
658
- }
659
- loading.present();
660
- switch (provider) {
661
- case AuthProvider.ANONYMOUS:
662
- throw new Error('Cannot reauthenticate with anonymous Credentials');
663
- case AuthProvider.EmailAndPassword:
664
- if (!(options === null || options === void 0 ? void 0 : options.credentials)) {
665
- throw new Error('Credentials are required when signing in with AuthProvider.EmailAndPassword');
666
- }
667
- if (!currentUser.email) {
668
- throw new Error('Cannot reauthenticate with email for an account without email');
669
- }
670
- if (!firebase.auth) {
671
- throw new Error('firebase.auth is undefined');
672
- }
673
- this.fire.addLogMessage(`creating email credential with firebase; email=${options.credentials.email}`);
674
- const authCred = firebase.auth.EmailAuthProvider.credential(currentUser.email, options.credentials.password);
675
- userCred = yield currentUser.reauthenticateWithCredential(authCred);
676
- break;
677
- case AuthProvider.PhoneNumber:
678
- // coming soon - see feature/sms branch
679
- break;
680
- default:
681
- if (this.credFactory && (yield this.credFactory.isProviderSupported(provider))) {
682
- const factoryCred = yield this.credFactory.getCredential(provider);
683
- if (factoryCred) {
684
- userCred = yield currentUser.reauthenticateWithCredential(factoryCred);
685
- }
686
- }
687
- else if (this.isWebPlatform) {
688
- userCred = yield currentUser.reauthenticateWithPopup(this.getAuthProvider(provider));
689
- }
690
- else {
691
- throw new Error('A CredentialFactory is required to use AuthProcessService on a non-web platform');
692
- }
693
- break;
694
- }
695
- yield loading.dismiss();
696
- return userCred || null;
697
- }
698
- catch (error) {
699
- // code auth/user-not-found
700
- yield this.handleError(error);
701
- yield loading.dismiss();
702
- return null;
703
- }
704
- });
705
- }
706
- /**
707
- * Link the current user to credentials from another auth provider.
708
- *
709
- * @param provider Provider to link.
710
- */
711
- linkCurrentUserToProvider(provider, options) {
712
- return __awaiter(this, void 0, void 0, function* () {
713
- this.fire.addLogMessage(`Linking current anon user to provider; provider=${provider}`);
714
- const loading = yield this.ui.createLoading();
715
- try {
716
- const currentUser = yield this.afa.currentUser;
717
- if (null === currentUser) {
718
- throw new Error('CurrentUser is null');
719
- }
720
- yield loading.present();
721
- let userCred = null;
722
- switch (provider) {
723
- case AuthProvider.ANONYMOUS:
724
- throw new Error('Linking anonymous user makes no sense');
725
- case AuthProvider.EmailAndPassword:
726
- if (!(options === null || options === void 0 ? void 0 : options.credentials)) {
727
- throw new Error('Credentials required to link to email credentential');
728
- }
729
- if (!firebase.auth) {
730
- throw new Error('firebase.auth is undefined');
731
- }
732
- this.fire.addLogMessage(`creating email credential with firebase; email=${options.credentials.email}`);
733
- const authCred = firebase.auth.EmailAuthProvider.credential(options.credentials.email, options.credentials.password);
734
- this.fire.addLogMessage(`linking userCredential to email authCredential`);
735
- userCred = yield currentUser.linkWithCredential(authCred);
736
- break;
737
- case AuthProvider.PhoneNumber:
738
- throw new Error('Linking phone number not suported');
739
- default:
740
- if (this.credFactory && (yield this.credFactory.isProviderSupported(provider))) {
741
- const factoryCred = yield this.credFactory.getCredential(provider);
742
- if (factoryCred) {
743
- userCred = yield currentUser.linkWithCredential(factoryCred);
744
- }
745
- }
746
- else if (this.isWebPlatform) {
747
- userCred = yield currentUser.linkWithPopup(this.getAuthProvider(provider));
748
- }
749
- else {
750
- throw new Error('A CredentialFactory is required to use AuthProcessService on a non-web platform');
751
- }
752
- }
753
- if (userCred && userCred.user) { // Null if user cancels (or perhaps fails) sign-in
754
- const userData = this.parseUserInfo(userCred.user);
755
- if (userData.displayName
756
- && (userCred.user.displayName !== userData.displayName || userCred.user.photoURL !== userData.displayName)) {
757
- this.fire.addLogMessage(`Updating user profile; displayName=${userData.displayName}, photoUrl=${userData.photoURL}`); // tslint:disable-line max-line-length
758
- yield this.updateUserInfo({ displayName: userData.displayName, photoURL: userData.photoURL });
759
- }
760
- yield this.handleSignInSuccess(userCred);
761
- }
762
- yield loading.dismiss();
763
- return userCred || null;
764
- }
765
- catch (error) {
766
- // Merge
767
- yield this.handleError(error);
768
- yield loading.dismiss();
769
- return null;
770
- }
771
- });
772
- }
773
- /**
774
- * Creates a firebase user account authenticated with the specified provider.
775
- * If AuthProvider.EmailAndPassword is specified credentials and displayname must also be provided.
776
- */
777
- registerWith(provider, options) {
778
- return __awaiter(this, void 0, void 0, function* () {
779
- this.fire.addLogMessage(`SigningUp with provider; provider=${provider}`);
780
- const loading = yield this.ui.createLoading();
781
- try {
782
- // If the current user is anonymous - link the credentials to the existing user.
783
- // Otherwise if the user is logged in un-Anonymously, throw error
784
- const currentUser = yield this.afa.currentUser;
785
- if (currentUser === null || currentUser === void 0 ? void 0 : currentUser.isAnonymous) { // Anonymous User
786
- return this.linkCurrentUserToProvider(provider, options);
787
- }
788
- else if (null !== currentUser) { // Non-Anonymous User
789
- throw new Error('Cannot Register whilst signed in as a non-Anonymous user. SignOut first');
790
- }
791
- else if (!(yield this.confirmTos(null, options))) { // No current user
792
- this.fire.addLogMessage('User declined TOS during register');
793
- return null;
794
- }
795
- let userCred = null;
796
- switch (provider) {
797
- case AuthProvider.EmailAndPassword:
798
- if (!(options === null || options === void 0 ? void 0 : options.credentials) || !(options === null || options === void 0 ? void 0 : options.displayName)) {
799
- throw new Error('Credentials & displayName required to SignUp by email');
800
- }
801
- yield loading.present();
802
- this.fire.addLogMessage(`creaating user with email and password; email=${options.credentials.email}`);
803
- userCred = yield this.afa.createUserWithEmailAndPassword(options.credentials.email, options.credentials.password);
804
- if (null === userCred.user) {
805
- throw new Error('User is null following successful signUp');
806
- }
807
- yield this.updateUserInfo({ displayName: options.displayName });
808
- yield this.confirmTos(userCred, { skipTosCheck: true }); // To save the tosAcceptance
809
- if (this.config.authUi.enableEmailVerification) {
810
- yield userCred.user.sendEmailVerification();
811
- }
812
- // Legacy fields
813
- this.emailConfirmationSent = true;
814
- this.emailToConfirm = userCred.user.email || undefined;
815
- yield this.handleSignInSuccess(userCred);
816
- yield loading.dismiss();
817
- break;
818
- default:
819
- userCred = yield this.signInWith(provider, Object.assign(Object.assign({}, options), { skipTosCheck: true }));
820
- }
821
- if (userCred.user) {
822
- this.onRegisterEmitter.emit(userCred.user);
823
- }
824
- return userCred || null;
825
- }
826
- catch (error) {
827
- // This is where I would handle merge
828
- yield this.handleError(error);
829
- yield loading.dismiss();
830
- return null;
831
- }
832
- });
833
- }
834
- /**
835
- * Present dialog and confirm the user agress to the privacy policy and terms of service (if either configured).
836
- * If nether configured returns true;
837
- *
838
- * @returns True if either user agrees to TOS/PrivacyUrl || no TOS/PrivacyUrl configured.
839
- */
840
- confirmTos(userCred = null, options = {}) {
841
- var _a;
842
- return __awaiter(this, void 0, void 0, function* () {
843
- if (this.config.authUi.tosUrl || this.config.authUi.privacyPolicyUrl) {
844
- let acceptedTos = (options.skipTosCheck) ? new Date().toISOString() : null;
845
- if (!acceptedTos && (userCred === null || userCred === void 0 ? void 0 : userCred.user) && !((_a = userCred === null || userCred === void 0 ? void 0 : userCred.additionalUserInfo) === null || _a === void 0 ? void 0 : _a.isNewUser) && this.config.authUi.enableFirestoreSync) {
846
- const userData = yield this.fireStoreService.getUserData(userCred.user.uid);
847
- acceptedTos = (userData === null || userData === void 0 ? void 0 : userData.acceptedTos) || null;
848
- }
849
- if (!acceptedTos && (yield this.ui.confirmTos())) {
850
- acceptedTos = new Date().toISOString();
851
- }
852
- if ((userCred === null || userCred === void 0 ? void 0 : userCred.user) && this.config.authUi.enableFirestoreSync) {
853
- yield this.fireStoreService.setUserData(userCred.user.uid, { acceptedTos }, { merge: true });
854
- }
855
- return !!acceptedTos;
856
- }
857
- else { // No tosUrl || privacyPolicyUrl
858
- return true;
859
- }
860
- });
861
- }
862
- /**
863
- * Send the currently authenticated user another verficiation email.
864
- */
865
- sendNewVerificationEmail() {
866
- return __awaiter(this, void 0, void 0, function* () {
867
- try {
868
- const currentUser = yield this.afa.currentUser;
869
- if (!currentUser) {
870
- throw new Error('No signed in user');
871
- }
872
- yield currentUser.sendEmailVerification();
873
- }
874
- catch (error) {
875
- this.fire.recordException(error);
876
- throw error;
877
- }
878
- });
879
- }
880
- /**
881
- * SignOut the currently authenticated user.
882
- */
883
- signOut() {
884
- return __awaiter(this, void 0, void 0, function* () {
885
- try {
886
- yield this.afa.signOut();
887
- if (this.credFactory) {
888
- this.credFactory.signOut();
889
- }
890
- }
891
- catch (error) {
892
- yield this.handleError(error);
893
- }
894
- });
895
- }
896
- /**
897
- * Update the details for the authenticated user of in the firebase authentication and sync with firestore.
898
- *
899
- * @param userInfo - UserInfo object containing those properties for which change is requried. Only provider
900
- * the properties actually to be changed. Others should be ommitted.
901
- */
902
- updateUserInfo(userInfo) {
903
- return __awaiter(this, void 0, void 0, function* () {
904
- try {
905
- const user = yield this.afa.currentUser;
906
- if (!user) {
907
- throw new Error('No currentUser');
908
- }
909
- if (userInfo.email) {
910
- yield user.updateEmail(userInfo.email);
911
- }
912
- if (userInfo.phoneNumber) {
913
- yield user.updatePhoneNumber(userInfo.phoneNumber); // TODO - bet this doesn't actually work
914
- }
915
- if (userInfo.displayName || userInfo.photoURL) {
916
- yield user.updateProfile({
917
- displayName: userInfo.displayName,
918
- photoURL: userInfo.photoURL
919
- });
920
- }
921
- yield this.afa.updateCurrentUser(user);
922
- if (this.config.authUi.enableFirestoreSync) {
923
- // await this.fireStoreService.updateUserData(user.uid, this.parseUserInfo(user));
924
- yield this.fireStoreService.updateUserData(user.uid, {
925
- displayName: user.displayName,
926
- email: user.email,
927
- photoURL: user.photoURL
928
- });
929
- }
930
- this.onUserUpdatedEmitter.emit();
931
- }
932
- catch (error) {
933
- this.fire.recordException(error);
934
- }
935
- });
936
- }
937
- /**
938
- * Extract UserInfo object from the User object
939
- * If multiple providers are supplied these are amalgamated to create the most complete
940
- * UserInfo object possible
941
- */
942
- parseUserInfo(user) {
943
- const userInfo = {
944
- uid: user.uid,
945
- displayName: user.displayName,
946
- email: user.email,
947
- phoneNumber: user.phoneNumber,
948
- photoURL: user.photoURL,
949
- providerId: user.providerId
950
- };
951
- if (user.providerData) {
952
- user.providerData.forEach(item => {
953
- if (!userInfo.displayName && (item === null || item === void 0 ? void 0 : item.displayName)) {
954
- userInfo.displayName = item.displayName;
955
- }
956
- if (!userInfo.email && (item === null || item === void 0 ? void 0 : item.email)) {
957
- userInfo.email = item.email;
958
- }
959
- if (!userInfo.phoneNumber && (item === null || item === void 0 ? void 0 : item.phoneNumber)) {
960
- userInfo.phoneNumber = item.phoneNumber;
961
- }
962
- if (!userInfo.photoURL && (item === null || item === void 0 ? void 0 : item.photoURL)) {
963
- userInfo.photoURL = item.photoURL;
964
- }
965
- if (!userInfo.providerId && (item === null || item === void 0 ? void 0 : item.providerId)) {
966
- userInfo.providerId = item.providerId;
967
- }
968
- });
969
- }
970
- return userInfo;
971
- }
972
- /**
973
- * Returns the UserPhotoUrl, or an appropraite placeholder if not provided
974
- * ToDo - this would probably bet better inside a user-photo component
975
- */
976
- getUserPhotoUrl() {
977
- return this.user$.pipe(map((user) => {
978
- if (!user) {
979
- return null;
980
- }
981
- else if (user.photoURL) {
982
- return user.photoURL;
983
- }
984
- else if (user.emailVerified) {
985
- return `assets/user/${Accounts.CHECK}.svg`;
986
- }
987
- else if (user.isAnonymous) {
988
- return `assets/user/${Accounts.OFF}.svg`;
989
- }
990
- else {
991
- return `assets/user/${Accounts.NONE}.svg`;
992
- }
993
- }));
994
- }
995
- /**
996
- * Common handler for successful signIn
997
- * Refreshes FireStore User document based on current user (if enabled)
998
- * And provides welcome back toast (if enabled)
999
- *
1000
- * @param cred UserCredential object provided by signIn function
1001
- */
1002
- handleSignInSuccess(cred) {
1003
- return __awaiter(this, void 0, void 0, function* () {
1004
- if (null === cred.user) {
1005
- throw new Error('user is null whilst handling sucessful login');
1006
- }
1007
- // if (this.config.authUi.enableFirestoreSync) {
1008
- // Now done by server-side trigger await this.fireStoreService.createUserData(userData);
1009
- // try {
1010
- // const userData = this.parseUserInfo(cred.user);
1011
- // this.fire.addLogMessage(`About to create user data in firestore; user=${JSON.stringify(userData)}`);
1012
- // } catch (error) {
1013
- // this.fire.recordException(error);
1014
- // }
1015
- // }
1016
- if (this.config.authUi.toastMessageOnAuthSuccess) {
1017
- const successMessage = ('string' === typeof this.config.authUi.toastMessageOnAuthSuccess)
1018
- ? this.config.authUi.toastMessageOnAuthSuccess
1019
- : `Hello ${cred.user.displayName ? cred.user.displayName : ''}!`;
1020
- this.ui.toast(successMessage, { duration: this.config.authUi.toastDefaultDurationMil });
1021
- }
1022
- });
1023
- }
1024
- /**
1025
- * Refresh user info. Can be useful for instance to get latest status regarding email verification.
1026
- */
1027
- reloadUserInfo() {
1028
- return __awaiter(this, void 0, void 0, function* () {
1029
- const user = yield this.user$.pipe(take(1)).toPromise();
1030
- if (user) {
1031
- yield user.reload();
1032
- }
1033
- });
1034
- }
1035
- /**
1036
- * Deletes the current user
1037
- */
1038
- deleteUser() {
1039
- return __awaiter(this, void 0, void 0, function* () {
1040
- const currentUser = yield this.afa.currentUser;
1041
- const currentUid = currentUser === null || currentUser === void 0 ? void 0 : currentUser.uid;
1042
- if (!currentUser || !currentUid) {
1043
- throw new Error('Unable to delete currentUser if null');
1044
- }
1045
- try {
1046
- // Userdata deleted by DB trigger
1047
- yield currentUser.delete();
1048
- this.onUserDeletedEmitter.emit();
1049
- }
1050
- catch (error) {
1051
- if (error.code !== FirebaseErrorCodes.requiresRecentLogin) {
1052
- this.fire.recordException(error);
1053
- }
1054
- throw (error);
1055
- }
1056
- });
1057
- }
1058
- /**
1059
- * Logs the error and provides user error notifcation if appropriate
1060
- */
1061
- handleError(error) {
1062
- return __awaiter(this, void 0, void 0, function* () {
1063
- yield this.fire.recordException(error);
1064
- this.onErrorEmitter.emit(error);
1065
- if (this.config.authUi.toastMessageOnAuthError) {
1066
- let message = 'auth.common.pleaseRetry';
1067
- if (error && typeof error === 'string') {
1068
- message = error;
1069
- }
1070
- else if (error && error.message) {
1071
- message = error.message;
1072
- }
1073
- else if (error && typeof error === 'object') {
1074
- message = JSON.stringify(error);
1075
- }
1076
- else if (error) {
1077
- message = error.toString();
1078
- }
1079
- yield this.ui.toast(message, { duration: this.config.authUi.toastDefaultDurationMil });
1080
- }
1081
- });
1082
- }
1083
- /**
1084
- * Returns a firebase auth provider object for the specified provider
1085
- */
1086
- getAuthProvider(provider) {
1087
- if (!firebase.auth) {
1088
- throw new Error('firebase.auth is undefined');
1089
- }
1090
- switch (provider) {
1091
- case AuthProvider.Google: return new firebase.auth.GoogleAuthProvider();
1092
- case AuthProvider.Apple: return new firebase.auth.OAuthProvider('apple.com');
1093
- case AuthProvider.Facebook: return new firebase.auth.FacebookAuthProvider();
1094
- case AuthProvider.Twitter: return new firebase.auth.TwitterAuthProvider();
1095
- case AuthProvider.Github: return new firebase.auth.GithubAuthProvider();
1096
- case AuthProvider.Microsoft: return new firebase.auth.OAuthProvider('microsoft.com');
1097
- case AuthProvider.Yahoo: return new firebase.auth.OAuthProvider('yahoo.com');
1098
- default: throw new Error(`${provider} is not available as auth provider`);
1099
- }
1100
- }
1101
- }
1102
- AuthProcessService.ɵprov = ɵɵdefineInjectable({ factory: function AuthProcessService_Factory() { return new AuthProcessService(ɵɵinject(MalSharedConfigToken), ɵɵinject(MalMergeUserServiceToken, 8), ɵɵinject(MalCredentialFactoryProviderToken, 8), ɵɵinject(FirestoreSyncService), ɵɵinject(AngularFireAuth), ɵɵinject(FirebaseService), ɵɵinject(UiService)); }, token: AuthProcessService, providedIn: "root" });
1103
- AuthProcessService.decorators = [
1104
- { type: Injectable, args: [{
1105
- providedIn: 'root',
1106
- },] }
1107
- ];
1108
- AuthProcessService.ctorParameters = () => [
1109
- { type: undefined, decorators: [{ type: Inject, args: [forwardRef(() => MalSharedConfigToken),] }] },
1110
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [forwardRef(() => MalMergeUserServiceToken),] }] },
1111
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [forwardRef(() => MalCredentialFactoryProviderToken),] }] },
1112
- { type: FirestoreSyncService },
1113
- { type: AngularFireAuth },
1114
- { type: FirebaseService },
1115
- { type: UiService }
1116
- ];
1117
-
1118
- var DisplayWidth;
1119
- (function (DisplayWidth) {
1120
- DisplayWidth[DisplayWidth["xs"] = 1] = "xs";
1121
- DisplayWidth[DisplayWidth["sm"] = 576] = "sm";
1122
- DisplayWidth[DisplayWidth["md"] = 768] = "md";
1123
- DisplayWidth[DisplayWidth["lg"] = 992] = "lg";
1124
- DisplayWidth[DisplayWidth["xl"] = 1200] = "xl";
1125
- })(DisplayWidth || (DisplayWidth = {}));
1126
-
1127
- /* @Component({
1128
- template: ''
1129
- }) */
1130
- class ValueAccessorValueComponent {
1131
- constructor() {
1132
- this.valueChange = new EventEmitter();
1133
- this.propagateChange = (_) => { };
1134
- this.propagateTouch = (_) => { }; // TODO - Not implemented.
1135
- this.propagateValidatorChange = () => { }; // TODO - Not implemented.
1136
- }
1137
- get value() { return this._value; }
1138
- set value(val) {
1139
- if (val) {
1140
- this._value = val;
1141
- this.valueChange.emit(val);
1142
- this.propagateChange(val);
1143
- }
1144
- }
1145
- validate(control) {
1146
- return null;
1147
- }
1148
- writeValue(value) {
1149
- this.value = value;
1150
- }
1151
- registerOnChange(fn) {
1152
- this.propagateChange = fn;
1153
- }
1154
- registerOnTouched(fn) {
1155
- this.propagateTouch = fn;
1156
- }
1157
- registerOnValidatorChange(fn) {
1158
- this.propagateValidatorChange = fn;
1159
- }
1160
- }
1161
- ValueAccessorValueComponent.propDecorators = {
1162
- value: [{ type: Input }],
1163
- valueChange: [{ type: Output }]
1164
- };
1165
-
1166
- /* @Component({
1167
- template: ''
1168
- }) */
1169
- class ValueAccessorControlComponent {
1170
- constructor(injector, cdRef) {
1171
- this.injector = injector;
1172
- this.cdRef = cdRef;
1173
- this.destroy$ = new ReplaySubject();
1174
- this.valueChange = new EventEmitter();
1175
- this.propagateChange = (val) => { };
1176
- this.propagateTouch = () => { };
1177
- this.propagateValidatorChange = () => { };
1178
- }
1179
- get _control() {
1180
- if (!this.control) {
1181
- throw new Error('ValueAccessorControlComponent: this.control must be eclipsed in the subclass');
1182
- }
1183
- return this.control;
1184
- }
1185
- set value(val) {
1186
- if (val) {
1187
- this._control.setValue(val);
1188
- }
1189
- else {
1190
- this._control.reset();
1191
- }
1192
- }
1193
- get value() {
1194
- return this._control.value;
1195
- }
1196
- ngOnInit() {
1197
- this._control.valueChanges
1198
- .pipe(takeUntil(this.destroy$))
1199
- .subscribe(val => {
1200
- if (this._control.dirty) {
1201
- this.propagateChange(val);
1202
- this.propagateTouch();
1203
- this.valueChange.emit(val);
1204
- }
1205
- });
1206
- this._control.statusChanges
1207
- .pipe(takeUntil(this.destroy$))
1208
- .subscribe(() => this.propagateValidatorChange());
1209
- }
1210
- ngAfterViewInit() {
1211
- this.parentControl = this.injector.get(NgControl, null);
1212
- this.cdRef.detectChanges();
1213
- }
1214
- ngOnDestroy() {
1215
- this.destroy$.next();
1216
- this.destroy$.complete();
1217
- }
1218
- writeValue(value) {
1219
- this.value = value;
1220
- }
1221
- registerOnChange(fn) {
1222
- this.propagateChange = fn;
1223
- }
1224
- registerOnTouched(fn) {
1225
- this.propagateTouch = fn;
1226
- }
1227
- registerOnValidatorChange(fn) {
1228
- this.propagateValidatorChange = fn;
1229
- }
1230
- setDisabledState(isDisabled) {
1231
- if (isDisabled) {
1232
- this._control.disable();
1233
- }
1234
- else {
1235
- this._control.enable();
1236
- }
1237
- }
1238
- validate(control) {
1239
- return this._control.errors;
1240
- }
1241
- }
1242
- ValueAccessorControlComponent.propDecorators = {
1243
- value: [{ type: Input }],
1244
- valueChange: [{ type: Output }]
1245
- };
1246
-
1247
- class LoggedInGuard {
1248
- constructor(config, router, aps) {
1249
- this.config = config;
1250
- this.router = router;
1251
- this.aps = aps;
1252
- }
1253
- guardOutcome(redirectUrl) {
1254
- return this.aps.user$.pipe(take(1), map((user) => {
1255
- if (user) {
1256
- if (this.config.authUi.guardProtectedRoutesUntilEmailIsVerified && !user.emailVerified) {
1257
- if (this.config.authUi.authGuardVerifyEmailURL) {
1258
- return this.router.createUrlTree([`${this.config.authUi.authGuardVerifyEmailURL}`], { queryParams: { redirectUrl } });
1259
- }
1260
- else if (this.config.authUi.authGuardFallbackURL) {
1261
- return this.router.createUrlTree([`${this.config.authUi.authGuardFallbackURL}`], { queryParams: { redirectUrl } });
1262
- }
1263
- else {
1264
- return false;
1265
- }
1266
- }
1267
- else {
1268
- return true;
1269
- }
1270
- }
1271
- else {
1272
- if (this.config.authUi.authGuardFallbackURL) {
1273
- return this.router.createUrlTree([`${this.config.authUi.authGuardFallbackURL}`], { queryParams: { redirectUrl } });
1274
- }
1275
- return false;
1276
- }
1277
- }));
1278
- }
1279
- canLoad(route, segments) {
1280
- return this.guardOutcome(segments[0].parameters.url);
1281
- }
1282
- canActivate(route, state) {
1283
- return this.guardOutcome(state.url);
1284
- }
1285
- }
1286
- LoggedInGuard.ɵprov = ɵɵdefineInjectable({ factory: function LoggedInGuard_Factory() { return new LoggedInGuard(ɵɵinject(MalSharedConfigToken), ɵɵinject(Router), ɵɵinject(AuthProcessService)); }, token: LoggedInGuard, providedIn: "root" });
1287
- LoggedInGuard.decorators = [
1288
- { type: Injectable, args: [{
1289
- providedIn: 'root'
1290
- },] }
1291
- ];
1292
- LoggedInGuard.ctorParameters = () => [
1293
- { type: undefined, decorators: [{ type: Inject, args: [MalSharedConfigToken,] }] },
1294
- { type: Router },
1295
- { type: AuthProcessService }
1296
- ];
1297
-
1298
- class VerifyEmailGuard {
1299
- constructor(config, router, aps) {
1300
- this.config = config;
1301
- this.router = router;
1302
- this.aps = aps;
1303
- }
1304
- canActivate(route, state) {
1305
- return this.aps.user$.pipe(map(user => {
1306
- if (user
1307
- && !user.emailVerified
1308
- && !user.isAnonymous
1309
- && this.config.authUi.authGuardVerifyEmailURL) {
1310
- return this.router.createUrlTree([`${this.config.authUi.authGuardVerifyEmailURL}`], { queryParams: { redirectUrl: state.url } });
1311
- }
1312
- else {
1313
- return true;
1314
- }
1315
- }));
1316
- }
1317
- }
1318
- VerifyEmailGuard.ɵprov = ɵɵdefineInjectable({ factory: function VerifyEmailGuard_Factory() { return new VerifyEmailGuard(ɵɵinject(MalSharedConfigToken), ɵɵinject(Router), ɵɵinject(AuthProcessService)); }, token: VerifyEmailGuard, providedIn: "root" });
1319
- VerifyEmailGuard.decorators = [
1320
- { type: Injectable, args: [{
1321
- providedIn: 'root'
1322
- },] }
1323
- ];
1324
- VerifyEmailGuard.ctorParameters = () => [
1325
- { type: undefined, decorators: [{ type: Inject, args: [MalSharedConfigToken,] }] },
1326
- { type: Router },
1327
- { type: AuthProcessService }
1328
- ];
1329
-
1330
- // @angular/*
1331
- const MODULES = [
1332
- HttpClientModule,
1333
- AngularFireAuthModule,
1334
- AngularFirestoreModule,
1335
- AngularFireFunctionsModule
1336
- ];
1337
- class MalSharedModule {
1338
- static forRoot(config, appNameFactory = () => undefined) {
1339
- var _a;
1340
- return {
1341
- ngModule: MalSharedModule,
1342
- providers: [
1343
- {
1344
- provide: MalUserProvidedConfigToken,
1345
- useValue: config
1346
- },
1347
- {
1348
- provide: MalSharedConfigToken,
1349
- useFactory: malSharedConfigFactory,
1350
- deps: [MalUserProvidedConfigToken]
1351
- },
1352
- {
1353
- provide: DEFAULTS,
1354
- useValue: config.configDefaults
1355
- },
1356
- {
1357
- provide: SETTINGS,
1358
- useFactory: () => isDevMode() ? { minimumFetchIntervalMillis: 3600000 } : {} // 1 hour§
1359
- },
1360
- {
1361
- provide: FIREBASE_OPTIONS,
1362
- useValue: config.firebase
1363
- },
1364
- {
1365
- provide: FIREBASE_APP_NAME,
1366
- useFactory: appNameFactory
1367
- },
1368
- {
1369
- provide: USE_EMULATOR,
1370
- useFactory: authEmulatorFactory,
1371
- deps: [MalSharedConfigToken]
1372
- },
1373
- {
1374
- provide: USE_EMULATOR$1,
1375
- useFactory: firestoreEmulatorFactory,
1376
- deps: [MalSharedConfigToken]
1377
- },
1378
- {
1379
- provide: USE_EMULATOR$2,
1380
- useFactory: functionsEmulatorFactory,
1381
- deps: [MalSharedConfigToken]
1382
- },
1383
- {
1384
- provide: REGION,
1385
- useValue: ((_a = config.services) === null || _a === void 0 ? void 0 : _a.firebaseRegion) || null
1386
- },
1387
- {
1388
- provide: AngularFirePerformance,
1389
- useFactory: performanceProviderFactory,
1390
- deps: [
1391
- MalSharedConfigToken,
1392
- FirebaseApp,
1393
- [new Optional(), DATA_COLLECTION_ENABLED],
1394
- [new Optional(), INSTRUMENTATION_ENABLED],
1395
- NgZone,
1396
- PLATFORM_ID
1397
- ]
1398
- },
1399
- {
1400
- provide: AngularFireRemoteConfig,
1401
- useFactory: remoteConfigFirebaseService,
1402
- deps: [
1403
- MalSharedConfigToken,
1404
- FIREBASE_OPTIONS,
1405
- FIREBASE_APP_NAME,
1406
- SETTINGS,
1407
- DEFAULTS,
1408
- NgZone,
1409
- PLATFORM_ID
1410
- ]
1411
- },
1412
- AnalyticsService,
1413
- CrashlyticsService,
1414
- FirebaseService,
1415
- UiService,
1416
- RemoteConfigService,
1417
- AuthProcessService,
1418
- FirestoreSyncService,
1419
- PerformanceService,
1420
- AngularFireAuth,
1421
- LoggedInGuard,
1422
- VerifyEmailGuard
1423
- ],
1424
- };
1425
- }
1426
- }
1427
- MalSharedModule.decorators = [
1428
- { type: NgModule, args: [{
1429
- imports: [
1430
- ...MODULES,
1431
- TranslateModule.forChild(),
1432
- AngularFireModule,
1433
- ],
1434
- exports: [
1435
- ...MODULES,
1436
- TranslateModule
1437
- ]
1438
- },] }
1439
- ];
1440
- function performanceProviderFactory(config, app, dataCollectionEnabled, instrumentationEnabled, zone, platformId) {
1441
- if (config.services.firebasePerformance) {
1442
- return new AngularFirePerformance(app, dataCollectionEnabled, instrumentationEnabled, zone, platformId);
1443
- }
1444
- return null;
1445
- }
1446
- function remoteConfigFirebaseService(config, options, nameOrConfig, settings, defaultConfig, zone, platformId) {
1447
- if (config.services.firebaseRemoteConfig) {
1448
- return new AngularFireRemoteConfig(options, nameOrConfig, settings, defaultConfig, zone, platformId);
1449
- }
1450
- return null;
1451
- }
1452
- function authEmulatorFactory(config) {
1453
- if (true === config.services.firebaseAuth) {
1454
- return undefined;
1455
- }
1456
- else {
1457
- return config.services.firebaseAuth;
1458
- }
1459
- }
1460
- function firestoreEmulatorFactory(config) {
1461
- if (true === config.services.firebaseFirestore) {
1462
- return undefined;
1463
- }
1464
- else {
1465
- return config.services.firebaseFirestore;
1466
- }
1467
- }
1468
- function functionsEmulatorFactory(config) {
1469
- if (true === config.services.firebaseFunctions) {
1470
- return undefined;
1471
- }
1472
- else {
1473
- return config.services.firebaseFunctions;
1474
- }
1475
- }
1476
-
1477
- /**
1478
- * Generated bundle index. Do not edit.
1479
- */
1480
-
1481
- export { Accounts, AnalyticsService, AuthProcessService, AuthProvider, CrashlyticsService, DisplayWidth, FirebaseErrorCodes, FirebaseService, FirestoreSyncService, LoggedInGuard, MalAlertsUIProviderToken, MalAnalyticsProviderToken, MalAuthServiceProviderToken, MalCrashlyticsProviderToken, MalCredentialFactoryProviderToken, MalDeviceInfoService, MalLegaliyDialogUIProiderToken, MalLoadingUIProviderToken, MalMergeUserServiceToken, MalPickerUIProviderToken, MalServiceEnabled, MalSharedConfigToken, MalSharedModule, MalToastUIProviderToken, MalUserProvidedConfigToken, PHONE_NUMBER_REGEX, PerformanceService, PerformanceTraceNoop, RemoteConfigService, UiService, ValueAccessorControlComponent, ValueAccessorValueComponent, VerifyEmailGuard, authEmulatorFactory, defaultAuthFirebaseUIConfig, firestoreEmulatorFactory, functionsEmulatorFactory, malSharedConfigFactory, performanceProviderFactory, remoteConfigFirebaseService, MalAnalyticsProviderToken as ɵa, MalCrashlyticsProviderToken as ɵc, MalSharedConfigToken as ɵe, MalMergeUserServiceToken as ɵf, MalCredentialFactoryProviderToken as ɵg, MalToastUIProviderToken as ɵk, MalAlertsUIProviderToken as ɵl, MalLoadingUIProviderToken as ɵm, MalLegaliyDialogUIProiderToken as ɵn };
1482
- //# sourceMappingURL=ngx-firebase.js.map