@dynamic-labs/utils 5.0.0-rc.0 → 5.0.0-rc.3
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/CHANGELOG.md +76 -1
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +5 -5
- package/src/errors/WalletRequiresInAppBrowserError.cjs +24 -0
- package/src/errors/WalletRequiresInAppBrowserError.d.ts +14 -0
- package/src/errors/WalletRequiresInAppBrowserError.js +20 -0
- package/src/errors/index.d.ts +1 -0
- package/src/index.cjs +2 -0
- package/src/index.js +1 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.cjs +22 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.js +22 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,80 @@
|
|
|
1
1
|
|
|
2
|
-
## [5.0.0-rc.
|
|
2
|
+
## [5.0.0-rc.3](https://github.com/dynamic-labs/dynamic-auth/compare/v5.0.0-rc.2...v5.0.0-rc.3) (2026-07-17)
|
|
3
|
+
|
|
4
|
+
## [5.0.0-rc.2](https://github.com/dynamic-labs/dynamic-auth/compare/v5.0.0-rc.1...v5.0.0-rc.2) (2026-07-17)
|
|
5
|
+
|
|
6
|
+
## [5.0.0-rc.1](https://github.com/dynamic-labs/dynamic-auth/compare/v5.0.0-rc.0...v5.0.0-rc.1) (2026-07-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* move legacy embedded wallet to waas upgrade flow to new legacy-embedded-wallet-migration package (#11841)
|
|
12
|
+
* drop default injection of legacy embedded wallet connectors (#11833)
|
|
13
|
+
* remove legacy embedded wallet support (#11979)
|
|
14
|
+
* throw when legacy embedded wallet is detected without migration provider (#11855)
|
|
15
|
+
* remove deprecated eclipse package (#11831)
|
|
16
|
+
* remove deprecated functions and props (#11832)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### [4.92.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.92.3...v4.92.4) (2026-07-16)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **bitcoin:** per-network address switching and dust-limit send validation [v4] ([#11970](https://github.com/dynamic-labs/dynamic-auth/issues/11970)) ([76a4a9a](https://github.com/dynamic-labs/dynamic-auth/commit/76a4a9a5025d78798ebd1beffe6c0af59d2d029a)), closes [#11896](https://github.com/dynamic-labs/dynamic-auth/issues/11896) [#11800](https://github.com/dynamic-labs/dynamic-auth/issues/11800)
|
|
25
|
+
* **midnight:** per-network addresses in deposit and wallet info views [v4] ([#11949](https://github.com/dynamic-labs/dynamic-auth/issues/11949)) ([978446a](https://github.com/dynamic-labs/dynamic-auth/commit/978446aca8546eb038ba9ed3be0503d10594ee15))
|
|
26
|
+
* **midnight:** resolve wallet address per selected network [v4] ([#11948](https://github.com/dynamic-labs/dynamic-auth/issues/11948)) ([d6f858c](https://github.com/dynamic-labs/dynamic-auth/commit/d6f858c5e35defda7ed73cf97b3fdbe5ed9d131d))
|
|
27
|
+
* set useMetamaskSdk to true by default ([#11926](https://github.com/dynamic-labs/dynamic-auth/issues/11926)) ([75b5a4a](https://github.com/dynamic-labs/dynamic-auth/commit/75b5a4a0fe8b1a375afce145c0b8bdc3ce761117))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* **midnight:** align per-network code with the final main iteration [v4] ([#11971](https://github.com/dynamic-labs/dynamic-auth/issues/11971)) ([3ef3ba8](https://github.com/dynamic-labs/dynamic-auth/commit/3ef3ba8c090dfd9e4286b4e51bf350ea5e6feac7))
|
|
33
|
+
* settle social sign-in when captcha is backed out or oauth popup never responds (v4) ([#11956](https://github.com/dynamic-labs/dynamic-auth/issues/11956)) ([ad49477](https://github.com/dynamic-labs/dynamic-auth/commit/ad49477f2acf61a154bb79cbe26b24f803cdb0e2))
|
|
34
|
+
* validate that private key is not empty before upgrading to WaaS ([#11952](https://github.com/dynamic-labs/dynamic-auth/issues/11952)) ([21dfb83](https://github.com/dynamic-labs/dynamic-auth/commit/21dfb83cb29e42b335bc94a0cdd2062cf14a262a))
|
|
35
|
+
|
|
36
|
+
### [4.92.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.92.2...v4.92.3) (2026-07-10)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### Bug Fixes
|
|
40
|
+
|
|
41
|
+
* **sdk-react-core:** fix deterministic 'Wallet not found' crash in embedded wallet export (v4) ([#11906](https://github.com/dynamic-labs/dynamic-auth/issues/11906)) ([913ef23](https://github.com/dynamic-labs/dynamic-auth/commit/913ef236b26245488e1cd5db7e874601b65ff0a2)), closes [#11905](https://github.com/dynamic-labs/dynamic-auth/issues/11905) [#11729](https://github.com/dynamic-labs/dynamic-auth/issues/11729)
|
|
42
|
+
|
|
43
|
+
### [4.92.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.92.1...v4.92.2) (2026-07-09)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
|
|
48
|
+
* engage captcha during step-up OTP re-auth ([#11879](https://github.com/dynamic-labs/dynamic-auth/issues/11879)) ([585460a](https://github.com/dynamic-labs/dynamic-auth/commit/585460a8976803a8ed0aad16a4a00047bd6c115a))
|
|
49
|
+
* **waas:** gate v1 wallet upgrade on recovery for email-only wallets ([#11897](https://github.com/dynamic-labs/dynamic-auth/issues/11897)) ([5a6f0c6](https://github.com/dynamic-labs/dynamic-auth/commit/5a6f0c6bf3120e59cf502004d09fae56f193e977))
|
|
50
|
+
|
|
51
|
+
### [4.92.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.92.0...v4.92.1) (2026-07-09)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
### Bug Fixes
|
|
55
|
+
|
|
56
|
+
* **ethereum:** fire in-app-browser redirect on sign for injected EVM wallets that use in-app-browser experience ([#11888](https://github.com/dynamic-labs/dynamic-auth/issues/11888)) ([5116d91](https://github.com/dynamic-labs/dynamic-auth/commit/5116d91ab2c71000a490d72c5d278549d4d8ae9a))
|
|
57
|
+
* **sdk-react-core:** show clear message for Phantom redirect signing failures (v4 backport) ([#11886](https://github.com/dynamic-labs/dynamic-auth/issues/11886)) ([60ac897](https://github.com/dynamic-labs/dynamic-auth/commit/60ac897ba81f7758ccd7a05f97b619785e1f50a7))
|
|
58
|
+
* **social:** use redirect strategy for step-up OAuth on mobile [V4 backport] ([#11881](https://github.com/dynamic-labs/dynamic-auth/issues/11881)) ([42a202e](https://github.com/dynamic-labs/dynamic-auth/commit/42a202e6255de8db73df02eff37c0b10b24fef1a))
|
|
59
|
+
* **solana:** fire in-app-browser redirect on sign and wallet switch ([#11871](https://github.com/dynamic-labs/dynamic-auth/issues/11871)) ([4e2d6b7](https://github.com/dynamic-labs/dynamic-auth/commit/4e2d6b7ac8fdef5bf7c62b8a726ecaef1c6210ec))
|
|
60
|
+
* **solana:** resolve Phantom/Backpack provider collision and Backpack >=0.10.x connect hangs ([#11856](https://github.com/dynamic-labs/dynamic-auth/issues/11856)) ([#11882](https://github.com/dynamic-labs/dynamic-auth/issues/11882)) ([5784aff](https://github.com/dynamic-labs/dynamic-auth/commit/5784aff9641bbc85445fb466f3ab1d6a14331e73))
|
|
61
|
+
|
|
62
|
+
## [4.92.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.6...v4.92.0) (2026-07-08)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Features
|
|
66
|
+
|
|
67
|
+
* **captcha:** add Cloudflare Turnstile provider support alongside hCaptcha (v4) ([#11798](https://github.com/dynamic-labs/dynamic-auth/issues/11798)) ([114c770](https://github.com/dynamic-labs/dynamic-auth/commit/114c7702e900d8dedeebe7be867de35d11a93f31))
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Bug Fixes
|
|
71
|
+
|
|
72
|
+
* **ethereum-aa:** resolve kernel client config per wallet (v4) ([#11870](https://github.com/dynamic-labs/dynamic-auth/issues/11870)) ([1b66d79](https://github.com/dynamic-labs/dynamic-auth/commit/1b66d79b4a32b4b6de433b7536bc46e6719224c6))
|
|
73
|
+
* **iframe-setup:** block dangerous URL schemes and verify sender in OPEN_URL ([#11819](https://github.com/dynamic-labs/dynamic-auth/issues/11819)) ([329b27e](https://github.com/dynamic-labs/dynamic-auth/commit/329b27e9fac825916ab227ec8cf93dc343898923))
|
|
74
|
+
* improve social OAuth error messages ([#11837](https://github.com/dynamic-labs/dynamic-auth/issues/11837)) ([8e57c06](https://github.com/dynamic-labs/dynamic-auth/commit/8e57c067c5a89111a32a12fb82e190cf6c46ad67))
|
|
75
|
+
* **react-native-extension:** reject path traversal in downloadFile fileName ([#11816](https://github.com/dynamic-labs/dynamic-auth/issues/11816)) ([9367a56](https://github.com/dynamic-labs/dynamic-auth/commit/9367a56b6daa853d7f7e7f5534261bc68825b239))
|
|
76
|
+
* **sdk-react-core:** display exactly the bytes signed in personal_sign preview ([#11818](https://github.com/dynamic-labs/dynamic-auth/issues/11818)) ([30b9382](https://github.com/dynamic-labs/dynamic-auth/commit/30b93829122f00060cb484aef09a03294c03f651))
|
|
77
|
+
|
|
3
78
|
|
|
4
79
|
### [4.91.6](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.5...v4.91.6) (2026-07-03)
|
|
5
80
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/utils",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.3",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
21
|
+
"@dynamic-labs/sdk-api-core": "0.0.1082",
|
|
22
22
|
"tldts": "6.0.16",
|
|
23
|
-
"@dynamic-labs/assert-package-version": "5.0.0-rc.
|
|
24
|
-
"@dynamic-labs/logger": "5.0.0-rc.
|
|
25
|
-
"@dynamic-labs/types": "5.0.0-rc.
|
|
23
|
+
"@dynamic-labs/assert-package-version": "5.0.0-rc.3",
|
|
24
|
+
"@dynamic-labs/logger": "5.0.0-rc.3",
|
|
25
|
+
"@dynamic-labs/types": "5.0.0-rc.3",
|
|
26
26
|
"buffer": "6.0.3",
|
|
27
27
|
"eventemitter3": "5.0.1"
|
|
28
28
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var CustomError = require('./CustomError.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Error thrown when a wallet action (e.g. signing) requires the wallet's
|
|
10
|
+
* in-app browser but there is no injected provider available and no way to
|
|
11
|
+
* redirect the user into it.
|
|
12
|
+
*
|
|
13
|
+
* This typically happens on mobile web when an in-app-browser wallet
|
|
14
|
+
* (Phantom, Backpack, Solflare, MetaMask, ...) has been made primary but the
|
|
15
|
+
* user is not inside the wallet's in-app browser, so no provider can be
|
|
16
|
+
* reached to sign.
|
|
17
|
+
*/
|
|
18
|
+
class WalletRequiresInAppBrowserError extends CustomError.CustomError {
|
|
19
|
+
constructor(walletName) {
|
|
20
|
+
super(`${walletName} requires its in-app browser to sign. Open this site inside the ${walletName} app's browser and try again.`, 'wallet_requires_in_app_browser');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.WalletRequiresInAppBrowserError = WalletRequiresInAppBrowserError;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CustomError } from './CustomError';
|
|
2
|
+
/**
|
|
3
|
+
* Error thrown when a wallet action (e.g. signing) requires the wallet's
|
|
4
|
+
* in-app browser but there is no injected provider available and no way to
|
|
5
|
+
* redirect the user into it.
|
|
6
|
+
*
|
|
7
|
+
* This typically happens on mobile web when an in-app-browser wallet
|
|
8
|
+
* (Phantom, Backpack, Solflare, MetaMask, ...) has been made primary but the
|
|
9
|
+
* user is not inside the wallet's in-app browser, so no provider can be
|
|
10
|
+
* reached to sign.
|
|
11
|
+
*/
|
|
12
|
+
export declare class WalletRequiresInAppBrowserError extends CustomError {
|
|
13
|
+
constructor(walletName: string);
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { CustomError } from './CustomError.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Error thrown when a wallet action (e.g. signing) requires the wallet's
|
|
6
|
+
* in-app browser but there is no injected provider available and no way to
|
|
7
|
+
* redirect the user into it.
|
|
8
|
+
*
|
|
9
|
+
* This typically happens on mobile web when an in-app-browser wallet
|
|
10
|
+
* (Phantom, Backpack, Solflare, MetaMask, ...) has been made primary but the
|
|
11
|
+
* user is not inside the wallet's in-app browser, so no provider can be
|
|
12
|
+
* reached to sign.
|
|
13
|
+
*/
|
|
14
|
+
class WalletRequiresInAppBrowserError extends CustomError {
|
|
15
|
+
constructor(walletName) {
|
|
16
|
+
super(`${walletName} requires its in-app browser to sign. Open this site inside the ${walletName} app's browser and try again.`, 'wallet_requires_in_app_browser');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { WalletRequiresInAppBrowserError };
|
package/src/errors/index.d.ts
CHANGED
|
@@ -47,4 +47,5 @@ export * from './VerificationDataCollectionError';
|
|
|
47
47
|
export * from './WaasAuthScopePendingError';
|
|
48
48
|
export * from './WalletAddressMismatchError';
|
|
49
49
|
export * from './WalletNotDeployedError';
|
|
50
|
+
export * from './WalletRequiresInAppBrowserError';
|
|
50
51
|
export * from './WalletUsedError';
|
package/src/index.cjs
CHANGED
|
@@ -58,6 +58,7 @@ var VerificationDataCollectionError = require('./errors/VerificationDataCollecti
|
|
|
58
58
|
var WaasAuthScopePendingError = require('./errors/WaasAuthScopePendingError.cjs');
|
|
59
59
|
var WalletAddressMismatchError = require('./errors/WalletAddressMismatchError.cjs');
|
|
60
60
|
var WalletNotDeployedError = require('./errors/WalletNotDeployedError.cjs');
|
|
61
|
+
var WalletRequiresInAppBrowserError = require('./errors/WalletRequiresInAppBrowserError.cjs');
|
|
61
62
|
var WalletUsedError = require('./errors/WalletUsedError.cjs');
|
|
62
63
|
var eventTimeline = require('./eventTimeline/eventTimeline.cjs');
|
|
63
64
|
var formatNumberText = require('./formatNumberText/formatNumberText.cjs');
|
|
@@ -186,6 +187,7 @@ exports.WAAS_AUTH_SCOPE_PENDING_CODE = WaasAuthScopePendingError.WAAS_AUTH_SCOPE
|
|
|
186
187
|
exports.WaasAuthScopePendingError = WaasAuthScopePendingError.WaasAuthScopePendingError;
|
|
187
188
|
exports.WalletAddressMismatchError = WalletAddressMismatchError.WalletAddressMismatchError;
|
|
188
189
|
exports.WalletNotDeployedError = WalletNotDeployedError.WalletNotDeployedError;
|
|
190
|
+
exports.WalletRequiresInAppBrowserError = WalletRequiresInAppBrowserError.WalletRequiresInAppBrowserError;
|
|
189
191
|
exports.WalletUsedError = WalletUsedError.WalletUsedError;
|
|
190
192
|
exports.createEventTimeline = eventTimeline.createEventTimeline;
|
|
191
193
|
exports.formatNumberText = formatNumberText.formatNumberText;
|
package/src/index.js
CHANGED
|
@@ -54,6 +54,7 @@ export { VerificationDataCollectionError } from './errors/VerificationDataCollec
|
|
|
54
54
|
export { WAAS_AUTH_SCOPE_PENDING_CODE, WaasAuthScopePendingError } from './errors/WaasAuthScopePendingError.js';
|
|
55
55
|
export { WalletAddressMismatchError } from './errors/WalletAddressMismatchError.js';
|
|
56
56
|
export { WalletNotDeployedError } from './errors/WalletNotDeployedError.js';
|
|
57
|
+
export { WalletRequiresInAppBrowserError } from './errors/WalletRequiresInAppBrowserError.js';
|
|
57
58
|
export { WalletUsedError } from './errors/WalletUsedError.js';
|
|
58
59
|
export { createEventTimeline } from './eventTimeline/eventTimeline.js';
|
|
59
60
|
export { formatNumberText } from './formatNumberText/formatNumberText.js';
|
|
@@ -12,6 +12,12 @@ var PlatformService = require('../../PlatformService/PlatformService.cjs');
|
|
|
12
12
|
require('tldts');
|
|
13
13
|
|
|
14
14
|
let authWindowInterval;
|
|
15
|
+
let authWindowTimeout;
|
|
16
|
+
// The backend caches the oauth init state for 5 minutes; past that the
|
|
17
|
+
// redirect can never complete, so if the popup still hasn't posted a result
|
|
18
|
+
// back by then (eg it landed on an error page and just sits there), settle
|
|
19
|
+
// the promise instead of leaving the pending view up forever.
|
|
20
|
+
const OAUTH_COMPLETION_TIMEOUT_MS = 6 * 60 * 1000;
|
|
15
21
|
const createWindowOauth2Service = () => ({
|
|
16
22
|
getOauthCode: ({ apiProvider, provider, redirectUrl, setIsProcessing, state, oauthLoginUrl, initWebAuth, strategy, }) => new Promise((resolve, _reject) => {
|
|
17
23
|
/**
|
|
@@ -46,6 +52,7 @@ const createWindowOauth2Service = () => ({
|
|
|
46
52
|
const typedReject = (params) => _reject(params);
|
|
47
53
|
// Clear any potential pending timeouts and intervals
|
|
48
54
|
clearInterval(authWindowInterval);
|
|
55
|
+
clearTimeout(authWindowTimeout);
|
|
49
56
|
const providersWaitingOauthMessage = {};
|
|
50
57
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
51
58
|
if (authWindow === null || typeof authWindow === 'undefined') {
|
|
@@ -58,6 +65,7 @@ const createWindowOauth2Service = () => ({
|
|
|
58
65
|
}
|
|
59
66
|
const clearListeners = () => {
|
|
60
67
|
window.removeEventListener('message', handleWindowMessage);
|
|
68
|
+
clearTimeout(authWindowTimeout);
|
|
61
69
|
providersWaitingOauthMessage[provider] = false;
|
|
62
70
|
};
|
|
63
71
|
const handleWindowMessage = (event) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -170,10 +178,24 @@ const createWindowOauth2Service = () => ({
|
|
|
170
178
|
// First we store the state in backend
|
|
171
179
|
initWebAuth().then(() => {
|
|
172
180
|
authWindow === null || authWindow === void 0 ? void 0 : authWindow.location.assign(oauthLoginUrl);
|
|
181
|
+
authWindowTimeout = setTimeout(() => {
|
|
182
|
+
clearInterval(authWindowInterval);
|
|
183
|
+
setIsProcessing(false);
|
|
184
|
+
// already resolved or rejected through another path
|
|
185
|
+
if (!providersWaitingOauthMessage[provider])
|
|
186
|
+
return;
|
|
187
|
+
clearListeners();
|
|
188
|
+
authWindow === null || authWindow === void 0 ? void 0 : authWindow.close();
|
|
189
|
+
typedReject({
|
|
190
|
+
code: types.SocialOAuthErrorCode.SESSION_TIMEOUT,
|
|
191
|
+
message: `Connecting ${provider} account timed out. Please try again.`,
|
|
192
|
+
});
|
|
193
|
+
}, OAUTH_COMPLETION_TIMEOUT_MS);
|
|
173
194
|
authWindowInterval = setInterval(() => {
|
|
174
195
|
if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed))
|
|
175
196
|
return;
|
|
176
197
|
clearInterval(authWindowInterval);
|
|
198
|
+
clearTimeout(authWindowTimeout);
|
|
177
199
|
setIsProcessing(false);
|
|
178
200
|
// user didn't complete oauth
|
|
179
201
|
if (providersWaitingOauthMessage[provider])
|
|
@@ -8,6 +8,12 @@ import { PlatformService } from '../../PlatformService/PlatformService.js';
|
|
|
8
8
|
import 'tldts';
|
|
9
9
|
|
|
10
10
|
let authWindowInterval;
|
|
11
|
+
let authWindowTimeout;
|
|
12
|
+
// The backend caches the oauth init state for 5 minutes; past that the
|
|
13
|
+
// redirect can never complete, so if the popup still hasn't posted a result
|
|
14
|
+
// back by then (eg it landed on an error page and just sits there), settle
|
|
15
|
+
// the promise instead of leaving the pending view up forever.
|
|
16
|
+
const OAUTH_COMPLETION_TIMEOUT_MS = 6 * 60 * 1000;
|
|
11
17
|
const createWindowOauth2Service = () => ({
|
|
12
18
|
getOauthCode: ({ apiProvider, provider, redirectUrl, setIsProcessing, state, oauthLoginUrl, initWebAuth, strategy, }) => new Promise((resolve, _reject) => {
|
|
13
19
|
/**
|
|
@@ -42,6 +48,7 @@ const createWindowOauth2Service = () => ({
|
|
|
42
48
|
const typedReject = (params) => _reject(params);
|
|
43
49
|
// Clear any potential pending timeouts and intervals
|
|
44
50
|
clearInterval(authWindowInterval);
|
|
51
|
+
clearTimeout(authWindowTimeout);
|
|
45
52
|
const providersWaitingOauthMessage = {};
|
|
46
53
|
const authWindow = window.open('', '_blank', 'width=500,height=600');
|
|
47
54
|
if (authWindow === null || typeof authWindow === 'undefined') {
|
|
@@ -54,6 +61,7 @@ const createWindowOauth2Service = () => ({
|
|
|
54
61
|
}
|
|
55
62
|
const clearListeners = () => {
|
|
56
63
|
window.removeEventListener('message', handleWindowMessage);
|
|
64
|
+
clearTimeout(authWindowTimeout);
|
|
57
65
|
providersWaitingOauthMessage[provider] = false;
|
|
58
66
|
};
|
|
59
67
|
const handleWindowMessage = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -166,10 +174,24 @@ const createWindowOauth2Service = () => ({
|
|
|
166
174
|
// First we store the state in backend
|
|
167
175
|
initWebAuth().then(() => {
|
|
168
176
|
authWindow === null || authWindow === void 0 ? void 0 : authWindow.location.assign(oauthLoginUrl);
|
|
177
|
+
authWindowTimeout = setTimeout(() => {
|
|
178
|
+
clearInterval(authWindowInterval);
|
|
179
|
+
setIsProcessing(false);
|
|
180
|
+
// already resolved or rejected through another path
|
|
181
|
+
if (!providersWaitingOauthMessage[provider])
|
|
182
|
+
return;
|
|
183
|
+
clearListeners();
|
|
184
|
+
authWindow === null || authWindow === void 0 ? void 0 : authWindow.close();
|
|
185
|
+
typedReject({
|
|
186
|
+
code: SocialOAuthErrorCode.SESSION_TIMEOUT,
|
|
187
|
+
message: `Connecting ${provider} account timed out. Please try again.`,
|
|
188
|
+
});
|
|
189
|
+
}, OAUTH_COMPLETION_TIMEOUT_MS);
|
|
169
190
|
authWindowInterval = setInterval(() => {
|
|
170
191
|
if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed))
|
|
171
192
|
return;
|
|
172
193
|
clearInterval(authWindowInterval);
|
|
194
|
+
clearTimeout(authWindowTimeout);
|
|
173
195
|
setIsProcessing(false);
|
|
174
196
|
// user didn't complete oauth
|
|
175
197
|
if (providersWaitingOauthMessage[provider])
|