@dynamic-labs/client
Advanced tools
Comparing version 4.0.0-alpha.7 to 4.0.0-alpha.8
'use client' | ||
var version = "4.0.0-alpha.7"; | ||
var version = "4.0.0-alpha.8"; | ||
export { version }; |
{ | ||
"name": "@dynamic-labs/client", | ||
"version": "4.0.0-alpha.7", | ||
"version": "4.0.0-alpha.8", | ||
"description": "Core package for utilizing Dynamic's sdk", | ||
@@ -22,6 +22,6 @@ "author": "Dynamic Labs, Inc.", | ||
"@vue/reactivity": "3.4.21", | ||
"@dynamic-labs/assert-package-version": "4.0.0-alpha.7", | ||
"@dynamic-labs/logger": "4.0.0-alpha.7", | ||
"@dynamic-labs/message-transport": "4.0.0-alpha.7", | ||
"@dynamic-labs/types": "4.0.0-alpha.7", | ||
"@dynamic-labs/assert-package-version": "4.0.0-alpha.8", | ||
"@dynamic-labs/logger": "4.0.0-alpha.8", | ||
"@dynamic-labs/message-transport": "4.0.0-alpha.8", | ||
"@dynamic-labs/types": "4.0.0-alpha.8", | ||
"eventemitter3": "5.0.1" | ||
@@ -28,0 +28,0 @@ }, |
@@ -22,3 +22,3 @@ import { Extendable } from '../utils/Extendable'; | ||
/** Module that provides all the networks configured */ | ||
networks: import("dist/packages/message-transport/src").StoreStateGetters<import("dist/packages/message-transport/src").NetworksModuleState> & Pick<import("eventemitter3").EventEmitter<import("dist/packages/message-transport/src").StoreStateEvents<import("dist/packages/message-transport/src").NetworksModuleState>, any>, "on" | "off" | "once">; | ||
networks: import("dist/packages/message-transport/src").StoreStateGetters<import("dist/packages/message-transport/src").NetworksModuleState> & import("dist/packages/message-transport/src").PickedEventListeners<import("dist/packages/message-transport/src").StoreStateEvents<import("dist/packages/message-transport/src").NetworksModuleState>>; | ||
/** Module that gives insight over the state of the SDK */ | ||
@@ -25,0 +25,0 @@ sdk: import("../modules/sdkModule").SdkModule; |
@@ -1,2 +0,3 @@ | ||
import { AuthModuleMessages, AuthModuleState, StoreEventListeners } from '@dynamic-labs/message-transport'; | ||
import { AuthModuleMessages, AuthModuleState, StoreEventListeners, PickedEventListeners, authEventNames } from '@dynamic-labs/message-transport'; | ||
import { UserProfile } from '@dynamic-labs/types'; | ||
import { Core } from '../../client/core'; | ||
@@ -7,4 +8,4 @@ import { EmailAuthModule } from './emailAuthModule'; | ||
import { SocialAuthModule } from './socialAuthModule'; | ||
type PublicAuthModuleMessages = Pick<AuthModuleMessages, 'logout'>; | ||
export type AuthModule = AuthModuleState & StoreEventListeners<AuthModuleState> & PublicAuthModuleMessages & { | ||
type PublicAuthModuleMessages = Pick<AuthModuleMessages, typeof authEventNames[number]>; | ||
export type AuthModule = AuthModuleState & StoreEventListeners<AuthModuleState> & PickedEventListeners<PublicAuthModuleMessages> & { | ||
sms: SmsAuthModule; | ||
@@ -14,4 +15,8 @@ email: EmailAuthModule; | ||
external: ExternalAuthModule; | ||
logout: AuthModuleMessages['logout']; | ||
setHandler: (name: 'userAuthenticated', handler: AuthenticatedUserHandler) => void; | ||
clearHandler: (name: 'userAuthenticated') => void; | ||
}; | ||
type AuthenticatedUserHandler = (user: UserProfile) => Promise<void>; | ||
export declare const createAuthModule: (core: Core) => AuthModule; | ||
export {}; |
'use client' | ||
import { createStore, createEventEmitterForMessages, createRequestChannel } from '@dynamic-labs/message-transport'; | ||
import { createStore, createEventEmitterForMessages, authEventNames, createRequestChannel } from '@dynamic-labs/message-transport'; | ||
import { pickListenerActions } from '../../utils/pickListenerActions/pickListenerActions.js'; | ||
@@ -9,2 +9,3 @@ import { createEmailAuthModule } from './emailAuthModule/emailAuthModule.js'; | ||
const defaultAuthenticatedUserHandler = () => Promise.resolve(); | ||
const createAuthModule = (core) => { | ||
@@ -20,11 +21,17 @@ const store = createStore({ | ||
const messageEvents = createEventEmitterForMessages({ | ||
eventNames: authEventNames, | ||
initialEventEmitter: store.eventEmitter, | ||
key: 'auth', | ||
messageTransport: core.messageTransport, | ||
}); | ||
const requestChannel = createRequestChannel(core.messageTransport); | ||
const handlers = { | ||
userAuthenticated: defaultAuthenticatedUserHandler, | ||
}; | ||
requestChannel.handle('handleAuthenticatedUser', ({ user }) => handlers.userAuthenticated(user)); | ||
return Object.assign(store.getters, pickListenerActions(messageEvents), { | ||
clearHandler: () => (handlers.userAuthenticated = defaultAuthenticatedUserHandler), | ||
email: createEmailAuthModule(core), | ||
external: createExternalAuthModule(core), | ||
logout: () => requestChannel.request('logout'), | ||
setHandler: (_, handler) => (handlers.userAuthenticated = handler), | ||
sms: createSmsAuthModule(core), | ||
@@ -31,0 +38,0 @@ social: createSocialAuthModule(core), |
@@ -1,4 +0,4 @@ | ||
import { OtpMessages } from '@dynamic-labs/message-transport'; | ||
import { OtpMessages, PickedEventListeners, emailEventNames } from '@dynamic-labs/message-transport'; | ||
import { Core } from '../../../client/core'; | ||
export type EmailAuthModule = { | ||
export type EmailAuthModule = PickedEventListeners<PublicEmailAuthMessages> & { | ||
resendOTP: OtpMessages['resendOTP']; | ||
@@ -8,2 +8,3 @@ sendOTP: (email: string) => Promise<void>; | ||
}; | ||
export type PublicEmailAuthMessages = Pick<OtpMessages, typeof emailEventNames[number]>; | ||
export declare const createEmailAuthModule: (core: Core) => EmailAuthModule; |
'use client' | ||
import { createRequestChannel } from '@dynamic-labs/message-transport'; | ||
import { createRequestChannel, createEventEmitterForMessages, emailEventNames } from '@dynamic-labs/message-transport'; | ||
import { pickListenerActions } from '../../../utils/pickListenerActions/pickListenerActions.js'; | ||
const createEmailAuthModule = (core) => { | ||
const requestChannel = createRequestChannel(core.messageTransport); | ||
return { | ||
const messageEvents = createEventEmitterForMessages({ | ||
eventNames: emailEventNames, | ||
messageTransport: core.messageTransport, | ||
}); | ||
return Object.assign(pickListenerActions(messageEvents), { | ||
resendOTP: () => requestChannel.request('resendOTP'), | ||
@@ -13,5 +18,5 @@ sendOTP: (email) => requestChannel.request('sendOTP', { | ||
verifyOTP: (token) => requestChannel.request('verifyOTP', token), | ||
}; | ||
}); | ||
}; | ||
export { createEmailAuthModule }; |
import { PhoneData } from '@dynamic-labs/types'; | ||
import { OtpMessages } from '@dynamic-labs/message-transport'; | ||
import { OtpMessages, PickedEventListeners, smsEventNames } from '@dynamic-labs/message-transport'; | ||
import { Core } from '../../../client/core'; | ||
export type SmsAuthModule = { | ||
export type SmsAuthModule = PickedEventListeners<PublicSmsAuthMessages> & { | ||
resendOTP: OtpMessages['resendOTP']; | ||
@@ -9,2 +9,3 @@ sendOTP: (phone: PhoneData) => Promise<void>; | ||
}; | ||
export type PublicSmsAuthMessages = Pick<OtpMessages, typeof smsEventNames[number]>; | ||
export declare const createSmsAuthModule: (core: Core) => SmsAuthModule; |
'use client' | ||
import { createRequestChannel } from '@dynamic-labs/message-transport'; | ||
import { createRequestChannel, createEventEmitterForMessages, smsEventNames } from '@dynamic-labs/message-transport'; | ||
import { pickListenerActions } from '../../../utils/pickListenerActions/pickListenerActions.js'; | ||
const createSmsAuthModule = (core) => { | ||
const requestChannel = createRequestChannel(core.messageTransport); | ||
return { | ||
const messageEvents = createEventEmitterForMessages({ | ||
eventNames: smsEventNames, | ||
messageTransport: core.messageTransport, | ||
}); | ||
return Object.assign(pickListenerActions(messageEvents), { | ||
resendOTP: () => requestChannel.request('resendOTP'), | ||
sendOTP: (phone) => requestChannel.request('sendOTP', { destination: 'sms', target: phone }), | ||
verifyOTP: (token) => requestChannel.request('verifyOTP', token), | ||
}; | ||
}); | ||
}; | ||
export { createSmsAuthModule }; |
import { NetworksModuleState } from '@dynamic-labs/message-transport'; | ||
import { Core } from '../../client/core'; | ||
export declare const createNetworksModule: (core: Core) => import("@dynamic-labs/message-transport").StoreStateGetters<NetworksModuleState> & Pick<import("eventemitter3").EventEmitter<import("@dynamic-labs/message-transport").StoreStateEvents<NetworksModuleState>, any>, "on" | "off" | "once">; | ||
export declare const createNetworksModule: (core: Core) => import("@dynamic-labs/message-transport").StoreStateGetters<NetworksModuleState> & import("@dynamic-labs/message-transport").PickedEventListeners<import("@dynamic-labs/message-transport").StoreStateEvents<NetworksModuleState>>; |
@@ -1,4 +0,4 @@ | ||
import { UserInterfaceModuleMessages } from '@dynamic-labs/message-transport'; | ||
import { PickedEventListeners, UserInterfaceModuleMessages, userInterfaceEventNames } from '@dynamic-labs/message-transport'; | ||
import { Core } from '../../client/core'; | ||
export type UserInterfaceModule = { | ||
type UserInterfaceModuleMethods = { | ||
auth: { | ||
@@ -40,2 +40,5 @@ /** | ||
}; | ||
type PublicUserInterfaceModuleMessages = Pick<UserInterfaceModuleMessages, typeof userInterfaceEventNames[number]>; | ||
export type UserInterfaceModule = PickedEventListeners<PublicUserInterfaceModuleMessages> & UserInterfaceModuleMethods; | ||
export declare const createUserInterfaceModule: (core: Core) => UserInterfaceModule; | ||
export {}; |
'use client' | ||
import { createRequestChannel } from '@dynamic-labs/message-transport'; | ||
import { createRequestChannel, createEventEmitterForMessages, userInterfaceEventNames } from '@dynamic-labs/message-transport'; | ||
import { pickListenerActions } from '../../utils/pickListenerActions/pickListenerActions.js'; | ||
const createUserInterfaceModule = (core) => { | ||
const userInterfaceRequestChannel = createRequestChannel(core.messageTransport); | ||
return { | ||
const messageEvents = createEventEmitterForMessages({ | ||
eventNames: userInterfaceEventNames, | ||
messageTransport: core.messageTransport, | ||
}); | ||
return Object.assign(pickListenerActions(messageEvents), { | ||
auth: { | ||
@@ -18,5 +23,5 @@ hide: () => userInterfaceRequestChannel.emit('hideAuthFlow'), | ||
}, | ||
}; | ||
}); | ||
}; | ||
export { createUserInterfaceModule }; |
@@ -1,6 +0,9 @@ | ||
import { EmbeddedWalletsModuleMessages, EmbeddedWalletsModuleState, StoreEventListeners } from '@dynamic-labs/message-transport'; | ||
import { EmbeddedWalletsModuleMessages, EmbeddedWalletsModuleState, StoreEventListeners, PickedEventListeners } from '@dynamic-labs/message-transport'; | ||
import { Core } from '../../../client/core'; | ||
type PublicEmbeddedWalletsModuleMessages = Pick<EmbeddedWalletsModuleMessages, 'createWallet' | 'getWallet'>; | ||
export type EmbeddedWalletsModule = EmbeddedWalletsModuleState & StoreEventListeners<EmbeddedWalletsModuleState> & PublicEmbeddedWalletsModuleMessages; | ||
type PublicEmbeddedWalletsModuleMessages = Pick<EmbeddedWalletsModuleMessages, 'embeddedWalletCreated'>; | ||
export type EmbeddedWalletsModule = EmbeddedWalletsModuleState & StoreEventListeners<EmbeddedWalletsModuleState> & PickedEventListeners<PublicEmbeddedWalletsModuleMessages> & { | ||
createWallet: EmbeddedWalletsModuleMessages['createWallet']; | ||
getWallet: EmbeddedWalletsModuleMessages['getWallet']; | ||
}; | ||
export declare const createEmbeddedWalletsModule: (core: Core) => EmbeddedWalletsModule; | ||
export {}; |
'use client' | ||
import { createStore, createEventEmitterForMessages, createRequestChannel } from '@dynamic-labs/message-transport'; | ||
import { createStore, createEventEmitterForMessages, embeddedWalletsEventNames, createRequestChannel } from '@dynamic-labs/message-transport'; | ||
import { pickListenerActions } from '../../../utils/pickListenerActions/pickListenerActions.js'; | ||
@@ -14,4 +14,4 @@ | ||
const messageEvents = createEventEmitterForMessages({ | ||
eventNames: embeddedWalletsEventNames, | ||
initialEventEmitter: store.eventEmitter, | ||
key: 'embeddedWallets', | ||
messageTransport: core.messageTransport, | ||
@@ -18,0 +18,0 @@ }); |
@@ -1,2 +0,3 @@ | ||
import { StoreEventListeners, WalletsModuleMessages, WalletsModuleState } from '@dynamic-labs/message-transport'; | ||
import { PickedEventListeners, StoreEventListeners, WalletsModuleMessages, WalletsModuleState, userWalletsEventNames } from '@dynamic-labs/message-transport'; | ||
import { BaseWallet } from '@dynamic-labs/types'; | ||
import { Core } from '../../client/core'; | ||
@@ -6,3 +7,4 @@ import { type AccountAbstractionModule } from './accountAbstractionModule'; | ||
import { EmbeddedWalletsModule } from './embeddedWalletsModule'; | ||
export type WalletsModule = WalletsModuleState & { | ||
export type PublicWalletModuleMessages = Pick<WalletsModuleMessages, typeof userWalletsEventNames[number]>; | ||
export type WalletsModule = WalletsModuleState & PickedEventListeners<PublicWalletModuleMessages> & StoreEventListeners<WalletsModuleState> & { | ||
embedded: EmbeddedWalletsModule; | ||
@@ -17,3 +19,7 @@ accountAbstraction: AccountAbstractionModule; | ||
offWalletEvent: WalletEventListener; | ||
} & StoreEventListeners<WalletsModuleState>; | ||
setHandler: (name: 'walletConnected', handler: ConnectedWalletsHandler) => void; | ||
clearHandler: (name: 'walletConnected') => void; | ||
}; | ||
type ConnectedWalletsHandler = (wallet: Partial<BaseWallet>) => Promise<boolean>; | ||
export declare const createWalletsModule: (core: Core) => WalletsModule; | ||
export {}; |
'use client' | ||
import { createRequestChannel, createStore } from '@dynamic-labs/message-transport'; | ||
import { createRequestChannel, createStore, createEventEmitterForMessages, userWalletsEventNames } from '@dynamic-labs/message-transport'; | ||
import { pickListenerActions } from '../../utils/pickListenerActions/pickListenerActions.js'; | ||
@@ -8,2 +8,3 @@ import { createAccountAbstractionModule } from './accountAbstractionModule/accountAbstractionModule.js'; | ||
const defaultConnectedWalletHandler = () => Promise.resolve(true); | ||
const createWalletsModule = (core) => { | ||
@@ -16,2 +17,7 @@ const requestChannel = createRequestChannel(core.messageTransport); | ||
}); | ||
const messageEvents = createEventEmitterForMessages({ | ||
eventNames: userWalletsEventNames, | ||
initialEventEmitter: store.eventEmitter, | ||
messageTransport: core.messageTransport, | ||
}); | ||
const signMessage = (params) => requestChannel.request('signMessage', params); | ||
@@ -23,4 +29,9 @@ const getBalance = (params) => requestChannel.request('getBalance', params); | ||
const { offWalletEvent, onWalletEvent } = createWalletListenerMethods(requestChannel); | ||
return Object.assign(store.getters, pickListenerActions(store.eventEmitter), { | ||
const handlers = { | ||
walletConnected: defaultConnectedWalletHandler, | ||
}; | ||
requestChannel.handle('handleConnectedWallet', (wallet) => handlers.walletConnected(wallet)); | ||
return Object.assign(store.getters, pickListenerActions(messageEvents), { | ||
accountAbstraction: createAccountAbstractionModule(core), | ||
clearHandler: () => (handlers.walletConnected = defaultConnectedWalletHandler), | ||
embedded: createEmbeddedWalletsModule(core), | ||
@@ -31,2 +42,3 @@ getBalance, | ||
onWalletEvent, | ||
setHandler: (_, handler) => (handlers.walletConnected = handler), | ||
setPrimary, | ||
@@ -33,0 +45,0 @@ signMessage, |
import EventEmitter from 'eventemitter3'; | ||
import { PickedEventListeners } from '@dynamic-labs/message-transport'; | ||
/** | ||
@@ -6,2 +7,2 @@ * This only serves to limit the methods of an event emitter to | ||
*/ | ||
export declare const pickListenerActions: <T extends EventEmitter<any, any>>(emitter: T) => Pick<T, 'on' | 'off' | 'once'>; | ||
export declare const pickListenerActions: <T extends Record<string, any>>(emitter: EventEmitter<T>) => PickedEventListeners<T>; |
@@ -8,7 +8,13 @@ 'use client' | ||
const pickListenerActions = (emitter) => ({ | ||
off: emitter.off.bind(emitter), | ||
on: emitter.on.bind(emitter), | ||
once: emitter.once.bind(emitter), | ||
off: (eventName, listener) => { | ||
emitter.off(eventName, listener); | ||
}, | ||
on: (eventName, listener) => { | ||
emitter.on(eventName, listener); | ||
}, | ||
once: (eventName, listener) => { | ||
emitter.once(eventName, listener); | ||
}, | ||
}); | ||
export { pickListenerActions }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
431353
1553
+ Added@dynamic-labs/assert-package-version@4.0.0-alpha.8(transitive)
+ Added@dynamic-labs/logger@4.0.0-alpha.8(transitive)
+ Added@dynamic-labs/message-transport@4.0.0-alpha.8(transitive)
+ Added@dynamic-labs/types@4.0.0-alpha.8(transitive)
+ Added@dynamic-labs/utils@4.0.0-alpha.8(transitive)
- Removed@dynamic-labs/assert-package-version@4.0.0-alpha.7(transitive)
- Removed@dynamic-labs/logger@4.0.0-alpha.7(transitive)
- Removed@dynamic-labs/message-transport@4.0.0-alpha.7(transitive)
- Removed@dynamic-labs/types@4.0.0-alpha.7(transitive)
- Removed@dynamic-labs/utils@4.0.0-alpha.7(transitive)