@dynamic-labs/utils 2.5.2 → 2.6.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 +14 -0
- package/package.json +4 -4
- package/src/getOrMapViemChain.cjs +10 -4
- package/src/getOrMapViemChain.js +10 -4
- package/src/index.cjs +1 -0
- package/src/index.js +1 -1
- package/src/isMobile.cjs +11 -0
- package/src/isMobile.d.ts +1 -0
- package/src/isMobile.js +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.6.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.5.3...v2.6.0) (2024-09-03)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* adds social redirect option and improve apple id login ([#6717](https://github.com/dynamic-labs/DynamicAuth/issues/6717)) ([500e70c](https://github.com/dynamic-labs/DynamicAuth/commit/500e70cb446b75a6264b566c7adc7cd9a0c89264))
|
|
8
|
+
|
|
9
|
+
### [2.5.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.5.2...v2.5.3) (2024-09-02)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* override viem chain data with evmNetworks override data ([#6780](https://github.com/dynamic-labs/DynamicAuth/issues/6780)) ([197f1b9](https://github.com/dynamic-labs/DynamicAuth/commit/197f1b91e7d8ab2687b1463cd9817f1e13884dec))
|
|
15
|
+
|
|
2
16
|
### [2.5.2](https://github.com/dynamic-labs/DynamicAuth/compare/v2.5.1...v2.5.2) (2024-08-30)
|
|
3
17
|
|
|
4
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
29
|
+
"@dynamic-labs/sdk-api-core": "0.0.510",
|
|
30
30
|
"tldts": "6.0.16",
|
|
31
|
-
"@dynamic-labs/logger": "2.
|
|
32
|
-
"@dynamic-labs/types": "2.
|
|
31
|
+
"@dynamic-labs/logger": "2.6.0",
|
|
32
|
+
"@dynamic-labs/types": "2.6.0",
|
|
33
33
|
"buffer": "6.0.3",
|
|
34
34
|
"stream": "0.0.2"
|
|
35
35
|
},
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var chains = require('viem/chains');
|
|
7
|
+
var logger = require('./logger/logger.cjs');
|
|
7
8
|
|
|
8
9
|
function _interopNamespace(e) {
|
|
9
10
|
if (e && e.__esModule) return e;
|
|
@@ -62,14 +63,19 @@ const mapChain = (network) => {
|
|
|
62
63
|
});
|
|
63
64
|
};
|
|
64
65
|
const getOrMapViemChain = (network) => {
|
|
65
|
-
let
|
|
66
|
+
let viemChain;
|
|
66
67
|
try {
|
|
67
|
-
|
|
68
|
+
viemChain = getChain(network.chainId);
|
|
68
69
|
}
|
|
69
70
|
catch (_a) {
|
|
70
|
-
|
|
71
|
+
logger.logger.debug(`Chain with id ${network.chainId} not found in viem's chains`);
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
const mappedChain = mapChain(network);
|
|
74
|
+
if (!viemChain) {
|
|
75
|
+
return mappedChain;
|
|
76
|
+
}
|
|
77
|
+
// even if a chain is found in viem's chains, we still want to overwrite some values
|
|
78
|
+
return Object.assign(Object.assign({}, viemChain), mappedChain);
|
|
73
79
|
};
|
|
74
80
|
|
|
75
81
|
exports.getChain = getChain;
|
package/src/getOrMapViemChain.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import * as chains from 'viem/chains';
|
|
3
|
+
import { logger } from './logger/logger.js';
|
|
3
4
|
|
|
4
5
|
// eslint-disable-next-line import/no-namespace
|
|
5
6
|
/**
|
|
@@ -38,14 +39,19 @@ const mapChain = (network) => {
|
|
|
38
39
|
});
|
|
39
40
|
};
|
|
40
41
|
const getOrMapViemChain = (network) => {
|
|
41
|
-
let
|
|
42
|
+
let viemChain;
|
|
42
43
|
try {
|
|
43
|
-
|
|
44
|
+
viemChain = getChain(network.chainId);
|
|
44
45
|
}
|
|
45
46
|
catch (_a) {
|
|
46
|
-
|
|
47
|
+
logger.debug(`Chain with id ${network.chainId} not found in viem's chains`);
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
const mappedChain = mapChain(network);
|
|
50
|
+
if (!viemChain) {
|
|
51
|
+
return mappedChain;
|
|
52
|
+
}
|
|
53
|
+
// even if a chain is found in viem's chains, we still want to overwrite some values
|
|
54
|
+
return Object.assign(Object.assign({}, viemChain), mappedChain);
|
|
49
55
|
};
|
|
50
56
|
|
|
51
57
|
export { getChain, getOrMapViemChain, mapChain };
|
package/src/index.cjs
CHANGED
|
@@ -109,6 +109,7 @@ exports.isIPhone = isMobile.isIPhone;
|
|
|
109
109
|
exports.isIPhone8OrEarlier = isMobile.isIPhone8OrEarlier;
|
|
110
110
|
exports.isLegacySafari = isMobile.isLegacySafari;
|
|
111
111
|
exports.isMobile = isMobile.isMobile;
|
|
112
|
+
exports.isSafariBrowser = isMobile.isSafariBrowser;
|
|
112
113
|
exports.isSamsungBrowser = isMobile.isSamsungBrowser;
|
|
113
114
|
exports.isWindows = isMobile.isWindows;
|
|
114
115
|
exports.getItemAsync = localStorageAsync.getItemAsync;
|
package/src/index.js
CHANGED
|
@@ -33,7 +33,7 @@ export { EmbeddedWalletException } from './errors/EmbeddedWalletException.js';
|
|
|
33
33
|
export { MfaInvalidOtpError } from './errors/MfaInvalidOtpError.js';
|
|
34
34
|
export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
|
|
35
35
|
export { isFunction } from './isFunction/isFunction.js';
|
|
36
|
-
export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows } from './isMobile.js';
|
|
36
|
+
export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSafariBrowser, isSamsungBrowser, isWindows } from './isMobile.js';
|
|
37
37
|
export { getItemAsync, removeItemAsync, setItemAsync } from './localStorageAsync.js';
|
|
38
38
|
export { bufferToBase64 } from './bufferToBase64.js';
|
|
39
39
|
export { last } from './last.js';
|
package/src/isMobile.cjs
CHANGED
|
@@ -59,6 +59,16 @@ const isLegacySafari = () => {
|
|
|
59
59
|
const cssValue = 'aspect-ratio: 1 / 1';
|
|
60
60
|
return !CSS.supports(cssValue);
|
|
61
61
|
};
|
|
62
|
+
const isSafariBrowser = () => {
|
|
63
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
const { userAgent } = navigator;
|
|
67
|
+
const isSafari = userAgent.includes('Safari') &&
|
|
68
|
+
!userAgent.includes('Chrome') &&
|
|
69
|
+
!userAgent.includes('Chromium');
|
|
70
|
+
return isSafari;
|
|
71
|
+
};
|
|
62
72
|
const isSamsungBrowser = () => {
|
|
63
73
|
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
64
74
|
return false;
|
|
@@ -142,5 +152,6 @@ exports.isIPhone = isIPhone;
|
|
|
142
152
|
exports.isIPhone8OrEarlier = isIPhone8OrEarlier;
|
|
143
153
|
exports.isLegacySafari = isLegacySafari;
|
|
144
154
|
exports.isMobile = isMobile;
|
|
155
|
+
exports.isSafariBrowser = isSafariBrowser;
|
|
145
156
|
exports.isSamsungBrowser = isSamsungBrowser;
|
|
146
157
|
exports.isWindows = isWindows;
|
package/src/isMobile.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const isIPad: (maxTouchPointsOverride?: number) => boolean;
|
|
|
13
13
|
export declare const isIOS: (maxTouchPointsOverride?: number) => boolean;
|
|
14
14
|
export declare const isAndroid: () => boolean;
|
|
15
15
|
export declare const isLegacySafari: () => boolean;
|
|
16
|
+
export declare const isSafariBrowser: () => boolean;
|
|
16
17
|
export declare const isSamsungBrowser: () => boolean;
|
|
17
18
|
export declare const isWindows: () => boolean;
|
|
18
19
|
export declare const getAndroidVersion: () => number | undefined;
|
package/src/isMobile.js
CHANGED
|
@@ -55,6 +55,16 @@ const isLegacySafari = () => {
|
|
|
55
55
|
const cssValue = 'aspect-ratio: 1 / 1';
|
|
56
56
|
return !CSS.supports(cssValue);
|
|
57
57
|
};
|
|
58
|
+
const isSafariBrowser = () => {
|
|
59
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const { userAgent } = navigator;
|
|
63
|
+
const isSafari = userAgent.includes('Safari') &&
|
|
64
|
+
!userAgent.includes('Chrome') &&
|
|
65
|
+
!userAgent.includes('Chromium');
|
|
66
|
+
return isSafari;
|
|
67
|
+
};
|
|
58
68
|
const isSamsungBrowser = () => {
|
|
59
69
|
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
60
70
|
return false;
|
|
@@ -130,4 +140,4 @@ const getAndroidVersion = () => {
|
|
|
130
140
|
return androidVersion;
|
|
131
141
|
};
|
|
132
142
|
|
|
133
|
-
export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows };
|
|
143
|
+
export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSafariBrowser, isSamsungBrowser, isWindows };
|