Skip to content

Commit c6251b7

Browse files
Steven Yuansyall
authored andcommitted
feat(experimentalIdentityAndAuth): update HttpAuthScheme and IdentityProviderConfig interfaces
Update `HttpAuthScheme` to use `IdentityProviderConfig` as an abstraction over a client's configuration.
1 parent a03026e commit c6251b7

File tree

5 files changed

+48
-54
lines changed

5 files changed

+48
-54
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: 3 additions & 2 deletions
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}
@@ -18,9 +19,9 @@ export interface HttpAuthScheme {
1819
*/
1920
schemeId: HttpAuthSchemeId;
2021
/**
21-
* IdentityProvider corresponding to an HttpAuthScheme.
22+
* Gets the 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
*/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { Identity, IdentityProvider } from "@smithy/types";
2+
3+
import { HttpAuthSchemeId } from "./HttpAuthScheme";
4+
5+
/**
6+
* Interface to get an IdentityProvider for a specified HttpAuthScheme
7+
* @internal
8+
*/
9+
export interface IdentityProviderConfig {
10+
/**
11+
* Get the IdentityProvider for a specified HttpAuthScheme.
12+
* @param schemeId schemeId of the HttpAuthScheme
13+
* @returns IdentityProvider or undefined if HttpAuthScheme is not found
14+
*/
15+
getIdentityProvider(schemeId: HttpAuthSchemeId): IdentityProvider<Identity> | undefined;
16+
}
17+
18+
/**
19+
* Default implementation of IddentityProviderConfig
20+
* @internal
21+
*/
22+
export class DefaultIdentityProviderConfig implements IdentityProviderConfig {
23+
private authSchemes: Map<HttpAuthSchemeId, IdentityProvider<Identity>> = new Map();
24+
25+
/**
26+
* Creates an IdentityProviderConfig with a record of scheme IDs to identity providers.
27+
*
28+
* @param config scheme IDs and identity providers to configure
29+
*/
30+
constructor(config: Record<HttpAuthSchemeId, IdentityProvider<Identity>>) {
31+
for (const [key, value] of Object.entries(config)) {
32+
this.authSchemes.set(key, value);
33+
}
34+
}
35+
36+
public getIdentityProvider(schemeId: HttpAuthSchemeId): IdentityProvider<Identity> | undefined {
37+
return this.authSchemes.get(schemeId);
38+
}
39+
}

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

Lines changed: 0 additions & 51 deletions
This file was deleted.

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)