|
6 | 6 | package software.amazon.smithy.aws.typescript.codegen.auth.http.integration;
|
7 | 7 |
|
8 | 8 | import static software.amazon.smithy.aws.typescript.codegen.AwsTraitsUtils.isAwsService;
|
| 9 | +import static software.amazon.smithy.aws.typescript.codegen.AwsTraitsUtils.isSigV4Service; |
9 | 10 |
|
10 | 11 | import java.util.List;
|
| 12 | +import software.amazon.smithy.aws.traits.auth.SigV4Trait; |
11 | 13 | import software.amazon.smithy.aws.typescript.codegen.AwsDependency;
|
12 | 14 | import software.amazon.smithy.model.Model;
|
13 | 15 | import software.amazon.smithy.model.shapes.ServiceShape;
|
@@ -56,7 +58,19 @@ public void customizeSupportedHttpAuthSchemes(
|
56 | 58 | .addImport("nodeProvider", null, AwsDependency.TOKEN_PROVIDERS)
|
57 | 59 | .addImport("FromSsoInit", null, AwsDependency.TOKEN_PROVIDERS)
|
58 | 60 | .openBlock("async (idProps) => {", "}", () -> {
|
59 |
| - w.write("return await nodeProvider(idProps as FromSsoInit)(idProps);"); |
| 61 | + String defaultProviderReturn = "return await nodeProvider(idProps as FromSsoInit)(idProps);"; |
| 62 | + if (useFromEnvSigningName(service)) { |
| 63 | + w.openBlock("try {", "}", () -> { |
| 64 | + w.addImport("fromEnvSigningName", null, AwsDependency.TOKEN_PROVIDERS); |
| 65 | + w.write("return await fromEnvSigningName({ signingName: $S })();", |
| 66 | + service.expectTrait(SigV4Trait.class).getName()); |
| 67 | + }); |
| 68 | + w.openBlock("catch (error) {", "}", () -> { |
| 69 | + w.write(defaultProviderReturn); |
| 70 | + }); |
| 71 | + } else { |
| 72 | + w.write(defaultProviderReturn); |
| 73 | + } |
60 | 74 | }))
|
61 | 75 | // Add identityProperties for backward compatibility of the `nodeProvider` default provider.
|
62 | 76 | // If adding new properties that need to be passed into `nodeProvider`, make sure
|
@@ -88,4 +102,11 @@ public void customizeSupportedHttpAuthSchemes(
|
88 | 102 | supportedHttpAuthSchemesIndex.putHttpAuthScheme(authScheme.getSchemeId(), authScheme);
|
89 | 103 | }
|
90 | 104 | }
|
| 105 | + |
| 106 | + private static boolean useFromEnvSigningName(ServiceShape service) { |
| 107 | + if (isSigV4Service(service)) { |
| 108 | + return service.expectTrait(SigV4Trait.class).getName().equals("bedrock"); |
| 109 | + } |
| 110 | + return false; |
| 111 | + } |
91 | 112 | }
|
0 commit comments