@dynamic-labs/utils 3.0.0-alpha.4 → 3.0.0-alpha.40
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 +371 -0
- package/_virtual/_tslib.cjs +15 -0
- package/_virtual/_tslib.js +14 -1
- package/package.json +7 -8
- package/src/eip6963/eip6963Provider.cjs +40 -0
- package/src/eip6963/eip6963Provider.d.ts +34 -0
- package/src/eip6963/eip6963Provider.js +35 -0
- package/src/eip6963/index.d.ts +1 -0
- package/src/errors/ExternalAuthError.cjs +14 -0
- package/src/errors/ExternalAuthError.d.ts +4 -0
- package/src/errors/ExternalAuthError.js +10 -0
- package/src/errors/MfaInvalidOtpError.cjs +1 -1
- package/src/errors/MfaInvalidOtpError.js +1 -1
- package/src/errors/NoAccessError.cjs +3 -1
- package/src/errors/NoAccessError.d.ts +5 -1
- package/src/errors/NoAccessError.js +3 -1
- package/src/errors/SandboxMaximumThresholdReachedError.cjs +15 -0
- package/src/errors/SandboxMaximumThresholdReachedError.d.ts +5 -0
- package/src/errors/SandboxMaximumThresholdReachedError.js +11 -0
- package/src/errors/WalletAddressMismatchError.cjs +17 -0
- package/src/errors/WalletAddressMismatchError.d.ts +11 -0
- package/src/errors/WalletAddressMismatchError.js +13 -0
- package/src/errors/index.d.ts +3 -0
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.cjs +0 -7
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.js +0 -7
- package/src/index.cjs +15 -4
- package/src/index.d.ts +3 -1
- package/src/index.js +7 -1
- package/src/nativeMobileOauthStateParam.cjs +13 -0
- package/src/nativeMobileOauthStateParam.d.ts +14 -0
- package/src/nativeMobileOauthStateParam.js +9 -0
- package/src/retryableFn.cjs +1 -6
- package/src/retryableFn.js +1 -6
- package/src/services/FetchService/FetchService.cjs +10 -5
- package/src/services/FetchService/FetchService.d.ts +2 -2
- package/src/services/FetchService/FetchService.js +10 -5
- package/src/services/Oauth2Service/Oauth2Service.cjs +38 -0
- package/src/services/Oauth2Service/Oauth2Service.d.ts +35 -0
- package/src/services/Oauth2Service/Oauth2Service.js +34 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.cjs +203 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.d.ts +2 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.js +199 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/index.d.ts +1 -0
- package/src/services/Oauth2Service/index.d.ts +2 -0
- package/src/services/PlatformService/PlatformService.cjs +13 -12
- package/src/services/PlatformService/PlatformService.d.ts +2 -3
- package/src/services/PlatformService/PlatformService.js +13 -12
- package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs +0 -3
- package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js +0 -3
- package/src/services/PlatformService/types.d.ts +0 -4
- package/src/getOrMapViemChain.cjs +0 -77
- package/src/getOrMapViemChain.d.ts +0 -11
- package/src/getOrMapViemChain.js +0 -51
|
@@ -6,11 +6,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var DynamicError = require('./DynamicError.cjs');
|
|
7
7
|
|
|
8
8
|
class NoAccessError extends DynamicError.DynamicError {
|
|
9
|
-
constructor({ walletPublicKey, email, phoneNumber, }) {
|
|
9
|
+
constructor({ walletPublicKey, email, phoneNumber, socialProvider, socialUsername, }) {
|
|
10
10
|
super('User does not have access');
|
|
11
11
|
this.email = email;
|
|
12
12
|
this.walletPublicKey = walletPublicKey;
|
|
13
13
|
this.phoneNumber = phoneNumber;
|
|
14
|
+
this.socialProvider = socialProvider;
|
|
15
|
+
this.socialUsername = socialUsername;
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -3,9 +3,13 @@ export declare class NoAccessError extends DynamicError {
|
|
|
3
3
|
walletPublicKey?: string;
|
|
4
4
|
email?: string;
|
|
5
5
|
phoneNumber?: string;
|
|
6
|
-
|
|
6
|
+
socialProvider?: string;
|
|
7
|
+
socialUsername?: string;
|
|
8
|
+
constructor({ walletPublicKey, email, phoneNumber, socialProvider, socialUsername, }: {
|
|
7
9
|
email?: string;
|
|
8
10
|
walletPublicKey?: string;
|
|
9
11
|
phoneNumber?: string;
|
|
12
|
+
socialProvider?: string;
|
|
13
|
+
socialUsername?: string;
|
|
10
14
|
});
|
|
11
15
|
}
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
import { DynamicError } from './DynamicError.js';
|
|
3
3
|
|
|
4
4
|
class NoAccessError extends DynamicError {
|
|
5
|
-
constructor({ walletPublicKey, email, phoneNumber, }) {
|
|
5
|
+
constructor({ walletPublicKey, email, phoneNumber, socialProvider, socialUsername, }) {
|
|
6
6
|
super('User does not have access');
|
|
7
7
|
this.email = email;
|
|
8
8
|
this.walletPublicKey = walletPublicKey;
|
|
9
9
|
this.phoneNumber = phoneNumber;
|
|
10
|
+
this.socialProvider = socialProvider;
|
|
11
|
+
this.socialUsername = socialUsername;
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
14
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var DynamicError = require('./DynamicError.cjs');
|
|
7
|
+
|
|
8
|
+
class SandboxMaximumThresholdReachedError extends DynamicError.DynamicError {
|
|
9
|
+
constructor(errorMessage) {
|
|
10
|
+
super(errorMessage);
|
|
11
|
+
this.errorMessage = errorMessage;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
exports.SandboxMaximumThresholdReachedError = SandboxMaximumThresholdReachedError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { DynamicError } from './DynamicError.js';
|
|
3
|
+
|
|
4
|
+
class SandboxMaximumThresholdReachedError extends DynamicError {
|
|
5
|
+
constructor(errorMessage) {
|
|
6
|
+
super(errorMessage);
|
|
7
|
+
this.errorMessage = errorMessage;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { SandboxMaximumThresholdReachedError };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var DynamicError = require('./DynamicError.cjs');
|
|
7
|
+
|
|
8
|
+
class WalletAddressMismatchError extends DynamicError.DynamicError {
|
|
9
|
+
constructor(message, { activeAddress, expectedAddress, walletName, }) {
|
|
10
|
+
super(message, 'wallet_address_mismatch_error');
|
|
11
|
+
this.expectedAddress = expectedAddress;
|
|
12
|
+
this.activeAddress = activeAddress;
|
|
13
|
+
this.walletName = walletName;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.WalletAddressMismatchError = WalletAddressMismatchError;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DynamicError } from './DynamicError';
|
|
2
|
+
export declare class WalletAddressMismatchError extends DynamicError {
|
|
3
|
+
expectedAddress: string | undefined;
|
|
4
|
+
activeAddress: string | undefined;
|
|
5
|
+
walletName: string | undefined;
|
|
6
|
+
constructor(message: string, { activeAddress, expectedAddress, walletName, }: {
|
|
7
|
+
activeAddress?: string;
|
|
8
|
+
expectedAddress?: string;
|
|
9
|
+
walletName?: string;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { DynamicError } from './DynamicError.js';
|
|
3
|
+
|
|
4
|
+
class WalletAddressMismatchError extends DynamicError {
|
|
5
|
+
constructor(message, { activeAddress, expectedAddress, walletName, }) {
|
|
6
|
+
super(message, 'wallet_address_mismatch_error');
|
|
7
|
+
this.expectedAddress = expectedAddress;
|
|
8
|
+
this.activeAddress = activeAddress;
|
|
9
|
+
this.walletName = walletName;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { WalletAddressMismatchError };
|
package/src/errors/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './AccountExistsError';
|
|
2
2
|
export * from './ChainalysisError';
|
|
3
|
+
export * from './SandboxMaximumThresholdReachedError';
|
|
3
4
|
export * from './CustomError';
|
|
4
5
|
export * from './DynamicError';
|
|
5
6
|
export * from './EmailAlreadyExistsError';
|
|
@@ -29,3 +30,5 @@ export * from './CookieInvalidError';
|
|
|
29
30
|
export * from './AccessBlockedError';
|
|
30
31
|
export * from './EmbeddedWalletException';
|
|
31
32
|
export * from './MfaInvalidOtpError';
|
|
33
|
+
export * from './ExternalAuthError';
|
|
34
|
+
export * from './WalletAddressMismatchError';
|
|
@@ -3,14 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
require('../errors/InsufficientFundsError.cjs');
|
|
7
|
-
require('../errors/TransactionGasCannotBeSponsoredError.cjs');
|
|
8
|
-
require('../logger/logger.cjs');
|
|
9
6
|
var isMobile = require('../isMobile.cjs');
|
|
10
|
-
require('../../_virtual/_tslib.cjs');
|
|
11
|
-
require('../bufferPolyfill.cjs');
|
|
12
|
-
require('viem/chains');
|
|
13
|
-
require('tldts');
|
|
14
7
|
|
|
15
8
|
const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
|
|
16
9
|
const url = encodeURIComponent(window.location.toString());
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import '../errors/InsufficientFundsError.js';
|
|
3
|
-
import '../errors/TransactionGasCannotBeSponsoredError.js';
|
|
4
|
-
import '../logger/logger.js';
|
|
5
2
|
import { isSamsungBrowser } from '../isMobile.js';
|
|
6
|
-
import '../../_virtual/_tslib.js';
|
|
7
|
-
import '../bufferPolyfill.js';
|
|
8
|
-
import 'viem/chains';
|
|
9
|
-
import 'tldts';
|
|
10
3
|
|
|
11
4
|
const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
|
|
12
5
|
const url = encodeURIComponent(window.location.toString());
|
package/src/index.cjs
CHANGED
|
@@ -7,6 +7,7 @@ var parseChainId = require('./parseChainId.cjs');
|
|
|
7
7
|
var parseEvmNetworks = require('./parseEvmNetworks.cjs');
|
|
8
8
|
var AccountExistsError = require('./errors/AccountExistsError.cjs');
|
|
9
9
|
var ChainalysisError = require('./errors/ChainalysisError.cjs');
|
|
10
|
+
var SandboxMaximumThresholdReachedError = require('./errors/SandboxMaximumThresholdReachedError.cjs');
|
|
10
11
|
var CustomError = require('./errors/CustomError.cjs');
|
|
11
12
|
var DynamicError = require('./errors/DynamicError.cjs');
|
|
12
13
|
var EmailAlreadyExistsError = require('./errors/EmailAlreadyExistsError.cjs');
|
|
@@ -35,6 +36,8 @@ var CookieInvalidError = require('./errors/CookieInvalidError.cjs');
|
|
|
35
36
|
var AccessBlockedError = require('./errors/AccessBlockedError.cjs');
|
|
36
37
|
var EmbeddedWalletException = require('./errors/EmbeddedWalletException.cjs');
|
|
37
38
|
var MfaInvalidOtpError = require('./errors/MfaInvalidOtpError.cjs');
|
|
39
|
+
var ExternalAuthError = require('./errors/ExternalAuthError.cjs');
|
|
40
|
+
var WalletAddressMismatchError = require('./errors/WalletAddressMismatchError.cjs');
|
|
38
41
|
var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
|
|
39
42
|
var isFunction = require('./isFunction/isFunction.cjs');
|
|
40
43
|
var isMobile = require('./isMobile.cjs');
|
|
@@ -43,7 +46,6 @@ var bufferToBase64 = require('./bufferToBase64.cjs');
|
|
|
43
46
|
var last = require('./last.cjs');
|
|
44
47
|
var getProvidersFromWindow = require('./getProvidersFromWindow.cjs');
|
|
45
48
|
var sleep = require('./sleep/sleep.cjs');
|
|
46
|
-
var getOrMapViemChain = require('./getOrMapViemChain.cjs');
|
|
47
49
|
var retryableFn = require('./retryableFn.cjs');
|
|
48
50
|
var wrapMethodWithCallback = require('./wrapMethodWithCallback/wrapMethodWithCallback.cjs');
|
|
49
51
|
var DeferredPromise = require('./DeferredPromise/DeferredPromise.cjs');
|
|
@@ -55,10 +57,14 @@ var formatNumberText = require('./formatNumberText/formatNumberText.cjs');
|
|
|
55
57
|
var ceil = require('./ceil/ceil.cjs');
|
|
56
58
|
var trimEnd = require('./trimEnd/trimEnd.cjs');
|
|
57
59
|
var isLedgerAddressViaVerifiedCredentials = require('./isLedgerAddressViaVerifiedCredentials.cjs');
|
|
60
|
+
var nativeMobileOauthStateParam = require('./nativeMobileOauthStateParam.cjs');
|
|
61
|
+
var eip6963Provider = require('./eip6963/eip6963Provider.cjs');
|
|
58
62
|
var runSafe = require('./runSafe/runSafe.cjs');
|
|
59
63
|
var PlatformService = require('./services/PlatformService/PlatformService.cjs');
|
|
60
64
|
var createBrowserPlatformService = require('./services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs');
|
|
61
65
|
var FetchService = require('./services/FetchService/FetchService.cjs');
|
|
66
|
+
var Oauth2Service = require('./services/Oauth2Service/Oauth2Service.cjs');
|
|
67
|
+
var createWindowOauth2Service = require('./services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.cjs');
|
|
62
68
|
var template = require('./template/template.cjs');
|
|
63
69
|
var get = require('./get/get.cjs');
|
|
64
70
|
var hexToString = require('./hexToString/hexToString.cjs');
|
|
@@ -70,6 +76,7 @@ exports.parseChainId = parseChainId.parseChainId;
|
|
|
70
76
|
exports.parseEvmNetworks = parseEvmNetworks.parseEvmNetworks;
|
|
71
77
|
exports.AccountExistsError = AccountExistsError.AccountExistsError;
|
|
72
78
|
exports.ChainalysisError = ChainalysisError.ChainalysisError;
|
|
79
|
+
exports.SandboxMaximumThresholdReachedError = SandboxMaximumThresholdReachedError.SandboxMaximumThresholdReachedError;
|
|
73
80
|
exports.CustomError = CustomError.CustomError;
|
|
74
81
|
exports.DynamicError = DynamicError.DynamicError;
|
|
75
82
|
exports.EmailAlreadyExistsError = EmailAlreadyExistsError.EmailAlreadyExistsError;
|
|
@@ -98,6 +105,8 @@ exports.CookieInvalidError = CookieInvalidError.CookieInvalidError;
|
|
|
98
105
|
exports.AccessBlockedError = AccessBlockedError.AccessBlockedError;
|
|
99
106
|
exports.EmbeddedWalletException = EmbeddedWalletException.EmbeddedWalletException;
|
|
100
107
|
exports.MfaInvalidOtpError = MfaInvalidOtpError.MfaInvalidOtpError;
|
|
108
|
+
exports.ExternalAuthError = ExternalAuthError.ExternalAuthError;
|
|
109
|
+
exports.WalletAddressMismatchError = WalletAddressMismatchError.WalletAddressMismatchError;
|
|
101
110
|
exports.CancellablePromise = CancellablePromise.CancellablePromise;
|
|
102
111
|
exports.isFunction = isFunction.isFunction;
|
|
103
112
|
exports.getAndroidVersion = isMobile.getAndroidVersion;
|
|
@@ -117,9 +126,6 @@ exports.bufferToBase64 = bufferToBase64.bufferToBase64;
|
|
|
117
126
|
exports.last = last.last;
|
|
118
127
|
exports.getProvidersFromWindow = getProvidersFromWindow.getProvidersFromWindow;
|
|
119
128
|
exports.sleep = sleep.sleep;
|
|
120
|
-
exports.getChain = getOrMapViemChain.getChain;
|
|
121
|
-
exports.getOrMapViemChain = getOrMapViemChain.getOrMapViemChain;
|
|
122
|
-
exports.mapChain = getOrMapViemChain.mapChain;
|
|
123
129
|
exports.FALLBACK_UNDEFINED = retryableFn.FALLBACK_UNDEFINED;
|
|
124
130
|
exports.retryableFn = retryableFn.retryableFn;
|
|
125
131
|
exports.wrapMethodWithCallback = wrapMethodWithCallback.wrapMethodWithCallback;
|
|
@@ -132,10 +138,15 @@ exports.formatNumberText = formatNumberText.formatNumberText;
|
|
|
132
138
|
exports.ceil = ceil.ceil;
|
|
133
139
|
exports.trimEnd = trimEnd.trimEnd;
|
|
134
140
|
exports.isLedgerAddressViaVerifiedCredentials = isLedgerAddressViaVerifiedCredentials.isLedgerAddressViaVerifiedCredentials;
|
|
141
|
+
exports.nativeMobileOauthStateParam = nativeMobileOauthStateParam.nativeMobileOauthStateParam;
|
|
142
|
+
exports.Eip6963Provider = eip6963Provider.Eip6963Provider;
|
|
143
|
+
exports.Eip6963ProviderSingleton = eip6963Provider.Eip6963ProviderSingleton;
|
|
135
144
|
exports.runSafe = runSafe.runSafe;
|
|
136
145
|
exports.PlatformService = PlatformService.PlatformService;
|
|
137
146
|
exports.createBrowserPlatformService = createBrowserPlatformService.createBrowserPlatformService;
|
|
138
147
|
exports.FetchService = FetchService.FetchService;
|
|
148
|
+
exports.Oauth2Service = Oauth2Service.Oauth2Service;
|
|
149
|
+
exports.createWindowOauth2Service = createWindowOauth2Service.createWindowOauth2Service;
|
|
139
150
|
exports.template = template.template;
|
|
140
151
|
exports.get = get.get;
|
|
141
152
|
exports.hexToString = hexToString.hexToString;
|
package/src/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export * from './bufferToBase64';
|
|
|
9
9
|
export * from './last';
|
|
10
10
|
export * from './getProvidersFromWindow';
|
|
11
11
|
export * from './sleep';
|
|
12
|
-
export * from './getOrMapViemChain';
|
|
13
12
|
export * from './retryableFn';
|
|
14
13
|
export * from './wrapMethodWithCallback';
|
|
15
14
|
export * from './DeferredPromise';
|
|
@@ -21,9 +20,12 @@ export * from './formatNumberText';
|
|
|
21
20
|
export * from './ceil';
|
|
22
21
|
export * from './trimEnd';
|
|
23
22
|
export * from './isLedgerAddressViaVerifiedCredentials';
|
|
23
|
+
export * from './nativeMobileOauthStateParam';
|
|
24
|
+
export * from './eip6963';
|
|
24
25
|
export { runSafe } from './runSafe';
|
|
25
26
|
export { PlatformService, createBrowserPlatformService, type IPlatformService, } from './services/PlatformService';
|
|
26
27
|
export { FetchService } from './services/FetchService';
|
|
28
|
+
export { Oauth2Service, type GetOauthCodeError, type GetOauthCodeProps, type IOauth2Service, createWindowOauth2Service, } from './services/Oauth2Service';
|
|
27
29
|
export { template } from './template';
|
|
28
30
|
export { get } from './get';
|
|
29
31
|
export { hexToString } from './hexToString';
|
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { parseChainId } from './parseChainId.js';
|
|
|
3
3
|
export { parseEvmNetworks } from './parseEvmNetworks.js';
|
|
4
4
|
export { AccountExistsError } from './errors/AccountExistsError.js';
|
|
5
5
|
export { ChainalysisError } from './errors/ChainalysisError.js';
|
|
6
|
+
export { SandboxMaximumThresholdReachedError } from './errors/SandboxMaximumThresholdReachedError.js';
|
|
6
7
|
export { CustomError } from './errors/CustomError.js';
|
|
7
8
|
export { DynamicError } from './errors/DynamicError.js';
|
|
8
9
|
export { EmailAlreadyExistsError } from './errors/EmailAlreadyExistsError.js';
|
|
@@ -31,6 +32,8 @@ export { CookieInvalidError } from './errors/CookieInvalidError.js';
|
|
|
31
32
|
export { AccessBlockedError } from './errors/AccessBlockedError.js';
|
|
32
33
|
export { EmbeddedWalletException } from './errors/EmbeddedWalletException.js';
|
|
33
34
|
export { MfaInvalidOtpError } from './errors/MfaInvalidOtpError.js';
|
|
35
|
+
export { ExternalAuthError } from './errors/ExternalAuthError.js';
|
|
36
|
+
export { WalletAddressMismatchError } from './errors/WalletAddressMismatchError.js';
|
|
34
37
|
export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
|
|
35
38
|
export { isFunction } from './isFunction/isFunction.js';
|
|
36
39
|
export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows } from './isMobile.js';
|
|
@@ -39,7 +42,6 @@ export { bufferToBase64 } from './bufferToBase64.js';
|
|
|
39
42
|
export { last } from './last.js';
|
|
40
43
|
export { getProvidersFromWindow } from './getProvidersFromWindow.js';
|
|
41
44
|
export { sleep } from './sleep/sleep.js';
|
|
42
|
-
export { getChain, getOrMapViemChain, mapChain } from './getOrMapViemChain.js';
|
|
43
45
|
export { FALLBACK_UNDEFINED, retryableFn } from './retryableFn.js';
|
|
44
46
|
export { wrapMethodWithCallback } from './wrapMethodWithCallback/wrapMethodWithCallback.js';
|
|
45
47
|
export { DeferredPromise } from './DeferredPromise/DeferredPromise.js';
|
|
@@ -51,10 +53,14 @@ export { formatNumberText } from './formatNumberText/formatNumberText.js';
|
|
|
51
53
|
export { ceil } from './ceil/ceil.js';
|
|
52
54
|
export { trimEnd } from './trimEnd/trimEnd.js';
|
|
53
55
|
export { isLedgerAddressViaVerifiedCredentials } from './isLedgerAddressViaVerifiedCredentials.js';
|
|
56
|
+
export { nativeMobileOauthStateParam } from './nativeMobileOauthStateParam.js';
|
|
57
|
+
export { Eip6963Provider, Eip6963ProviderSingleton } from './eip6963/eip6963Provider.js';
|
|
54
58
|
export { runSafe } from './runSafe/runSafe.js';
|
|
55
59
|
export { PlatformService } from './services/PlatformService/PlatformService.js';
|
|
56
60
|
export { createBrowserPlatformService } from './services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js';
|
|
57
61
|
export { FetchService } from './services/FetchService/FetchService.js';
|
|
62
|
+
export { Oauth2Service } from './services/Oauth2Service/Oauth2Service.js';
|
|
63
|
+
export { createWindowOauth2Service } from './services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.js';
|
|
58
64
|
export { template } from './template/template.js';
|
|
59
65
|
export { get } from './get/get.js';
|
|
60
66
|
export { hexToString } from './hexToString/hexToString.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents the value that separates the random string from the
|
|
8
|
+
* mobile deeplink URL in the state param from the oauth messages
|
|
9
|
+
* emitted from native mobile apps.
|
|
10
|
+
*/
|
|
11
|
+
const nativeMobileOauthStateParam = '_client-redirect:';
|
|
12
|
+
|
|
13
|
+
exports.nativeMobileOauthStateParam = nativeMobileOauthStateParam;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the value that separates the random string from the
|
|
3
|
+
* mobile deeplink URL in the state param from the oauth messages
|
|
4
|
+
* emitted from native mobile apps.
|
|
5
|
+
*/
|
|
6
|
+
export declare const nativeMobileOauthStateParam = "_client-redirect:";
|
|
7
|
+
/**
|
|
8
|
+
* Represents the format of the state variable exchanged in oauth2 messages
|
|
9
|
+
* by native mobile devices.
|
|
10
|
+
*
|
|
11
|
+
* It has a random state string followed byt the client redirect URL as configured
|
|
12
|
+
* in the Client.
|
|
13
|
+
*/
|
|
14
|
+
export type NativeMobileOauthState = `${string}${typeof nativeMobileOauthStateParam}${string}`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Represents the value that separates the random string from the
|
|
4
|
+
* mobile deeplink URL in the state param from the oauth messages
|
|
5
|
+
* emitted from native mobile apps.
|
|
6
|
+
*/
|
|
7
|
+
const nativeMobileOauthStateParam = '_client-redirect:';
|
|
8
|
+
|
|
9
|
+
export { nativeMobileOauthStateParam };
|
package/src/retryableFn.cjs
CHANGED
|
@@ -4,13 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
7
|
-
require('./errors/InsufficientFundsError.cjs');
|
|
8
|
-
require('./errors/TransactionGasCannotBeSponsoredError.cjs');
|
|
9
|
-
require('./logger/logger.cjs');
|
|
10
|
-
require('./bufferPolyfill.cjs');
|
|
11
7
|
var sleep = require('./sleep/sleep.cjs');
|
|
12
|
-
require('viem/chains');
|
|
13
|
-
require('tldts');
|
|
14
8
|
|
|
15
9
|
const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
|
|
16
10
|
const retryableFn = (fn_1, ...args_1) => _tslib.__awaiter(void 0, [fn_1, ...args_1], void 0, function* (fn, options = {}) {
|
|
@@ -68,6 +62,7 @@ const retryableFn = (fn_1, ...args_1) => _tslib.__awaiter(void 0, [fn_1, ...args
|
|
|
68
62
|
fallbackValue,
|
|
69
63
|
logger,
|
|
70
64
|
maxRetries,
|
|
65
|
+
retryIntervalMs,
|
|
71
66
|
retryStrategy,
|
|
72
67
|
timeoutMs,
|
|
73
68
|
});
|
package/src/retryableFn.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
3
|
-
import './errors/InsufficientFundsError.js';
|
|
4
|
-
import './errors/TransactionGasCannotBeSponsoredError.js';
|
|
5
|
-
import './logger/logger.js';
|
|
6
|
-
import './bufferPolyfill.js';
|
|
7
3
|
import { sleep } from './sleep/sleep.js';
|
|
8
|
-
import 'viem/chains';
|
|
9
|
-
import 'tldts';
|
|
10
4
|
|
|
11
5
|
const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
|
|
12
6
|
const retryableFn = (fn_1, ...args_1) => __awaiter(void 0, [fn_1, ...args_1], void 0, function* (fn, options = {}) {
|
|
@@ -64,6 +58,7 @@ const retryableFn = (fn_1, ...args_1) => __awaiter(void 0, [fn_1, ...args_1], vo
|
|
|
64
58
|
fallbackValue,
|
|
65
59
|
logger,
|
|
66
60
|
maxRetries,
|
|
61
|
+
retryIntervalMs,
|
|
67
62
|
retryStrategy,
|
|
68
63
|
timeoutMs,
|
|
69
64
|
});
|
|
@@ -3,22 +3,27 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
|
|
8
|
+
var _a, _FetchService_implementation;
|
|
6
9
|
/**
|
|
7
10
|
* Class implementing the fetch service with a configurable fetch implementation.
|
|
8
11
|
*/
|
|
9
12
|
class FetchService {
|
|
10
13
|
static get implementation() {
|
|
11
|
-
if (!
|
|
14
|
+
if (!_tslib.__classPrivateFieldGet(_a, _a, "f", _FetchService_implementation)) {
|
|
12
15
|
return { fetch: window.fetch.bind(window) };
|
|
13
16
|
}
|
|
14
|
-
return
|
|
17
|
+
return _tslib.__classPrivateFieldGet(_a, _a, "f", _FetchService_implementation);
|
|
15
18
|
}
|
|
16
|
-
static
|
|
17
|
-
|
|
19
|
+
static set implementation(implementation) {
|
|
20
|
+
_tslib.__classPrivateFieldSet(_a, _a, implementation, "f", _FetchService_implementation);
|
|
18
21
|
}
|
|
19
22
|
static get fetch() {
|
|
20
|
-
return
|
|
23
|
+
return _a.implementation.fetch;
|
|
21
24
|
}
|
|
22
25
|
}
|
|
26
|
+
_a = FetchService;
|
|
27
|
+
_FetchService_implementation = { value: void 0 };
|
|
23
28
|
|
|
24
29
|
exports.FetchService = FetchService;
|
|
@@ -3,8 +3,8 @@ import { IFetchService } from './types';
|
|
|
3
3
|
* Class implementing the fetch service with a configurable fetch implementation.
|
|
4
4
|
*/
|
|
5
5
|
export declare class FetchService {
|
|
6
|
-
|
|
6
|
+
#private;
|
|
7
7
|
static get implementation(): IFetchService;
|
|
8
|
-
static
|
|
8
|
+
static set implementation(implementation: IFetchService);
|
|
9
9
|
static get fetch(): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
10
10
|
}
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../_virtual/_tslib.js';
|
|
3
|
+
|
|
4
|
+
var _a, _FetchService_implementation;
|
|
2
5
|
/**
|
|
3
6
|
* Class implementing the fetch service with a configurable fetch implementation.
|
|
4
7
|
*/
|
|
5
8
|
class FetchService {
|
|
6
9
|
static get implementation() {
|
|
7
|
-
if (!
|
|
10
|
+
if (!__classPrivateFieldGet(_a, _a, "f", _FetchService_implementation)) {
|
|
8
11
|
return { fetch: window.fetch.bind(window) };
|
|
9
12
|
}
|
|
10
|
-
return
|
|
13
|
+
return __classPrivateFieldGet(_a, _a, "f", _FetchService_implementation);
|
|
11
14
|
}
|
|
12
|
-
static
|
|
13
|
-
|
|
15
|
+
static set implementation(implementation) {
|
|
16
|
+
__classPrivateFieldSet(_a, _a, implementation, "f", _FetchService_implementation);
|
|
14
17
|
}
|
|
15
18
|
static get fetch() {
|
|
16
|
-
return
|
|
19
|
+
return _a.implementation.fetch;
|
|
17
20
|
}
|
|
18
21
|
}
|
|
22
|
+
_a = FetchService;
|
|
23
|
+
_FetchService_implementation = { value: void 0 };
|
|
19
24
|
|
|
20
25
|
export { FetchService };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var types = require('@dynamic-labs/types');
|
|
8
|
+
var createWindowOauth2Service = require('./createWindowOauth2Service/createWindowOauth2Service.cjs');
|
|
9
|
+
|
|
10
|
+
var _a, _Oauth2Service_implementation;
|
|
11
|
+
/**
|
|
12
|
+
* Class implementing the fetch service with a configurable fetch implementation.
|
|
13
|
+
*/
|
|
14
|
+
class Oauth2Service {
|
|
15
|
+
static get implementation() {
|
|
16
|
+
if (!_tslib.__classPrivateFieldGet(_a, _a, "f", _Oauth2Service_implementation)) {
|
|
17
|
+
return createWindowOauth2Service.createWindowOauth2Service();
|
|
18
|
+
}
|
|
19
|
+
return _tslib.__classPrivateFieldGet(_a, _a, "f", _Oauth2Service_implementation);
|
|
20
|
+
}
|
|
21
|
+
static set implementation(implementation) {
|
|
22
|
+
_tslib.__classPrivateFieldSet(_a, _a, implementation, "f", _Oauth2Service_implementation);
|
|
23
|
+
}
|
|
24
|
+
static get getOauthCode() {
|
|
25
|
+
return _a.implementation.getOauthCode;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
_a = Oauth2Service;
|
|
29
|
+
_Oauth2Service_implementation = { value: void 0 };
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
+
Oauth2Service.isGetOauthCodeError = (error) => error === 'user-cancelled' ||
|
|
32
|
+
(typeof error === 'object' &&
|
|
33
|
+
'code' in error &&
|
|
34
|
+
Object.values(types.SocialOAuthErrorCode).includes(error.code) &&
|
|
35
|
+
'message' in error &&
|
|
36
|
+
typeof error.message === 'string');
|
|
37
|
+
|
|
38
|
+
exports.Oauth2Service = Oauth2Service;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { OauthResultResponse, Provider, ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
import { SocialOAuthErrorCode } from '@dynamic-labs/types';
|
|
3
|
+
export type GetOauthCodeProps = {
|
|
4
|
+
provider: ProviderEnum;
|
|
5
|
+
apiProvider: Provider | undefined;
|
|
6
|
+
setIsProcessing: (value: boolean) => void;
|
|
7
|
+
onSettled?: VoidFunction;
|
|
8
|
+
getOAuthResultFromApi: () => Promise<OauthResultResponse | undefined>;
|
|
9
|
+
initWebAuth: () => Promise<void>;
|
|
10
|
+
state: string;
|
|
11
|
+
oauthLoginUrl: URL;
|
|
12
|
+
sessionTimeout: number;
|
|
13
|
+
/**
|
|
14
|
+
* Overrides the default redirectUrl coming from the DynamicContextProvider
|
|
15
|
+
*/
|
|
16
|
+
redirectUrl?: string;
|
|
17
|
+
isMobile?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type IOauth2Service = {
|
|
20
|
+
getOauthCode: (props: GetOauthCodeProps) => Promise<string>;
|
|
21
|
+
};
|
|
22
|
+
export type GetOauthCodeError = 'user-cancelled' | {
|
|
23
|
+
code: SocialOAuthErrorCode;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Class implementing the fetch service with a configurable fetch implementation.
|
|
28
|
+
*/
|
|
29
|
+
export declare class Oauth2Service {
|
|
30
|
+
#private;
|
|
31
|
+
static get implementation(): IOauth2Service;
|
|
32
|
+
static set implementation(implementation: IOauth2Service);
|
|
33
|
+
static get getOauthCode(): (props: GetOauthCodeProps) => Promise<string>;
|
|
34
|
+
static isGetOauthCodeError: (error: any) => error is GetOauthCodeError;
|
|
35
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { SocialOAuthErrorCode } from '@dynamic-labs/types';
|
|
4
|
+
import { createWindowOauth2Service } from './createWindowOauth2Service/createWindowOauth2Service.js';
|
|
5
|
+
|
|
6
|
+
var _a, _Oauth2Service_implementation;
|
|
7
|
+
/**
|
|
8
|
+
* Class implementing the fetch service with a configurable fetch implementation.
|
|
9
|
+
*/
|
|
10
|
+
class Oauth2Service {
|
|
11
|
+
static get implementation() {
|
|
12
|
+
if (!__classPrivateFieldGet(_a, _a, "f", _Oauth2Service_implementation)) {
|
|
13
|
+
return createWindowOauth2Service();
|
|
14
|
+
}
|
|
15
|
+
return __classPrivateFieldGet(_a, _a, "f", _Oauth2Service_implementation);
|
|
16
|
+
}
|
|
17
|
+
static set implementation(implementation) {
|
|
18
|
+
__classPrivateFieldSet(_a, _a, implementation, "f", _Oauth2Service_implementation);
|
|
19
|
+
}
|
|
20
|
+
static get getOauthCode() {
|
|
21
|
+
return _a.implementation.getOauthCode;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
_a = Oauth2Service;
|
|
25
|
+
_Oauth2Service_implementation = { value: void 0 };
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
Oauth2Service.isGetOauthCodeError = (error) => error === 'user-cancelled' ||
|
|
28
|
+
(typeof error === 'object' &&
|
|
29
|
+
'code' in error &&
|
|
30
|
+
Object.values(SocialOAuthErrorCode).includes(error.code) &&
|
|
31
|
+
'message' in error &&
|
|
32
|
+
typeof error.message === 'string');
|
|
33
|
+
|
|
34
|
+
export { Oauth2Service };
|