@dynamic-labs/utils 0.17.0-RC.7 → 0.17.0-RC.8

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 (40) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/package.json +2 -2
  3. package/src/CancellablePromise/CancellablePromise.cjs +33 -0
  4. package/src/CancellablePromise/CancellablePromise.d.ts +9 -0
  5. package/src/CancellablePromise/CancellablePromise.js +29 -0
  6. package/src/CancellablePromise/index.d.ts +1 -0
  7. package/src/errors/ChainalysisError.cjs +14 -0
  8. package/src/errors/ChainalysisError.d.ts +5 -0
  9. package/src/errors/ChainalysisError.js +10 -0
  10. package/src/errors/CustomError.cjs +23 -0
  11. package/src/errors/CustomError.d.ts +11 -0
  12. package/src/errors/CustomError.js +19 -0
  13. package/src/errors/DynamicError.cjs +10 -0
  14. package/src/errors/DynamicError.d.ts +3 -0
  15. package/src/errors/DynamicError.js +6 -0
  16. package/src/errors/EmailAlreadyExistsError.cjs +13 -0
  17. package/src/errors/EmailAlreadyExistsError.d.ts +4 -0
  18. package/src/errors/EmailAlreadyExistsError.js +9 -0
  19. package/src/errors/EmailVerificationError.cjs +13 -0
  20. package/src/errors/EmailVerificationError.d.ts +4 -0
  21. package/src/errors/EmailVerificationError.js +9 -0
  22. package/src/errors/NoAccessError.cjs +15 -0
  23. package/src/errors/NoAccessError.d.ts +9 -0
  24. package/src/errors/NoAccessError.js +11 -0
  25. package/src/errors/NotSupportedError.cjs +10 -0
  26. package/src/errors/NotSupportedError.d.ts +3 -0
  27. package/src/errors/NotSupportedError.js +6 -0
  28. package/src/errors/UsernameAlreadyExistsError.cjs +13 -0
  29. package/src/errors/UsernameAlreadyExistsError.d.ts +4 -0
  30. package/src/errors/UsernameAlreadyExistsError.js +9 -0
  31. package/src/errors/WalletNotDeployedError.cjs +13 -0
  32. package/src/errors/WalletNotDeployedError.d.ts +4 -0
  33. package/src/errors/WalletNotDeployedError.js +9 -0
  34. package/src/errors/WalletUsedError.cjs +13 -0
  35. package/src/errors/WalletUsedError.d.ts +4 -0
  36. package/src/errors/WalletUsedError.js +9 -0
  37. package/src/errors/index.d.ts +10 -0
  38. package/src/index.cjs +22 -0
  39. package/src/index.d.ts +2 -0
  40. package/src/index.js +11 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,26 @@
1
1
 
