@frontmcp/auth 0.10.0 → 0.11.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/__test-utils__/assertion.helpers.d.ts +2 -0
- package/__test-utils__/assertion.helpers.d.ts.map +1 -0
- package/authorization/authorization.class.d.ts +122 -0
- package/authorization/authorization.class.d.ts.map +1 -0
- package/authorization/authorization.types.d.ts +65 -1
- package/authorization/authorization.types.d.ts.map +1 -1
- package/authorization/index.d.ts +11 -2
- package/authorization/index.d.ts.map +1 -1
- package/authorization/orchestrated.accessor.d.ts +161 -0
- package/authorization/orchestrated.accessor.d.ts.map +1 -0
- package/authorization/orchestrated.authorization.d.ts +257 -0
- package/authorization/orchestrated.authorization.d.ts.map +1 -0
- package/authorization/public.authorization.d.ts +92 -0
- package/authorization/public.authorization.d.ts.map +1 -0
- package/authorization/transparent.authorization.d.ts +130 -0
- package/authorization/transparent.authorization.d.ts.map +1 -0
- package/common/auth-logger.interface.d.ts +15 -0
- package/common/auth-logger.interface.d.ts.map +1 -0
- package/common/index.d.ts +6 -0
- package/common/index.d.ts.map +1 -0
- package/common/jwt.types.d.ts +87 -0
- package/common/jwt.types.d.ts.map +1 -0
- package/common/session-user.types.d.ts +17 -0
- package/common/session-user.types.d.ts.map +1 -0
- package/common/session.types.d.ts +190 -0
- package/common/session.types.d.ts.map +1 -0
- package/common/zod-utils.d.ts +5 -0
- package/common/zod-utils.d.ts.map +1 -0
- package/consent/consent.types.d.ts +112 -0
- package/consent/consent.types.d.ts.map +1 -0
- package/consent/index.d.ts +2 -0
- package/consent/index.d.ts.map +1 -0
- package/detection/auth-provider-detection.d.ts +53 -0
- package/detection/auth-provider-detection.d.ts.map +1 -0
- package/detection/index.d.ts +3 -0
- package/detection/index.d.ts.map +1 -0
- package/errors/auth-internal.error.d.ts +33 -0
- package/errors/auth-internal.error.d.ts.map +1 -0
- package/errors/auth-internal.errors.d.ts +123 -0
- package/errors/auth-internal.errors.d.ts.map +1 -0
- package/errors/index.d.ts +3 -0
- package/errors/index.d.ts.map +1 -0
- package/esm/index.mjs +5473 -1204
- package/esm/package.json +18 -3
- package/index.d.ts +18 -5
- package/index.d.ts.map +1 -1
- package/index.js +5351 -961
- package/jwks/jwks.service.d.ts +1 -0
- package/jwks/jwks.service.d.ts.map +1 -1
- package/jwks/jwks.types.d.ts +3 -0
- package/jwks/jwks.types.d.ts.map +1 -1
- package/machine-id/index.d.ts +2 -0
- package/machine-id/index.d.ts.map +1 -0
- package/machine-id/machine-id.d.ts +28 -0
- package/machine-id/machine-id.d.ts.map +1 -0
- package/options/app-auth.schema.d.ts +272 -0
- package/options/app-auth.schema.d.ts.map +1 -0
- package/options/index.d.ts +15 -0
- package/options/index.d.ts.map +1 -0
- package/options/interfaces.d.ts +250 -0
- package/options/interfaces.d.ts.map +1 -0
- package/options/orchestrated.schema.d.ts +446 -0
- package/options/orchestrated.schema.d.ts.map +1 -0
- package/options/public.schema.d.ts +19 -0
- package/options/public.schema.d.ts.map +1 -0
- package/options/schema.d.ts +265 -0
- package/options/schema.d.ts.map +1 -0
- package/options/shared.schemas.d.ts +128 -0
- package/options/shared.schemas.d.ts.map +1 -0
- package/options/transparent.schema.d.ts +33 -0
- package/options/transparent.schema.d.ts.map +1 -0
- package/options/typecheck.d.ts +2 -0
- package/options/typecheck.d.ts.map +1 -0
- package/options/utils.d.ts +33 -0
- package/options/utils.d.ts.map +1 -0
- package/package.json +18 -3
- package/session/encrypted-authorization-vault.d.ts +182 -0
- package/session/encrypted-authorization-vault.d.ts.map +1 -0
- package/session/federated-auth.session.d.ts +252 -0
- package/session/federated-auth.session.d.ts.map +1 -0
- package/session/index.d.ts +21 -1
- package/session/index.d.ts.map +1 -1
- package/session/orchestrated-token.store.d.ts +155 -0
- package/session/orchestrated-token.store.d.ts.map +1 -0
- package/session/redis-session.store.d.ts +93 -0
- package/session/redis-session.store.d.ts.map +1 -0
- package/session/session-crypto.d.ts +84 -0
- package/session/session-crypto.d.ts.map +1 -0
- package/session/session-rate-limiter.d.ts +114 -0
- package/session/session-rate-limiter.d.ts.map +1 -0
- package/session/session.transport.d.ts +11 -0
- package/session/session.transport.d.ts.map +1 -0
- package/session/session.types.d.ts +66 -0
- package/session/session.types.d.ts.map +1 -0
- package/session/token.refresh.d.ts +61 -0
- package/session/token.refresh.d.ts.map +1 -0
- package/session/transport-session.types.d.ts +479 -0
- package/session/transport-session.types.d.ts.map +1 -0
- package/session/utils/auth-token.utils.d.ts +12 -0
- package/session/utils/auth-token.utils.d.ts.map +1 -0
- package/session/utils/index.d.ts +2 -0
- package/session/utils/index.d.ts.map +1 -1
- package/session/utils/session-crypto.utils.d.ts +30 -0
- package/session/utils/session-crypto.utils.d.ts.map +1 -0
- package/session/vercel-kv-session.store.d.ts +123 -0
- package/session/vercel-kv-session.store.d.ts.map +1 -0
- package/utils/authorization-id.utils.d.ts +12 -0
- package/utils/authorization-id.utils.d.ts.map +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.d.ts.map +1 -1
- package/vault/auth-providers.accessor.d.ts +154 -0
- package/vault/auth-providers.accessor.d.ts.map +1 -0
- package/vault/auth-providers.accessor.impl.d.ts +54 -0
- package/vault/auth-providers.accessor.impl.d.ts.map +1 -0
- package/vault/auth-providers.registry.d.ts +111 -0
- package/vault/auth-providers.registry.d.ts.map +1 -0
- package/vault/auth-providers.types.d.ts +3 -3
- package/vault/auth-providers.vault.d.ts +94 -0
- package/vault/auth-providers.vault.d.ts.map +1 -0
- package/vault/credential-loaders/eager-loader.d.ts +47 -0
- package/vault/credential-loaders/eager-loader.d.ts.map +1 -0
- package/vault/credential-loaders/index.d.ts +7 -0
- package/vault/credential-loaders/index.d.ts.map +1 -0
- package/vault/credential-loaders/lazy-loader.d.ts +54 -0
- package/vault/credential-loaders/lazy-loader.d.ts.map +1 -0
- package/vault/index.d.ts +9 -0
- package/vault/index.d.ts.map +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive a consistent authorization ID from a JWT token.
|
|
3
|
+
*
|
|
4
|
+
* Uses the token's signature (third part) to generate a deterministic
|
|
5
|
+
* ID that uniquely identifies this authorization without exposing
|
|
6
|
+
* the full token.
|
|
7
|
+
*
|
|
8
|
+
* @param token - JWT token string
|
|
9
|
+
* @returns 16-character hex string authorization ID
|
|
10
|
+
*/
|
|
11
|
+
export declare function deriveAuthorizationId(token: string): string;
|
|
12
|
+
//# sourceMappingURL=authorization-id.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-id.utils.d.ts","sourceRoot":"","sources":["../../src/utils/authorization-id.utils.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAI3D"}
|
package/utils/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export { buildWwwAuthenticate, buildPrmUrl, buildUnauthorizedHeader, buildInvali
|
|
|
5
5
|
export type { BearerErrorCode, WwwAuthenticateOptions } from './www-authenticate.utils';
|
|
6
6
|
export { validateAudience, createAudienceValidator, deriveExpectedAudience, AudienceValidator, } from './audience.validator';
|
|
7
7
|
export type { AudienceValidationResult, AudienceValidatorOptions } from './audience.validator';
|
|
8
|
+
export { deriveAuthorizationId } from './authorization-id.utils';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/utils/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAExF,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,uBAAuB,EACvB,uBAAuB,EACvB,4BAA4B,EAC5B,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAExF,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAE/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthProvidersAccessor - Interface for accessing auth provider credentials
|
|
3
|
+
*
|
|
4
|
+
* This interface provides the runtime API for tools to access credentials
|
|
5
|
+
* from registered auth providers. It supports:
|
|
6
|
+
* - Credential retrieval by provider name
|
|
7
|
+
* - Lazy loading with session-scoped caching
|
|
8
|
+
* - Automatic token refresh for OAuth providers
|
|
9
|
+
* - Headers generation for HTTP requests
|
|
10
|
+
*/
|
|
11
|
+
import { Token } from '@frontmcp/di';
|
|
12
|
+
import type { Credential } from '../session';
|
|
13
|
+
import type { ResolvedCredential, GetCredentialOptions } from './auth-providers.types';
|
|
14
|
+
/**
|
|
15
|
+
* AuthProvidersAccessor - Runtime accessor for auth providers in tool contexts.
|
|
16
|
+
*
|
|
17
|
+
* Available in tool execution via `this.authProviders`:
|
|
18
|
+
* ```typescript
|
|
19
|
+
* @Tool({ name: 'my_tool' })
|
|
20
|
+
* class MyTool extends ToolContext {
|
|
21
|
+
* async execute(input: Input) {
|
|
22
|
+
* const github = await this.authProviders.get('github');
|
|
23
|
+
* const headers = await this.authProviders.headers('github');
|
|
24
|
+
* }
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export interface AuthProvidersAccessor {
|
|
29
|
+
/**
|
|
30
|
+
* Get a credential by provider name.
|
|
31
|
+
*
|
|
32
|
+
* @param providerName - Registered provider name (e.g., 'github', 'google')
|
|
33
|
+
* @param options - Retrieval options (forceRefresh, scopes, timeout)
|
|
34
|
+
* @returns Resolved credential or null if not available
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const cred = await this.authProviders.get('github');
|
|
39
|
+
* if (cred?.credential.type === 'oauth') {
|
|
40
|
+
* const token = cred.credential.accessToken;
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Force refresh
|
|
45
|
+
* ```typescript
|
|
46
|
+
* const cred = await this.authProviders.get('github', { forceRefresh: true });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
get<T extends Credential = Credential>(providerName: string, options?: GetCredentialOptions): Promise<ResolvedCredential<T> | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Get multiple credentials by provider names.
|
|
52
|
+
* Executes all retrievals in parallel for efficiency.
|
|
53
|
+
*
|
|
54
|
+
* @param providerNames - Array of provider names
|
|
55
|
+
* @param options - Retrieval options applied to all providers
|
|
56
|
+
* @returns Map of provider name to resolved credential (null if not available)
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const creds = await this.authProviders.getMany(['github', 'jira']);
|
|
61
|
+
* const github = creds.get('github');
|
|
62
|
+
* const jira = creds.get('jira');
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
getMany(providerNames: string[], options?: GetCredentialOptions): Promise<Map<string, ResolvedCredential | null>>;
|
|
66
|
+
/**
|
|
67
|
+
* Get headers for a provider (convenience method).
|
|
68
|
+
* Automatically handles different credential types:
|
|
69
|
+
* - OAuth/Bearer: `Authorization: Bearer <token>`
|
|
70
|
+
* - API Key: Uses configured header name
|
|
71
|
+
* - Basic: `Authorization: Basic <base64>`
|
|
72
|
+
*
|
|
73
|
+
* @param providerName - Provider name
|
|
74
|
+
* @returns Headers record or empty object if not available
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const headers = await this.authProviders.headers('github');
|
|
79
|
+
* const response = await fetch(url, { headers });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
headers(providerName: string): Promise<Record<string, string>>;
|
|
83
|
+
/**
|
|
84
|
+
* Get headers for multiple providers merged into a single object.
|
|
85
|
+
* Later providers override earlier ones if headers conflict.
|
|
86
|
+
*
|
|
87
|
+
* @param providerNames - Array of provider names
|
|
88
|
+
* @returns Merged headers from all providers
|
|
89
|
+
*/
|
|
90
|
+
headersMany(providerNames: string[]): Promise<Record<string, string>>;
|
|
91
|
+
/**
|
|
92
|
+
* Force refresh a credential (for OAuth token refresh).
|
|
93
|
+
* Uses the provider's refresh function if available, otherwise calls factory.
|
|
94
|
+
*
|
|
95
|
+
* @param providerName - Provider name to refresh
|
|
96
|
+
* @returns New credential or null if refresh failed
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // On 401 response, try refreshing
|
|
101
|
+
* if (response.status === 401) {
|
|
102
|
+
* const newCred = await this.authProviders.refresh('github');
|
|
103
|
+
* if (newCred) {
|
|
104
|
+
* // Retry request with new credential
|
|
105
|
+
* }
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
refresh(providerName: string): Promise<ResolvedCredential | null>;
|
|
110
|
+
/**
|
|
111
|
+
* Check if a provider credential is available and valid.
|
|
112
|
+
* Does not trigger credential loading.
|
|
113
|
+
*
|
|
114
|
+
* @param providerName - Provider name
|
|
115
|
+
* @returns true if credential exists in cache/vault and is valid
|
|
116
|
+
*/
|
|
117
|
+
has(providerName: string): Promise<boolean>;
|
|
118
|
+
/**
|
|
119
|
+
* Check if a provider is registered (regardless of credential availability).
|
|
120
|
+
*
|
|
121
|
+
* @param providerName - Provider name
|
|
122
|
+
* @returns true if provider is registered
|
|
123
|
+
*/
|
|
124
|
+
isRegistered(providerName: string): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Invalidate cached credential (triggers reload on next access).
|
|
127
|
+
* Does not remove from persistent vault storage.
|
|
128
|
+
*
|
|
129
|
+
* @param providerName - Provider name to invalidate
|
|
130
|
+
*/
|
|
131
|
+
invalidate(providerName: string): void;
|
|
132
|
+
/**
|
|
133
|
+
* Invalidate all cached credentials for this session.
|
|
134
|
+
*/
|
|
135
|
+
invalidateAll(): void;
|
|
136
|
+
/**
|
|
137
|
+
* List all registered provider names.
|
|
138
|
+
*/
|
|
139
|
+
listProviders(): string[];
|
|
140
|
+
/**
|
|
141
|
+
* List all available credentials (loaded in cache or vault).
|
|
142
|
+
*/
|
|
143
|
+
listAvailable(): Promise<string[]>;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* DI Token for AuthProvidersAccessor
|
|
147
|
+
*
|
|
148
|
+
* Used to resolve the accessor in tool contexts:
|
|
149
|
+
* ```typescript
|
|
150
|
+
* const accessor = this.get(AUTH_PROVIDERS_ACCESSOR);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare const AUTH_PROVIDERS_ACCESSOR: Token<AuthProvidersAccessor>;
|
|
154
|
+
//# sourceMappingURL=auth-providers.accessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-providers.accessor.d.ts","sourceRoot":"","sources":["../../src/vault/auth-providers.accessor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,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I,IAAI,CAAC;IAEtB;;OAEG;IACH,aAAa,IAAI,MAAM,EAAE,CAAC;IAE1B;;OAEG;IACH,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,EAAqD,KAAK,CAAC,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthProvidersAccessorImpl - Implementation of AuthProvidersAccessor
|
|
3
|
+
*
|
|
4
|
+
* Provides runtime access to credential providers in tool contexts.
|
|
5
|
+
* Handles caching, vault storage, lazy loading, and credential refresh.
|
|
6
|
+
*/
|
|
7
|
+
import type { Credential } from '../session';
|
|
8
|
+
import type { CredentialFactoryContext, GetCredentialOptions, ResolvedCredential } from './auth-providers.types';
|
|
9
|
+
import { CredentialCache } from './credential-cache';
|
|
10
|
+
import type { AuthProvidersAccessor } from './auth-providers.accessor';
|
|
11
|
+
import type { AuthProvidersRegistry } from './auth-providers.registry';
|
|
12
|
+
import type { AuthProvidersVault } from './auth-providers.vault';
|
|
13
|
+
import type { LazyCredentialLoader } from './credential-loaders/lazy-loader';
|
|
14
|
+
import type { AuthLogger } from '../common/auth-logger.interface';
|
|
15
|
+
/**
|
|
16
|
+
* AuthProvidersAccessorImpl - Runtime implementation
|
|
17
|
+
*/
|
|
18
|
+
export declare class AuthProvidersAccessorImpl implements AuthProvidersAccessor {
|
|
19
|
+
private readonly registry;
|
|
20
|
+
private readonly vault;
|
|
21
|
+
private readonly cache;
|
|
22
|
+
private readonly loader;
|
|
23
|
+
private readonly context;
|
|
24
|
+
private readonly logger?;
|
|
25
|
+
constructor(registry: AuthProvidersRegistry, vault: AuthProvidersVault, cache: CredentialCache, loader: LazyCredentialLoader, context: CredentialFactoryContext, logger?: AuthLogger | undefined);
|
|
26
|
+
get<T extends Credential = Credential>(providerName: string, options?: GetCredentialOptions): Promise<ResolvedCredential<T> | null>;
|
|
27
|
+
getMany(providerNames: string[], options?: GetCredentialOptions): Promise<Map<string, ResolvedCredential | null>>;
|
|
28
|
+
headers(providerName: string): Promise<Record<string, string>>;
|
|
29
|
+
headersMany(providerNames: string[]): Promise<Record<string, string>>;
|
|
30
|
+
refresh(providerName: string): Promise<ResolvedCredential | null>;
|
|
31
|
+
has(providerName: string): Promise<boolean>;
|
|
32
|
+
isRegistered(providerName: string): boolean;
|
|
33
|
+
invalidate(providerName: string): void;
|
|
34
|
+
invalidateAll(): void;
|
|
35
|
+
listProviders(): string[];
|
|
36
|
+
listAvailable(): Promise<string[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Load credential from vault storage
|
|
39
|
+
*/
|
|
40
|
+
private loadFromVault;
|
|
41
|
+
/**
|
|
42
|
+
* Store credential in vault storage
|
|
43
|
+
*/
|
|
44
|
+
private storeInVault;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a resolved credential is still valid
|
|
47
|
+
*/
|
|
48
|
+
private isValid;
|
|
49
|
+
/**
|
|
50
|
+
* Generate default headers for a credential type
|
|
51
|
+
*/
|
|
52
|
+
private defaultHeaders;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=auth-providers.accessor.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-providers.accessor.impl.d.ts","sourceRoot":"","sources":["../../src/vault/auth-providers.accessor.impl.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,KAAK,EAAE,qBAAqB,EAA4B,MAAM,2BAA2B,CAAC;AACjG,OAAO,KAAK,EAAE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,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAqBjD,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO;IAI3C,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAKtC,aAAa,IAAI,IAAI;IAKrB,aAAa,IAAI,MAAM,EAAE;IAInB,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAYxC;;OAEG;YACW,aAAa;IA8B3B;;OAEG;YACW,YAAY;IAkB1B;;OAEG;IACH,OAAO,CAAC,OAAO;IAYf;;OAEG;IACH,OAAO,CAAC,cAAc;CAmCvB"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthProvidersRegistry - Registry for credential providers
|
|
3
|
+
*
|
|
4
|
+
* Manages registration and lookup of credential providers.
|
|
5
|
+
* Providers are registered at scope initialization and
|
|
6
|
+
* remain available for the lifetime of the scope.
|
|
7
|
+
*/
|
|
8
|
+
import { Token } from '@frontmcp/di';
|
|
9
|
+
import type { Credential } from '../session';
|
|
10
|
+
import type { CredentialProviderConfig, CredentialScope, LoadingStrategy, AuthProvidersVaultOptions } from './auth-providers.types';
|
|
11
|
+
/**
|
|
12
|
+
* Normalized provider config with defaults applied
|
|
13
|
+
*/
|
|
14
|
+
export interface NormalizedProviderConfig<T extends Credential = Credential> extends Required<Pick<CredentialProviderConfig<T>, 'name' | 'scope' | 'loading'>> {
|
|
15
|
+
description?: string;
|
|
16
|
+
cacheTtl: number;
|
|
17
|
+
factory: CredentialProviderConfig<T>['factory'];
|
|
18
|
+
refresh?: CredentialProviderConfig<T>['refresh'];
|
|
19
|
+
toHeaders?: CredentialProviderConfig<T>['toHeaders'];
|
|
20
|
+
metadata?: Record<string, unknown>;
|
|
21
|
+
required: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* AuthProvidersRegistry - Manages credential provider configurations
|
|
25
|
+
*/
|
|
26
|
+
export declare class AuthProvidersRegistry {
|
|
27
|
+
private readonly providers;
|
|
28
|
+
private readonly defaultCacheTtl;
|
|
29
|
+
constructor(options?: AuthProvidersVaultOptions);
|
|
30
|
+
/**
|
|
31
|
+
* Register a credential provider
|
|
32
|
+
*
|
|
33
|
+
* @param config - Provider configuration
|
|
34
|
+
* @throws CredentialProviderAlreadyRegisteredError if provider with same name already registered
|
|
35
|
+
*/
|
|
36
|
+
register<T extends Credential = Credential>(config: CredentialProviderConfig<T>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Unregister a credential provider
|
|
39
|
+
*
|
|
40
|
+
* @param name - Provider name to unregister
|
|
41
|
+
* @returns true if provider was unregistered, false if not found
|
|
42
|
+
*/
|
|
43
|
+
unregister(name: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Get a provider configuration by name
|
|
46
|
+
*
|
|
47
|
+
* @param name - Provider name
|
|
48
|
+
* @returns Provider config or undefined if not found
|
|
49
|
+
*/
|
|
50
|
+
get<T extends Credential = Credential>(name: string): NormalizedProviderConfig<T> | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Check if a provider is registered
|
|
53
|
+
*
|
|
54
|
+
* @param name - Provider name
|
|
55
|
+
* @returns true if provider is registered
|
|
56
|
+
*/
|
|
57
|
+
has(name: string): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Get all registered provider names
|
|
60
|
+
*/
|
|
61
|
+
getNames(): string[];
|
|
62
|
+
/**
|
|
63
|
+
* Get all provider configurations
|
|
64
|
+
*/
|
|
65
|
+
getAll(): NormalizedProviderConfig[];
|
|
66
|
+
/**
|
|
67
|
+
* Get providers by scope
|
|
68
|
+
*
|
|
69
|
+
* @param scope - Credential scope to filter by
|
|
70
|
+
*/
|
|
71
|
+
getByScope(scope: CredentialScope): NormalizedProviderConfig[];
|
|
72
|
+
/**
|
|
73
|
+
* Get providers by loading strategy
|
|
74
|
+
*
|
|
75
|
+
* @param loading - Loading strategy to filter by
|
|
76
|
+
*/
|
|
77
|
+
getByLoading(loading: LoadingStrategy): NormalizedProviderConfig[];
|
|
78
|
+
/**
|
|
79
|
+
* Get providers that are required
|
|
80
|
+
*/
|
|
81
|
+
getRequired(): NormalizedProviderConfig[];
|
|
82
|
+
/**
|
|
83
|
+
* Get providers that should be eagerly loaded
|
|
84
|
+
*/
|
|
85
|
+
getEager(): NormalizedProviderConfig[];
|
|
86
|
+
/**
|
|
87
|
+
* Get providers that should be lazily loaded
|
|
88
|
+
*/
|
|
89
|
+
getLazy(): NormalizedProviderConfig[];
|
|
90
|
+
/**
|
|
91
|
+
* Get the number of registered providers
|
|
92
|
+
*/
|
|
93
|
+
get size(): number;
|
|
94
|
+
/**
|
|
95
|
+
* Check if registry is empty
|
|
96
|
+
*/
|
|
97
|
+
isEmpty(): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Clear all registered providers
|
|
100
|
+
*/
|
|
101
|
+
clear(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Normalize provider config with defaults
|
|
104
|
+
*/
|
|
105
|
+
private normalize;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* DI Token for AuthProvidersRegistry
|
|
109
|
+
*/
|
|
110
|
+
export declare const AUTH_PROVIDERS_REGISTRY: Token<AuthProvidersRegistry>;
|
|
111
|
+
//# sourceMappingURL=auth-providers.registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-providers.registry.d.ts","sourceRoot":"","sources":["../../src/vault/auth-providers.registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,yBAAyB,EAC1B,MAAM,wBAAwB,CAAC;AAEhC;;GAEG;AACH,MAAM,WAAW,wBAAwB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,CACzE,SAAQ,QAAQ,CAA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e,GAAG,wBAAwB,EAAE;IAIlE;;OAEG;IACH,WAAW,IAAI,wBAAwB,EAAE;IAIzC;;OAEG;IACH,QAAQ,IAAI,wBAAwB,EAAE;IAItC;;OAEG;IACH,OAAO,IAAI,wBAAwB,EAAE;IAIrC;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,OAAO,CAAC,SAAS;CAclB;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAqD,KAAK,CAAC,qBAAqB,CAAC,CAAC"}
|
|
@@ -15,9 +15,9 @@ import type { Credential, AuthorizationVault } from '../session';
|
|
|
15
15
|
*/
|
|
16
16
|
export type CredentialScope = 'global' | 'user' | 'session';
|
|
17
17
|
export declare const credentialScopeSchema: z.ZodEnum<{
|
|
18
|
+
session: "session";
|
|
18
19
|
user: "user";
|
|
19
20
|
global: "global";
|
|
20
|
-
session: "session";
|
|
21
21
|
}>;
|
|
22
22
|
/**
|
|
23
23
|
* Loading strategy determines when credentials are acquired.
|
|
@@ -141,9 +141,9 @@ export declare const credentialProviderConfigSchema: z.ZodObject<{
|
|
|
141
141
|
name: z.ZodString;
|
|
142
142
|
description: z.ZodOptional<z.ZodString>;
|
|
143
143
|
scope: z.ZodEnum<{
|
|
144
|
+
session: "session";
|
|
144
145
|
user: "user";
|
|
145
146
|
global: "global";
|
|
146
|
-
session: "session";
|
|
147
147
|
}>;
|
|
148
148
|
loading: z.ZodEnum<{
|
|
149
149
|
lazy: "lazy";
|
|
@@ -227,9 +227,9 @@ export declare const authProvidersVaultOptionsSchema: z.ZodObject<{
|
|
|
227
227
|
name: z.ZodString;
|
|
228
228
|
description: z.ZodOptional<z.ZodString>;
|
|
229
229
|
scope: z.ZodEnum<{
|
|
230
|
+
session: "session";
|
|
230
231
|
user: "user";
|
|
231
232
|
global: "global";
|
|
232
|
-
session: "session";
|
|
233
233
|
}>;
|
|
234
234
|
loading: z.ZodEnum<{
|
|
235
235
|
lazy: "lazy";
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthProvidersVault - Dedicated storage namespace for auth provider credentials
|
|
3
|
+
*
|
|
4
|
+
* Uses the same underlying storage (Redis/Vercel KV) as AuthorizationVault
|
|
5
|
+
* but with a separate namespace to avoid conflicts.
|
|
6
|
+
*/
|
|
7
|
+
import { Token } from '@frontmcp/di';
|
|
8
|
+
import type { Credential, AuthorizationVault, AppCredential } from '../session';
|
|
9
|
+
import type { CredentialScope } from './auth-providers.types';
|
|
10
|
+
import type { AuthLogger } from '../common/auth-logger.interface';
|
|
11
|
+
/**
|
|
12
|
+
* AuthProvidersVault - Storage layer for auth provider credentials
|
|
13
|
+
*/
|
|
14
|
+
export declare class AuthProvidersVault {
|
|
15
|
+
private readonly baseVault;
|
|
16
|
+
private readonly namespace;
|
|
17
|
+
private readonly logger?;
|
|
18
|
+
constructor(baseVault: AuthorizationVault, namespace?: string, logger?: AuthLogger | undefined);
|
|
19
|
+
/**
|
|
20
|
+
* Store a credential in the vault
|
|
21
|
+
*
|
|
22
|
+
* @param sessionId - Current session ID
|
|
23
|
+
* @param providerId - Provider name
|
|
24
|
+
* @param credential - Credential to store
|
|
25
|
+
* @param scope - Credential scope
|
|
26
|
+
* @param userId - User ID (required for user scope)
|
|
27
|
+
*/
|
|
28
|
+
storeCredential<T extends Credential>(sessionId: string, providerId: string, credential: T, scope: CredentialScope, userId?: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Get a credential from the vault
|
|
31
|
+
*
|
|
32
|
+
* @param sessionId - Current session ID
|
|
33
|
+
* @param providerId - Provider name
|
|
34
|
+
* @param scope - Credential scope
|
|
35
|
+
* @param userId - User ID (required for user scope)
|
|
36
|
+
* @returns Credential or null if not found
|
|
37
|
+
*/
|
|
38
|
+
getCredential<T extends Credential>(sessionId: string, providerId: string, scope: CredentialScope, userId?: string): Promise<T | null>;
|
|
39
|
+
/**
|
|
40
|
+
* Remove a credential from the vault
|
|
41
|
+
*
|
|
42
|
+
* @param sessionId - Current session ID
|
|
43
|
+
* @param providerId - Provider name
|
|
44
|
+
* @param scope - Credential scope
|
|
45
|
+
* @param userId - User ID (required for user scope)
|
|
46
|
+
*/
|
|
47
|
+
removeCredential(sessionId: string, providerId: string, scope: CredentialScope, userId?: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Invalidate a credential (mark as invalid without removing)
|
|
50
|
+
*
|
|
51
|
+
* @param sessionId - Current session ID
|
|
52
|
+
* @param providerId - Provider name
|
|
53
|
+
* @param scope - Credential scope
|
|
54
|
+
* @param reason - Reason for invalidation
|
|
55
|
+
* @param userId - User ID (required for user scope)
|
|
56
|
+
*/
|
|
57
|
+
invalidateCredential(sessionId: string, providerId: string, scope: CredentialScope, reason: string, userId?: string): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Update OAuth credential tokens (for refresh)
|
|
60
|
+
*
|
|
61
|
+
* @param sessionId - Current session ID
|
|
62
|
+
* @param providerId - Provider name
|
|
63
|
+
* @param scope - Credential scope
|
|
64
|
+
* @param tokens - New tokens
|
|
65
|
+
* @param userId - User ID (required for user scope)
|
|
66
|
+
*/
|
|
67
|
+
refreshOAuthCredential(sessionId: string, providerId: string, scope: CredentialScope, tokens: {
|
|
68
|
+
accessToken: string;
|
|
69
|
+
refreshToken?: string;
|
|
70
|
+
expiresAt?: number;
|
|
71
|
+
}, userId?: string): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Get all credentials for a session
|
|
74
|
+
*
|
|
75
|
+
* @param sessionId - Current session ID
|
|
76
|
+
* @param scope - Optional scope filter
|
|
77
|
+
* @param userId - User ID (required for user scope)
|
|
78
|
+
*/
|
|
79
|
+
getAllCredentials(sessionId: string, scope?: CredentialScope, userId?: string): Promise<AppCredential[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Build vault key based on scope
|
|
82
|
+
*
|
|
83
|
+
* Key patterns:
|
|
84
|
+
* - global: `authproviders:global`
|
|
85
|
+
* - user: `authproviders:user:{userId}`
|
|
86
|
+
* - session: `authproviders:session:{sessionId}`
|
|
87
|
+
*/
|
|
88
|
+
private buildVaultKey;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* DI Token for AuthProvidersVault
|
|
92
|
+
*/
|
|
93
|
+
export declare const AUTH_PROVIDERS_VAULT: Token<AuthProvidersVault>;
|
|
94
|
+
//# sourceMappingURL=auth-providers.vault.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-providers.vault.d.ts","sourceRoot":"","sources":["../../src/vault/auth-providers.vault.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAGlE;;GAEG;AACH,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAFP,SAAS,EAAE,kBAAkB,EAC7B,SAAS,SAAmB,EAC5B,MAAM,CAAC,EAAE,UAAU,YAAA;IAGtC;;;;;;;;OAQG;IACG,eAAe,CAAC,CAAC,SAAS,UAAU,EACxC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,CAAC,EACb,KAAK,EAAE,eAAe,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAqBhB;;;;;;;;OAQG;IACG,aAAa,CAAC,CAAC,SAAS,UAAU,EACtC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,eAAe,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAkCpB;;;;;;;OAOG;IACG,gBAAgB,CACpB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,eAAe,EACtB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;;;;OAQG;IACG,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;;;;OAQG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,EAC1E,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;;;OAMG;IACG,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAoD9G;;;;;;;OAOG;IACH,OAAO,CAAC,aAAa;CAoBtB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAkD,KAAK,CAAC,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EagerCredentialLoader - Loads credentials at session initialization
|
|
3
|
+
*
|
|
4
|
+
* Used for providers configured with `loading: 'eager'`.
|
|
5
|
+
* Credentials are loaded in parallel at session start.
|
|
6
|
+
*/
|
|
7
|
+
import type { CredentialFactoryContext, ResolvedCredential } from '../auth-providers.types';
|
|
8
|
+
import { CredentialCache } from '../credential-cache';
|
|
9
|
+
import type { AuthProvidersRegistry } from '../auth-providers.registry';
|
|
10
|
+
import type { AuthLogger } from '../../common/auth-logger.interface';
|
|
11
|
+
/**
|
|
12
|
+
* Result of eager loading
|
|
13
|
+
*/
|
|
14
|
+
export interface EagerLoadResult {
|
|
15
|
+
/** Successfully loaded credentials */
|
|
16
|
+
loaded: Map<string, ResolvedCredential>;
|
|
17
|
+
/** Failed provider names with errors */
|
|
18
|
+
failed: Map<string, Error>;
|
|
19
|
+
/** Total loading time in ms */
|
|
20
|
+
duration: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* EagerCredentialLoader - Loads credentials at session initialization
|
|
24
|
+
*/
|
|
25
|
+
export declare class EagerCredentialLoader {
|
|
26
|
+
private readonly registry;
|
|
27
|
+
private readonly cache;
|
|
28
|
+
private readonly logger?;
|
|
29
|
+
constructor(registry: AuthProvidersRegistry, cache: CredentialCache, logger?: AuthLogger | undefined);
|
|
30
|
+
/**
|
|
31
|
+
* Load all eager credentials for a session.
|
|
32
|
+
* Called during session initialization.
|
|
33
|
+
*
|
|
34
|
+
* @param context - Factory context with session/user info
|
|
35
|
+
* @returns Map of provider name to resolved credential
|
|
36
|
+
*/
|
|
37
|
+
loadForSession(context: CredentialFactoryContext): Promise<EagerLoadResult>;
|
|
38
|
+
/**
|
|
39
|
+
* Load a single credential
|
|
40
|
+
*/
|
|
41
|
+
private loadOne;
|
|
42
|
+
/**
|
|
43
|
+
* Wrap credential with resolved metadata
|
|
44
|
+
*/
|
|
45
|
+
private wrapCredential;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=eager-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eager-loader.d.ts","sourceRoot":"","sources":["../../../src/vault/credential-loaders/eager-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE5F,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAA4B,MAAM,4BAA4B,CAAC;AAClG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACxC,wCAAwC;IACxC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC3B,+BAA+B;IAC/B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,qBAAa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAFP,QAAQ,EAAE,qBAAqB,EAC/B,KAAK,EAAE,eAAe,EACtB,MAAM,CAAC,EAAE,UAAU,YAAA;IAGtC;;;;;;OAMG;IACG,cAAc,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;IAoDjF;;OAEG;YACW,OAAO;IAgBrB;;OAEG;IACH,OAAO,CAAC,cAAc;CAcvB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential Loaders - Eager and Lazy credential loading strategies
|
|
3
|
+
*/
|
|
4
|
+
export { EagerCredentialLoader, type EagerLoadResult } from './eager-loader';
|
|
5
|
+
export { LazyCredentialLoader } from './lazy-loader';
|
|
6
|
+
export { extractCredentialExpiry } from '../credential-helpers';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vault/credential-loaders/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LazyCredentialLoader - Loads credentials on first access
|
|
3
|
+
*
|
|
4
|
+
* Used for providers configured with `loading: 'lazy'` (default).
|
|
5
|
+
* Prevents concurrent loads for the same provider (deduplication).
|
|
6
|
+
*/
|
|
7
|
+
import type { Credential } from '../../session';
|
|
8
|
+
import type { CredentialFactoryContext, ResolvedCredential } from '../auth-providers.types';
|
|
9
|
+
import type { NormalizedProviderConfig } from '../auth-providers.registry';
|
|
10
|
+
import type { AuthLogger } from '../../common/auth-logger.interface';
|
|
11
|
+
/**
|
|
12
|
+
* LazyCredentialLoader - Loads credentials on first access
|
|
13
|
+
*/
|
|
14
|
+
export declare class LazyCredentialLoader {
|
|
15
|
+
private readonly logger?;
|
|
16
|
+
/** In-flight loading promises for deduplication */
|
|
17
|
+
private readonly loading;
|
|
18
|
+
constructor(logger?: AuthLogger | undefined);
|
|
19
|
+
/**
|
|
20
|
+
* Load a credential lazily.
|
|
21
|
+
* If already loading, returns the in-flight promise (deduplication).
|
|
22
|
+
*
|
|
23
|
+
* @param config - Provider configuration
|
|
24
|
+
* @param context - Factory context
|
|
25
|
+
* @returns Resolved credential or null
|
|
26
|
+
*/
|
|
27
|
+
load<T extends Credential>(config: NormalizedProviderConfig<T>, context: CredentialFactoryContext): Promise<ResolvedCredential<T> | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Perform the actual credential loading
|
|
30
|
+
*/
|
|
31
|
+
private doLoad;
|
|
32
|
+
/**
|
|
33
|
+
* Refresh a credential using the provider's refresh function or factory
|
|
34
|
+
*
|
|
35
|
+
* @param config - Provider configuration
|
|
36
|
+
* @param context - Factory context with existing credential
|
|
37
|
+
* @returns Refreshed credential or null
|
|
38
|
+
*/
|
|
39
|
+
refresh<T extends Credential>(config: NormalizedProviderConfig<T>, context: CredentialFactoryContext & {
|
|
40
|
+
existingCredential: T;
|
|
41
|
+
}): Promise<ResolvedCredential<T> | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Check if a credential is currently being loaded
|
|
44
|
+
*
|
|
45
|
+
* @param name - Provider name
|
|
46
|
+
* @returns true if loading is in progress
|
|
47
|
+
*/
|
|
48
|
+
isLoading(name: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Cancel all in-flight loads (for cleanup)
|
|
51
|
+
*/
|
|
52
|
+
cancelAll(): void;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=lazy-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-loader.d.ts","sourceRoot":"","sources":["../../../src/vault/credential-loaders/lazy-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE5F,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE;;GAEG;AACH,qBAAa,oBAAoB;IAInB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAHpC,mDAAmD;IACnD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyD;gBAEpD,MAAM,CAAC,EAAE,UAAU,YAAA;IAEhD;;;;;;;OAOG;IACG,IAAI,CAAC,CAAC,SAAS,UAAU,EAC7B,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC,EACnC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAmBxC;;OAEG;YACW,MAAM;IAsCpB;;;;;;OAMG;IACG,OAAO,CAAC,CAAC,SAAS,UAAU,EAChC,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC,EACnC,OAAO,EAAE,wBAAwB,GAAG;QAAE,kBAAkB,EAAE,CAAC,CAAA;KAAE,GAC5D,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAwCxC;;;;;OAKG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACH,SAAS,IAAI,IAAI;CAGlB"}
|
package/vault/index.d.ts
CHANGED
|
@@ -7,4 +7,13 @@ export type { CredentialScope, LoadingStrategy, GetCredentialOptions, ResolvedCr
|
|
|
7
7
|
export { credentialScopeSchema, loadingStrategySchema, getCredentialOptionsSchema, credentialProviderConfigSchema, authProviderMappingSchema, authProvidersVaultOptionsSchema, } from './auth-providers.types';
|
|
8
8
|
export { extractCredentialExpiry } from './credential-helpers';
|
|
9
9
|
export { CredentialCache, type CacheStats } from './credential-cache';
|
|
10
|
+
export type { AuthProvidersAccessor } from './auth-providers.accessor';
|
|
11
|
+
export { AUTH_PROVIDERS_ACCESSOR } from './auth-providers.accessor';
|
|
12
|
+
export { AuthProvidersAccessorImpl } from './auth-providers.accessor.impl';
|
|
13
|
+
export { AuthProvidersRegistry, AUTH_PROVIDERS_REGISTRY } from './auth-providers.registry';
|
|
14
|
+
export type { NormalizedProviderConfig } from './auth-providers.registry';
|
|
15
|
+
export { AuthProvidersVault, AUTH_PROVIDERS_VAULT } from './auth-providers.vault';
|
|
16
|
+
export { EagerCredentialLoader } from './credential-loaders/eager-loader';
|
|
17
|
+
export type { EagerLoadResult } from './credential-loaders/eager-loader';
|
|
18
|
+
export { LazyCredentialLoader } from './credential-loaders/lazy-loader';
|
|
10
19
|
//# sourceMappingURL=index.d.ts.map
|
package/vault/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vault/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,+BAA+B,GAChC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vault/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,YAAY,EACV,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,GAChB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EACzB,+BAA+B,GAChC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGtE,YAAY,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