@dynamic-labs/client 0.0.0-exp20240808.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +3746 -0
  2. package/LICENSE +21 -0
  3. package/README.md +3 -0
  4. package/_virtual/_tslib.cjs +36 -0
  5. package/_virtual/_tslib.js +32 -0
  6. package/package.cjs +8 -0
  7. package/package.js +4 -0
  8. package/package.json +37 -0
  9. package/src/client/client.cjs +43 -0
  10. package/src/client/client.d.ts +29 -0
  11. package/src/client/client.js +38 -0
  12. package/src/client/core/core.cjs +50 -0
  13. package/src/client/core/core.d.ts +44 -0
  14. package/src/client/core/core.js +46 -0
  15. package/src/client/core/index.d.ts +1 -0
  16. package/src/client/core/modules/initializationModule/index.d.ts +1 -0
  17. package/src/client/core/modules/initializationModule/initializationModule.cjs +33 -0
  18. package/src/client/core/modules/initializationModule/initializationModule.d.ts +6 -0
  19. package/src/client/core/modules/initializationModule/initializationModule.js +29 -0
  20. package/src/client/core/modules/manifestModule/createPartialManifest/createPartialManifest.cjs +17 -0
  21. package/src/client/core/modules/manifestModule/createPartialManifest/createPartialManifest.d.ts +3 -0
  22. package/src/client/core/modules/manifestModule/createPartialManifest/createPartialManifest.js +13 -0
  23. package/src/client/core/modules/manifestModule/createPartialManifest/index.d.ts +1 -0
  24. package/src/client/core/modules/manifestModule/index.d.ts +1 -0
  25. package/src/client/core/modules/manifestModule/manifestModule.cjs +36 -0
  26. package/src/client/core/modules/manifestModule/manifestModule.d.ts +11 -0
  27. package/src/client/core/modules/manifestModule/manifestModule.js +32 -0
  28. package/src/client/core/modules/manifestModule/validateManifest/index.d.ts +1 -0
  29. package/src/client/core/modules/manifestModule/validateManifest/validateManifest.cjs +31 -0
  30. package/src/client/core/modules/manifestModule/validateManifest/validateManifest.d.ts +14 -0
  31. package/src/client/core/modules/manifestModule/validateManifest/validateManifest.js +26 -0
  32. package/src/client/index.d.ts +1 -0
  33. package/src/index.cjs +15 -0
  34. package/src/index.d.ts +9 -0
  35. package/src/index.js +4 -0
  36. package/src/modules/authModule/authModule.cjs +37 -0
  37. package/src/modules/authModule/authModule.d.ts +15 -0
  38. package/src/modules/authModule/authModule.js +33 -0
  39. package/src/modules/authModule/emailAuthModule/emailAuthModule.cjs +20 -0
  40. package/src/modules/authModule/emailAuthModule/emailAuthModule.d.ts +8 -0
  41. package/src/modules/authModule/emailAuthModule/emailAuthModule.js +16 -0
  42. package/src/modules/authModule/emailAuthModule/index.d.ts +1 -0
  43. package/src/modules/authModule/externalAuthModule/externalAuthModule.cjs +16 -0
  44. package/src/modules/authModule/externalAuthModule/externalAuthModule.d.ts +7 -0
  45. package/src/modules/authModule/externalAuthModule/externalAuthModule.js +12 -0
  46. package/src/modules/authModule/externalAuthModule/index.d.ts +1 -0
  47. package/src/modules/authModule/index.d.ts +1 -0
  48. package/src/modules/authModule/smsAuthModule/index.d.ts +1 -0
  49. package/src/modules/authModule/smsAuthModule/smsAuthModule.cjs +17 -0
  50. package/src/modules/authModule/smsAuthModule/smsAuthModule.d.ts +9 -0
  51. package/src/modules/authModule/smsAuthModule/smsAuthModule.js +13 -0
  52. package/src/modules/authModule/socialAuthModule/index.d.ts +1 -0
  53. package/src/modules/authModule/socialAuthModule/socialAuthModule.cjs +14 -0
  54. package/src/modules/authModule/socialAuthModule/socialAuthModule.d.ts +6 -0
  55. package/src/modules/authModule/socialAuthModule/socialAuthModule.js +10 -0
  56. package/src/modules/networksModule/index.d.ts +1 -0
  57. package/src/modules/networksModule/networksModule.cjs +18 -0
  58. package/src/modules/networksModule/networksModule.d.ts +3 -0
  59. package/src/modules/networksModule/networksModule.js +14 -0
  60. package/src/modules/sdkModule/index.d.ts +1 -0
  61. package/src/modules/sdkModule/sdkModule.cjs +24 -0
  62. package/src/modules/sdkModule/sdkModule.d.ts +6 -0
  63. package/src/modules/sdkModule/sdkModule.js +20 -0
  64. package/src/modules/userInterfaceModule/index.d.ts +1 -0
  65. package/src/modules/userInterfaceModule/userInterfaceModule.cjs +23 -0
  66. package/src/modules/userInterfaceModule/userInterfaceModule.d.ts +14 -0
  67. package/src/modules/userInterfaceModule/userInterfaceModule.js +19 -0
  68. package/src/modules/walletsModule/embeddedWalletsModule/embeddedWalletsModule.cjs +29 -0
  69. package/src/modules/walletsModule/embeddedWalletsModule/embeddedWalletsModule.d.ts +6 -0
  70. package/src/modules/walletsModule/embeddedWalletsModule/embeddedWalletsModule.js +25 -0
  71. package/src/modules/walletsModule/embeddedWalletsModule/index.d.ts +1 -0
  72. package/src/modules/walletsModule/index.d.ts +1 -0
  73. package/src/modules/walletsModule/walletsModule.cjs +32 -0
  74. package/src/modules/walletsModule/walletsModule.d.ts +12 -0
  75. package/src/modules/walletsModule/walletsModule.js +28 -0
  76. package/src/utils/Extendable/Extendable.cjs +29 -0
  77. package/src/utils/Extendable/Extendable.d.ts +25 -0
  78. package/src/utils/Extendable/Extendable.js +25 -0
  79. package/src/utils/Extendable/deepMerge/deepMergeInto.cjs +26 -0
  80. package/src/utils/Extendable/deepMerge/deepMergeInto.d.ts +6 -0
  81. package/src/utils/Extendable/deepMerge/deepMergeInto.js +22 -0
  82. package/src/utils/Extendable/deepMerge/index.d.ts +1 -0
  83. package/src/utils/Extendable/hasExtension/hasExtension.cjs +14 -0
  84. package/src/utils/Extendable/hasExtension/hasExtension.d.ts +9 -0
  85. package/src/utils/Extendable/hasExtension/hasExtension.js +10 -0
  86. package/src/utils/Extendable/hasExtension/index.d.ts +1 -0
  87. package/src/utils/Extendable/index.d.ts +1 -0
  88. package/src/utils/addProperty/addProperty.cjs +21 -0
  89. package/src/utils/addProperty/addProperty.d.ts +13 -0
  90. package/src/utils/addProperty/addProperty.js +17 -0
  91. package/src/utils/addProperty/index.d.ts +1 -0
  92. package/src/utils/logger/index.d.ts +1 -0
  93. package/src/utils/logger/logger.cjs +10 -0
  94. package/src/utils/logger/logger.d.ts +2 -0
  95. package/src/utils/logger/logger.js +6 -0
  96. package/src/utils/pickListenerActions/index.d.ts +1 -0
  97. package/src/utils/pickListenerActions/pickListenerActions.cjs +17 -0
  98. package/src/utils/pickListenerActions/pickListenerActions.d.ts +6 -0
  99. package/src/utils/pickListenerActions/pickListenerActions.js +13 -0
