Skip to content

Commit 863ef3b

Browse files
committed
defaults placed in constants and referenced. version set in package file.
1 parent 88e5f4a commit 863ef3b

File tree

6 files changed

+62
-40
lines changed

6 files changed

+62
-40
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "1.2.0",
3+
"version": "1.2.0-alpha",
44
"description": "Redux integration for Firebase. Comes with a Higher Order Component for use with React.",
55
"main": "dist/index.js",
66
"module": "src/index.js",

src/actions/auth.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { omit, isArray, isString, isFunction } from 'lodash'
22
import jwtDecode from 'jwt-decode'
33

4-
import { actionTypes, defaultJWTKeys } from '../constants'
4+
import { actionTypes, defaultJWTProps } from '../constants'
55
import { promisesForPopulate } from '../utils/populate'
66
import { getLoginMethodAndParams } from '../utils/auth'
77

@@ -208,7 +208,7 @@ export const login = (dispatch, firebase, credentials) => {
208208
if (method === 'signInWithCustomToken') {
209209
// Extract the extra data in the JWT token for user object
210210
const { stsTokenManager: { accessToken }, uid } = userData.toJSON()
211-
const extraJWTData = omit(jwtDecode(accessToken), defaultJWTKeys)
211+
const extraJWTData = omit(jwtDecode(accessToken), defaultJWTProps)
212212

213213
return createUserProfile(
214214
dispatch,
@@ -220,12 +220,11 @@ export const login = (dispatch, firebase, credentials) => {
220220

221221
// Create profile when logging in with external provider
222222
const { user } = userData
223-
console.log('userData:', userData, user)
224223

225224
return createUserProfile(
226225
dispatch,
227226
firebase,
228-
user, // TODO: Change this to userData so it has uid?
227+
user,
229228
{
230229
email: user.email,
231230
displayName: user.providerData[0].displayName || user.email,

src/actions/storage.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { map, isFunction } from 'lodash'
22
import { actionTypes } from '../constants'
3-
import { wrapInDispatch, deleteFile as deleteFileFromFb } from '../utils/actions'
3+
import { wrapInDispatch } from '../utils/actions'
4+
import { deleteFile as deleteFileFromFb } from '../utils/storage'
45

56
const {
67
FILE_UPLOAD_START,
@@ -71,7 +72,7 @@ export const uploadFile = (dispatch, firebase, { path, file, dbPath }) =>
7172
}
7273
const { metadata: { name, fullPath, downloadURLs } } = res
7374
const { fileMetadataFactory } = firebase._.config
74-
console.log('download urls:', res)
75+
7576
// Apply fileMetadataFactory if it exists in config
7677
const fileData = isFunction(fileMetadataFactory)
7778
? fileMetadataFactory(res)

src/compose.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Firebase from 'firebase'
2+
import { defaultConfig } from './constants'
23
import { authActions, queryActions, storageActions } from './actions'
34
let firebaseInstance
45

@@ -44,16 +45,10 @@ let firebaseInstance
4445
*/
4546
export default (config, otherConfig) => next =>
4647
(reducer, initialState, middleware) => {
47-
const defaultConfig = {
48-
userProfile: null,
49-
enableLogging: false,
50-
updateProfileOnLogin: true
51-
}
52-
5348
const store = next(reducer, initialState, middleware)
5449
const { dispatch } = store
5550

56-
const { apiKey, authDomain, databaseURL, storageBucket } = config
51+
const { apiKey, authDomain, databaseURL } = config
5752

5853
// Throw for missing Firebase Data
5954
if (!databaseURL) throw new Error('Firebase databaseURL is required')
@@ -65,7 +60,7 @@ export default (config, otherConfig) => next =>
6560

6661
// Initialize Firebase
6762
try {
68-
Firebase.initializeApp({apiKey, authDomain, databaseURL, storageBucket})
63+
Firebase.initializeApp(config)
6964
} catch (err) {}
7065

7166
// Enable Logging based on config

src/constants.js

Lines changed: 52 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* import { constants } from 'react-redux-firebase'
66
* constants.actionsPrefix === '@@reactReduxFirebase' // true
77
*/
8-
export const actionsPrefix = '@@reactReduxFirebase/'
8+
export const actionsPrefix = '@@reactReduxFirebase'
99

1010
/** @constant
1111
* @description Object containing all action types
@@ -18,25 +18,35 @@ export const actionsPrefix = '@@reactReduxFirebase/'
1818
* constants.actionTypes.SET === '@@reactReduxFirebase/SET' // true
1919
*/
2020
export const actionTypes = {
21-
START: `${actionsPrefix}START`,
22-
SET: `${actionsPrefix}SET`,
23-
SET_PROFILE: `${actionsPrefix}SET_PROFILE`,
24-
LOGIN: `${actionsPrefix}LOGIN`,
25-
LOGOUT: `${actionsPrefix}LOGOUT`,
26-
LOGIN_ERROR: `${actionsPrefix}LOGIN_ERROR`,
27-
NO_VALUE: `${actionsPrefix}NO_VALUE`,
28-
UNAUTHORIZED_ERROR: `${actionsPrefix}UNAUTHORIZED_ERROR`,
29-
ERROR: `${actionsPrefix}ERROR`,
30-
INIT_BY_PATH: `${actionsPrefix}INIT_BY_PATH`,
31-
AUTHENTICATION_INIT_STARTED: `${actionsPrefix}AUTHENTICATION_INIT_STARTED`,
32-
AUTHENTICATION_INIT_FINISHED: `${actionsPrefix}AUTHENTICATION_INIT_FINISHED`,
33-
FILE_UPLOAD_START: `${actionsPrefix}FILE_UPLOAD_START`,
34-
FILE_UPLOAD_ERROR: `${actionsPrefix}FILE_UPLOAD_ERROR`,
35-
FILE_UPLOAD_PROGRESS: `${actionsPrefix}FILE_UPLOAD_PROGRESS`,
36-
FILE_UPLOAD_COMPLETE: `${actionsPrefix}FILE_UPLOAD_COMPLETE`,
37-
FILE_DELETE_START: `${actionsPrefix}FILE_DELETE_START`,
38-
FILE_DELETE_ERROR: `${actionsPrefix}FILE_DELETE_ERROR`,
39-
FILE_DELETE_COMPLETE: `${actionsPrefix}FILE_DELETE_COMPLETE`
21+
START: `${actionsPrefix}/START`,
22+
SET: `${actionsPrefix}/SET`,
23+
SET_PROFILE: `${actionsPrefix}/SET_PROFILE`,
24+
LOGIN: `${actionsPrefix}/LOGIN`,
25+
LOGOUT: `${actionsPrefix}/LOGOUT`,
26+
LOGIN_ERROR: `${actionsPrefix}/LOGIN_ERROR`,
27+
NO_VALUE: `${actionsPrefix}/NO_VALUE`,
28+
UNAUTHORIZED_ERROR: `${actionsPrefix}/UNAUTHORIZED_ERROR`,
29+
ERROR: `${actionsPrefix}/ERROR`,
30+
INIT_BY_PATH: `${actionsPrefix}/INIT_BY_PATH`,
31+
AUTHENTICATION_INIT_STARTED: `${actionsPrefix}/AUTHENTICATION_INIT_STARTED`,
32+
AUTHENTICATION_INIT_FINISHED: `${actionsPrefix}/AUTHENTICATION_INIT_FINISHED`,
33+
FILE_UPLOAD_START: `${actionsPrefix}/FILE_UPLOAD_START`,
34+
FILE_UPLOAD_ERROR: `${actionsPrefix}/FILE_UPLOAD_ERROR`,
35+
FILE_UPLOAD_PROGRESS: `${actionsPrefix}/FILE_UPLOAD_PROGRESS`,
36+
FILE_UPLOAD_COMPLETE: `${actionsPrefix}/FILE_UPLOAD_COMPLETE`,
37+
FILE_DELETE_START: `${actionsPrefix}/FILE_DELETE_START`,
38+
FILE_DELETE_ERROR: `${actionsPrefix}/FILE_DELETE_ERROR`,
39+
FILE_DELETE_COMPLETE: `${actionsPrefix}/FILE_DELETE_COMPLETE`
40+
}
41+
42+
/** @constant
43+
* @description Default configuration options
44+
* @type {Array}
45+
*/
46+
export const defaultConfig = {
47+
userProfile: null,
48+
enableLogging: false,
49+
updateProfileOnLogin: true
4050
}
4151

4252
/** @constant
@@ -56,7 +66,7 @@ export const supportedAuthProviders = [
5666
* @type {Array}
5767
* @private
5868
*/
59-
export const defaultJWTKeys = [
69+
export const defaultJWTProps = [
6070
'aud',
6171
'auth_time',
6272
'exp',
@@ -67,14 +77,31 @@ export const defaultJWTKeys = [
6777
'user_id'
6878
]
6979

80+
/** @constant
81+
* @description Default initial props used when running firebase.initializeApp
82+
* @type {Array}
83+
* @private
84+
*/
85+
export const defaultInitProps = [
86+
'apiKey',
87+
'authDomain',
88+
'databaseURL',
89+
'storageBucket',
90+
'messagingSenderId'
91+
]
92+
7093
export default {
71-
defaultJWTKeys,
94+
defaultJWTProps,
7295
actionTypes,
73-
supportedAuthProviders
96+
defaultConfig,
97+
supportedAuthProviders,
98+
defaultInitProps
7499
}
75100

76101
module.exports = {
77-
defaultJWTKeys,
102+
defaultJWTProps,
78103
actionTypes,
79-
supportedAuthProviders
104+
defaultConfig,
105+
supportedAuthProviders,
106+
defaultInitProps
80107
}

0 commit comments

Comments
 (0)