1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ import * as impl from '@firebase/auth-exp' ;
19
+ import { UserImpl } from '@firebase/auth-exp/src/core/user/user_impl' ;
20
+ import { UserParameters } from '@firebase/auth-exp/src/model/user' ;
21
+ import * as compat from '@firebase/auth-types' ;
22
+ import * as externs from '@firebase/auth-types-exp' ;
23
+ import '@firebase/installations' ;
24
+ import { convertComfirmationResult , convertCredential } from './user_credential' ;
25
+
26
+ export class User extends UserImpl implements compat . User {
27
+ readonly multiFactor : compat . MultiFactorUser ;
28
+
29
+ constructor ( params : UserParameters ) {
30
+ super ( params ) ;
31
+ this . multiFactor = impl . multiFactor ( this ) ;
32
+ }
33
+
34
+ getIdTokenResult ( forceRefresh ?: boolean ) : Promise < compat . IdTokenResult > {
35
+ return impl . getIdTokenResult ( this , forceRefresh ) ;
36
+ }
37
+ getIdToken ( forceRefresh ?: boolean ) : Promise < string > {
38
+ return impl . getIdToken ( this , forceRefresh ) ;
39
+ }
40
+ linkAndRetrieveDataWithCredential (
41
+ credential : compat . AuthCredential
42
+ ) : Promise < compat . UserCredential > {
43
+ return this . linkWithCredential ( credential ) ;
44
+ }
45
+ async linkWithCredential ( credential : compat . AuthCredential ) : Promise < compat . UserCredential > {
46
+ return convertCredential ( impl . linkWithCredential ( this , credential as externs . AuthCredential ) ) ;
47
+ }
48
+ async linkWithPhoneNumber (
49
+ phoneNumber : string ,
50
+ applicationVerifier : compat . ApplicationVerifier
51
+ ) : Promise < compat . ConfirmationResult > {
52
+ return convertComfirmationResult ( impl . linkWithPhoneNumber ( this , phoneNumber , applicationVerifier ) ) ;
53
+ }
54
+ async linkWithPopup ( provider : compat . AuthProvider ) : Promise < compat . UserCredential > {
55
+ return convertCredential ( impl . linkWithPopup ( this , provider as externs . AuthProvider , impl . browserPopupRedirectResolver ) ) ;
56
+ }
57
+ linkWithRedirect ( provider : compat . AuthProvider ) : Promise < void > {
58
+ return impl . linkWithRedirect ( this , provider as externs . AuthProvider , impl . browserPopupRedirectResolver ) ;
59
+ }
60
+ reauthenticateAndRetrieveDataWithCredential (
61
+ credential : compat . AuthCredential
62
+ ) : Promise < compat . UserCredential > {
63
+ return this . reauthenticateWithCredential ( credential ) ;
64
+ }
65
+ async reauthenticateWithCredential (
66
+ credential : compat . AuthCredential
67
+ ) : Promise < compat . UserCredential > {
68
+ return convertCredential ( impl . reauthenticateWithCredential ( this , credential as externs . AuthCredential ) ) ;
69
+ }
70
+ reauthenticateWithPhoneNumber (
71
+ phoneNumber : string ,
72
+ applicationVerifier : compat . ApplicationVerifier
73
+ ) : Promise < compat . ConfirmationResult > {
74
+ return convertComfirmationResult ( impl . reauthenticateWithPhoneNumber ( this , phoneNumber , applicationVerifier ) ) ;
75
+ }
76
+ reauthenticateWithPopup ( provider : compat . AuthProvider ) : Promise < compat . UserCredential > {
77
+ return convertCredential ( impl . reauthenticateWithPopup ( this , provider as externs . AuthProvider , impl . browserPopupRedirectResolver ) ) ;
78
+ }
79
+ reauthenticateWithRedirect ( provider : compat . AuthProvider ) : Promise < void > {
80
+ return impl . reauthenticateWithRedirect ( this , provider as externs . AuthProvider , impl . browserPopupRedirectResolver ) ;
81
+ }
82
+ sendEmailVerification (
83
+ actionCodeSettings ?: compat . ActionCodeSettings | null
84
+ ) : Promise < void > {
85
+ return impl . sendEmailVerification ( this , actionCodeSettings ) ;
86
+ }
87
+ async unlink ( providerId : string ) : Promise < compat . User > {
88
+ await impl . unlink ( this , providerId as externs . ProviderId ) ;
89
+ return this ;
90
+ }
91
+ updateEmail ( newEmail : string ) : Promise < void > {
92
+ return impl . updateEmail ( this , newEmail ) ;
93
+ }
94
+ updatePassword ( newPassword : string ) : Promise < void > {
95
+ return impl . updatePassword ( this , newPassword ) ;
96
+ }
97
+ updatePhoneNumber ( phoneCredential : compat . AuthCredential ) : Promise < void > {
98
+ return impl . updatePhoneNumber ( this , phoneCredential as externs . AuthCredential ) ;
99
+ }
100
+ updateProfile ( profile : {
101
+ displayName ?: string | null ;
102
+ photoURL ?: string | null ;
103
+ } ) : Promise < void > {
104
+ return impl . updateProfile ( this , profile ) ;
105
+ }
106
+ verifyBeforeUpdateEmail (
107
+ newEmail : string ,
108
+ actionCodeSettings ?: compat . ActionCodeSettings | null
109
+ ) : Promise < void > {
110
+ return impl . verifyBeforeUpdateEmail ( this , newEmail , actionCodeSettings ) ;
111
+ }
112
+ }
0 commit comments