@absolutejs/auth 0.54.9 → 0.55.1

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Absolute Auth
2
2
 
3
+ Server applications should import the primary authentication contract from
4
+ `@absolutejs/auth/server`. This declaration-stable entry point exposes `auth`,
5
+ session types, route protection, provider configuration, and the other core
6
+ server utilities without loading declarations for every optional Auth feature.
7
+ The root entry point remains available for applications that need the complete
8
+ feature export surface.
9
+
3
10
  ## Overview
4
11
 
5
12
  Absolute Auth is a TypeScript-based authentication system that provides a comprehensive solution for handling user authentication in web applications. It supports multiple authentication providers and offers features such as authorization, callback handling, token refresh, token revocation, and session management.
@@ -77,11 +84,13 @@ import { createSimpleWebAuthnAdapter } from '@absolutejs/auth/webauthn';
77
84
 
78
85
  ### Delegated AI agents
79
86
 
80
- The `agentAuth` block provides a standards-first agent identity layer without
81
- depending on a vendor registration protocol. It publishes RFC 9728 protected
82
- resource metadata, records agent registrations and user delegations, and adds a
83
- scoped `protectAgent` guard. Protocol-specific credentials are normalized by a
84
- verifier adapter:
87
+ The `agentAuth` block provides a standards-first agent identity layer. It
88
+ publishes RFC 9728 metadata, records registrations and user delegations, and
89
+ adds a scoped `protectAgent` guard. It can also serve a generated `/auth.md`
90
+ registration guide and matching structured OAuth metadata. This is native to
91
+ `@absolutejs/auth`; no WorkOS service or separate package is required.
92
+
93
+ Protocol-specific credentials are normalized by verifier adapters:
85
94
 
