@dynamic-labs/utils 2.1.0-alpha.17 → 2.1.0-alpha.19

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/package.json +4 -4
  3. package/src/errors/CustomFieldNotUniqueError.cjs +14 -0
  4. package/src/errors/CustomFieldNotUniqueError.d.ts +4 -0
  5. package/src/errors/CustomFieldNotUniqueError.js +10 -0
  6. package/src/errors/index.d.ts +1 -0
  7. package/src/getTLD/getTLD.cjs +3 -11
  8. package/src/getTLD/getTLD.js +3 -11
  9. package/src/index.cjs +10 -0
  10. package/src/index.d.ts +2 -0
  11. package/src/index.js +5 -0
  12. package/src/services/FetchService/FetchService.cjs +24 -0
  13. package/src/services/FetchService/FetchService.d.ts +10 -0
  14. package/src/services/FetchService/FetchService.js +20 -0
  15. package/src/services/FetchService/index.d.ts +2 -0
  16. package/src/services/FetchService/types.d.ts +3 -0
  17. package/src/services/LocationService/LocationService.cjs +26 -0
  18. package/src/services/LocationService/LocationService.d.ts +8 -0
  19. package/src/services/LocationService/LocationService.js +22 -0
  20. package/src/services/LocationService/index.d.ts +3 -0
  21. package/src/services/LocationService/types.d.ts +4 -0
  22. package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.cjs +14 -0
  23. package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.d.ts +2 -0
  24. package/src/services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.js +10 -0
  25. package/src/services/LocationService/utils/createLocationFromOrigin/index.d.ts +1 -0
  26. package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.cjs +24 -0
  27. package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.d.ts +2 -0
  28. package/src/services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.js +20 -0
  29. package/src/services/LocationService/utils/createLocationFromWindow/index.d.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,22 @@
1
1
 
