Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SaslOptions type for aws specific fields #966

Merged
merged 1 commit into from
Nov 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,22 @@ export interface ISocketFactoryArgs {

export type ISocketFactory = (args: ISocketFactoryArgs) => net.Socket

export type SASLMechanism = 'plain' | 'scram-sha-256' | 'scram-sha-512' | 'aws' | 'oauthbearer'

export interface OauthbearerProviderResponse {
value: string
}

export interface SASLOptions {
mechanism: SASLMechanism
username?: string
password?: string
oauthBearerProvider?: () => Promise<OauthbearerProviderResponse>
type SASLMechanismOptionsMap = {
'plain': { username: string, password: string },
'scram-sha-256': { username: string, password: string },
'scram-sha-512': { username: string, password: string },
'aws': { authorizationIdentity: string, accessKeyId: string, secretAccessKey: string, sessionToken?: string },
'oauthbearer': { oauthBearerProvider: () => Promise<OauthbearerProviderResponse> }
}

export type SASLMechanism = keyof SASLMechanismOptionsMap
type SASLMechanismOptions<T> = T extends SASLMechanism ? { mechanism: T } & SASLMechanismOptionsMap[T] : never
export type SASLOptions = SASLMechanismOptions<SASLMechanism>

export interface ProducerConfig {
createPartitioner?: ICustomPartitioner
retry?: RetryOptions
Expand Down