@dynamic-labs/client 2.0.0-alpha.29 → 2.0.0-alpha.31

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,28 @@
1
1
 
2
+ ## [2.0.0-alpha.31](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.30...v2.0.0-alpha.31) (2024-04-11)
3
+
4
+
5
+ ### Features
6
+
7
+ * support adding email for recovery to existing embedded wallet ([#5128](https://github.com/dynamic-labs/DynamicAuth/issues/5128)) ([477fd81](https://github.com/dynamic-labs/DynamicAuth/commit/477fd81ac00864284d9d2183c0b8c078a0a23a2b))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * issue where customer also tries to use i18n.init ([#5267](https://github.com/dynamic-labs/DynamicAuth/issues/5267)) ([7f81f1e](https://github.com/dynamic-labs/DynamicAuth/commit/7f81f1e010fbc6408f6a5d6a37608235e947befa))
13
+ * smart wallet not loading correctly upon refresh when using non-embedded eoa wallet ([#5301](https://github.com/dynamic-labs/DynamicAuth/issues/5301)) ([e957317](https://github.com/dynamic-labs/DynamicAuth/commit/e9573173f6209773a0be5f4af37323f2be8d7906))
14
+
15
+ ## [2.0.0-alpha.30](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.29...v2.0.0-alpha.30) (2024-04-11)
16
+
17
+
18
+ ### ⚠ BREAKING CHANGES
19
+
20
+ * add headless sms sign-in (#5274)
21
+
22
+ ### Features
23
+
24
+ * add headless sms sign-in ([#5274](https://github.com/dynamic-labs/DynamicAuth/issues/5274)) ([fffc293](https://github.com/dynamic-labs/DynamicAuth/commit/fffc293f85447a784e8c728d1586f3555ab1fbfa))
25
+
2
26
  ## [2.0.0-alpha.29](https://github.com/dynamic-labs/DynamicAuth/compare/v2.0.0-alpha.28...v2.0.0-alpha.29) (2024-04-10)
3
27
 
4
28
 
package/package.cjs CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "2.0.0-alpha.29";
5
+ var version = "2.0.0-alpha.31";
6
6
 
7
7
  exports.version = version;
package/package.js CHANGED
@@ -1,3 +1,3 @@
1
- var version = "2.0.0-alpha.29";
1
+ var version = "2.0.0-alpha.31";
2
2
 
3
3
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/client",
3
- "version": "2.0.0-alpha.29",
3
+ "version": "2.0.0-alpha.31",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -26,6 +26,8 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "peerDependencies": {
29
- "@dynamic-labs/message-transport": "2.0.0-alpha.29"
29
+ "@dynamic-labs/message-transport": "2.0.0-alpha.31",
30
+ "@dynamic-labs/types": "2.0.0-alpha.31",
31
+ "eventemitter3": "5.0.1"
30
32
  }
31
33
  }
@@ -2,7 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var authModule = require('../modules/authModule/authModule.cjs');
5
6
  var sdkModule = require('../modules/sdkModule/sdkModule.cjs');
7
+ var walletsModule = require('../modules/walletsModule/walletsModule.cjs');
6
8
  var Extendable = require('../utils/Extendable/Extendable.cjs');
7
9
  var core = require('./core/core.cjs');
8
10
 
@@ -17,8 +19,12 @@ const createClient = (props) => {
17
19
  const core$1 = core.createCore();
18
20
  const baseExtendable = new Extendable.Extendable(core$1);
19
21
  return baseExtendable.extend(() => ({
22
+ /** Module that gives access over authentication state, such as the auth token and user */
23
+ auth: authModule.createAuthModule(core$1),
20
24
  /** Module that gives insight over the state of the SDK */
21
25
  sdk: sdkModule.createSdkModule(core$1, props),
26
+ /** Module that provides access to user's wallets */
27
+ wallets: walletsModule.createWalletsModule(core$1),
22
28
  }));
23
29
  };
24
30
 
@@ -15,8 +15,12 @@ export type ClientProps = {
15
15
  * it will be used for.
16
16
  */
17
17
  export declare const createClient: (props: ClientProps) => {
18
- /** Module that gives insight over the state of the SDK */
19
- sdk: {
20
- readonly loaded: boolean;
18
+ /** Module that gives access over authentication state, such as the auth token and user */
19
+ auth: import("dist/packages/message-transport/src").StoreStateGetters<import("dist/packages/message-transport/src").AuthModuleState> & Pick<import("eventemitter3").EventEmitter<import("dist/packages/message-transport/src").AuthModuleMessages & import("dist/packages/message-transport/src").StoreStateEvents<import("dist/packages/message-transport/src").AuthModuleState>, any>, "on" | "off" | "once"> & {
20
+ logout: () => Promise<void>;
21
21
  };
22
+ /** Module that gives insight over the state of the SDK */
23
+ sdk: import("dist/packages/message-transport/src").StoreStateGetters<import("dist/packages/message-transport/src").SdkModuleState>;
24
+ /** Module that provides access to user's wallets */
25
+ wallets: import("dist/packages/message-transport/src").StoreStateGetters<import("dist/packages/message-transport/src").WalletsModuleState> & Pick<import("eventemitter3").EventEmitter<import("dist/packages/message-transport/src").StoreStateEvents<import("dist/packages/message-transport/src").WalletsModuleState>, any>, "on" | "off" | "once">;
22
26
  } & Extendable;
@@ -1,4 +1,6 @@
1
+ import { createAuthModule } from '../modules/authModule/authModule.js';
1
2
  import { createSdkModule } from '../modules/sdkModule/sdkModule.js';
3
+ import { createWalletsModule } from '../modules/walletsModule/walletsModule.js';
2
4
  import { Extendable } from '../utils/Extendable/Extendable.js';
3
5
  import { createCore } from './core/core.js';
4
6
 
@@ -13,8 +15,12 @@ const createClient = (props) => {
13
15
  const core = createCore();
14
16
  const baseExtendable = new Extendable(core);
15
17
  return baseExtendable.extend(() => ({
18
+ /** Module that gives access over authentication state, such as the auth token and user */
19
+ auth: createAuthModule(core),
16
20
  /** Module that gives insight over the state of the SDK */
17
21
  sdk: createSdkModule(core, props),
22
+ /** Module that provides access to user's wallets */
23
+ wallets: createWalletsModule(core),
18
24
  }));
19
25
  };
20
26
 
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var messageTransport = require('@dynamic-labs/message-transport');
6
+ var pickListenerActions = require('../../utils/pickListenerActions/pickListenerActions.cjs');
7
+
8
+ const createAuthModule = (core) => {
9
+ const store = messageTransport.createStore({
10
+ initialState: {
11
+ authToken: null,
12
+ authenticatedUser: null,
13
+ },
14
+ key: 'auth',
15
+ messageTransport: core.messageTransport,
16
+ });
17
+ const messageEvents = messageTransport.createEventEmitterForMessages({
18
+ initialEventEmitter: store.eventEmitter,
19
+ key: 'auth',
20
+ messageTransport: core.messageTransport,
21
+ });
22
+ const requestChannel = messageTransport.createRequestChannel(core.messageTransport);
23
+ return Object.assign(store.getters, pickListenerActions.pickListenerActions(messageEvents), {
24
+ logout: () => requestChannel.request('logout'),
25
+ });
26
+ };
27
+
28
+ exports.createAuthModule = createAuthModule;
@@ -0,0 +1,6 @@
1
+ import { AuthModuleMessages, AuthModuleState } from '@dynamic-labs/message-transport';
2
+ import { Core } from '../../client/core';
3
+ export type AuthModule = ReturnType<typeof createAuthModule>;
4
+ export declare const createAuthModule: (core: Core) => import("@dynamic-labs/message-transport").StoreStateGetters<AuthModuleState> & Pick<import("eventemitter3").EventEmitter<AuthModuleMessages & import("@dynamic-labs/message-transport").StoreStateEvents<AuthModuleState>, any>, "on" | "off" | "once"> & {
5
+ logout: () => Promise<void>;
6
+ };
@@ -0,0 +1,24 @@
1
+ import { createStore, createEventEmitterForMessages, createRequestChannel } from '@dynamic-labs/message-transport';
2
+ import { pickListenerActions } from '../../utils/pickListenerActions/pickListenerActions.js';
3
+
4
+ const createAuthModule = (core) => {
5
+ const store = createStore({
6
+ initialState: {
7
+ authToken: null,
8
+ authenticatedUser: null,
9
+ },
10
+ key: 'auth',
11
+ messageTransport: core.messageTransport,
12
+ });
13
+ const messageEvents = createEventEmitterForMessages({
14
+ initialEventEmitter: store.eventEmitter,
15
+ key: 'auth',
16
+ messageTransport: core.messageTransport,
17
+ });
18
+ const requestChannel = createRequestChannel(core.messageTransport);
19
+ return Object.assign(store.getters, pickListenerActions(messageEvents), {
20
+ logout: () => requestChannel.request('logout'),
21
+ });
22
+ };
23
+
24
+ export { createAuthModule };
@@ -0,0 +1 @@
1
+ export * from './authModule';
@@ -8,18 +8,15 @@ var manifest = require('./manifest/manifest.cjs');
8
8
 
9
9
  const createSdkModule = (core, props) => {
10
10
  const requestChannel = messageTransport.createRequestChannel(core.messageTransport);
11
- const state = {
12
- loaded: false,
13
- };
14
11
  requestChannel.handle('manifest', () => _tslib.__awaiter(void 0, void 0, void 0, function* () { return manifest.createManifest(props); }));
15
- // This will soon have to change. After we implement th store abstraction
16
- // in the message transport package, we should use it here.
17
- requestChannel.handle('loaded', () => (state.loaded = true));
18
- return {
19
- get loaded() {
20
- return state.loaded;
12
+ const store = messageTransport.createStore({
13
+ initialState: {
14
+ loaded: false,
21
15
  },
22
- };
16
+ key: 'sdk',
17
+ messageTransport: core.messageTransport,
18
+ });
19
+ return store.getters;
23
20
  };
24
21
 
25
22
  exports.createSdkModule = createSdkModule;
@@ -1,5 +1,4 @@
1
+ import { SdkModuleState } from '@dynamic-labs/message-transport';
1
2
  import type { ClientProps } from '../../client';
2
3
  import { Core } from '../../client/core';
3
- export declare const createSdkModule: (core: Core, props: ClientProps) => {
4
- readonly loaded: boolean;
5
- };
4
+ export declare const createSdkModule: (core: Core, props: ClientProps) => import("@dynamic-labs/message-transport").StoreStateGetters<SdkModuleState>;
@@ -1,21 +1,18 @@
1
1
  import { __awaiter } from '../../../_virtual/_tslib.js';
2
- import { createRequestChannel } from '@dynamic-labs/message-transport';
2
+ import { createRequestChannel, createStore } from '@dynamic-labs/message-transport';
3
3
  import { createManifest } from './manifest/manifest.js';
4
4
 
5
5
  const createSdkModule = (core, props) => {
6
6
  const requestChannel = createRequestChannel(core.messageTransport);
7
- const state = {
8
- loaded: false,
9
- };
10
7
  requestChannel.handle('manifest', () => __awaiter(void 0, void 0, void 0, function* () { return createManifest(props); }));
11
- // This will soon have to change. After we implement th store abstraction
12
- // in the message transport package, we should use it here.
13
- requestChannel.handle('loaded', () => (state.loaded = true));
14
- return {
15
- get loaded() {
16
- return state.loaded;
8
+ const store = createStore({
9
+ initialState: {
10
+ loaded: false,
17
11
  },
18
- };
12
+ key: 'sdk',
13
+ messageTransport: core.messageTransport,
14
+ });
15
+ return store.getters;
19
16
  };
20
17
 
21
18
  export { createSdkModule };
@@ -0,0 +1 @@
1
+ export * from './walletsModule';
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var messageTransport = require('@dynamic-labs/message-transport');
6
+ var pickListenerActions = require('../../utils/pickListenerActions/pickListenerActions.cjs');
7
+
8
+ const createWalletsModule = (core) => {
9
+ const store = messageTransport.createStore({
10
+ initialState: { primary: undefined, userWallets: [] },
11
+ key: 'wallets',
12
+ messageTransport: core.messageTransport,
13
+ });
14
+ return Object.assign(store.getters, pickListenerActions.pickListenerActions(store.eventEmitter));
15
+ };
16
+
17
+ exports.createWalletsModule = createWalletsModule;
@@ -0,0 +1,4 @@
1
+ import { WalletsModuleState } from '@dynamic-labs/message-transport';
2
+ import { Core } from '../../client/core';
3
+ export type WalletsModule = ReturnType<typeof createWalletsModule>;
4
+ export declare const createWalletsModule: (core: Core) => import("@dynamic-labs/message-transport").StoreStateGetters<WalletsModuleState> & Pick<import("eventemitter3").EventEmitter<import("@dynamic-labs/message-transport").StoreStateEvents<WalletsModuleState>, any>, "on" | "off" | "once">;
@@ -0,0 +1,13 @@
1
+ import { createStore } from '@dynamic-labs/message-transport';
2
+ import { pickListenerActions } from '../../utils/pickListenerActions/pickListenerActions.js';
3
+
4
+ const createWalletsModule = (core) => {
5
+ const store = createStore({
6
+ initialState: { primary: undefined, userWallets: [] },
7
+ key: 'wallets',
8
+ messageTransport: core.messageTransport,
9
+ });
10
+ return Object.assign(store.getters, pickListenerActions(store.eventEmitter));
11
+ };
12
+
13
+ export { createWalletsModule };
@@ -0,0 +1 @@
1
+ export * from './pickListenerActions';
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * This only serves to limit the methods of an event emitter to
7
+ * only the ones necessary for event listening
8
+ */
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ const pickListenerActions = (emitter) => ({
11
+ off: emitter.off.bind(emitter),
12
+ on: emitter.on.bind(emitter),
13
+ once: emitter.once.bind(emitter),
14
+ });
15
+
16
+ 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,12 @@
1
+ /**
2
+ * This only serves to limit the methods of an event emitter to
3
+ * only the ones necessary for event listening
4
+ */
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ const pickListenerActions = (emitter) => ({
7
+ off: emitter.off.bind(emitter),
8
+ on: emitter.on.bind(emitter),
9
+ once: emitter.once.bind(emitter),
10
+ });
11
+
12
+ export { pickListenerActions };