@@ -0,0 +1,28 @@
1
+ 'use client'
2
+ import { createRequestChannel, createStore } from '@dynamic-labs/message-transport';
3
+ import { pickListenerActions } from '../../utils/pickListenerActions/pickListenerActions.js';
4
+ import { createEmbeddedWalletsModule } from './embeddedWalletsModule/embeddedWalletsModule.js';
5
+
6
+ const createWalletsModule = (core) => {
7
+ const requestChannel = createRequestChannel(core.messageTransport);
8
+ const store = createStore({
9
+ initialState: { primary: undefined, userWallets: [] },
10
+ key: 'wallets',
11
+ messageTransport: core.messageTransport,
12
+ });
13
+ const signMessage = (params) => requestChannel.request('signMessage', params);
14
+ const getBalance = (params) => requestChannel.request('getBalance', params);
15
+ const switchNetwork = (params) => requestChannel.request('switchNetwork', params);
16
+ const getNetwork = (params) => requestChannel.request('getNetwork', params);
17
+ const setPrimary = (params) => requestChannel.request('setPrimary', params);
18
+ return Object.assign(store.getters, pickListenerActions(store.eventEmitter), {
19
+ embedded: createEmbeddedWalletsModule(core),
20
+ getBalance,
21
+ getNetwork,
22
+ setPrimary,
23
+ signMessage,
24
+ switchNetwork,
25
+ });
26
+ };
27
+
28
+ export { createWalletsModule };
@@ -0,0 +1,29 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var deepMergeInto = require('./deepMerge/deepMergeInto.cjs');
7
+
8
+ // Class here is necessary to have access to "this" keyword
9
+ /**
10
+ * An object that can be extended.
11
+ *
12
+ * To extend here means to add or replace the existing properties of this object,
13
+ * as well as kicking off any related procedures. Like a structure on which you can
14
+ * attach lego bricks.
15
+ *
16
+ * Ex: a { movie: "Up" } object can be extended by adding an audienceScore
17
+ * property to it, and kicking off an api call that will constantly update this property from
18
+ * an IMDb api.
19
+ */
20
+ class Extendable {
21
+ constructor(core) {
22
+ this.core = core;
23
+ }
24
+ extend(extension) {
25
+ return deepMergeInto.deepMergeInto(this, extension(this, this.core));
26
+ }
27
+ }
28
+
29
+ exports.Extendable = Extendable;
@@ -0,0 +1,25 @@
1
+ import { Core } from '../../client/core';
2
+ /**
3
+ * Allows extending properties and methods of an Extendable
4
+ */
5
+ export type Extension<T extends Record<string, unknown>> = (
6
+ /** The extendable object to which this extension will be applied */
7
+ extendable: Extendable,
8
+ /** An object with internal properties and methods not publicly accessible */
9
+ core: Core) => T;
10
+ /**
11
+ * An object that can be extended.
12
+ *
13
+ * To extend here means to add or replace the existing properties of this object,
14
+ * as well as kicking off any related procedures. Like a structure on which you can
15
+ * attach lego bricks.
16
+ *
17
+ * Ex: a { movie: "Up" } object can be extended by adding an audienceScore
18
+ * property to it, and kicking off an api call that will constantly update this property from
19
+ * an IMDb api.
20
+ */
21
+ export declare class Extendable {
22
+ private readonly core;
23
+ constructor(core: Core);
24
+ extend<T extends Record<string, unknown>>(extension: Extension<T>): T & typeof this;
25
+ }
@@ -0,0 +1,25 @@
1
+ 'use client'
2
+ import { deepMergeInto } from './deepMerge/deepMergeInto.js';
3
+
4
+ // Class here is necessary to have access to "this" keyword
5
+ /**
6
+ * An object that can be extended.
7
+ *
8
+ * To extend here means to add or replace the existing properties of this object,
9
+ * as well as kicking off any related procedures. Like a structure on which you can
10
+ * attach lego bricks.
11
+ *
12
+ * Ex: a { movie: "Up" } object can be extended by adding an audienceScore
13
+ * property to it, and kicking off an api call that will constantly update this property from
14
+ * an IMDb api.
15
+ */
16
+ class Extendable {
17
+ constructor(core) {
18
+ this.core = core;
19
+ }
20
+ extend(extension) {
21
+ return deepMergeInto(this, extension(this, this.core));
22
+ }
23
+ }
24
+
25
+ export { Extendable };
@@ -0,0 +1,26 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /** Performs a deep merge into obj1 */
7
+ const deepMergeInto = (obj1, obj2) => {
8
+ // Merge obj2 into obj1, recursively if the property is an object
9
+ for (const key in obj2) {
10
+ if (!Object.prototype.hasOwnProperty.call(obj2, key))
11
+ continue;
12
+ // If key exists in obj1 and both are objects, recurse
13
+ if (Object.prototype.hasOwnProperty.call(obj1, key) &&
14
+ typeof obj1[key] === 'object' &&
15
+ typeof obj2[key] === 'object') {
16
+ obj1[key] = deepMergeInto(obj1[key], obj2[key]);
17
+ }
18
+ else {
19
+ // Otherwise, just overwrite/add the property from obj2
20
+ obj1[key] = obj2[key];
21
+ }
22
+ }
23
+ return obj1;
24
+ };
25
+
26
+ exports.deepMergeInto = deepMergeInto;
@@ -0,0 +1,6 @@
1
+ type GenericObject = {
2
+ [key: string]: any;
3
+ };
4
+ /** Performs a deep merge into obj1 */
5
+ export declare const deepMergeInto: <T extends GenericObject>(obj1: GenericObject, obj2: GenericObject) => T;
6
+ export {};
@@ -0,0 +1,22 @@
1
+ 'use client'
2
+ /** Performs a deep merge into obj1 */
3
+ const deepMergeInto = (obj1, obj2) => {
4
+ // Merge obj2 into obj1, recursively if the property is an object
5
+ for (const key in obj2) {
6
+ if (!Object.prototype.hasOwnProperty.call(obj2, key))
7
+ continue;
8
+ // If key exists in obj1 and both are objects, recurse
9
+ if (Object.prototype.hasOwnProperty.call(obj1, key) &&
10
+ typeof obj1[key] === 'object' &&
11
+ typeof obj2[key] === 'object') {
12
+ obj1[key] = deepMergeInto(obj1[key], obj2[key]);
13
+ }
14
+ else {
15
+ // Otherwise, just overwrite/add the property from obj2
16
+ obj1[key] = obj2[key];
17
+ }
18
+ }
19
+ return obj1;
20
+ };
21
+
22
+ export { deepMergeInto };
@@ -0,0 +1 @@
1
+ export * from './deepMergeInto';
@@ -0,0 +1,14 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * This method allows safely type casting an Extendable object to include an extension type.
8
+ *
9
+ * It assumes you are checking if the target extension has declared its name to the core,
10
+ * and if that name is found in core's declaredExtensionNames, it will complete the type cast.
11
+ */
12
+ const hasExtension = (extendable, core, extensionName) => core.declaredExtensionNames.includes(extensionName);
13
+
14
+ exports.hasExtension = hasExtension;
@@ -0,0 +1,9 @@
1
+ import { Extendable } from '..';
2
+ import { Core } from '../../..';
3
+ /**
4
+ * This method allows safely type casting an Extendable object to include an extension type.
5
+ *
6
+ * It assumes you are checking if the target extension has declared its name to the core,
7
+ * and if that name is found in core's declaredExtensionNames, it will complete the type cast.
8
+ */
9
+ export declare const hasExtension: <T>(extendable: Extendable, core: Core, extensionName: string) => extendable is Extendable & T;
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ /**
3
+ * This method allows safely type casting an Extendable object to include an extension type.
4
+ *
5
+ * It assumes you are checking if the target extension has declared its name to the core,
6
+ * and if that name is found in core's declaredExtensionNames, it will complete the type cast.
7
+ */
8
+ const hasExtension = (extendable, core, extensionName) => core.declaredExtensionNames.includes(extensionName);
9
+
10
+ export { hasExtension };
@@ -0,0 +1 @@
1
+ export { hasExtension } from './hasExtension';
@@ -0,0 +1 @@
1
+ export * from './Extendable';
@@ -0,0 +1,21 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * Adds a new property to an object with a specified key and value.
8
+ * @template T - The type of the object.
9
+ * @param {T} obj - The object to add the property to.
10
+ * @param {string} key - The key of the new property.
11
+ * @param {PropertyDescriptor} descriptor - The property descriptor.
12
+ * @returns {T & Record<K, V>} The object with the added property.
13
+ * @template K - The key type.
14
+ * @template V - The value type.
15
+ */
16
+ const addProperty = (obj, key, descriptor) => {
17
+ Object.defineProperty(obj, key, descriptor);
18
+ return obj;
19
+ };
20
+
21
+ exports.addProperty = addProperty;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Adds a new property to an object with a specified key and value.
3
+ * @template T - The type of the object.
4
+ * @param {T} obj - The object to add the property to.
5
+ * @param {string} key - The key of the new property.
6
+ * @param {PropertyDescriptor} descriptor - The property descriptor.
7
+ * @returns {T & Record<K, V>} The object with the added property.
8
+ * @template K - The key type.
9
+ * @template V - The value type.
10
+ */
11
+ export declare const addProperty: <T extends object, K extends string, V>(obj: T, key: K, descriptor: {
12
+ get: () => V;
13
+ }) => T & Record<K, V>;
@@ -0,0 +1,17 @@
1
+ 'use client'
2
+ /**
3
+ * Adds a new property to an object with a specified key and value.
4
+ * @template T - The type of the object.
5
+ * @param {T} obj - The object to add the property to.
6
+ * @param {string} key - The key of the new property.
7
+ * @param {PropertyDescriptor} descriptor - The property descriptor.
8
+ * @returns {T & Record<K, V>} The object with the added property.
9
+ * @template K - The key type.
10
+ * @template V - The value type.
11
+ */
12
+ const addProperty = (obj, key, descriptor) => {
13
+ Object.defineProperty(obj, key, descriptor);
14
+ return obj;
15
+ };
16
+
17
+ export { addProperty };
@@ -0,0 +1 @@
1
+ export { addProperty } from './addProperty';
@@ -0,0 +1 @@
1
+ export { logger } from './logger';
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var logger$1 = require('@dynamic-labs/logger');
7
+
8
+ const logger = new logger$1.Logger('@dynamic-labs/client');
9
+
10
+ exports.logger = logger;
@@ -0,0 +1,2 @@
1
+ import { Logger } from '@dynamic-labs/logger';
2
+ export declare const logger: Logger;
@@ -0,0 +1,6 @@
1
+ 'use client'
2
+ import { Logger } from '@dynamic-labs/logger';
3
+
4
+ const logger = new Logger('@dynamic-labs/client');
5
+
6
+ export { logger };
@@ -0,0 +1 @@
1
+ export * from './pickListenerActions';
@@ -0,0 +1,17 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ /**
7
+ * This only serves to limit the methods of an event emitter to
8
+ * only the ones necessary for event listening
9
+ */
10
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
+ const pickListenerActions = (emitter) => ({
12
+ off: emitter.off.bind(emitter),
13
+ on: emitter.on.bind(emitter),
14
+ once: emitter.once.bind(emitter),
15
+ });
16
+
17
+ exports.pickListenerActions = pickListenerActions;
@@ -0,0 +1,6 @@
1
+ import EventEmitter from 'eventemitter3';
2
+ /**
3
+ * This only serves to limit the methods of an event emitter to
4
+ * only the ones necessary for event listening
5
+ */
6
+ export declare const pickListenerActions: <T extends EventEmitter<any, any>>(emitter: T) => Pick<T, 'on' | 'off' | 'once'>;
@@ -0,0 +1,13 @@
1
+ 'use client'
2
+ /**
3
+ * This only serves to limit the methods of an event emitter to
4
+ * only the ones necessary for event listening
5
+ */
6
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+ const pickListenerActions = (emitter) => ({
8
+ off: emitter.off.bind(emitter),
9
+ on: emitter.on.bind(emitter),
10
+ once: emitter.once.bind(emitter),
11
+ });
12
+
13
+ export { pickListenerActions };