@dynamic-labs/sdk-react-core 4.18.7 → 4.18.8
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 +7 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs +7 -1
- package/src/lib/context/DynamicContext/useDynamicContext/useDynamicContext.js +8 -2
- package/src/lib/context/UserWalletsContext/UserWalletsContext.cjs +26 -3
- package/src/lib/context/UserWalletsContext/UserWalletsContext.js +27 -4
- package/src/lib/locale/en/translation.cjs +39 -0
- package/src/lib/locale/en/translation.d.ts +39 -0
- package/src/lib/locale/en/translation.js +39 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -0
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.cjs +92 -4
- package/src/lib/utils/hooks/useAuthLayoutChecks/useAllowClose/useAllowClose.js +92 -4
- package/src/lib/utils/hooks/useSubdomainCheck/useSubdomainCheck.cjs +3 -90
- package/src/lib/utils/hooks/useSubdomainCheck/useSubdomainCheck.js +3 -90
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.cjs +2 -0
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.d.ts +2 -1
- package/src/lib/widgets/DynamicWidget/components/DynamicWidgetViews/mapViewToComponent.js +2 -0
- package/src/lib/widgets/DynamicWidget/context/DynamicWidgetContext.types.d.ts +1 -1
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/RevokeAccessView/RevokeAccessView.cjs +37 -0
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/RevokeAccessView/RevokeAccessView.d.ts +2 -0
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/RevokeAccessView/RevokeAccessView.js +33 -0
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/RevokeAccessView/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionListItem/SessionListItem.cjs +30 -0
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionListItem/SessionListItem.d.ts +10 -0
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionListItem/SessionListItem.js +26 -0
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionListItem/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionManagementView.cjs +25 -2
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionManagementView.d.ts +7 -1
- package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionManagementView.js +26 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { ModalHeader } from '../../../../../components/ModalHeader/ModalHeader.js';
|
|
5
|
+
import { Typography } from '../../../../../components/Typography/Typography.js';
|
|
6
|
+
import { IconButton } from '../../../../../components/IconButton/IconButton.js';
|
|
7
|
+
import { useWidgetContext } from '../../../context/DynamicWidgetContext.js';
|
|
8
|
+
import 'react';
|
|
9
|
+
import { ReactComponent as SvgClose } from '../../../../../shared/assets/close.js';
|
|
10
|
+
import '@dynamic-labs/iconic';
|
|
11
|
+
import '../../../../../context/ViewContext/ViewContext.js';
|
|
12
|
+
import { TypographyButton } from '../../../../../components/TypographyButton/TypographyButton.js';
|
|
13
|
+
|
|
14
|
+
const RevokeAccessView = () => {
|
|
15
|
+
const { t } = useTranslation();
|
|
16
|
+
const { setDynamicWidgetView } = useWidgetContext();
|
|
17
|
+
const handleCancel = () => {
|
|
18
|
+
setDynamicWidgetView('session-management');
|
|
19
|
+
};
|
|
20
|
+
const handleRevoke = () => {
|
|
21
|
+
// TODO: Implement revoke logic
|
|
22
|
+
setDynamicWidgetView('session-management', {
|
|
23
|
+
bannerMessage: {
|
|
24
|
+
message: 'revoked',
|
|
25
|
+
type: 'success',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
const renderCloseButton = () => (jsx(IconButton, { onClick: handleCancel, "aria-label": t('dyn_session_management.aria.close_button_label'), children: jsx(SvgClose, {}) }));
|
|
30
|
+
return (jsxs("div", { className: 'revoke-access-view', children: [jsx(ModalHeader, { trailing: renderCloseButton(), children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_session_management.revoke_access_view.title', children: t('dyn_session_management.revoke_access_view.title') }) }), jsx("div", { className: 'revoke-access-view__body', children: jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_session_management.revoke_access_view.description', align: 'center', children: t('dyn_session_management.revoke_access_view.description') }) }), jsxs("div", { className: 'revoke-access-view__footer', children: [jsx(TypographyButton, { buttonVariant: 'danger', buttonPadding: 'small', onClick: handleRevoke, dataTestId: 'revoke-access-confirm-button', copykey: 'dyn_session_management.revoke_access_view.revoke_button', expanded: true, children: t('dyn_session_management.revoke_access_view.revoke_button') }), jsx(TypographyButton, { buttonPadding: 'small', onClick: handleCancel, dataTestId: 'revoke-access-cancel-button', copykey: 'dyn_session_management.revoke_access_view.cancel_button', expanded: true, children: t('dyn_session_management.revoke_access_view.cancel_button') })] })] }));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { RevokeAccessView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './RevokeAccessView';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var reactI18next = require('react-i18next');
|
|
9
|
+
var Typography = require('../../../../../components/Typography/Typography.cjs');
|
|
10
|
+
var TypographyButton = require('../../../../../components/TypographyButton/TypographyButton.cjs');
|
|
11
|
+
var IconButton = require('../../../../../components/IconButton/IconButton.cjs');
|
|
12
|
+
var chevronDown = require('../../../../../shared/assets/chevron-down.cjs');
|
|
13
|
+
require('@dynamic-labs/iconic');
|
|
14
|
+
require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
|
|
16
|
+
const SessionListItem = ({ session, onRevokeAccessClick, }) => {
|
|
17
|
+
const { t } = reactI18next.useTranslation();
|
|
18
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
19
|
+
const handleRevokeAccess = React.useCallback(() => {
|
|
20
|
+
onRevokeAccessClick(session.sessionId);
|
|
21
|
+
}, [onRevokeAccessClick, session.sessionId]);
|
|
22
|
+
const toggleExpanded = React.useCallback(() => {
|
|
23
|
+
setIsExpanded((prev) => !prev);
|
|
24
|
+
}, []);
|
|
25
|
+
return (jsxRuntime.jsxs("div", { className: 'session-management-session', children: [jsxRuntime.jsxs("div", { className: 'session-management-session__main', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', children: session.site }), jsxRuntime.jsx(TypographyButton.TypographyButton, { onClick: handleRevokeAccess, children: t('dyn_session_management.session_component.revoke_button') })] }), jsxRuntime.jsxs("div", { className: 'session-management-session__permissions-toggle', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', children: t('dyn_session_management.session_component.permission_details') }), jsxRuntime.jsx(IconButton.IconButton, { onClick: toggleExpanded, "aria-label": t(isExpanded
|
|
26
|
+
? 'dyn_session_management.session_component.aria.collapse_permissions'
|
|
27
|
+
: 'dyn_session_management.session_component.aria.expand_permissions'), className: 'session-management-session__icon-button', children: jsxRuntime.jsx(chevronDown.ReactComponent, {}) })] }), isExpanded && (jsxRuntime.jsx("div", { className: 'session-management-session__permissions', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'bold', children: "TODO: Add permission details" }) }))] }));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.SessionListItem = SessionListItem;
|
package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionListItem/SessionListItem.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useState, useCallback } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Typography } from '../../../../../components/Typography/Typography.js';
|
|
6
|
+
import { TypographyButton } from '../../../../../components/TypographyButton/TypographyButton.js';
|
|
7
|
+
import { IconButton } from '../../../../../components/IconButton/IconButton.js';
|
|
8
|
+
import { ReactComponent as SvgChevronDown } from '../../../../../shared/assets/chevron-down.js';
|
|
9
|
+
import '@dynamic-labs/iconic';
|
|
10
|
+
import '../../../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
|
|
12
|
+
const SessionListItem = ({ session, onRevokeAccessClick, }) => {
|
|
13
|
+
const { t } = useTranslation();
|
|
14
|
+
const [isExpanded, setIsExpanded] = useState(false);
|
|
15
|
+
const handleRevokeAccess = useCallback(() => {
|
|
16
|
+
onRevokeAccessClick(session.sessionId);
|
|
17
|
+
}, [onRevokeAccessClick, session.sessionId]);
|
|
18
|
+
const toggleExpanded = useCallback(() => {
|
|
19
|
+
setIsExpanded((prev) => !prev);
|
|
20
|
+
}, []);
|
|
21
|
+
return (jsxs("div", { className: 'session-management-session', children: [jsxs("div", { className: 'session-management-session__main', children: [jsx(Typography, { variant: 'body_normal', children: session.site }), jsx(TypographyButton, { onClick: handleRevokeAccess, children: t('dyn_session_management.session_component.revoke_button') })] }), jsxs("div", { className: 'session-management-session__permissions-toggle', children: [jsx(Typography, { variant: 'body_small', children: t('dyn_session_management.session_component.permission_details') }), jsx(IconButton, { onClick: toggleExpanded, "aria-label": t(isExpanded
|
|
22
|
+
? 'dyn_session_management.session_component.aria.collapse_permissions'
|
|
23
|
+
: 'dyn_session_management.session_component.aria.expand_permissions'), className: 'session-management-session__icon-button', children: jsx(SvgChevronDown, {}) })] }), isExpanded && (jsx("div", { className: 'session-management-session__permissions', children: jsx(Typography, { variant: 'body_small', weight: 'bold', children: "TODO: Add permission details" }) }))] }));
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { SessionListItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SessionListItem';
|
|
@@ -14,20 +14,43 @@ var DynamicWidgetContext = require('../../context/DynamicWidgetContext.cjs');
|
|
|
14
14
|
var ModalHeader = require('../../../../components/ModalHeader/ModalHeader.cjs');
|
|
15
15
|
var Typography = require('../../../../components/Typography/Typography.cjs');
|
|
16
16
|
var IconButton = require('../../../../components/IconButton/IconButton.cjs');
|
|
17
|
+
var ErrorContainer = require('../../../../components/ErrorContainer/ErrorContainer.cjs');
|
|
17
18
|
var EmptySessionsView = require('./EmptySessionsView/EmptySessionsView.cjs');
|
|
19
|
+
var SessionListItem = require('./SessionListItem/SessionListItem.cjs');
|
|
18
20
|
|
|
19
|
-
const SessionManagementView = () => {
|
|
21
|
+
const SessionManagementView = ({ bannerMessage, }) => {
|
|
20
22
|
const { t } = reactI18next.useTranslation();
|
|
21
23
|
const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
|
|
24
|
+
const sessions = React.useMemo(() => [
|
|
25
|
+
{
|
|
26
|
+
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
|
|
27
|
+
permissions: [],
|
|
28
|
+
sessionId: '1',
|
|
29
|
+
site: 'app.lumfi.xyz',
|
|
30
|
+
url: 'https://app.lumfi.xyz',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
|
|
34
|
+
permissions: [],
|
|
35
|
+
sessionId: '2',
|
|
36
|
+
site: 'app.sophon.xyz',
|
|
37
|
+
url: 'https://app.sophon.xyz',
|
|
38
|
+
},
|
|
39
|
+
], []);
|
|
22
40
|
const handleBackButtonClick = React.useCallback(() => {
|
|
23
41
|
setDynamicWidgetView('account-and-security-settings');
|
|
24
42
|
}, [setDynamicWidgetView]);
|
|
25
43
|
const handleInfoButtonClick = React.useCallback(() => {
|
|
26
44
|
setDynamicWidgetView('session-management-info');
|
|
27
45
|
}, [setDynamicWidgetView]);
|
|
46
|
+
const handleRevokeAccessClick = React.useCallback((sessionId) => {
|
|
47
|
+
setDynamicWidgetView('session-management-revoke-access', {
|
|
48
|
+
sessionId,
|
|
49
|
+
});
|
|
50
|
+
}, [setDynamicWidgetView]);
|
|
28
51
|
const renderBackButton = () => (jsxRuntime.jsx(IconButton.IconButton, { onClick: handleBackButtonClick, "aria-label": t('dyn_session_management.aria.back_button_label'), children: jsxRuntime.jsx(chevronLeft.ReactComponent, {}) }));
|
|
29
52
|
const renderInfoButton = () => (jsxRuntime.jsx(IconButton.IconButton, { onClick: handleInfoButtonClick, "aria-label": t('dyn_session_management.aria.info_button_label'), children: jsxRuntime.jsx(footerInfoIcon.ReactComponent, {}) }));
|
|
30
|
-
return (jsxRuntime.jsxs("div", { className: 'session-management-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: renderBackButton(), trailing: renderInfoButton(), displayBorder: true, variant: 'filled', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_session_management.title', children: t('dyn_session_management.title') }) }), jsxRuntime.jsx("div", { className: 'session-management-view__body', children: jsxRuntime.jsx(EmptySessionsView.EmptySessionsView, {}) })] }));
|
|
53
|
+
return (jsxRuntime.jsxs("div", { className: 'session-management-view', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { leading: renderBackButton(), trailing: renderInfoButton(), displayBorder: true, variant: 'filled', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_session_management.title', children: t('dyn_session_management.title') }) }), jsxRuntime.jsx("div", { className: 'session-management-view__banner', children: bannerMessage && (jsxRuntime.jsx(ErrorContainer.ErrorContainer, { variant: bannerMessage.type, withIcon: false, children: bannerMessage.message })) }), jsxRuntime.jsx("div", { className: 'session-management-view__body', children: sessions.length === 0 ? (jsxRuntime.jsx(EmptySessionsView.EmptySessionsView, {})) : (jsxRuntime.jsx("div", { className: 'session-management-view__sessions-container', children: sessions.map((session) => (jsxRuntime.jsx(SessionListItem.SessionListItem, { session: session, onRevokeAccessClick: handleRevokeAccessClick }, session.sessionId))) })) })] }));
|
|
31
54
|
};
|
|
32
55
|
|
|
33
56
|
exports.SessionManagementView = SessionManagementView;
|
package/src/lib/widgets/DynamicWidget/views/SessionManagementView/SessionManagementView.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
export
|
|
2
|
+
export interface SessionManagementViewProps {
|
|
3
|
+
bannerMessage?: {
|
|
4
|
+
type: 'success' | 'error';
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare const SessionManagementView: FC<SessionManagementViewProps>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { useCallback } from 'react';
|
|
3
|
+
import { useMemo, useCallback } from 'react';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { ReactComponent as SvgChevronLeft } from '../../../../shared/assets/chevron-left.js';
|
|
6
6
|
import { ReactComponent as SvgFooterInfoIcon } from '../../../../shared/assets/footer-info-icon.js';
|
|
@@ -10,20 +10,43 @@ import { useWidgetContext } from '../../context/DynamicWidgetContext.js';
|
|
|
10
10
|
import { ModalHeader } from '../../../../components/ModalHeader/ModalHeader.js';
|
|
11
11
|
import { Typography } from '../../../../components/Typography/Typography.js';
|
|
12
12
|
import { IconButton } from '../../../../components/IconButton/IconButton.js';
|
|
13
|
+
import { ErrorContainer } from '../../../../components/ErrorContainer/ErrorContainer.js';
|
|
13
14
|
import { EmptySessionsView } from './EmptySessionsView/EmptySessionsView.js';
|
|
15
|
+
import { SessionListItem } from './SessionListItem/SessionListItem.js';
|
|
14
16
|
|
|
15
|
-
const SessionManagementView = () => {
|
|
17
|
+
const SessionManagementView = ({ bannerMessage, }) => {
|
|
16
18
|
const { t } = useTranslation();
|
|
17
19
|
const { setDynamicWidgetView } = useWidgetContext();
|
|
20
|
+
const sessions = useMemo(() => [
|
|
21
|
+
{
|
|
22
|
+
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
|
|
23
|
+
permissions: [],
|
|
24
|
+
sessionId: '1',
|
|
25
|
+
site: 'app.lumfi.xyz',
|
|
26
|
+
url: 'https://app.lumfi.xyz',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
|
|
30
|
+
permissions: [],
|
|
31
|
+
sessionId: '2',
|
|
32
|
+
site: 'app.sophon.xyz',
|
|
33
|
+
url: 'https://app.sophon.xyz',
|
|
34
|
+
},
|
|
35
|
+
], []);
|
|
18
36
|
const handleBackButtonClick = useCallback(() => {
|
|
19
37
|
setDynamicWidgetView('account-and-security-settings');
|
|
20
38
|
}, [setDynamicWidgetView]);
|
|
21
39
|
const handleInfoButtonClick = useCallback(() => {
|
|
22
40
|
setDynamicWidgetView('session-management-info');
|
|
23
41
|
}, [setDynamicWidgetView]);
|
|
42
|
+
const handleRevokeAccessClick = useCallback((sessionId) => {
|
|
43
|
+
setDynamicWidgetView('session-management-revoke-access', {
|
|
44
|
+
sessionId,
|
|
45
|
+
});
|
|
46
|
+
}, [setDynamicWidgetView]);
|
|
24
47
|
const renderBackButton = () => (jsx(IconButton, { onClick: handleBackButtonClick, "aria-label": t('dyn_session_management.aria.back_button_label'), children: jsx(SvgChevronLeft, {}) }));
|
|
25
48
|
const renderInfoButton = () => (jsx(IconButton, { onClick: handleInfoButtonClick, "aria-label": t('dyn_session_management.aria.info_button_label'), children: jsx(SvgFooterInfoIcon, {}) }));
|
|
26
|
-
return (jsxs("div", { className: 'session-management-view', children: [jsx(ModalHeader, { leading: renderBackButton(), trailing: renderInfoButton(), displayBorder: true, variant: 'filled', children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_session_management.title', children: t('dyn_session_management.title') }) }), jsx("div", { className: 'session-management-view__body', children: jsx(EmptySessionsView, {}) })] }));
|
|
49
|
+
return (jsxs("div", { className: 'session-management-view', children: [jsx(ModalHeader, { leading: renderBackButton(), trailing: renderInfoButton(), displayBorder: true, variant: 'filled', children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_session_management.title', children: t('dyn_session_management.title') }) }), jsx("div", { className: 'session-management-view__banner', children: bannerMessage && (jsx(ErrorContainer, { variant: bannerMessage.type, withIcon: false, children: bannerMessage.message })) }), jsx("div", { className: 'session-management-view__body', children: sessions.length === 0 ? (jsx(EmptySessionsView, {})) : (jsx("div", { className: 'session-management-view__sessions-container', children: sessions.map((session) => (jsx(SessionListItem, { session: session, onRevokeAccessClick: handleRevokeAccessClick }, session.sessionId))) })) })] }));
|
|
27
50
|
};
|
|
28
51
|
|
|
29
52
|
export { SessionManagementView };
|