Skip to content

Commit 0d7182f

Browse files
prescottpruemagrinjvicracdependabot[bot]illuminist
authored andcommitted
v3.1.0
* fix(auth): remove stale profile listener on empty auth state change - @illuminist - #508, #838 * feat(types): add support for typed db schema - @vicrac - #826 * feat(auth): add reauthenticate method from firebase - @magrinj - #812 * chore(deps): bump lodash from 4.17.11 to 4.17.15 in react-native example - @dependabot * chore(deps): bump stringstream from 0.0.5 to 0.0.6 in react-native-firebase example - @dependabot * chore(deps): bump mixin-deep from 1.3.1 to 1.3.2 in react-native example - @dependabot * chore(deps): bump diff in react-native-firebase example - @dependabot * chore(deps): bump lodash-es from 4.17.4 to 4.17.15 in react-native-firebase example - @dependabot * chore(deps): bump diff from 3.3.0 to 3.5.0 in react-native-firebase example - @dependabot Co-authored-by: Jérémy M <[email protected]> Co-authored-by: Michał Kaczanowicz <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: illuminist <[email protected]>
1 parent d2668dd commit 0d7182f

File tree

10 files changed

+277
-227
lines changed

10 files changed

+277
-227
lines changed

docs/auth.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ If you need access to methods that are not available at the top level, you can a
2828

2929
For examples of how to use this API, checkout the [auth recipes section](/docs/recipes/auth.html).
3030

31-
## login(credentials)
31+
## login(credentials) and reauthenticate(credentials)
3232

33-
##### Parameters
33+
##### Parameters for login
3434

3535
* `credentials` ([**Object**][object-url])
3636
* [**Object**][object-url] - cases:
37-
* email and password (runs `ref.authWithPassword(credentials)`) :
37+
* - email and password (runs `ref.authWithPassword(credentials)`) :
3838
```js
3939
{
4040
email: String,
@@ -78,6 +78,33 @@ For examples of how to use this API, checkout the [auth recipes section](/docs/r
7878
}
7979
```
8080

