Skip to content

Commit 0e8a123

Browse files
author
Steven Yuan
committed
feat(experimentalIdentityAndAuth): update HttpAuthScheme and IdentityProviderConfig interfaces
Update `HttpAuthScheme` to use `IdentityProviderConfig` as an abstraction over a client's configuration.
1 parent 697310d commit 0e8a123

File tree

4 files changed

+16
-20
lines changed

4 files changed

+16
-20
lines changed

.changeset/grumpy-turtles-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/experimental-identity-and-auth": patch
3+
---
4+
5+
INTERNAL USE ONLY: Update `HttpAuthScheme` and `IdentityProviderConfig` interfaces

packages/experimental-identity-and-auth/src/HttpAuthScheme.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Identity, IdentityProvider } from "@smithy/types";
22

33
import { HttpSigner } from "./HttpSigner";
4+
import { IdentityProviderConfig } from "./IdentityProviderConfig";
45

56
/**
67
* ID for {@link HttpAuthScheme}
@@ -20,7 +21,7 @@ export interface HttpAuthScheme {
2021
/**
2122
* IdentityProvider corresponding to an HttpAuthScheme.
2223
*/
23-
identityProvider: IdentityProvider<Identity>;
24+
identityProvider: (config: IdentityProviderConfig) => IdentityProvider<Identity> | undefined;
2425
/**
2526
* HttpSigner corresponding to an HttpAuthScheme.
2627
*/
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
import { Identity, IdentityProvider } from "@smithy/types";
22

3-
import { HttpAuthScheme, HttpAuthSchemeId } from "./HttpAuthScheme";
3+
import { HttpAuthSchemeId } from "./HttpAuthScheme";
44

55
/**
66
* Interface to get an IdentityProvider for a specified HttpAuthScheme
77
* @internal
88
*/
9-
export interface IdentityProviderConfiguration {
9+
export interface IdentityProviderConfig {
1010
/**
1111
* Get the IdentityProvider for a specified HttpAuthScheme.
1212
* @param schemeId schemeId of the HttpAuthScheme
1313
* @returns IdentityProvider or undefined if HttpAuthScheme is not found
1414
*/
1515
getIdentityProvider(schemeId: HttpAuthSchemeId): IdentityProvider<Identity> | undefined;
16-
17-
/**
18-
* Gets the configured HttpAuthSchemes.
19-
* @returns all configured HttpAuthSchemes
20-
*/
21-
getAuthSchemes(): Map<HttpAuthSchemeId, HttpAuthScheme>;
2216
}
2317

2418
/**
2519
* Default implementation of IdentityProviderConfiguration
2620
* @internal
2721
*/
28-
export class DefaultIdentityProviderConfiguration implements IdentityProviderConfiguration {
29-
private authSchemes: Map<HttpAuthSchemeId, HttpAuthScheme> = new Map();
22+
export class DefaultIdentityProviderConfig implements IdentityProviderConfig {
23+
private authSchemes: Map<HttpAuthSchemeId, IdentityProvider<Identity>> = new Map();
3024

3125
/**
3226
* Creates an IdentityProviderConfiguration with a list of HttpAuthSchemes.
@@ -35,17 +29,13 @@ export class DefaultIdentityProviderConfiguration implements IdentityProviderCon
3529
* HttpAuthScheme later in the list will have priority.
3630
* @param authSchemes auth schemes to configure
3731
*/
38-
constructor(authSchemes: HttpAuthScheme[]) {
39-
for (const authScheme of authSchemes) {
40-
this.authSchemes.set(authScheme.schemeId, authScheme);
32+
constructor(config: Record<HttpAuthSchemeId, IdentityProvider<Identity>>) {
33+
for (const [key, value] of Object.entries(config)) {
34+
this.authSchemes.set(key, value);
4135
}
4236
}
4337

4438
public getIdentityProvider(schemeId: HttpAuthSchemeId): IdentityProvider<Identity> | undefined {
45-
return this.authSchemes.get(schemeId)?.identityProvider;
46-
}
47-
48-
public getAuthSchemes(): Map<HttpAuthSchemeId, HttpAuthScheme> {
49-
return this.authSchemes;
39+
return this.authSchemes.get(schemeId);
5040
}
5141
}

packages/experimental-identity-and-auth/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export * from "./IdentityProviderConfiguration";
21
export * from "./HttpAuthScheme";
32
export * from "./HttpSigner";
3+
export * from "./IdentityProviderConfig";
44
export * from "./SigV4Signer";
55
export * from "./apiKeyIdentity";
66
export * from "./httpApiKeyAuth";

0 commit comments

Comments
 (0)