-
Notifications
You must be signed in to change notification settings - Fork 872
/
defines.js
181 lines (158 loc) · 5.32 KB
/
defines.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
169
170
171
172
173
174
175
176
177
178
179
180
181
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Defines all common constants and enums used by firebase-auth.
*/
goog.provide('fireauth.constants');
goog.provide('fireauth.constants.AuthEventType');
/**
* Enums for authentication operation types.
* @enum {string}
*/
fireauth.constants.OperationType = {
LINK: 'link',
REAUTHENTICATE: 'reauthenticate',
SIGN_IN: 'signIn'
};
/**
* Events dispatched firebase.auth.Auth.
* @enum {string}
*/
fireauth.constants.AuthEventType = {
/** Dispatched when emulator config is changed. */
EMULATOR_CONFIG_CHANGED: 'emulatorConfigChanged',
/** Dispatched when Firebase framework is changed. */
FRAMEWORK_CHANGED: 'frameworkChanged',
/** Dispatched when language code is changed. */
LANGUAGE_CODE_CHANGED: 'languageCodeChanged'
};
/**
* Enums for all second factor types.
* @enum {string}
*/
fireauth.constants.SecondFactorType = {
PHONE: 'phone'
};
/**
* The settings of an Auth endpoint. The fields are:
* <ul>
* <li>firebaseAuthEndpoint: defines the Firebase Auth backend endpoint for
* specified endpoint type.</li>
* <li>secureTokenEndpoint: defines the secure token backend endpoint for
* specified endpoint type.</li>
* <li>identityPlatformEndpoint: defines the Identity Platform backend endpoint
* for specified endpoint type.</li>
* <li>id: defines the endpoint identifier.</li>
* </ul>
* @typedef {{
* firebaseAuthEndpoint: string,
* secureTokenEndpoint: string,
* identityPlatformEndpoint: string,
* id: string
* }}
*/
fireauth.constants.EndpointSettings;
/**
* The different endpoints for Firebase Auth backend.
* @enum {!fireauth.constants.EndpointSettings}
*/
fireauth.constants.Endpoint = {
// TODO: this is no longer needed now that client endpoint migration is
// completed.
BOQ: {
firebaseAuthEndpoint: 'https://staging-identitytoolkit.sandbox.googleapi' +
's.com/identitytoolkit/v3/relyingparty/',
secureTokenEndpoint: 'https://staging-securetoken.sandbox.googleapis.com' +
'/v1/token',
identityPlatformEndpoint:
'https://staging-identitytoolkit.sandbox.googleapis.com/v2/',
id: 'b'
},
PRODUCTION: {
firebaseAuthEndpoint: 'https://www.googleapis.com/identitytoolkit/v3/' +
'relyingparty/',
secureTokenEndpoint: 'https://securetoken.googleapis.com/v1/token',
identityPlatformEndpoint:
'https://identitytoolkit.googleapis.com/v2/',
id: 'p'
},
STAGING: {
firebaseAuthEndpoint: 'https://staging-www.sandbox.googleapis.com/' +
'identitytoolkit/v3/relyingparty/',
secureTokenEndpoint: 'https://staging-securetoken.sandbox.googleapis.com' +
'/v1/token',
identityPlatformEndpoint:
'https://staging-identitytoolkit.sandbox.googleapis.com/v2/',
id: 's'
},
TEST: {
firebaseAuthEndpoint: 'https://www-googleapis-test.sandbox.google.com/' +
'identitytoolkit/v3/relyingparty/',
secureTokenEndpoint: 'https://test-securetoken.sandbox.googleapis.com/v1' +
'/token',
identityPlatformEndpoint:
'https://test-identitytoolkit.sandbox.googleapis.com/v2/',
id: 't'
}
};
/**
* Returns the endpoint specific RpcHandler configuration.
* @param {?string=} opt_id The identifier of the endpoint type if available.
* @return {?Object|undefined} The RpcHandler endpoint configuration object.
*/
fireauth.constants.getEndpointConfig = function(opt_id) {
for (var endpointKey in fireauth.constants.Endpoint) {
if (fireauth.constants.Endpoint[endpointKey].id === opt_id) {
var endpoint = fireauth.constants.Endpoint[endpointKey];
return {
'firebaseEndpoint': endpoint.firebaseAuthEndpoint,
'secureTokenEndpoint': endpoint.secureTokenEndpoint,
'identityPlatformEndpoint': endpoint.identityPlatformEndpoint
};
}
}
return null;
};
/**
* Returns the validated endpoint identifier. Undefined if the provided one is
* invalid.
* @param {?string=} opt_id The identifier of the endpoint type if available.
* @return {string|undefined} The validated endpoint ID. If not valid,
* undefined.
*/
fireauth.constants.getEndpointId = function(opt_id) {
if (opt_id && fireauth.constants.getEndpointConfig(opt_id)) {
return opt_id;
}
return undefined;
};
/** @const {string|undefined} The current client endpoint. */
fireauth.constants.clientEndpoint = fireauth.constants.getEndpointId('__EID__');
/** @const {string} The required SAML provider ID prefix. */
fireauth.constants.SAML_PREFIX = 'saml.';
/** @const {string} The required OIDC provider ID prefix. */
fireauth.constants.OIDC_PREFIX = 'oidc.';
/**
* The settings of an Auth emulator. The fields are:
* <ul>
* <li>url: defines the URL where the emulator is running.</li>
* </ul>
* @typedef {{
* url: string,
* }}
*/
fireauth.constants.EmulatorSettings;