forked from prescottprue/react-redux-firebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstants.js
168 lines (159 loc) · 5.87 KB
/
constants.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/** @constant
* @description Prefix for all actions within library
* @type {String}
* @example
* import { constants } from 'react-redux-firebase'
* constants.actionsPrefix === '@@reactReduxFirebase' // true
*/
export const actionsPrefix = '@@reactReduxFirebase'
/**
* @constant
* @type {Object}
* @description Object containing all action types
* @property {String} START - `@@reactReduxFirebase/START`
* @property {String} SET - `@@reactReduxFirebase/SET`
* @property {String} SET_PROFILE - `@@reactReduxFirebase/SET_PROFILE`
* @property {String} LOGIN - `@@reactReduxFirebase/LOGIN`
* @property {String} LOGOUT - `@@reactReduxFirebase/LOGOUT`
* @property {String} LOGIN_ERROR - `@@reactReduxFirebase/LOGIN_ERROR`
* @property {String} NO_VALUE - `@@reactReduxFirebase/NO_VALUE`
* @property {String} UNAUTHORIZED_ERROR - `@@reactReduxFirebase/UNAUTHORIZED_ERROR`
* @property {String} UNSET_LISTENER - `@@reactReduxFirebase/UNSET_LISTENER`
* @property {String} AUTHENTICATION_INIT_STARTED - `@@reactReduxFirebase/AUTHENTICATION_INIT_STARTED`
* @property {String} AUTHENTICATION_INIT_FINISHED - `@@reactReduxFirebase/AUTHENTICATION_INIT_FINISHED`
* @property {String} FILE_UPLOAD_START - `@@reactReduxFirebase/FILE_UPLOAD_START`
* @property {String} FILE_UPLOAD_ERROR - `@@reactReduxFirebase/FILE_UPLOAD_ERROR`
* @property {String} FILE_UPLOAD_PROGRESS - `@@reactReduxFirebase/FILE_UPLOAD_PROGRESS`
* @property {String} FILE_UPLOAD_COMPLETE - `@@reactReduxFirebase/FILE_UPLOAD_COMPLETE`
* @property {String} FILE_DELETE_START - `@@reactReduxFirebase/FILE_DELETE_START`
* @property {String} FILE_DELETE_ERROR - `@@reactReduxFirebase/FILE_DELETE_ERROR`
* @property {String} FILE_DELETE_COMPLETE - `@@reactReduxFirebase/FILE_DELETE_COMPLETE`
* @example
* import { actionTypes } from 'react-redux-firebase'
* actionTypes.SET === '@@reactReduxFirebase/SET' // true
*/
export const actionTypes = {
START: `${actionsPrefix}/START`,
SET: `${actionsPrefix}/SET`,
SET_PROFILE: `${actionsPrefix}/SET_PROFILE`,
LOGIN: `${actionsPrefix}/LOGIN`,
LOGOUT: `${actionsPrefix}/LOGOUT`,
LOGIN_ERROR: `${actionsPrefix}/LOGIN_ERROR`,
NO_VALUE: `${actionsPrefix}/NO_VALUE`,
UNAUTHORIZED_ERROR: `${actionsPrefix}/UNAUTHORIZED_ERROR`,
ERROR: `${actionsPrefix}/ERROR`,
UNSET_LISTENER: `${actionsPrefix}/UNSET_LISTENER`,
AUTHENTICATION_INIT_STARTED: `${actionsPrefix}/AUTHENTICATION_INIT_STARTED`,
AUTHENTICATION_INIT_FINISHED: `${actionsPrefix}/AUTHENTICATION_INIT_FINISHED`,
FILE_UPLOAD_START: `${actionsPrefix}/FILE_UPLOAD_START`,
FILE_UPLOAD_ERROR: `${actionsPrefix}/FILE_UPLOAD_ERROR`,
FILE_UPLOAD_PROGRESS: `${actionsPrefix}/FILE_UPLOAD_PROGRESS`,
FILE_UPLOAD_COMPLETE: `${actionsPrefix}/FILE_UPLOAD_COMPLETE`,
FILE_DELETE_START: `${actionsPrefix}/FILE_DELETE_START`,
FILE_DELETE_ERROR: `${actionsPrefix}/FILE_DELETE_ERROR`,
FILE_DELETE_COMPLETE: `${actionsPrefix}/FILE_DELETE_COMPLETE`
}
/** @constant
* @description Default configuration options
* @property {String} userProfile - `null` Location on Firebase where user
* profiles are stored. Often set to `'users'`.
* @property {Boolean} enableLogging - `false` Whether or not firebase
* database logging is enabled.
* @property {Boolean} updateProfileOnLogin - `true` Whether or not to update
* user profile when logging in.
* @property {Boolean} enableRedirectHandling - `true` Whether or not to enable
* redirect handling. This must be disabled if environment is not http/https
* such as with react-native.
* @property {Boolean} autoPopulateProfile - `true` Whether or not to
* automatically populate profile with data loaded through
* profileParamsToPopulate config.
* @property {Boolean} setProfilePopulateResults - `true` Whether or not to
* call SET actions for data that results from populating profile to redux under
* the data path. For example: role paramter on profile populated from 'roles'
* root. True will call SET_PROFILE as well as a SET action with the role that
* is loaded (places it in data/roles).
* @property {Boolean} distpatchOnUnsetListener - `false` Whether or not to
* dispatch UNSET_LISTENER when disabling listeners for a specific path. USE WITH CAUTION
* Setting this to true allows an action to be called that removes data
* from redux (which might not always be expected).
* @type {Array}
*/
export const defaultConfig = {
userProfile: null,
enableLogging: false,
updateProfileOnLogin: true,
enableRedirectHandling: true,
autoPopulateProfile: true,
setProfilePopulateResults: false,
distpatchOnUnsetListener: false
}
/** @constant
* @description List of all external auth providers that are supported
* (firebase's email/anonymous included by default).
* @type {Array}
* @private
*/
export const supportedAuthProviders = [
'google',
'github',
'twitter',
'facebook'
]
/** @constant
* @description Default keys returned within JSON Web Token recieved when
* authenticating with Firebase
* @type {Array}
* @private
*/
export const defaultJWTProps = [
'aud',
'auth_time',
'exp',
'firebase',
'iat',
'iss',
'sub',
'user_id'
]
/** @constant
* @description Default initial props used when running firebase.initializeApp
* @type {Array}
* @private
*/
export const defaultInitProps = [
'apiKey',
'authDomain',
'databaseURL',
'storageBucket',
'messagingSenderId'
]
/** @constant
* @description Parameters stored by path string instead of full path
* @type {Array}
* @private
*/
export const metaParams = ['timestamp', 'requesting', 'requested']
/** @constant
* @description String Character used to split/join meta parameter keys
* @type {Array}
* @private
*/
export const paramSplitChar = '/'
export default {
defaultJWTProps,
actionTypes,
defaultConfig,
supportedAuthProviders,
defaultInitProps,
metaParams,
paramSplitChar
}
module.exports = {
defaultJWTProps,
actionTypes,
defaultConfig,
supportedAuthProviders,
defaultInitProps,
metaParams,
paramSplitChar
}