@dynamic-labs/utils 4.8.0 → 4.8.2-preview.0
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 +23 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +5 -5
- package/src/errors/CustomError.d.ts +4 -3
- package/src/errors/ErrorCode.cjs +24 -0
- package/src/errors/ErrorCode.d.ts +18 -0
- package/src/errors/ErrorCode.js +22 -0
- package/src/errors/MetaMaskError.cjs +35 -0
- package/src/errors/MetaMaskError.d.ts +14 -0
- package/src/errors/MetaMaskError.js +30 -0
- package/src/errors/index.d.ts +2 -0
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.cjs +5 -2
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.js +5 -2
- package/src/index.cjs +8 -0
- package/src/index.js +2 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.cjs +3 -1
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.js +3 -1
- package/src/services/PlatformService/PlatformService.d.ts +1 -1
- package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs +7 -2
- package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js +7 -2
- package/src/services/PlatformService/types.d.ts +10 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.8.2-preview.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.1...v4.8.2-preview.0) (2025-02-28)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add disconnect to wallet action in connect only ([#8152](https://github.com/dynamic-labs/dynamic-auth/issues/8152)) ([4f8fa26](https://github.com/dynamic-labs/dynamic-auth/commit/4f8fa26c293aa249e697cc6494463b3bb545251a))
|
|
8
|
+
* support for onramp options via function, and default support for coinbase ([#8139](https://github.com/dynamic-labs/dynamic-auth/issues/8139)) ([f4dee01](https://github.com/dynamic-labs/dynamic-auth/commit/f4dee0175512de7a15928c577a20cc620863c282))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* embedded widget race condition that would show both embedded and non-embedded widgets at the same time ([4cb1686](https://github.com/dynamic-labs/dynamic-auth/commit/4cb16860cc61f6fcc074eb20ce38f848cdda31f1))
|
|
14
|
+
* filter out networks without a key value when parsing coinbase onramp url ([#8158](https://github.com/dynamic-labs/dynamic-auth/issues/8158)) ([8033299](https://github.com/dynamic-labs/dynamic-auth/commit/80332991551987a29b6ea7c8f66fd373956d875b))
|
|
15
|
+
* **QNTM-2927:** send users back to login on MM cancel ([#8149](https://github.com/dynamic-labs/dynamic-auth/issues/8149)) ([8e92702](https://github.com/dynamic-labs/dynamic-auth/commit/8e9270270220fc781da9c9235f86b29b9c4d2f28))
|
|
16
|
+
* update WC re-connect view on mobile ([45c5241](https://github.com/dynamic-labs/dynamic-auth/commit/45c5241fa8d973b8ad3f8b0e85b5034e429c3c11))
|
|
17
|
+
|
|
18
|
+
### [4.8.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.0...v4.8.1) (2025-02-25)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* wc redirect for safari inside iframe ([#8131](https://github.com/dynamic-labs/dynamic-auth/issues/8131)) ([8c74bea](https://github.com/dynamic-labs/dynamic-auth/commit/8c74beae505014eb85be4fd211909709d0a339dd))
|
|
24
|
+
|
|
2
25
|
## [4.8.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.7.2...v4.8.0) (2025-02-25)
|
|
3
26
|
|
|
4
27
|
|
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": "4.8.0",
|
|
3
|
+
"version": "4.8.2-preview.0",
|
|
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.633",
|
|
22
22
|
"tldts": "6.0.16",
|
|
23
|
-
"@dynamic-labs/assert-package-version": "4.8.0",
|
|
24
|
-
"@dynamic-labs/logger": "4.8.0",
|
|
25
|
-
"@dynamic-labs/types": "4.8.0",
|
|
23
|
+
"@dynamic-labs/assert-package-version": "4.8.2-preview.0",
|
|
24
|
+
"@dynamic-labs/logger": "4.8.2-preview.0",
|
|
25
|
+
"@dynamic-labs/types": "4.8.2-preview.0",
|
|
26
26
|
"buffer": "6.0.3",
|
|
27
27
|
"eventemitter3": "5.0.1"
|
|
28
28
|
},
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import { ErrorCode } from './ErrorCode';
|
|
1
2
|
/**
|
|
2
3
|
* Extend this class to allow usage of instanceof
|
|
3
4
|
*/
|
|
4
5
|
export declare class CustomError extends Error {
|
|
5
|
-
code: string | undefined;
|
|
6
|
-
constructor(message?: string
|
|
6
|
+
code: ErrorCode | string | undefined;
|
|
7
|
+
constructor(message?: string, code?: ErrorCode | string);
|
|
7
8
|
toJSON(): {
|
|
8
|
-
code: string | undefined;
|
|
9
|
+
code: string | ErrorCode | undefined;
|
|
9
10
|
error: string;
|
|
10
11
|
};
|
|
11
12
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* All supported error codes.
|
|
8
|
+
*
|
|
9
|
+
* Any changes here should be reflected in the [useErrorText] hook to maintain
|
|
10
|
+
* accurate translations.
|
|
11
|
+
*/
|
|
12
|
+
exports.ErrorCode = void 0;
|
|
13
|
+
(function (ErrorCode) {
|
|
14
|
+
ErrorCode[ErrorCode["UNKNOWN"] = 0] = "UNKNOWN";
|
|
15
|
+
ErrorCode[ErrorCode["DEFAULT"] = 1] = "DEFAULT";
|
|
16
|
+
ErrorCode[ErrorCode["USER_REJECTED"] = 2] = "USER_REJECTED";
|
|
17
|
+
ErrorCode[ErrorCode["MESSAGE_SIGNATURE_DENIED"] = 3] = "MESSAGE_SIGNATURE_DENIED";
|
|
18
|
+
ErrorCode[ErrorCode["WALLET_LOCKED"] = 4] = "WALLET_LOCKED";
|
|
19
|
+
ErrorCode[ErrorCode["INVALID_PARAMETERS"] = 5] = "INVALID_PARAMETERS";
|
|
20
|
+
ErrorCode[ErrorCode["INTERNAL_ERROR"] = 6] = "INTERNAL_ERROR";
|
|
21
|
+
ErrorCode[ErrorCode["ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_PROFILE"] = 7] = "ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_PROFILE";
|
|
22
|
+
ErrorCode[ErrorCode["CONNECTION_REJECTED"] = 8] = "CONNECTION_REJECTED";
|
|
23
|
+
ErrorCode[ErrorCode["MISSING_PUBLIC_ADDRESS"] = 9] = "MISSING_PUBLIC_ADDRESS";
|
|
24
|
+
})(exports.ErrorCode || (exports.ErrorCode = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All supported error codes.
|
|
3
|
+
*
|
|
4
|
+
* Any changes here should be reflected in the [useErrorText] hook to maintain
|
|
5
|
+
* accurate translations.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ErrorCode {
|
|
8
|
+
UNKNOWN = 0,
|
|
9
|
+
DEFAULT = 1,
|
|
10
|
+
USER_REJECTED = 2,
|
|
11
|
+
MESSAGE_SIGNATURE_DENIED = 3,
|
|
12
|
+
WALLET_LOCKED = 4,
|
|
13
|
+
INVALID_PARAMETERS = 5,
|
|
14
|
+
INTERNAL_ERROR = 6,
|
|
15
|
+
ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_PROFILE = 7,
|
|
16
|
+
CONNECTION_REJECTED = 8,
|
|
17
|
+
MISSING_PUBLIC_ADDRESS = 9
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* All supported error codes.
|
|
4
|
+
*
|
|
5
|
+
* Any changes here should be reflected in the [useErrorText] hook to maintain
|
|
6
|
+
* accurate translations.
|
|
7
|
+
*/
|
|
8
|
+
var ErrorCode;
|
|
9
|
+
(function (ErrorCode) {
|
|
10
|
+
ErrorCode[ErrorCode["UNKNOWN"] = 0] = "UNKNOWN";
|
|
11
|
+
ErrorCode[ErrorCode["DEFAULT"] = 1] = "DEFAULT";
|
|
12
|
+
ErrorCode[ErrorCode["USER_REJECTED"] = 2] = "USER_REJECTED";
|
|
13
|
+
ErrorCode[ErrorCode["MESSAGE_SIGNATURE_DENIED"] = 3] = "MESSAGE_SIGNATURE_DENIED";
|
|
14
|
+
ErrorCode[ErrorCode["WALLET_LOCKED"] = 4] = "WALLET_LOCKED";
|
|
15
|
+
ErrorCode[ErrorCode["INVALID_PARAMETERS"] = 5] = "INVALID_PARAMETERS";
|
|
16
|
+
ErrorCode[ErrorCode["INTERNAL_ERROR"] = 6] = "INTERNAL_ERROR";
|
|
17
|
+
ErrorCode[ErrorCode["ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_PROFILE"] = 7] = "ACCOUNT_ALREADY_LINKED_TO_DIFFERENT_PROFILE";
|
|
18
|
+
ErrorCode[ErrorCode["CONNECTION_REJECTED"] = 8] = "CONNECTION_REJECTED";
|
|
19
|
+
ErrorCode[ErrorCode["MISSING_PUBLIC_ADDRESS"] = 9] = "MISSING_PUBLIC_ADDRESS";
|
|
20
|
+
})(ErrorCode || (ErrorCode = {}));
|
|
21
|
+
|
|
22
|
+
export { ErrorCode };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var CustomError = require('./CustomError.cjs');
|
|
7
|
+
var ErrorCode = require('./ErrorCode.cjs');
|
|
8
|
+
|
|
9
|
+
/** Mapping of metamask error codes to dynamic [ErrorCode]s */
|
|
10
|
+
const metaMaskErrorMap = {
|
|
11
|
+
4001: ErrorCode.ErrorCode.USER_REJECTED,
|
|
12
|
+
};
|
|
13
|
+
class MetaMaskError extends CustomError.CustomError {
|
|
14
|
+
constructor(message, code) {
|
|
15
|
+
super(message, code);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a [MetaMaskError] from an unknown error (thrown by MetaMask)
|
|
19
|
+
*
|
|
20
|
+
* @param error - The error to create the [MetaMaskError] from
|
|
21
|
+
* @returns A new [MetaMaskError]
|
|
22
|
+
*/
|
|
23
|
+
static fromError(error) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
if (error instanceof Object) {
|
|
26
|
+
const errorObject = error;
|
|
27
|
+
const dynamicErrorCode = (_b = metaMaskErrorMap[(_a = errorObject.code) !== null && _a !== void 0 ? _a : '']) !== null && _b !== void 0 ? _b : ErrorCode.ErrorCode.DEFAULT;
|
|
28
|
+
return new MetaMaskError(errorObject.message, dynamicErrorCode);
|
|
29
|
+
}
|
|
30
|
+
return new MetaMaskError(String(error), ErrorCode.ErrorCode.DEFAULT);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.MetaMaskError = MetaMaskError;
|
|
35
|
+
exports.metaMaskErrorMap = metaMaskErrorMap;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CustomError } from './CustomError';
|
|
2
|
+
import { ErrorCode } from './ErrorCode';
|
|
3
|
+
/** Mapping of metamask error codes to dynamic [ErrorCode]s */
|
|
4
|
+
export declare const metaMaskErrorMap: Record<string, ErrorCode>;
|
|
5
|
+
export declare class MetaMaskError extends CustomError {
|
|
6
|
+
constructor(message?: string, code?: ErrorCode);
|
|
7
|
+
/**
|
|
8
|
+
* Creates a [MetaMaskError] from an unknown error (thrown by MetaMask)
|
|
9
|
+
*
|
|
10
|
+
* @param error - The error to create the [MetaMaskError] from
|
|
11
|
+
* @returns A new [MetaMaskError]
|
|
12
|
+
*/
|
|
13
|
+
static fromError(error: unknown): MetaMaskError;
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { CustomError } from './CustomError.js';
|
|
3
|
+
import { ErrorCode } from './ErrorCode.js';
|
|
4
|
+
|
|
5
|
+
/** Mapping of metamask error codes to dynamic [ErrorCode]s */
|
|
6
|
+
const metaMaskErrorMap = {
|
|
7
|
+
4001: ErrorCode.USER_REJECTED,
|
|
8
|
+
};
|
|
9
|
+
class MetaMaskError extends CustomError {
|
|
10
|
+
constructor(message, code) {
|
|
11
|
+
super(message, code);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a [MetaMaskError] from an unknown error (thrown by MetaMask)
|
|
15
|
+
*
|
|
16
|
+
* @param error - The error to create the [MetaMaskError] from
|
|
17
|
+
* @returns A new [MetaMaskError]
|
|
18
|
+
*/
|
|
19
|
+
static fromError(error) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
if (error instanceof Object) {
|
|
22
|
+
const errorObject = error;
|
|
23
|
+
const dynamicErrorCode = (_b = metaMaskErrorMap[(_a = errorObject.code) !== null && _a !== void 0 ? _a : '']) !== null && _b !== void 0 ? _b : ErrorCode.DEFAULT;
|
|
24
|
+
return new MetaMaskError(errorObject.message, dynamicErrorCode);
|
|
25
|
+
}
|
|
26
|
+
return new MetaMaskError(String(error), ErrorCode.DEFAULT);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { MetaMaskError, metaMaskErrorMap };
|
package/src/errors/index.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ export * from './DynamicError';
|
|
|
6
6
|
export * from './EmailAlreadyExistsError';
|
|
7
7
|
export * from './EmailProviderError';
|
|
8
8
|
export * from './EmailVerificationError';
|
|
9
|
+
export * from './ErrorCode';
|
|
9
10
|
export * from './GateBlockedError';
|
|
10
11
|
export * from './InsufficientFundsError';
|
|
12
|
+
export * from './MetaMaskError';
|
|
11
13
|
export * from './MissingEnvironmentIdError';
|
|
12
14
|
export * from './MissingPublicAddressError';
|
|
13
15
|
export * from './NoAccessError';
|
|
@@ -4,16 +4,19 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var isMobile = require('../isMobile/isMobile.cjs');
|
|
7
|
+
var PlatformService = require('../services/PlatformService/PlatformService.cjs');
|
|
8
|
+
require('../../_virtual/_tslib.cjs');
|
|
9
|
+
require('tldts');
|
|
7
10
|
|
|
8
11
|
const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
|
|
9
12
|
const url = encodeURIComponent(window.location.toString());
|
|
10
13
|
const ref = encodeURIComponent(window.location.origin);
|
|
11
14
|
// samsung browser only supports native links, not universal links
|
|
12
15
|
if (isMobile.isSamsungBrowser()) {
|
|
13
|
-
|
|
16
|
+
PlatformService.PlatformService.openURL(`${nativeLink}/${url}?ref=${ref}`);
|
|
14
17
|
}
|
|
15
18
|
else {
|
|
16
|
-
|
|
19
|
+
PlatformService.PlatformService.openURL(`${universalLink}/${url}?ref=${ref}`);
|
|
17
20
|
}
|
|
18
21
|
};
|
|
19
22
|
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { isSamsungBrowser } from '../isMobile/isMobile.js';
|
|
3
|
+
import { PlatformService } from '../services/PlatformService/PlatformService.js';
|
|
4
|
+
import '../../_virtual/_tslib.js';
|
|
5
|
+
import 'tldts';
|
|
3
6
|
|
|
4
7
|
const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
|
|
5
8
|
const url = encodeURIComponent(window.location.toString());
|
|
6
9
|
const ref = encodeURIComponent(window.location.origin);
|
|
7
10
|
// samsung browser only supports native links, not universal links
|
|
8
11
|
if (isSamsungBrowser()) {
|
|
9
|
-
|
|
12
|
+
PlatformService.openURL(`${nativeLink}/${url}?ref=${ref}`);
|
|
10
13
|
}
|
|
11
14
|
else {
|
|
12
|
-
|
|
15
|
+
PlatformService.openURL(`${universalLink}/${url}?ref=${ref}`);
|
|
13
16
|
}
|
|
14
17
|
};
|
|
15
18
|
|
package/src/index.cjs
CHANGED
|
@@ -18,8 +18,10 @@ var DynamicError = require('./errors/DynamicError.cjs');
|
|
|
18
18
|
var EmailAlreadyExistsError = require('./errors/EmailAlreadyExistsError.cjs');
|
|
19
19
|
var EmailProviderError = require('./errors/EmailProviderError.cjs');
|
|
20
20
|
var EmailVerificationError = require('./errors/EmailVerificationError.cjs');
|
|
21
|
+
var ErrorCode = require('./errors/ErrorCode.cjs');
|
|
21
22
|
var GateBlockedError = require('./errors/GateBlockedError.cjs');
|
|
22
23
|
var InsufficientFundsError = require('./errors/InsufficientFundsError.cjs');
|
|
24
|
+
var MetaMaskError = require('./errors/MetaMaskError.cjs');
|
|
23
25
|
var MissingEnvironmentIdError = require('./errors/MissingEnvironmentIdError.cjs');
|
|
24
26
|
var MissingPublicAddressError = require('./errors/MissingPublicAddressError.cjs');
|
|
25
27
|
var NoAccessError = require('./errors/NoAccessError.cjs');
|
|
@@ -117,8 +119,14 @@ exports.DynamicError = DynamicError.DynamicError;
|
|
|
117
119
|
exports.EmailAlreadyExistsError = EmailAlreadyExistsError.EmailAlreadyExistsError;
|
|
118
120
|
exports.EmailProviderError = EmailProviderError.EmailProviderError;
|
|
119
121
|
exports.EmailVerificationError = EmailVerificationError.EmailVerificationError;
|
|
122
|
+
Object.defineProperty(exports, 'ErrorCode', {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: function () { return ErrorCode.ErrorCode; }
|
|
125
|
+
});
|
|
120
126
|
exports.GateBlockedError = GateBlockedError.GateBlockedError;
|
|
121
127
|
exports.InsufficientFundsError = InsufficientFundsError.InsufficientFundsError;
|
|
128
|
+
exports.MetaMaskError = MetaMaskError.MetaMaskError;
|
|
129
|
+
exports.metaMaskErrorMap = MetaMaskError.metaMaskErrorMap;
|
|
122
130
|
exports.MissingEnvironmentIdError = MissingEnvironmentIdError.MissingEnvironmentIdError;
|
|
123
131
|
exports.MissingPublicAddressError = MissingPublicAddressError.MissingPublicAddressError;
|
|
124
132
|
exports.NoAccessError = NoAccessError.NoAccessError;
|
package/src/index.js
CHANGED
|
@@ -14,8 +14,10 @@ export { DynamicError } from './errors/DynamicError.js';
|
|
|
14
14
|
export { EmailAlreadyExistsError } from './errors/EmailAlreadyExistsError.js';
|
|
15
15
|
export { EmailProviderError } from './errors/EmailProviderError.js';
|
|
16
16
|
export { EmailVerificationError } from './errors/EmailVerificationError.js';
|
|
17
|
+
export { ErrorCode } from './errors/ErrorCode.js';
|
|
17
18
|
export { GateBlockedError } from './errors/GateBlockedError.js';
|
|
18
19
|
export { InsufficientFundsError } from './errors/InsufficientFundsError.js';
|
|
20
|
+
export { MetaMaskError, metaMaskErrorMap } from './errors/MetaMaskError.js';
|
|
19
21
|
export { MissingEnvironmentIdError } from './errors/MissingEnvironmentIdError.js';
|
|
20
22
|
export { MissingPublicAddressError } from './errors/MissingPublicAddressError.js';
|
|
21
23
|
export { NoAccessError } from './errors/NoAccessError.js';
|
|
@@ -8,6 +8,8 @@ var types = require('@dynamic-labs/types');
|
|
|
8
8
|
var logger = require('../../../logger/logger.cjs');
|
|
9
9
|
var connectWithAppleId = require('../utils/connectWithAppleId/connectWithAppleId.cjs');
|
|
10
10
|
var isMobile = require('../../../isMobile/isMobile.cjs');
|
|
11
|
+
var PlatformService = require('../../PlatformService/PlatformService.cjs');
|
|
12
|
+
require('tldts');
|
|
11
13
|
|
|
12
14
|
let authWindowInterval;
|
|
13
15
|
const createWindowOauth2Service = () => ({
|
|
@@ -35,7 +37,7 @@ const createWindowOauth2Service = () => ({
|
|
|
35
37
|
initWebAuth({
|
|
36
38
|
redirectUrl: redirectUrl || window.location.href,
|
|
37
39
|
}).then(() => {
|
|
38
|
-
|
|
40
|
+
PlatformService.PlatformService.openURL(oauthLoginUrl.toString());
|
|
39
41
|
});
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
@@ -4,6 +4,8 @@ import { ProviderEnum, SocialOAuthErrorCode } from '@dynamic-labs/types';
|
|
|
4
4
|
import { logger } from '../../../logger/logger.js';
|
|
5
5
|
import { connectWithAppleId } from '../utils/connectWithAppleId/connectWithAppleId.js';
|
|
6
6
|
import { isSafariBrowser, isIOS } from '../../../isMobile/isMobile.js';
|
|
7
|
+
import { PlatformService } from '../../PlatformService/PlatformService.js';
|
|
8
|
+
import 'tldts';
|
|
7
9
|
|
|
8
10
|
let authWindowInterval;
|
|
9
11
|
const createWindowOauth2Service = () => ({
|
|
@@ -31,7 +33,7 @@ const createWindowOauth2Service = () => ({
|
|
|
31
33
|
initWebAuth({
|
|
32
34
|
redirectUrl: redirectUrl || window.location.href,
|
|
33
35
|
}).then(() => {
|
|
34
|
-
|
|
36
|
+
PlatformService.openURL(oauthLoginUrl.toString());
|
|
35
37
|
});
|
|
36
38
|
return;
|
|
37
39
|
}
|
|
@@ -36,5 +36,5 @@ export declare class PlatformService {
|
|
|
36
36
|
/**
|
|
37
37
|
* Opens a URL. If possible, should avoid new windows.
|
|
38
38
|
*/
|
|
39
|
-
static get openURL(): (url: string) => Promise<void>;
|
|
39
|
+
static get openURL(): (url: string, target?: "self" | "blank" | undefined, features?: string | undefined) => Promise<void>;
|
|
40
40
|
}
|
package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs
CHANGED
|
@@ -24,8 +24,13 @@ const createBrowserPlatformService = (window) => ({
|
|
|
24
24
|
return data.domain || undefined;
|
|
25
25
|
},
|
|
26
26
|
isNativeMobile: false,
|
|
27
|
-
openURL: (
|
|
28
|
-
|
|
27
|
+
openURL: (url_1, ...args_1) => _tslib.__awaiter(void 0, [url_1, ...args_1], void 0, function* (url, target = 'self', features = '') {
|
|
28
|
+
if (target === 'blank') {
|
|
29
|
+
window.open(url, '_blank', features);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
window.location.assign(url);
|
|
33
|
+
}
|
|
29
34
|
}),
|
|
30
35
|
});
|
|
31
36
|
|
package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js
CHANGED
|
@@ -20,8 +20,13 @@ const createBrowserPlatformService = (window) => ({
|
|
|
20
20
|
return data.domain || undefined;
|
|
21
21
|
},
|
|
22
22
|
isNativeMobile: false,
|
|
23
|
-
openURL: (
|
|
24
|
-
|
|
23
|
+
openURL: (url_1, ...args_1) => __awaiter(void 0, [url_1, ...args_1], void 0, function* (url, target = 'self', features = '') {
|
|
24
|
+
if (target === 'blank') {
|
|
25
|
+
window.open(url, '_blank', features);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
window.location.assign(url);
|
|
29
|
+
}
|
|
25
30
|
}),
|
|
26
31
|
});
|
|
27
32
|
|
|
@@ -30,7 +30,15 @@ export interface IPlatformService {
|
|
|
30
30
|
getDisplayOrigin(): string | undefined;
|
|
31
31
|
getTLD(): string | undefined;
|
|
32
32
|
/**
|
|
33
|
-
* Opens a URL.
|
|
33
|
+
* Opens a URL.
|
|
34
|
+
*
|
|
35
|
+
* Target options:
|
|
36
|
+
* - 'self': Opens the URL in the current window (default).
|
|
37
|
+
* - 'blank': Opens the URL in a new window.
|
|
38
|
+
*
|
|
39
|
+
* The `features` parameter is passed to the `window.open` function when the target is 'blank'.
|
|
40
|
+
*
|
|
41
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/open
|
|
34
42
|
*/
|
|
35
|
-
openURL(url: string): Promise<void>;
|
|
43
|
+
openURL(url: string, target?: 'self' | 'blank', features?: string): Promise<void>;
|
|
36
44
|
}
|