81+
##### Parameters for reauthenticate
82+
83+
* `credentials` ([**Object**][object-url])
84+
* [**Object**][object-url] - cases:
85+
* provider (runs `ref.reauthenticateWithPopup(provider)` or `ref.reauthenticateWithRedirect(provider)`) :
86+
```js
87+
{
88+
provider: "facebook | google | twitter",
89+
type: "popup | redirect", // popup is default
90+
scopes: Array // email is default
91+
}
92+
```
93+
* credential (runs `ref.reauthenticateWithCredential(credential)`) :
94+
```js
95+
{
96+
credential: firebase.auth.AuthCredential // created using specific provider
97+
}
98+
```
99+
The credential parameter is a firebase.auth.AuthCredential specific to the provider (i.e. `firebase.auth.GoogleAuthProvider.credential(null)`). For more details [please view the Firebase API reference](https://firebase.google.com/docs/reference/js/firebase.auth.GoogleAuthProvider#methods)
100+
* phone number (runs `ref.reauthenticateWithPhoneNumber(phoneNumber, applicationVerifier)`). Automatic profile creation is enabled by default if you are using the `userProfile` config option. `updateProfileOnLogin` config option can be set to `false` in order to prevent this behavior.
101+
```js
102+
{
103+
phoneNumber: String,
104+
applicationVerifier: firebase.auth.ApplicationVerifier
105+
}
106+
```
107+
81108
##### Returns
82109

83110
[**Promise**][promise-url] that resolves with the response from firebase's login method (an [**Object**][object-url]). `credential` property is also included if using oAuth provider.
@@ -121,6 +148,10 @@ firebase.login({
121148
firebase.login({
122149
credential: firebase.auth.GoogleAuthProvider.credential(null, 'some access token')
123150
})
151+
// or using reauthenticate
152+
firebase.reauthenticate({
153+
credential: firebase.auth.GoogleAuthProvider.credential(null, 'some access token')
154+
})
124155
```
125156

126157
*Token*

examples/complete/react-native-firebase/yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,8 +1434,8 @@ detect-indent@^4.0.0:
14341434
repeating "^2.0.0"
14351435

14361436
diff@^3.2.0:
1437-
version "3.3.0"
1438-
resolved "https://registry.yarnpkg.com/diff/-/diff-3.3.0.tgz#056695150d7aa93237ca7e378ac3b1682b7963b9"
1437+
version "3.5.0"
1438+
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
14391439

14401440
dom-walk@^0.1.0:
14411441
version "0.1.1"
@@ -2610,8 +2610,8 @@ locate-path@^2.0.0:
26102610
path-exists "^3.0.0"
26112611

26122612
lodash-es@^4.2.0, lodash-es@^4.2.1:
2613-
version "4.17.4"
2614-
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7"
2613+
version "4.17.15"
2614+
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.15.tgz#21bd96839354412f23d7a10340e5eac6ee455d78"
26152615

26162616
lodash._basecopy@^3.0.0:
26172617
version "3.0.1"
@@ -3986,8 +3986,8 @@ string_decoder@~1.0.3:
39863986
safe-buffer "~5.1.0"
39873987

39883988
stringstream@~0.0.4:
3989-
version "0.0.5"
3990-
resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.5.tgz#4e484cd4de5a0bbbee18e46307710a8a81621878"
3989+
version "0.0.6"
3990+
resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.6.tgz#7880225b0d4ad10e30927d167a1d6f2fd3b33a72"
39913991

39923992
strip-ansi@^3.0.0, strip-ansi@^3.0.1:
39933993
version "3.0.1"

examples/complete/react-native/yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4594,9 +4594,9 @@ lodash.zipobject@^4.1.3:
45944594
integrity sha1-s5n1q6j/YqdG9peb8gshT5ZNvvg=
45954595

45964596
lodash@^4.0.0, lodash@^4.13.1, lodash@^4.16.6, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1:
4597-
version "4.17.11"
4598-
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
4599-
integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==
4597+
version "4.17.15"
4598+
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
4599+
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
46004600

46014601
long@~3:
46024602
version "3.2.0"
@@ -5046,9 +5046,9 @@ minizlib@^1.1.1:
50465046
minipass "^2.2.1"
50475047

50485048
mixin-deep@^1.2.0:
5049-
version "1.3.1"
5050-
resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe"
5051-
integrity sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==
5049+
version "1.3.2"
5050+
resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566"
5051+
integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==
50525052
dependencies:
50535053
for-in "^1.0.2"
50545054
is-extendable "^1.0.1"

index.d.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,15 @@ export function firebaseConnect<ProfileType, TInner = {}>(
805805
* @param action.data - Data associated with action
806806
* @see https://react-redux-firebase.com/docs/api/reducer.html
807807
*/
808-
export function firebaseReducer<UserType>(
809-
state: any,
810-
action: any
811-
): FirebaseReducer.Reducer<UserType>
808+
export function firebaseReducer<
809+
Schema extends Record<string, Record<string | number, string | number>>,
810+
UserType
811+
>(state: any, action: any): FirebaseReducer.Reducer<Schema, UserType>
812+
813+
export function makeFirebaseReducer<
814+
Schema extends Record<string, Record<string | number, string | number>>,
815+
UserType = {}
816+
>(): (state: any, action: any) => FirebaseReducer.Reducer<Schema, UserType>
812817

813818
/**
814819
* React HOC that attaches/detaches Cloud Firestore listeners on mount/unmount
@@ -1120,12 +1125,17 @@ export interface Data<T extends FirestoreTypes.DocumentData> {
11201125
}
11211126

11221127
export namespace FirebaseReducer {
1123-
export interface Reducer<ProfileType = {}> {
1128+
export interface Reducer<
1129+
Schema extends Record<string, Record<string | number, string | number>>,
1130+
ProfileType = {}
1131+
> {
11241132
auth: AuthState
11251133
profile: Profile<ProfileType>
11261134
authError: any
1127-
data: Data<any | Dictionary<any>>
1128-
ordered: Ordered<any>
1135+
data: { [T in keyof Schema]: Record<string, Schema[T]> }
1136+
ordered: {
1137+
[T in keyof Schema]: Array<{ key: string; value: Schema[T] }>
1138+
}
11291139
errors: any[]
11301140
isInitializing: boolean
11311141
listeners: Listeners

0 commit comments

Comments
 (0)