@absolutejs/auth 0.56.3 → 0.56.5
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/dist/abuse/captcha.d.ts +11 -0
- package/dist/abuse/config.d.ts +29 -0
- package/dist/actions.d.ts +27 -0
- package/dist/agents/config.d.ts +44 -0
- package/dist/agents/context.d.ts +46 -0
- package/dist/agents/principal.d.ts +4 -0
- package/dist/agents/registration.d.ts +162 -0
- package/dist/agents/routes.d.ts +321 -0
- package/dist/agents/types.d.ts +129 -0
- package/dist/apikeys/config.d.ts +64 -0
- package/dist/apikeys/routes.d.ts +83 -0
- package/dist/apikeys/types.d.ts +53 -0
- package/dist/audit/config.d.ts +9 -0
- package/dist/audit/export.d.ts +2 -0
- package/dist/audit/inMemoryAuditStore.d.ts +2 -0
- package/dist/audit/integrity.d.ts +19 -0
- package/dist/audit/postgresAuditStore.d.ts +116 -0
- package/dist/audit/siem.d.ts +11 -0
- package/dist/audit/types.d.ts +19 -0
- package/dist/audit/wrap.d.ts +9 -0
- package/dist/authContext.d.ts +193 -0
- package/dist/authorization/config.d.ts +19 -0
- package/dist/authorization/protectPermission.d.ts +52 -0
- package/dist/cli/migrate.js.map +1 -1
- package/dist/compliance/cipher.d.ts +11 -0
- package/dist/compliance/config.d.ts +18 -0
- package/dist/compliance/redaction.d.ts +8 -0
- package/dist/compliance/routes.d.ts +89 -0
- package/dist/constants.d.ts +10 -0
- package/dist/credentials/backgroundOps.d.ts +45 -0
- package/dist/credentials/config.d.ts +68 -0
- package/dist/credentials/emailValidation.d.ts +9 -0
- package/dist/credentials/emailVerification.d.ts +83 -0
- package/dist/credentials/import.d.ts +34 -0
- package/dist/credentials/inMemoryCredentialStore.d.ts +2 -0
- package/dist/credentials/legacyHashers.d.ts +3 -0
- package/dist/credentials/login.d.ts +76 -0
- package/dist/credentials/passwordPolicy.d.ts +15 -0
- package/dist/credentials/passwordReset.d.ts +87 -0
- package/dist/credentials/postgresCredentialStore.d.ts +235 -0
- package/dist/credentials/register.d.ts +54 -0
- package/dist/credentials/routes.d.ts +201 -0
- package/dist/credentials/types.d.ts +26 -0
- package/dist/crypto.d.ts +32 -0
- package/dist/errors.d.ts +12 -0
- package/dist/federation/tokenStore.d.ts +29 -0
- package/dist/htmx/configuredRoutes.d.ts +542 -0
- package/dist/htmx/renderers.d.ts +8 -0
- package/dist/htmx/routes.d.ts +514 -0
- package/dist/htmx/types.d.ts +129 -0
- package/dist/index.js +31 -1
- package/dist/index.js.map +4 -4
- package/dist/linkedProviders/inMemoryStores.d.ts +9 -0
- package/dist/linkedProviders/neonStores.d.ts +484 -0
- package/dist/linkedProviders/oauthAccountResolver.d.ts +28 -0
- package/dist/linkedProviders/oauthResolver.d.ts +9 -0
- package/dist/linkedProviders/resolver.d.ts +22 -0
- package/dist/lockout/config.d.ts +17 -0
- package/dist/lockout/inMemoryLockoutStore.d.ts +2 -0
- package/dist/lockout/postgresLockoutStore.d.ts +71 -0
- package/dist/lockout/redisLockoutStore.d.ts +3 -0
- package/dist/lockout/types.d.ts +12 -0
- package/dist/mfa/backupCodes.d.ts +5 -0
- package/dist/mfa/challenge.d.ts +70 -0
- package/dist/mfa/config.d.ts +50 -0
- package/dist/mfa/gate.d.ts +2 -0
- package/dist/mfa/inMemoryMfaStore.d.ts +2 -0
- package/dist/mfa/management.d.ts +106 -0
- package/dist/mfa/postgresMfaStore.d.ts +206 -0
- package/dist/mfa/rotation.d.ts +17 -0
- package/dist/mfa/routes.d.ts +234 -0
- package/dist/mfa/secret.d.ts +2 -0
- package/dist/mfa/sms.d.ts +105 -0
- package/dist/mfa/totp.d.ts +91 -0
- package/dist/mfa/types.d.ts +23 -0
- package/dist/oidc/clientAuth.d.ts +19 -0
- package/dist/oidc/config.d.ts +296 -0
- package/dist/oidc/dpop.d.ts +23 -0
- package/dist/oidc/inMemoryVciStores.d.ts +3 -0
- package/dist/oidc/index.js +11 -1
- package/dist/oidc/index.js.map +3 -3
- package/dist/oidc/jar.d.ts +14 -0
- package/dist/oidc/keys.d.ts +35 -0
- package/dist/oidc/logout.d.ts +38 -0
- package/dist/oidc/mtls.d.ts +11 -0
- package/dist/oidc/par.d.ts +28 -0
- package/dist/oidc/registration.d.ts +138 -0
- package/dist/oidc/routes.d.ts +569 -0
- package/dist/oidc/types.d.ts +148 -0
- package/dist/oidc/userinfo.d.ts +21 -0
- package/dist/oidc/vci.d.ts +159 -0
- package/dist/oidc/vciRoutes.d.ts +92 -0
- package/dist/organizations/config.d.ts +46 -0
- package/dist/organizations/operations.d.ts +39 -0
- package/dist/organizations/routes.d.ts +299 -0
- package/dist/organizations/types.d.ts +45 -0
- package/dist/passwordless/config.d.ts +43 -0
- package/dist/passwordless/routes.d.ts +163 -0
- package/dist/passwordless/types.d.ts +9 -0
- package/dist/pluginIdentity.d.ts +2 -0
- package/dist/portal/config.d.ts +34 -0
- package/dist/portal/operations.d.ts +10 -0
- package/dist/portal/routes.d.ts +160 -0
- package/dist/portal/types.d.ts +16 -0
- package/dist/providers/clients.d.ts +1818 -0
- package/dist/providersFromEnv.d.ts +19 -0
- package/dist/roles/config.d.ts +27 -0
- package/dist/roles/operations.d.ts +8 -0
- package/dist/roles/routes.d.ts +106 -0
- package/dist/roles/types.d.ts +14 -0
- package/dist/routes/authorize.d.ts +102 -0
- package/dist/routes/callback.d.ts +64 -0
- package/dist/routes/profile.d.ts +70 -0
- package/dist/routes/protectRoute.d.ts +51 -0
- package/dist/routes/refresh.d.ts +74 -0
- package/dist/routes/revoke.d.ts +73 -0
- package/dist/routes/sessions.d.ts +103 -0
- package/dist/routes/signout.d.ts +70 -0
- package/dist/routes/stepUp.d.ts +48 -0
- package/dist/routes/userStatus.d.ts +72 -0
- package/dist/scim/config.d.ts +57 -0
- package/dist/scim/extensions.d.ts +30 -0
- package/dist/scim/inMemoryScimTokenStore.d.ts +2 -0
- package/dist/scim/routes.d.ts +366 -0
- package/dist/scim/serialize.d.ts +83 -0
- package/dist/scim/types.d.ts +54 -0
- package/dist/server.js +31 -1
- package/dist/server.js.map +4 -4
- package/dist/session/access.d.ts +33 -0
- package/dist/session/anonymous.d.ts +12 -0
- package/dist/session/cleanup.d.ts +45 -0
- package/dist/session/impersonation.d.ts +34 -0
- package/dist/session/inMemoryStore.d.ts +7 -0
- package/dist/session/multiSession.d.ts +27 -0
- package/dist/session/neonStore.d.ts +513 -0
- package/dist/session/promote.d.ts +23 -0
- package/dist/session/redisStore.d.ts +6 -0
- package/dist/session/sessionsConfig.d.ts +9 -0
- package/dist/session/state.d.ts +33 -0
- package/dist/session/types.d.ts +21 -0
- package/dist/session/userSessions.d.ts +19 -0
- package/dist/sso/config.d.ts +149 -0
- package/dist/sso/discoveryRoute.d.ts +63 -0
- package/dist/sso/oidcRoutes.d.ts +98 -0
- package/dist/sso/samlRoutes.d.ts +179 -0
- package/dist/sso/types.d.ts +53 -0
- package/dist/stores/postgres.d.ts +5 -0
- package/dist/stores/redis.d.ts +5 -0
- package/dist/telemetry/tracing.d.ts +15 -0
- package/dist/tenancy.d.ts +9 -0
- package/dist/typeGuards.d.ts +6 -0
- package/dist/typebox.d.ts +4 -0
- package/dist/types.d.ts +421 -0
- package/dist/utils.d.ts +45 -0
- package/dist/vault/config.d.ts +20 -0
- package/dist/vault/inMemoryVaultStore.d.ts +2 -0
- package/dist/vault/postgresVaultStore.d.ts +86 -0
- package/dist/vault/types.d.ts +14 -0
- package/dist/vc/inMemoryVpStores.d.ts +2 -0
- package/dist/vc/openid4vp.d.ts +82 -0
- package/dist/vc/postgresVcStores.d.ts +300 -0
- package/dist/vc/sdJwt.d.ts +37 -0
- package/dist/vc/statusList.d.ts +29 -0
- package/dist/vc/statusListRoutes.d.ts +63 -0
- package/dist/vc/vpRoutes.d.ts +120 -0
- package/dist/webauthn/adapter.d.ts +59 -0
- package/dist/webauthn/config.d.ts +36 -0
- package/dist/webauthn/routes.d.ts +155 -0
- package/dist/webauthn/types.d.ts +17 -0
- package/dist/webhooks/config.d.ts +34 -0
- package/dist/webhooks/dispatcher.d.ts +3 -0
- package/dist/webhooks/sign.d.ts +11 -0
- package/dist/webhooks/types.d.ts +25 -0
- package/package.json +3 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AbuseContext } from './config';
|
|
2
|
+
export declare const verifyHcaptcha: ({ secret }: {
|
|
3
|
+
secret: string;
|
|
4
|
+
}) => (token: string | undefined, context: AbuseContext) => Promise<boolean>;
|
|
5
|
+
export declare const verifyRecaptcha: ({ minScore, secret }: {
|
|
6
|
+
minScore?: number;
|
|
7
|
+
secret: string;
|
|
8
|
+
}) => (token: string | undefined, context: AbuseContext) => Promise<boolean>;
|
|
9
|
+
export declare const verifyTurnstile: ({ secret }: {
|
|
10
|
+
secret: string;
|
|
11
|
+
}) => (token: string | undefined, context: AbuseContext) => Promise<boolean>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type AbuseAction = 'allow' | 'challenge' | 'deny';
|
|
2
|
+
export type AbuseSignal = 'blocked_ip' | 'bot' | 'captcha_failed' | 'not_allowlisted';
|
|
3
|
+
export type BotClass = 'agent' | 'bot' | 'crawler' | 'human';
|
|
4
|
+
export type AbuseContext = {
|
|
5
|
+
captchaToken?: string;
|
|
6
|
+
ip?: string;
|
|
7
|
+
userAgent?: string;
|
|
8
|
+
};
|
|
9
|
+
export type AbuseReason = {
|
|
10
|
+
action: AbuseAction;
|
|
11
|
+
signal: AbuseSignal;
|
|
12
|
+
};
|
|
13
|
+
export type AbuseAssessment = {
|
|
14
|
+
action: AbuseAction;
|
|
15
|
+
reasons: AbuseReason[];
|
|
16
|
+
};
|
|
17
|
+
export type AbuseConfig = {
|
|
18
|
+
botAction?: AbuseAction;
|
|
19
|
+
captchaAction?: AbuseAction;
|
|
20
|
+
classifyBot?: (context: AbuseContext) => BotClass | Promise<BotClass>;
|
|
21
|
+
ipAllow?: string[];
|
|
22
|
+
ipDeny?: string[];
|
|
23
|
+
verifyCaptcha?: (token: string | undefined, context: AbuseContext) => boolean | Promise<boolean>;
|
|
24
|
+
};
|
|
25
|
+
export declare const assessAbuse: (config: AbuseConfig, context: AbuseContext) => Promise<AbuseAssessment>;
|
|
26
|
+
export declare const createAbuseGuard: (config: AbuseConfig) => {
|
|
27
|
+
assess: (context: AbuseContext) => Promise<AbuseAssessment>;
|
|
28
|
+
};
|
|
29
|
+
export declare const defaultBotClassifier: (context: AbuseContext) => "bot" | "crawler" | "human";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type AuthEventName = 'postLogin' | 'postLogout' | 'postMfa' | 'postOauthCallback' | 'postRegister' | 'preLogin' | 'preRegister';
|
|
2
|
+
export type AuthActionContext<UserType> = {
|
|
3
|
+
email?: string;
|
|
4
|
+
event: AuthEventName;
|
|
5
|
+
ip?: string;
|
|
6
|
+
metadata?: Record<string, unknown>;
|
|
7
|
+
user?: UserType;
|
|
8
|
+
userAgent?: string;
|
|
9
|
+
};
|
|
10
|
+
export type AuthActionResult = {
|
|
11
|
+
kind: 'deny';
|
|
12
|
+
reason: string;
|
|
13
|
+
} | {
|
|
14
|
+
kind: 'pass';
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'redirect';
|
|
17
|
+
url: string;
|
|
18
|
+
};
|
|
19
|
+
export type AuthAction<UserType> = {
|
|
20
|
+
event: AuthEventName | AuthEventName[];
|
|
21
|
+
handler: (context: AuthActionContext<UserType>) => AuthActionResult | Promise<AuthActionResult>;
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
export type AuthPipeline<UserType> = {
|
|
25
|
+
run: (event: AuthEventName, context: Omit<AuthActionContext<UserType>, 'event'>) => Promise<AuthActionResult>;
|
|
26
|
+
};
|
|
27
|
+
export declare const createActionPipeline: <UserType>(actions: AuthAction<UserType>[]) => AuthPipeline<UserType>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { RouteString } from '../types';
|
|
2
|
+
import type { AgentCredentialVerifier, AgentDelegationStore, AgentRegistrationStore } from './types';
|
|
3
|
+
import type { AgentRegistrationProtocolConfig } from './registration';
|
|
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
|
+
};
|
|
14
|
+
export type AgentAuthConfig = {
|
|
15
|
+
/** Permit registered agents to authenticate without a user delegation. Secure
|
|
16
|
+
* default is false; enable for machine-only resources. */
|
|
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;
|
|
21
|
+
authorizationServer: string;
|
|
22
|
+
delegationStore: AgentDelegationStore;
|
|
23
|
+
logoUri?: string;
|
|
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;
|
|
28
|
+
registrationStore: AgentRegistrationStore;
|
|
29
|
+
/** Treat clients created through RFC 7591 DCR as agent registrations. Explicitly
|
|
30
|
+
* opt-in because a deployment may also use DCR for ordinary relying parties. */
|
|
31
|
+
registerDynamicClients?: boolean;
|
|
32
|
+
resource: string;
|
|
33
|
+
resourceName?: string;
|
|
34
|
+
scopes: string[];
|
|
35
|
+
verifyCredential: AgentCredentialVerifier;
|
|
36
|
+
};
|
|
37
|
+
export declare const agentProtectedResourceMetadata: (config: Pick<AgentAuthConfig, "authorizationServer" | "logoUri" | "resource" | "resourceName" | "scopes">) => {
|
|
38
|
+
resource: string;
|
|
39
|
+
scopes_supported: string[];
|
|
40
|
+
resource_name?: string | undefined;
|
|
41
|
+
resource_logo_uri?: string | undefined;
|
|
42
|
+
authorization_servers: string[];
|
|
43
|
+
bearer_methods_supported: string[];
|
|
44
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type AgentAuthConfig } from './config';
|
|
3
|
+
import type { AgentPrincipal } from './types';
|
|
4
|
+
type AgentAuthFailure = {
|
|
5
|
+
code: 'Forbidden' | 'Unauthorized';
|
|
6
|
+
message: 'Agent is not authenticated' | 'Insufficient agent scopes';
|
|
7
|
+
};
|
|
8
|
+
export declare const agentAuthChallenge: ({ config, error, requiredScopes }: {
|
|
9
|
+
config: AgentAuthConfig;
|
|
10
|
+
error?: "invalid_token" | "insufficient_scope";
|
|
11
|
+
requiredScopes?: string[];
|
|
12
|
+
}) => string;
|
|
13
|
+
export declare const agentResourceMetadataUrl: (config: AgentAuthConfig) => string;
|
|
14
|
+
export declare const agentAuthContextPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
15
|
+
decorator: {};
|
|
16
|
+
store: {};
|
|
17
|
+
derive: {
|
|
18
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
19
|
+
};
|
|
20
|
+
resolve: {};
|
|
21
|
+
}, {
|
|
22
|
+
typebox: {};
|
|
23
|
+
error: {};
|
|
24
|
+
}, {
|
|
25
|
+
schema: {};
|
|
26
|
+
standaloneSchema: {};
|
|
27
|
+
macro: {};
|
|
28
|
+
macroFn: {};
|
|
29
|
+
parser: {};
|
|
30
|
+
response: import("elysia").ExtractErrorFromHandle<{
|
|
31
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: AgentAuthFailure) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
32
|
+
}>;
|
|
33
|
+
}, {}, {
|
|
34
|
+
derive: {};
|
|
35
|
+
resolve: {};
|
|
36
|
+
schema: {};
|
|
37
|
+
standaloneSchema: {};
|
|
38
|
+
response: {};
|
|
39
|
+
}, {
|
|
40
|
+
derive: {};
|
|
41
|
+
resolve: {};
|
|
42
|
+
schema: {};
|
|
43
|
+
standaloneSchema: {};
|
|
44
|
+
response: {};
|
|
45
|
+
}>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AgentAuthConfig } from './config';
|
|
2
|
+
import type { AgentPrincipal } from './types';
|
|
3
|
+
export declare const agentHasScopes: (principal: AgentPrincipal | undefined, requiredScopes: string[]) => boolean;
|
|
4
|
+
export declare const resolveAgentPrincipal: (request: Request, config: AgentAuthConfig) => Promise<AgentPrincipal | undefined>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import type { AccessTokenStore } from '../apikeys/types';
|
|
2
|
+
import { type SigningKey } from '../oidc/keys';
|
|
3
|
+
import type { RouteString } from '../types';
|
|
4
|
+
import type { AgentAuthConfig, AgentRegistrationDiscoveryMetadata } from './config';
|
|
5
|
+
import type { AgentIdentityRegistration, AgentIdentityRegistrationKind, AgentIdentityRegistrationStore, VerifiedAgentIdentityAssertion } from './types';
|
|
6
|
+
export declare const AGENT_CLAIM_GRANT_TYPE: "urn:workos:agent-auth:grant-type:claim";
|
|
7
|
+
export declare const AGENT_IDENTITY_ASSERTION_GRANT_TYPE: "urn:ietf:params:oauth:grant-type:jwt-bearer";
|
|
8
|
+
export declare const AGENT_IDENTITY_ASSERTION_TYPE: "urn:ietf:params:oauth:token-type:id-jag";
|
|
9
|
+
export type AgentRegistrationAuthenticatedUser = {
|
|
10
|
+
email?: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
};
|
|
13
|
+
export type AgentRegistrationProtocolConfig = {
|
|
14
|
+
accessTokenStore: AccessTokenStore;
|
|
15
|
+
allowAnonymous?: boolean;
|
|
16
|
+
allowServiceAuth?: boolean;
|
|
17
|
+
assertionTtlMs?: number;
|
|
18
|
+
attemptTtlMs?: number;
|
|
19
|
+
claimRoute?: RouteString;
|
|
20
|
+
claimTtlMs?: number;
|
|
21
|
+
completeRoute?: RouteString;
|
|
22
|
+
guideRoute?: RouteString;
|
|
23
|
+
identityRoute?: RouteString;
|
|
24
|
+
identityStore: AgentIdentityRegistrationStore;
|
|
25
|
+
maxAuthenticationAgeMs?: number;
|
|
26
|
+
maxCodeAttempts?: number;
|
|
27
|
+
pollIntervalSeconds?: number;
|
|
28
|
+
postClaimScopes: string[];
|
|
29
|
+
preClaimScopes?: string[];
|
|
30
|
+
resolveAuthenticatedUser: (request: Request) => Promise<AgentRegistrationAuthenticatedUser | undefined>;
|
|
31
|
+
/** Match a cryptographically verified upstream identity to local state. A
|
|
32
|
+
* userId permits immediate registration; omitting it requires a user claim. */
|
|
33
|
+
resolveVerifiedIdentity?: (identity: VerifiedAgentIdentityAssertion) => Promise<{
|
|
34
|
+
userId?: string;
|
|
35
|
+
} | undefined>;
|
|
36
|
+
/** Bulk-revokes access tokens for an agent. Required for anonymous
|
|
37
|
+
* registration and recommended for immediate cleanup on any revocation. It
|
|
38
|
+
* must be idempotent because atomic state updates may be retried. */
|
|
39
|
+
revokeAccessTokens?: (agentId: string) => Promise<void>;
|
|
40
|
+
signingKey: SigningKey;
|
|
41
|
+
tokenTtlMs?: number;
|
|
42
|
+
verifyIdentityAssertion?: (assertion: string) => Promise<VerifiedAgentIdentityAssertion | undefined>;
|
|
43
|
+
};
|
|
44
|
+
export type AgentRegistrationEndpoints = {
|
|
45
|
+
claimEndpoint: string;
|
|
46
|
+
completeEndpoint: string;
|
|
47
|
+
guide: string;
|
|
48
|
+
identityEndpoint: string;
|
|
49
|
+
tokenEndpoint: string;
|
|
50
|
+
};
|
|
51
|
+
export declare const agentRegistrationDiscoveryMetadata: (config: AgentAuthConfig) => AgentRegistrationDiscoveryMetadata;
|
|
52
|
+
export declare const agentRegistrationEndpoints: (config: AgentAuthConfig) => AgentRegistrationEndpoints;
|
|
53
|
+
/** Generates the agent-readable companion document. Endpoint URLs and support
|
|
54
|
+
* flags come from the same structured configuration used for discovery, so the
|
|
55
|
+
* prose cannot silently drift from the authorization server metadata. */
|
|
56
|
+
export declare const generateAgentRegistrationGuide: (config: AgentAuthConfig) => string;
|
|
57
|
+
declare const createFlow: ({ agentId, kind, loginHint, now, registration, status, upstream, userId, withAttempt }: {
|
|
58
|
+
agentId: string;
|
|
59
|
+
kind: AgentIdentityRegistrationKind;
|
|
60
|
+
loginHint?: string;
|
|
61
|
+
now: number;
|
|
62
|
+
registration: AgentRegistrationProtocolConfig;
|
|
63
|
+
status: AgentIdentityRegistration["status"];
|
|
64
|
+
upstream?: AgentIdentityRegistration["upstream"];
|
|
65
|
+
userId?: string;
|
|
66
|
+
withAttempt?: string;
|
|
67
|
+
}) => Promise<{
|
|
68
|
+
attempt: {
|
|
69
|
+
attempt: {
|
|
70
|
+
attempts: number;
|
|
71
|
+
email: string;
|
|
72
|
+
expiresAt: number;
|
|
73
|
+
tokenHash: string;
|
|
74
|
+
userCodeHash: string;
|
|
75
|
+
};
|
|
76
|
+
attemptToken: string;
|
|
77
|
+
expiresAt: number;
|
|
78
|
+
userCode: string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
claimToken: string;
|
|
81
|
+
flow: AgentIdentityRegistration;
|
|
82
|
+
}>;
|
|
83
|
+
export declare const issueAgentServiceAssertion: (config: AgentAuthConfig, flow: AgentIdentityRegistration, now?: number) => Promise<{
|
|
84
|
+
assertion: string;
|
|
85
|
+
expiresAt: number;
|
|
86
|
+
}>;
|
|
87
|
+
declare const ceremony: (config: AgentAuthConfig, flow: AgentIdentityRegistration, attempt: NonNullable<Awaited<ReturnType<typeof createFlow>>["attempt"]>) => {
|
|
88
|
+
expires_in: number;
|
|
89
|
+
interval: number;
|
|
90
|
+
user_code: string;
|
|
91
|
+
verification_uri: string;
|
|
92
|
+
};
|
|
93
|
+
export type StartAgentRegistrationInput = {
|
|
94
|
+
type: 'anonymous';
|
|
95
|
+
} | {
|
|
96
|
+
loginHint: string;
|
|
97
|
+
type: 'service_auth';
|
|
98
|
+
} | {
|
|
99
|
+
assertion: string;
|
|
100
|
+
assertionType: typeof AGENT_IDENTITY_ASSERTION_TYPE;
|
|
101
|
+
type: 'identity_assertion';
|
|
102
|
+
};
|
|
103
|
+
export type StartAgentRegistrationResult = {
|
|
104
|
+
error: string;
|
|
105
|
+
message?: string;
|
|
106
|
+
status: 400 | 401 | 403;
|
|
107
|
+
} | {
|
|
108
|
+
assertionExpires: number;
|
|
109
|
+
claim?: ReturnType<typeof ceremony>;
|
|
110
|
+
claimToken?: string;
|
|
111
|
+
claimTokenExpires?: number;
|
|
112
|
+
identityAssertion?: string;
|
|
113
|
+
preClaimScopes?: string[];
|
|
114
|
+
postClaimScopes: string[];
|
|
115
|
+
registrationId: string;
|
|
116
|
+
registrationType: AgentIdentityRegistrationKind;
|
|
117
|
+
status: 200;
|
|
118
|
+
};
|
|
119
|
+
export declare const startAgentRegistration: (config: AgentAuthConfig, input: StartAgentRegistrationInput, now?: number) => Promise<StartAgentRegistrationResult>;
|
|
120
|
+
export type BeginAgentClaimResult = {
|
|
121
|
+
error: 'claim_expired' | 'invalid_claim_token';
|
|
122
|
+
status: 400;
|
|
123
|
+
} | {
|
|
124
|
+
error: 'concurrent_update';
|
|
125
|
+
status: 409;
|
|
126
|
+
} | {
|
|
127
|
+
claimAttempt: ReturnType<typeof ceremony>;
|
|
128
|
+
status: 200;
|
|
129
|
+
};
|
|
130
|
+
export declare const beginAgentClaim: (config: AgentAuthConfig, input: {
|
|
131
|
+
claimToken: string;
|
|
132
|
+
email: string;
|
|
133
|
+
}, now?: number) => Promise<BeginAgentClaimResult>;
|
|
134
|
+
export type CompleteAgentClaimResult = {
|
|
135
|
+
error: 'claim_expired' | 'concurrent_update' | 'invalid_claim_attempt' | 'user_code_invalid' | 'wrong_user';
|
|
136
|
+
status: 400 | 403 | 409 | 429;
|
|
137
|
+
} | {
|
|
138
|
+
status: 204;
|
|
139
|
+
};
|
|
140
|
+
export declare const completeAgentClaim: (config: AgentAuthConfig, input: {
|
|
141
|
+
attemptToken: string;
|
|
142
|
+
request: Request;
|
|
143
|
+
userCode: string;
|
|
144
|
+
}, now?: number) => Promise<CompleteAgentClaimResult>;
|
|
145
|
+
export type AgentTokenGrantResult = {
|
|
146
|
+
body: Record<string, unknown>;
|
|
147
|
+
status: 200;
|
|
148
|
+
} | {
|
|
149
|
+
body: {
|
|
150
|
+
error: string;
|
|
151
|
+
};
|
|
152
|
+
status: 400;
|
|
153
|
+
};
|
|
154
|
+
export declare const createAgentRegistrationCredentialVerifier: (accessTokenStore: AccessTokenStore, identityStore?: AgentIdentityRegistrationStore) => (request: Request) => Promise<{
|
|
155
|
+
agentId: string;
|
|
156
|
+
expiresAt: number;
|
|
157
|
+
scopes: string[];
|
|
158
|
+
userId: string | undefined;
|
|
159
|
+
} | undefined>;
|
|
160
|
+
export declare const handleAgentTokenGrant: (config: AgentAuthConfig, body: Record<string, string | undefined>, now?: number) => Promise<AgentTokenGrantResult | undefined>;
|
|
161
|
+
export declare const revokeAgentIdentityRegistration: (config: AgentAuthConfig, registrationId: string, now?: number) => Promise<boolean>;
|
|
162
|
+
export {};
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import { type AgentAuthConfig } from './config';
|
|
3
|
+
import { agentAuthChallenge } from './context';
|
|
4
|
+
import { agentRegistrationDiscoveryMetadata } from './registration';
|
|
5
|
+
export { agentAuthChallenge, agentRegistrationDiscoveryMetadata };
|
|
6
|
+
export declare const agentAuthPlugin: (config?: AgentAuthConfig) => Elysia<"", {
|
|
7
|
+
decorator: {};
|
|
8
|
+
store: {};
|
|
9
|
+
derive: {
|
|
10
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
11
|
+
code: "Forbidden" | "Unauthorized";
|
|
12
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
13
|
+
}) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
14
|
+
};
|
|
15
|
+
resolve: {};
|
|
16
|
+
}, {
|
|
17
|
+
typebox: {};
|
|
18
|
+
error: {};
|
|
19
|
+
}, {
|
|
20
|
+
schema: {};
|
|
21
|
+
standaloneSchema: {};
|
|
22
|
+
macro: {};
|
|
23
|
+
macroFn: {};
|
|
24
|
+
parser: {};
|
|
25
|
+
response: import("elysia").ExtractErrorFromHandle<{
|
|
26
|
+
readonly protectAgent: <AuthReturn, AuthFailReturn>(requiredScopes: string[], handleAuth: (principal: import("./types").AgentPrincipal) => AuthReturn | Promise<AuthReturn>, handleAuthFail?: (error: {
|
|
27
|
+
code: "Forbidden" | "Unauthorized";
|
|
28
|
+
message: "Agent is not authenticated" | "Insufficient agent scopes";
|
|
29
|
+
}) => AuthFailReturn | Promise<AuthFailReturn>) => Promise<Response | AuthReturn | NonNullable<Awaited<AuthFailReturn>>>;
|
|
30
|
+
}>;
|
|
31
|
+
}, {} | {
|
|
32
|
+
[x: string]: {
|
|
33
|
+
get: {
|
|
34
|
+
body: unknown;
|
|
35
|
+
params: {};
|
|
36
|
+
query: unknown;
|
|
37
|
+
headers: unknown;
|
|
38
|
+
response: {
|
|
39
|
+
200: {
|
|
40
|
+
resource: string;
|
|
41
|
+
scopes_supported: string[];
|
|
42
|
+
resource_name?: string | undefined;
|
|
43
|
+
resource_logo_uri?: string | undefined;
|
|
44
|
+
authorization_servers: string[];
|
|
45
|
+
bearer_methods_supported: string[];
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
} | ({
|
|
51
|
+
[x: string]: {
|
|
52
|
+
get: {
|
|
53
|
+
body: unknown;
|
|
54
|
+
params: {};
|
|
55
|
+
query: unknown;
|
|
56
|
+
headers: unknown;
|
|
57
|
+
response: {
|
|
58
|
+
200: {
|
|
59
|
+
resource: string;
|
|
60
|
+
scopes_supported: string[];
|
|
61
|
+
resource_name?: string | undefined;
|
|
62
|
+
resource_logo_uri?: string | undefined;
|
|
63
|
+
authorization_servers: string[];
|
|
64
|
+
bearer_methods_supported: string[];
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
} & {
|
|
70
|
+
[x: string]: {
|
|
71
|
+
get: {
|
|
72
|
+
body: unknown;
|
|
73
|
+
params: {};
|
|
74
|
+
query: unknown;
|
|
75
|
+
headers: unknown;
|
|
76
|
+
response: {
|
|
77
|
+
200: Response;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
} & {
|
|
82
|
+
[x: string]: {
|
|
83
|
+
get: {
|
|
84
|
+
body: unknown;
|
|
85
|
+
params: {};
|
|
86
|
+
query: unknown;
|
|
87
|
+
headers: unknown;
|
|
88
|
+
response: {
|
|
89
|
+
200: Response;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
} & {
|
|
94
|
+
[x: string]: {
|
|
95
|
+
post: {
|
|
96
|
+
body: unknown;
|
|
97
|
+
params: {};
|
|
98
|
+
query: unknown;
|
|
99
|
+
headers: unknown;
|
|
100
|
+
response: {
|
|
101
|
+
200: Response;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
} & {
|
|
106
|
+
[x: string]: {
|
|
107
|
+
post: {
|
|
108
|
+
body: unknown;
|
|
109
|
+
params: {};
|
|
110
|
+
query: unknown;
|
|
111
|
+
headers: unknown;
|
|
112
|
+
response: {
|
|
113
|
+
200: Response;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
} & {
|
|
118
|
+
[x: string]: {
|
|
119
|
+
post: {
|
|
120
|
+
body: unknown;
|
|
121
|
+
params: {};
|
|
122
|
+
query: unknown;
|
|
123
|
+
headers: unknown;
|
|
124
|
+
response: {
|
|
125
|
+
200: Response;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
}), {
|
|
130
|
+
derive: {};
|
|
131
|
+
resolve: {};
|
|
132
|
+
schema: {};
|
|
133
|
+
standaloneSchema: {};
|
|
134
|
+
response: {};
|
|
135
|
+
}, {
|
|
136
|
+
derive: {};
|
|
137
|
+
resolve: {};
|
|
138
|
+
schema: {};
|
|
139
|
+
standaloneSchema: {};
|
|
140
|
+
response: {};
|
|
141
|
+
}>;
|
|
142
|
+
export declare const agentAuthRoutes: (config?: AgentAuthConfig) => Elysia<"", {
|
|
143
|
+
decorator: {};
|
|
144
|
+
store: {};
|
|
145
|
+
derive: {};
|
|
146
|
+
resolve: {};
|
|
147
|
+
}, {
|
|
148
|
+
typebox: {};
|
|
149
|
+
error: {};
|
|
150
|
+
}, {
|
|
151
|
+
schema: {};
|
|
152
|
+
standaloneSchema: {};
|
|
153
|
+
macro: {};
|
|
154
|
+
macroFn: {};
|
|
155
|
+
parser: {};
|
|
156
|
+
response: {};
|
|
157
|
+
}, {}, {
|
|
158
|
+
derive: {};
|
|
159
|
+
resolve: {};
|
|
160
|
+
schema: {};
|
|
161
|
+
standaloneSchema: {};
|
|
162
|
+
response: {};
|
|
163
|
+
}, {
|
|
164
|
+
derive: {};
|
|
165
|
+
resolve: {};
|
|
166
|
+
schema: {};
|
|
167
|
+
standaloneSchema: {};
|
|
168
|
+
response: {};
|
|
169
|
+
}> | Elysia<"", {
|
|
170
|
+
decorator: {};
|
|
171
|
+
store: {};
|
|
172
|
+
derive: {};
|
|
173
|
+
resolve: {};
|
|
174
|
+
}, {
|
|
175
|
+
typebox: {};
|
|
176
|
+
error: {};
|
|
177
|
+
}, {
|
|
178
|
+
schema: {};
|
|
179
|
+
standaloneSchema: {};
|
|
180
|
+
macro: {};
|
|
181
|
+
macroFn: {};
|
|
182
|
+
parser: {};
|
|
183
|
+
response: {};
|
|
184
|
+
}, {
|
|
185
|
+
[x: string]: {
|
|
186
|
+
get: {
|
|
187
|
+
body: unknown;
|
|
188
|
+
params: {};
|
|
189
|
+
query: unknown;
|
|
190
|
+
headers: unknown;
|
|
191
|
+
response: {
|
|
192
|
+
200: {
|
|
193
|
+
resource: string;
|
|
194
|
+
scopes_supported: string[];
|
|
195
|
+
resource_name?: string | undefined;
|
|
196
|
+
resource_logo_uri?: string | undefined;
|
|
197
|
+
authorization_servers: string[];
|
|
198
|
+
bearer_methods_supported: string[];
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
}, {
|
|
204
|
+
derive: {};
|
|
205
|
+
resolve: {};
|
|
206
|
+
schema: {};
|
|
207
|
+
standaloneSchema: {};
|
|
208
|
+
response: {};
|
|
209
|
+
}, {
|
|
210
|
+
derive: {};
|
|
211
|
+
resolve: {};
|
|
212
|
+
schema: {};
|
|
213
|
+
standaloneSchema: {};
|
|
214
|
+
response: {};
|
|
215
|
+
}> | Elysia<"", {
|
|
216
|
+
decorator: {};
|
|
217
|
+
store: {};
|
|
218
|
+
derive: {};
|
|
219
|
+
resolve: {};
|
|
220
|
+
}, {
|
|
221
|
+
typebox: {};
|
|
222
|
+
error: {};
|
|
223
|
+
}, {
|
|
224
|
+
schema: {};
|
|
225
|
+
standaloneSchema: {};
|
|
226
|
+
macro: {};
|
|
227
|
+
macroFn: {};
|
|
228
|
+
parser: {};
|
|
229
|
+
response: {};
|
|
230
|
+
}, {
|
|
231
|
+
[x: string]: {
|
|
232
|
+
get: {
|
|
233
|
+
body: unknown;
|
|
234
|
+
params: {};
|
|
235
|
+
query: unknown;
|
|
236
|
+
headers: unknown;
|
|
237
|
+
response: {
|
|
238
|
+
200: {
|
|
239
|
+
resource: string;
|
|
240
|
+
scopes_supported: string[];
|
|
241
|
+
resource_name?: string | undefined;
|
|
242
|
+
resource_logo_uri?: string | undefined;
|
|
243
|
+
authorization_servers: string[];
|
|
244
|
+
bearer_methods_supported: string[];
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
} & {
|
|
250
|
+
[x: string]: {
|
|
251
|
+
get: {
|
|
252
|
+
body: unknown;
|
|
253
|
+
params: {};
|
|
254
|
+
query: unknown;
|
|
255
|
+
headers: unknown;
|
|
256
|
+
response: {
|
|
257
|
+
200: Response;
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
} & {
|
|
262
|
+
[x: string]: {
|
|
263
|
+
get: {
|
|
264
|
+
body: unknown;
|
|
265
|
+
params: {};
|
|
266
|
+
query: unknown;
|
|
267
|
+
headers: unknown;
|
|
268
|
+
response: {
|
|
269
|
+
200: Response;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
} & {
|
|
274
|
+
[x: string]: {
|
|
275
|
+
post: {
|
|
276
|
+
body: unknown;
|
|
277
|
+
params: {};
|
|
278
|
+
query: unknown;
|
|
279
|
+
headers: unknown;
|
|
280
|
+
response: {
|
|
281
|
+
200: Response;
|
|
282
|
+
};
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
} & {
|
|
286
|
+
[x: string]: {
|
|
287
|
+
post: {
|
|
288
|
+
body: unknown;
|
|
289
|
+
params: {};
|
|
290
|
+
query: unknown;
|
|
291
|
+
headers: unknown;
|
|
292
|
+
response: {
|
|
293
|
+
200: Response;
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
} & {
|
|
298
|
+
[x: string]: {
|
|
299
|
+
post: {
|
|
300
|
+
body: unknown;
|
|
301
|
+
params: {};
|
|
302
|
+
query: unknown;
|
|
303
|
+
headers: unknown;
|
|
304
|
+
response: {
|
|
305
|
+
200: Response;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
}, {
|
|
310
|
+
derive: {};
|
|
311
|
+
resolve: {};
|
|
312
|
+
schema: {};
|
|
313
|
+
standaloneSchema: {};
|
|
314
|
+
response: {};
|
|
315
|
+
}, {
|
|
316
|
+
derive: {};
|
|
317
|
+
resolve: {};
|
|
318
|
+
schema: {};
|
|
319
|
+
standaloneSchema: {};
|
|
320
|
+
response: {};
|
|
321
|
+
}>;
|