@firebase/auth 1.1.0-canary.e037eeed6 → 1.1.0-canary.f9a232a29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.d.ts +0 -1
- package/dist/browser-cjs/{index-1a2a2779.js → index-dde9002c.js} +254 -254
- package/dist/browser-cjs/index-dde9002c.js.map +1 -0
- package/dist/browser-cjs/index.js +2 -2
- package/dist/browser-cjs/internal.js +2 -2
- package/dist/browser-cjs/src/core/auth/auth_impl.d.ts +0 -1
- package/dist/browser-cjs/src/model/auth.d.ts +0 -1
- package/dist/browser-cjs/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +1 -0
- package/dist/cordova/index.js +2 -2
- package/dist/cordova/internal.js +2 -2
- package/dist/cordova/{popup_redirect-8599967b.js → popup_redirect-ad35caa5.js} +333 -332
- package/dist/cordova/popup_redirect-ad35caa5.js.map +1 -0
- package/dist/cordova/src/core/auth/auth_impl.d.ts +0 -1
- package/dist/cordova/src/model/auth.d.ts +0 -1
- package/dist/cordova/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +1 -0
- package/dist/esm2017/{index-f8a66098.js → index-44229602.js} +254 -254
- package/dist/esm2017/index-44229602.js.map +1 -0
- package/dist/esm2017/index.js +2 -2
- package/dist/esm2017/internal.js +3 -3
- package/dist/esm2017/src/core/auth/auth_impl.d.ts +0 -1
- package/dist/esm2017/src/model/auth.d.ts +0 -1
- package/dist/esm2017/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +1 -0
- package/dist/esm5/{index-fdb9efbb.js → index-c07774ba.js} +333 -332
- package/dist/esm5/index-c07774ba.js.map +1 -0
- package/dist/esm5/index.js +1 -1
- package/dist/esm5/internal.js +2 -2
- package/dist/esm5/src/core/auth/auth_impl.d.ts +0 -1
- package/dist/esm5/src/model/auth.d.ts +0 -1
- package/dist/esm5/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +1 -0
- package/dist/index.webworker.esm5.js +650 -649
- package/dist/index.webworker.esm5.js.map +1 -1
- package/dist/node/index.js +1 -1
- package/dist/node/internal.js +1 -1
- package/dist/node/src/core/auth/auth_impl.d.ts +0 -1
- package/dist/node/src/model/auth.d.ts +0 -1
- package/dist/node/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +1 -0
- package/dist/node/{totp-7ea0acc9.js → totp-2bf88c5d.js} +319 -318
- package/dist/node/totp-2bf88c5d.js.map +1 -0
- package/dist/node-esm/index.js +1 -1
- package/dist/node-esm/internal.js +2 -2
- package/dist/node-esm/src/core/auth/auth_impl.d.ts +0 -1
- package/dist/node-esm/src/model/auth.d.ts +0 -1
- package/dist/node-esm/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +1 -0
- package/dist/node-esm/{totp-af1856f8.js → totp-611a1ef1.js} +243 -243
- package/dist/node-esm/totp-611a1ef1.js.map +1 -0
- package/dist/rn/index.js +1 -1
- package/dist/rn/internal.js +1 -1
- package/dist/rn/{phone-a321ec79.js → phone-770ab2d6.js} +333 -332
- package/dist/rn/phone-770ab2d6.js.map +1 -0
- package/dist/rn/src/core/auth/auth_impl.d.ts +0 -1
- package/dist/rn/src/model/auth.d.ts +0 -1
- package/dist/rn/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +1 -0
- package/dist/src/core/auth/auth_impl.d.ts +0 -1
- package/dist/src/model/auth.d.ts +0 -1
- package/dist/src/platform_browser/recaptcha/recaptcha_enterprise_verifier.d.ts +1 -0
- package/package.json +6 -6
- package/dist/browser-cjs/index-1a2a2779.js.map +0 -1
- package/dist/cordova/popup_redirect-8599967b.js.map +0 -1
- package/dist/esm2017/index-f8a66098.js.map +0 -1
- package/dist/esm5/index-fdb9efbb.js.map +0 -1
- package/dist/node/totp-7ea0acc9.js.map +0 -1
- package/dist/node-esm/totp-af1856f8.js.map +0 -1
- package/dist/rn/phone-a321ec79.js.map +0 -1
package/dist/auth.d.ts
CHANGED
|
@@ -881,7 +881,6 @@ declare interface AuthInternal extends Auth {
|
|
|
881
881
|
_errorFactory: ErrorFactory<AuthErrorCode, AuthErrorParams>;
|
|
882
882
|
useDeviceLanguage(): void;
|
|
883
883
|
signOut(): Promise<void>;
|
|
884
|
-
initializeRecaptchaConfig(): Promise<void>;
|
|
885
884
|
}
|
|
886
885
|
|
|
887
886
|
declare class AuthPopup {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var util = require('@firebase/util');
|
|
4
4
|
var app = require('@firebase/app');
|
|
5
|
-
var tslib = require('tslib');
|
|
6
5
|
var logger = require('@firebase/logger');
|
|
6
|
+
var tslib = require('tslib');
|
|
7
7
|
var component = require('@firebase/component');
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -105,6 +105,50 @@ const ActionCodeOperation = {
|
|
|
105
105
|
VERIFY_EMAIL: 'VERIFY_EMAIL'
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* @license
|
|
110
|
+
* Copyright 2020 Google LLC
|
|
111
|
+
*
|
|
112
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
113
|
+
* you may not use this file except in compliance with the License.
|
|
114
|
+
* You may obtain a copy of the License at
|
|
115
|
+
*
|
|
116
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
117
|
+
*
|
|
118
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
119
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
120
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
121
|
+
* See the License for the specific language governing permissions and
|
|
122
|
+
* limitations under the License.
|
|
123
|
+
*/
|
|
124
|
+
function isV2(grecaptcha) {
|
|
125
|
+
return (grecaptcha !== undefined &&
|
|
126
|
+
grecaptcha.getResponse !== undefined);
|
|
127
|
+
}
|
|
128
|
+
function isEnterprise(grecaptcha) {
|
|
129
|
+
return (grecaptcha !== undefined &&
|
|
130
|
+
grecaptcha.enterprise !== undefined);
|
|
131
|
+
}
|
|
132
|
+
class RecaptchaConfig {
|
|
133
|
+
constructor(response) {
|
|
134
|
+
/**
|
|
135
|
+
* The reCAPTCHA site key.
|
|
136
|
+
*/
|
|
137
|
+
this.siteKey = '';
|
|
138
|
+
/**
|
|
139
|
+
* The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
|
|
140
|
+
*/
|
|
141
|
+
this.emailPasswordEnabled = false;
|
|
142
|
+
if (response.recaptchaKey === undefined) {
|
|
143
|
+
throw new Error('recaptchaKey undefined');
|
|
144
|
+
}
|
|
145
|
+
// Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
|
|
146
|
+
this.siteKey = response.recaptchaKey.split('/')[3];
|
|
147
|
+
this.emailPasswordEnabled = response.recaptchaEnforcementState.some(enforcementState => enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
|
|
148
|
+
enforcementState.enforcementState !== 'OFF');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
108
152
|
/**
|
|
109
153
|
* @license
|
|
110
154
|
* Copyright 2020 Google LLC
|
|
@@ -973,6 +1017,29 @@ function _makeTaggedError(auth, code, response) {
|
|
|
973
1017
|
return error;
|
|
974
1018
|
}
|
|
975
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* @license
|
|
1022
|
+
* Copyright 2020 Google LLC
|
|
1023
|
+
*
|
|
1024
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
1025
|
+
* you may not use this file except in compliance with the License.
|
|
1026
|
+
* You may obtain a copy of the License at
|
|
1027
|
+
*
|
|
1028
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
1029
|
+
*
|
|
1030
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
1031
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
1032
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1033
|
+
* See the License for the specific language governing permissions and
|
|
1034
|
+
* limitations under the License.
|
|
1035
|
+
*/
|
|
1036
|
+
async function getRecaptchaParams(auth) {
|
|
1037
|
+
return ((await _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)).recaptchaSiteKey || '');
|
|
1038
|
+
}
|
|
1039
|
+
async function getRecaptchaConfig(auth, request) {
|
|
1040
|
+
return _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v2/recaptchaConfig" /* Endpoint.GET_RECAPTCHA_CONFIG */, _addTidIfNecessary(auth, request));
|
|
1041
|
+
}
|
|
1042
|
+
|
|
976
1043
|
/**
|
|
977
1044
|
* @license
|
|
978
1045
|
* Copyright 2020 Google LLC
|
|
@@ -2093,238 +2160,6 @@ function _getClientVersion(clientPlatform, frameworks = []) {
|
|
|
2093
2160
|
return `${reportedPlatform}/${"JsCore" /* ClientImplementation.CORE */}/${app.SDK_VERSION}/${reportedFrameworks}`;
|
|
2094
2161
|
}
|
|
2095
2162
|
|
|
2096
|
-
/**
|
|
2097
|
-
* @license
|
|
2098
|
-
* Copyright 2020 Google LLC
|
|
2099
|
-
*
|
|
2100
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2101
|
-
* you may not use this file except in compliance with the License.
|
|
2102
|
-
* You may obtain a copy of the License at
|
|
2103
|
-
*
|
|
2104
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2105
|
-
*
|
|
2106
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2107
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2108
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2109
|
-
* See the License for the specific language governing permissions and
|
|
2110
|
-
* limitations under the License.
|
|
2111
|
-
*/
|
|
2112
|
-
async function getRecaptchaParams(auth) {
|
|
2113
|
-
return ((await _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v1/recaptchaParams" /* Endpoint.GET_RECAPTCHA_PARAM */)).recaptchaSiteKey || '');
|
|
2114
|
-
}
|
|
2115
|
-
async function getRecaptchaConfig(auth, request) {
|
|
2116
|
-
return _performApiRequest(auth, "GET" /* HttpMethod.GET */, "/v2/recaptchaConfig" /* Endpoint.GET_RECAPTCHA_CONFIG */, _addTidIfNecessary(auth, request));
|
|
2117
|
-
}
|
|
2118
|
-
|
|
2119
|
-
/**
|
|
2120
|
-
* @license
|
|
2121
|
-
* Copyright 2020 Google LLC
|
|
2122
|
-
*
|
|
2123
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2124
|
-
* you may not use this file except in compliance with the License.
|
|
2125
|
-
* You may obtain a copy of the License at
|
|
2126
|
-
*
|
|
2127
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2128
|
-
*
|
|
2129
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2130
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2131
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2132
|
-
* See the License for the specific language governing permissions and
|
|
2133
|
-
* limitations under the License.
|
|
2134
|
-
*/
|
|
2135
|
-
function isV2(grecaptcha) {
|
|
2136
|
-
return (grecaptcha !== undefined &&
|
|
2137
|
-
grecaptcha.getResponse !== undefined);
|
|
2138
|
-
}
|
|
2139
|
-
function isEnterprise(grecaptcha) {
|
|
2140
|
-
return (grecaptcha !== undefined &&
|
|
2141
|
-
grecaptcha.enterprise !== undefined);
|
|
2142
|
-
}
|
|
2143
|
-
class RecaptchaConfig {
|
|
2144
|
-
constructor(response) {
|
|
2145
|
-
/**
|
|
2146
|
-
* The reCAPTCHA site key.
|
|
2147
|
-
*/
|
|
2148
|
-
this.siteKey = '';
|
|
2149
|
-
/**
|
|
2150
|
-
* The reCAPTCHA enablement status of the {@link EmailAuthProvider} for the current tenant.
|
|
2151
|
-
*/
|
|
2152
|
-
this.emailPasswordEnabled = false;
|
|
2153
|
-
if (response.recaptchaKey === undefined) {
|
|
2154
|
-
throw new Error('recaptchaKey undefined');
|
|
2155
|
-
}
|
|
2156
|
-
// Example response.recaptchaKey: "projects/proj123/keys/sitekey123"
|
|
2157
|
-
this.siteKey = response.recaptchaKey.split('/')[3];
|
|
2158
|
-
this.emailPasswordEnabled = response.recaptchaEnforcementState.some(enforcementState => enforcementState.provider === 'EMAIL_PASSWORD_PROVIDER' &&
|
|
2159
|
-
enforcementState.enforcementState !== 'OFF');
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
|
|
2163
|
-
/**
|
|
2164
|
-
* @license
|
|
2165
|
-
* Copyright 2020 Google LLC
|
|
2166
|
-
*
|
|
2167
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2168
|
-
* you may not use this file except in compliance with the License.
|
|
2169
|
-
* You may obtain a copy of the License at
|
|
2170
|
-
*
|
|
2171
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2172
|
-
*
|
|
2173
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
2174
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2175
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2176
|
-
* See the License for the specific language governing permissions and
|
|
2177
|
-
* limitations under the License.
|
|
2178
|
-
*/
|
|
2179
|
-
function getScriptParentElement() {
|
|
2180
|
-
var _a, _b;
|
|
2181
|
-
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
2182
|
-
}
|
|
2183
|
-
function _loadJS(url) {
|
|
2184
|
-
// TODO: consider adding timeout support & cancellation
|
|
2185
|
-
return new Promise((resolve, reject) => {
|
|
2186
|
-
const el = document.createElement('script');
|
|
2187
|
-
el.setAttribute('src', url);
|
|
2188
|
-
el.onload = resolve;
|
|
2189
|
-
el.onerror = e => {
|
|
2190
|
-
const error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
2191
|
-
error.customData = e;
|
|
2192
|
-
reject(error);
|
|
2193
|
-
};
|
|
2194
|
-
el.type = 'text/javascript';
|
|
2195
|
-
el.charset = 'UTF-8';
|
|
2196
|
-
getScriptParentElement().appendChild(el);
|
|
2197
|
-
});
|
|
2198
|
-
}
|
|
2199
|
-
function _generateCallbackName(prefix) {
|
|
2200
|
-
return `__${prefix}${Math.floor(Math.random() * 1000000)}`;
|
|
2201
|
-
}
|
|
2202
|
-
|
|
2203
|
-
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2204
|
-
const RECAPTCHA_ENTERPRISE_URL = 'https://www.google.com/recaptcha/enterprise.js?render=';
|
|
2205
|
-
const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
|
|
2206
|
-
const FAKE_TOKEN = 'NO_RECAPTCHA';
|
|
2207
|
-
class RecaptchaEnterpriseVerifier {
|
|
2208
|
-
/**
|
|
2209
|
-
*
|
|
2210
|
-
* @param authExtern - The corresponding Firebase {@link Auth} instance.
|
|
2211
|
-
*
|
|
2212
|
-
*/
|
|
2213
|
-
constructor(authExtern) {
|
|
2214
|
-
/**
|
|
2215
|
-
* Identifies the type of application verifier (e.g. "recaptcha-enterprise").
|
|
2216
|
-
*/
|
|
2217
|
-
this.type = RECAPTCHA_ENTERPRISE_VERIFIER_TYPE;
|
|
2218
|
-
this.auth = _castAuth(authExtern);
|
|
2219
|
-
}
|
|
2220
|
-
/**
|
|
2221
|
-
* Executes the verification process.
|
|
2222
|
-
*
|
|
2223
|
-
* @returns A Promise for a token that can be used to assert the validity of a request.
|
|
2224
|
-
*/
|
|
2225
|
-
async verify(action = 'verify', forceRefresh = false) {
|
|
2226
|
-
async function retrieveSiteKey(auth) {
|
|
2227
|
-
if (!forceRefresh) {
|
|
2228
|
-
if (auth.tenantId == null && auth._agentRecaptchaConfig != null) {
|
|
2229
|
-
return auth._agentRecaptchaConfig.siteKey;
|
|
2230
|
-
}
|
|
2231
|
-
if (auth.tenantId != null &&
|
|
2232
|
-
auth._tenantRecaptchaConfigs[auth.tenantId] !== undefined) {
|
|
2233
|
-
return auth._tenantRecaptchaConfigs[auth.tenantId].siteKey;
|
|
2234
|
-
}
|
|
2235
|
-
}
|
|
2236
|
-
return new Promise(async (resolve, reject) => {
|
|
2237
|
-
getRecaptchaConfig(auth, {
|
|
2238
|
-
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2239
|
-
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2240
|
-
})
|
|
2241
|
-
.then(response => {
|
|
2242
|
-
if (response.recaptchaKey === undefined) {
|
|
2243
|
-
reject(new Error('recaptcha Enterprise site key undefined'));
|
|
2244
|
-
}
|
|
2245
|
-
else {
|
|
2246
|
-
const config = new RecaptchaConfig(response);
|
|
2247
|
-
if (auth.tenantId == null) {
|
|
2248
|
-
auth._agentRecaptchaConfig = config;
|
|
2249
|
-
}
|
|
2250
|
-
else {
|
|
2251
|
-
auth._tenantRecaptchaConfigs[auth.tenantId] = config;
|
|
2252
|
-
}
|
|
2253
|
-
return resolve(config.siteKey);
|
|
2254
|
-
}
|
|
2255
|
-
})
|
|
2256
|
-
.catch(error => {
|
|
2257
|
-
reject(error);
|
|
2258
|
-
});
|
|
2259
|
-
});
|
|
2260
|
-
}
|
|
2261
|
-
function retrieveRecaptchaToken(siteKey, resolve, reject) {
|
|
2262
|
-
const grecaptcha = window.grecaptcha;
|
|
2263
|
-
if (isEnterprise(grecaptcha)) {
|
|
2264
|
-
grecaptcha.enterprise.ready(() => {
|
|
2265
|
-
grecaptcha.enterprise
|
|
2266
|
-
.execute(siteKey, { action })
|
|
2267
|
-
.then(token => {
|
|
2268
|
-
resolve(token);
|
|
2269
|
-
})
|
|
2270
|
-
.catch(() => {
|
|
2271
|
-
resolve(FAKE_TOKEN);
|
|
2272
|
-
});
|
|
2273
|
-
});
|
|
2274
|
-
}
|
|
2275
|
-
else {
|
|
2276
|
-
reject(Error('No reCAPTCHA enterprise script loaded.'));
|
|
2277
|
-
}
|
|
2278
|
-
}
|
|
2279
|
-
return new Promise((resolve, reject) => {
|
|
2280
|
-
retrieveSiteKey(this.auth)
|
|
2281
|
-
.then(siteKey => {
|
|
2282
|
-
if (!forceRefresh && isEnterprise(window.grecaptcha)) {
|
|
2283
|
-
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2284
|
-
}
|
|
2285
|
-
else {
|
|
2286
|
-
if (typeof window === 'undefined') {
|
|
2287
|
-
reject(new Error('RecaptchaVerifier is only supported in browser'));
|
|
2288
|
-
return;
|
|
2289
|
-
}
|
|
2290
|
-
_loadJS(RECAPTCHA_ENTERPRISE_URL + siteKey)
|
|
2291
|
-
.then(() => {
|
|
2292
|
-
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2293
|
-
})
|
|
2294
|
-
.catch(error => {
|
|
2295
|
-
reject(error);
|
|
2296
|
-
});
|
|
2297
|
-
}
|
|
2298
|
-
})
|
|
2299
|
-
.catch(error => {
|
|
2300
|
-
reject(error);
|
|
2301
|
-
});
|
|
2302
|
-
});
|
|
2303
|
-
}
|
|
2304
|
-
}
|
|
2305
|
-
async function injectRecaptchaFields(auth, request, action, captchaResp = false) {
|
|
2306
|
-
const verifier = new RecaptchaEnterpriseVerifier(auth);
|
|
2307
|
-
let captchaResponse;
|
|
2308
|
-
try {
|
|
2309
|
-
captchaResponse = await verifier.verify(action);
|
|
2310
|
-
}
|
|
2311
|
-
catch (error) {
|
|
2312
|
-
captchaResponse = await verifier.verify(action, true);
|
|
2313
|
-
}
|
|
2314
|
-
const newRequest = Object.assign({}, request);
|
|
2315
|
-
if (!captchaResp) {
|
|
2316
|
-
Object.assign(newRequest, { captchaResponse });
|
|
2317
|
-
}
|
|
2318
|
-
else {
|
|
2319
|
-
Object.assign(newRequest, { 'captchaResp': captchaResponse });
|
|
2320
|
-
}
|
|
2321
|
-
Object.assign(newRequest, { 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */ });
|
|
2322
|
-
Object.assign(newRequest, {
|
|
2323
|
-
'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2324
|
-
});
|
|
2325
|
-
return newRequest;
|
|
2326
|
-
}
|
|
2327
|
-
|
|
2328
2163
|
/**
|
|
2329
2164
|
* @license
|
|
2330
2165
|
* Copyright 2022 Google LLC
|
|
@@ -2665,23 +2500,6 @@ class AuthImpl {
|
|
|
2665
2500
|
await this.assertedPersistence.setPersistence(_getInstance(persistence));
|
|
2666
2501
|
});
|
|
2667
2502
|
}
|
|
2668
|
-
async initializeRecaptchaConfig() {
|
|
2669
|
-
const response = await getRecaptchaConfig(this, {
|
|
2670
|
-
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2671
|
-
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2672
|
-
});
|
|
2673
|
-
const config = new RecaptchaConfig(response);
|
|
2674
|
-
if (this.tenantId == null) {
|
|
2675
|
-
this._agentRecaptchaConfig = config;
|
|
2676
|
-
}
|
|
2677
|
-
else {
|
|
2678
|
-
this._tenantRecaptchaConfigs[this.tenantId] = config;
|
|
2679
|
-
}
|
|
2680
|
-
if (config.emailPasswordEnabled) {
|
|
2681
|
-
const verifier = new RecaptchaEnterpriseVerifier(this);
|
|
2682
|
-
void verifier.verify();
|
|
2683
|
-
}
|
|
2684
|
-
}
|
|
2685
2503
|
_getRecaptchaConfig() {
|
|
2686
2504
|
if (this.tenantId == null) {
|
|
2687
2505
|
return this._agentRecaptchaConfig;
|
|
@@ -2925,6 +2743,189 @@ class Subscription {
|
|
|
2925
2743
|
}
|
|
2926
2744
|
}
|
|
2927
2745
|
|
|
2746
|
+
/**
|
|
2747
|
+
* @license
|
|
2748
|
+
* Copyright 2020 Google LLC
|
|
2749
|
+
*
|
|
2750
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
2751
|
+
* you may not use this file except in compliance with the License.
|
|
2752
|
+
* You may obtain a copy of the License at
|
|
2753
|
+
*
|
|
2754
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
2755
|
+
*
|
|
2756
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
2757
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
2758
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2759
|
+
* See the License for the specific language governing permissions and
|
|
2760
|
+
* limitations under the License.
|
|
2761
|
+
*/
|
|
2762
|
+
function getScriptParentElement() {
|
|
2763
|
+
var _a, _b;
|
|
2764
|
+
return (_b = (_a = document.getElementsByTagName('head')) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : document;
|
|
2765
|
+
}
|
|
2766
|
+
function _loadJS(url) {
|
|
2767
|
+
// TODO: consider adding timeout support & cancellation
|
|
2768
|
+
return new Promise((resolve, reject) => {
|
|
2769
|
+
const el = document.createElement('script');
|
|
2770
|
+
el.setAttribute('src', url);
|
|
2771
|
+
el.onload = resolve;
|
|
2772
|
+
el.onerror = e => {
|
|
2773
|
+
const error = _createError("internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
2774
|
+
error.customData = e;
|
|
2775
|
+
reject(error);
|
|
2776
|
+
};
|
|
2777
|
+
el.type = 'text/javascript';
|
|
2778
|
+
el.charset = 'UTF-8';
|
|
2779
|
+
getScriptParentElement().appendChild(el);
|
|
2780
|
+
});
|
|
2781
|
+
}
|
|
2782
|
+
function _generateCallbackName(prefix) {
|
|
2783
|
+
return `__${prefix}${Math.floor(Math.random() * 1000000)}`;
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2786
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
2787
|
+
const RECAPTCHA_ENTERPRISE_URL = 'https://www.google.com/recaptcha/enterprise.js?render=';
|
|
2788
|
+
const RECAPTCHA_ENTERPRISE_VERIFIER_TYPE = 'recaptcha-enterprise';
|
|
2789
|
+
const FAKE_TOKEN = 'NO_RECAPTCHA';
|
|
2790
|
+
class RecaptchaEnterpriseVerifier {
|
|
2791
|
+
/**
|
|
2792
|
+
*
|
|
2793
|
+
* @param authExtern - The corresponding Firebase {@link Auth} instance.
|
|
2794
|
+
*
|
|
2795
|
+
*/
|
|
2796
|
+
constructor(authExtern) {
|
|
2797
|
+
/**
|
|
2798
|
+
* Identifies the type of application verifier (e.g. "recaptcha-enterprise").
|
|
2799
|
+
*/
|
|
2800
|
+
this.type = RECAPTCHA_ENTERPRISE_VERIFIER_TYPE;
|
|
2801
|
+
this.auth = _castAuth(authExtern);
|
|
2802
|
+
}
|
|
2803
|
+
/**
|
|
2804
|
+
* Executes the verification process.
|
|
2805
|
+
*
|
|
2806
|
+
* @returns A Promise for a token that can be used to assert the validity of a request.
|
|
2807
|
+
*/
|
|
2808
|
+
async verify(action = 'verify', forceRefresh = false) {
|
|
2809
|
+
async function retrieveSiteKey(auth) {
|
|
2810
|
+
if (!forceRefresh) {
|
|
2811
|
+
if (auth.tenantId == null && auth._agentRecaptchaConfig != null) {
|
|
2812
|
+
return auth._agentRecaptchaConfig.siteKey;
|
|
2813
|
+
}
|
|
2814
|
+
if (auth.tenantId != null &&
|
|
2815
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] !== undefined) {
|
|
2816
|
+
return auth._tenantRecaptchaConfigs[auth.tenantId].siteKey;
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
return new Promise(async (resolve, reject) => {
|
|
2820
|
+
getRecaptchaConfig(auth, {
|
|
2821
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2822
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2823
|
+
})
|
|
2824
|
+
.then(response => {
|
|
2825
|
+
if (response.recaptchaKey === undefined) {
|
|
2826
|
+
reject(new Error('recaptcha Enterprise site key undefined'));
|
|
2827
|
+
}
|
|
2828
|
+
else {
|
|
2829
|
+
const config = new RecaptchaConfig(response);
|
|
2830
|
+
if (auth.tenantId == null) {
|
|
2831
|
+
auth._agentRecaptchaConfig = config;
|
|
2832
|
+
}
|
|
2833
|
+
else {
|
|
2834
|
+
auth._tenantRecaptchaConfigs[auth.tenantId] = config;
|
|
2835
|
+
}
|
|
2836
|
+
return resolve(config.siteKey);
|
|
2837
|
+
}
|
|
2838
|
+
})
|
|
2839
|
+
.catch(error => {
|
|
2840
|
+
reject(error);
|
|
2841
|
+
});
|
|
2842
|
+
});
|
|
2843
|
+
}
|
|
2844
|
+
function retrieveRecaptchaToken(siteKey, resolve, reject) {
|
|
2845
|
+
const grecaptcha = window.grecaptcha;
|
|
2846
|
+
if (isEnterprise(grecaptcha)) {
|
|
2847
|
+
grecaptcha.enterprise.ready(() => {
|
|
2848
|
+
grecaptcha.enterprise
|
|
2849
|
+
.execute(siteKey, { action })
|
|
2850
|
+
.then(token => {
|
|
2851
|
+
resolve(token);
|
|
2852
|
+
})
|
|
2853
|
+
.catch(() => {
|
|
2854
|
+
resolve(FAKE_TOKEN);
|
|
2855
|
+
});
|
|
2856
|
+
});
|
|
2857
|
+
}
|
|
2858
|
+
else {
|
|
2859
|
+
reject(Error('No reCAPTCHA enterprise script loaded.'));
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
return new Promise((resolve, reject) => {
|
|
2863
|
+
retrieveSiteKey(this.auth)
|
|
2864
|
+
.then(siteKey => {
|
|
2865
|
+
if (!forceRefresh && isEnterprise(window.grecaptcha)) {
|
|
2866
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2867
|
+
}
|
|
2868
|
+
else {
|
|
2869
|
+
if (typeof window === 'undefined') {
|
|
2870
|
+
reject(new Error('RecaptchaVerifier is only supported in browser'));
|
|
2871
|
+
return;
|
|
2872
|
+
}
|
|
2873
|
+
_loadJS(RECAPTCHA_ENTERPRISE_URL + siteKey)
|
|
2874
|
+
.then(() => {
|
|
2875
|
+
retrieveRecaptchaToken(siteKey, resolve, reject);
|
|
2876
|
+
})
|
|
2877
|
+
.catch(error => {
|
|
2878
|
+
reject(error);
|
|
2879
|
+
});
|
|
2880
|
+
}
|
|
2881
|
+
})
|
|
2882
|
+
.catch(error => {
|
|
2883
|
+
reject(error);
|
|
2884
|
+
});
|
|
2885
|
+
});
|
|
2886
|
+
}
|
|
2887
|
+
}
|
|
2888
|
+
async function injectRecaptchaFields(auth, request, action, captchaResp = false) {
|
|
2889
|
+
const verifier = new RecaptchaEnterpriseVerifier(auth);
|
|
2890
|
+
let captchaResponse;
|
|
2891
|
+
try {
|
|
2892
|
+
captchaResponse = await verifier.verify(action);
|
|
2893
|
+
}
|
|
2894
|
+
catch (error) {
|
|
2895
|
+
captchaResponse = await verifier.verify(action, true);
|
|
2896
|
+
}
|
|
2897
|
+
const newRequest = Object.assign({}, request);
|
|
2898
|
+
if (!captchaResp) {
|
|
2899
|
+
Object.assign(newRequest, { captchaResponse });
|
|
2900
|
+
}
|
|
2901
|
+
else {
|
|
2902
|
+
Object.assign(newRequest, { 'captchaResp': captchaResponse });
|
|
2903
|
+
}
|
|
2904
|
+
Object.assign(newRequest, { 'clientType': "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */ });
|
|
2905
|
+
Object.assign(newRequest, {
|
|
2906
|
+
'recaptchaVersion': "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2907
|
+
});
|
|
2908
|
+
return newRequest;
|
|
2909
|
+
}
|
|
2910
|
+
async function _initializeRecaptchaConfig(auth) {
|
|
2911
|
+
const authInternal = _castAuth(auth);
|
|
2912
|
+
const response = await getRecaptchaConfig(authInternal, {
|
|
2913
|
+
clientType: "CLIENT_TYPE_WEB" /* RecaptchaClientType.WEB */,
|
|
2914
|
+
version: "RECAPTCHA_ENTERPRISE" /* RecaptchaVersion.ENTERPRISE */
|
|
2915
|
+
});
|
|
2916
|
+
const config = new RecaptchaConfig(response);
|
|
2917
|
+
if (authInternal.tenantId == null) {
|
|
2918
|
+
authInternal._agentRecaptchaConfig = config;
|
|
2919
|
+
}
|
|
2920
|
+
else {
|
|
2921
|
+
authInternal._tenantRecaptchaConfigs[authInternal.tenantId] = config;
|
|
2922
|
+
}
|
|
2923
|
+
if (config.emailPasswordEnabled) {
|
|
2924
|
+
const verifier = new RecaptchaEnterpriseVerifier(authInternal);
|
|
2925
|
+
void verifier.verify();
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
|
|
2928
2929
|
/**
|
|
2929
2930
|
* @license
|
|
2930
2931
|
* Copyright 2020 Google LLC
|
|
@@ -6124,8 +6125,7 @@ function setPersistence(auth, persistence) {
|
|
|
6124
6125
|
* @public
|
|
6125
6126
|
*/
|
|
6126
6127
|
function initializeRecaptchaConfig(auth) {
|
|
6127
|
-
|
|
6128
|
-
return authInternal.initializeRecaptchaConfig();
|
|
6128
|
+
return _initializeRecaptchaConfig(auth);
|
|
6129
6129
|
}
|
|
6130
6130
|
/**
|
|
6131
6131
|
* Adds an observer for changes to the signed-in user's ID token.
|
|
@@ -9933,7 +9933,7 @@ function _isEmptyString(input) {
|
|
|
9933
9933
|
}
|
|
9934
9934
|
|
|
9935
9935
|
var name = "@firebase/auth";
|
|
9936
|
-
var version = "1.1.0-canary.
|
|
9936
|
+
var version = "1.1.0-canary.f9a232a29";
|
|
9937
9937
|
|
|
9938
9938
|
/**
|
|
9939
9939
|
* @license
|
|
@@ -10258,4 +10258,4 @@ exports.updateProfile = updateProfile;
|
|
|
10258
10258
|
exports.useDeviceLanguage = useDeviceLanguage;
|
|
10259
10259
|
exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
|
|
10260
10260
|
exports.verifyPasswordResetCode = verifyPasswordResetCode;
|
|
10261
|
-
//# sourceMappingURL=index-
|
|
10261
|
+
//# sourceMappingURL=index-dde9002c.js.map
|