Skip to content

Commit 3d4c847

Browse files
author
Steven Yuan
committed
chore(codegen): update smithy-typescript commit
1 parent 0a9a162 commit 3d4c847

File tree

8 files changed

+102
-10
lines changed

8 files changed

+102
-10
lines changed

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AddBuiltinPlugins.java

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public List<RuntimeClientPlugin> getClientPlugins() {
5050
RuntimeClientPlugin.builder()
5151
.withConventions(TypeScriptDependency.CONFIG_RESOLVER.dependency, "Region", HAS_CONFIG)
5252
.servicePredicate((m, s) -> isAwsService(s) || isSigV4Service(s))
53-
.settingsPredicate((m, s, settings) -> !settings.getExperimentalIdentityAndAuth())
5453
.build(),
5554
// Only one of Endpoints or CustomEndpoints should be used
5655
RuntimeClientPlugin.builder()

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/AwsTraitsUtils.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@
2828
* Utility methods related to AWS traits.
2929
*/
3030
@SmithyInternalApi
31-
final class AwsTraitsUtils {
31+
public final class AwsTraitsUtils {
3232

3333
private AwsTraitsUtils() {}
3434

3535
static boolean isAwsService(TypeScriptSettings settings, Model model) {
3636
return isAwsService(settings.getService(model));
3737
}
3838

39-
static boolean isAwsService(ServiceShape serviceShape) {
39+
public static boolean isAwsService(ServiceShape serviceShape) {
4040
return serviceShape.hasTrait(ServiceTrait.class);
4141
}
4242

4343
static boolean isSigV4Service(TypeScriptSettings settings, Model model) {
4444
return isSigV4Service(settings.getService(model));
4545
}
4646

47-
static boolean isSigV4Service(ServiceShape serviceShape) {
47+
public static boolean isSigV4Service(ServiceShape serviceShape) {
4848
return serviceShape.hasTrait(SigV4Trait.class);
4949
}
5050

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package software.amazon.smithy.aws.typescript.codegen.auth.http.integration;
7+
8+
import static software.amazon.smithy.aws.typescript.codegen.AwsTraitsUtils.isAwsService;
9+
import static software.amazon.smithy.aws.typescript.codegen.AwsTraitsUtils.isSigV4Service;
10+
11+
import java.util.logging.Logger;
12+
import software.amazon.smithy.aws.traits.ServiceTrait;
13+
import software.amazon.smithy.aws.traits.auth.SigV4Trait;
14+
import software.amazon.smithy.aws.typescript.codegen.AddAwsAuthPlugin;
15+
import software.amazon.smithy.codegen.core.SymbolProvider;
16+
import software.amazon.smithy.model.Model;
17+
import software.amazon.smithy.model.shapes.ServiceShape;
18+
import software.amazon.smithy.typescript.codegen.TypeScriptSettings;
19+
import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
20+
import software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration;
21+
import software.amazon.smithy.utils.SmithyInternalApi;
22+
23+
/**
24+
* Configure clients with Default AWS Signing Name.
25+
*
26+
* This is the experimental behavior for `experimentalIdentityAndAuth`.
27+
*/
28+
@SmithyInternalApi
29+
public final class AddAwsDefaultSigningName implements TypeScriptIntegration {
30+
private static final Logger LOGGER = Logger.getLogger(AddAwsAuthPlugin.class.getName());
31+
32+
/**
33+
* Integration should only be used if `experimentalIdentityAndAuth` flag is true.
34+
*/
35+
@Override
36+
public boolean matchesSettings(TypeScriptSettings settings) {
37+
return settings.getExperimentalIdentityAndAuth();
38+
}
39+
40+
@Override
41+
public void addConfigInterfaceFields(
42+
TypeScriptSettings settings,
43+
Model model,
44+
SymbolProvider symbolProvider,
45+
TypeScriptWriter writer
46+
) {
47+
ServiceShape service = settings.getService(model);
48+
// Do nothing if service doesn't use sigv4 and is not an AWS service
49+
if (!isSigV4Service(service) && !isAwsService(service)) {
50+
return;
51+
}
52+
53+
// Write config field if service uses sigv4 and is not an AWS service
54+
if (isSigV4Service(service) && !isAwsService(service)) {
55+
writer
56+
.writeDocs("The service name to use as the signing service for AWS Auth\n@internal")
57+
.write("signingName?: string;\n");
58+
}
59+
60+
// Set default name setting for service based on: SigV4 first, then the AWS Service trait
61+
try {
62+
settings.setDefaultSigningName(
63+
service.getTrait(SigV4Trait.class)
64+
.map(SigV4Trait::getName)
65+
.orElseGet(() -> service.expectTrait(ServiceTrait.class).getArnNamespace())
66+
);
67+
} catch (Exception e) {
68+
LOGGER.warning("Unable to set service default signing name. A SigV4 or Service trait is needed.");
69+
}
70+
}
71+
72+
}

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/auth/http/integration/AwsCustomizeHttpBearerTokenAuthPlugin.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,18 @@ public void customizeSupportedHttpAuthSchemes(SupportedHttpAuthSchemesIndex supp
5151
.putDefaultIdentityProvider(LanguageTarget.NODE, w -> {
5252
w.addDependency(AwsDependency.TOKEN_PROVIDERS);
5353
w.addImport("nodeProvider", null, AwsDependency.TOKEN_PROVIDERS);
54-
w.write("nodeProvider");
54+
w.write("async (idProps) => await nodeProvider(idProps?.__config || {})(idProps)");
5555
})
56+
// Add __config as an identityProperty for backward compatibility of the `nodeProvider` default provider
57+
.propertiesExtractor(s -> w -> w.write("""
58+
(__config, context) => ({
59+
/**
60+
* @internal
61+
*/
62+
identityProperties: {
63+
__config,
64+
},
65+
}),"""))
5666
.build();
5767
supportedHttpAuthSchemesIndex.putHttpAuthScheme(authScheme.getSchemeId(), authScheme);
5868
}

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/auth/http/integration/AwsCustomizeSigv4AuthPlugin.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,20 @@ public void customizeSupportedHttpAuthSchemes(SupportedHttpAuthSchemesIndex supp
5555
w.addDependency(AwsDependency.CREDENTIAL_PROVIDER_NODE);
5656
w.addImport("defaultProvider", "credentialDefaultProvider",
5757
AwsDependency.CREDENTIAL_PROVIDER_NODE);
58-
w.write("decorateDefaultCredentialProvider(credentialDefaultProvider)");
58+
w.write("""
59+
async (idProps) => await \
60+
decorateDefaultCredentialProvider(credentialDefaultProvider)(idProps?.__config || {})()")""");
5961
})
62+
// Add __config as an identityProperty for backward compatibility of `credentialDefaultProvider`
63+
.propertiesExtractor(s -> w -> w.write("""
64+
(__config, context) => ({
65+
/**
66+
* @internal
67+
*/
68+
identityProperties: {
69+
__config,
70+
},
71+
}),"""))
6072
.build();
6173
supportedHttpAuthSchemesIndex.putHttpAuthScheme(authScheme.getSchemeId(), authScheme);
6274
}

codegen/smithy-aws-typescript-codegen/src/main/resources/META-INF/services/software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration

+1
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@ software.amazon.smithy.aws.typescript.codegen.AddHttpChecksumDependency
2626
software.amazon.smithy.aws.typescript.codegen.AddEventBridgePlugin
2727
software.amazon.smithy.aws.typescript.codegen.auth.http.integration.AwsCustomizeHttpBearerTokenAuthPlugin
2828
software.amazon.smithy.aws.typescript.codegen.auth.http.integration.AwsCustomizeSigv4AuthPlugin
29+
software.amazon.smithy.aws.typescript.codegen.auth.http.integration.AddAwsDefaultSigningName

packages/middleware-token/src/middleware-token.integ.spec.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ describe("middleware-token", () => {
1212
},
1313
});
1414
requireRequestsFrom(client).toMatch({
15-
headers: {
16-
authorization: /Bearer my-token/,
17-
},
15+
headers: new Map([[/authorization/i, /Bearer my-token/]]),
1816
});
1917
await client.getUserDetails({
2018
id: "my-id",

scripts/generate-clients/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Update this commit when taking up new changes from smithy-typescript.
22
module.exports = {
33
// Use full commit hash as we explicitly fetch it.
4-
SMITHY_TS_COMMIT: "7de91ee308862ad62ed95fe9222f239221fa5a90",
4+
SMITHY_TS_COMMIT: "b4ff4377ebaf5f51b89e6e98cdbb4b205f69594b",
55
};

0 commit comments

Comments
 (0)