cordova-plugin-firebase-authentication 5.1.0 → 7.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 +527 -127
- package/package.json +14 -6
- package/plugin.xml +9 -8
- package/src/android/FirebaseAuthenticationPlugin.java +82 -95
- package/src/ios/FirebaseAuthenticationPlugin.h +1 -1
- package/src/ios/FirebaseAuthenticationPlugin.m +2 -0
- package/tsconfig.json +15 -0
- package/types/FirebaseAuthentication.d.ts +252 -0
- package/types/index.d.ts +7 -0
- package/www/FirebaseAuthentication.js +366 -106
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a block as an auth state did change listener. To be invoked when:
|
|
3
|
+
* - The block is registered as a listener,
|
|
4
|
+
* - A user with a different UID from the current user has signed in, or
|
|
5
|
+
* - The current user has signed out.
|
|
6
|
+
* @param {(userDetails: UserDetails | null) => void} callback Callback function
|
|
7
|
+
* @param {(error: string) => void} [errorCallback] Error callback function
|
|
8
|
+
*/
|
|
9
|
+
export function onAuthStateChanged(callback: (userDetails: UserDetails | null) => void, errorCallback?: (error: string) => void): () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the current user in the Firebase instance.
|
|
12
|
+
* @returns {Promise<UserDetails>} Fulfills promise with user details
|
|
13
|
+
*/
|
|
14
|
+
export function getCurrentUser(): Promise<UserDetails>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a JWT token used to identify the user to a Firebase service.
|
|
17
|
+
* @param {boolean} forceRefresh When <code>true</code> cached value is ignored
|
|
18
|
+
* @returns {Promise<string>} Fulfills promis with id token string value
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* cordova.plugins.firebase.auth.getIdToken().then(function(idToken) {
|
|
22
|
+
* // send token to server
|
|
23
|
+
* });
|
|
24
|
+
*/
|
|
25
|
+
export function getIdToken(forceRefresh: boolean): Promise<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new user account with the given email address and password.
|
|
28
|
+
* @param {string} email User account email
|
|
29
|
+
* @param {string} password User accound password
|
|
30
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* cordova.plugins.firebase.auth.createUserWithEmailAndPassword("my@mail.com", "pa55w0rd");
|
|
34
|
+
*/
|
|
35
|
+
export function createUserWithEmailAndPassword(email: string, password: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Initiates email verification for the current user.
|
|
38
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* cordova.plugins.firebase.auth.sendEmailVerification();
|
|
42
|
+
*/
|
|
43
|
+
export function sendEmailVerification(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Triggers the Firebase Authentication backend to send a password-reset email
|
|
46
|
+
* to the given email address, which must correspond to an existing user of your app.
|
|
47
|
+
* @param {string} email User account email
|
|
48
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* cordova.plugins.firebase.auth.sendPasswordResetEmail("my@mail.com");
|
|
52
|
+
*/
|
|
53
|
+
export function sendPasswordResetEmail(email: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Triggers the Firebase Authentication backend to send a password-reset email
|
|
56
|
+
* to the given email address, which must correspond to an existing user of your app.
|
|
57
|
+
* @param {string} email User account email
|
|
58
|
+
* @param {string} password User accound password
|
|
59
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* cordova.plugins.firebase.auth.signInWithEmailAndPassword("my@mail.com", "pa55w0rd");
|
|
63
|
+
*/
|
|
64
|
+
export function signInWithEmailAndPassword(email: string, password: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Create and use temporary anonymous account to authenticate with Firebase.
|
|
67
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* cordova.plugins.firebase.auth.signInAnonymously();
|
|
71
|
+
*/
|
|
72
|
+
export function signInAnonymously(): Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* Uses Google's <code>idToken</code> and <code>accessToken</code> to sign-in into firebase account.
|
|
75
|
+
* @param {string} idToken Google ID token
|
|
76
|
+
* @param {string} accessToken Google Access token
|
|
77
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* // Below we use cordova-plugin-googleplus to trigger Google Login UI
|
|
81
|
+
* window.plugins.googleplus.login({
|
|
82
|
+
* scopes: '... ',
|
|
83
|
+
* webClientId: '1234...',
|
|
84
|
+
* offline: true
|
|
85
|
+
* }, function(res) {
|
|
86
|
+
* cordova.plugins.firebase.auth.signInWithGoogle(res.idToken, res.accessToken).then(function() {
|
|
87
|
+
* console.log("Firebase logged in with Google");
|
|
88
|
+
* }, function(err) {
|
|
89
|
+
* console.error("Firebase login failed", err);
|
|
90
|
+
* });
|
|
91
|
+
* }, function(err) {
|
|
92
|
+
* console.error("Google login failed", err);
|
|
93
|
+
* });
|
|
94
|
+
*/
|
|
95
|
+
export function signInWithGoogle(idToken: string, accessToken: string): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Uses Facebook's <code>accessToken</code> to sign-in into firebase account. In order to
|
|
98
|
+
* retrieve those tokens follow instructions for iOS and Android from Firebase docs.
|
|
99
|
+
* @param {string} accessToken Facebook's access token string
|
|
100
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
101
|
+
*
|
|
102
|
+
* @see https://firebase.google.com/docs/auth/android/facebook-login
|
|
103
|
+
* @see https://firebase.google.com/docs/auth/ios/facebook-login
|
|
104
|
+
*/
|
|
105
|
+
export function signInWithFacebook(accessToken: string): Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Uses Twitter's <code>token</code> and <code>secret</code> to sign-in into firebase account.
|
|
108
|
+
* In order to retrieve those tokens follow instructions for iOS and Android from Firebase docs.
|
|
109
|
+
* @param {string} token Twitter's token string
|
|
110
|
+
* @param {string} secret Twitter's secret string
|
|
111
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
112
|
+
*
|
|
113
|
+
* @see https://firebase.google.com/docs/auth/android/twitter-login
|
|
114
|
+
* @see https://firebase.google.com/docs/auth/ios/twitter-login
|
|
115
|
+
*/
|
|
116
|
+
export function signInWithTwitter(token: string, secret: string): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Uses Apples's <code>idToken</code> and <code>rawNonce</code> to sign-in into firebase account. For getting _idToken_ (_rawNonce_ is optional) you can use `cordova-plugin-sign-in-with-apple` (or any other cordova plugin for Apple Sign-In).
|
|
119
|
+
* @param {string} idToken Apple's ID token string
|
|
120
|
+
* @param {string} rawNonce Apple's raw token string
|
|
121
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* // below we use cordova-plugin-sign-in-with-apple to trigger Apple Login UI
|
|
125
|
+
* cordova.plugins.SignInWithApple.signin({
|
|
126
|
+
* requestedScopes: [0, 1]
|
|
127
|
+
* }, function(res) {
|
|
128
|
+
* cordova.plugins.firebase.auth.signInWithApple(res.identityToken).then(function() {
|
|
129
|
+
* console.log("Firebase logged in with Apple");
|
|
130
|
+
* }, function(err) {
|
|
131
|
+
* console.error("Firebase login failed", err);
|
|
132
|
+
* });
|
|
133
|
+
* }, function(err) {
|
|
134
|
+
* console.error("Apple signin failed", err);
|
|
135
|
+
* });
|
|
136
|
+
*/
|
|
137
|
+
export function signInWithApple(idToken: string, rawNonce: string): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* You can integrate Firebase Authentication with a custom authentication system
|
|
140
|
+
* by modifying your authentication server to produce custom signed tokens when
|
|
141
|
+
* a user successfully signs in. Your app receives this token and uses it to
|
|
142
|
+
* authenticate with Firebase.
|
|
143
|
+
* @param {string} authToken Custom auth token
|
|
144
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
145
|
+
*
|
|
146
|
+
* @see https://firebase.google.com/docs/auth/android/custom-auth
|
|
147
|
+
* @see https://firebase.google.com/docs/auth/ios/custom-auth
|
|
148
|
+
*/
|
|
149
|
+
export function signInWithCustomToken(authToken: string): Promise<void>;
|
|
150
|
+
/**
|
|
151
|
+
* Signs out the current user and clears it from the disk cache.
|
|
152
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* cordova.plugins.firebase.auth.signOut();
|
|
156
|
+
*/
|
|
157
|
+
export function signOut(): Promise<void>;
|
|
158
|
+
/**
|
|
159
|
+
* Starts the phone number verification process for the given phone number.
|
|
160
|
+
*
|
|
161
|
+
* Android supports auto-verify and instant device verification.
|
|
162
|
+
* <b>You must register `onAuthStateChanged` to get callback on instant verification.</b>
|
|
163
|
+
*
|
|
164
|
+
* Maximum allowed value for timeout is 2 minutes. Use 0 to disable SMS-auto-retrieval.
|
|
165
|
+
* If you specify a positive value less than 30 seconds, library will default to 30 seconds.
|
|
166
|
+
* @param {string} phoneNumber Phone number in international format
|
|
167
|
+
* @param {number} [timeoutMillis] Maximum amount of time you are willing to wait for SMS auto-retrieval to be completed by the library.
|
|
168
|
+
* @returns {Promise<string>} Fulfills promise with <code>verificationId</code> to use later for signing in
|
|
169
|
+
*/
|
|
170
|
+
export function verifyPhoneNumber(phoneNumber: string, timeoutMillis?: number): Promise<string>;
|
|
171
|
+
/**
|
|
172
|
+
* Completes phone number verification process and use it to sign in.
|
|
173
|
+
* @param {string} verificationId [description]
|
|
174
|
+
* @param {string} code 6-digit SMS code
|
|
175
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* cordova.plugins.firebase.auth.verifyPhoneNumber("+123456789").then(function(verificationId) {
|
|
179
|
+
* var code = prompt("Enter verification code");
|
|
180
|
+
* if (code) {
|
|
181
|
+
* return cordova.plugins.firebase.auth.signInWithVerificationId(verificationId, code);
|
|
182
|
+
* }
|
|
183
|
+
* }).catch(function(err) {
|
|
184
|
+
* console.error("Phone number verification failed", err);
|
|
185
|
+
* });
|
|
186
|
+
*/
|
|
187
|
+
export function signInWithVerificationId(verificationId: string, code: string): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Sets languageCode to the app’s current language.
|
|
190
|
+
* @param {string} host Emulator host name
|
|
191
|
+
* @param {number} port Emulator port
|
|
192
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* cordova.plugins.firebase.auth.useEmulator('localhost', 8000);
|
|
196
|
+
*/
|
|
197
|
+
export function useEmulator(host: string, port: number): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Updates the current user's profile data.
|
|
200
|
+
* Passing a `null` value will delete the current attribute's value, but not
|
|
201
|
+
* passing a property won't change the current attribute's value.
|
|
202
|
+
* @param {{displayName: string; photoURL: string}} profileDetails User attributes.
|
|
203
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* cordova.plugins.firebase.auth.updateProfile({
|
|
207
|
+
* displayName: "Jane Q. User",
|
|
208
|
+
* photoURL: "https://example.com/jane-q-user/profile.jpg",
|
|
209
|
+
* });
|
|
210
|
+
*/
|
|
211
|
+
export function updateProfile(profileDetails: {
|
|
212
|
+
displayName: string;
|
|
213
|
+
photoURL: string;
|
|
214
|
+
}): Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* Sets languageCode to the app’s current language.
|
|
217
|
+
* @returns {Promise<void>} Callback when operation is completed
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* cordova.plugins.firebase.auth.useAppLanguage();
|
|
221
|
+
*/
|
|
222
|
+
export function useAppLanguage(): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Represents a user's profile information in your Firebase project's user database.
|
|
225
|
+
*/
|
|
226
|
+
export type UserDetails = {
|
|
227
|
+
/**
|
|
228
|
+
* String used to uniquely identify your user in your Firebase project's user database
|
|
229
|
+
*/
|
|
230
|
+
uid: string;
|
|
231
|
+
/**
|
|
232
|
+
* Main display name of this user from the Firebase project's user database
|
|
233
|
+
*/
|
|
234
|
+
displayName: string;
|
|
235
|
+
/**
|
|
236
|
+
* Main email address of the user, as stored in the Firebase project's user database.
|
|
237
|
+
*/
|
|
238
|
+
email: string;
|
|
239
|
+
/**
|
|
240
|
+
* <code>true</code> if the user's email is verified.
|
|
241
|
+
*/
|
|
242
|
+
emailVerified: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Phone number of the user, as stored in the Firebase project's user database, or null if none exists.
|
|
245
|
+
*/
|
|
246
|
+
phoneNumber: string | null;
|
|
247
|
+
/**
|
|
248
|
+
* URL of this user's main profile picture, as stored in the Firebase project's user database.
|
|
249
|
+
*/
|
|
250
|
+
photoURL: string;
|
|
251
|
+
providerId: string;
|
|
252
|
+
};
|