@@ -7,13 +7,26 @@ import {
7
7
inject ,
8
8
} from '@angular/core' ;
9
9
import { FirebaseApps } from '@angular/fire/app' ;
10
- import { type FirebaseUI as FirebaseUIType , getTranslation } from '@firebase-ui/core' ;
10
+ import {
11
+ type FirebaseUI as FirebaseUIType ,
12
+ getTranslation ,
13
+ } from '@firebase-ui/core' ;
11
14
import { distinctUntilChanged , map , takeUntil } from 'rxjs/operators' ;
12
15
import { Observable , ReplaySubject } from 'rxjs' ;
13
16
import { Store } from 'nanostores' ;
14
17
import { TranslationCategory , TranslationKey } from '@firebase-ui/translations' ;
15
18
16
- const FIREBASE_UI_STORE = new InjectionToken < FirebaseUIType > ( 'firebaseui.store' ) ;
19
+ const FIREBASE_UI_STORE = new InjectionToken < FirebaseUIType > (
20
+ 'firebaseui.store' ,
21
+ ) ;
22
+ const FIREBASE_UI_POLICIES = new InjectionToken < PolicyConfig > (
23
+ 'firebaseui.policies' ,
24
+ ) ;
25
+
26
+ type PolicyConfig = {
27
+ termsOfServiceUrl : string ;
28
+ privacyPolicyUrl : string ;
29
+ } ;
17
30
18
31
export function provideFirebaseUI (
19
32
uiFactory : ( apps : FirebaseApps ) => FirebaseUIType ,
@@ -27,6 +40,14 @@ export function provideFirebaseUI(
27
40
return makeEnvironmentProviders ( providers ) ;
28
41
}
29
42
43
+ export function provideFirebaseUIPolicies ( factory : ( ) => PolicyConfig ) {
44
+ const providers : Provider [ ] = [
45
+ { provide : FIREBASE_UI_POLICIES , useFactory : factory } ,
46
+ ] ;
47
+
48
+ return makeEnvironmentProviders ( providers ) ;
49
+ }
50
+
30
51
@Injectable ( {
31
52
providedIn : 'root' ,
32
53
} )
@@ -43,9 +64,7 @@ export class FirebaseUI {
43
64
key : TranslationKey < T > ,
44
65
) {
45
66
return this . config ( ) . pipe (
46
- map ( ( config ) =>
47
- getTranslation ( config , category , key ) ,
48
- ) ,
67
+ map ( ( config ) => getTranslation ( config , category , key ) ) ,
49
68
) ;
50
69
}
51
70
@@ -61,3 +80,18 @@ export class FirebaseUI {
61
80
this . destroyed$ . complete ( ) ;
62
81
}
63
82
}
83
+
84
+ @Injectable ( {
85
+ providedIn : 'root' ,
86
+ } )
87
+ export class FirebaseUIPolicies {
88
+ private policies = inject ( FIREBASE_UI_POLICIES ) ;
89
+
90
+ get termsOfServiceUrl ( ) {
91
+ return this . policies . termsOfServiceUrl ;
92
+ }
93
+
94
+ get privacyPolicyUrl ( ) {
95
+ return this . policies . privacyPolicyUrl ;
96
+ }
97
+ }
0 commit comments