@dynamic-labs/utils 2.1.0-alpha.16 → 2.1.0-alpha.18
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 +9 -0
- package/package.json +3 -3
- package/src/getTLD/getTLD.cjs +4 -1
- package/src/getTLD/getTLD.js +4 -1
- package/src/index.cjs +6 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -0
- package/src/services/LocationService/LocationService.cjs +23 -0
- package/src/services/LocationService/LocationService.d.ts +7 -0
- package/src/services/LocationService/LocationService.js +19 -0
- package/src/services/LocationService/index.d.ts +3 -0
- package/src/services/LocationService/types.d.ts +3 -0
- package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.cjs +13 -0
- package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.d.ts +2 -0
- package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.js +9 -0
- package/src/services/LocationService/utils/createLocationFromOrigin/index.d.ts +1 -0
- package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.cjs +10 -0
- package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.d.ts +2 -0
- package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.js +6 -0
- package/src/services/LocationService/utils/createLocationFromWindow/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.1.0-alpha.18](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.17...v2.1.0-alpha.18) (2024-05-15)
|
|
3
|
+
|
|
4
|
+
## [2.1.0-alpha.17](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.16...v2.1.0-alpha.17) (2024-05-15)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* add coinbaseWalletPreference prop ([#5607](https://github.com/dynamic-labs/DynamicAuth/issues/5607)) ([1ac3b2c](https://github.com/dynamic-labs/DynamicAuth/commit/1ac3b2ce7abb136465f4aa88b045dfb70d99aad7))
|
|
10
|
+
|
|
2
11
|
## [2.1.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.15...v2.1.0-alpha.16) (2024-05-14)
|
|
3
12
|
|
|
4
13
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/utils",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.18",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@dynamic-labs/sdk-api-core": "0.0.433",
|
|
30
30
|
"tldts": "6.0.16",
|
|
31
|
-
"@dynamic-labs/logger": "2.1.0-alpha.
|
|
32
|
-
"@dynamic-labs/types": "2.1.0-alpha.
|
|
31
|
+
"@dynamic-labs/logger": "2.1.0-alpha.18",
|
|
32
|
+
"@dynamic-labs/types": "2.1.0-alpha.18",
|
|
33
33
|
"buffer": "6.0.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
package/src/getTLD/getTLD.cjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var tldts = require('tldts');
|
|
7
|
+
var LocationService = require('../services/LocationService/LocationService.cjs');
|
|
7
8
|
|
|
8
9
|
const getTLD = () => {
|
|
9
10
|
// Passing the allowPrivateDomains option prevents returning the actual TLD
|
|
@@ -12,7 +13,9 @@ const getTLD = () => {
|
|
|
12
13
|
// separated by ICANN DOMAINS and PRIVATE DOMAINS
|
|
13
14
|
// so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
|
|
14
15
|
// whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
|
|
15
|
-
const data = tldts.parse(
|
|
16
|
+
const data = tldts.parse(LocationService.LocationService.getHostname(), {
|
|
17
|
+
allowPrivateDomains: true,
|
|
18
|
+
});
|
|
16
19
|
return data.domain || undefined;
|
|
17
20
|
};
|
|
18
21
|
|
package/src/getTLD/getTLD.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { parse } from 'tldts';
|
|
3
|
+
import { LocationService } from '../services/LocationService/LocationService.js';
|
|
3
4
|
|
|
4
5
|
const getTLD = () => {
|
|
5
6
|
// Passing the allowPrivateDomains option prevents returning the actual TLD
|
|
@@ -8,7 +9,9 @@ const getTLD = () => {
|
|
|
8
9
|
// separated by ICANN DOMAINS and PRIVATE DOMAINS
|
|
9
10
|
// so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
|
|
10
11
|
// whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
|
|
11
|
-
const data = parse(
|
|
12
|
+
const data = parse(LocationService.getHostname(), {
|
|
13
|
+
allowPrivateDomains: true,
|
|
14
|
+
});
|
|
12
15
|
return data.domain || undefined;
|
|
13
16
|
};
|
|
14
17
|
|
package/src/index.cjs
CHANGED
|
@@ -51,6 +51,9 @@ var ceil = require('./ceil/ceil.cjs');
|
|
|
51
51
|
var trimEnd = require('./trimEnd/trimEnd.cjs');
|
|
52
52
|
var isLedgerAddressViaVerifiedCredentials = require('./isLedgerAddressViaVerifiedCredentials.cjs');
|
|
53
53
|
var runSafe = require('./runSafe/runSafe.cjs');
|
|
54
|
+
var LocationService = require('./services/LocationService/LocationService.cjs');
|
|
55
|
+
var createLocationFromWindow = require('./services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.cjs');
|
|
56
|
+
var createLocationFromOrigin = require('./services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.cjs');
|
|
54
57
|
|
|
55
58
|
|
|
56
59
|
|
|
@@ -116,3 +119,6 @@ exports.ceil = ceil.ceil;
|
|
|
116
119
|
exports.trimEnd = trimEnd.trimEnd;
|
|
117
120
|
exports.isLedgerAddressViaVerifiedCredentials = isLedgerAddressViaVerifiedCredentials.isLedgerAddressViaVerifiedCredentials;
|
|
118
121
|
exports.runSafe = runSafe.runSafe;
|
|
122
|
+
exports.LocationService = LocationService.LocationService;
|
|
123
|
+
exports.createLocationFromWindow = createLocationFromWindow.createLocationFromWindow;
|
|
124
|
+
exports.createLocationFromOrigin = createLocationFromOrigin.createLocationFromOrigin;
|
package/src/index.d.ts
CHANGED
|
@@ -22,3 +22,4 @@ export * from './ceil';
|
|
|
22
22
|
export * from './trimEnd';
|
|
23
23
|
export * from './isLedgerAddressViaVerifiedCredentials';
|
|
24
24
|
export { runSafe } from './runSafe';
|
|
25
|
+
export { LocationService, createLocationFromOrigin, createLocationFromWindow, } from './services/LocationService';
|
package/src/index.js
CHANGED
|
@@ -47,3 +47,6 @@ export { ceil } from './ceil/ceil.js';
|
|
|
47
47
|
export { trimEnd } from './trimEnd/trimEnd.js';
|
|
48
48
|
export { isLedgerAddressViaVerifiedCredentials } from './isLedgerAddressViaVerifiedCredentials.js';
|
|
49
49
|
export { runSafe } from './runSafe/runSafe.js';
|
|
50
|
+
export { LocationService } from './services/LocationService/LocationService.js';
|
|
51
|
+
export { createLocationFromWindow } from './services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.js';
|
|
52
|
+
export { createLocationFromOrigin } from './services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.js';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var createLocationFromWindow = require('./utils/createLocationFromWindow/createLocationFromWindow.cjs');
|
|
7
|
+
|
|
8
|
+
class LocationService {
|
|
9
|
+
static get implementation() {
|
|
10
|
+
if (!LocationService._implementation) {
|
|
11
|
+
return createLocationFromWindow.createLocationFromWindow(window);
|
|
12
|
+
}
|
|
13
|
+
return LocationService._implementation;
|
|
14
|
+
}
|
|
15
|
+
static setImplementation(implementation) {
|
|
16
|
+
LocationService._implementation = implementation;
|
|
17
|
+
}
|
|
18
|
+
static getHostname() {
|
|
19
|
+
return LocationService.implementation.getHostname();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.LocationService = LocationService;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { createLocationFromWindow } from './utils/createLocationFromWindow/createLocationFromWindow.js';
|
|
3
|
+
|
|
4
|
+
class LocationService {
|
|
5
|
+
static get implementation() {
|
|
6
|
+
if (!LocationService._implementation) {
|
|
7
|
+
return createLocationFromWindow(window);
|
|
8
|
+
}
|
|
9
|
+
return LocationService._implementation;
|
|
10
|
+
}
|
|
11
|
+
static setImplementation(implementation) {
|
|
12
|
+
LocationService._implementation = implementation;
|
|
13
|
+
}
|
|
14
|
+
static getHostname() {
|
|
15
|
+
return LocationService.implementation.getHostname();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { LocationService };
|
package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.cjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const createLocationFromOrigin = (origin) => {
|
|
7
|
+
const url = new URL(origin);
|
|
8
|
+
return {
|
|
9
|
+
getHostname: () => url.hostname,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.createLocationFromOrigin = createLocationFromOrigin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createLocationFromOrigin } from './createLocationFromOrigin';
|
package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
const createLocationFromWindow = (window) => ({
|
|
7
|
+
getHostname: () => window.location.hostname,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
exports.createLocationFromWindow = createLocationFromWindow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createLocationFromWindow } from './createLocationFromWindow';
|