@dynamic-labs/client 2.1.0-alpha.15 → 2.1.0-alpha.16
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 +9 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +5 -3
- package/src/client/client.cjs +3 -0
- package/src/client/client.d.ts +9 -0
- package/src/client/client.js +3 -0
- package/src/client/core/core.cjs +5 -0
- package/src/client/core/core.d.ts +8 -1
- package/src/client/core/core.js +5 -0
- package/src/client/core/modules/initializationModule/index.d.ts +1 -0
- package/src/client/core/modules/initializationModule/initializationModule.cjs +30 -0
- package/src/client/core/modules/initializationModule/initializationModule.d.ts +5 -0
- package/src/client/core/modules/initializationModule/initializationModule.js +26 -0
- package/src/modules/sdkModule/sdkModule.cjs +5 -1
- package/src/modules/sdkModule/sdkModule.d.ts +3 -1
- package/src/modules/sdkModule/sdkModule.js +5 -1
- package/src/modules/userInterfaceModule/index.d.ts +1 -0
- package/src/modules/userInterfaceModule/userInterfaceModule.cjs +20 -0
- package/src/modules/userInterfaceModule/userInterfaceModule.d.ts +9 -0
- package/src/modules/userInterfaceModule/userInterfaceModule.js +16 -0
- package/src/utils/addProperty/addProperty.cjs +21 -0
- package/src/utils/addProperty/addProperty.d.ts +13 -0
- package/src/utils/addProperty/addProperty.js +17 -0
- package/src/utils/addProperty/index.d.ts +1 -0
- package/src/utils/logger/index.d.ts +1 -0
- package/src/utils/logger/logger.cjs +10 -0
- package/src/utils/logger/logger.d.ts +2 -0
- package/src/utils/logger/logger.js +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.1.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.15...v2.1.0-alpha.16) (2024-05-14)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add client.sdk.error with errors from the webview ([#5520](https://github.com/dynamic-labs/DynamicAuth/issues/5520)) ([a886927](https://github.com/dynamic-labs/DynamicAuth/commit/a8869273bf361c870d6e3cb82a28d9ccec65905b))
|
|
8
|
+
* add setDefaultTabIndex to default the selected wallets tab ([#5593](https://github.com/dynamic-labs/DynamicAuth/issues/5593)) ([6e8ce05](https://github.com/dynamic-labs/DynamicAuth/commit/6e8ce053c4f6f009acc57dac55a8e9c74fbcc73b))
|
|
9
|
+
* add visibility/auth-flow/user-profile to react-native ([#5564](https://github.com/dynamic-labs/DynamicAuth/issues/5564)) ([d93cea8](https://github.com/dynamic-labs/DynamicAuth/commit/d93cea82a123c6ec4d3d594a7dc064f4db2981c2))
|
|
10
|
+
|
|
2
11
|
## [2.1.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.14...v2.1.0-alpha.15) (2024-05-13)
|
|
3
12
|
|
|
4
13
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/client",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.16",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -26,10 +26,12 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dynamic-labs/message-transport": "2.1.0-alpha.
|
|
29
|
+
"@dynamic-labs/message-transport": "2.1.0-alpha.16",
|
|
30
|
+
"@vue/reactivity": "3.4.21"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
|
-
"@dynamic-labs/
|
|
33
|
+
"@dynamic-labs/logger": "2.1.0-alpha.16",
|
|
34
|
+
"@dynamic-labs/types": "2.1.0-alpha.16",
|
|
33
35
|
"eventemitter3": "5.0.1"
|
|
34
36
|
}
|
|
35
37
|
}
|
package/src/client/client.cjs
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var authModule = require('../modules/authModule/authModule.cjs');
|
|
7
7
|
var sdkModule = require('../modules/sdkModule/sdkModule.cjs');
|
|
8
|
+
var userInterfaceModule = require('../modules/userInterfaceModule/userInterfaceModule.cjs');
|
|
8
9
|
var walletsModule = require('../modules/walletsModule/walletsModule.cjs');
|
|
9
10
|
var Extendable = require('../utils/Extendable/Extendable.cjs');
|
|
10
11
|
var core = require('./core/core.cjs');
|
|
@@ -24,6 +25,8 @@ const createClient = (props) => {
|
|
|
24
25
|
auth: authModule.createAuthModule(core$1),
|
|
25
26
|
/** Module that gives insight over the state of the SDK */
|
|
26
27
|
sdk: sdkModule.createSdkModule(core$1, props),
|
|
28
|
+
/** Module that provide access to UI features */
|
|
29
|
+
ui: userInterfaceModule.createUserInterfaceModule(core$1),
|
|
27
30
|
/** Module that provides access to user's wallets */
|
|
28
31
|
wallets: walletsModule.createWalletsModule(core$1),
|
|
29
32
|
}));
|
package/src/client/client.d.ts
CHANGED
|
@@ -19,6 +19,15 @@ export declare const createClient: (props: ClientProps) => {
|
|
|
19
19
|
auth: import("../modules/authModule").AuthModule;
|
|
20
20
|
/** Module that gives insight over the state of the SDK */
|
|
21
21
|
sdk: import("../modules/sdkModule").SdkModule;
|
|
22
|
+
/** Module that provide access to UI features */
|
|
23
|
+
ui: {
|
|
24
|
+
auth: {
|
|
25
|
+
show: () => void;
|
|
26
|
+
};
|
|
27
|
+
userProfile: {
|
|
28
|
+
show: () => void;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
22
31
|
/** Module that provides access to user's wallets */
|
|
23
32
|
wallets: import("../modules/walletsModule").WalletsModule;
|
|
24
33
|
} & Extendable;
|
package/src/client/client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { createAuthModule } from '../modules/authModule/authModule.js';
|
|
3
3
|
import { createSdkModule } from '../modules/sdkModule/sdkModule.js';
|
|
4
|
+
import { createUserInterfaceModule } from '../modules/userInterfaceModule/userInterfaceModule.js';
|
|
4
5
|
import { createWalletsModule } from '../modules/walletsModule/walletsModule.js';
|
|
5
6
|
import { Extendable } from '../utils/Extendable/Extendable.js';
|
|
6
7
|
import { createCore } from './core/core.js';
|
|
@@ -20,6 +21,8 @@ const createClient = (props) => {
|
|
|
20
21
|
auth: createAuthModule(core),
|
|
21
22
|
/** Module that gives insight over the state of the SDK */
|
|
22
23
|
sdk: createSdkModule(core, props),
|
|
24
|
+
/** Module that provide access to UI features */
|
|
25
|
+
ui: createUserInterfaceModule(core),
|
|
23
26
|
/** Module that provides access to user's wallets */
|
|
24
27
|
wallets: createWalletsModule(core),
|
|
25
28
|
}));
|
package/src/client/core/core.cjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var messageTransport$1 = require('@dynamic-labs/message-transport');
|
|
7
|
+
var initializationModule = require('./modules/initializationModule/initializationModule.cjs');
|
|
7
8
|
|
|
8
9
|
const messageTransport = messageTransport$1.applyDefaultMessageOrigin({
|
|
9
10
|
defaultOrigin: 'host',
|
|
@@ -26,6 +27,10 @@ const createCore = () => ({
|
|
|
26
27
|
* checks this list and throws an error if it doesn't find "viem" there.
|
|
27
28
|
*/
|
|
28
29
|
declaredExtensionNames: [],
|
|
30
|
+
/**
|
|
31
|
+
* SDK initialization module handles the initialization error
|
|
32
|
+
*/
|
|
33
|
+
initialization: initializationModule.createInitializationModule(messageTransport),
|
|
29
34
|
/**
|
|
30
35
|
* Message transport that will be used to send and receive messages to the webview.
|
|
31
36
|
* Should preferably be used with createRequestChannel, rather than used directly.
|
|
@@ -12,6 +12,13 @@ export declare const createCore: () => {
|
|
|
12
12
|
* checks this list and throws an error if it doesn't find "viem" there.
|
|
13
13
|
*/
|
|
14
14
|
declaredExtensionNames: string[];
|
|
15
|
+
/**
|
|
16
|
+
* SDK initialization module handles the initialization error
|
|
17
|
+
*/
|
|
18
|
+
initialization: {
|
|
19
|
+
get error(): Error | null;
|
|
20
|
+
set error(error: Error);
|
|
21
|
+
};
|
|
15
22
|
/**
|
|
16
23
|
* Message transport that will be used to send and receive messages to the webview.
|
|
17
24
|
* Should preferably be used with createRequestChannel, rather than used directly.
|
|
@@ -25,7 +32,7 @@ export declare const createCore: () => {
|
|
|
25
32
|
off: (callback: import("@dynamic-labs/message-transport").MessageTransportCallback) => void;
|
|
26
33
|
on: (callback: import("@dynamic-labs/message-transport").MessageTransportCallback) => void;
|
|
27
34
|
} & {
|
|
28
|
-
defaultOrigin: "
|
|
35
|
+
defaultOrigin: "webview" | "host";
|
|
29
36
|
emit: (message: import("@dynamic-labs/message-transport").MessageTransportDataOptionalOrigin) => void;
|
|
30
37
|
};
|
|
31
38
|
};
|
package/src/client/core/core.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { applyDefaultMessageOrigin, makeWaitForInitEvent, sdkHasLoadedEventName, createMessageTransport } from '@dynamic-labs/message-transport';
|
|
3
|
+
import { createInitializationModule } from './modules/initializationModule/initializationModule.js';
|
|
3
4
|
|
|
4
5
|
const messageTransport = applyDefaultMessageOrigin({
|
|
5
6
|
defaultOrigin: 'host',
|
|
@@ -22,6 +23,10 @@ const createCore = () => ({
|
|
|
22
23
|
* checks this list and throws an error if it doesn't find "viem" there.
|
|
23
24
|
*/
|
|
24
25
|
declaredExtensionNames: [],
|
|
26
|
+
/**
|
|
27
|
+
* SDK initialization module handles the initialization error
|
|
28
|
+
*/
|
|
29
|
+
initialization: createInitializationModule(messageTransport),
|
|
25
30
|
/**
|
|
26
31
|
* Message transport that will be used to send and receive messages to the webview.
|
|
27
32
|
* Should preferably be used with createRequestChannel, rather than used directly.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createInitializationModule } from './initializationModule';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var reactivity = require('@vue/reactivity');
|
|
7
|
+
var messageTransport = require('@dynamic-labs/message-transport');
|
|
8
|
+
var logger = require('../../../../utils/logger/logger.cjs');
|
|
9
|
+
|
|
10
|
+
const createInitializationModule = (messageTransport$1) => {
|
|
11
|
+
const consoleRequestChannel = messageTransport.createRequestChannel(messageTransport$1);
|
|
12
|
+
const state = reactivity.reactive({
|
|
13
|
+
error: null,
|
|
14
|
+
});
|
|
15
|
+
consoleRequestChannel.handle('error', (serializedError) => {
|
|
16
|
+
state.error = messageTransport.parseErrorFromTransport(serializedError);
|
|
17
|
+
logger.logger.error(state.error);
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
get error() {
|
|
21
|
+
return state.error;
|
|
22
|
+
},
|
|
23
|
+
set error(error) {
|
|
24
|
+
state.error = error;
|
|
25
|
+
logger.logger.error(state.error);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.createInitializationModule = createInitializationModule;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { reactive } from '@vue/reactivity';
|
|
3
|
+
import { createRequestChannel, parseErrorFromTransport } from '@dynamic-labs/message-transport';
|
|
4
|
+
import { logger } from '../../../../utils/logger/logger.js';
|
|
5
|
+
|
|
6
|
+
const createInitializationModule = (messageTransport) => {
|
|
7
|
+
const consoleRequestChannel = createRequestChannel(messageTransport);
|
|
8
|
+
const state = reactive({
|
|
9
|
+
error: null,
|
|
10
|
+
});
|
|
11
|
+
consoleRequestChannel.handle('error', (serializedError) => {
|
|
12
|
+
state.error = parseErrorFromTransport(serializedError);
|
|
13
|
+
logger.error(state.error);
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
get error() {
|
|
17
|
+
return state.error;
|
|
18
|
+
},
|
|
19
|
+
set error(error) {
|
|
20
|
+
state.error = error;
|
|
21
|
+
logger.error(state.error);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { createInitializationModule };
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
7
|
var messageTransport = require('@dynamic-labs/message-transport');
|
|
8
8
|
var pickListenerActions = require('../../utils/pickListenerActions/pickListenerActions.cjs');
|
|
9
|
+
var addProperty = require('../../utils/addProperty/addProperty.cjs');
|
|
9
10
|
var manifest = require('./manifest/manifest.cjs');
|
|
10
11
|
|
|
11
12
|
const createSdkModule = (core, props) => {
|
|
@@ -18,7 +19,10 @@ const createSdkModule = (core, props) => {
|
|
|
18
19
|
key: 'sdk',
|
|
19
20
|
messageTransport: core.messageTransport,
|
|
20
21
|
});
|
|
21
|
-
|
|
22
|
+
const baseModule = Object.assign(store.getters, pickListenerActions.pickListenerActions(store.eventEmitter));
|
|
23
|
+
return addProperty.addProperty(baseModule, 'error', {
|
|
24
|
+
get: () => core.initialization.error,
|
|
25
|
+
});
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
exports.createSdkModule = createSdkModule;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SdkModuleState, StoreEventListeners } from '@dynamic-labs/message-transport';
|
|
2
2
|
import type { ClientProps } from '../../client';
|
|
3
3
|
import { Core } from '../../client/core';
|
|
4
|
-
export type SdkModule = SdkModuleState & StoreEventListeners<SdkModuleState
|
|
4
|
+
export type SdkModule = SdkModuleState & StoreEventListeners<SdkModuleState> & {
|
|
5
|
+
readonly error: Error | null;
|
|
6
|
+
};
|
|
5
7
|
export declare const createSdkModule: (core: Core, props: ClientProps) => SdkModule;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
3
|
import { createRequestChannel, createStore } from '@dynamic-labs/message-transport';
|
|
4
4
|
import { pickListenerActions } from '../../utils/pickListenerActions/pickListenerActions.js';
|
|
5
|
+
import { addProperty } from '../../utils/addProperty/addProperty.js';
|
|
5
6
|
import { createManifest } from './manifest/manifest.js';
|
|
6
7
|
|
|
7
8
|
const createSdkModule = (core, props) => {
|
|
@@ -14,7 +15,10 @@ const createSdkModule = (core, props) => {
|
|
|
14
15
|
key: 'sdk',
|
|
15
16
|
messageTransport: core.messageTransport,
|
|
16
17
|
});
|
|
17
|
-
|
|
18
|
+
const baseModule = Object.assign(store.getters, pickListenerActions(store.eventEmitter));
|
|
19
|
+
return addProperty(baseModule, 'error', {
|
|
20
|
+
get: () => core.initialization.error,
|
|
21
|
+
});
|
|
18
22
|
};
|
|
19
23
|
|
|
20
24
|
export { createSdkModule };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createUserInterfaceModule } from './userInterfaceModule';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var messageTransport = require('@dynamic-labs/message-transport');
|
|
7
|
+
|
|
8
|
+
const createUserInterfaceModule = (core) => {
|
|
9
|
+
const userInterfaceRequestChannel = messageTransport.createRequestChannel(core.messageTransport);
|
|
10
|
+
return {
|
|
11
|
+
auth: {
|
|
12
|
+
show: () => userInterfaceRequestChannel.emit('openAuthFlow'),
|
|
13
|
+
},
|
|
14
|
+
userProfile: {
|
|
15
|
+
show: () => userInterfaceRequestChannel.emit('openUserProfile'),
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.createUserInterfaceModule = createUserInterfaceModule;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { createRequestChannel } from '@dynamic-labs/message-transport';
|
|
3
|
+
|
|
4
|
+
const createUserInterfaceModule = (core) => {
|
|
5
|
+
const userInterfaceRequestChannel = createRequestChannel(core.messageTransport);
|
|
6
|
+
return {
|
|
7
|
+
auth: {
|
|
8
|
+
show: () => userInterfaceRequestChannel.emit('openAuthFlow'),
|
|
9
|
+
},
|
|
10
|
+
userProfile: {
|
|
11
|
+
show: () => userInterfaceRequestChannel.emit('openUserProfile'),
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { createUserInterfaceModule };
|
|
@@ -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';
|