@adonis-agora/authkit-server 0.80.1 → 0.80.2

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.
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { stubsRoot } from '../stubs/main.js';
4
- import { resolveUiPreset, uiStubPaths } from './ui_preset.js';
4
+ import { resolveUiPreset, uiStubDestination, uiStubPaths } from './ui_preset.js';
5
5
  function assertPresetPrereqs(preset, appRoot) {
6
6
  if (preset !== 'react')
7
7
  return;
@@ -40,8 +40,11 @@ export async function configure(command) {
40
40
  },
41
41
  });
42
42
  await codemods.makeUsingStub(stubsRoot, 'models/auth_user.stub', {});
43
+ // As páginas React vão byte a byte: o `page.stub` só define o destino e o
44
+ // conteúdo vem do `.tsx` via `contentsFromFile`, sem passar pelo template
45
+ // engine (que quebraria nas crases das template literals — bug #194).
43
46
  for (const path of uiStubPaths(preset)) {
44
- await codemods.makeUsingStub(stubsRoot, path, {});
47
+ await codemods.makeUsingStub(stubsRoot, 'ui/react/page.stub', { destination: uiStubDestination(path) }, { contentsFromFile: join(stubsRoot, path) });
45
48
  }
46
49
  await codemods.updateRcFile((rcFile) => {
47
50
  rcFile.addProvider('@adonis-agora/authkit-server/authkit_server_provider');
@@ -1,4 +1,19 @@
1
1
  export type UiPreset = 'headless' | 'edge' | 'react';
2
2
  export declare function resolveUiPreset(value: string | undefined): UiPreset;
3
- /** Caminhos de stub (relativos ao stubsRoot) que o preset publica. */
3
+ /**
4
+ * Arquivos (relativos ao stubsRoot) que o preset publica.
5
+ *
6
+ * As páginas React são TSX puro, SEM frontmatter `{{{ exports() }}}`: o
7
+ * `configure` as publica via `ui/react/page.stub` + `contentsFromFile` (ver
8
+ * `uiStubDestination`). Elas não podem passar pelo template engine dos stubs —
9
+ * crases e `${...}` de template literal quebram a compilação (bug #194) —, e
10
+ * como são `.tsx` o formatter reescrevia o frontmatter para `{ exports() }`,
11
+ * que o gerador nem reconhece.
12
+ */
4
13
  export declare function uiStubPaths(preset: UiPreset): string[];
14
+ /**
15
+ * Destino, relativo à raiz do app, de um arquivo de `uiStubPaths('react')`:
16
+ * `ui/react/components/*` vai para `inertia/components/*` e `ui/react/pages/*`
17
+ * para `inertia/pages/authkit/*` (o `prefix` do `inertiaRenderer`).
18
+ */
19
+ export declare function uiStubDestination(path: string): string;
@@ -7,7 +7,16 @@ export function resolveUiPreset(value) {
7
7
  }
8
8
  return value;
9
9
  }
10
- /** Caminhos de stub (relativos ao stubsRoot) que o preset publica. */
10
+ /**
11
+ * Arquivos (relativos ao stubsRoot) que o preset publica.
12
+ *
13
+ * As páginas React são TSX puro, SEM frontmatter `{{{ exports() }}}`: o
14
+ * `configure` as publica via `ui/react/page.stub` + `contentsFromFile` (ver
15
+ * `uiStubDestination`). Elas não podem passar pelo template engine dos stubs —
16
+ * crases e `${...}` de template literal quebram a compilação (bug #194) —, e
17
+ * como são `.tsx` o formatter reescrevia o frontmatter para `{ exports() }`,
18
+ * que o gerador nem reconhece.
19
+ */
11
20
  export function uiStubPaths(preset) {
12
21
  switch (preset) {
13
22
  case 'headless':
@@ -44,3 +53,17 @@ export function uiStubPaths(preset) {
44
53
  ];
45
54
  }
46
55
  }
56
+ /**
57
+ * Destino, relativo à raiz do app, de um arquivo de `uiStubPaths('react')`:
58
+ * `ui/react/components/*` vai para `inertia/components/*` e `ui/react/pages/*`
59
+ * para `inertia/pages/authkit/*` (o `prefix` do `inertiaRenderer`).
60
+ */
61
+ export function uiStubDestination(path) {
62
+ if (path.startsWith('ui/react/components/')) {
63
+ return `inertia/components/${path.slice('ui/react/components/'.length)}`;
64
+ }
65
+ if (path.startsWith('ui/react/pages/')) {
66
+ return `inertia/pages/authkit/${path.slice('ui/react/pages/'.length)}`;
67
+ }
68
+ throw new Error(`authkit: stub de UI sem destino conhecido: ${path}`);
69
+ }
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/components/auth_shell.tsx') });
3
- }
4
-
5
1
  import type { ReactNode } from 'react';
