-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces TokenManager and supporting classes to handle token acquisition, automatic refresh, and updates via identity providers. This foundation enables consistent authentication token management across different identity provider implementations. Key additions: - Add TokenManager to obtain and maintain auth tokens from identity providers with automated refresh scheduling based on TTL and configurable thresholds - Add IdentityProvider interface for token acquisition from auth providers - Implement Token class for managing token state and TTL tracking - Include configurable retry mechanism with exponential backoff and jitter - Add comprehensive test suite covering refresh cycles and error handling This change establishes the core infrastructure needed for reliable token lifecycle management across different authentication providers.
- Loading branch information
1 parent
a0c324b
commit e7d6f5b
Showing
13 changed files
with
1,156 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export { TokenManager, TokenManagerConfig, TokenStreamListener, RetryPolicy, IDPError } from './lib/token-manager'; | ||
export { | ||
CredentialsProvider, | ||
StreamingCredentialsProvider, | ||
UnableToObtainNewCredentialsError, | ||
CredentialsError, | ||
StreamingCredentialsListener, | ||
AsyncCredentialsProvider, | ||
ReAuthenticationError, | ||
BasicAuth | ||
} from './lib/credentials-provider'; | ||
export { Token } from './lib/token'; | ||
export { IdentityProvider, TokenResponse } from './lib/identity-provider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* An identity provider is responsible for providing a token that can be used to authenticate with a service. | ||
*/ | ||
|
||
/** | ||
* The response from an identity provider when requesting a token. | ||
* | ||
* note: "native" refers to the type of the token that the actual identity provider library is using. | ||
* | ||
* @type T The type of the native idp token. | ||
* @property token The token. | ||
* @property ttlMs The time-to-live of the token in epoch milliseconds extracted from the native token in local time. | ||
*/ | ||
export type TokenResponse<T> = { token: T, ttlMs: number }; | ||
|
||
export interface IdentityProvider<T> { | ||
/** | ||
* Request a token from the identity provider. | ||
* @returns A promise that resolves to an object containing the token and the time-to-live in epoch milliseconds. | ||
*/ | ||
requestToken(): Promise<TokenResponse<T>>; | ||
} |
Oops, something went wrong.