Skip to content

Commit

Permalink
Merge pull request #966 from tulios/fix-aws-auth-types
Browse files Browse the repository at this point in the history
Fix SaslOptions type for aws specific fields
  • Loading branch information
Nevon authored Nov 19, 2020
2 parents d13acd5 + c8b428d commit 2c55fc1
Showing 1 changed file with 10 additions and 7 deletions.
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

0 comments on commit 2c55fc1

Please sign in to comment.