86
95
  ```ts
87
96
  import {
@@ -133,6 +142,18 @@ app.get('/documents', ({ protectAgent }) =>
133
142
  Postgres and Neon registration/delegation stores are exported alongside the
134
143
  in-memory stores. Include the `agents` migration block in production.
135
144
 
145
+ For agents that need to create or link an account, configure
146
+ `agentAuth.agentRegistration` with an identity-registration store, access-token
147
+ store, signing key, authenticated-user resolver, and post-claim scopes. Enable
148
+ `service_auth` or anonymous registration explicitly; anonymous registration
149
+ also requires an idempotent callback that revokes every pre-claim token before
150
+ ownership changes. Absolute exposes provider and consumer helpers from
151
+ `@absolutejs/auth/agents`, including ID-JAG issuance and verification, secure
152
+ RFC 9728/RFC 8414 discovery, claim polling, and assertion exchange.
153
+
154
+ See [the agent-auth interoperability and deployment guide](docs/AGENT-AUTH.md)
155
+ for supported standards, security invariants, and the production checklist.
156
+
136
157
  ### Features
137
158
 
138
159
  - **Authorization**: Handles the authorization process by generating the authorization URL and redirecting the user to the authentication provider.
@@ -1,14 +1,30 @@
1
1
  import type { RouteString } from '../types';
2
2
  import type { AgentCredentialVerifier, AgentDelegationStore, AgentRegistrationStore } from './types';
3
+ import type { AgentRegistrationProtocolConfig } from './registration';
3
4
  export declare const DEFAULT_AGENT_RESOURCE_METADATA_ROUTE: RouteString;
5
+ export type AgentRegistrationDiscoveryMetadata = {
6
+ claim_endpoint: string;
7
+ identity_assertion: {
8
+ assertion_types_supported: string[];
9
+ };
10
+ identity_endpoint: string;
11
+ identity_types_supported: string[];
12
+ skill: string;
13
+ };
4
14
  export type AgentAuthConfig = {
5
15
  /** Permit registered agents to authenticate without a user delegation. Secure
6
16
  * default is false; enable for machine-only resources. */
7
17
  allowUndelegated?: boolean;
18
+ /** Open auth.md agent-registration support. Implemented natively by Absolute
19
+ * Auth and projected through OAuth discovery; no WorkOS service is required. */
20
+ agentRegistration?: AgentRegistrationProtocolConfig;
8
21
  authorizationServer: string;
9
22
  delegationStore: AgentDelegationStore;
10
23
  logoUri?: string;
11
24
  metadataRoute?: RouteString;
25
+ /** Authorization-server route prefix. Defaults to `/oauth2`; used to derive
26
+ * the authoritative token endpoint advertised by the generated guide. */
27
+ oidcRoute?: RouteString;
12
28
  registrationStore: AgentRegistrationStore;
13
29
  /** Treat clients created through RFC 7591 DCR as agent registrations. Explicitly
14
30
  * opt-in because a deployment may also use DCR for ordinary relying parties. */
@@ -0,0 +1,49 @@
1
+ import { type SigningKey } from '../oidc/keys';
2
+ import type { VerifiedAgentIdentityAssertion } from './types';
3
+ export type AgentIdentityAssertionJtiStore = {
4
+ /** Atomically records an issuer+jti pair. Returns false for a replay. */
5
+ recordIfFresh: (issuer: string, jti: string, expiresAt: number) => Promise<boolean>;
6
+ };
7
+ export declare const createInMemoryAgentIdentityAssertionJtiStore: () => AgentIdentityAssertionJtiStore;
8
+ export type AgentIdentityAssertionUser = {
9
+ authenticatedAt: number;
10
+ email?: string;
11
+ emailVerified?: boolean;
12
+ methods?: string[];
13
+ name?: string;
14
+ phoneNumber?: string;
15
+ phoneNumberVerified?: boolean;
16
+ subject: string;
17
+ };
18
+ /** Native provider-side ID-JAG issuance. The caller owns the user consent UI
19
+ * and must authorize the requested audience before invoking this helper. */
20
+ export declare const issueAgentIdentityAssertion: ({ agentContextId, agentPlatform, audience, clientId, issuer, now, resource, signingKey, ttlMs, user }: {
21
+ agentContextId?: string;
22
+ agentPlatform?: string;
23
+ audience: string;
24
+ clientId: string;
25
+ issuer: string;
26
+ now?: number;
27
+ resource?: string;
28
+ signingKey: SigningKey;
29
+ ttlMs?: number;
30
+ user: AgentIdentityAssertionUser;
31
+ }) => Promise<{
32
+ assertion: string;
33
+ assertionType: "urn:ietf:params:oauth:token-type:id-jag";
34
+ expiresAt: number;
35
+ }>;
36
+ /** Builds a fail-closed service-side verifier. Issuer resolution is injected so
37
+ * the application can use pinned configuration, CIMD, or an egress-guarded
38
+ * JWKS resolver without this package performing ambient network access. */
39
+ export declare const createAgentIdentityAssertionVerifier: ({ audience, clockSkewMs, jtiStore, maxAssertionLifetimeMs, maxAuthenticationAgeMs, resolveIssuer }: {
40
+ audience: string;
41
+ clockSkewMs?: number;
42
+ jtiStore: AgentIdentityAssertionJtiStore;
43
+ maxAssertionLifetimeMs?: number;
44
+ maxAuthenticationAgeMs?: number;
45
+ resolveIssuer: (issuer: string) => Promise<{
46
+ allowedClientIds?: string[];
47
+ publicJwk: JsonWebKey;
48
+ } | undefined>;
49
+ }) => (assertion: string, now?: number) => Promise<VerifiedAgentIdentityAssertion | undefined>;
@@ -1,3 +1,4 @@
1
- import type { AgentDelegationStore, AgentRegistrationStore } from './types';
1
+ import type { AgentDelegationStore, AgentIdentityRegistrationStore, AgentRegistrationStore } from './types';
2
2
  export declare const createInMemoryAgentDelegationStore: () => AgentDelegationStore;
3
+ export declare const createInMemoryAgentIdentityRegistrationStore: () => AgentIdentityRegistrationStore;
3
4
  export declare const createInMemoryAgentRegistrationStore: () => AgentRegistrationStore;
@@ -1,8 +1,11 @@
1
1
  export * from './config';
2
2
  export * from './types';
3
+ export * from './registration';
4
+ export * from './registrationClient';
5
+ export * from './idJag';
3
6
  export * from '../oidc/clientIdMetadata';
4
7
  export { createOidcAgentCredentialVerifier } from './oidcAdapter';
5
8
  export { agentHasScopes, resolveAgentPrincipal } from './principal';
6
9
  export { agentAuthChallenge, agentAuthPlugin } from './routes';
7
- export { createInMemoryAgentDelegationStore, createInMemoryAgentRegistrationStore } from './inMemoryStores';
8
- export { agentDelegationsTable, agentRegistrationsTable, createNeonAgentDelegationStore, createNeonAgentRegistrationStore, createPostgresAgentDelegationStore, createPostgresAgentRegistrationStore } from './postgresStores';
10
+ export { createInMemoryAgentDelegationStore, createInMemoryAgentIdentityRegistrationStore, createInMemoryAgentRegistrationStore } from './inMemoryStores';
11
+ export { agentDelegationsTable, agentIdentityRegistrationsTable, agentRegistrationsTable, createNeonAgentDelegationStore, createNeonAgentIdentityRegistrationStore, createNeonAgentRegistrationStore, createPostgresAgentDelegationStore, createPostgresAgentIdentityRegistrationStore, createPostgresAgentRegistrationStore } from './postgresStores';