@adonis-agora/authkit-server 0.80.0 → 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.0",
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",
@@ -60,17 +60,17 @@
60
60
  "@adonis-agora/durable": ">=0.7.0 <1.0.0",
61
61
  "@adonis-agora/media": ">=0.5.0 <1.0.0",
62
62
  "@adonis-agora/telescope": ">=0.1.0 <1.0.0",
63
- "@adonisjs/ally": "6.3.0",
64
- "@adonisjs/auth": "10.1.0",
65
- "@adonisjs/core": "7.5.0",
66
- "@adonisjs/drive": "4.0.0",
67
- "@adonisjs/lock": "2.1.0",
68
- "@adonisjs/lucid": "22.4.2",
69
- "@adonisjs/redis": "11.0.0",
70
- "@adonisjs/session": "8.1.0",
71
- "@adonisjs/shield": "9.0.0",
72
- "@vinejs/vine": "4.4.0",
73
- "edge.js": "6.5.1"
63
+ "@adonisjs/ally": "^6.3.0",
64
+ "@adonisjs/auth": "^10.1.0",
65
+ "@adonisjs/core": "^7.5.0",
66
+ "@adonisjs/drive": "^4.0.0",
67
+ "@adonisjs/lock": "^2.1.0",
68
+ "@adonisjs/lucid": "^22.4.2",
69
+ "@adonisjs/redis": "^9.2.0 || ^10.0.0 || ^11.0.0",
70
+ "@adonisjs/session": "^8.1.0",
71
+ "@adonisjs/shield": "^9.0.0",
72
+ "@vinejs/vine": "^4.4.0",
73
+ "edge.js": "^6.5.1"
74
74
  },
75
75
  "peerDependenciesMeta": {
76
76
  "@adonis-agora/durable": {
@@ -113,7 +113,7 @@
113
113
  "qrcode": "1.5.4"
114
114
  },
115
115
  "devDependencies": {
116
- "@adonis-agora/authkit-react": "0.24.0",
116
+ "@adonis-agora/authkit-react": "0.24.1",
117
117
  "@adonis-agora/durable": "0.40.0",
118
118
  "@adonis-agora/telescope": "0.21.1",
119
119
  "@adonisjs/ally": "6.3.0",
@@ -145,7 +145,7 @@ JWKS, and fakes the authenticator for controller tests:
145
145
 
146
146
  ```ts
147
147
  import { mintTestIdToken, serveJwks, fakeAuthenticator } from '@adonis-agora/authkit-testing'
148
- import { resolvers } from '@adonis-agora/authkit-client'
148
+ import { conventionEndpoints, resolvers } from '@adonis-agora/authkit-client'
149
149
 
150
150
  const { token, jwks } = await mintTestIdToken({
151
151
  issuer: 'https://idp.test',
@@ -160,6 +160,8 @@ const resolver = await factory.resolver({
160
160
  clientId: 'my-app',
161
161
  sessionKey: 'authkit',
162
162
  globalRolesClaim: 'roles',
163
+ endpoints: async () => conventionEndpoints('https://idp.test'),
164
+ logger: { warn: () => {} },
163
165
  })
164
166
  const ctx = { auth: fakeAuthenticator({ identity: null }) } // anonymous request fake
165
167
  await served.close()
@@ -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 }) {