@dynamic-labs/utils 4.0.0-alpha.1 → 4.0.0-alpha.3

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 CHANGED
@@ -1,4 +1,26 @@
1
1
 
2
+ ## [4.0.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.2...v4.0.0-alpha.3) (2024-09-20)
3
+
4
+
5
+ ### Features
6
+
7
+ * developers provide global connectivity appkit project id ([#6941](https://github.com/dynamic-labs/DynamicAuth/issues/6941)) ([83760ea](https://github.com/dynamic-labs/DynamicAuth/commit/83760ea57591685b12caee945f173f6a7f9312d1))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * don't try to set up event listeners if wallet provider doesn't support it ([#6943](https://github.com/dynamic-labs/DynamicAuth/issues/6943)) ([439f1bb](https://github.com/dynamic-labs/DynamicAuth/commit/439f1bbb3c765959756cfc6eeb8429e4018e0379))
13
+ * dont verify all signatures for solana embedded multisig tx ([#6953](https://github.com/dynamic-labs/DynamicAuth/issues/6953)) ([7a7973e](https://github.com/dynamic-labs/DynamicAuth/commit/7a7973e05f0960421b348a55c6a00c9fd873b0b7))
14
+
15
+ ## [4.0.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.1...v4.0.0-alpha.2) (2024-09-18)
16
+
17
+
18
+ ### Features
19
+
20
+ * add iconVariant prop to DynamicBridgeWidget ([#6915](https://github.com/dynamic-labs/DynamicAuth/issues/6915)) ([8aa0f3d](https://github.com/dynamic-labs/DynamicAuth/commit/8aa0f3d8d8c41c7b5c4796106f611f208010cb6d))
21
+ * allow to create extra embedded wallets in react-native ([#6923](https://github.com/dynamic-labs/DynamicAuth/issues/6923)) ([ba22f7b](https://github.com/dynamic-labs/DynamicAuth/commit/ba22f7bcf41a444a4df0aff9b6aec257457e9402))
22
+ * **client:** add hide method for auth and userProfile ui modules ([#6928](https://github.com/dynamic-labs/DynamicAuth/issues/6928)) ([a11a4a5](https://github.com/dynamic-labs/DynamicAuth/commit/a11a4a5d6e25ce2a916ebd52f0b341020dc1a7e5))
23
+
2
24
  ## [4.0.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v4.0.0-alpha.0...v4.0.0-alpha.1) (2024-09-17)
3
25
 
4
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "4.0.0-alpha.1",
3
+ "version": "4.0.0-alpha.3",
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.530",
29
+ "@dynamic-labs/sdk-api-core": "0.0.534",
30
30
  "tldts": "6.0.16",
31
- "@dynamic-labs/logger": "4.0.0-alpha.1",
32
- "@dynamic-labs/types": "4.0.0-alpha.1",
31
+ "@dynamic-labs/logger": "4.0.0-alpha.3",
32
+ "@dynamic-labs/types": "4.0.0-alpha.3",
33
33
  "buffer": "6.0.3",
34
34
  "eventemitter3": "5.0.1",
35
35
  "stream": "0.0.2"
package/src/index.cjs CHANGED
@@ -76,6 +76,7 @@ var isHex = require('./isHex/isHex.cjs');
76
76
  var StorageService = require('./services/StorageService/StorageService.cjs');
77
77
  var createStorageService = require('./services/StorageService/createStorageService/createStorageService.cjs');
78
78
  var cloneObjectWithOverrides = require('./cloneObjectWithOverrides/cloneObjectWithOverrides.cjs');
79
+ var promiseWithTimeout = require('./promiseWithTimeout/promiseWithTimeout.cjs');
79
80
 
80
81
 
81
82
 
@@ -166,3 +167,4 @@ exports.isHex = isHex.isHex;
166
167
  exports.StorageService = StorageService.StorageService;
167
168
  exports.createStorageService = createStorageService.createStorageService;
168
169
  exports.cloneObjectWithOverrides = cloneObjectWithOverrides.cloneObjectWithOverrides;
170
+ exports.promiseWithTimeout = promiseWithTimeout.promiseWithTimeout;
package/src/index.d.ts CHANGED
@@ -32,3 +32,4 @@ export { hexToString } from './hexToString';
32
32
  export { isHex } from './isHex';
33
33
  export { type IStorageService, type StorageOptions, StorageService, createStorageService, } from './services/StorageService';
34
34
  export { cloneObjectWithOverrides } from './cloneObjectWithOverrides';
35
+ export { promiseWithTimeout } from './promiseWithTimeout';
package/src/index.js CHANGED
@@ -72,3 +72,4 @@ export { isHex } from './isHex/isHex.js';
72
72
  export { StorageService } from './services/StorageService/StorageService.js';
73
73
  export { createStorageService } from './services/StorageService/createStorageService/createStorageService.js';
74
74
  export { cloneObjectWithOverrides } from './cloneObjectWithOverrides/cloneObjectWithOverrides.js';
75
+ export { promiseWithTimeout } from './promiseWithTimeout/promiseWithTimeout.js';
@@ -0,0 +1 @@
1
+ export { promiseWithTimeout } from './promiseWithTimeout';
@@ -0,0 +1,19 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ const promiseWithTimeout = (promise, ms, { timeoutMessage = 'Operation timed out' } = {}) => {
7
+ let timerId;
8
+ const timeoutPromise = new Promise((_, reject) => {
9
+ timerId = setTimeout(() => {
10
+ reject(new Error(timeoutMessage));
11
+ }, ms);
12
+ });
13
+ const wrappedPromise = promise.finally(() => {
14
+ clearTimeout(timerId);
15
+ });
16
+ return Promise.race([wrappedPromise, timeoutPromise]);
17
+ };
18
+
19
+ exports.promiseWithTimeout = promiseWithTimeout;
@@ -0,0 +1,5 @@
1
+ type PromiseWithTimeoutOptions = {
2
+ timeoutMessage?: string;
3
+ };
4
+ export declare const promiseWithTimeout: <T>(promise: Promise<T>, ms: number, { timeoutMessage }?: PromiseWithTimeoutOptions) => Promise<T>;
5
+ export {};
@@ -0,0 +1,15 @@
1
+ 'use client'
2
+ const promiseWithTimeout = (promise, ms, { timeoutMessage = 'Operation timed out' } = {}) => {
3
+ let timerId;
4
+ const timeoutPromise = new Promise((_, reject) => {
5
+ timerId = setTimeout(() => {
6
+ reject(new Error(timeoutMessage));
7
+ }, ms);
8
+ });
9
+ const wrappedPromise = promise.finally(() => {
10
+ clearTimeout(timerId);
11
+ });
12
+ return Promise.race([wrappedPromise, timeoutPromise]);
13
+ };
14
+
15
+ export { promiseWithTimeout };
@@ -28,11 +28,10 @@ class Oauth2Service {
28
28
  _a = Oauth2Service;
29
29
  _Oauth2Service_implementation = { value: void 0 };
30
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');
31
+ Oauth2Service.isGetOauthCodeError = (error) => typeof error === 'object' &&
32
+ 'code' in error &&
33
+ Object.values(types.SocialOAuthErrorCode).includes(error.code) &&
34
+ 'message' in error &&
35
+ typeof error.message === 'string';
37
36
 
38
37
  exports.Oauth2Service = Oauth2Service;
@@ -25,7 +25,7 @@ export type GetOauthCodeProps = {
25
25
  export type IOauth2Service = {
26
26
  getOauthCode: (props: GetOauthCodeProps) => Promise<string>;
27
27
  };
28
- export type GetOauthCodeError = 'user-cancelled' | {
28
+ export type GetOauthCodeError = {
29
29
  code: SocialOAuthErrorCode;
30
30
  message: string;
31
31
  };
@@ -24,11 +24,10 @@ class Oauth2Service {
24
24
  _a = Oauth2Service;
25
25
  _Oauth2Service_implementation = { value: void 0 };
26
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');
27
+ Oauth2Service.isGetOauthCodeError = (error) => typeof error === 'object' &&
28
+ 'code' in error &&
29
+ Object.values(SocialOAuthErrorCode).includes(error.code) &&
30
+ 'message' in error &&
31
+ typeof error.message === 'string';
33
32
 
34
33
  export { Oauth2Service };
@@ -167,7 +167,10 @@ const createWindowOauth2Service = () => ({
167
167
  setIsProcessing(false);
168
168
  // user didn't complete oauth
169
169
  if (providersWaitingOauthMessage[provider])
170
- typedReject('user-cancelled');
170
+ typedReject({
171
+ code: types.SocialOAuthErrorCode.USER_CANCELLED,
172
+ message: 'User cancelled connection',
173
+ });
171
174
  }, 2000);
172
175
  });
173
176
  }),
@@ -163,7 +163,10 @@ const createWindowOauth2Service = () => ({
163
163
  setIsProcessing(false);
164
164
  // user didn't complete oauth
165
165
  if (providersWaitingOauthMessage[provider])
166
- typedReject('user-cancelled');
166
+ typedReject({
167
+ code: SocialOAuthErrorCode.USER_CANCELLED,
168
+ message: 'User cancelled connection',
169
+ });
167
170
  }, 2000);
168
171
  });
169
172
  }),