2
+ ## [0.17.0-RC.8](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.7...v0.17.0-RC.8) (2023-05-03)
3
+
4
+
5
+ ### ⚠ BREAKING CHANGES
6
+
7
+ * Removes support for Fortmatic in favor of Magic
8
+
9
+ ### Features
10
+
11
+ * add selected address to qr code modal ([#2017](https://github.com/dynamic-labs/DynamicAuth/issues/2017)) ([58a5d69](https://github.com/dynamic-labs/DynamicAuth/commit/58a5d691f8a4045d92be1a2bcaf6092f44b91b73))
12
+ * **DYN-2228:** show network picker only when more than 1 network ([#2007](https://github.com/dynamic-labs/DynamicAuth/issues/2007)) ([8329737](https://github.com/dynamic-labs/DynamicAuth/commit/83297378cc5ed019f3f8297b48c16f56d7cfe9a7))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * disable kyc submit button when network is not supported ([#1952](https://github.com/dynamic-labs/DynamicAuth/issues/1952)) ([ec2f0eb](https://github.com/dynamic-labs/DynamicAuth/commit/ec2f0eb708ed2938dd68cbc7e8ee40f3bc856c2b))
18
+ * missing evm networks for connect-only ([#2006](https://github.com/dynamic-labs/DynamicAuth/issues/2006)) ([78561b3](https://github.com/dynamic-labs/DynamicAuth/commit/78561b3243ac38a348a383bb3c79ce58c8731538))
19
+ * wallet-connect menu on mobile ([#2025](https://github.com/dynamic-labs/DynamicAuth/issues/2025)) ([1f358a6](https://github.com/dynamic-labs/DynamicAuth/commit/1f358a66dda696e745db32f121fb4ef62379cb9a))
20
+
21
+
22
+ * remove Fortmatic ([#2010](https://github.com/dynamic-labs/DynamicAuth/issues/2010)) ([0ca95c1](https://github.com/dynamic-labs/DynamicAuth/commit/0ca95c175b5d8383433340832bd9ae7dab85f912))
23
+
2
24
  ## [0.17.0-RC.7](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.6...v0.17.0-RC.7) (2023-04-28)
3
25
 
4
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "0.17.0-RC.7",
3
+ "version": "0.17.0-RC.8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -26,7 +26,7 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@dynamic-labs/types": "0.17.0-RC.7"
29
+ "@dynamic-labs/types": "0.17.0-RC.8"
30
30
  },
31
31
  "peerDependencies": {}
32
32
  }
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ class CancellablePromise extends Promise {
6
+ constructor(executor) {
7
+ super((resolve, reject) => {
8
+ executor((val) => {
9
+ if (this.isCancelled)
10
+ return;
11
+ resolve(val);
12
+ }, (err) => {
13
+ if (this.isCancelled)
14
+ return;
15
+ reject(err);
16
+ });
17
+ });
18
+ this._controller = new AbortController();
19
+ }
20
+ get isCancelled() {
21
+ return this._controller.signal.aborted;
22
+ }
23
+ cancel() {
24
+ this._controller.abort();
25
+ }
26
+ static fromPromise(promise) {
27
+ return new CancellablePromise((resolve, reject) => {
28
+ promise.then(resolve).catch(reject);
29
+ });
30
+ }
31
+ }
32
+
33
+ exports.CancellablePromise = CancellablePromise;
@@ -0,0 +1,9 @@
1
+ type Executor<T> = (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void;
2
+ export declare class CancellablePromise<T> extends Promise<T> {
3
+ _controller: AbortController;
4
+ constructor(executor: Executor<T>);
5
+ get isCancelled(): boolean;
6
+ cancel(): void;
7
+ static fromPromise<T>(promise: Promise<T>): CancellablePromise<T>;
8
+ }
9
+ export {};
@@ -0,0 +1,29 @@
1
+ class CancellablePromise extends Promise {
2
+ constructor(executor) {
3
+ super((resolve, reject) => {
4
+ executor((val) => {
5
+ if (this.isCancelled)
6
+ return;
7
+ resolve(val);
8
+ }, (err) => {
9
+ if (this.isCancelled)
10
+ return;
11
+ reject(err);
12
+ });
13
+ });
14
+ this._controller = new AbortController();
15
+ }
16
+ get isCancelled() {
17
+ return this._controller.signal.aborted;
18
+ }
19
+ cancel() {
20
+ this._controller.abort();
21
+ }
22
+ static fromPromise(promise) {
23
+ return new CancellablePromise((resolve, reject) => {
24
+ promise.then(resolve).catch(reject);
25
+ });
26
+ }
27
+ }
28
+
29
+ export { CancellablePromise };
@@ -0,0 +1 @@
1
+ export { CancellablePromise } from './CancellablePromise';
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class ChainalysisError extends DynamicError.DynamicError {
8
+ constructor(walletPublicKey) {
9
+ super('This address is not approved for access');
10
+ this.walletPublicKey = walletPublicKey;
11
+ }
12
+ }
13
+
14
+ exports.ChainalysisError = ChainalysisError;
@@ -0,0 +1,5 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class ChainalysisError extends DynamicError {
3
+ walletPublicKey: string | undefined;
4
+ constructor(walletPublicKey: string);
5
+ }
@@ -0,0 +1,10 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class ChainalysisError extends DynamicError {
4
+ constructor(walletPublicKey) {
5
+ super('This address is not approved for access');
6
+ this.walletPublicKey = walletPublicKey;
7
+ }
8
+ }
9
+
10
+ export { ChainalysisError };
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * Extend this class to allow usage of instanceof
7
+ */
8
+ class CustomError extends Error {
9
+ constructor(message, code) {
10
+ super(message);
11
+ this.code = undefined;
12
+ this.code = code;
13
+ Object.setPrototypeOf(this, this.constructor.prototype);
14
+ }
15
+ toJSON() {
16
+ return {
17
+ code: this.code,
18
+ error: this.message,
19
+ };
20
+ }
21
+ }
22
+
23
+ exports.CustomError = CustomError;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Extend this class to allow usage of instanceof
3
+ */
4
+ export declare class CustomError extends Error {
5
+ code: string | undefined;
6
+ constructor(message?: string | undefined, code?: string);
7
+ toJSON(): {
8
+ code: string | undefined;
9
+ error: string;
10
+ };
11
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Extend this class to allow usage of instanceof
3
+ */
4
+ class CustomError extends Error {
5
+ constructor(message, code) {
6
+ super(message);
7
+ this.code = undefined;
8
+ this.code = code;
9
+ Object.setPrototypeOf(this, this.constructor.prototype);
10
+ }
11
+ toJSON() {
12
+ return {
13
+ code: this.code,
14
+ error: this.message,
15
+ };
16
+ }
17
+ }
18
+
19
+ export { CustomError };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var CustomError = require('./CustomError.cjs');
6
+
7
+ class DynamicError extends CustomError.CustomError {
8
+ }
9
+
10
+ exports.DynamicError = DynamicError;
@@ -0,0 +1,3 @@
1
+ import { CustomError } from './CustomError';
2
+ export declare class DynamicError extends CustomError {
3
+ }
@@ -0,0 +1,6 @@
1
+ import { CustomError } from './CustomError.js';
2
+
3
+ class DynamicError extends CustomError {
4
+ }
5
+
6
+ export { DynamicError };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class EmailAlreadyExistsError extends DynamicError.DynamicError {
8
+ constructor() {
9
+ super('Email already exists');
10
+ }
11
+ }
12
+
13
+ exports.EmailAlreadyExistsError = EmailAlreadyExistsError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class EmailAlreadyExistsError extends DynamicError {
3
+ constructor();
4
+ }
@@ -0,0 +1,9 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class EmailAlreadyExistsError extends DynamicError {
4
+ constructor() {
5
+ super('Email already exists');
6
+ }
7
+ }
8
+
9
+ export { EmailAlreadyExistsError };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class EmailVerificationError extends DynamicError.DynamicError {
8
+ constructor(code) {
9
+ super('EmailVerificationError', code);
10
+ }
11
+ }
12
+
13
+ exports.EmailVerificationError = EmailVerificationError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class EmailVerificationError extends DynamicError {
3
+ constructor(code: string);
4
+ }
@@ -0,0 +1,9 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class EmailVerificationError extends DynamicError {
4
+ constructor(code) {
5
+ super('EmailVerificationError', code);
6
+ }
7
+ }
8
+
9
+ export { EmailVerificationError };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class NoAccessError extends DynamicError.DynamicError {
8
+ constructor({ walletPublicKey, email, }) {
9
+ super('User does not have access');
10
+ this.email = email;
11
+ this.walletPublicKey = walletPublicKey;
12
+ }
13
+ }
14
+
15
+ exports.NoAccessError = NoAccessError;
@@ -0,0 +1,9 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class NoAccessError extends DynamicError {
3
+ walletPublicKey?: string;
4
+ email?: string;
5
+ constructor({ walletPublicKey, email, }: {
6
+ email?: string;
7
+ walletPublicKey?: string;
8
+ });
9
+ }
@@ -0,0 +1,11 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class NoAccessError extends DynamicError {
4
+ constructor({ walletPublicKey, email, }) {
5
+ super('User does not have access');
6
+ this.email = email;
7
+ this.walletPublicKey = walletPublicKey;
8
+ }
9
+ }
10
+
11
+ export { NoAccessError };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class NotSupportedError extends DynamicError.DynamicError {
8
+ }
9
+
10
+ exports.NotSupportedError = NotSupportedError;
@@ -0,0 +1,3 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class NotSupportedError extends DynamicError {
3
+ }
@@ -0,0 +1,6 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class NotSupportedError extends DynamicError {
4
+ }
5
+
6
+ export { NotSupportedError };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class UsernameAlreadyExistsError extends DynamicError.DynamicError {
8
+ constructor() {
9
+ super('Username already exists');
10
+ }
11
+ }
12
+
13
+ exports.UsernameAlreadyExistsError = UsernameAlreadyExistsError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class UsernameAlreadyExistsError extends DynamicError {
3
+ constructor();
4
+ }
@@ -0,0 +1,9 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class UsernameAlreadyExistsError extends DynamicError {
4
+ constructor() {
5
+ super('Username already exists');
6
+ }
7
+ }
8
+
9
+ export { UsernameAlreadyExistsError };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class WalletNotDeployedError extends DynamicError.DynamicError {
8
+ constructor() {
9
+ super('Wallet has not been deployed', 'wallet_not_deployed');
10
+ }
11
+ }
12
+
13
+ exports.WalletNotDeployedError = WalletNotDeployedError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class WalletNotDeployedError extends DynamicError {
3
+ constructor();
4
+ }
@@ -0,0 +1,9 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class WalletNotDeployedError extends DynamicError {
4
+ constructor() {
5
+ super('Wallet has not been deployed', 'wallet_not_deployed');
6
+ }
7
+ }
8
+
9
+ export { WalletNotDeployedError };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class WalletUsedError extends DynamicError.DynamicError {
8
+ constructor(code) {
9
+ super('WalletUsedError', code);
10
+ }
11
+ }
12
+
13
+ exports.WalletUsedError = WalletUsedError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class WalletUsedError extends DynamicError {
3
+ constructor(code: string);
4
+ }
@@ -0,0 +1,9 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class WalletUsedError extends DynamicError {
4
+ constructor(code) {
5
+ super('WalletUsedError', code);
6
+ }
7
+ }
8
+
9
+ export { WalletUsedError };
@@ -0,0 +1,10 @@
1
+ export * from './ChainalysisError';
2
+ export * from './CustomError';
3
+ export * from './DynamicError';
4
+ export * from './EmailAlreadyExistsError';
5
+ export * from './EmailVerificationError';
6
+ export * from './NoAccessError';
7
+ export * from './NotSupportedError';
8
+ export * from './UsernameAlreadyExistsError';
9
+ export * from './WalletNotDeployedError';
10
+ export * from './WalletUsedError';
package/src/index.cjs CHANGED
@@ -4,8 +4,30 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var parseChainId = require('./parseChainId.cjs');
6
6
  var parseEvmNetworks = require('./parseEvmNetworks.cjs');
7
+ var ChainalysisError = require('./errors/ChainalysisError.cjs');
8
+ var CustomError = require('./errors/CustomError.cjs');
9
+ var DynamicError = require('./errors/DynamicError.cjs');
10
+ var EmailAlreadyExistsError = require('./errors/EmailAlreadyExistsError.cjs');
11
+ var EmailVerificationError = require('./errors/EmailVerificationError.cjs');
12
+ var NoAccessError = require('./errors/NoAccessError.cjs');
13
+ var NotSupportedError = require('./errors/NotSupportedError.cjs');
14
+ var UsernameAlreadyExistsError = require('./errors/UsernameAlreadyExistsError.cjs');
15
+ var WalletNotDeployedError = require('./errors/WalletNotDeployedError.cjs');
16
+ var WalletUsedError = require('./errors/WalletUsedError.cjs');
17
+ var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
7
18
 
8
19
 
9
20
 
10
21
  exports.parseChainId = parseChainId.parseChainId;
11
22
  exports.parseEvmNetworks = parseEvmNetworks.parseEvmNetworks;
23
+ exports.ChainalysisError = ChainalysisError.ChainalysisError;
24
+ exports.CustomError = CustomError.CustomError;
25
+ exports.DynamicError = DynamicError.DynamicError;
26
+ exports.EmailAlreadyExistsError = EmailAlreadyExistsError.EmailAlreadyExistsError;
27
+ exports.EmailVerificationError = EmailVerificationError.EmailVerificationError;
28
+ exports.NoAccessError = NoAccessError.NoAccessError;
29
+ exports.NotSupportedError = NotSupportedError.NotSupportedError;
30
+ exports.UsernameAlreadyExistsError = UsernameAlreadyExistsError.UsernameAlreadyExistsError;
31
+ exports.WalletNotDeployedError = WalletNotDeployedError.WalletNotDeployedError;
32
+ exports.WalletUsedError = WalletUsedError.WalletUsedError;
33
+ exports.CancellablePromise = CancellablePromise.CancellablePromise;
package/src/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './parseChainId';
2
2
  export * from './parseEvmNetworks';
3
+ export * from './errors';
4
+ export * from './CancellablePromise';
package/src/index.js CHANGED
@@ -1,2 +1,13 @@
1
1
  export { parseChainId } from './parseChainId.js';
2
2
  export { parseEvmNetworks } from './parseEvmNetworks.js';
3
+ export { ChainalysisError } from './errors/ChainalysisError.js';
4
+ export { CustomError } from './errors/CustomError.js';
5
+ export { DynamicError } from './errors/DynamicError.js';
6
+ export { EmailAlreadyExistsError } from './errors/EmailAlreadyExistsError.js';
7
+ export { EmailVerificationError } from './errors/EmailVerificationError.js';
8
+ export { NoAccessError } from './errors/NoAccessError.js';
9
+ export { NotSupportedError } from './errors/NotSupportedError.js';
10
+ export { UsernameAlreadyExistsError } from './errors/UsernameAlreadyExistsError.js';
11
+ export { WalletNotDeployedError } from './errors/WalletNotDeployedError.js';
12
+ export { WalletUsedError } from './errors/WalletUsedError.js';
13
+ export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';