@dynamic-labs/client 2.1.0-alpha.25 → 2.1.0-alpha.26
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 +13 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +4 -4
- package/src/client/core/core.cjs +3 -2
- package/src/client/core/core.d.ts +2 -4
- package/src/client/core/core.js +3 -2
- package/src/client/core/modules/initializationModule/initializationModule.d.ts +2 -1
- package/src/client/core/modules/manifestModule/{utils/manifest/manifest.cjs → createPartialManifest/createPartialManifest.cjs} +3 -3
- package/src/client/core/modules/manifestModule/createPartialManifest/createPartialManifest.d.ts +3 -0
- package/src/client/core/modules/manifestModule/createPartialManifest/createPartialManifest.js +13 -0
- package/src/client/core/modules/manifestModule/createPartialManifest/index.d.ts +1 -0
- package/src/client/core/modules/manifestModule/manifestModule.cjs +18 -5
- package/src/client/core/modules/manifestModule/manifestModule.d.ts +4 -2
- package/src/client/core/modules/manifestModule/manifestModule.js +17 -4
- package/src/client/core/modules/manifestModule/validateManifest/index.d.ts +1 -0
- package/src/client/core/modules/manifestModule/validateManifest/validateManifest.cjs +30 -0
- package/src/client/core/modules/manifestModule/validateManifest/validateManifest.d.ts +14 -0
- package/src/client/core/modules/manifestModule/validateManifest/validateManifest.js +25 -0
- package/src/client/core/modules/manifestModule/utils/manifest/index.d.ts +0 -1
- package/src/client/core/modules/manifestModule/utils/manifest/manifest.d.ts +0 -3
- package/src/client/core/modules/manifestModule/utils/manifest/manifest.js +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.1.0-alpha.26](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.25...v2.1.0-alpha.26) (2024-05-29)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add farcaster login to react native ([#5713](https://github.com/dynamic-labs/DynamicAuth/issues/5713)) ([08f4473](https://github.com/dynamic-labs/DynamicAuth/commit/08f4473eec9b32b82b6f703fa4d5136514a61b25))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* better error handling of invalid mfa otp ([#5759](https://github.com/dynamic-labs/DynamicAuth/issues/5759)) ([72ab01f](https://github.com/dynamic-labs/DynamicAuth/commit/72ab01f8f919f147eeedfabf8b4838802abf308a))
|
|
13
|
+
* show correct status for magic eden btc wallets after ([#5748](https://github.com/dynamic-labs/DynamicAuth/issues/5748)) ([b8f20bb](https://github.com/dynamic-labs/DynamicAuth/commit/b8f20bb796b9a2e88817ef3b0da6ac32e9012b18))
|
|
14
|
+
|
|
2
15
|
## [2.1.0-alpha.25](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.24...v2.1.0-alpha.25) (2024-05-27)
|
|
3
16
|
|
|
4
17
|
|
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.26",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -26,12 +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.26",
|
|
30
30
|
"@vue/reactivity": "3.4.21"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@dynamic-labs/logger": "2.1.0-alpha.
|
|
34
|
-
"@dynamic-labs/types": "2.1.0-alpha.
|
|
33
|
+
"@dynamic-labs/logger": "2.1.0-alpha.26",
|
|
34
|
+
"@dynamic-labs/types": "2.1.0-alpha.26",
|
|
35
35
|
"eventemitter3": "5.0.1"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/client/core/core.cjs
CHANGED
|
@@ -19,6 +19,7 @@ const messageTransport = messageTransport$1.applyDefaultMessageOrigin({
|
|
|
19
19
|
// messageTransport.on((message) =>
|
|
20
20
|
// console.log('message', JSON.stringify(message, null, 2)),
|
|
21
21
|
// );
|
|
22
|
+
const initialization = initializationModule.createInitializationModule(messageTransport);
|
|
22
23
|
const createCore = (props) => ({
|
|
23
24
|
/**
|
|
24
25
|
* Allows an extension to add its name to the list, such that
|
|
@@ -31,11 +32,11 @@ const createCore = (props) => ({
|
|
|
31
32
|
/**
|
|
32
33
|
* SDK initialization module handles the initialization error
|
|
33
34
|
*/
|
|
34
|
-
initialization
|
|
35
|
+
initialization,
|
|
35
36
|
/**
|
|
36
37
|
* Manages the manifest of the host
|
|
37
38
|
*/
|
|
38
|
-
manifest: manifestModule.createManifestModule(props, messageTransport),
|
|
39
|
+
manifest: manifestModule.createManifestModule(props, messageTransport, initialization),
|
|
39
40
|
/**
|
|
40
41
|
* Message transport that will be used to send and receive messages to the webview.
|
|
41
42
|
* Should preferably be used with createRequestChannel, rather than used directly.
|
|
@@ -16,15 +16,13 @@ export declare const createCore: (props: ClientProps) => {
|
|
|
16
16
|
/**
|
|
17
17
|
* SDK initialization module handles the initialization error
|
|
18
18
|
*/
|
|
19
|
-
initialization:
|
|
20
|
-
get error(): Error | null;
|
|
21
|
-
set error(error: Error);
|
|
22
|
-
};
|
|
19
|
+
initialization: import("./modules/initializationModule/initializationModule").InitializationModule;
|
|
23
20
|
/**
|
|
24
21
|
* Manages the manifest of the host
|
|
25
22
|
*/
|
|
26
23
|
manifest: {
|
|
27
24
|
setAppOrigin: (appOrigin: string) => string;
|
|
25
|
+
setPlatform: (platform: "browser" | "react-native") => "browser" | "react-native";
|
|
28
26
|
};
|
|
29
27
|
/**
|
|
30
28
|
* Message transport that will be used to send and receive messages to the webview.
|
package/src/client/core/core.js
CHANGED
|
@@ -15,6 +15,7 @@ const messageTransport = applyDefaultMessageOrigin({
|
|
|
15
15
|
// messageTransport.on((message) =>
|
|
16
16
|
// console.log('message', JSON.stringify(message, null, 2)),
|
|
17
17
|
// );
|
|
18
|
+
const initialization = createInitializationModule(messageTransport);
|
|
18
19
|
const createCore = (props) => ({
|
|
19
20
|
/**
|
|
20
21
|
* Allows an extension to add its name to the list, such that
|
|
@@ -27,11 +28,11 @@ const createCore = (props) => ({
|
|
|
27
28
|
/**
|
|
28
29
|
* SDK initialization module handles the initialization error
|
|
29
30
|
*/
|
|
30
|
-
initialization
|
|
31
|
+
initialization,
|
|
31
32
|
/**
|
|
32
33
|
* Manages the manifest of the host
|
|
33
34
|
*/
|
|
34
|
-
manifest: createManifestModule(props, messageTransport),
|
|
35
|
+
manifest: createManifestModule(props, messageTransport, initialization),
|
|
35
36
|
/**
|
|
36
37
|
* Message transport that will be used to send and receive messages to the webview.
|
|
37
38
|
* Should preferably be used with createRequestChannel, rather than used directly.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MessageTransportWithDefaultOrigin } from '@dynamic-labs/message-transport';
|
|
2
|
-
export
|
|
2
|
+
export type InitializationModule = {
|
|
3
3
|
get error(): Error | null;
|
|
4
4
|
set error(error: Error);
|
|
5
5
|
};
|
|
6
|
+
export declare const createInitializationModule: (messageTransport: MessageTransportWithDefaultOrigin) => InitializationModule;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _package = require('
|
|
6
|
+
var _package = require('../../../../../../package.cjs');
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const createPartialManifest = ({ apiBaseUrl, environmentId, appLogoUrl, appName, cssOverrides, }) => ({
|
|
9
9
|
apiBaseUrl,
|
|
10
10
|
appLogoUrl,
|
|
11
11
|
appName,
|
|
@@ -14,4 +14,4 @@ const createManifest = ({ apiBaseUrl, environmentId, appLogoUrl, appName, cssOve
|
|
|
14
14
|
environmentId,
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
exports.
|
|
17
|
+
exports.createPartialManifest = createPartialManifest;
|
package/src/client/core/modules/manifestModule/createPartialManifest/createPartialManifest.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ClientManifest } from '@dynamic-labs/message-transport';
|
|
2
|
+
import { ClientProps } from '../../../../client';
|
|
3
|
+
export declare const createPartialManifest: ({ apiBaseUrl, environmentId, appLogoUrl, appName, cssOverrides, }: ClientProps) => Partial<ClientManifest>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { version } from '../../../../../../package.js';
|
|
3
|
+
|
|
4
|
+
const createPartialManifest = ({ apiBaseUrl, environmentId, appLogoUrl, appName, cssOverrides, }) => ({
|
|
5
|
+
apiBaseUrl,
|
|
6
|
+
appLogoUrl,
|
|
7
|
+
appName,
|
|
8
|
+
clientVersion: version,
|
|
9
|
+
cssOverrides,
|
|
10
|
+
environmentId,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { createPartialManifest };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './createPartialManifest';
|
|
@@ -5,17 +5,30 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
7
|
var messageTransport = require('@dynamic-labs/message-transport');
|
|
8
|
-
var
|
|
8
|
+
var logger = require('../../../../utils/logger/logger.cjs');
|
|
9
|
+
var createPartialManifest = require('./createPartialManifest/createPartialManifest.cjs');
|
|
10
|
+
var validateManifest = require('./validateManifest/validateManifest.cjs');
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Manifest module handles the client manifest that will be requested by the webview
|
|
12
14
|
*/
|
|
13
|
-
const createManifestModule = (props, messageTransport$1) => {
|
|
15
|
+
const createManifestModule = (props, messageTransport$1, initializationModule) => {
|
|
14
16
|
const requestChannel = messageTransport.createRequestChannel(messageTransport$1);
|
|
15
|
-
const manifest
|
|
16
|
-
requestChannel.handle('manifest', () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const manifest = createPartialManifest.createPartialManifest(props);
|
|
18
|
+
requestChannel.handle('manifest', () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
try {
|
|
20
|
+
return validateManifest.validateManifest(manifest);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
logger.logger.error(error);
|
|
24
|
+
if (error instanceof Error)
|
|
25
|
+
initializationModule.error = error;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
17
29
|
return {
|
|
18
|
-
setAppOrigin: (appOrigin) => (manifest
|
|
30
|
+
setAppOrigin: (appOrigin) => (manifest.appOrigin = appOrigin),
|
|
31
|
+
setPlatform: (platform) => (manifest.platform = platform),
|
|
19
32
|
};
|
|
20
33
|
};
|
|
21
34
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { MessageTransportWithDefaultOrigin } from '@dynamic-labs/message-transport';
|
|
1
|
+
import { ClientManifest, MessageTransportWithDefaultOrigin } from '@dynamic-labs/message-transport';
|
|
2
2
|
import { ClientProps } from '../../../client';
|
|
3
|
+
import { InitializationModule } from '../initializationModule/initializationModule';
|
|
3
4
|
/**
|
|
4
5
|
* Manifest module handles the client manifest that will be requested by the webview
|
|
5
6
|
*/
|
|
6
|
-
export declare const createManifestModule: (props: ClientProps, messageTransport: MessageTransportWithDefaultOrigin) => {
|
|
7
|
+
export declare const createManifestModule: (props: ClientProps, messageTransport: MessageTransportWithDefaultOrigin, initializationModule: InitializationModule) => {
|
|
7
8
|
setAppOrigin: (appOrigin: string) => string;
|
|
9
|
+
setPlatform: (platform: ClientManifest['platform']) => "browser" | "react-native";
|
|
8
10
|
};
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
3
|
import { createRequestChannel } from '@dynamic-labs/message-transport';
|
|
4
|
-
import {
|
|
4
|
+
import { logger } from '../../../../utils/logger/logger.js';
|
|
5
|
+
import { createPartialManifest } from './createPartialManifest/createPartialManifest.js';
|
|
6
|
+
import { validateManifest } from './validateManifest/validateManifest.js';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Manifest module handles the client manifest that will be requested by the webview
|
|
8
10
|
*/
|
|
9
|
-
const createManifestModule = (props, messageTransport) => {
|
|
11
|
+
const createManifestModule = (props, messageTransport, initializationModule) => {
|
|
10
12
|
const requestChannel = createRequestChannel(messageTransport);
|
|
11
|
-
const manifest =
|
|
12
|
-
requestChannel.handle('manifest', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
+
const manifest = createPartialManifest(props);
|
|
14
|
+
requestChannel.handle('manifest', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
try {
|
|
16
|
+
return validateManifest(manifest);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
logger.error(error);
|
|
20
|
+
if (error instanceof Error)
|
|
21
|
+
initializationModule.error = error;
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
13
25
|
return {
|
|
14
26
|
setAppOrigin: (appOrigin) => (manifest.appOrigin = appOrigin),
|
|
27
|
+
setPlatform: (platform) => (manifest.platform = platform),
|
|
15
28
|
};
|
|
16
29
|
};
|
|
17
30
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './validateManifest';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Maps each required field of the client manifest to an error message that explains
|
|
8
|
+
* what the customer can do if his app runs into the issue where this field is missing from his manifest.
|
|
9
|
+
*/
|
|
10
|
+
const mandatoryFields = {
|
|
11
|
+
clientVersion: "We were unable to retrieve the Dynamic Client's version from your app. Please contact us about this.",
|
|
12
|
+
environmentId: 'You must provide an environment id to the Dynamic Client.',
|
|
13
|
+
platform: 'Missing platform specific extension, like BrowserExtension or ReactNativeExtension. See how to setup Dynamic Client in our docs for help.',
|
|
14
|
+
};
|
|
15
|
+
const validateManifest = (partialManifest) => {
|
|
16
|
+
/**
|
|
17
|
+
* If any of these fields are missing, we show the user an error message.
|
|
18
|
+
* You should map to each required field a description of what the user can do to fix this issue.
|
|
19
|
+
*
|
|
20
|
+
* And if you add a new required field to DynamicClient, TS will automatically force you to
|
|
21
|
+
* also include a description here :)
|
|
22
|
+
*/
|
|
23
|
+
for (const [field, description] of Object.entries(mandatoryFields))
|
|
24
|
+
if (partialManifest[field] === undefined)
|
|
25
|
+
throw new Error(`Missing client manifest field "${field}": ${description}`);
|
|
26
|
+
return partialManifest;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.mandatoryFields = mandatoryFields;
|
|
30
|
+
exports.validateManifest = validateManifest;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ClientManifest } from '@dynamic-labs/message-transport';
|
|
2
|
+
/**
|
|
3
|
+
* Union of fields from ClientManifest which must be defined
|
|
4
|
+
*/
|
|
5
|
+
type MandatoryClientManifestField = {
|
|
6
|
+
[K in keyof ClientManifest]-?: NonNullable<unknown> extends Pick<ClientManifest, K> ? never : K;
|
|
7
|
+
}[keyof ClientManifest];
|
|
8
|
+
/**
|
|
9
|
+
* Maps each required field of the client manifest to an error message that explains
|
|
10
|
+
* what the customer can do if his app runs into the issue where this field is missing from his manifest.
|
|
11
|
+
*/
|
|
12
|
+
export declare const mandatoryFields: Record<MandatoryClientManifestField, string>;
|
|
13
|
+
export declare const validateManifest: (partialManifest: Partial<ClientManifest>) => ClientManifest;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Maps each required field of the client manifest to an error message that explains
|
|
4
|
+
* what the customer can do if his app runs into the issue where this field is missing from his manifest.
|
|
5
|
+
*/
|
|
6
|
+
const mandatoryFields = {
|
|
7
|
+
clientVersion: "We were unable to retrieve the Dynamic Client's version from your app. Please contact us about this.",
|
|
8
|
+
environmentId: 'You must provide an environment id to the Dynamic Client.',
|
|
9
|
+
platform: 'Missing platform specific extension, like BrowserExtension or ReactNativeExtension. See how to setup Dynamic Client in our docs for help.',
|
|
10
|
+
};
|
|
11
|
+
const validateManifest = (partialManifest) => {
|
|
12
|
+
/**
|
|
13
|
+
* If any of these fields are missing, we show the user an error message.
|
|
14
|
+
* You should map to each required field a description of what the user can do to fix this issue.
|
|
15
|
+
*
|
|
16
|
+
* And if you add a new required field to DynamicClient, TS will automatically force you to
|
|
17
|
+
* also include a description here :)
|
|
18
|
+
*/
|
|
19
|
+
for (const [field, description] of Object.entries(mandatoryFields))
|
|
20
|
+
if (partialManifest[field] === undefined)
|
|
21
|
+
throw new Error(`Missing client manifest field "${field}": ${description}`);
|
|
22
|
+
return partialManifest;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { mandatoryFields, validateManifest };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './manifest';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { version } from '../../../../../../../package.js';
|
|
3
|
-
|
|
4
|
-
const createManifest = ({ apiBaseUrl, environmentId, appLogoUrl, appName, cssOverrides, }) => ({
|
|
5
|
-
apiBaseUrl,
|
|
6
|
-
appLogoUrl,
|
|
7
|
-
appName,
|
|
8
|
-
clientVersion: version,
|
|
9
|
-
cssOverrides,
|
|
10
|
-
environmentId,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export { createManifest };
|