@adonis-agora/authkit-server 1.0.0-rc.0 → 1.0.0-rc.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.
- package/CHANGELOG.md +38 -0
- package/README.md +4 -5
- package/build/index.d.ts +7 -11
- package/build/index.js +5 -9
- package/build/providers/authkit_server_provider.js +14 -8
- package/build/src/agents/config.d.ts +9 -13
- package/build/src/agents/config.js +17 -11
- package/build/src/agents/delegation_service.js +3 -3
- package/build/src/agents/delegation_store.d.ts +3 -2
- package/build/src/agents/delegation_store.js +6 -5
- package/build/src/agents/extension.d.ts +261 -0
- package/build/src/agents/extension.js +40 -0
- package/build/src/agents/middleware.js +1 -1
- package/build/src/agents/protocol.d.ts +4 -4
- package/build/src/agents/registry_store.d.ts +3 -2
- package/build/src/agents/registry_store.js +1 -1
- package/build/src/agents/runtime.d.ts +26 -7
- package/build/src/agents/runtime.js +110 -75
- package/build/src/audit/audit_sink.js +1 -1
- package/build/src/console_authorize.d.ts +56 -0
- package/build/src/console_authorize.js +85 -0
- package/build/src/define_config.d.ts +20 -14
- package/build/src/define_config.js +11 -8
- package/build/src/doctor/checks.d.ts +7 -1
- package/build/src/doctor/checks.js +47 -1
- package/build/src/host/account_api/account_api_controller.js +8 -6
- package/build/src/host/account_session_sign_in.d.ts +12 -0
- package/build/src/host/account_session_sign_in.js +19 -0
- package/build/src/host/admin_clients_service.js +10 -1
- package/build/src/host/admin_console/console_personal_agents_controller.d.ts +1 -6
- package/build/src/host/admin_console/console_personal_agents_controller.js +50 -30
- package/build/src/host/admin_console_warning.d.ts +8 -0
- package/build/src/host/admin_console_warning.js +18 -0
- package/build/src/host/admin_sessions_service.js +8 -5
- package/build/src/host/auth_host_config.d.ts +11 -2
- package/build/src/host/console_denied_page.d.ts +6 -0
- package/build/src/host/console_denied_page.js +18 -0
- package/build/src/host/console_sso.d.ts +24 -0
- package/build/src/host/console_sso.js +70 -0
- package/build/src/host/controllers/account_apps_controller.js +15 -11
- package/build/src/host/controllers/account_session_controller.js +10 -1
- package/build/src/host/controllers/console_sso_controller.d.ts +12 -0
- package/build/src/host/controllers/console_sso_controller.js +61 -0
- package/build/src/host/controllers/interaction_controller.js +3 -1
- package/build/src/host/csrf.d.ts +3 -3
- package/build/src/host/csrf.js +3 -13
- package/build/src/host/default_mailer.d.ts +11 -6
- package/build/src/host/default_mailer.js +16 -12
- package/build/src/host/i18n.d.ts +3 -14
- package/build/src/host/i18n.js +15 -13
- package/build/src/host/register_auth_host.d.ts +2 -0
- package/build/src/host/register_auth_host.js +110 -64
- package/build/src/host/ui-dist/assets/index-BqyJYRVX.js +67 -0
- package/build/src/host/ui-dist/index.html +1 -1
- package/build/src/provider/build_provider.js +6 -0
- package/build/src/provider/oidc_service.d.ts +1 -1
- package/build/src/provider/oidc_service.js +1 -1
- package/build/src/schema/ensure.d.ts +14 -0
- package/build/src/schema/ensure.js +43 -150
- package/package.json +5 -5
- package/build/src/agents/poppy/client_registry.d.ts +0 -50
- package/build/src/agents/poppy/client_registry.js +0 -260
- package/build/src/agents/poppy/config.d.ts +0 -396
- package/build/src/agents/poppy/config.js +0 -228
- package/build/src/agents/poppy/dpop.d.ts +0 -61
- package/build/src/agents/poppy/dpop.js +0 -158
- package/build/src/agents/poppy/email_code_sign_in.d.ts +0 -27
- package/build/src/agents/poppy/email_code_sign_in.js +0 -140
- package/build/src/agents/poppy/errors.d.ts +0 -25
- package/build/src/agents/poppy/errors.js +0 -25
- package/build/src/agents/poppy/replay.d.ts +0 -25
- package/build/src/agents/poppy/replay.js +0 -106
- package/build/src/agents/poppy/resource.d.ts +0 -100
- package/build/src/agents/poppy/resource.js +0 -129
- package/build/src/agents/poppy/safe_fetch.d.ts +0 -48
- package/build/src/agents/poppy/safe_fetch.js +0 -262
- package/build/src/agents/poppy/service.d.ts +0 -293
- package/build/src/agents/poppy/service.js +0 -1458
- package/build/src/agents/poppy/session_jwt.d.ts +0 -30
- package/build/src/agents/poppy/session_jwt.js +0 -133
- package/build/src/agents/poppy/store.d.ts +0 -106
- package/build/src/agents/poppy/store.js +0 -261
- package/build/src/agents/poppy/web_session.d.ts +0 -39
- package/build/src/agents/poppy/web_session.js +0 -122
- package/build/src/host/controllers/poppy_consent_controller.d.ts +0 -19
- package/build/src/host/controllers/poppy_consent_controller.js +0 -199
- package/build/src/host/controllers/poppy_controller.d.ts +0 -33
- package/build/src/host/controllers/poppy_controller.js +0 -219
- package/build/src/host/poppy_session_key.d.ts +0 -9
- package/build/src/host/poppy_session_key.js +0 -9
- package/build/src/host/ui-dist/assets/index-D0EIeyKK.js +0 -67
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# @adonis-agora/authkit-server
|
|
2
2
|
|
|
3
|
+
## 1.0.0-rc.2
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#456](https://github.com/DavideCarvalho/adonis-agora-authkit/pull/456) [`9c12ef9`](https://github.com/DavideCarvalho/adonis-agora-authkit/commit/9c12ef9c1c49db9d54a7da6d241264499ad76e18) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Poppy (the Personal Agent Protocol) moves out of `@adonis-agora/authkit-server` into the new `@adonis-agora/authkit-poppy` package, and authkit-server gains a stable extension surface for personal-agent protocols. See [Install `@adonis-agora/authkit-poppy` for Poppy](https://github.com/DavideCarvalho/adonis-agora-authkit/blob/main/apps/docs/content/docs/migrating-to-1-0.mdx#install-adonis-agoraauthkit-poppy-for-poppy).
|
|
8
|
+
|
|
9
|
+
Breaking changes (`@adonis-agora/authkit-server`):
|
|
10
|
+
|
|
11
|
+
- `personalAgents.poppy` is removed: install `@adonis-agora/authkit-poppy` and use `personalAgents: { extensions: [poppy({ ... })] }` with the same options. A config that still has `personalAgents.poppy` fails at boot. Routes, tables, tokens and sessions are unchanged, so no data migration is needed.
|
|
12
|
+
- Every Poppy export (`PoppyConfigInput` and the other `Poppy*` types, `poppyEmailCodeSignIn`, `verifyPoppyRequest`, `poppyAuth`, `poppyOf`, `poppyWebSession`, `poppyWebSessionOf`, `installPoppySlots`, `POPPY_AUTHENTICATE_SLOT`, `POPPY_WEB_SESSION_KEY`, `PoppyError`, `verifyDpopProof`, `accessTokenHash`, `hmacNonceSource`, `databaseReplayStore`, `memoryReplayStore`, `redisReplayStore`, `safeFetchJson`, `isBlockedAddress`, `SafeFetchError`, `maskEmail`) now comes from `@adonis-agora/authkit-poppy`.
|
|
13
|
+
- `mail.onPoppySignInCode` is removed: pass `sendCode` to `poppyEmailCodeSignIn()`.
|
|
14
|
+
- `authkitCsrfExceptions` no longer takes `poppyPrefix`; extensions' endpoints are exempted from the config (`personalAgentExtensions: false` turns that off).
|
|
15
|
+
- `ensureAuthkitSchema()` no longer creates the `auth_poppy_*` tables (the extension's tables are ensured at boot; `ensurePoppySchema()` for migrations).
|
|
16
|
+
- Admin console API: an extension's `protocols` entry is `{ label, requireRegistration, hostResolver, allowHttpIdentifiers, identifierLabel, identifierPlaceholder }`.
|
|
17
|
+
|
|
18
|
+
New, stable for 1.x: `personalAgents.extensions` and the types `PersonalAgentExtension`, `PersonalAgentExtensionDefinition`, `PersonalAgentExtensionContext`, `PersonalAgentRouteKit`, `PersonalAgentHost`, `PersonalAgentGrantLedger`, `PersonalAgentGrant`, `PersonalAgentRefreshToken`, `PersonalAgentAccessTokens`, `PersonalAgentProtocolRuntime`, `PersonalAgentGrantSummary`, `PersonalAgentConsoleSummary`, `ResolvedPersonalAgentExtension`, `AuthkitTable`; the functions `personalAgentExtensionRuntime`, `ensureAuthkitTables`, `sendAuthkitCodeEmail`, `signInAccountSession` and `signOutAccountSession`; and the `tables` option of `ensureAuthkitSchema`.
|
|
19
|
+
|
|
20
|
+
Breaking changes (`@adonis-agora/authkit-react`):
|
|
21
|
+
|
|
22
|
+
- `PersonalAgentProtocol` is `'pact'` or any extension id, and `PersonalAgentsOverview.protocols` has one entry per extension (`PersonalAgentExtensionOverview`) instead of a fixed `poppy` key. `AccountAgentGrant.protocol` uses `PersonalAgentProtocol`.
|
|
23
|
+
|
|
24
|
+
## 1.0.0-rc.1
|
|
25
|
+
|
|
26
|
+
### Major Changes
|
|
27
|
+
|
|
28
|
+
- [#451](https://github.com/DavideCarvalho/adonis-agora-authkit/pull/451) [`1162aee`](https://github.com/DavideCarvalho/adonis-agora-authkit/commit/1162aeeee00d4706b8515d89e37f93d172cec44a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The account and admin consoles now sign in through the IdP login by default.
|
|
29
|
+
|
|
30
|
+
- `accountSession.acceptIdpSession` defaults to `true`. Without a console session, `/account/*` and the admin console send the visitor to the IdP login (`/auth/console/sso`) and come back with the console open; a user already signed in to an app opens them directly.
|
|
31
|
+
- `/account/login` redirects to the IdP login. The password form stays at `/account/login?method=password` while password login is on.
|
|
32
|
+
- The console's idle timeout now also ends the IdP session the console was opened from, like "Sign out" already did.
|
|
33
|
+
- `accountSession: { acceptIdpSession: false }` with `authMethods: { password: false }` and no `accountLoginUrl` (passed to `registerAuthHost` or set in `routes`) now fails at boot when the routes are registered, since the consoles would have no way in. `authkit:doctor` warns about it, and when SSO is off.
|
|
34
|
+
- The client id `authkit-console` is reserved for the consoles' internal client (`response_type=none`, never listed in the console) and cannot be registered.
|
|
35
|
+
- New `admin.authorize`, the access check every `@adonis-agora` console takes: an inline function, an authorizer class (built through the container, so `@inject()` works) or a lazy import (`() => import('#policies/console_access')`). It runs after `admin.roles` (both must pass) on the shell and on every `{prefix}/api/*` route. An account without one of the roles still goes to `accountHome`.
|
|
36
|
+
- **Breaking:** without `admin.authorize`, the admin console is open outside production and answers 403 to every request in production. The app logs `[@adonis-agora/authkit-server] console has no \`authorize\` configured: …` once at boot, and `authkit:doctor` warns. To keep letting every admin in, set `admin: { enabled: true, roles: ['ADMIN'], authorize: () => true }`.
|
|
37
|
+
- An `authorize` denial answers 403 (an access-denied page, or `{ error: 'forbidden' }` for JSON); `reason: 'unauthenticated'` answers 401 (`{ error: 'unauthenticated' }`); `{ redirectTo }` redirects page navigations and answers 401 `{ error: 'unauthenticated', redirectTo }` to JSON calls; a thrown error is a 403.
|
|
38
|
+
- New `authorizeByToken({ token })`: a `ConsoleAuthorize` that allows `Authorization: Bearer <token>` (timing-safe compare) and answers 401 otherwise. An empty token throws when the config loads.
|
|
39
|
+
- The types `ConsoleAuthorize`, `ConsoleAuthorizer`, `ConsoleAuthorizerClass` and `ConsoleAuthorizeResult` are exported, next to `authorizeByToken`.
|
|
40
|
+
|
|
3
41
|
## 1.0.0-rc.0
|
|
4
42
|
|
|
5
43
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -15,11 +15,10 @@ wrapper around [`oidc-provider`](https://github.com/panva/node-oidc-provider).
|
|
|
15
15
|
auth via `acr_values`, Dynamic Client Registration (RFC 7591/7592).
|
|
16
16
|
- **Personal agents** — AI assistants acting for your users: agent identity by signed JWT
|
|
17
17
|
(JWKS, no shared secrets) and user-approved, revocable delegation with scopes you define,
|
|
18
|
-
over a pluggable protocol adapter ([PACT](https://openpactprotocol.org) built in)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
semver majors) while the spec is a draft.
|
|
18
|
+
over a pluggable protocol adapter ([PACT](https://openpactprotocol.org) built in), plus
|
|
19
|
+
`personalAgents.extensions` for protocols shipped as their own packages — the
|
|
20
|
+
[Personal Agent Protocol ("Poppy")](https://personalagentprotocol.org/docs/spec) is
|
|
21
|
+
[`@adonis-agora/authkit-poppy`](https://www.npmjs.com/package/@adonis-agora/authkit-poppy).
|
|
23
22
|
- **Native apps** — RFC 8252 native clients (`authkit:clients:create --native`: private-use
|
|
24
23
|
scheme / claimed https / loopback redirects, always public + PKCE) and the `@adonisjs/auth`
|
|
25
24
|
guards `oidcRpGuard` (session) and `oidcBearerGuard` (`Authorization: Bearer` access tokens,
|
package/build/index.d.ts
CHANGED
|
@@ -15,21 +15,16 @@ export type { PersonalAgentIdentity } from './src/agents/agent_identity.js';
|
|
|
15
15
|
export { PersonalAgentVerifier } from './src/agents/agent_identity.js';
|
|
16
16
|
export type { PersonalAgentDelegationConfigInput, PersonalAgentRegistration, PersonalAgentResolver, PersonalAgentsConfigInput, ResolvedPersonalAgentsConfig, } from './src/agents/config.js';
|
|
17
17
|
export type { DelegationContext, DelegationGrantSummary, DelegationReceipt, } from './src/agents/delegation_service.js';
|
|
18
|
+
export type { AuthkitTable, PersonalAgentAccessTokens, PersonalAgentConsoleSummary, PersonalAgentExtension, PersonalAgentExtensionContext, PersonalAgentExtensionDefinition, PersonalAgentGrant, PersonalAgentGrantLedger, PersonalAgentGrantSummary, PersonalAgentHost, PersonalAgentProtocolRuntime, PersonalAgentRefreshToken, PersonalAgentRouteKit, ResolvedPersonalAgentExtension, } from './src/agents/extension.js';
|
|
18
19
|
export type { PersonalAgentAuthOptions, PersonalAgentRequestContext, } from './src/agents/middleware.js';
|
|
19
20
|
export { personalAgentAuth, personalAgentOf, personalAgentReceipt, personalAgentSecurity, personalAgentStepUp, } from './src/agents/middleware.js';
|
|
20
|
-
export type { PoppyAgentProtocolEntry, PoppyApiEntry, PoppyBrowserLogin, PoppyClientsConfigInput, PoppyConfigInput, PoppyLimiter, PoppyMediatedConfigInput, PoppyMediatedField, PoppyMediatedResult, PoppyMediatedVerifyInput, PoppyPrincipalBase, PoppyReplayStore, PoppyScopeHint, ResolvedPoppyConfig, } from './src/agents/poppy/config.js';
|
|
21
|
-
export { accessTokenHash, type DpopNonceSource, type DpopResult, hmacNonceSource, type VerifyDpopInput, verifyDpopProof, } from './src/agents/poppy/dpop.js';
|
|
22
|
-
export { maskEmail, type PoppyEmailCodeSignInOptions, poppyEmailCodeSignIn, } from './src/agents/poppy/email_code_sign_in.js';
|
|
23
|
-
export { PoppyError, type PoppyErrorCode } from './src/agents/poppy/errors.js';
|
|
24
|
-
export { databaseReplayStore, memoryReplayStore, redisReplayStore, } from './src/agents/poppy/replay.js';
|
|
25
|
-
export { installPoppySlots, POPPY_AUTHENTICATE_SLOT, type PoppyAuthenticate, type PoppyAuthResult, type PoppyPrincipal, type PoppySlotRequest, poppyAuth, poppyOf, verifyPoppyRequest, writePoppyAuthError, } from './src/agents/poppy/resource.js';
|
|
26
|
-
export { isBlockedAddress, SafeFetchError, safeFetchJson, } from './src/agents/poppy/safe_fetch.js';
|
|
27
|
-
export type { PoppyAuthError, PoppyGrantSummary, PoppySessionState, PoppyTokenResponse, PoppyVerifyOptions, } from './src/agents/poppy/service.js';
|
|
28
|
-
export { type PoppyWebSessionMarker, poppyWebSession, poppyWebSessionOf, } from './src/agents/poppy/web_session.js';
|
|
29
21
|
export type { BuiltinProtocolId, PactOptions, PersonalAgentProtocol, } from './src/agents/protocol.js';
|
|
30
22
|
export { pact, pactProtocol } from './src/agents/protocol.js';
|
|
23
|
+
export { type PersonalAgentRuntimeSource, personalAgentExtensionRuntime, } from './src/agents/runtime.js';
|
|
31
24
|
export type { AuditEvent, AuditEventType, AuditPage, AuditSink, ListAuditParams, StoredAuditEvent, } from './src/audit/audit_sink.js';
|
|
32
25
|
export { lucidAuditSink } from './src/audit/lucid_audit_sink.js';
|
|
26
|
+
export type { ConsoleAuthorize, ConsoleAuthorizeResult, ConsoleAuthorizer, ConsoleAuthorizerClass, } from './src/console_authorize.js';
|
|
27
|
+
export { authorizeByToken } from './src/console_authorize.js';
|
|
33
28
|
export type { AdminApiConfigInput, AdminConfigInput, AuthHostRenderer, AuthMethodsConfigInput, AuthServerConfigInput, AuthSocialConfig, DynamicRegistrationConfigInput, LoginConfigInput, OrganizationsConfigInput, PasswordlessConfigInput, RateLimitBucket, RateLimitConfigInput, RegistrationConfigInput, ResolvedAdminApiConfig, ResolvedAdminConfig, ResolvedAuthMethodsConfig, ResolvedDynamicRegistrationConfig, ResolvedLoginConfig, ResolvedNotificationsConfig, ResolvedOrganizationsConfig, ResolvedPasswordlessConfig, ResolvedRateLimitConfig, ResolvedRegistrationConfig, ResolvedServerConfig, ResolvedWebauthnConfig, WebauthnConfigInput, } from './src/define_config.js';
|
|
34
29
|
export { adapters, defineConfig, resolveAdmin, resolveAdminApi, resolveAuthMethodsConfig, resolveDynamicRegistration, resolveLogin, resolveNotifications, resolveOrganizations, resolvePasswordless, resolveRateLimit, resolveRegistration, resolveWebauthn, toSeconds, } from './src/define_config.js';
|
|
35
30
|
export type { EventsConfigInput, ResolvedEventsConfig } from './src/events/dispatcher.js';
|
|
@@ -56,6 +51,7 @@ export type { AccountPathKey, AccountPathsOptions } from './src/host/account_pat
|
|
|
56
51
|
export { accountPath, accountPrefix, joinAccountPath, } from './src/host/account_paths.js';
|
|
57
52
|
export type { AccountConfirmMethod, AccountConfirmProps, AccountEmailConfirmedProps, AccountLoginProps, AccountMfaProps, AccountSecurityProps, } from './src/host/account_screen_props.js';
|
|
58
53
|
export { ACCOUNT_SESSION_KEY } from './src/host/account_session_key.js';
|
|
54
|
+
export { signInAccountSession, signOutAccountSession, } from './src/host/account_session_sign_in.js';
|
|
59
55
|
export { ACTIVE_ORG_COOKIE, ACTIVE_ORG_COOKIE_TTL, decodeActiveOrgCookie, encodeActiveOrgCookie, readActiveOrgFromKoaCtx, } from './src/host/active_org_cookie.js';
|
|
60
56
|
export type { AddMemberInput as AdminAddMemberInput, CreateInvitationInput as AdminCreateInvitationInput, CreateOrgInput as AdminCreateOrgInput, OrgDetail, OrgWithMemberCount, UpdateOrgInput as AdminUpdateOrgInput, } from './src/host/admin_api/admin_orgs_service.js';
|
|
61
57
|
export { AdminOrgsService } from './src/host/admin_api/admin_orgs_service.js';
|
|
@@ -90,6 +86,7 @@ export type { CustomLoginIdentity, CustomLoginMethod, CustomLoginMethodBinding,
|
|
|
90
86
|
export { authenticateCustomLogin, beginCustomLogin, completeCustomLogin, } from './src/host/custom_login.js';
|
|
91
87
|
export type { CustomMfaContext, CustomMfaDescription, CustomMfaDescriptor, CustomMfaField, CustomMfaMethod, CustomMfaMethodBinding, CustomMfaMethodConstructor, CustomMfaMethods, } from './src/host/custom_mfa.js';
|
|
92
88
|
export { beginCustomMfa, customMfaViewProps, verifyCustomMfa } from './src/host/custom_mfa.js';
|
|
89
|
+
export { sendAuthkitCodeEmail } from './src/host/default_mailer.js';
|
|
93
90
|
export { normalizeEmailIdentifier } from './src/host/email_identifier.js';
|
|
94
91
|
export type { ResolveGeo } from './src/host/geo.js';
|
|
95
92
|
export { GEO_RESOLVE_TIMEOUT_MS, resolveGeoSafe } from './src/host/geo.js';
|
|
@@ -109,7 +106,6 @@ export { OidcRpGuard, oidcRpGuard } from './src/host/oidc_rp_guard.js';
|
|
|
109
106
|
export { evaluateLoginOtp, generateOtpCode, OTP_LOGIN_DEFAULTS, type OtpLoginConfigInput, type OtpVerifyOutcome, type ResolvedOtpLoginConfig, resolveOtpLoginConfig, } from './src/host/otp_login.js';
|
|
110
107
|
export type { PersistentRpOptions } from './src/host/persistent_rp_session.js';
|
|
111
108
|
export { endRpSession } from './src/host/persistent_rp_session.js';
|
|
112
|
-
export { POPPY_WEB_SESSION_KEY } from './src/host/poppy_session_key.js';
|
|
113
109
|
export type { AuthThrottles, ThrottleMiddleware } from './src/host/rate_limit.js';
|
|
114
110
|
export { createAuthThrottles } from './src/host/rate_limit.js';
|
|
115
111
|
export type { AccountScreensOptions, AuthHostOptions, AuthHostRouteMap, } from './src/host/register_auth_host.js';
|
|
@@ -161,5 +157,5 @@ export { OidcService } from './src/provider/oidc_service.js';
|
|
|
161
157
|
export { checkClientRegistration, classifyRedirect, type RedirectUriPolicy, type RegistrationOperation, RegistrationPolicyError, type ResolvedRedirectUriPolicy, type ValidateRegistrationHook, } from './src/provider/registration_policy.js';
|
|
162
158
|
export { registerOidcRoutes } from './src/register_routes.js';
|
|
163
159
|
export type { EnsureSchemaOptions, EnsureSchemaReport } from './src/schema/ensure.js';
|
|
164
|
-
export { ensureAuthkitSchema } from './src/schema/ensure.js';
|
|
160
|
+
export { ensureAuthkitSchema, ensureAuthkitTables } from './src/schema/ensure.js';
|
|
165
161
|
export { stubsRoot } from './stubs/main.js';
|
package/build/index.js
CHANGED
|
@@ -10,15 +10,10 @@ export { lucidStores } from './src/accounts/lucid_stores.js';
|
|
|
10
10
|
export { ProviderIdentities, ProviderIdentitiesUnsupportedError, } from './src/accounts/provider_identities.js';
|
|
11
11
|
export { PersonalAgentVerifier } from './src/agents/agent_identity.js';
|
|
12
12
|
export { personalAgentAuth, personalAgentOf, personalAgentReceipt, personalAgentSecurity, personalAgentStepUp, } from './src/agents/middleware.js';
|
|
13
|
-
export { accessTokenHash, hmacNonceSource, verifyDpopProof, } from './src/agents/poppy/dpop.js';
|
|
14
|
-
export { maskEmail, poppyEmailCodeSignIn, } from './src/agents/poppy/email_code_sign_in.js';
|
|
15
|
-
export { PoppyError } from './src/agents/poppy/errors.js';
|
|
16
|
-
export { databaseReplayStore, memoryReplayStore, redisReplayStore, } from './src/agents/poppy/replay.js';
|
|
17
|
-
export { installPoppySlots, POPPY_AUTHENTICATE_SLOT, poppyAuth, poppyOf, verifyPoppyRequest, writePoppyAuthError, } from './src/agents/poppy/resource.js';
|
|
18
|
-
export { isBlockedAddress, SafeFetchError, safeFetchJson, } from './src/agents/poppy/safe_fetch.js';
|
|
19
|
-
export { poppyWebSession, poppyWebSessionOf, } from './src/agents/poppy/web_session.js';
|
|
20
13
|
export { pact, pactProtocol } from './src/agents/protocol.js';
|
|
14
|
+
export { personalAgentExtensionRuntime, } from './src/agents/runtime.js';
|
|
21
15
|
export { lucidAuditSink } from './src/audit/lucid_audit_sink.js';
|
|
16
|
+
export { authorizeByToken } from './src/console_authorize.js';
|
|
22
17
|
export { adapters, defineConfig, resolveAdmin, resolveAdminApi, resolveAuthMethodsConfig, resolveDynamicRegistration, resolveLogin, resolveNotifications, resolveOrganizations, resolvePasswordless, resolveRateLimit, resolveRegistration, resolveWebauthn, toSeconds, } from './src/define_config.js';
|
|
23
18
|
export { buildWebhookBody, composeAuditSink, resolveEvents, signWebhookBody, } from './src/events/dispatcher.js';
|
|
24
19
|
export { inProcessAccessTokenVerifier, remoteAccessTokenVerifier, } from './src/host/access_token_verifier.js';
|
|
@@ -38,6 +33,7 @@ export { AccountExportService } from './src/host/account_export_service.js';
|
|
|
38
33
|
*/
|
|
39
34
|
export { accountPath, accountPrefix, joinAccountPath, } from './src/host/account_paths.js';
|
|
40
35
|
export { ACCOUNT_SESSION_KEY } from './src/host/account_session_key.js';
|
|
36
|
+
export { signInAccountSession, signOutAccountSession, } from './src/host/account_session_sign_in.js';
|
|
41
37
|
// Organizations (multi-tenancy)
|
|
42
38
|
export { ACTIVE_ORG_COOKIE, ACTIVE_ORG_COOKIE_TTL, decodeActiveOrgCookie, encodeActiveOrgCookie, readActiveOrgFromKoaCtx, } from './src/host/active_org_cookie.js';
|
|
43
39
|
export { AdminOrgsService } from './src/host/admin_api/admin_orgs_service.js';
|
|
@@ -64,6 +60,7 @@ export { consoleLoginUrl, getAccountId, hasAccountSession, realAccountId, } from
|
|
|
64
60
|
export { authkitCsrfExceptions } from './src/host/csrf.js';
|
|
65
61
|
export { authenticateCustomLogin, beginCustomLogin, completeCustomLogin, } from './src/host/custom_login.js';
|
|
66
62
|
export { beginCustomMfa, customMfaViewProps, verifyCustomMfa } from './src/host/custom_mfa.js';
|
|
63
|
+
export { sendAuthkitCodeEmail } from './src/host/default_mailer.js';
|
|
67
64
|
export { normalizeEmailIdentifier } from './src/host/email_identifier.js';
|
|
68
65
|
export { GEO_RESOLVE_TIMEOUT_MS, resolveGeoSafe } from './src/host/geo.js';
|
|
69
66
|
export { BUILTIN_MESSAGES, DEFAULT_LOCALE, DEFAULT_MESSAGES, PT_BR_MESSAGES, resolveMessages, translate, } from './src/host/i18n.js';
|
|
@@ -88,7 +85,6 @@ export { OidcRpGuard, oidcRpGuard } from './src/host/oidc_rp_guard.js';
|
|
|
88
85
|
// Login por OTP (código digitável): config + helpers puros.
|
|
89
86
|
export { evaluateLoginOtp, generateOtpCode, OTP_LOGIN_DEFAULTS, resolveOtpLoginConfig, } from './src/host/otp_login.js';
|
|
90
87
|
export { endRpSession } from './src/host/persistent_rp_session.js';
|
|
91
|
-
export { POPPY_WEB_SESSION_KEY } from './src/host/poppy_session_key.js';
|
|
92
88
|
export { createAuthThrottles } from './src/host/rate_limit.js';
|
|
93
89
|
export { registerAuthHost } from './src/host/register_auth_host.js';
|
|
94
90
|
export { edgeRenderer } from './src/host/renderers/edge_renderer.js';
|
|
@@ -139,5 +135,5 @@ export { generatePatToken, hashPatToken } from './src/pat/pat_tokens.js';
|
|
|
139
135
|
export { OidcService } from './src/provider/oidc_service.js';
|
|
140
136
|
export { checkClientRegistration, classifyRedirect, RegistrationPolicyError, } from './src/provider/registration_policy.js';
|
|
141
137
|
export { registerOidcRoutes } from './src/register_routes.js';
|
|
142
|
-
export { ensureAuthkitSchema } from './src/schema/ensure.js';
|
|
138
|
+
export { ensureAuthkitSchema, ensureAuthkitTables } from './src/schema/ensure.js';
|
|
143
139
|
export { stubsRoot } from './stubs/main.js';
|
|
@@ -130,11 +130,12 @@ export default class AuthkitServerProvider {
|
|
|
130
130
|
// Defaults estruturais de `config.routes` (o argumento ainda vence).
|
|
131
131
|
routes: typeof config.routes === 'object' ? config.routes : undefined,
|
|
132
132
|
lockedRouteOptions: config.lockedRouteOptions,
|
|
133
|
+
consoleNeedsLoginUrl: config.accountSession?.acceptIdpSession === false && config.authMethods?.password === false,
|
|
133
134
|
personalAgents: config.personalAgents
|
|
134
135
|
? {
|
|
135
136
|
prefix: config.personalAgents.prefix,
|
|
136
|
-
...(config.personalAgents.
|
|
137
|
-
? {
|
|
137
|
+
...(config.personalAgents.extensions?.length
|
|
138
|
+
? { extensions: config.personalAgents.extensions }
|
|
138
139
|
: {}),
|
|
139
140
|
}
|
|
140
141
|
: undefined,
|
|
@@ -146,12 +147,16 @@ export default class AuthkitServerProvider {
|
|
|
146
147
|
}
|
|
147
148
|
: undefined,
|
|
148
149
|
});
|
|
149
|
-
//
|
|
150
|
-
//
|
|
151
|
-
if (config.
|
|
152
|
-
const {
|
|
153
|
-
const
|
|
154
|
-
|
|
150
|
+
// Admin console without `admin.authorize`: open outside production, 403 in production.
|
|
151
|
+
// Said once, at boot.
|
|
152
|
+
if (config.admin.enabled && !config.admin.authorize) {
|
|
153
|
+
const { warnAdminConsoleUnauthorized } = await import('../src/host/admin_console_warning.js');
|
|
154
|
+
const logger = await this.app.container.make('logger').catch(() => null);
|
|
155
|
+
warnAdminConsoleUnauthorized(logger);
|
|
156
|
+
}
|
|
157
|
+
// `personalAgents.extensions`: o boot de cada uma (slots globais, etc.).
|
|
158
|
+
for (const extension of config.personalAgents?.extensions ?? []) {
|
|
159
|
+
await extension.boot?.();
|
|
155
160
|
}
|
|
156
161
|
// Auto-montagem das rotas (`config.routes`). Chama a MESMA função exportada que o
|
|
157
162
|
// `start/routes.ts` chamaria; não há segunda implementação. "As rotas não subiram" não pode
|
|
@@ -260,6 +265,7 @@ export default class AuthkitServerProvider {
|
|
|
260
265
|
const report = await ensureAuthkitSchema(db, {
|
|
261
266
|
connection: config.schema.connection,
|
|
262
267
|
accountTable: config.accountStore?.accountTable,
|
|
268
|
+
tables: config.personalAgents?.extensions?.flatMap((e) => e.tables ?? []),
|
|
263
269
|
});
|
|
264
270
|
const logger = await this.app.container.make('logger').catch(() => null);
|
|
265
271
|
if (report.created.length > 0) {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* recibos) não depende de protocolo; o formato do fio vem do adapter em
|
|
13
13
|
* `protocol` (default: PACT — https://openpactprotocol.org). Ver `protocol.ts`.
|
|
14
14
|
*/
|
|
15
|
-
import { type
|
|
15
|
+
import { type PersonalAgentExtension, type ResolvedPersonalAgentExtension } from './extension.js';
|
|
16
16
|
import { type BuiltinProtocolId, type PersonalAgentProtocol } from './protocol.js';
|
|
17
17
|
/** Registro de um personal agent conhecido (PACT §3.1). */
|
|
18
18
|
export interface PersonalAgentRegistration {
|
|
@@ -58,8 +58,8 @@ export interface PersonalAgentsConfigInput {
|
|
|
58
58
|
/**
|
|
59
59
|
* Valor que os personal agents põem no `aud` do JWT deles (PACT). Opaco e
|
|
60
60
|
* atribuído por ESTE app no registro do agente — um valor por app, não
|
|
61
|
-
* derivado de URL. Liga o PACT; obrigatório, a não ser num app
|
|
62
|
-
*
|
|
61
|
+
* derivado de URL. Liga o PACT; obrigatório, a não ser num app que só usa
|
|
62
|
+
* `extensions` (sem `audience`).
|
|
63
63
|
*/
|
|
64
64
|
audience?: string;
|
|
65
65
|
/**
|
|
@@ -79,14 +79,10 @@ export interface PersonalAgentsConfigInput {
|
|
|
79
79
|
/** Prefixo das rotas (`{prefix}/oauth/*`, `{prefix}/consent`). Default: `/agents`. */
|
|
80
80
|
prefix?: string;
|
|
81
81
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* `poppy/config.ts`.
|
|
85
|
-
*
|
|
86
|
-
* @experimental Poppy (Personal Agent Protocol) Draft 0.3 — acompanha a spec em desenvolvimento e PODE MUDAR
|
|
87
|
-
* de forma incompatível fora de majors enquanto ela for draft.
|
|
82
|
+
* Outros protocolos de personal agents, de pacotes à parte, ao lado do PACT
|
|
83
|
+
* (ex.: `poppy()` de `@adonis-agora/authkit-poppy`). Ver {@link PersonalAgentExtension}.
|
|
88
84
|
*/
|
|
89
|
-
|
|
85
|
+
extensions?: PersonalAgentExtension[];
|
|
90
86
|
}
|
|
91
87
|
export interface ResolvedPersonalAgentDelegationConfig {
|
|
92
88
|
interfaceUrl: string;
|
|
@@ -108,11 +104,11 @@ export interface ResolvedPersonalAgentsConfig {
|
|
|
108
104
|
open: boolean;
|
|
109
105
|
delegation?: ResolvedPersonalAgentDelegationConfig;
|
|
110
106
|
prefix: string;
|
|
111
|
-
/**
|
|
112
|
-
|
|
107
|
+
/** `extensions` resolvidas, na ordem do config. */
|
|
108
|
+
extensions: ResolvedPersonalAgentExtension[];
|
|
113
109
|
}
|
|
114
110
|
export declare function normalizePersonalAgentsPrefix(prefix: string | undefined): string;
|
|
115
|
-
export declare function resolvePersonalAgentsConfig(input: PersonalAgentsConfigInput | undefined): ResolvedPersonalAgentsConfig | undefined;
|
|
111
|
+
export declare function resolvePersonalAgentsConfig(input: PersonalAgentsConfigInput | undefined, issuer?: string): ResolvedPersonalAgentsConfig | undefined;
|
|
116
112
|
/** `"a b c"` → `['a','b','c']` sem duplicatas, na ordem. */
|
|
117
113
|
export declare function parseScope(value: string | null | undefined): string[];
|
|
118
114
|
export declare function formatScope(scopes: Iterable<string>): string;
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* recibos) não depende de protocolo; o formato do fio vem do adapter em
|
|
13
13
|
* `protocol` (default: PACT — https://openpactprotocol.org). Ver `protocol.ts`.
|
|
14
14
|
*/
|
|
15
|
-
import {
|
|
15
|
+
import { resolvePersonalAgentExtensions, } from './extension.js';
|
|
16
16
|
import { BUILTIN_PROTOCOLS, } from './protocol.js';
|
|
17
17
|
const SCOPE_ID = /^[\x21\x23-\x5B\x5D-\x7E]+$/; // RFC 6749 §3.3 scope-token
|
|
18
18
|
function assertUrl(value, what) {
|
|
@@ -37,19 +37,20 @@ export function normalizePersonalAgentsPrefix(prefix) {
|
|
|
37
37
|
return '/agents';
|
|
38
38
|
return trimmed.startsWith('/') ? trimmed : `/${trimmed}`;
|
|
39
39
|
}
|
|
40
|
-
export function resolvePersonalAgentsConfig(input) {
|
|
40
|
+
export function resolvePersonalAgentsConfig(input, issuer = '') {
|
|
41
41
|
if (!input)
|
|
42
42
|
return undefined;
|
|
43
|
+
// 0.x → 1.0: o Poppy virou o pacote `@adonis-agora/authkit-poppy`.
|
|
44
|
+
if ('poppy' in input) {
|
|
45
|
+
throw new Error('authkit: `personalAgents.poppy` saiu do authkit-server — instale `@adonis-agora/authkit-poppy` e use `personalAgents.extensions: [poppy({ ... })]`.');
|
|
46
|
+
}
|
|
43
47
|
const pact = !!input.audience?.trim();
|
|
44
|
-
if (!pact && !input.
|
|
45
|
-
throw new Error('authkit: personalAgents.audience é obrigatório (o `aud` dos JWTs dos agentes PACT) — ou configure só `personalAgents.
|
|
48
|
+
if (!pact && !input.extensions?.length) {
|
|
49
|
+
throw new Error('authkit: personalAgents.audience é obrigatório (o `aud` dos JWTs dos agentes PACT) — ou configure só `personalAgents.extensions`.');
|
|
46
50
|
}
|
|
47
51
|
if (!pact && input.delegation) {
|
|
48
52
|
throw new Error('authkit: personalAgents.delegation é do PACT e exige `personalAgents.audience`.');
|
|
49
53
|
}
|
|
50
|
-
if (input.protocol === 'poppy') {
|
|
51
|
-
throw new Error('authkit: o Poppy não é um `protocol` do PACT — configure-o em `personalAgents.poppy` (os dois convivem).');
|
|
52
|
-
}
|
|
53
54
|
let resolveAgent;
|
|
54
55
|
let staticAgents = null;
|
|
55
56
|
if (typeof input.agents === 'function') {
|
|
@@ -94,9 +95,14 @@ export function resolvePersonalAgentsConfig(input) {
|
|
|
94
95
|
throw new Error(`authkit: personalAgents.protocol "${String(input.protocol)}" desconhecido (embutidos: ${Object.keys(BUILTIN_PROTOCOLS).join(', ')}).`);
|
|
95
96
|
}
|
|
96
97
|
const prefix = normalizePersonalAgentsPrefix(input.prefix);
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
const extensions = resolvePersonalAgentExtensions(input.extensions, {
|
|
99
|
+
issuer,
|
|
100
|
+
delegationScopes: input.delegation?.scopes ? { ...input.delegation.scopes } : null,
|
|
101
|
+
});
|
|
102
|
+
for (const extension of extensions) {
|
|
103
|
+
if (pact && (extension.prefix === prefix || extension.prefix.startsWith(`${prefix}/`))) {
|
|
104
|
+
throw new Error(`authkit: o prefixo "${extension.prefix}" de personalAgents.extensions "${extension.id}" não pode ficar debaixo de personalAgents.prefix ("${prefix}").`);
|
|
105
|
+
}
|
|
100
106
|
}
|
|
101
107
|
return {
|
|
102
108
|
pact,
|
|
@@ -107,7 +113,7 @@ export function resolvePersonalAgentsConfig(input) {
|
|
|
107
113
|
open: input.open === true,
|
|
108
114
|
delegation,
|
|
109
115
|
prefix,
|
|
110
|
-
|
|
116
|
+
extensions,
|
|
111
117
|
};
|
|
112
118
|
}
|
|
113
119
|
/** `"a b c"` → `['a','b','c']` sem duplicatas, na ordem. */
|
|
@@ -31,11 +31,11 @@ function newUserCode() {
|
|
|
31
31
|
return `${code.slice(0, 4)}-${code.slice(4)}`;
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* A tabela de grants é compartilhada com
|
|
35
|
-
* o PACT só enxerga os dele
|
|
34
|
+
* A tabela de grants é compartilhada com as `personalAgents.extensions` (cada uma com o seu
|
|
35
|
+
* prefixo de id): o PACT só enxerga os dele, `agrant_`.
|
|
36
36
|
*/
|
|
37
37
|
function isPactGrant(id) {
|
|
38
|
-
return
|
|
38
|
+
return id.startsWith('agrant_');
|
|
39
39
|
}
|
|
40
40
|
/** Aceita o código como o usuário digitar: minúsculas, sem hífen, com espaços. */
|
|
41
41
|
export function normalizeUserCode(input) {
|
|
@@ -38,7 +38,8 @@ export interface GrantRow {
|
|
|
38
38
|
updatedAt: Date;
|
|
39
39
|
}
|
|
40
40
|
export interface LiveGrantFilter {
|
|
41
|
-
|
|
41
|
+
/** Só os grants com este prefixo de id (`agrant_` = PACT; o `grantIdPrefix` de uma extension). */
|
|
42
|
+
idPrefix?: string;
|
|
42
43
|
clientId?: string;
|
|
43
44
|
accountId?: string;
|
|
44
45
|
}
|
|
@@ -88,7 +89,7 @@ export declare class DelegationStore {
|
|
|
88
89
|
}): Promise<GrantRow[]>;
|
|
89
90
|
countLiveGrants(now: Date, filter?: LiveGrantFilter): Promise<number>;
|
|
90
91
|
/** Conexões vivas de um protocolo por agente: `client_id` → número de grants. */
|
|
91
|
-
countLiveGrantsByClient(now: Date,
|
|
92
|
+
countLiveGrantsByClient(now: Date, idPrefix: string): Promise<Map<string, number>>;
|
|
92
93
|
/** Ids dos grants não revogados de um agente (vivos ou não) — para revogar todos. */
|
|
93
94
|
unrevokedGrantIdsOfClient(clientId: string): Promise<string[]>;
|
|
94
95
|
/** Revoga um grant sem checar a conta — reação a reuso de refresh token. */
|
|
@@ -186,12 +186,13 @@ export class DelegationStore {
|
|
|
186
186
|
// ─── console admin (todas as contas) ──────────────────────────────────────
|
|
187
187
|
/**
|
|
188
188
|
* Grants vivos (não revogados nem expirados em `now`), de todas as contas. O
|
|
189
|
-
* protocolo sai do prefixo do id: `agrant_` (PACT) ou `
|
|
189
|
+
* protocolo sai do prefixo do id: `agrant_` (PACT) ou o `grantIdPrefix` de uma extension.
|
|
190
190
|
*/
|
|
191
191
|
#live(now, filter = {}) {
|
|
192
192
|
let q = this.conn().from(GRANT_TABLE).whereNull('revoked_at').where('expires_at', '>', now);
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
// O prefixo é `[a-z0-9]+_`: o `_` do LIKE (um caractere qualquer) casa com ele mesmo.
|
|
194
|
+
if (filter.idPrefix)
|
|
195
|
+
q = q.where('id', 'like', `${filter.idPrefix}%`);
|
|
195
196
|
if (filter.clientId)
|
|
196
197
|
q = q.where('client_id', filter.clientId);
|
|
197
198
|
if (filter.accountId)
|
|
@@ -211,8 +212,8 @@ export class DelegationStore {
|
|
|
211
212
|
return Number(row?.total ?? 0);
|
|
212
213
|
}
|
|
213
214
|
/** Conexões vivas de um protocolo por agente: `client_id` → número de grants. */
|
|
214
|
-
async countLiveGrantsByClient(now,
|
|
215
|
-
const rows = await this.#live(now, {
|
|
215
|
+
async countLiveGrantsByClient(now, idPrefix) {
|
|
216
|
+
const rows = await this.#live(now, { idPrefix })
|
|
216
217
|
.select('client_id')
|
|
217
218
|
.count('* as total')
|
|
218
219
|
.groupBy('client_id');
|