Skip to content

Commit c5c16a4

Browse files
authored
docs(firebase-auth): update (#189)
* wip(firebase-auth): README * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update * chore: update
1 parent 1ca5eeb commit c5c16a4

File tree

1 file changed

+95
-25
lines changed

1 file changed

+95
-25
lines changed

packages/firebase-auth/README.md

Lines changed: 95 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@
1717
* [Phone number auth setup](#phone-number-auth-setup)
1818
* [Sign in user with phone number](#sign-in-user-with-phone-number)
1919
* [Testing phone number auth](#testing-phone-number-auth)
20+
21+
* [API](#api)
22+
* [Auth class](#auth-class)
23+
* [Properties](#properties)
24+
* [Methods](#methods)
25+
* [User](#user)
26+
* [Properties](#properties-1)
27+
* [Methods](#methods-1)
28+
* [UserCredential](#usercredential)
2029
* [License](#license)
2130

2231
## Intro
@@ -90,7 +99,7 @@ import '@nativescript/firebase-auth';
9099
firebase()
91100
.auth()
92101
.signInAnonymously()
93-
.then((cred: UserCredential) => {})
102+
.then((cred: [UserCredential]()) => {})
94103
.catch((error) => {});
95104
```
96105

@@ -107,7 +116,7 @@ import '@nativescript/firebase-auth';
107116
firebase()
108117
.auth()
109118
.createUserWithEmailAndPassword('[email protected]', 'password')
110-
.then((cred: UserCredential) => {})
119+
.then((cred: [UserCredential]()) => {})
111120
.catch((error) => {});
112121
```
113122

@@ -122,7 +131,7 @@ import '@nativescript/firebase-auth';
122131
firebase()
123132
.auth()
124133
.signInWithEmailAndPassword('[email protected]', 'password')
125-
.then((cred: UserCredential) => {})
134+
.then((cred: [UserCredential]()) => {})
126135
.catch((error) => {});
127136
```
128137

@@ -164,6 +173,7 @@ Apple announced that any applications using 3rd party login services (such as Fa
164173

165174
- Next, ensure that the app has the [Sign in with Apple capability](https://developer.apple.com/documentation/xcode/configuring-sign-in-with-apple#Add-the-Sign-in-with-Apple-capability-to-your-app).
166175

176+
167177
- Install the `@nativescript/apple-sign-in` plugin. Use the `signIn` method from the plugin to get the user's credentials from Apple.
168178
- Create an AuthCredential instance from the user's credentials. Call the `signInWithCredential` method passing it the Apple credentials.
169179

@@ -323,21 +333,44 @@ Firebase provides support for locally testing phone numbers:
323333
If providing a test phone number to either the `verifyPhoneNumber` or `signInWithPhoneNumber` methods, no SMS will be sent. You can instead provide the test code directly to the `PhoneAuthProvider` or with `signInWithPhoneNumbers` confirmation result handler.
324334

325335
## API
326-
### Auth
336+
### Auth class
337+
338+
#### Properties
339+
327340
| Property | Type | Description
328341
|----------|------|-------------
329342
| `app`| `FirebaseApp` | _readonly_
330343
| `currentUser`| [User](#user) \| `null` | _readonly_
331344
| `languageCode`| `boolean` | _readonly_
332345
| `settings` | [AuthSettings]()| _readonly_
333-
| `tenantId` | `string` | _readonly_
346+
| `tenantId` | `string` | A _readonly_ only property that returns the tenant ID of the Auth class instance. Read more at [tenantId](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#tenantid).
334347

335-
####
348+
#### Methods
336349
| Method | Returns | Description
337350
|----------|------|-------------
338-
| `useEmulator(host: string, port: number)` | `void`
339-
| `applyActionCode(code: string)` | `Promise<void>`
340-
| `checkActionCode(code: string)` | Promise\<[ActionCodeInfo]()\>
351+
| `useEmulator(host: string, port: number)` | `void` | For the description, see [useEmulator](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#useemulator) on the Firebase documentation.
352+
| `applyActionCode(code: string)` | `Promise<void>` | For the description, see [applyActionCode](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#applyactioncode) on the Firebase documentation.
353+
| `checkActionCode(code: string)` | Promise<[ActionCodeInfo]()> | For the description, see [checkActionCode](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#checkactioncode) on the Firebase documentation.
354+
| `confirmPasswordReset(code: string, newPassword: string)` | `Promise<void>` | For the description, see [confirmPasswordReset](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#confirmpasswordreset) on the Firebase documentation.
355+
| `createUserWithEmailAndPassword(email: string, password: string)` | Promise<[UserCredential](#usercredential)> | For the description, see [createUserWithEmailAndPassword](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#createuserwithemailandpassword) on the Firebase documentation.
356+
| `fetchSignInMethodsForEmail(email: string)` | `Promise<string[]>` | For the description, see [fetchSignInMethodsForEmail](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#fetchsigninmethodsforemail) on the Firebase documentation.
357+
| `isSignInWithEmailLink(emailLink: string)` | `boolean` | For the description, see [isSignInWithEmailLink](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#issigninwithemaillink) on the Firebase documentation.
358+
| `addAuthStateChangeListener(listener: (user: User) => void)` | `void` | For the description, see [onAuthStateChanged](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#onauthstatechanged) on the Firebase documentation.
359+
| `removeAuthStateChangeListener(listener: (user: User) => void)` | `void` |
360+
| `addIdTokenChangeListener(listener: (user: User) => void)` | `void` | For the description, see [onIdTokenChanged](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#onidtokenchanged) on the Firebase documentation.
361+
| `removeIdTokenChangListener(listener: (user: User) => void)` | `void` |
362+
| `sendPasswordResetEmail(email: string, actionCodeSettings?: ActionCodeSettings)` | `Promise<void>` | For the description, see [sendPasswordResetEmail](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#sendpasswordresetemail) on the Firebase documentation.
363+
| `sendSignInLinkToEmail(email: string, actionCodeSettings?: ActionCodeSettings)` | `Promise<void>` | For the description, see [sendSignInLinkToEmail(](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#sendsigninlinktoemail) on the Firebase documentation.
364+
| `signInAnonymously()` | Promise<[UserCredential](#usercredential)> | For the description, see [signInAnonymously](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#signinanonymously) on the Firebase documentation.
365+
| `signInWithProvider(provider: OAuthProvider)` | Promise<[UserCredential](#usercredential)> |
366+
| `getProviderCredential(provider: OAuthProvider)` | Promise<[OAuthCredential](#oauthcredential)> |
367+
| `signInWithCredential(credential: AuthCredential)` | Promise<[UserCredential](#usercredential)> | For the description, see [signInWithCredential](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#signinwithcredential) on the Firebase documentation.
368+
| `signInWithCustomToken(customToken: string)` | Promise<[UserCredential](#usercredential)> | For the description, see [signInWithCustomToken](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#signinwithcustomtoken) on the Firebase documentation.
369+
| `signInWithEmailAndPassword(email: string, password: string)` | Promise<[UserCredential](#usercredential)> | For the description, see [signInWithEmailAndPassword](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#signinwithemailandpassword) on the Firebase documentation.
370+
| `signInWithEmailLink(email: string, emailLink: string)` | Promise<[UserCredential](#usercredential)> | For the description, see [signInWithEmailLink](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#signinwithemaillink) on the Firebase documentation.
371+
| `signOut()` | `boolean` | Signs the user out.
372+
| `useUserAccessGroup(userAccessGroup: string)` | `Promise<void>` |
373+
| `verifyPasswordResetCode(code: string)` | `Promise<string>` | For the description, see [verifyPasswordResetCode](https://firebase.google.com/docs/reference/js/v8/firebase.auth.Auth#overifypasswordreset) on the Firebase documentation.
341374

342375

343376
### User
@@ -360,22 +393,59 @@ The user object has the following members.
360393

361394
#### Methods
362395

363-
| Method | Returns |
364-
| --------------------------------------------------------------------------------- | -------------------------- |
365-
| `delete()` | `Promise<void>` |
366-
| `getIdToken(forceRefresh?: boolean` | `Promise<string>` |
367-
| `getIdTokenResult(forceRefresh?: boolean` | `Promise<AuthTokenResult>` |
368-
| `linkWithCredential(credential: AuthCredential)` | `Promise<UserCredential>` |
369-
| `reauthenticateWithProvider(provider: OAuthProvider)` | `Promise<UserCredential>` |
370-
| `reauthenticateWithCredential(credential: AuthCredential)` | `Promise<UserCredential>` |
371-
| `reload()` | `Promise<void>` |
372-
| `sendEmailVerification(actionCodeSettings?: ActionCodeSettings)` | `Promise<void>` |
373-
| `unlink(providerId: string)` | `Promise<User>` |
374-
| `updateEmail(email: string)` | `Promise<void>` |
375-
| `updatePassword(password: string)` | `Promise<void>` |
376-
| `updatePhoneNumber(credential: AuthCredential)` | `Promise<void>` |
377-
| `updateProfile(updates: UserProfileChangeRequest)` | `Promise<void>` |
378-
| `verifyBeforeUpdateEmail(email: string, actionCodeSettings?: ActionCodeSettings)` | `Promise<void>` |
396+
| Method | Returns | Description
397+
|----------|------|-------------
398+
| `delete()` | `Promise<void>` | For the description, see [delete](https://firebase.google.com/docs/reference/js/v8/firebase.User#delete) on the Firebase documentation.
399+
| `getIdToken(forceRefresh?: undefined \| false \| true)` | `Promise<string>` | For the description, see [getIdToken](https://firebase.google.com/docs/reference/js/v8/firebase.User#getidtoken) on the Firebase documentation.
400+
| `getIdTokenResult(forceRefresh?: undefined \| false \| true)` | Promise<[AuthTokenResult]()> |
401+
| `linkWithCredential(credential: AuthCredential)` | Promise<[UserCredential](#usercredential)> | For the description, see [linkWithCredential](https://firebase.google.com/docs/reference/js/v8/firebase.User#linkwithcredential) on the Firebase documentation.
402+
| `reauthenticateWithProvider(provider: OAuthProvider)` | Promise<[UserCredential](#usercredential)> |
403+
| `reauthenticateWithCredential(credential: AuthCredential)` | Promise<[UserCredential](#usercredential)> | For the description, see [reauthenticateWithCredential](https://firebase.google.com/docs/reference/js/v8/firebase.User#reauthenticatewithcredintial) on the Firebase documentation.
404+
| `reload()` | `Promise<void>` | For the description, see [reload](https://firebase.google.com/docs/reference/js/v8/firebase.User#reload) on the Firebase documentation.
405+
| `sendEmailVerification(actionCodeSettings?: ActionCodeSettings)` | `Promise<void>` | For the description, see [sendEmailVerification](https://firebase.google.com/docs/reference/js/v8/firebase.User#sendemailverification) on the Firebase documentation.
406+
| `unlink(providerId: string)` | Promise<[User](#user)> | For the description, see [unlink](https://firebase.google.com/docs/reference/js/v8/firebase.User#unlink) on the Firebase documentation.
407+
`updateEmail(email: string)` | `Promise<void>` | For the description, see [updateEmail](https://firebase.google.com/docs/reference/js/v8/firebase.User#updateemail) on the Firebase documentation.
408+
| `updatePassword(password: string)` | ` Promise<void>` | For the description, see [updatePassword](https://firebase.google.com/docs/reference/js/v8/firebase.User#updatepassword) on the Firebase documentation.
409+
| `updatePhoneNumber(credential: AuthCredential)` | `Promise<void>` | For the description, see [updatePhoneNumber](https://firebase.google.com/docs/reference/js/v8/firebase.User#updatephonenumber) on the Firebase documentation.
410+
| `updateProfile(updates: UserProfileChangeRequest)` | `Promise<void>` | For the description, see [updateProfile](https://firebase.google.com/docs/reference/js/v8/firebase.User#updateprofile) on the Firebase documentation.
411+
| `verifyBeforeUpdateEmail(email: string, actionCodeSettings?: ActionCodeSettings)` | `Promise<void>` | For the description, see [verifyBeforeUpdateEmail](https://firebase.google.com/docs/reference/js/v8/firebase.User#verifybeforeupdateemail) on the Firebase documentation.
412+
413+
### UserCredential
414+
415+
| Property | Type | Description
416+
|----------|------|-------------
417+
| `additionalUserInfo` |<[AdditionalUserInfo](#additionaluserinfo)> |
418+
| `user` |<[User](#user)> |
419+
| `credential` |<[AuthCredential](#authcredential)> |
420+
421+
#### AdditionalUserInfo
422+
423+
| Property | Type | Description
424+
|----------|------|-------------
425+
| `newUser` | `boolean` |
426+
| `profile` | `Record<string, any>` |
427+
| `providerId` | `string` |
428+
| `username` | `string` |
429+
430+
#### AuthCredential
431+
| Property | Type | Description
432+
|----------|------|-------------
433+
| `ios` | `FIRAuthCredential` ` | |_readonly_
434+
| `android` | `com.google.firebase.auth.AuthCredential`| _readonly_
435+
| `signInMethod` | `string` | _readonly_
436+
| `idToken` | `string` | _readonly_
437+
| `accessToken` | `string` | _readonly_
438+
| `secret` | `string` | _readonly_
439+
440+
#### OAuthCredential
441+
| Property | Type | Description
442+
|----------|------|-------------
443+
| `ios` | |_readonly_
444+
| `android` | |_readonly_
445+
| `signInMethod` | `string` |
446+
| `idToken` | `string` | _readonly_
447+
| `accessToken` | `string` |_readonly_
448+
| `secret` | `string` |_readonly_
379449

380450
## License
381451

0 commit comments

Comments
 (0)