@adonis-agora/authkit-client 0.20.4 → 1.0.0-rc.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +957 -0
  2. package/README.md +47 -12
  3. package/build/auth.d.ts +2 -0
  4. package/build/auth.js +1 -0
  5. package/build/authkit_context_middleware.d.ts +1 -0
  6. package/build/authkit_context_middleware.js +2 -0
  7. package/build/commands/configure.d.ts +10 -0
  8. package/build/commands/configure.js +57 -2
  9. package/build/index.d.ts +3 -2
  10. package/build/index.js +1 -1
  11. package/build/providers/authkit_client_provider.d.ts +8 -1
  12. package/build/providers/authkit_client_provider.js +28 -12
  13. package/build/src/authenticator.d.ts +4 -3
  14. package/build/src/authenticator.js +6 -3
  15. package/build/src/host/authkit_client_guard.d.ts +51 -36
  16. package/build/src/host/authkit_client_guard.js +97 -46
  17. package/build/src/host/dashboard_guard.d.ts +3 -7
  18. package/build/src/host/dashboard_guard.js +3 -7
  19. package/build/src/host/request_authenticator.d.ts +28 -10
  20. package/build/src/host/request_authenticator.js +5 -3
  21. package/build/src/middleware/authkit_context_middleware.d.ts +3 -4
  22. package/build/src/middleware/authkit_context_middleware.js +5 -4
  23. package/build/src/middleware/backchannel_revocation_middleware.d.ts +1 -1
  24. package/build/src/middleware/backchannel_revocation_middleware.js +1 -1
  25. package/build/src/middleware/require_org_middleware.d.ts +3 -2
  26. package/build/src/middleware/require_org_middleware.js +5 -4
  27. package/build/src/resolvers/dpop_proof.d.ts +34 -0
  28. package/build/src/resolvers/dpop_proof.js +92 -0
  29. package/build/src/resolvers/factory.d.ts +5 -0
  30. package/build/src/resolvers/factory.js +1 -0
  31. package/build/src/resolvers/jwt_resolver.d.ts +9 -0
  32. package/build/src/resolvers/jwt_resolver.js +47 -3
  33. package/build/stubs/config/auth.stub +30 -0
  34. package/build/stubs/config/authkit_client.stub +2 -1
  35. package/build/stubs/middleware/auth_middleware.stub +25 -0
  36. package/build/stubs/middleware/silent_auth_middleware.stub +16 -0
  37. package/build/types.d.ts +5 -32
  38. package/build/types.js +1 -1
  39. package/package.json +12 -17
  40. package/skills/authkit-rp-client/SKILL.md +102 -47
  41. package/stubs/config/auth.stub +30 -0
  42. package/stubs/config/authkit_client.stub +2 -1
  43. package/stubs/middleware/auth_middleware.stub +25 -0
  44. package/stubs/middleware/silent_auth_middleware.stub +16 -0
  45. package/build/src/host/ctx_auth.d.ts +0 -6
  46. package/build/src/host/ctx_auth.js +0 -8
  47. package/build/src/middleware/auth_middleware.d.ts +0 -13
  48. package/build/src/middleware/auth_middleware.js +0 -13
  49. package/build/src/middleware/authkit_middleware.d.ts +0 -6
  50. package/build/src/middleware/authkit_middleware.js +0 -24
  51. package/build/src/middleware/silent_auth_middleware.d.ts +0 -13
  52. package/build/src/middleware/silent_auth_middleware.js +0 -15
