@absolutejs/auth 0.54.4 → 0.54.6

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
@@ -75,6 +75,64 @@ The concrete SimpleWebAuthn adapter follows the same boundary:
75
75
  import { createSimpleWebAuthnAdapter } from '@absolutejs/auth/webauthn';
76
76
  ```
77
77
 
78
+ ### Delegated AI agents
79
+
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:
85
+
86
+ ```ts
87
+ import {
88
+ createInMemoryAgentDelegationStore,
89
+ createInMemoryAgentRegistrationStore,
90
+ createOidcAgentCredentialVerifier
91
+ } from '@absolutejs/auth/agents';
92
+
93
+ const registrationStore = createInMemoryAgentRegistrationStore();
94
+ const delegationStore = createInMemoryAgentDelegationStore();
95
+
96
+ const authPlugin = await auth({
97
+ agentAuth: {
98
+ authorizationServer: 'https://auth.example.com',
99
+ delegationStore,
100
+ registerDynamicClients: true,
101
+ registrationStore,
102
+ resource: 'https://api.example.com',
103
+ scopes: ['documents:read', 'documents:write'],
104
+ verifyCredential: createOidcAgentCredentialVerifier({
105
+ issuer: 'https://auth.example.com',
106
+ publicJwk: signingKey.publicJwk,
107
+ resource: 'https://api.example.com'
108
+ })
109
+ },
110
+ oidc: {
111
+ // Enable RFC 7591 dynamic client registration and RFC 8628 device auth.
112
+ clientRegistrationTokenStore,
113
+ deviceAuthorizationStore
114
+ // ...the normal OIDC provider configuration
115
+ }
116
+ });
117
+ ```
118
+
119
+ With `registerDynamicClients` enabled, an RFC 7591 client becomes an agent
120
+ registration. Approval through the existing RFC 8628 device flow creates the
121
+ user-to-agent delegation. The agent can then use RFC 8693 token exchange to get
122
+ a narrowed, audience-bound access token for the protected API.
123
+
124
+ ```ts
125
+ app.get('/documents', ({ protectAgent }) =>
126
+ protectAgent(['documents:read'], (agent) => ({
127
+ agentId: agent.agentId,
128
+ actingFor: agent.userId
129
+ }))
130
+ );
131
+ ```
132
+
133
+ Postgres and Neon registration/delegation stores are exported alongside the
134
+ in-memory stores. Include the `agents` migration block in production.
135
+
78
136
  ### Features
79
137
 
80
138
  - **Authorization**: Handles the authorization process by generating the authorization URL and redirecting the user to the authentication provider.
@@ -0,0 +1,28 @@
1
+ import type { RouteString } from '../types';
2
+ import type { AgentCredentialVerifier, AgentDelegationStore, AgentRegistrationStore } from './types';
3
+ export declare const DEFAULT_AGENT_RESOURCE_METADATA_ROUTE: RouteString;
4
+ export type AgentAuthConfig = {
5
+ /** Permit registered agents to authenticate without a user delegation. Secure
6
+ * default is false; enable for machine-only resources. */
7
+ allowUndelegated?: boolean;
8
+ authorizationServer: string;
9
+ delegationStore: AgentDelegationStore;
10
+ logoUri?: string;
11
+ metadataRoute?: RouteString;
12
+ registrationStore: AgentRegistrationStore;
13
+ /** Treat clients created through RFC 7591 DCR as agent registrations. Explicitly
14
+ * opt-in because a deployment may also use DCR for ordinary relying parties. */
15
+ registerDynamicClients?: boolean;
16
+ resource: string;
17
+ resourceName?: string;
18
+ scopes: string[];
19
+ verifyCredential: AgentCredentialVerifier;
20
+ };
21
+ export declare const agentProtectedResourceMetadata: (config: Pick<AgentAuthConfig, "authorizationServer" | "logoUri" | "resource" | "resourceName" | "scopes">) => {
22
+ resource: string;
23
+ scopes_supported: string[];
24
+ resource_name?: string | undefined;
25
+ resource_logo_uri?: string | undefined;
26
+ authorization_servers: string[];
27
+ bearer_methods_supported: string[];
28
+ };
@@ -0,0 +1,3 @@
1
+ import type { AgentDelegationStore, AgentRegistrationStore } from './types';
2
+ export declare const createInMemoryAgentDelegationStore: () => AgentDelegationStore;
3
+ export declare const createInMemoryAgentRegistrationStore: () => AgentRegistrationStore;
@@ -0,0 +1,7 @@
1
+ export * from './config';
2
+ export * from './types';
3
+ export { createOidcAgentCredentialVerifier } from './oidcAdapter';
4
+ export { agentHasScopes, resolveAgentPrincipal } from './principal';
5
+ export { agentAuthChallenge, agentAuthPlugin } from './routes';
6
+ export { createInMemoryAgentDelegationStore, createInMemoryAgentRegistrationStore } from './inMemoryStores';
7
+ export { agentDelegationsTable, agentRegistrationsTable, createNeonAgentDelegationStore, createNeonAgentRegistrationStore, createPostgresAgentDelegationStore, createPostgresAgentRegistrationStore } from './postgresStores';