ngx-firebase 1.1.13 → 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.
- package/README.md +51 -11
- package/fesm2022/ngx-firebase.mjs +158 -0
- package/fesm2022/ngx-firebase.mjs.map +1 -0
- package/package.json +40 -30
- package/types/ngx-firebase.d.ts +55 -0
- package/bundles/ngx-firebase-capacitor.umd.js +0 -763
- package/bundles/ngx-firebase-capacitor.umd.js.map +0 -1
- package/bundles/ngx-firebase-capacitor.umd.min.js +0 -16
- package/bundles/ngx-firebase-capacitor.umd.min.js.map +0 -1
- package/bundles/ngx-firebase-iap.umd.js +0 -718
- package/bundles/ngx-firebase-iap.umd.js.map +0 -1
- package/bundles/ngx-firebase-iap.umd.min.js +0 -2
- package/bundles/ngx-firebase-iap.umd.min.js.map +0 -1
- package/bundles/ngx-firebase-ionic-auth-ui.umd.js +0 -2116
- package/bundles/ngx-firebase-ionic-auth-ui.umd.js.map +0 -1
- package/bundles/ngx-firebase-ionic-auth-ui.umd.min.js +0 -16
- package/bundles/ngx-firebase-ionic-auth-ui.umd.min.js.map +0 -1
- package/bundles/ngx-firebase-ionic.umd.js +0 -979
- package/bundles/ngx-firebase-ionic.umd.js.map +0 -1
- package/bundles/ngx-firebase-ionic.umd.min.js +0 -16
- package/bundles/ngx-firebase-ionic.umd.min.js.map +0 -1
- package/bundles/ngx-firebase-testing.umd.js +0 -801
- package/bundles/ngx-firebase-testing.umd.js.map +0 -1
- package/bundles/ngx-firebase-testing.umd.min.js +0 -2
- package/bundles/ngx-firebase-testing.umd.min.js.map +0 -1
- package/bundles/ngx-firebase.umd.js +0 -2299
- package/bundles/ngx-firebase.umd.js.map +0 -1
- package/bundles/ngx-firebase.umd.min.js +0 -2
- package/bundles/ngx-firebase.umd.min.js.map +0 -1
- package/capacitor/capacitor.module.d.ts +0 -9
- package/capacitor/interfaces/config.d.ts +0 -12
- package/capacitor/interfaces/index.d.ts +0 -1
- package/capacitor/ngx-firebase-capacitor.d.ts +0 -5
- package/capacitor/ngx-firebase-capacitor.metadata.json +0 -1
- package/capacitor/package.json +0 -25
- package/capacitor/public-api.d.ts +0 -3
- package/capacitor/services/analytics-firebase-capacitor.service.d.ts +0 -9
- package/capacitor/services/crashlytics-firebase-capacitor.service.d.ts +0 -8
- package/capacitor/services/credential-factory-capacitor.service.d.ts +0 -18
- package/capacitor/services/index.d.ts +0 -3
- package/esm2015/capacitor/capacitor.module.js +0 -78
- package/esm2015/capacitor/interfaces/config.js +0 -3
- package/esm2015/capacitor/interfaces/index.js +0 -2
- package/esm2015/capacitor/ngx-firebase-capacitor.js +0 -6
- package/esm2015/capacitor/public-api.js +0 -4
- package/esm2015/capacitor/services/analytics-firebase-capacitor.service.js +0 -43
- package/esm2015/capacitor/services/crashlytics-firebase-capacitor.service.js +0 -40
- package/esm2015/capacitor/services/credential-factory-capacitor.service.js +0 -182
- package/esm2015/capacitor/services/index.js +0 -4
- package/esm2015/iap/iap.module.js +0 -32
- package/esm2015/iap/interfaces/index.js +0 -5
- package/esm2015/iap/ngx-firebase-iap.js +0 -5
- package/esm2015/iap/public-api.js +0 -5
- package/esm2015/iap/services/iap.service.js +0 -317
- package/esm2015/iap/tokens/index.js +0 -4
- package/esm2015/ionic/animations/index.js +0 -30
- package/esm2015/ionic/components/avatar/avatar.component.js +0 -98
- package/esm2015/ionic/components/avatar/index.js +0 -2
- package/esm2015/ionic/components/index.js +0 -3
- package/esm2015/ionic/components/popover-menu/index.js +0 -3
- package/esm2015/ionic/components/popover-menu/interface.js +0 -2
- package/esm2015/ionic/components/popover-menu/popover-menu.component.js +0 -34
- package/esm2015/ionic/ionic.module.js +0 -46
- package/esm2015/ionic/ngx-firebase-ionic.js +0 -5
- package/esm2015/ionic/public-api.js +0 -5
- package/esm2015/ionic/services/alerts-ionic.service.js +0 -107
- package/esm2015/ionic/services/index.js +0 -6
- package/esm2015/ionic/services/legality-dialog-ionic.service.js +0 -85
- package/esm2015/ionic/services/loading-ionic.service.js +0 -46
- package/esm2015/ionic/services/picker-ionic.service.js +0 -44
- package/esm2015/ionic/services/toast-ionic.service.js +0 -49
- package/esm2015/ionic-auth-ui/animations/index.js +0 -30
- package/esm2015/ionic-auth-ui/components/email-confirmation/email-confirmation.component.js +0 -99
- package/esm2015/ionic-auth-ui/components/email-field/email-field.component.js +0 -25
- package/esm2015/ionic-auth-ui/components/form-field/form-field.component.js +0 -82
- package/esm2015/ionic-auth-ui/components/index.js +0 -12
- package/esm2015/ionic-auth-ui/components/name-field/name-field.component.js +0 -30
- package/esm2015/ionic-auth-ui/components/or-divider/or-divider.component.js +0 -11
- package/esm2015/ionic-auth-ui/components/password-field/password-field.component.js +0 -138
- package/esm2015/ionic-auth-ui/components/password-field/passwordValidatorFunctions.js +0 -62
- package/esm2015/ionic-auth-ui/components/providers/providers.component.js +0 -70
- package/esm2015/ionic-auth-ui/components/reauthenticate/reauthenticate.component.js +0 -99
- package/esm2015/ionic-auth-ui/components/register/register.component.js +0 -142
- package/esm2015/ionic-auth-ui/components/register-with-email/register-with-email.component.js +0 -60
- package/esm2015/ionic-auth-ui/components/register-with-email-popover/register-with-email-popover.component.js +0 -26
- package/esm2015/ionic-auth-ui/components/signin/signin.component.js +0 -92
- package/esm2015/ionic-auth-ui/components/terms-field/terms-field.component.js +0 -99
- package/esm2015/ionic-auth-ui/components/user/user.component.js +0 -195
- package/esm2015/ionic-auth-ui/ionic-auth-ui.module.js +0 -92
- package/esm2015/ionic-auth-ui/ngx-firebase-ionic-auth-ui.js +0 -23
- package/esm2015/ionic-auth-ui/pages/index.js +0 -5
- package/esm2015/ionic-auth-ui/pages/register/index.js +0 -2
- package/esm2015/ionic-auth-ui/pages/register/register.page.js +0 -56
- package/esm2015/ionic-auth-ui/pages/signin/index.js +0 -2
- package/esm2015/ionic-auth-ui/pages/signin/signin.page.js +0 -78
- package/esm2015/ionic-auth-ui/pages/user/index.js +0 -2
- package/esm2015/ionic-auth-ui/pages/user/user.page.js +0 -11
- package/esm2015/ionic-auth-ui/pages/verifyemail/index.js +0 -2
- package/esm2015/ionic-auth-ui/pages/verifyemail/verifyemail.page.js +0 -85
- package/esm2015/ionic-auth-ui/public-api.js +0 -5
- package/esm2015/ngx-firebase.js +0 -6
- package/esm2015/public-api.js +0 -6
- package/esm2015/shared/guards/index.js +0 -3
- package/esm2015/shared/guards/logged-in.guard.js +0 -60
- package/esm2015/shared/guards/verify-email.guard.js +0 -41
- package/esm2015/shared/interfaces/accounts.enum.js +0 -9
- package/esm2015/shared/interfaces/authprovider.enum.js +0 -15
- package/esm2015/shared/interfaces/config.interface.js +0 -61
- package/esm2015/shared/interfaces/index.js +0 -8
- package/esm2015/shared/interfaces/main.interface.js +0 -7
- package/esm2015/shared/interfaces/providers.interface.js +0 -2
- package/esm2015/shared/interfaces/tokens.js +0 -19
- package/esm2015/shared/interfaces/ui-providers.interface.js +0 -2
- package/esm2015/shared/services/analytics.service.js +0 -24
- package/esm2015/shared/services/auth-process.service.js +0 -779
- package/esm2015/shared/services/crashlytics.service.js +0 -42
- package/esm2015/shared/services/device-info.service.js +0 -14
- package/esm2015/shared/services/firebase.service.js +0 -37
- package/esm2015/shared/services/firestore-sync.service.js +0 -60
- package/esm2015/shared/services/index.js +0 -10
- package/esm2015/shared/services/performance.service.js +0 -28
- package/esm2015/shared/services/remoteconfig.service.js +0 -49
- package/esm2015/shared/services/ui.service.js +0 -45
- package/esm2015/shared/shared.module.js +0 -175
- package/esm2015/shared/types/DisplayWidth.js +0 -9
- package/esm2015/shared/types/Location.js +0 -2
- package/esm2015/shared/types/ValueAccessorControlComponent.js +0 -85
- package/esm2015/shared/types/ValueAccessorValueComponent.js +0 -40
- package/esm2015/shared/types/index.js +0 -5
- package/esm2015/testing/fakeavatar.module.js +0 -22
- package/esm2015/testing/fakes/FakeAuthProcessService.js +0 -31
- package/esm2015/testing/fakes/FakeAvatarComponent.js +0 -13
- package/esm2015/testing/fakes/FakeFireService.js +0 -21
- package/esm2015/testing/fakes/FakeFirestoreSyncService.js +0 -11
- package/esm2015/testing/fakes/FakeIAPurchaseService.js +0 -11
- package/esm2015/testing/fakes/FakePickerService.js +0 -9
- package/esm2015/testing/fakes/FakeRemoteConfigService.js +0 -44
- package/esm2015/testing/fakes/FakeTranslateService.js +0 -21
- package/esm2015/testing/fakes/FakeUiService.js +0 -26
- package/esm2015/testing/fakes/angular-fire/FakeAngularFireAuth.js +0 -30
- package/esm2015/testing/fakes/angular-fire/FakeAngularFireFunctions.js +0 -17
- package/esm2015/testing/fakes/angular-fire/FakeAngularFirePerformance.js +0 -17
- package/esm2015/testing/fakes/angular-fire/FakeAngularFireStorage.js +0 -8
- package/esm2015/testing/fakes/angular-fire/FakeAngularFirestore.js +0 -8
- package/esm2015/testing/fakes/angular-fire/FakeUserCredential.js +0 -18
- package/esm2015/testing/fakes/index.js +0 -19
- package/esm2015/testing/ngx-firebase-testing.js +0 -6
- package/esm2015/testing/public-api.js +0 -5
- package/esm2015/testing/test.module.js +0 -66
- package/esm2015/testing/utils/index.js +0 -17
- package/esm2015/testing/utils/patchConsole.js +0 -14
- package/fesm2015/ngx-firebase-capacitor.js +0 -328
- package/fesm2015/ngx-firebase-capacitor.js.map +0 -1
- package/fesm2015/ngx-firebase-iap.js +0 -354
- package/fesm2015/ngx-firebase-iap.js.map +0 -1
- package/fesm2015/ngx-firebase-ionic-auth-ui.js +0 -1482
- package/fesm2015/ngx-firebase-ionic-auth-ui.js.map +0 -1
- package/fesm2015/ngx-firebase-ionic.js +0 -495
- package/fesm2015/ngx-firebase-ionic.js.map +0 -1
- package/fesm2015/ngx-firebase-testing.js +0 -388
- package/fesm2015/ngx-firebase-testing.js.map +0 -1
- package/fesm2015/ngx-firebase.js +0 -1509
- package/fesm2015/ngx-firebase.js.map +0 -1
- package/iap/iap.module.d.ts +0 -5
- package/iap/interfaces/index.d.ts +0 -11
- package/iap/ngx-firebase-iap.d.ts +0 -4
- package/iap/ngx-firebase-iap.metadata.json +0 -1
- package/iap/package.json +0 -23
- package/iap/public-api.d.ts +0 -4
- package/iap/services/iap.service.d.ts +0 -47
- package/iap/tokens/index.d.ts +0 -3
- package/ionic/animations/index.d.ts +0 -1
- package/ionic/components/avatar/avatar.component.d.ts +0 -27
- package/ionic/components/avatar/index.d.ts +0 -1
- package/ionic/components/index.d.ts +0 -2
- package/ionic/components/popover-menu/index.d.ts +0 -2
- package/ionic/components/popover-menu/interface.d.ts +0 -6
- package/ionic/components/popover-menu/popover-menu.component.d.ts +0 -10
- package/ionic/ionic.module.d.ts +0 -2
- package/ionic/ngx-firebase-ionic.d.ts +0 -4
- package/ionic/ngx-firebase-ionic.metadata.json +0 -1
- package/ionic/package.json +0 -30
- package/ionic/public-api.d.ts +0 -4
- package/ionic/services/alerts-ionic.service.d.ts +0 -13
- package/ionic/services/index.d.ts +0 -5
- package/ionic/services/legality-dialog-ionic.service.d.ts +0 -10
- package/ionic/services/loading-ionic.service.d.ts +0 -17
- package/ionic/services/picker-ionic.service.d.ts +0 -9
- package/ionic/services/toast-ionic.service.d.ts +0 -11
- package/ionic-auth-ui/animations/index.d.ts +0 -1
- package/ionic-auth-ui/components/email-confirmation/email-confirmation.component.d.ts +0 -31
- package/ionic-auth-ui/components/email-field/email-field.component.d.ts +0 -7
- package/ionic-auth-ui/components/form-field/form-field.component.d.ts +0 -28
- package/ionic-auth-ui/components/index.d.ts +0 -11
- package/ionic-auth-ui/components/name-field/name-field.component.d.ts +0 -8
- package/ionic-auth-ui/components/or-divider/or-divider.component.d.ts +0 -2
- package/ionic-auth-ui/components/password-field/password-field.component.d.ts +0 -34
- package/ionic-auth-ui/components/password-field/passwordValidatorFunctions.d.ts +0 -4
- package/ionic-auth-ui/components/providers/providers.component.d.ts +0 -26
- package/ionic-auth-ui/components/reauthenticate/reauthenticate.component.d.ts +0 -30
- package/ionic-auth-ui/components/register/register.component.d.ts +0 -26
- package/ionic-auth-ui/components/register-with-email/register-with-email.component.d.ts +0 -24
- package/ionic-auth-ui/components/register-with-email-popover/register-with-email-popover.component.d.ts +0 -7
- package/ionic-auth-ui/components/signin/signin.component.d.ts +0 -28
- package/ionic-auth-ui/components/terms-field/terms-field.component.d.ts +0 -27
- package/ionic-auth-ui/components/user/user.component.d.ts +0 -45
- package/ionic-auth-ui/ionic-auth-ui.module.d.ts +0 -32
- package/ionic-auth-ui/ngx-firebase-ionic-auth-ui.d.ts +0 -22
- package/ionic-auth-ui/ngx-firebase-ionic-auth-ui.metadata.json +0 -1
- package/ionic-auth-ui/package.json +0 -30
- package/ionic-auth-ui/pages/index.d.ts +0 -4
- package/ionic-auth-ui/pages/register/index.d.ts +0 -1
- package/ionic-auth-ui/pages/register/register.page.d.ts +0 -16
- package/ionic-auth-ui/pages/signin/index.d.ts +0 -1
- package/ionic-auth-ui/pages/signin/signin.page.d.ts +0 -22
- package/ionic-auth-ui/pages/user/index.d.ts +0 -1
- package/ionic-auth-ui/pages/user/user.page.d.ts +0 -3
- package/ionic-auth-ui/pages/verifyemail/index.d.ts +0 -1
- package/ionic-auth-ui/pages/verifyemail/verifyemail.page.d.ts +0 -19
- package/ionic-auth-ui/public-api.d.ts +0 -4
- package/ngx-firebase.d.ts +0 -5
- package/ngx-firebase.metadata.json +0 -1
- package/public-api.d.ts +0 -5
- package/shared/guards/index.d.ts +0 -2
- package/shared/guards/logged-in.guard.d.ts +0 -13
- package/shared/guards/verify-email.guard.d.ts +0 -11
- package/shared/interfaces/accounts.enum.d.ts +0 -7
- package/shared/interfaces/authprovider.enum.d.ts +0 -13
- package/shared/interfaces/config.interface.d.ts +0 -63
- package/shared/interfaces/index.d.ts +0 -7
- package/shared/interfaces/main.interface.d.ts +0 -13
- package/shared/interfaces/providers.interface.d.ts +0 -70
- package/shared/interfaces/tokens.d.ts +0 -16
- package/shared/interfaces/ui-providers.interface.d.ts +0 -66
- package/shared/services/analytics.service.d.ts +0 -10
- package/shared/services/auth-process.service.d.ts +0 -197
- package/shared/services/crashlytics.service.d.ts +0 -11
- package/shared/services/device-info.service.d.ts +0 -3
- package/shared/services/firebase.service.d.ts +0 -16
- package/shared/services/firestore-sync.service.d.ts +0 -16
- package/shared/services/index.d.ts +0 -9
- package/shared/services/performance.service.d.ts +0 -12
- package/shared/services/remoteconfig.service.d.ts +0 -18
- package/shared/services/ui.service.d.ts +0 -22
- package/shared/shared.module.d.ts +0 -14
- package/shared/types/DisplayWidth.d.ts +0 -7
- package/shared/types/Location.d.ts +0 -8
- package/shared/types/ValueAccessorControlComponent.d.ts +0 -27
- package/shared/types/ValueAccessorValueComponent.d.ts +0 -19
- package/shared/types/index.d.ts +0 -4
- package/testing/fakeavatar.module.d.ts +0 -2
- package/testing/fakes/FakeAuthProcessService.d.ts +0 -28
- package/testing/fakes/FakeAvatarComponent.d.ts +0 -3
- package/testing/fakes/FakeFireService.d.ts +0 -20
- package/testing/fakes/FakeFirestoreSyncService.d.ts +0 -9
- package/testing/fakes/FakeIAPurchaseService.d.ts +0 -9
- package/testing/fakes/FakePickerService.d.ts +0 -6
- package/testing/fakes/FakeRemoteConfigService.d.ts +0 -19
- package/testing/fakes/FakeTranslateService.d.ts +0 -15
- package/testing/fakes/FakeUiService.d.ts +0 -25
- package/testing/fakes/angular-fire/FakeAngularFireAuth.d.ts +0 -52
- package/testing/fakes/angular-fire/FakeAngularFireFunctions.d.ts +0 -11
- package/testing/fakes/angular-fire/FakeAngularFirePerformance.d.ts +0 -10
- package/testing/fakes/angular-fire/FakeAngularFireStorage.d.ts +0 -5
- package/testing/fakes/angular-fire/FakeAngularFirestore.d.ts +0 -5
- package/testing/fakes/angular-fire/FakeUserCredential.d.ts +0 -9
- package/testing/fakes/index.d.ts +0 -16
- package/testing/ngx-firebase-testing.d.ts +0 -5
- package/testing/ngx-firebase-testing.metadata.json +0 -1
- package/testing/package.json +0 -29
- package/testing/public-api.d.ts +0 -4
- package/testing/test.module.d.ts +0 -4
- package/testing/utils/index.d.ts +0 -5
- package/testing/utils/patchConsole.d.ts +0 -4
package/fesm2015/ngx-firebase.js
DELETED
|
@@ -1,1509 +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 AuthHooksProviderToken = new InjectionToken('AuthHooksProviderToken');
|
|
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, hooksService, credFactory, fireStoreService, afa, // TODO should be private
|
|
389
|
-
fire, ui) {
|
|
390
|
-
this.config = config;
|
|
391
|
-
this.hooksService = hooksService;
|
|
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
|
-
/**
|
|
442
|
-
* Triggers subscriber actions when the current user token is refreshed
|
|
443
|
-
*/
|
|
444
|
-
this.tokenRefreshed$ = new Subject();
|
|
445
|
-
this.afa.user.subscribe(user => this._user$.next(user));
|
|
446
|
-
this.afa.authState.subscribe(authState => this._authState$.next(authState));
|
|
447
|
-
this.authState$.subscribe(user => {
|
|
448
|
-
this.fire.setUserId((user === null || user === void 0 ? void 0 : user.uid) || null);
|
|
449
|
-
});
|
|
450
|
-
this.onSignOut$.subscribe(() => this.onSignOutEmitter.emit());
|
|
451
|
-
}
|
|
452
|
-
get user() {
|
|
453
|
-
return this._user$.value;
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* Provides an array of authentication providers that are valid for the currently signed-in user
|
|
457
|
-
*/
|
|
458
|
-
get reauthenticateProviders$() {
|
|
459
|
-
return this.user$.pipe(map(user => ((user === null || user === void 0 ? void 0 : user.providerData) || [])
|
|
460
|
-
.map(item => {
|
|
461
|
-
switch (item === null || item === void 0 ? void 0 : item.providerId) {
|
|
462
|
-
case 'google.com': return AuthProvider.Google;
|
|
463
|
-
default:
|
|
464
|
-
console.log('NO MATCH', item);
|
|
465
|
-
return;
|
|
466
|
-
}
|
|
467
|
-
})
|
|
468
|
-
.filter(item => !!item)));
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Returns true if current platform is webplatform supported by @angular/fire
|
|
472
|
-
*/
|
|
473
|
-
get isWebPlatform() {
|
|
474
|
-
return ['https:', 'http:', 'chrome-extension'].includes(location.protocol);
|
|
475
|
-
}
|
|
476
|
-
/**
|
|
477
|
-
* Indicates if the specified provider is supported on the current platform
|
|
478
|
-
*
|
|
479
|
-
* A provider is supported if it is configured to be so in authUi.supportProviders and either the platform is a webplatform
|
|
480
|
-
* (in which case @anguluar/fire will be used). Or the provider is supported by the injected credFactory (such as that provided by /capacitor).
|
|
481
|
-
*/
|
|
482
|
-
isProviderSupported(provider) {
|
|
483
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
484
|
-
return (this.config.authUi.supportedProviders === AuthProvider.ALL || this.config.authUi.supportedProviders.includes(provider))
|
|
485
|
-
&& (this.isWebPlatform || (this.credFactory && (yield this.credFactory.isProviderSupported(provider))));
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Refreshes the current user IdToken, and triggers the tokenRefreshed$ subject
|
|
490
|
-
*/
|
|
491
|
-
refreshToken() {
|
|
492
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
493
|
-
const user = yield this.afa.currentUser;
|
|
494
|
-
if (user) {
|
|
495
|
-
yield user.getIdToken(true);
|
|
496
|
-
yield this.tokenRefreshed$.next();
|
|
497
|
-
}
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Provides an observable that subscribes to the current user token and returns the value of the specified claim.
|
|
502
|
-
*
|
|
503
|
-
* @param claim Claim to be returned
|
|
504
|
-
* @returns Observable for: Value of claim within current user token || null (if not signed in) || undefined (if no such claim exists)
|
|
505
|
-
*/
|
|
506
|
-
selectCurrentUserClaim(claim) {
|
|
507
|
-
return new Observable(subscriber => {
|
|
508
|
-
// Handler function to process the ID token
|
|
509
|
-
// Emits the claim || undefined || null
|
|
510
|
-
const handleTokenRefresh = (user) => __awaiter(this, void 0, void 0, function* () {
|
|
511
|
-
if (user) {
|
|
512
|
-
const token = yield user.getIdTokenResult();
|
|
513
|
-
subscriber.next(token.claims[claim]);
|
|
514
|
-
}
|
|
515
|
-
else {
|
|
516
|
-
subscriber.next(null);
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
// Subscribe to token refresh events
|
|
520
|
-
this.tokenRefreshed$.subscribe(() => __awaiter(this, void 0, void 0, function* () {
|
|
521
|
-
const user = yield this.afa.currentUser;
|
|
522
|
-
yield handleTokenRefresh(user);
|
|
523
|
-
}));
|
|
524
|
-
// Subscribe to user update events
|
|
525
|
-
this.afa.user.subscribe((user) => __awaiter(this, void 0, void 0, function* () {
|
|
526
|
-
yield handleTokenRefresh(user);
|
|
527
|
-
}));
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
/**
|
|
531
|
-
* Get the value for a custom claim for the current user (extracted from their ID token)
|
|
532
|
-
*
|
|
533
|
-
* @param claim Claim to be returned
|
|
534
|
-
* @returns Value of claim within current user token || null (if not signed in) || undefined (if no such claim exists)
|
|
535
|
-
*/
|
|
536
|
-
getCurrentUserClaim(claim) {
|
|
537
|
-
return this.selectCurrentUserClaim(claim).pipe(take(1)).toPromise();
|
|
538
|
-
}
|
|
539
|
-
/**
|
|
540
|
-
* Reset the password of currently authenticated user via email,
|
|
541
|
-
* Firebase sends an email to the user - and managed the reset process directly via google's hosted pages.
|
|
542
|
-
*
|
|
543
|
-
* @param email - the email to reset
|
|
544
|
-
*/
|
|
545
|
-
resetPassword(email) {
|
|
546
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
547
|
-
try {
|
|
548
|
-
this.fire.addLogMessage('Password reset email sent');
|
|
549
|
-
this.afa.sendPasswordResetEmail(email);
|
|
550
|
-
this.ui.toast('auth.resetPassword.onResetRequestedTo', { duration: this.config.authUi.toastDefaultDurationMil, interpolateParams: { email }, position: 'bottom' });
|
|
551
|
-
}
|
|
552
|
-
catch (error) {
|
|
553
|
-
yield this.handleError(error);
|
|
554
|
-
}
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* General sign in mechanism to authenticate the users with a firebase project
|
|
559
|
-
* using a traditional way, via username and password or by using an authentication provider
|
|
560
|
-
* like google, facebook, twitter and github
|
|
561
|
-
*
|
|
562
|
-
* [Current State -> Target State]
|
|
563
|
-
* Null -> Anon/named: OK
|
|
564
|
-
* Anon -> Anon: Throws Error
|
|
565
|
-
* Anon -> Named: Triggers MergeService
|
|
566
|
-
* Named -> Any: Throws Error
|
|
567
|
-
*
|
|
568
|
-
* @param provider - the provider to authenticate with (google, facebook, twitter, github)
|
|
569
|
-
* @param credentials optional email and password
|
|
570
|
-
*/
|
|
571
|
-
signInWith(provider, options) {
|
|
572
|
-
var _a, _b;
|
|
573
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
574
|
-
this.fire.addLogMessage(`SignInWithProvider; provider=${provider}`);
|
|
575
|
-
const loading = yield this.ui.createLoading();
|
|
576
|
-
try {
|
|
577
|
-
let userCred = null;
|
|
578
|
-
const currentUser = yield this.afa.currentUser;
|
|
579
|
-
// Trigger hook for user merge where an anonymoust user >>> non-anonymous user.
|
|
580
|
-
// Two merge hooks are provided, one run as source user (prepareMergeSource) and once the new non-anonymous user is created
|
|
581
|
-
// a second hook applyMergeToTarget is subsequenrly run. The output from prepareMergeSource is passed into applyMergeToTarget.
|
|
582
|
-
// Don't catch any errors, so they are caught by function and trigger a login abort.
|
|
583
|
-
let mergeContext = null;
|
|
584
|
-
if (currentUser && currentUser.isAnonymous && ((_a = this.hooksService) === null || _a === void 0 ? void 0 : _a.prepareMergeSource) && provider !== AuthProvider.ANONYMOUS) {
|
|
585
|
-
mergeContext = yield this.hooksService.prepareMergeSource(currentUser);
|
|
586
|
-
}
|
|
587
|
-
switch (provider) {
|
|
588
|
-
case AuthProvider.ANONYMOUS:
|
|
589
|
-
if (currentUser) {
|
|
590
|
-
throw new Error('Cannot signIn anonymously whilst already signedIn, SignOut first');
|
|
591
|
-
}
|
|
592
|
-
if (yield this.confirmTos(null, options)) {
|
|
593
|
-
loading.present();
|
|
594
|
-
userCred = yield this.afa.signInAnonymously();
|
|
595
|
-
yield this.confirmTos(userCred, { skipTosCheck: true }); // Save tosAcceptance in firestore if sync enabled
|
|
596
|
-
yield loading.dismiss();
|
|
597
|
-
}
|
|
598
|
-
break;
|
|
599
|
-
case AuthProvider.EmailAndPassword:
|
|
600
|
-
if (currentUser && !currentUser.isAnonymous) {
|
|
601
|
-
throw new Error('Cannot signIn whilst already signedIn, SignOut first');
|
|
602
|
-
}
|
|
603
|
-
if (!(options === null || options === void 0 ? void 0 : options.credentials)) {
|
|
604
|
-
throw new Error('Credentials are required when signing in with AuthProvider.EmailAndPassword');
|
|
605
|
-
}
|
|
606
|
-
loading.present();
|
|
607
|
-
userCred = yield this.afa.signInWithEmailAndPassword(options.credentials.email, options.credentials.password);
|
|
608
|
-
if (!(yield this.confirmTos(userCred, options))) {
|
|
609
|
-
yield this.signOut();
|
|
610
|
-
userCred = null;
|
|
611
|
-
}
|
|
612
|
-
;
|
|
613
|
-
yield loading.dismiss();
|
|
614
|
-
break;
|
|
615
|
-
case AuthProvider.PhoneNumber:
|
|
616
|
-
// coming soon - see feature/sms branch
|
|
617
|
-
break;
|
|
618
|
-
default:
|
|
619
|
-
userCred = yield this.socialSignIn(provider, options);
|
|
620
|
-
break;
|
|
621
|
-
}
|
|
622
|
-
// Will be null if user cancels operation
|
|
623
|
-
if (userCred) {
|
|
624
|
-
if (this.config.authUi.toastMessageOnAuthSuccess) {
|
|
625
|
-
const successMessage = ('string' === typeof this.config.authUi.toastMessageOnAuthSuccess)
|
|
626
|
-
? this.config.authUi.toastMessageOnAuthSuccess
|
|
627
|
-
: `Hello ${userCred.user.displayName ? userCred.user.displayName : ''}!`;
|
|
628
|
-
this.ui.toast(successMessage, { duration: this.config.authUi.toastDefaultDurationMil });
|
|
629
|
-
}
|
|
630
|
-
// Run the merge hook if present and mergeContext has been generated by the prepare hook above.
|
|
631
|
-
if (userCred.user && mergeContext && ((_b = this.hooksService) === null || _b === void 0 ? void 0 : _b.applyMergeToTarget)) {
|
|
632
|
-
try {
|
|
633
|
-
yield this.hooksService.applyMergeToTarget(userCred.user, mergeContext);
|
|
634
|
-
}
|
|
635
|
-
catch (error) {
|
|
636
|
-
// If a failure occurs in merge applyToTarget we can't do much about it (we are already logged in as new user)
|
|
637
|
-
// but we should at least log it. The onus is really on the applyToTarget function to handle it's own errors.
|
|
638
|
-
this.fire.recordException(error);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
this.onSignInEmitter.emit(userCred.user);
|
|
642
|
-
}
|
|
643
|
-
yield loading.dismiss();
|
|
644
|
-
return userCred || null;
|
|
645
|
-
}
|
|
646
|
-
catch (error) {
|
|
647
|
-
// code auth/user-not-found
|
|
648
|
-
yield this.handleError(error);
|
|
649
|
-
yield loading.dismiss();
|
|
650
|
-
return null;
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
/**
|
|
655
|
-
* Reauthenicate the current user - a recent authentication is required for some sensitive operations
|
|
656
|
-
* such as changing account details
|
|
657
|
-
*/
|
|
658
|
-
reauthenicateWithProvider(provider, options) {
|
|
659
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
660
|
-
this.fire.addLogMessage(`reauthenicateWithProvider; provider=${provider}`);
|
|
661
|
-
const loading = yield this.ui.createLoading();
|
|
662
|
-
try {
|
|
663
|
-
let userCred = null;
|
|
664
|
-
// Throw error if reauthentication attempted whilst signed in as guest, nor not signed in.
|
|
665
|
-
const currentUser = yield this.afa.currentUser;
|
|
666
|
-
if (!currentUser || currentUser.isAnonymous) {
|
|
667
|
-
throw new Error('Caanot reauthticate if no currentUser or currentUser is anonymous');
|
|
668
|
-
}
|
|
669
|
-
loading.present();
|
|
670
|
-
switch (provider) {
|
|
671
|
-
case AuthProvider.ANONYMOUS:
|
|
672
|
-
throw new Error('Cannot reauthenticate with anonymous Credentials');
|
|
673
|
-
case AuthProvider.EmailAndPassword:
|
|
674
|
-
if (!(options === null || options === void 0 ? void 0 : options.credentials)) {
|
|
675
|
-
throw new Error('Credentials are required when reauthenticating with AuthProvider.EmailAndPassword');
|
|
676
|
-
}
|
|
677
|
-
if (!currentUser.email) {
|
|
678
|
-
throw new Error('Cannot reauthenticate with email for an account without email');
|
|
679
|
-
}
|
|
680
|
-
if (!firebase.auth) {
|
|
681
|
-
throw new Error('firebase.auth is undefined');
|
|
682
|
-
}
|
|
683
|
-
this.fire.addLogMessage(`creating email credential with firebase; email=${options.credentials.email}`);
|
|
684
|
-
const authCred = firebase.auth.EmailAuthProvider.credential(currentUser.email, options.credentials.password);
|
|
685
|
-
userCred = yield currentUser.reauthenticateWithCredential(authCred);
|
|
686
|
-
break;
|
|
687
|
-
case AuthProvider.PhoneNumber:
|
|
688
|
-
// coming soon - see feature/sms branch
|
|
689
|
-
break;
|
|
690
|
-
default:
|
|
691
|
-
if (this.credFactory && (yield this.credFactory.isProviderSupported(provider))) {
|
|
692
|
-
const factoryCred = yield this.credFactory.getCredential(provider);
|
|
693
|
-
if (factoryCred) {
|
|
694
|
-
userCred = yield currentUser.reauthenticateWithCredential(factoryCred);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
else if (this.isWebPlatform) {
|
|
698
|
-
userCred = yield currentUser.reauthenticateWithPopup(this.getAuthProvider(provider));
|
|
699
|
-
}
|
|
700
|
-
else {
|
|
701
|
-
throw new Error('A CredentialFactory is required to use AuthProcessService on a non-web platform');
|
|
702
|
-
}
|
|
703
|
-
break;
|
|
704
|
-
}
|
|
705
|
-
yield loading.dismiss();
|
|
706
|
-
return userCred || null;
|
|
707
|
-
}
|
|
708
|
-
catch (error) {
|
|
709
|
-
// code auth/user-not-found
|
|
710
|
-
yield this.handleError(error);
|
|
711
|
-
yield loading.dismiss();
|
|
712
|
-
return null;
|
|
713
|
-
}
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Link the current user to credentials from another auth provider.
|
|
718
|
-
*
|
|
719
|
-
* @param provider Provider to link.
|
|
720
|
-
*/
|
|
721
|
-
linkCurrentUserToProvider(provider, options) {
|
|
722
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
723
|
-
this.fire.addLogMessage(`Linking current anon user to provider; provider=${provider}`);
|
|
724
|
-
const loading = yield this.ui.createLoading();
|
|
725
|
-
try {
|
|
726
|
-
const currentUser = yield this.afa.currentUser;
|
|
727
|
-
if (null === currentUser) {
|
|
728
|
-
throw new Error('CurrentUser is null');
|
|
729
|
-
}
|
|
730
|
-
yield loading.present();
|
|
731
|
-
let userCred = null;
|
|
732
|
-
switch (provider) {
|
|
733
|
-
case AuthProvider.ANONYMOUS:
|
|
734
|
-
throw new Error('Linking anonymous user makes no sense');
|
|
735
|
-
case AuthProvider.EmailAndPassword:
|
|
736
|
-
if (!(options === null || options === void 0 ? void 0 : options.credentials)) {
|
|
737
|
-
throw new Error('Credentials required to link to email credentential');
|
|
738
|
-
}
|
|
739
|
-
if (!firebase.auth) {
|
|
740
|
-
throw new Error('firebase.auth is undefined');
|
|
741
|
-
}
|
|
742
|
-
this.fire.addLogMessage(`creating email credential with firebase; email=${options.credentials.email}`);
|
|
743
|
-
const authCred = firebase.auth.EmailAuthProvider.credential(options.credentials.email, options.credentials.password);
|
|
744
|
-
this.fire.addLogMessage(`linking userCredential to email authCredential`);
|
|
745
|
-
userCred = yield currentUser.linkWithCredential(authCred);
|
|
746
|
-
break;
|
|
747
|
-
case AuthProvider.PhoneNumber:
|
|
748
|
-
throw new Error('Linking phone number not suported');
|
|
749
|
-
default:
|
|
750
|
-
if (this.credFactory && (yield this.credFactory.isProviderSupported(provider))) {
|
|
751
|
-
const factoryCred = yield this.credFactory.getCredential(provider);
|
|
752
|
-
if (factoryCred) {
|
|
753
|
-
userCred = yield currentUser.linkWithCredential(factoryCred);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
else if (this.isWebPlatform) {
|
|
757
|
-
userCred = yield currentUser.linkWithPopup(this.getAuthProvider(provider));
|
|
758
|
-
}
|
|
759
|
-
else {
|
|
760
|
-
throw new Error('A CredentialFactory is required to use AuthProcessService on a non-web platform');
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
if (userCred && userCred.user) { // Null if user cancels (or perhaps fails) sign-in
|
|
764
|
-
const userData = this.parseUserInfo(userCred.user);
|
|
765
|
-
if (userData.displayName
|
|
766
|
-
&& (userCred.user.displayName !== userData.displayName || userCred.user.photoURL !== userData.displayName)) {
|
|
767
|
-
this.fire.addLogMessage(`Updating user profile; displayName=${userData.displayName}, photoUrl=${userData.photoURL}`); // tslint:disable-line max-line-length
|
|
768
|
-
yield this.updateUserInfo({ displayName: userData.displayName, photoURL: userData.photoURL });
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
yield loading.dismiss();
|
|
772
|
-
return userCred || null;
|
|
773
|
-
}
|
|
774
|
-
catch (error) {
|
|
775
|
-
// Merge
|
|
776
|
-
yield this.handleError(error);
|
|
777
|
-
yield loading.dismiss();
|
|
778
|
-
return null;
|
|
779
|
-
}
|
|
780
|
-
});
|
|
781
|
-
}
|
|
782
|
-
/**
|
|
783
|
-
* Creates a firebase user account authenticated with the specified provider.
|
|
784
|
-
* If AuthProvider.EmailAndPassword is specified credentials and displayname must also be provided.
|
|
785
|
-
*/
|
|
786
|
-
registerWith(provider, options) {
|
|
787
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
788
|
-
this.fire.addLogMessage(`SigningUp with provider; provider=${provider}`);
|
|
789
|
-
const loading = yield this.ui.createLoading();
|
|
790
|
-
try {
|
|
791
|
-
// If the current user is anonymous - link the credentials to the existing user.
|
|
792
|
-
// Otherwise if the user is logged in un-Anonymously, throw error
|
|
793
|
-
const currentUser = yield this.afa.currentUser;
|
|
794
|
-
if (currentUser === null || currentUser === void 0 ? void 0 : currentUser.isAnonymous) { // Anonymous User
|
|
795
|
-
return this.linkCurrentUserToProvider(provider, options);
|
|
796
|
-
}
|
|
797
|
-
else if (null !== currentUser) { // Non-Anonymous User
|
|
798
|
-
throw new Error('Cannot Register whilst signed in as a non-Anonymous user. SignOut first');
|
|
799
|
-
}
|
|
800
|
-
else if (!(yield this.confirmTos(null, options))) { // No current user
|
|
801
|
-
this.fire.addLogMessage('User declined TOS during register');
|
|
802
|
-
return null;
|
|
803
|
-
}
|
|
804
|
-
let userCred = null;
|
|
805
|
-
switch (provider) {
|
|
806
|
-
case AuthProvider.EmailAndPassword:
|
|
807
|
-
if (!(options === null || options === void 0 ? void 0 : options.credentials) || !(options === null || options === void 0 ? void 0 : options.displayName)) {
|
|
808
|
-
throw new Error('Credentials & displayName required to SignUp by email');
|
|
809
|
-
}
|
|
810
|
-
yield loading.present();
|
|
811
|
-
this.fire.addLogMessage(`creaating user with email and password; email=${options.credentials.email}`);
|
|
812
|
-
userCred = yield this.afa.createUserWithEmailAndPassword(options.credentials.email, options.credentials.password);
|
|
813
|
-
if (null === userCred.user) {
|
|
814
|
-
throw new Error('User is null following successful signUp');
|
|
815
|
-
}
|
|
816
|
-
yield this.updateUserInfo({ displayName: options.displayName });
|
|
817
|
-
yield this.confirmTos(userCred, { skipTosCheck: true }); // To save the tosAcceptance
|
|
818
|
-
if (this.config.authUi.enableEmailVerification) {
|
|
819
|
-
yield userCred.user.sendEmailVerification();
|
|
820
|
-
}
|
|
821
|
-
yield loading.dismiss();
|
|
822
|
-
break;
|
|
823
|
-
default:
|
|
824
|
-
userCred = yield this.socialSignIn(provider, Object.assign(Object.assign({}, options), { skipTosCheck: true }));
|
|
825
|
-
}
|
|
826
|
-
if (userCred.user) {
|
|
827
|
-
this.onRegisterEmitter.emit(userCred.user);
|
|
828
|
-
}
|
|
829
|
-
return userCred || null;
|
|
830
|
-
}
|
|
831
|
-
catch (error) {
|
|
832
|
-
// This is where I would handle merge
|
|
833
|
-
yield this.handleError(error);
|
|
834
|
-
yield loading.dismiss();
|
|
835
|
-
return null;
|
|
836
|
-
}
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
/**
|
|
840
|
-
* Authenticates the user using social provider.
|
|
841
|
-
*
|
|
842
|
-
* @param provider social auth provider
|
|
843
|
-
* @param options
|
|
844
|
-
* @returns user credentials || null if not signed in.
|
|
845
|
-
*/
|
|
846
|
-
socialSignIn(provider, options) {
|
|
847
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
848
|
-
const currentUser = yield this.afa.currentUser;
|
|
849
|
-
const loading = yield this.ui.createLoading();
|
|
850
|
-
let userCred;
|
|
851
|
-
if (currentUser && !currentUser.isAnonymous) {
|
|
852
|
-
throw new Error('Cannot signIn whilst already signedIn, SignOut first');
|
|
853
|
-
}
|
|
854
|
-
if (this.credFactory && (yield this.credFactory.isProviderSupported(provider))) {
|
|
855
|
-
loading.present();
|
|
856
|
-
const factoryCred = yield this.credFactory.getCredential(provider);
|
|
857
|
-
if (factoryCred) {
|
|
858
|
-
userCred = yield this.afa.signInWithCredential(factoryCred);
|
|
859
|
-
}
|
|
860
|
-
yield loading.dismiss();
|
|
861
|
-
}
|
|
862
|
-
else if (this.isWebPlatform) {
|
|
863
|
-
loading.present();
|
|
864
|
-
userCred = yield this.afa.signInWithPopup(this.getAuthProvider(provider));
|
|
865
|
-
yield loading.dismiss();
|
|
866
|
-
/*
|
|
867
|
-
a: null
|
|
868
|
-
code: "auth/popup-closed-by-user"
|
|
869
|
-
message: "The popup has been closed by the user before finalizing the operation."
|
|
870
|
-
__proto__: Error
|
|
871
|
-
*/
|
|
872
|
-
}
|
|
873
|
-
else {
|
|
874
|
-
throw new Error('A CredentialFactory is required to use AuthProcessService on a non-web platform');
|
|
875
|
-
}
|
|
876
|
-
yield loading.dismiss();
|
|
877
|
-
if (!(yield this.confirmTos(userCred, options))) {
|
|
878
|
-
yield this.signOut();
|
|
879
|
-
userCred = null;
|
|
880
|
-
}
|
|
881
|
-
;
|
|
882
|
-
return userCred;
|
|
883
|
-
});
|
|
884
|
-
}
|
|
885
|
-
/**
|
|
886
|
-
* Present dialog and confirm the user agress to the privacy policy and terms of service (if either configured).
|
|
887
|
-
* If nether configured returns true;
|
|
888
|
-
*
|
|
889
|
-
* @returns True if either user agrees to TOS/PrivacyUrl || no TOS/PrivacyUrl configured.
|
|
890
|
-
*/
|
|
891
|
-
confirmTos(userCred = null, options = {}) {
|
|
892
|
-
var _a;
|
|
893
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
894
|
-
if (this.config.authUi.tosUrl || this.config.authUi.privacyPolicyUrl) {
|
|
895
|
-
let acceptedTos = (options.skipTosCheck) ? new Date().toISOString() : null;
|
|
896
|
-
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) {
|
|
897
|
-
const userData = yield this.fireStoreService.getUserData(userCred.user.uid);
|
|
898
|
-
acceptedTos = (userData === null || userData === void 0 ? void 0 : userData.acceptedTos) || null;
|
|
899
|
-
}
|
|
900
|
-
if (!acceptedTos && (yield this.ui.confirmTos())) {
|
|
901
|
-
acceptedTos = new Date().toISOString();
|
|
902
|
-
}
|
|
903
|
-
if ((userCred === null || userCred === void 0 ? void 0 : userCred.user) && this.config.authUi.enableFirestoreSync) {
|
|
904
|
-
yield this.fireStoreService.setUserData(userCred.user.uid, { acceptedTos }, { merge: true });
|
|
905
|
-
}
|
|
906
|
-
return !!acceptedTos;
|
|
907
|
-
}
|
|
908
|
-
else { // No tosUrl || privacyPolicyUrl
|
|
909
|
-
return true;
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
}
|
|
913
|
-
/**
|
|
914
|
-
* Send the currently authenticated user another verficiation email.
|
|
915
|
-
*/
|
|
916
|
-
sendNewVerificationEmail() {
|
|
917
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
918
|
-
try {
|
|
919
|
-
const currentUser = yield this.afa.currentUser;
|
|
920
|
-
if (!currentUser) {
|
|
921
|
-
throw new Error('No signed in user');
|
|
922
|
-
}
|
|
923
|
-
yield currentUser.sendEmailVerification();
|
|
924
|
-
}
|
|
925
|
-
catch (error) {
|
|
926
|
-
this.fire.recordException(error);
|
|
927
|
-
throw error;
|
|
928
|
-
}
|
|
929
|
-
});
|
|
930
|
-
}
|
|
931
|
-
/**
|
|
932
|
-
* SignOut the currently authenticated user.
|
|
933
|
-
*/
|
|
934
|
-
signOut() {
|
|
935
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
936
|
-
try {
|
|
937
|
-
yield this.afa.signOut();
|
|
938
|
-
if (this.credFactory) {
|
|
939
|
-
this.credFactory.signOut();
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
catch (error) {
|
|
943
|
-
yield this.handleError(error);
|
|
944
|
-
}
|
|
945
|
-
});
|
|
946
|
-
}
|
|
947
|
-
/**
|
|
948
|
-
* Update the details for the authenticated user of in the firebase authentication and sync with firestore.
|
|
949
|
-
*
|
|
950
|
-
* @param userInfo - UserInfo object containing those properties for which change is requried. Only provider
|
|
951
|
-
* the properties actually to be changed. Others should be ommitted.
|
|
952
|
-
*/
|
|
953
|
-
updateUserInfo(userInfo) {
|
|
954
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
955
|
-
try {
|
|
956
|
-
const user = yield this.afa.currentUser;
|
|
957
|
-
if (!user) {
|
|
958
|
-
throw new Error('No currentUser');
|
|
959
|
-
}
|
|
960
|
-
if (userInfo.email) {
|
|
961
|
-
yield user.updateEmail(userInfo.email);
|
|
962
|
-
}
|
|
963
|
-
if (userInfo.phoneNumber) {
|
|
964
|
-
yield user.updatePhoneNumber(userInfo.phoneNumber); // TODO - bet this doesn't actually work
|
|
965
|
-
}
|
|
966
|
-
if (userInfo.displayName || userInfo.photoURL) {
|
|
967
|
-
yield user.updateProfile({
|
|
968
|
-
displayName: userInfo.displayName,
|
|
969
|
-
photoURL: userInfo.photoURL
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
yield this.afa.updateCurrentUser(user);
|
|
973
|
-
if (this.config.authUi.enableFirestoreSync) {
|
|
974
|
-
// await this.fireStoreService.updateUserData(user.uid, this.parseUserInfo(user));
|
|
975
|
-
yield this.fireStoreService.updateUserData(user.uid, {
|
|
976
|
-
displayName: user.displayName,
|
|
977
|
-
email: user.email,
|
|
978
|
-
photoURL: user.photoURL
|
|
979
|
-
});
|
|
980
|
-
}
|
|
981
|
-
this.onUserUpdatedEmitter.emit();
|
|
982
|
-
}
|
|
983
|
-
catch (error) {
|
|
984
|
-
this.fire.recordException(error);
|
|
985
|
-
}
|
|
986
|
-
});
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Extract UserInfo object from the User object
|
|
990
|
-
* If multiple providers are supplied these are amalgamated to create the most complete
|
|
991
|
-
* UserInfo object possible
|
|
992
|
-
*/
|
|
993
|
-
parseUserInfo(user) {
|
|
994
|
-
const userInfo = {
|
|
995
|
-
uid: user.uid,
|
|
996
|
-
displayName: user.displayName,
|
|
997
|
-
email: user.email,
|
|
998
|
-
phoneNumber: user.phoneNumber,
|
|
999
|
-
photoURL: user.photoURL,
|
|
1000
|
-
providerId: user.providerId
|
|
1001
|
-
};
|
|
1002
|
-
if (user.providerData) {
|
|
1003
|
-
user.providerData.forEach(item => {
|
|
1004
|
-
if (!userInfo.displayName && (item === null || item === void 0 ? void 0 : item.displayName)) {
|
|
1005
|
-
userInfo.displayName = item.displayName;
|
|
1006
|
-
}
|
|
1007
|
-
if (!userInfo.email && (item === null || item === void 0 ? void 0 : item.email)) {
|
|
1008
|
-
userInfo.email = item.email;
|
|
1009
|
-
}
|
|
1010
|
-
if (!userInfo.phoneNumber && (item === null || item === void 0 ? void 0 : item.phoneNumber)) {
|
|
1011
|
-
userInfo.phoneNumber = item.phoneNumber;
|
|
1012
|
-
}
|
|
1013
|
-
if (!userInfo.photoURL && (item === null || item === void 0 ? void 0 : item.photoURL)) {
|
|
1014
|
-
userInfo.photoURL = item.photoURL;
|
|
1015
|
-
}
|
|
1016
|
-
if (!userInfo.providerId && (item === null || item === void 0 ? void 0 : item.providerId)) {
|
|
1017
|
-
userInfo.providerId = item.providerId;
|
|
1018
|
-
}
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
return userInfo;
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* Returns the UserPhotoUrl, or an appropraite placeholder if not provided
|
|
1025
|
-
* ToDo - this would probably bet better inside a user-photo component
|
|
1026
|
-
*/
|
|
1027
|
-
getUserPhotoUrl() {
|
|
1028
|
-
return this.user$.pipe(map((user) => {
|
|
1029
|
-
if (!user) {
|
|
1030
|
-
return null;
|
|
1031
|
-
}
|
|
1032
|
-
else if (user.photoURL) {
|
|
1033
|
-
return user.photoURL;
|
|
1034
|
-
}
|
|
1035
|
-
else if (user.emailVerified) {
|
|
1036
|
-
return `assets/user/${Accounts.CHECK}.svg`;
|
|
1037
|
-
}
|
|
1038
|
-
else if (user.isAnonymous) {
|
|
1039
|
-
return `assets/user/${Accounts.OFF}.svg`;
|
|
1040
|
-
}
|
|
1041
|
-
else {
|
|
1042
|
-
return `assets/user/${Accounts.NONE}.svg`;
|
|
1043
|
-
}
|
|
1044
|
-
}));
|
|
1045
|
-
}
|
|
1046
|
-
/**
|
|
1047
|
-
* Refresh user info. Can be useful for instance to get latest status regarding email verification.
|
|
1048
|
-
*/
|
|
1049
|
-
reloadUserInfo() {
|
|
1050
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1051
|
-
const user = yield this.user$.pipe(take(1)).toPromise();
|
|
1052
|
-
if (user) {
|
|
1053
|
-
yield user.reload();
|
|
1054
|
-
}
|
|
1055
|
-
});
|
|
1056
|
-
}
|
|
1057
|
-
/**
|
|
1058
|
-
* Deletes the current user
|
|
1059
|
-
*/
|
|
1060
|
-
deleteUser() {
|
|
1061
|
-
var _a;
|
|
1062
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1063
|
-
const currentUser = yield this.afa.currentUser;
|
|
1064
|
-
const currentUid = currentUser === null || currentUser === void 0 ? void 0 : currentUser.uid;
|
|
1065
|
-
if (!currentUser || !currentUid) {
|
|
1066
|
-
throw new Error('Unable to delete currentUser if null');
|
|
1067
|
-
}
|
|
1068
|
-
const canDelete = ((_a = this.hooksService) === null || _a === void 0 ? void 0 : _a.beforeDelete) ? yield this.hooksService.beforeDelete(currentUser) : true;
|
|
1069
|
-
// Allow exception from beforeDelete to propgate
|
|
1070
|
-
if (canDelete) {
|
|
1071
|
-
try {
|
|
1072
|
-
// Userdata deleted by DB trigger
|
|
1073
|
-
yield currentUser.delete();
|
|
1074
|
-
this.onUserDeletedEmitter.emit();
|
|
1075
|
-
}
|
|
1076
|
-
catch (error) {
|
|
1077
|
-
if (error.code !== FirebaseErrorCodes.requiresRecentLogin) {
|
|
1078
|
-
this.fire.recordException(error);
|
|
1079
|
-
}
|
|
1080
|
-
throw (error);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
});
|
|
1084
|
-
}
|
|
1085
|
-
/**
|
|
1086
|
-
* Logs the error and provides user error notifcation if appropriate
|
|
1087
|
-
*/
|
|
1088
|
-
handleError(error) {
|
|
1089
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1090
|
-
yield this.fire.recordException(error);
|
|
1091
|
-
this.onErrorEmitter.emit(error);
|
|
1092
|
-
if (this.config.authUi.toastMessageOnAuthError) {
|
|
1093
|
-
let message = 'auth.common.pleaseRetry';
|
|
1094
|
-
if (error && typeof error === 'string') {
|
|
1095
|
-
message = error;
|
|
1096
|
-
}
|
|
1097
|
-
else if (error && error.message) {
|
|
1098
|
-
message = error.message;
|
|
1099
|
-
}
|
|
1100
|
-
else if (error && typeof error === 'object') {
|
|
1101
|
-
message = JSON.stringify(error);
|
|
1102
|
-
}
|
|
1103
|
-
else if (error) {
|
|
1104
|
-
message = error.toString();
|
|
1105
|
-
}
|
|
1106
|
-
yield this.ui.toast(message, { duration: this.config.authUi.toastDefaultDurationMil });
|
|
1107
|
-
}
|
|
1108
|
-
});
|
|
1109
|
-
}
|
|
1110
|
-
/**
|
|
1111
|
-
* Returns a firebase auth provider object for the specified provider
|
|
1112
|
-
*/
|
|
1113
|
-
getAuthProvider(provider) {
|
|
1114
|
-
if (!firebase.auth) {
|
|
1115
|
-
throw new Error('firebase.auth is undefined');
|
|
1116
|
-
}
|
|
1117
|
-
switch (provider) {
|
|
1118
|
-
case AuthProvider.Google: return new firebase.auth.GoogleAuthProvider();
|
|
1119
|
-
case AuthProvider.Apple: return new firebase.auth.OAuthProvider('apple.com');
|
|
1120
|
-
case AuthProvider.Facebook: return new firebase.auth.FacebookAuthProvider();
|
|
1121
|
-
case AuthProvider.Twitter: return new firebase.auth.TwitterAuthProvider();
|
|
1122
|
-
case AuthProvider.Github: return new firebase.auth.GithubAuthProvider();
|
|
1123
|
-
case AuthProvider.Microsoft: return new firebase.auth.OAuthProvider('microsoft.com');
|
|
1124
|
-
case AuthProvider.Yahoo: return new firebase.auth.OAuthProvider('yahoo.com');
|
|
1125
|
-
default: throw new Error(`${provider} is not available as auth provider`);
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
AuthProcessService.ɵprov = ɵɵdefineInjectable({ factory: function AuthProcessService_Factory() { return new AuthProcessService(ɵɵinject(MalSharedConfigToken), ɵɵinject(AuthHooksProviderToken, 8), ɵɵinject(MalCredentialFactoryProviderToken, 8), ɵɵinject(FirestoreSyncService), ɵɵinject(AngularFireAuth), ɵɵinject(FirebaseService), ɵɵinject(UiService)); }, token: AuthProcessService, providedIn: "root" });
|
|
1130
|
-
AuthProcessService.decorators = [
|
|
1131
|
-
{ type: Injectable, args: [{
|
|
1132
|
-
providedIn: 'root',
|
|
1133
|
-
},] }
|
|
1134
|
-
];
|
|
1135
|
-
AuthProcessService.ctorParameters = () => [
|
|
1136
|
-
{ type: undefined, decorators: [{ type: Inject, args: [forwardRef(() => MalSharedConfigToken),] }] },
|
|
1137
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [forwardRef(() => AuthHooksProviderToken),] }] },
|
|
1138
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [forwardRef(() => MalCredentialFactoryProviderToken),] }] },
|
|
1139
|
-
{ type: FirestoreSyncService },
|
|
1140
|
-
{ type: AngularFireAuth },
|
|
1141
|
-
{ type: FirebaseService },
|
|
1142
|
-
{ type: UiService }
|
|
1143
|
-
];
|
|
1144
|
-
|
|
1145
|
-
var DisplayWidth;
|
|
1146
|
-
(function (DisplayWidth) {
|
|
1147
|
-
DisplayWidth[DisplayWidth["xs"] = 1] = "xs";
|
|
1148
|
-
DisplayWidth[DisplayWidth["sm"] = 576] = "sm";
|
|
1149
|
-
DisplayWidth[DisplayWidth["md"] = 768] = "md";
|
|
1150
|
-
DisplayWidth[DisplayWidth["lg"] = 992] = "lg";
|
|
1151
|
-
DisplayWidth[DisplayWidth["xl"] = 1200] = "xl";
|
|
1152
|
-
})(DisplayWidth || (DisplayWidth = {}));
|
|
1153
|
-
|
|
1154
|
-
/* @Component({
|
|
1155
|
-
template: ''
|
|
1156
|
-
}) */
|
|
1157
|
-
class ValueAccessorValueComponent {
|
|
1158
|
-
constructor() {
|
|
1159
|
-
this.valueChange = new EventEmitter();
|
|
1160
|
-
this.propagateChange = (_) => { };
|
|
1161
|
-
this.propagateTouch = (_) => { }; // TODO - Not implemented.
|
|
1162
|
-
this.propagateValidatorChange = () => { }; // TODO - Not implemented.
|
|
1163
|
-
}
|
|
1164
|
-
get value() { return this._value; }
|
|
1165
|
-
set value(val) {
|
|
1166
|
-
if (val) {
|
|
1167
|
-
this._value = val;
|
|
1168
|
-
this.valueChange.emit(val);
|
|
1169
|
-
this.propagateChange(val);
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
validate(control) {
|
|
1173
|
-
return null;
|
|
1174
|
-
}
|
|
1175
|
-
writeValue(value) {
|
|
1176
|
-
this.value = value;
|
|
1177
|
-
}
|
|
1178
|
-
registerOnChange(fn) {
|
|
1179
|
-
this.propagateChange = fn;
|
|
1180
|
-
}
|
|
1181
|
-
registerOnTouched(fn) {
|
|
1182
|
-
this.propagateTouch = fn;
|
|
1183
|
-
}
|
|
1184
|
-
registerOnValidatorChange(fn) {
|
|
1185
|
-
this.propagateValidatorChange = fn;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
ValueAccessorValueComponent.propDecorators = {
|
|
1189
|
-
value: [{ type: Input }],
|
|
1190
|
-
valueChange: [{ type: Output }]
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
|
-
/* @Component({
|
|
1194
|
-
template: ''
|
|
1195
|
-
}) */
|
|
1196
|
-
class ValueAccessorControlComponent {
|
|
1197
|
-
constructor(injector, cdRef) {
|
|
1198
|
-
this.injector = injector;
|
|
1199
|
-
this.cdRef = cdRef;
|
|
1200
|
-
this.destroy$ = new ReplaySubject();
|
|
1201
|
-
this.valueChange = new EventEmitter();
|
|
1202
|
-
this.propagateChange = (val) => { };
|
|
1203
|
-
this.propagateTouch = () => { };
|
|
1204
|
-
this.propagateValidatorChange = () => { };
|
|
1205
|
-
}
|
|
1206
|
-
get _control() {
|
|
1207
|
-
if (!this.control) {
|
|
1208
|
-
throw new Error('ValueAccessorControlComponent: this.control must be eclipsed in the subclass');
|
|
1209
|
-
}
|
|
1210
|
-
return this.control;
|
|
1211
|
-
}
|
|
1212
|
-
set value(val) {
|
|
1213
|
-
if (val) {
|
|
1214
|
-
this._control.setValue(val);
|
|
1215
|
-
}
|
|
1216
|
-
else {
|
|
1217
|
-
this._control.reset();
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
get value() {
|
|
1221
|
-
return this._control.value;
|
|
1222
|
-
}
|
|
1223
|
-
ngOnInit() {
|
|
1224
|
-
this._control.valueChanges
|
|
1225
|
-
.pipe(takeUntil(this.destroy$))
|
|
1226
|
-
.subscribe(val => {
|
|
1227
|
-
if (this._control.dirty) {
|
|
1228
|
-
this.propagateChange(val);
|
|
1229
|
-
this.propagateTouch();
|
|
1230
|
-
this.valueChange.emit(val);
|
|
1231
|
-
}
|
|
1232
|
-
});
|
|
1233
|
-
this._control.statusChanges
|
|
1234
|
-
.pipe(takeUntil(this.destroy$))
|
|
1235
|
-
.subscribe(() => this.propagateValidatorChange());
|
|
1236
|
-
}
|
|
1237
|
-
ngAfterViewInit() {
|
|
1238
|
-
this.parentControl = this.injector.get(NgControl, null);
|
|
1239
|
-
this.cdRef.detectChanges();
|
|
1240
|
-
}
|
|
1241
|
-
ngOnDestroy() {
|
|
1242
|
-
this.destroy$.next();
|
|
1243
|
-
this.destroy$.complete();
|
|
1244
|
-
}
|
|
1245
|
-
writeValue(value) {
|
|
1246
|
-
this.value = value;
|
|
1247
|
-
}
|
|
1248
|
-
registerOnChange(fn) {
|
|
1249
|
-
this.propagateChange = fn;
|
|
1250
|
-
}
|
|
1251
|
-
registerOnTouched(fn) {
|
|
1252
|
-
this.propagateTouch = fn;
|
|
1253
|
-
}
|
|
1254
|
-
registerOnValidatorChange(fn) {
|
|
1255
|
-
this.propagateValidatorChange = fn;
|
|
1256
|
-
}
|
|
1257
|
-
setDisabledState(isDisabled) {
|
|
1258
|
-
if (isDisabled) {
|
|
1259
|
-
this._control.disable();
|
|
1260
|
-
}
|
|
1261
|
-
else {
|
|
1262
|
-
this._control.enable();
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
validate(control) {
|
|
1266
|
-
return this._control.errors;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
ValueAccessorControlComponent.propDecorators = {
|
|
1270
|
-
value: [{ type: Input }],
|
|
1271
|
-
valueChange: [{ type: Output }]
|
|
1272
|
-
};
|
|
1273
|
-
|
|
1274
|
-
class LoggedInGuard {
|
|
1275
|
-
constructor(config, router, aps) {
|
|
1276
|
-
this.config = config;
|
|
1277
|
-
this.router = router;
|
|
1278
|
-
this.aps = aps;
|
|
1279
|
-
}
|
|
1280
|
-
guardOutcome(redirectUrl) {
|
|
1281
|
-
return this.aps.user$.pipe(take(1), map((user) => {
|
|
1282
|
-
if (user) {
|
|
1283
|
-
if (this.config.authUi.guardProtectedRoutesUntilEmailIsVerified && !user.emailVerified) {
|
|
1284
|
-
if (this.config.authUi.authGuardVerifyEmailURL) {
|
|
1285
|
-
return this.router.createUrlTree([`${this.config.authUi.authGuardVerifyEmailURL}`], { queryParams: { redirectUrl } });
|
|
1286
|
-
}
|
|
1287
|
-
else if (this.config.authUi.authGuardFallbackURL) {
|
|
1288
|
-
return this.router.createUrlTree([`${this.config.authUi.authGuardFallbackURL}`], { queryParams: { redirectUrl } });
|
|
1289
|
-
}
|
|
1290
|
-
else {
|
|
1291
|
-
return false;
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
else {
|
|
1295
|
-
return true;
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
else {
|
|
1299
|
-
if (this.config.authUi.authGuardFallbackURL) {
|
|
1300
|
-
return this.router.createUrlTree([`${this.config.authUi.authGuardFallbackURL}`], { queryParams: { redirectUrl } });
|
|
1301
|
-
}
|
|
1302
|
-
return false;
|
|
1303
|
-
}
|
|
1304
|
-
}));
|
|
1305
|
-
}
|
|
1306
|
-
canLoad(route, segments) {
|
|
1307
|
-
return this.guardOutcome(segments[0].parameters.url);
|
|
1308
|
-
}
|
|
1309
|
-
canActivate(route, state) {
|
|
1310
|
-
return this.guardOutcome(state.url);
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
LoggedInGuard.ɵprov = ɵɵdefineInjectable({ factory: function LoggedInGuard_Factory() { return new LoggedInGuard(ɵɵinject(MalSharedConfigToken), ɵɵinject(Router), ɵɵinject(AuthProcessService)); }, token: LoggedInGuard, providedIn: "root" });
|
|
1314
|
-
LoggedInGuard.decorators = [
|
|
1315
|
-
{ type: Injectable, args: [{
|
|
1316
|
-
providedIn: 'root'
|
|
1317
|
-
},] }
|
|
1318
|
-
];
|
|
1319
|
-
LoggedInGuard.ctorParameters = () => [
|
|
1320
|
-
{ type: undefined, decorators: [{ type: Inject, args: [MalSharedConfigToken,] }] },
|
|
1321
|
-
{ type: Router },
|
|
1322
|
-
{ type: AuthProcessService }
|
|
1323
|
-
];
|
|
1324
|
-
|
|
1325
|
-
class VerifyEmailGuard {
|
|
1326
|
-
constructor(config, router, aps) {
|
|
1327
|
-
this.config = config;
|
|
1328
|
-
this.router = router;
|
|
1329
|
-
this.aps = aps;
|
|
1330
|
-
}
|
|
1331
|
-
canActivate(route, state) {
|
|
1332
|
-
return this.aps.user$.pipe(map(user => {
|
|
1333
|
-
if (user
|
|
1334
|
-
&& !user.emailVerified
|
|
1335
|
-
&& !user.isAnonymous
|
|
1336
|
-
&& this.config.authUi.authGuardVerifyEmailURL) {
|
|
1337
|
-
return this.router.createUrlTree([`${this.config.authUi.authGuardVerifyEmailURL}`], { queryParams: { redirectUrl: state.url } });
|
|
1338
|
-
}
|
|
1339
|
-
else {
|
|
1340
|
-
return true;
|
|
1341
|
-
}
|
|
1342
|
-
}));
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
VerifyEmailGuard.ɵprov = ɵɵdefineInjectable({ factory: function VerifyEmailGuard_Factory() { return new VerifyEmailGuard(ɵɵinject(MalSharedConfigToken), ɵɵinject(Router), ɵɵinject(AuthProcessService)); }, token: VerifyEmailGuard, providedIn: "root" });
|
|
1346
|
-
VerifyEmailGuard.decorators = [
|
|
1347
|
-
{ type: Injectable, args: [{
|
|
1348
|
-
providedIn: 'root'
|
|
1349
|
-
},] }
|
|
1350
|
-
];
|
|
1351
|
-
VerifyEmailGuard.ctorParameters = () => [
|
|
1352
|
-
{ type: undefined, decorators: [{ type: Inject, args: [MalSharedConfigToken,] }] },
|
|
1353
|
-
{ type: Router },
|
|
1354
|
-
{ type: AuthProcessService }
|
|
1355
|
-
];
|
|
1356
|
-
|
|
1357
|
-
// @angular/*
|
|
1358
|
-
const MODULES = [
|
|
1359
|
-
HttpClientModule,
|
|
1360
|
-
AngularFireAuthModule,
|
|
1361
|
-
AngularFirestoreModule,
|
|
1362
|
-
AngularFireFunctionsModule
|
|
1363
|
-
];
|
|
1364
|
-
class MalSharedModule {
|
|
1365
|
-
static forRoot(config, appNameFactory = () => undefined) {
|
|
1366
|
-
var _a;
|
|
1367
|
-
return {
|
|
1368
|
-
ngModule: MalSharedModule,
|
|
1369
|
-
providers: [
|
|
1370
|
-
{
|
|
1371
|
-
provide: MalUserProvidedConfigToken,
|
|
1372
|
-
useValue: config
|
|
1373
|
-
},
|
|
1374
|
-
{
|
|
1375
|
-
provide: MalSharedConfigToken,
|
|
1376
|
-
useFactory: malSharedConfigFactory,
|
|
1377
|
-
deps: [MalUserProvidedConfigToken]
|
|
1378
|
-
},
|
|
1379
|
-
{
|
|
1380
|
-
provide: DEFAULTS,
|
|
1381
|
-
useValue: config.configDefaults
|
|
1382
|
-
},
|
|
1383
|
-
{
|
|
1384
|
-
provide: SETTINGS,
|
|
1385
|
-
useFactory: () => isDevMode() ? { minimumFetchIntervalMillis: 3600000 } : {} // 1 hour§
|
|
1386
|
-
},
|
|
1387
|
-
{
|
|
1388
|
-
provide: FIREBASE_OPTIONS,
|
|
1389
|
-
useValue: config.firebase
|
|
1390
|
-
},
|
|
1391
|
-
{
|
|
1392
|
-
provide: FIREBASE_APP_NAME,
|
|
1393
|
-
useFactory: appNameFactory
|
|
1394
|
-
},
|
|
1395
|
-
{
|
|
1396
|
-
provide: USE_EMULATOR,
|
|
1397
|
-
useFactory: authEmulatorFactory,
|
|
1398
|
-
deps: [MalSharedConfigToken]
|
|
1399
|
-
},
|
|
1400
|
-
{
|
|
1401
|
-
provide: USE_EMULATOR$1,
|
|
1402
|
-
useFactory: firestoreEmulatorFactory,
|
|
1403
|
-
deps: [MalSharedConfigToken]
|
|
1404
|
-
},
|
|
1405
|
-
{
|
|
1406
|
-
provide: USE_EMULATOR$2,
|
|
1407
|
-
useFactory: functionsEmulatorFactory,
|
|
1408
|
-
deps: [MalSharedConfigToken]
|
|
1409
|
-
},
|
|
1410
|
-
{
|
|
1411
|
-
provide: REGION,
|
|
1412
|
-
useValue: ((_a = config.services) === null || _a === void 0 ? void 0 : _a.firebaseRegion) || null
|
|
1413
|
-
},
|
|
1414
|
-
{
|
|
1415
|
-
provide: AngularFirePerformance,
|
|
1416
|
-
useFactory: performanceProviderFactory,
|
|
1417
|
-
deps: [
|
|
1418
|
-
MalSharedConfigToken,
|
|
1419
|
-
FirebaseApp,
|
|
1420
|
-
[new Optional(), DATA_COLLECTION_ENABLED],
|
|
1421
|
-
[new Optional(), INSTRUMENTATION_ENABLED],
|
|
1422
|
-
NgZone,
|
|
1423
|
-
PLATFORM_ID
|
|
1424
|
-
]
|
|
1425
|
-
},
|
|
1426
|
-
{
|
|
1427
|
-
provide: AngularFireRemoteConfig,
|
|
1428
|
-
useFactory: remoteConfigFirebaseService,
|
|
1429
|
-
deps: [
|
|
1430
|
-
MalSharedConfigToken,
|
|
1431
|
-
FIREBASE_OPTIONS,
|
|
1432
|
-
FIREBASE_APP_NAME,
|
|
1433
|
-
SETTINGS,
|
|
1434
|
-
DEFAULTS,
|
|
1435
|
-
NgZone,
|
|
1436
|
-
PLATFORM_ID
|
|
1437
|
-
]
|
|
1438
|
-
},
|
|
1439
|
-
AnalyticsService,
|
|
1440
|
-
CrashlyticsService,
|
|
1441
|
-
FirebaseService,
|
|
1442
|
-
UiService,
|
|
1443
|
-
RemoteConfigService,
|
|
1444
|
-
AuthProcessService,
|
|
1445
|
-
FirestoreSyncService,
|
|
1446
|
-
PerformanceService,
|
|
1447
|
-
AngularFireAuth,
|
|
1448
|
-
LoggedInGuard,
|
|
1449
|
-
VerifyEmailGuard
|
|
1450
|
-
],
|
|
1451
|
-
};
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
MalSharedModule.decorators = [
|
|
1455
|
-
{ type: NgModule, args: [{
|
|
1456
|
-
imports: [
|
|
1457
|
-
...MODULES,
|
|
1458
|
-
TranslateModule.forChild(),
|
|
1459
|
-
AngularFireModule,
|
|
1460
|
-
],
|
|
1461
|
-
exports: [
|
|
1462
|
-
...MODULES,
|
|
1463
|
-
TranslateModule
|
|
1464
|
-
]
|
|
1465
|
-
},] }
|
|
1466
|
-
];
|
|
1467
|
-
function performanceProviderFactory(config, app, dataCollectionEnabled, instrumentationEnabled, zone, platformId) {
|
|
1468
|
-
if (config.services.firebasePerformance) {
|
|
1469
|
-
return new AngularFirePerformance(app, dataCollectionEnabled, instrumentationEnabled, zone, platformId);
|
|
1470
|
-
}
|
|
1471
|
-
return null;
|
|
1472
|
-
}
|
|
1473
|
-
function remoteConfigFirebaseService(config, options, nameOrConfig, settings, defaultConfig, zone, platformId) {
|
|
1474
|
-
if (config.services.firebaseRemoteConfig) {
|
|
1475
|
-
return new AngularFireRemoteConfig(options, nameOrConfig, settings, defaultConfig, zone, platformId);
|
|
1476
|
-
}
|
|
1477
|
-
return null;
|
|
1478
|
-
}
|
|
1479
|
-
function authEmulatorFactory(config) {
|
|
1480
|
-
if (true === config.services.firebaseAuth) {
|
|
1481
|
-
return undefined;
|
|
1482
|
-
}
|
|
1483
|
-
else {
|
|
1484
|
-
return config.services.firebaseAuth;
|
|
1485
|
-
}
|
|
1486
|
-
}
|
|
1487
|
-
function firestoreEmulatorFactory(config) {
|
|
1488
|
-
if (true === config.services.firebaseFirestore) {
|
|
1489
|
-
return undefined;
|
|
1490
|
-
}
|
|
1491
|
-
else {
|
|
1492
|
-
return config.services.firebaseFirestore;
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
function functionsEmulatorFactory(config) {
|
|
1496
|
-
if (true === config.services.firebaseFunctions) {
|
|
1497
|
-
return undefined;
|
|
1498
|
-
}
|
|
1499
|
-
else {
|
|
1500
|
-
return config.services.firebaseFunctions;
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
/**
|
|
1505
|
-
* Generated bundle index. Do not edit.
|
|
1506
|
-
*/
|
|
1507
|
-
|
|
1508
|
-
export { Accounts, AnalyticsService, AuthHooksProviderToken, AuthProcessService, AuthProvider, CrashlyticsService, DisplayWidth, FirebaseErrorCodes, FirebaseService, FirestoreSyncService, LoggedInGuard, MalAlertsUIProviderToken, MalAnalyticsProviderToken, MalAuthServiceProviderToken, MalCrashlyticsProviderToken, MalCredentialFactoryProviderToken, MalDeviceInfoService, MalLegaliyDialogUIProiderToken, MalLoadingUIProviderToken, 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, AuthHooksProviderToken as ɵf, MalCredentialFactoryProviderToken as ɵg, MalToastUIProviderToken as ɵk, MalAlertsUIProviderToken as ɵl, MalLoadingUIProviderToken as ɵm, MalLegaliyDialogUIProiderToken as ɵn };
|
|
1509
|
-
//# sourceMappingURL=ngx-firebase.js.map
|