@djangocfg/layouts 2.1.667 → 2.1.669
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/README.md +2 -2
- package/package.json +19 -19
- package/src/components/account/AccountMenu.test.tsx +6 -0
- package/src/components/account/AccountMenu.tsx +4 -6
- package/src/layouts/AuthLayout/components/steps/OTPStep.test.tsx +83 -0
- package/src/layouts/AuthLayout/components/steps/OTPStep.tsx +0 -6
- package/src/layouts/AuthLayout/shells/AuthShell.tsx +1 -1
- package/src/layouts/AuthLayout/styles/auth.css +0 -15
- package/src/utils/config.ts +1 -2
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# @djangocfg/layouts
|
|
8
8
|
|
|
9
|
-
Layouts, app shell, and providers for **Next.js App Router**. Part of **[DjangoCFG](https://djangocfg.
|
|
9
|
+
Layouts, app shell, and providers for **Next.js App Router**. Part of **[DjangoCFG](https://djangocfg.cmdop.ai)**.
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
pnpm add @djangocfg/layouts
|
|
@@ -296,4 +296,4 @@ Extensions: `@djangocfg/ext-newsletter`, `ext-knowbase`, `ext-leads`, `ext-payme
|
|
|
296
296
|
|
|
297
297
|
## License
|
|
298
298
|
|
|
299
|
-
MIT — [DjangoCFG](https://djangocfg.
|
|
299
|
+
MIT — [DjangoCFG](https://djangocfg.cmdop.ai)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/layouts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.669",
|
|
4
4
|
"description": "Simple, straightforward layout components for Next.js - import and use with props",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"layouts",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
],
|
|
15
15
|
"author": {
|
|
16
16
|
"name": "DjangoCFG",
|
|
17
|
-
"url": "https://djangocfg.
|
|
17
|
+
"url": "https://djangocfg.cmdop.ai"
|
|
18
18
|
},
|
|
19
|
-
"homepage": "https://djangocfg.
|
|
19
|
+
"homepage": "https://djangocfg.cmdop.ai",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://github.com/
|
|
23
|
-
"directory": "packages/layouts"
|
|
22
|
+
"url": "git+https://github.com/commandoperator/cmdop-djangocfg.git",
|
|
23
|
+
"directory": "solution/projects/frontend/packages/layouts"
|
|
24
24
|
},
|
|
25
25
|
"bugs": {
|
|
26
|
-
"url": "https://github.com/
|
|
26
|
+
"url": "https://github.com/commandoperator/cmdop-djangocfg/issues"
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"main": "./src/index.ts",
|
|
@@ -91,12 +91,12 @@
|
|
|
91
91
|
"test": "vitest run"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"@djangocfg/analytics": "^2.1.
|
|
95
|
-
"@djangocfg/api": "^2.1.
|
|
96
|
-
"@djangocfg/devtools": "^2.1.
|
|
97
|
-
"@djangocfg/i18n": "^2.1.
|
|
98
|
-
"@djangocfg/realtime": "^2.1.
|
|
99
|
-
"@djangocfg/ui-core": "^2.1.
|
|
94
|
+
"@djangocfg/analytics": "^2.1.669",
|
|
95
|
+
"@djangocfg/api": "^2.1.669",
|
|
96
|
+
"@djangocfg/devtools": "^2.1.669",
|
|
97
|
+
"@djangocfg/i18n": "^2.1.669",
|
|
98
|
+
"@djangocfg/realtime": "^2.1.669",
|
|
99
|
+
"@djangocfg/ui-core": "^2.1.669",
|
|
100
100
|
"@hookform/resolvers": "^5.2.2 || ^7.0.2",
|
|
101
101
|
"@tanstack/react-query": "^5.108.2",
|
|
102
102
|
"consola": "^3.4.2",
|
|
@@ -123,13 +123,13 @@
|
|
|
123
123
|
"qrcode.react": "^4.2.0"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
|
-
"@djangocfg/analytics": "^2.1.
|
|
127
|
-
"@djangocfg/api": "^2.1.
|
|
128
|
-
"@djangocfg/devtools": "^2.1.
|
|
129
|
-
"@djangocfg/i18n": "^2.1.
|
|
130
|
-
"@djangocfg/realtime": "^2.1.
|
|
131
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
132
|
-
"@djangocfg/ui-core": "^2.1.
|
|
126
|
+
"@djangocfg/analytics": "^2.1.669",
|
|
127
|
+
"@djangocfg/api": "^2.1.669",
|
|
128
|
+
"@djangocfg/devtools": "^2.1.669",
|
|
129
|
+
"@djangocfg/i18n": "^2.1.669",
|
|
130
|
+
"@djangocfg/realtime": "^2.1.669",
|
|
131
|
+
"@djangocfg/typescript-config": "^2.1.669",
|
|
132
|
+
"@djangocfg/ui-core": "^2.1.669",
|
|
133
133
|
"@storybook/react-vite": "^10.6.5",
|
|
134
134
|
"@tanstack/react-query": "5.108.2",
|
|
135
135
|
"@types/node": "^25.9.5",
|
|
@@ -72,6 +72,12 @@ describe('AccountMenu', () => {
|
|
|
72
72
|
expect(host!.querySelector('[aria-haspopup="menu"]')).toBeNull();
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
it('signed out: one focusable control, no button inside the link', async () => {
|
|
76
|
+
await mount(<AccountMenu><AccountAvatarTrigger /></AccountMenu>);
|
|
77
|
+
expect(host!.querySelector('a button, button a')).toBeNull();
|
|
78
|
+
expect(host!.querySelectorAll('a[href], button, [tabindex]:not([tabindex="-1"])')).toHaveLength(1);
|
|
79
|
+
});
|
|
80
|
+
|
|
75
81
|
it('signed out with authPath: link goes there; signIn="none" renders nothing', async () => {
|
|
76
82
|
await mount(<AccountMenu authPath="/login"><AccountAvatarTrigger /></AccountMenu>);
|
|
77
83
|
expect(host!.querySelector('a')?.getAttribute('href')).toBe('/login');
|
|
@@ -16,7 +16,7 @@ import { ArrowRight } from 'lucide-react';
|
|
|
16
16
|
import React from 'react';
|
|
17
17
|
|
|
18
18
|
import { useAppT } from '@djangocfg/i18n';
|
|
19
|
-
import { Button, Link, MenuBuilder } from '@djangocfg/ui-core/components';
|
|
19
|
+
import { Button, ButtonLink, Link, MenuBuilder } from '@djangocfg/ui-core/components';
|
|
20
20
|
import { useAuth } from '@djangocfg/api/auth';
|
|
21
21
|
import { isDev } from '@djangocfg/ui-core/lib';
|
|
22
22
|
|
|
@@ -74,11 +74,9 @@ export function AccountMenu({
|
|
|
74
74
|
);
|
|
75
75
|
}
|
|
76
76
|
return (
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
</Button>
|
|
81
|
-
</Link>
|
|
77
|
+
<ButtonLink href={authPath ?? routes.auth} variant="default" size="sm" className="h-9 rounded-full px-5">
|
|
78
|
+
{label}
|
|
79
|
+
</ButtonLink>
|
|
82
80
|
);
|
|
83
81
|
}
|
|
84
82
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import React, { act } from 'react';
|
|
3
|
+
import { createRoot } from 'react-dom/client';
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
|
|
6
|
+
import { OTPStep } from './OTPStep';
|
|
7
|
+
|
|
8
|
+
const form = vi.hoisted(() => ({
|
|
9
|
+
identifier: 'fixture@example.com',
|
|
10
|
+
otp: '1234',
|
|
11
|
+
isLoading: false,
|
|
12
|
+
error: 'Invalid verification code',
|
|
13
|
+
isRateLimited: false,
|
|
14
|
+
rateLimitLabel: '',
|
|
15
|
+
resendSeconds: 0,
|
|
16
|
+
resendLabel: '',
|
|
17
|
+
webmail: null,
|
|
18
|
+
setOtp: vi.fn(),
|
|
19
|
+
handleOTPSubmit: vi.fn(async (event: React.FormEvent) => event.preventDefault()),
|
|
20
|
+
handleResendOTP: vi.fn(),
|
|
21
|
+
handleBackToIdentifier: vi.fn(),
|
|
22
|
+
isAutoSubmittingFromUrl: { current: false },
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
vi.mock('../../context', () => ({ useAuthFormContext: () => form }));
|
|
26
|
+
vi.mock('../../../../utils', () => ({ config: { isDevelopment: true } }));
|
|
27
|
+
vi.mock('@djangocfg/api/auth', () => ({
|
|
28
|
+
AUTH_CONSTANTS: { EMAIL_OTP_LENGTH: 4, TOTP_LENGTH: 6, BACKUP_CODE_MAX_LENGTH: 12 },
|
|
29
|
+
}));
|
|
30
|
+
vi.mock('@djangocfg/i18n', () => ({
|
|
31
|
+
useAppT: () => (key: string) => key === 'layouts.auth.dev.anyCodeWorks'
|
|
32
|
+
? 'Dev Mode: Any code works'
|
|
33
|
+
: key,
|
|
34
|
+
}));
|
|
35
|
+
vi.mock('@djangocfg/ui-core/components', () => ({
|
|
36
|
+
Link: ({ children }: { children: React.ReactNode }) => <a href="/">{children}</a>,
|
|
37
|
+
OTPInput: ({ value, onChange }: { value: string; onChange: (value: string) => void }) =>
|
|
38
|
+
<input aria-label="Verification code" value={value} onChange={e => onChange(e.target.value)} />,
|
|
39
|
+
}));
|
|
40
|
+
vi.mock('../shared', async () => ({
|
|
41
|
+
...(await import('../shared/AuthContainer')),
|
|
42
|
+
...(await import('../shared/AuthHeader')),
|
|
43
|
+
...(await import('../shared/AuthButton')),
|
|
44
|
+
...(await import('../shared/AuthLink')),
|
|
45
|
+
...(await import('../shared/AuthError')),
|
|
46
|
+
...(await import('../shared/AuthOTPInput')),
|
|
47
|
+
WebmailIcon: () => null,
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
|
|
51
|
+
|
|
52
|
+
let cleanup: (() => void) | undefined;
|
|
53
|
+
afterEach(() => {
|
|
54
|
+
cleanup?.();
|
|
55
|
+
cleanup = undefined;
|
|
56
|
+
form.handleOTPSubmit.mockClear();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
function render() {
|
|
60
|
+
const host = document.createElement('div');
|
|
61
|
+
document.body.append(host);
|
|
62
|
+
const root = createRoot(host);
|
|
63
|
+
act(() => root.render(<OTPStep />));
|
|
64
|
+
cleanup = () => { act(() => root.unmount()); host.remove(); };
|
|
65
|
+
return host;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
describe('OTPStep server-owned verification', () => {
|
|
69
|
+
it('does not claim a development frontend can bypass OTP verification', () => {
|
|
70
|
+
const host = render();
|
|
71
|
+
expect(host.querySelector('.auth-dev-notice')).toBeNull();
|
|
72
|
+
expect(host.textContent).not.toContain('Any code works');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('keeps the backend error and verification action visible', () => {
|
|
76
|
+
const host = render();
|
|
77
|
+
expect(host.querySelector('[role="alert"]')?.textContent).toContain(form.error);
|
|
78
|
+
const submit = host.querySelector<HTMLButtonElement>('button[type="submit"]')!;
|
|
79
|
+
expect(submit.disabled).toBe(false);
|
|
80
|
+
act(() => submit.click());
|
|
81
|
+
expect(form.handleOTPSubmit).toHaveBeenCalledOnce();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -4,7 +4,6 @@ import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from '
|
|
|
4
4
|
|
|
5
5
|
import { useAppT } from '@djangocfg/i18n';
|
|
6
6
|
|
|
7
|
-
import { config } from '../../../../utils';
|
|
8
7
|
import { AUTH } from '../../constants';
|
|
9
8
|
import { useAuthFormContext } from '../../context';
|
|
10
9
|
import {
|
|
@@ -59,7 +58,6 @@ function OTPStepRaw() {
|
|
|
59
58
|
button: t('layouts.auth.otp.button'),
|
|
60
59
|
resend: t('layouts.auth.otp.resend'),
|
|
61
60
|
changeEmail: t('layouts.auth.otp.changeEmail'),
|
|
62
|
-
devMode: t('layouts.auth.dev.anyCodeWorks'),
|
|
63
61
|
}), [t]);
|
|
64
62
|
|
|
65
63
|
// "Open Gmail / Outlook / …" — jumps straight to a search for our email.
|
|
@@ -134,10 +132,6 @@ function OTPStepRaw() {
|
|
|
134
132
|
size="lg"
|
|
135
133
|
/>
|
|
136
134
|
|
|
137
|
-
{config.isDevelopment && (
|
|
138
|
-
<div className="auth-dev-notice">{content.devMode}</div>
|
|
139
|
-
)}
|
|
140
|
-
|
|
141
135
|
{webmail && (
|
|
142
136
|
<AuthButton
|
|
143
137
|
type="button"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import React, { memo, useMemo } from 'react';
|
|
4
4
|
|
|
5
|
-
import { useImageLoader } from '@djangocfg/ui-core/hooks';
|
|
5
|
+
import { useImageLoader } from '@djangocfg/ui-core/hooks/image-loader';
|
|
6
6
|
|
|
7
7
|
import { AuthShellProvider } from './context';
|
|
8
8
|
import { CenteredShell } from './CenteredShell';
|
|
@@ -707,21 +707,6 @@ a.auth-logo:focus-visible {
|
|
|
707
707
|
color: var(--auth-muted);
|
|
708
708
|
}
|
|
709
709
|
|
|
710
|
-
/* ===== DEV NOTICE ===== */
|
|
711
|
-
|
|
712
|
-
/* Uses the shared warning surface tokens (defined for both themes) instead of
|
|
713
|
-
hardcoded amber — keeps the dev banner consistent with the rest of the
|
|
714
|
-
system and drops the manual `.dark` override. */
|
|
715
|
-
.auth-dev-notice {
|
|
716
|
-
padding: 0.5rem 0.75rem;
|
|
717
|
-
font-size: 0.75rem;
|
|
718
|
-
text-align: center;
|
|
719
|
-
color: var(--warning-foreground);
|
|
720
|
-
background: var(--warning-background);
|
|
721
|
-
border-radius: var(--auth-radius-xs);
|
|
722
|
-
border: 1px solid var(--warning-border);
|
|
723
|
-
}
|
|
724
|
-
|
|
725
710
|
/* ===== INSTRUCTION ===== */
|
|
726
711
|
|
|
727
712
|
/* ===== RESPONSIVE ===== */
|
package/src/utils/config.ts
CHANGED
|
@@ -5,8 +5,7 @@ import { isDev, isProd } from '@djangocfg/ui-core/lib';
|
|
|
5
5
|
|
|
6
6
|
export const config = {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* In development mode, any OTP code is accepted for authentication
|
|
8
|
+
* Frontend build mode only; the server owns authentication policy.
|
|
10
9
|
*/
|
|
11
10
|
isDevelopment: isDev,
|
|
12
11
|
isProduction: isProd,
|