1 | import { ap as _isAndroid, aq as _isIOS7Or8, ar as _isIOS, as as _fail, at as _getRedirectUrl, au as debugAssert, av as _getProjectConfig, aw as _createError, ax as _assert, ay as AuthEventManager, az as _getInstance, b as browserLocalPersistence, aA as _persistenceKeyName, aB as _clearRedirectOutcomes, a as browserSessionPersistence, aC as _getRedirectResult, aD as _overrideRedirectResult, aE as _castAuth } from './index-0e5111f4.js';
|
2 | export { A as ActionCodeOperation, ad as ActionCodeURL, H as AuthCredential, D as AuthErrorCodes, aG as AuthImpl, aJ as AuthPopup, I as EmailAuthCredential, M as EmailAuthProvider, N as FacebookAuthProvider, F as FactorId, aK as FetchProvider, T as GithubAuthProvider, Q as GoogleAuthProvider, J as OAuthCredential, U as OAuthProvider, O as OperationType, K as PhoneAuthCredential, P as PhoneAuthProvider, m as PhoneMultiFactorGenerator, o as ProviderId, R as RecaptchaVerifier, aL as SAMLAuthCredential, V as SAMLAuthProvider, S as SignInMethod, W as TwitterAuthProvider, aF as UserImpl, ax as _assert, aE as _castAuth, as as _fail, aI as _generateEventId, aH as _getClientVersion, az as _getInstance, aC as _getRedirectResult, aD as _overrideRedirectResult, aA as _persistenceKeyName, a2 as applyActionCode, t as beforeAuthStateChanged, b as browserLocalPersistence, k as browserPopupRedirectResolver, a as browserSessionPersistence, a3 as checkActionCode, a1 as confirmPasswordReset, G as connectAuthEmulator, a5 as createUserWithEmailAndPassword, B as debugErrorMap, z as deleteUser, aa as fetchSignInMethodsForEmail, al as getAdditionalUserInfo, n as getAuth, ai as getIdToken, aj as getIdTokenResult, an as getMultiFactorResolver, j as getRedirectResult, L as inMemoryPersistence, i as indexedDBLocalPersistence, E as initializeAuth, a8 as isSignInWithEmailLink, Z as linkWithCredential, l as linkWithPhoneNumber, d as linkWithPopup, g as linkWithRedirect, ao as multiFactor, v as onAuthStateChanged, q as onIdTokenChanged, ae as parseActionCodeURL, C as prodErrorMap, _ as reauthenticateWithCredential, r as reauthenticateWithPhoneNumber, e as reauthenticateWithPopup, h as reauthenticateWithRedirect, am as reload, ab as sendEmailVerification, a0 as sendPasswordResetEmail, a7 as sendSignInLinkToEmail, p as setPersistence, X as signInAnonymously, Y as signInWithCredential, $ as signInWithCustomToken, a6 as signInWithEmailAndPassword, a9 as signInWithEmailLink, s as signInWithPhoneNumber, c as signInWithPopup, f as signInWithRedirect, y as signOut, ak as unlink, x as updateCurrentUser, ag as updateEmail, ah as updatePassword, u as updatePhoneNumber, af as updateProfile, w as useDeviceLanguage, ac as verifyBeforeUpdateEmail, a4 as verifyPasswordResetCode } from './index-0e5111f4.js';
|
3 | import { __awaiter, __generator, __extends } from 'tslib';
|
4 | import { querystringDecode } from '@firebase/util';
|
5 | import '@firebase/app';
|
6 | import '@firebase/logger';
|
7 | import '@firebase/component';
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | function _cordovaWindow() {
|
26 | return window;
|
27 | }
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | var REDIRECT_TIMEOUT_MS = 2000;
|
50 |
|
51 |
|
52 |
|
53 | function _generateHandlerUrl(auth, event, provider) {
|
54 | var _a;
|
55 | return __awaiter(this, void 0, void 0, function () {
|
56 | var BuildInfo, sessionDigest, additionalParams;
|
57 | return __generator(this, function (_b) {
|
58 | switch (_b.label) {
|
59 | case 0:
|
60 | BuildInfo = _cordovaWindow().BuildInfo;
|
61 | debugAssert(event.sessionId, 'AuthEvent did not contain a session ID');
|
62 | return [4 , computeSha256(event.sessionId)];
|
63 | case 1:
|
64 | sessionDigest = _b.sent();
|
65 | additionalParams = {};
|
66 | if (_isIOS()) {
|
67 |
|
68 | additionalParams['ibi'] = BuildInfo.packageName;
|
69 | }
|
70 | else if (_isAndroid()) {
|
71 |
|
72 | additionalParams['apn'] = BuildInfo.packageName;
|
73 | }
|
74 | else {
|
75 | _fail(auth, "operation-not-supported-in-this-environment" );
|
76 | }
|
77 |
|
78 | if (BuildInfo.displayName) {
|
79 | additionalParams['appDisplayName'] = BuildInfo.displayName;
|
80 | }
|
81 |
|
82 | additionalParams['sessionId'] = sessionDigest;
|
83 | return [2 , _getRedirectUrl(auth, provider, event.type, undefined, (_a = event.eventId) !== null && _a !== void 0 ? _a : undefined, additionalParams)];
|
84 | }
|
85 | });
|
86 | });
|
87 | }
|
88 |
|
89 |
|
90 |
|
91 | function _validateOrigin(auth) {
|
92 | return __awaiter(this, void 0, void 0, function () {
|
93 | var BuildInfo, request;
|
94 | return __generator(this, function (_a) {
|
95 | switch (_a.label) {
|
96 | case 0:
|
97 | BuildInfo = _cordovaWindow().BuildInfo;
|
98 | request = {};
|
99 | if (_isIOS()) {
|
100 | request.iosBundleId = BuildInfo.packageName;
|
101 | }
|
102 | else if (_isAndroid()) {
|
103 | request.androidPackageName = BuildInfo.packageName;
|
104 | }
|
105 | else {
|
106 | _fail(auth, "operation-not-supported-in-this-environment" );
|
107 | }
|
108 |
|
109 | return [4 , _getProjectConfig(auth, request)];
|
110 | case 1:
|
111 |
|
112 | _a.sent();
|
113 | return [2 ];
|
114 | }
|
115 | });
|
116 | });
|
117 | }
|
118 | function _performRedirect(handlerUrl) {
|
119 |
|
120 | var cordova = _cordovaWindow().cordova;
|
121 | return new Promise(function (resolve) {
|
122 | cordova.plugins.browsertab.isAvailable(function (browserTabIsAvailable) {
|
123 | var iabRef = null;
|
124 | if (browserTabIsAvailable) {
|
125 | cordova.plugins.browsertab.openUrl(handlerUrl);
|
126 | }
|
127 | else {
|
128 |
|
129 | iabRef = cordova.InAppBrowser.open(handlerUrl, _isIOS7Or8() ? '_blank' : '_system', 'location=yes');
|
130 | }
|
131 | resolve(iabRef);
|
132 | });
|
133 | });
|
134 | }
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 | function _waitForAppResume(auth, eventListener, iabRef) {
|
142 | return __awaiter(this, void 0, void 0, function () {
|
143 | var cordova, cleanup;
|
144 | return __generator(this, function (_a) {
|
145 | switch (_a.label) {
|
146 | case 0:
|
147 | cordova = _cordovaWindow().cordova;
|
148 | cleanup = function () { };
|
149 | _a.label = 1;
|
150 | case 1:
|
151 | _a.trys.push([1, , 3, 4]);
|
152 | return [4 , new Promise(function (resolve, reject) {
|
153 | var onCloseTimer = null;
|
154 |
|
155 | function authEventSeen() {
|
156 | var _a;
|
157 |
|
158 |
|
159 | resolve();
|
160 | var closeBrowserTab = (_a = cordova.plugins.browsertab) === null || _a === void 0 ? void 0 : _a.close;
|
161 | if (typeof closeBrowserTab === 'function') {
|
162 | closeBrowserTab();
|
163 | }
|
164 |
|
165 |
|
166 | if (typeof (iabRef === null || iabRef === void 0 ? void 0 : iabRef.close) === 'function') {
|
167 | iabRef.close();
|
168 | }
|
169 | }
|
170 | function resumed() {
|
171 | if (onCloseTimer) {
|
172 |
|
173 | return;
|
174 | }
|
175 | onCloseTimer = window.setTimeout(function () {
|
176 |
|
177 | reject(_createError(auth, "redirect-cancelled-by-user" ));
|
178 | }, REDIRECT_TIMEOUT_MS);
|
179 | }
|
180 | function visibilityChanged() {
|
181 | if ((document === null || document === void 0 ? void 0 : document.visibilityState) === 'visible') {
|
182 | resumed();
|
183 | }
|
184 | }
|
185 |
|
186 |
|
187 | eventListener.addPassiveListener(authEventSeen);
|
188 |
|
189 | document.addEventListener('resume', resumed, false);
|
190 | if (_isAndroid()) {
|
191 | document.addEventListener('visibilitychange', visibilityChanged, false);
|
192 | }
|
193 |
|
194 | cleanup = function () {
|
195 | eventListener.removePassiveListener(authEventSeen);
|
196 | document.removeEventListener('resume', resumed, false);
|
197 | document.removeEventListener('visibilitychange', visibilityChanged, false);
|
198 | if (onCloseTimer) {
|
199 | window.clearTimeout(onCloseTimer);
|
200 | }
|
201 | };
|
202 | })];
|
203 | case 2:
|
204 | _a.sent();
|
205 | return [3 , 4];
|
206 | case 3:
|
207 | cleanup();
|
208 | return [7 ];
|
209 | case 4: return [2 ];
|
210 | }
|
211 | });
|
212 | });
|
213 | }
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 | function _checkCordovaConfiguration(auth) {
|
220 | var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
221 | var win = _cordovaWindow();
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 | _assert(typeof ((_a = win === null || win === void 0 ? void 0 : win.universalLinks) === null || _a === void 0 ? void 0 : _a.subscribe) === 'function', auth, "invalid-cordova-configuration" , {
|
228 | missingPlugin: 'cordova-universal-links-plugin-fix'
|
229 | });
|
230 |
|
231 | _assert(typeof ((_b = win === null || win === void 0 ? void 0 : win.BuildInfo) === null || _b === void 0 ? void 0 : _b.packageName) !== 'undefined', auth, "invalid-cordova-configuration" , {
|
232 | missingPlugin: 'cordova-plugin-buildInfo'
|
233 | });
|
234 |
|
235 | _assert(typeof ((_e = (_d = (_c = win === null || win === void 0 ? void 0 : win.cordova) === null || _c === void 0 ? void 0 : _c.plugins) === null || _d === void 0 ? void 0 : _d.browsertab) === null || _e === void 0 ? void 0 : _e.openUrl) === 'function', auth, "invalid-cordova-configuration" , {
|
236 | missingPlugin: 'cordova-plugin-browsertab'
|
237 | });
|
238 | _assert(typeof ((_h = (_g = (_f = win === null || win === void 0 ? void 0 : win.cordova) === null || _f === void 0 ? void 0 : _f.plugins) === null || _g === void 0 ? void 0 : _g.browsertab) === null || _h === void 0 ? void 0 : _h.isAvailable) === 'function', auth, "invalid-cordova-configuration" , {
|
239 | missingPlugin: 'cordova-plugin-browsertab'
|
240 | });
|
241 |
|
242 | _assert(typeof ((_k = (_j = win === null || win === void 0 ? void 0 : win.cordova) === null || _j === void 0 ? void 0 : _j.InAppBrowser) === null || _k === void 0 ? void 0 : _k.open) === 'function', auth, "invalid-cordova-configuration" , {
|
243 | missingPlugin: 'cordova-plugin-inappbrowser'
|
244 | });
|
245 | }
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 | function computeSha256(sessionId) {
|
252 | return __awaiter(this, void 0, void 0, function () {
|
253 | var bytes, buf, arr;
|
254 | return __generator(this, function (_a) {
|
255 | switch (_a.label) {
|
256 | case 0:
|
257 | bytes = stringToArrayBuffer(sessionId);
|
258 | return [4 , crypto.subtle.digest('SHA-256', bytes)];
|
259 | case 1:
|
260 | buf = _a.sent();
|
261 | arr = Array.from(new Uint8Array(buf));
|
262 | return [2 , arr.map(function (num) { return num.toString(16).padStart(2, '0'); }).join('')];
|
263 | }
|
264 | });
|
265 | });
|
266 | }
|
267 | function stringToArrayBuffer(str) {
|
268 |
|
269 |
|
270 | debugAssert(/[0-9a-zA-Z]+/.test(str), 'Can only convert alpha-numeric strings');
|
271 | if (typeof TextEncoder !== 'undefined') {
|
272 | return new TextEncoder().encode(str);
|
273 | }
|
274 | var buff = new ArrayBuffer(str.length);
|
275 | var view = new Uint8Array(buff);
|
276 | for (var i = 0; i < str.length; i++) {
|
277 | view[i] = str.charCodeAt(i);
|
278 | }
|
279 | return view;
|
280 | }
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 | var SESSION_ID_LENGTH = 20;
|
299 |
|
300 | var CordovaAuthEventManager = (function (_super) {
|
301 | __extends(CordovaAuthEventManager, _super);
|
302 | function CordovaAuthEventManager() {
|
303 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
304 | _this.passiveListeners = new Set();
|
305 | _this.initPromise = new Promise(function (resolve) {
|
306 | _this.resolveInialized = resolve;
|
307 | });
|
308 | return _this;
|
309 | }
|
310 | CordovaAuthEventManager.prototype.addPassiveListener = function (cb) {
|
311 | this.passiveListeners.add(cb);
|
312 | };
|
313 | CordovaAuthEventManager.prototype.removePassiveListener = function (cb) {
|
314 | this.passiveListeners.delete(cb);
|
315 | };
|
316 |
|
317 |
|
318 | CordovaAuthEventManager.prototype.resetRedirect = function () {
|
319 | this.queuedRedirectEvent = null;
|
320 | this.hasHandledPotentialRedirect = false;
|
321 | };
|
322 |
|
323 | CordovaAuthEventManager.prototype.onEvent = function (event) {
|
324 | this.resolveInialized();
|
325 | this.passiveListeners.forEach(function (cb) { return cb(event); });
|
326 | return _super.prototype.onEvent.call(this, event);
|
327 | };
|
328 | CordovaAuthEventManager.prototype.initialized = function () {
|
329 | return __awaiter(this, void 0, void 0, function () {
|
330 | return __generator(this, function (_a) {
|
331 | switch (_a.label) {
|
332 | case 0: return [4 , this.initPromise];
|
333 | case 1:
|
334 | _a.sent();
|
335 | return [2 ];
|
336 | }
|
337 | });
|
338 | });
|
339 | };
|
340 | return CordovaAuthEventManager;
|
341 | }(AuthEventManager));
|
342 |
|
343 |
|
344 |
|
345 | function _generateNewEvent(auth, type, eventId) {
|
346 | if (eventId === void 0) { eventId = null; }
|
347 | return {
|
348 | type: type,
|
349 | eventId: eventId,
|
350 | urlResponse: null,
|
351 | sessionId: generateSessionId(),
|
352 | postBody: null,
|
353 | tenantId: auth.tenantId,
|
354 | error: _createError(auth, "no-auth-event" )
|
355 | };
|
356 | }
|
357 | function _savePartialEvent(auth, event) {
|
358 | return storage()._set(persistenceKey(auth), event);
|
359 | }
|
360 | function _getAndRemoveEvent(auth) {
|
361 | return __awaiter(this, void 0, void 0, function () {
|
362 | var event;
|
363 | return __generator(this, function (_a) {
|
364 | switch (_a.label) {
|
365 | case 0: return [4 , storage()._get(persistenceKey(auth))];
|
366 | case 1:
|
367 | event = (_a.sent());
|
368 | if (!event) return [3 , 3];
|
369 | return [4 , storage()._remove(persistenceKey(auth))];
|
370 | case 2:
|
371 | _a.sent();
|
372 | _a.label = 3;
|
373 | case 3: return [2 , event];
|
374 | }
|
375 | });
|
376 | });
|
377 | }
|
378 | function _eventFromPartialAndUrl(partialEvent, url) {
|
379 | var _a, _b;
|
380 |
|
381 | var callbackUrl = _getDeepLinkFromCallback(url);
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 | if (callbackUrl.includes('/__/auth/callback')) {
|
388 |
|
389 |
|
390 |
|
391 | var params = searchParamsOrEmpty(callbackUrl);
|
392 |
|
393 | var errorObject = params['firebaseError']
|
394 | ? parseJsonOrNull(decodeURIComponent(params['firebaseError']))
|
395 | : null;
|
396 | var code = (_b = (_a = errorObject === null || errorObject === void 0 ? void 0 : errorObject['code']) === null || _a === void 0 ? void 0 : _a.split('auth/')) === null || _b === void 0 ? void 0 : _b[1];
|
397 | var error = code ? _createError(code) : null;
|
398 | if (error) {
|
399 | return {
|
400 | type: partialEvent.type,
|
401 | eventId: partialEvent.eventId,
|
402 | tenantId: partialEvent.tenantId,
|
403 | error: error,
|
404 | urlResponse: null,
|
405 | sessionId: null,
|
406 | postBody: null
|
407 | };
|
408 | }
|
409 | else {
|
410 | return {
|
411 | type: partialEvent.type,
|
412 | eventId: partialEvent.eventId,
|
413 | tenantId: partialEvent.tenantId,
|
414 | sessionId: partialEvent.sessionId,
|
415 | urlResponse: callbackUrl,
|
416 | postBody: null
|
417 | };
|
418 | }
|
419 | }
|
420 | return null;
|
421 | }
|
422 | function generateSessionId() {
|
423 | var chars = [];
|
424 | var allowedChars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
425 | for (var i = 0; i < SESSION_ID_LENGTH; i++) {
|
426 | var idx = Math.floor(Math.random() * allowedChars.length);
|
427 | chars.push(allowedChars.charAt(idx));
|
428 | }
|
429 | return chars.join('');
|
430 | }
|
431 | function storage() {
|
432 | return _getInstance(browserLocalPersistence);
|
433 | }
|
434 | function persistenceKey(auth) {
|
435 | return _persistenceKeyName("authEvent" , auth.config.apiKey, auth.name);
|
436 | }
|
437 | function parseJsonOrNull(json) {
|
438 | try {
|
439 | return JSON.parse(json);
|
440 | }
|
441 | catch (e) {
|
442 | return null;
|
443 | }
|
444 | }
|
445 |
|
446 | function _getDeepLinkFromCallback(url) {
|
447 | var params = searchParamsOrEmpty(url);
|
448 | var link = params['link'] ? decodeURIComponent(params['link']) : undefined;
|
449 |
|
450 | var doubleDeepLink = searchParamsOrEmpty(link)['link'];
|
451 |
|
452 | var iOSDeepLink = params['deep_link_id']
|
453 | ? decodeURIComponent(params['deep_link_id'])
|
454 | : undefined;
|
455 | var iOSDoubleDeepLink = searchParamsOrEmpty(iOSDeepLink)['link'];
|
456 | return iOSDoubleDeepLink || iOSDeepLink || doubleDeepLink || link || url;
|
457 | }
|
458 |
|
459 |
|
460 |
|
461 |
|
462 | function searchParamsOrEmpty(url) {
|
463 | if (!(url === null || url === void 0 ? void 0 : url.includes('?'))) {
|
464 | return {};
|
465 | }
|
466 | var _a = url.split('?'); _a[0]; var rest = _a.slice(1);
|
467 | return querystringDecode(rest.join('?'));
|
468 | }
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 | var INITIAL_EVENT_TIMEOUT_MS = 500;
|
491 | var CordovaPopupRedirectResolver = (function () {
|
492 | function CordovaPopupRedirectResolver() {
|
493 | this._redirectPersistence = browserSessionPersistence;
|
494 | this._shouldInitProactively = true;
|
495 | this.eventManagers = new Map();
|
496 | this.originValidationPromises = {};
|
497 | this._completeRedirectFn = _getRedirectResult;
|
498 | this._overrideRedirectResult = _overrideRedirectResult;
|
499 | }
|
500 | CordovaPopupRedirectResolver.prototype._initialize = function (auth) {
|
501 | return __awaiter(this, void 0, void 0, function () {
|
502 | var key, manager;
|
503 | return __generator(this, function (_a) {
|
504 | key = auth._key();
|
505 | manager = this.eventManagers.get(key);
|
506 | if (!manager) {
|
507 | manager = new CordovaAuthEventManager(auth);
|
508 | this.eventManagers.set(key, manager);
|
509 | this.attachCallbackListeners(auth, manager);
|
510 | }
|
511 | return [2 , manager];
|
512 | });
|
513 | });
|
514 | };
|
515 | CordovaPopupRedirectResolver.prototype._openPopup = function (auth) {
|
516 | _fail(auth, "operation-not-supported-in-this-environment" );
|
517 | };
|
518 | CordovaPopupRedirectResolver.prototype._openRedirect = function (auth, provider, authType, eventId) {
|
519 | return __awaiter(this, void 0, void 0, function () {
|
520 | var manager, event, url, iabRef;
|
521 | return __generator(this, function (_a) {
|
522 | switch (_a.label) {
|
523 | case 0:
|
524 | _checkCordovaConfiguration(auth);
|
525 | return [4 , this._initialize(auth)];
|
526 | case 1:
|
527 | manager = _a.sent();
|
528 | return [4 , manager.initialized()];
|
529 | case 2:
|
530 | _a.sent();
|
531 |
|
532 |
|
533 |
|
534 | manager.resetRedirect();
|
535 | _clearRedirectOutcomes();
|
536 | return [4 , this._originValidation(auth)];
|
537 | case 3:
|
538 | _a.sent();
|
539 | event = _generateNewEvent(auth, authType, eventId);
|
540 | return [4 , _savePartialEvent(auth, event)];
|
541 | case 4:
|
542 | _a.sent();
|
543 | return [4 , _generateHandlerUrl(auth, event, provider)];
|
544 | case 5:
|
545 | url = _a.sent();
|
546 | return [4 , _performRedirect(url)];
|
547 | case 6:
|
548 | iabRef = _a.sent();
|
549 | return [2 , _waitForAppResume(auth, manager, iabRef)];
|
550 | }
|
551 | });
|
552 | });
|
553 | };
|
554 | CordovaPopupRedirectResolver.prototype._isIframeWebStorageSupported = function (_auth, _cb) {
|
555 | throw new Error('Method not implemented.');
|
556 | };
|
557 | CordovaPopupRedirectResolver.prototype._originValidation = function (auth) {
|
558 | var key = auth._key();
|
559 | if (!this.originValidationPromises[key]) {
|
560 | this.originValidationPromises[key] = _validateOrigin(auth);
|
561 | }
|
562 | return this.originValidationPromises[key];
|
563 | };
|
564 | CordovaPopupRedirectResolver.prototype.attachCallbackListeners = function (auth, manager) {
|
565 | var _this = this;
|
566 |
|
567 | var _a = _cordovaWindow(), universalLinks = _a.universalLinks, handleOpenURL = _a.handleOpenURL, BuildInfo = _a.BuildInfo;
|
568 | var noEventTimeout = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
569 | return __generator(this, function (_a) {
|
570 | switch (_a.label) {
|
571 | case 0:
|
572 |
|
573 |
|
574 | return [4 , _getAndRemoveEvent(auth)];
|
575 | case 1:
|
576 |
|
577 |
|
578 | _a.sent();
|
579 | manager.onEvent(generateNoEvent());
|
580 | return [2 ];
|
581 | }
|
582 | });
|
583 | }); }, INITIAL_EVENT_TIMEOUT_MS);
|
584 | var universalLinksCb = function (eventData) { return __awaiter(_this, void 0, void 0, function () {
|
585 | var partialEvent, finalEvent;
|
586 | return __generator(this, function (_a) {
|
587 | switch (_a.label) {
|
588 | case 0:
|
589 |
|
590 | clearTimeout(noEventTimeout);
|
591 | return [4 , _getAndRemoveEvent(auth)];
|
592 | case 1:
|
593 | partialEvent = _a.sent();
|
594 | finalEvent = null;
|
595 | if (partialEvent && (eventData === null || eventData === void 0 ? void 0 : eventData['url'])) {
|
596 | finalEvent = _eventFromPartialAndUrl(partialEvent, eventData['url']);
|
597 | }
|
598 |
|
599 | manager.onEvent(finalEvent || generateNoEvent());
|
600 | return [2 ];
|
601 | }
|
602 | });
|
603 | }); };
|
604 |
|
605 | if (typeof universalLinks !== 'undefined' &&
|
606 | typeof universalLinks.subscribe === 'function') {
|
607 | universalLinks.subscribe(null, universalLinksCb);
|
608 | }
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 | var existingHandleOpenURL = handleOpenURL;
|
615 | var packagePrefix = BuildInfo.packageName.toLowerCase() + "://";
|
616 | _cordovaWindow().handleOpenURL = function (url) { return __awaiter(_this, void 0, void 0, function () {
|
617 | return __generator(this, function (_a) {
|
618 | if (url.toLowerCase().startsWith(packagePrefix)) {
|
619 |
|
620 |
|
621 | universalLinksCb({ url: url });
|
622 | }
|
623 |
|
624 | if (typeof existingHandleOpenURL === 'function') {
|
625 | try {
|
626 | existingHandleOpenURL(url);
|
627 | }
|
628 | catch (e) {
|
629 |
|
630 | console.error(e);
|
631 | }
|
632 | }
|
633 | return [2 ];
|
634 | });
|
635 | }); };
|
636 | };
|
637 | return CordovaPopupRedirectResolver;
|
638 | }());
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 | var cordovaPopupRedirectResolver = CordovaPopupRedirectResolver;
|
646 | function generateNoEvent() {
|
647 | return {
|
648 | type: "unknown" ,
|
649 | eventId: null,
|
650 | sessionId: null,
|
651 | urlResponse: null,
|
652 | postBody: null,
|
653 | tenantId: null,
|
654 | error: _createError("no-auth-event" )
|
655 | };
|
656 | }
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 | function addFrameworkForLogging(auth, framework) {
|
678 | _castAuth(auth)._logFramework(framework);
|
679 | }
|
680 |
|
681 | export { addFrameworkForLogging, cordovaPopupRedirectResolver };
|
682 |
|