2
+ ## [2.1.0-alpha.19](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.18...v2.1.0-alpha.19) (2024-05-17)
3
+
4
+
5
+ ### Features
6
+
7
+ * add createUserProfileFromSDKUser ([#5596](https://github.com/dynamic-labs/DynamicAuth/issues/5596)) ([d37a1b4](https://github.com/dynamic-labs/DynamicAuth/commit/d37a1b4119f5ff4fff1e987d157f6d5abf105a8b))
8
+ * add headless social sign-in ([#5439](https://github.com/dynamic-labs/DynamicAuth/issues/5439)) ([e32fdf8](https://github.com/dynamic-labs/DynamicAuth/commit/e32fdf863718d661b90b592c8df734e92386ddf3))
9
+ * fetch custom fields in profile and update user ([#5627](https://github.com/dynamic-labs/DynamicAuth/issues/5627)) ([3940c25](https://github.com/dynamic-labs/DynamicAuth/commit/3940c2542bb330f3ed9a8eb98eed9d05c8fcb03a))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * include applinks details to AASA ([#5635](https://github.com/dynamic-labs/DynamicAuth/issues/5635)) ([ce94fec](https://github.com/dynamic-labs/DynamicAuth/commit/ce94fec80adbb3eb4efcb79d1aa2cc6eb35eab6f))
15
+ * include the appOrigin to every api call to create correct passkey ([#5636](https://github.com/dynamic-labs/DynamicAuth/issues/5636)) ([ee64df3](https://github.com/dynamic-labs/DynamicAuth/commit/ee64df3b90037bd29cca161e601973ef202c58f0))
16
+ * use PromptModal when using the DynamicMultiWalletPromptsWidget for pending connection views ([#5594](https://github.com/dynamic-labs/DynamicAuth/issues/5594)) ([c095b6e](https://github.com/dynamic-labs/DynamicAuth/commit/c095b6e4c974f02cfe632963be92d16bb201dfa5))
17
+
18
+ ## [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)
19
+
2
20
  ## [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)
3
21
 
4
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "2.1.0-alpha.17",
3
+ "version": "2.1.0-alpha.19",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -26,10 +26,10 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@dynamic-labs/sdk-api-core": "0.0.433",
29
+ "@dynamic-labs/sdk-api-core": "0.0.444",
30
30
  "tldts": "6.0.16",
31
- "@dynamic-labs/logger": "2.1.0-alpha.17",
32
- "@dynamic-labs/types": "2.1.0-alpha.17",
31
+ "@dynamic-labs/logger": "2.1.0-alpha.19",
32
+ "@dynamic-labs/types": "2.1.0-alpha.19",
33
33
  "buffer": "6.0.3"
34
34
  },
35
35
  "peerDependencies": {
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var DynamicError = require('./DynamicError.cjs');
7
+
8
+ class CustomFieldNotUniqueError extends DynamicError.DynamicError {
9
+ constructor() {
10
+ super('Custom Field for user must be unique within the environment', 'custom_field_data_not_unique');
11
+ }
12
+ }
13
+
14
+ exports.CustomFieldNotUniqueError = CustomFieldNotUniqueError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class CustomFieldNotUniqueError extends DynamicError {
3
+ constructor();
4
+ }
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ import { DynamicError } from './DynamicError.js';
3
+
4
+ class CustomFieldNotUniqueError extends DynamicError {
5
+ constructor() {
6
+ super('Custom Field for user must be unique within the environment', 'custom_field_data_not_unique');
7
+ }
8
+ }
9
+
10
+ export { CustomFieldNotUniqueError };
@@ -24,3 +24,4 @@ export * from './TooManyEmailVerificationsError';
24
24
  export * from './VerificationDataCollectionError';
25
25
  export * from './InvalidPhoneNumberError';
26
26
  export * from './MergeAccountsConfirmationError';
27
+ export * from './CustomFieldNotUniqueError';
@@ -3,17 +3,9 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var tldts = require('tldts');
6
+ var LocationService = require('../services/LocationService/LocationService.cjs');
7
+ require('tldts');
7
8
 
8
- const getTLD = () => {
9
- // Passing the allowPrivateDomains option prevents returning the actual TLD
10
- // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
11
- // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
12
- // separated by ICANN DOMAINS and PRIVATE DOMAINS
13
- // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
14
- // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
15
- const data = tldts.parse(window.location.hostname, { allowPrivateDomains: true });
16
- return data.domain || undefined;
17
- };
9
+ const getTLD = () => LocationService.LocationService.getTLD();
18
10
 
19
11
  exports.getTLD = getTLD;
@@ -1,15 +1,7 @@
1
1
  'use client'
2
- import { parse } from 'tldts';
2
+ import { LocationService } from '../services/LocationService/LocationService.js';
3
+ import 'tldts';
3
4
 
4
- const getTLD = () => {
5
- // Passing the allowPrivateDomains option prevents returning the actual TLD
6
- // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
7
- // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
8
- // separated by ICANN DOMAINS and PRIVATE DOMAINS
9
- // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
10
- // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
11
- const data = parse(window.location.hostname, { allowPrivateDomains: true });
12
- return data.domain || undefined;
13
- };
5
+ const getTLD = () => LocationService.getTLD();
14
6
 
15
7
  export { getTLD };
package/src/index.cjs CHANGED
@@ -30,6 +30,7 @@ var TooManyEmailVerificationsError = require('./errors/TooManyEmailVerifications
30
30
  var VerificationDataCollectionError = require('./errors/VerificationDataCollectionError.cjs');
31
31
  var InvalidPhoneNumberError = require('./errors/InvalidPhoneNumberError.cjs');
32
32
  var MergeAccountsConfirmationError = require('./errors/MergeAccountsConfirmationError.cjs');
33
+ var CustomFieldNotUniqueError = require('./errors/CustomFieldNotUniqueError.cjs');
33
34
  var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
34
35
  var isFunction = require('./isFunction/isFunction.cjs');
35
36
  var isMobile = require('./isMobile.cjs');
@@ -51,6 +52,10 @@ var ceil = require('./ceil/ceil.cjs');
51
52
  var trimEnd = require('./trimEnd/trimEnd.cjs');
52
53
  var isLedgerAddressViaVerifiedCredentials = require('./isLedgerAddressViaVerifiedCredentials.cjs');
53
54
  var runSafe = require('./runSafe/runSafe.cjs');
55
+ var LocationService = require('./services/LocationService/LocationService.cjs');
56
+ var createLocationFromWindow = require('./services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.cjs');
57
+ var createLocationFromOrigin = require('./services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.cjs');
58
+ var FetchService = require('./services/FetchService/FetchService.cjs');
54
59
 
55
60
 
56
61
 
@@ -81,6 +86,7 @@ exports.TooManyEmailVerificationsError = TooManyEmailVerificationsError.TooManyE
81
86
  exports.VerificationDataCollectionError = VerificationDataCollectionError.VerificationDataCollectionError;
82
87
  exports.InvalidPhoneNumberError = InvalidPhoneNumberError.InvalidPhoneNumberError;
83
88
  exports.MergeAccountsConfirmationError = MergeAccountsConfirmationError.MergeAccountsConfirmationError;
89
+ exports.CustomFieldNotUniqueError = CustomFieldNotUniqueError.CustomFieldNotUniqueError;
84
90
  exports.CancellablePromise = CancellablePromise.CancellablePromise;
85
91
  exports.isFunction = isFunction.isFunction;
86
92
  exports.getAndroidVersion = isMobile.getAndroidVersion;
@@ -116,3 +122,7 @@ exports.ceil = ceil.ceil;
116
122
  exports.trimEnd = trimEnd.trimEnd;
117
123
  exports.isLedgerAddressViaVerifiedCredentials = isLedgerAddressViaVerifiedCredentials.isLedgerAddressViaVerifiedCredentials;
118
124
  exports.runSafe = runSafe.runSafe;
125
+ exports.LocationService = LocationService.LocationService;
126
+ exports.createLocationFromWindow = createLocationFromWindow.createLocationFromWindow;
127
+ exports.createLocationFromOrigin = createLocationFromOrigin.createLocationFromOrigin;
128
+ exports.FetchService = FetchService.FetchService;
package/src/index.d.ts CHANGED
@@ -22,3 +22,5 @@ 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';
26
+ export { FetchService } from './services/FetchService';
package/src/index.js CHANGED
@@ -26,6 +26,7 @@ export { TooManyEmailVerificationsError } from './errors/TooManyEmailVerificatio
26
26
  export { VerificationDataCollectionError } from './errors/VerificationDataCollectionError.js';
27
27
  export { InvalidPhoneNumberError } from './errors/InvalidPhoneNumberError.js';
28
28
  export { MergeAccountsConfirmationError } from './errors/MergeAccountsConfirmationError.js';
29
+ export { CustomFieldNotUniqueError } from './errors/CustomFieldNotUniqueError.js';
29
30
  export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
30
31
  export { isFunction } from './isFunction/isFunction.js';
31
32
  export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows } from './isMobile.js';
@@ -47,3 +48,7 @@ export { ceil } from './ceil/ceil.js';
47
48
  export { trimEnd } from './trimEnd/trimEnd.js';
48
49
  export { isLedgerAddressViaVerifiedCredentials } from './isLedgerAddressViaVerifiedCredentials.js';
49
50
  export { runSafe } from './runSafe/runSafe.js';
51
+ export { LocationService } from './services/LocationService/LocationService.js';
52
+ export { createLocationFromWindow } from './services/LocationService/utils/createLocationFromWindow/createLocationFromWindow.js';
53
+ export { createLocationFromOrigin } from './services/LocationService/utils/createLocationFromOrigin/createLocationFromOrigin.js';
54
+ export { FetchService } from './services/FetchService/FetchService.js';
@@ -0,0 +1,24 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Class implementing the fetch service with a configurable fetch implementation.
8
+ */
9
+ class FetchService {
10
+ static get implementation() {
11
+ if (!FetchService._implementation) {
12
+ return { fetch: window.fetch };
13
+ }
14
+ return FetchService._implementation;
15
+ }
16
+ static setImplementation(implementation) {
17
+ FetchService._implementation = implementation;
18
+ }
19
+ static get fetch() {
20
+ return FetchService.implementation.fetch;
21
+ }
22
+ }
23
+
24
+ exports.FetchService = FetchService;
@@ -0,0 +1,10 @@
1
+ import { IFetchService } from './types';
2
+ /**
3
+ * Class implementing the fetch service with a configurable fetch implementation.
4
+ */
5
+ export declare class FetchService {
6
+ static _implementation: IFetchService;
7
+ static get implementation(): IFetchService;
8
+ static setImplementation(implementation: IFetchService): void;
9
+ static get fetch(): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
10
+ }
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ /**
3
+ * Class implementing the fetch service with a configurable fetch implementation.
4
+ */
5
+ class FetchService {
6
+ static get implementation() {
7
+ if (!FetchService._implementation) {
8
+ return { fetch: window.fetch };
9
+ }
10
+ return FetchService._implementation;
11
+ }
12
+ static setImplementation(implementation) {
13
+ FetchService._implementation = implementation;
14
+ }
15
+ static get fetch() {
16
+ return FetchService.implementation.fetch;
17
+ }
18
+ }
19
+
20
+ export { FetchService };
@@ -0,0 +1,2 @@
1
+ export { FetchService } from './FetchService';
2
+ export type { IFetchService } from './types';
@@ -0,0 +1,3 @@
1
+ export type IFetchService = {
2
+ fetch: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
3
+ };
@@ -0,0 +1,26 @@
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 get getHostname() {
19
+ return LocationService.implementation.getHostname;
20
+ }
21
+ static get getTLD() {
22
+ return LocationService.implementation.getTLD;
23
+ }
24
+ }
25
+
26
+ exports.LocationService = LocationService;
@@ -0,0 +1,8 @@
1
+ import { ILocation } from './types';
2
+ export declare class LocationService {
3
+ static _implementation: ILocation;
4
+ static get implementation(): ILocation;
5
+ static setImplementation(implementation: ILocation): void;
6
+ static get getHostname(): () => string;
7
+ static get getTLD(): () => string | undefined;
8
+ }
@@ -0,0 +1,22 @@
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 get getHostname() {
15
+ return LocationService.implementation.getHostname;
16
+ }
17
+ static get getTLD() {
18
+ return LocationService.implementation.getTLD;
19
+ }
20
+ }
21
+
22
+ export { LocationService };
@@ -0,0 +1,3 @@
1
+ export { LocationService } from './LocationService';
2
+ export { createLocationFromWindow } from './utils/createLocationFromWindow';
3
+ export { createLocationFromOrigin } from './utils/createLocationFromOrigin';
@@ -0,0 +1,4 @@
1
+ export interface ILocation {
2
+ getHostname(): string;
3
+ getTLD(): string | undefined;
4
+ }
@@ -0,0 +1,14 @@
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
+ getTLD: () => url.hostname,
11
+ };
12
+ };
13
+
14
+ exports.createLocationFromOrigin = createLocationFromOrigin;
@@ -0,0 +1,2 @@
1
+ import { ILocation } from '../../types';
2
+ export declare const createLocationFromOrigin: (origin: string) => ILocation;
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ const createLocationFromOrigin = (origin) => {
3
+ const url = new URL(origin);
4
+ return {
5
+ getHostname: () => url.hostname,
6
+ getTLD: () => url.hostname,
7
+ };
8
+ };
9
+
10
+ export { createLocationFromOrigin };
@@ -0,0 +1 @@
1
+ export { createLocationFromOrigin } from './createLocationFromOrigin';
@@ -0,0 +1,24 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var tldts = require('tldts');
7
+
8
+ const createLocationFromWindow = (window) => ({
9
+ getHostname: () => window.location.hostname,
10
+ getTLD: () => {
11
+ // Passing the allowPrivateDomains option prevents returning the actual TLD
12
+ // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
13
+ // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
14
+ // separated by ICANN DOMAINS and PRIVATE DOMAINS
15
+ // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
16
+ // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
17
+ const data = tldts.parse(window.location.hostname, {
18
+ allowPrivateDomains: true,
19
+ });
20
+ return data.domain || undefined;
21
+ },
22
+ });
23
+
24
+ exports.createLocationFromWindow = createLocationFromWindow;
@@ -0,0 +1,2 @@
1
+ import { ILocation } from '../../types';
2
+ export declare const createLocationFromWindow: (window: Window) => ILocation;
@@ -0,0 +1,20 @@
1
+ 'use client'
2
+ import { parse } from 'tldts';
3
+
4
+ const createLocationFromWindow = (window) => ({
5
+ getHostname: () => window.location.hostname,
6
+ getTLD: () => {
7
+ // Passing the allowPrivateDomains option prevents returning the actual TLD
8
+ // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
9
+ // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
10
+ // separated by ICANN DOMAINS and PRIVATE DOMAINS
11
+ // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
12
+ // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
13
+ const data = parse(window.location.hostname, {
14
+ allowPrivateDomains: true,
15
+ });
16
+ return data.domain || undefined;
17
+ },
18
+ });
19
+
20
+ export { createLocationFromWindow };
@@ -0,0 +1 @@
1
+ export { createLocationFromWindow } from './createLocationFromWindow';