@@ -1,13 +0,0 @@
1
- import type { HttpContext } from '@adonisjs/core/http';
2
- import type { NextFn } from '@adonisjs/core/types/http';
3
- export interface AuthMiddlewareOptions {
4
- /** Para onde redirecionar quando não autenticado. Default: `/auth/login`. */
5
- redirectTo?: string;
6
- }
7
- /**
8
- * Middleware de autenticação do AuthKit: exige sessão válida. Autorização por role saiu daqui — use
9
- * `@adonis-agora/authz` (ou Bouncer) na rota. AuthKit só autentica.
10
- */
11
- export default class AuthkitAuthMiddleware {
12
- handle(ctx: HttpContext, next: NextFn, options?: AuthMiddlewareOptions): Promise<any>;
13
- }
@@ -1,13 +0,0 @@
1
- import { ctxAuth } from '../host/ctx_auth.js';
2
- /**
3
- * Middleware de autenticação do AuthKit: exige sessão válida. Autorização por role saiu daqui — use
4
- * `@adonis-agora/authz` (ou Bouncer) na rota. AuthKit só autentica.
5
- */
6
- export default class AuthkitAuthMiddleware {
7
- async handle(ctx, next, options = {}) {
8
- const ok = await ctxAuth(ctx).check();
9
- if (!ok)
10
- return ctx.response.redirect(options.redirectTo ?? '/auth/login');
11
- return next();
12
- }
13
- }
@@ -1,6 +0,0 @@
1
- import '../../container_bindings.js';
2
- import type { HttpContext } from '@adonisjs/core/http';
3
- import type { NextFn } from '@adonisjs/core/types/http';
4
- export default class AuthkitMiddleware {
5
- handle(ctx: HttpContext, next: NextFn): Promise<any>;
6
- }
@@ -1,24 +0,0 @@
1
- // Side-effect import: carries this package's `ContainerBindings` declaration into
2
- // the emitted `.d.ts`, so `containerResolver.make('authkit.client')` is typed in a
3
- // consumer's program. It must be a bare side-effect import — the
4
- // `import type {} from` form is erased from the declaration output.
5
- //
6
- // It points at `container_bindings.js`, NOT at the root `types.js`. `types.js`
7
- // also augments `HttpContext.auth`, and importing it here pushed that
8
- // augmentation into every app that registers this middleware, where it collided
9
- // with the app's own `auth: Authenticator<AppUser>`. `skipLibCheck` hid the
10
- // conflict and the library's non-parameterised declaration won, collapsing
11
- // `auth.getUser()` to `unknown` across the consumer's codebase. Typing `ctx.auth`
12
- // is the host's decision, taken by importing
13
- // `@adonis-agora/authkit-client/types`; it is not this middleware's to impose.
14
- import '../../container_bindings.js';
15
- import { setCtxAuth } from '../host/ctx_auth.js';
16
- export default class AuthkitMiddleware {
17
- async handle(ctx, next) {
18
- const manager = await ctx.containerResolver.make('authkit.client');
19
- // Renova proativamente o TokenSet (rotação de refresh token) antes de resolver.
20
- await manager.maybeRefresh(ctx);
21
- setCtxAuth(ctx, await manager.createAuthenticator(ctx));
22
- return next();
23
- }
24
- }
@@ -1,13 +0,0 @@
1
- import type { HttpContext } from '@adonisjs/core/http';
2
- import type { NextFn } from '@adonisjs/core/types/http';
3
- /**
4
- * Resolve a identidade da sessão (popula `ctx.auth`) SEM exigir login — útil em
5
- * rotas públicas que mostram estado logado/deslogado. Nunca redireciona.
6
- *
7
- * ```ts
8
- * silentAuth: () => import('@adonis-agora/authkit-client/silent_auth_middleware'),
9
- * ```
10
- */
11
- export default class AuthkitSilentAuthMiddleware {
12
- handle(ctx: HttpContext, next: NextFn): Promise<any>;
13
- }
@@ -1,15 +0,0 @@
1
- import { ctxAuth } from '../host/ctx_auth.js';
2
- /**
3
- * Resolve a identidade da sessão (popula `ctx.auth`) SEM exigir login — útil em
4
- * rotas públicas que mostram estado logado/deslogado. Nunca redireciona.
5
- *
6
- * ```ts
7
- * silentAuth: () => import('@adonis-agora/authkit-client/silent_auth_middleware'),
8
- * ```
9
- */
10
- export default class AuthkitSilentAuthMiddleware {
11
- async handle(ctx, next) {
12
- await ctxAuth(ctx).check();
13
- return next();
14
- }
15
- }