-
Notifications
You must be signed in to change notification settings - Fork 578
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(codegen): move eventstream services to id-auth sra (#6340)
- Loading branch information
Showing
24 changed files
with
814 additions
and
90 deletions.
There are no files selected for viewing
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
72 changes: 72 additions & 0 deletions
72
clients/client-lex-runtime-v2/src/auth/httpAuthExtensionConfiguration.ts
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,72 @@ | ||
// smithy-typescript generated code | ||
import { AwsCredentialIdentity, AwsCredentialIdentityProvider, HttpAuthScheme } from "@smithy/types"; | ||
|
||
import { LexRuntimeV2HttpAuthSchemeProvider } from "./httpAuthSchemeProvider"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface HttpAuthExtensionConfiguration { | ||
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void; | ||
httpAuthSchemes(): HttpAuthScheme[]; | ||
setHttpAuthSchemeProvider(httpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider): void; | ||
httpAuthSchemeProvider(): LexRuntimeV2HttpAuthSchemeProvider; | ||
setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void; | ||
credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export type HttpAuthRuntimeConfig = Partial<{ | ||
httpAuthSchemes: HttpAuthScheme[]; | ||
httpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider; | ||
credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider; | ||
}>; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const getHttpAuthExtensionConfiguration = ( | ||
runtimeConfig: HttpAuthRuntimeConfig | ||
): HttpAuthExtensionConfiguration => { | ||
const _httpAuthSchemes = runtimeConfig.httpAuthSchemes!; | ||
let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider!; | ||
let _credentials = runtimeConfig.credentials; | ||
return { | ||
setHttpAuthScheme(httpAuthScheme: HttpAuthScheme): void { | ||
const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId); | ||
if (index === -1) { | ||
_httpAuthSchemes.push(httpAuthScheme); | ||
} else { | ||
_httpAuthSchemes.splice(index, 1, httpAuthScheme); | ||
} | ||
}, | ||
httpAuthSchemes(): HttpAuthScheme[] { | ||
return _httpAuthSchemes; | ||
}, | ||
setHttpAuthSchemeProvider(httpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider): void { | ||
_httpAuthSchemeProvider = httpAuthSchemeProvider; | ||
}, | ||
httpAuthSchemeProvider(): LexRuntimeV2HttpAuthSchemeProvider { | ||
return _httpAuthSchemeProvider; | ||
}, | ||
setCredentials(credentials: AwsCredentialIdentity | AwsCredentialIdentityProvider): void { | ||
_credentials = credentials; | ||
}, | ||
credentials(): AwsCredentialIdentity | AwsCredentialIdentityProvider | undefined { | ||
return _credentials; | ||
}, | ||
}; | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const resolveHttpAuthRuntimeConfig = (config: HttpAuthExtensionConfiguration): HttpAuthRuntimeConfig => { | ||
return { | ||
httpAuthSchemes: config.httpAuthSchemes(), | ||
httpAuthSchemeProvider: config.httpAuthSchemeProvider(), | ||
credentials: config.credentials(), | ||
}; | ||
}; |
138 changes: 138 additions & 0 deletions
138
clients/client-lex-runtime-v2/src/auth/httpAuthSchemeProvider.ts
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,138 @@ | ||
// smithy-typescript generated code | ||
import { | ||
AwsSdkSigV4AuthInputConfig, | ||
AwsSdkSigV4AuthResolvedConfig, | ||
AwsSdkSigV4PreviouslyResolved, | ||
resolveAwsSdkSigV4Config, | ||
} from "@aws-sdk/core"; | ||
import { | ||
HandlerExecutionContext, | ||
HttpAuthOption, | ||
HttpAuthScheme, | ||
HttpAuthSchemeParameters, | ||
HttpAuthSchemeParametersProvider, | ||
HttpAuthSchemeProvider, | ||
} from "@smithy/types"; | ||
import { getSmithyContext, normalizeProvider } from "@smithy/util-middleware"; | ||
|
||
import { LexRuntimeV2ClientConfig, LexRuntimeV2ClientResolvedConfig } from "../LexRuntimeV2Client"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface LexRuntimeV2HttpAuthSchemeParameters extends HttpAuthSchemeParameters { | ||
region?: string; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface LexRuntimeV2HttpAuthSchemeParametersProvider | ||
extends HttpAuthSchemeParametersProvider< | ||
LexRuntimeV2ClientResolvedConfig, | ||
HandlerExecutionContext, | ||
LexRuntimeV2HttpAuthSchemeParameters, | ||
object | ||
> {} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const defaultLexRuntimeV2HttpAuthSchemeParametersProvider = async ( | ||
config: LexRuntimeV2ClientResolvedConfig, | ||
context: HandlerExecutionContext, | ||
input: object | ||
): Promise<LexRuntimeV2HttpAuthSchemeParameters> => { | ||
return { | ||
operation: getSmithyContext(context).operation as string, | ||
region: | ||
(await normalizeProvider(config.region)()) || | ||
(() => { | ||
throw new Error("expected `region` to be configured for `aws.auth#sigv4`"); | ||
})(), | ||
}; | ||
}; | ||
|
||
function createAwsAuthSigv4HttpAuthOption(authParameters: LexRuntimeV2HttpAuthSchemeParameters): HttpAuthOption { | ||
return { | ||
schemeId: "aws.auth#sigv4", | ||
signingProperties: { | ||
name: "lex", | ||
region: authParameters.region, | ||
}, | ||
propertiesExtractor: (config: Partial<LexRuntimeV2ClientConfig>, context) => ({ | ||
/** | ||
* @internal | ||
*/ | ||
signingProperties: { | ||
config, | ||
context, | ||
}, | ||
}), | ||
}; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface LexRuntimeV2HttpAuthSchemeProvider | ||
extends HttpAuthSchemeProvider<LexRuntimeV2HttpAuthSchemeParameters> {} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const defaultLexRuntimeV2HttpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider = (authParameters) => { | ||
const options: HttpAuthOption[] = []; | ||
switch (authParameters.operation) { | ||
default: { | ||
options.push(createAwsAuthSigv4HttpAuthOption(authParameters)); | ||
} | ||
} | ||
return options; | ||
}; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface HttpAuthSchemeInputConfig extends AwsSdkSigV4AuthInputConfig { | ||
/** | ||
* Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme. | ||
* @internal | ||
*/ | ||
httpAuthSchemes?: HttpAuthScheme[]; | ||
|
||
/** | ||
* Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use. | ||
* @internal | ||
*/ | ||
httpAuthSchemeProvider?: LexRuntimeV2HttpAuthSchemeProvider; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export interface HttpAuthSchemeResolvedConfig extends AwsSdkSigV4AuthResolvedConfig { | ||
/** | ||
* Configuration of HttpAuthSchemes for a client which provides default identity providers and signers per auth scheme. | ||
* @internal | ||
*/ | ||
readonly httpAuthSchemes: HttpAuthScheme[]; | ||
|
||
/** | ||
* Configuration of an HttpAuthSchemeProvider for a client which resolves which HttpAuthScheme to use. | ||
* @internal | ||
*/ | ||
readonly httpAuthSchemeProvider: LexRuntimeV2HttpAuthSchemeProvider; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const resolveHttpAuthSchemeConfig = <T>( | ||
config: T & HttpAuthSchemeInputConfig & AwsSdkSigV4PreviouslyResolved | ||
): T & HttpAuthSchemeResolvedConfig => { | ||
const config_0 = resolveAwsSdkSigV4Config(config); | ||
return { | ||
...config_0, | ||
} as T & HttpAuthSchemeResolvedConfig; | ||
}; |
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
Oops, something went wrong.