6
2
 
7
3
  export interface AuthBrand {
@@ -0,0 +1,3 @@
1
+ {{{
2
+ exports({ to: app.makePath(destination) })
3
+ }}}
@@ -1,6 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/account/login.tsx') });
3
- }
4
1
  interface Props {
5
2
  csrfToken: string;
6
3
  error?: string;
@@ -1,6 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/account/mfa.tsx') });
3
- }
4
1
  interface Props {
5
2
  csrfToken: string;
6
3
  enabled: boolean;
@@ -1,6 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/account/tokens.tsx') });
3
- }
4
1
  interface TokenRow {
5
2
  id: string;
6
3
  name: string;
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/consent.tsx') });
3
- }
4
-
5
1
  import AuthShell, { type AuthBrand } from '../../components/auth_shell';
6
2
 
7
3
  export default function AuthkitConsent({
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/forgot.tsx') });
3
- }
4
-
5
1
  import AuthShell from '../../components/auth_shell';
6
2
 
7
3
  const inputClass =
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/login.tsx') });
3
- }
4
-
5
1
  import AuthShell, { type AuthBrand } from '../../components/auth_shell';
6
2
 
7
3
  const inputClass =
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/mfa-challenge.tsx') });
3
- }
4
-
5
1
  import { useRef, useState } from 'react';
6
2
  import AuthShell, { type AuthBrand } from '../../components/auth_shell';
7
3
 
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/reset.tsx') });
3
- }
4
-
5
1
  import AuthShell from '../../components/auth_shell';
6
2
 
7
3
  const inputClass =
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/signup.tsx') });
3
- }
4
-
5
1
  import AuthShell, { type AuthBrand } from '../../components/auth_shell';
6
2
 
7
3
  const inputClass =
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/verify-email.tsx') });
3
- }
4
-
5
1
  import AuthShell from '../../components/auth_shell';
6
2
 
7
3
  export default function AuthkitVerifyEmail({ verified }: { verified?: boolean }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonis-agora/authkit-server",
3
- "version": "0.80.1",
3
+ "version": "0.80.2",
4
4
  "description": "AdonisJS OIDC/OAuth2 provider (Identity Provider) toolkit: ejectable auth server with sessions, rate-limiting, MFA/TOTP, audit log, federated logout and OpenTelemetry metrics.",
5
5
  "license": "MIT",
6
6
  "author": "dudousxd",
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/components/auth_shell.tsx') });
3
- }
4
-
5
1
  import type { ReactNode } from 'react';
6
2
 
7
3
  export interface AuthBrand {
@@ -0,0 +1,3 @@
1
+ {{{
2
+ exports({ to: app.makePath(destination) })
3
+ }}}
@@ -1,6 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/account/login.tsx') });
3
- }
4
1
  interface Props {
5
2
  csrfToken: string;
6
3
  error?: string;
@@ -1,6 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/account/mfa.tsx') });
3
- }
4
1
  interface Props {
5
2
  csrfToken: string;
6
3
  enabled: boolean;
@@ -1,6 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/account/tokens.tsx') });
3
- }
4
1
  interface TokenRow {
5
2
  id: string;
6
3
  name: string;
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/consent.tsx') });
3
- }
4
-
5
1
  import AuthShell, { type AuthBrand } from '../../components/auth_shell';
6
2
 
7
3
  export default function AuthkitConsent({
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/forgot.tsx') });
3
- }
4
-
5
1
  import AuthShell from '../../components/auth_shell';
6
2
 
7
3
  const inputClass =
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/login.tsx') });
3
- }
4
-
5
1
  import AuthShell, { type AuthBrand } from '../../components/auth_shell';
6
2
 
7
3
  const inputClass =
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/mfa-challenge.tsx') });
3
- }
4
-
5
1
  import { useRef, useState } from 'react';
6
2
  import AuthShell, { type AuthBrand } from '../../components/auth_shell';
7
3
 
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/reset.tsx') });
3
- }
4
-
5
1
  import AuthShell from '../../components/auth_shell';
6
2
 
7
3
  const inputClass =
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/signup.tsx') });
3
- }
4
-
5
1
  import AuthShell, { type AuthBrand } from '../../components/auth_shell';
6
2
 
7
3
  const inputClass =
@@ -1,7 +1,3 @@
1
- {
2
- exports({ to: app.makePath('inertia/pages/authkit/verify-email.tsx') });
3
- }
4
-
5
1
  import AuthShell from '../../components/auth_shell';
6
2
 
7
3
  export default function AuthkitVerifyEmail({ verified }: { verified?: boolean }) {