Skip to content

Commit 9e5c5ac

Browse files
authored
chore: enable explicit API for runtime components (#676)
1 parent c43ea90 commit 9e5c5ac

File tree

168 files changed

+1443
-1404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+1443
-1404
lines changed

runtime/auth/aws-signing-common/common/src/aws/smithy/kotlin/runtime/auth/awssigning/AwsSigner.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import aws.smithy.kotlin.runtime.http.request.HttpRequest
99
/**
1010
* A component capable of signing requests and request chunks for AWS APIs.
1111
*/
12-
interface AwsSigner {
12+
public interface AwsSigner {
1313
/**
1414
* Signs an HTTP request according to the supplied signing configuration
1515
* @param request The request to sign
1616
* @param config The signing configuration
1717
* @return The signed request
1818
*/
19-
suspend fun sign(request: HttpRequest, config: AwsSigningConfig): AwsSigningResult<HttpRequest>
19+
public suspend fun sign(request: HttpRequest, config: AwsSigningConfig): AwsSigningResult<HttpRequest>
2020

2121
/**
2222
* Signs a body chunk according to the supplied signing configuration
@@ -26,7 +26,7 @@ interface AwsSigner {
2626
* @param config The signing configuration
2727
* @return The signing result, which provides access to all signing-related result properties
2828
*/
29-
suspend fun signChunk(
29+
public suspend fun signChunk(
3030
chunkBody: ByteArray,
3131
prevSignature: ByteArray,
3232
config: AwsSigningConfig,

runtime/auth/aws-signing-common/common/src/aws/smithy/kotlin/runtime/auth/awssigning/AwsSigningAttributes.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,54 @@ import aws.smithy.kotlin.runtime.util.AttributeKey
1212
/**
1313
* [ClientOption] instances related to signing.
1414
*/
15-
object AwsSigningAttributes {
15+
public object AwsSigningAttributes {
1616
/**
1717
* The signer implementation to use
1818
*/
19-
val Signer: ClientOption<AwsSigner> = ClientOption("Signer")
19+
public val Signer: ClientOption<AwsSigner> = ClientOption("Signer")
2020

2121
/**
2222
* AWS region to be used for signing the request
2323
*/
24-
val SigningRegion: ClientOption<String> = ClientOption("AwsSigningRegion")
24+
public val SigningRegion: ClientOption<String> = ClientOption("AwsSigningRegion")
2525

2626
/**
2727
* The signature version 4 service signing name to use in the credential scope when signing requests.
2828
* See: https://docs.aws.amazon.com/general/latest/gr/sigv4_elements.html
2929
*/
30-
val SigningService: ClientOption<String> = ClientOption("AwsSigningService")
30+
public val SigningService: ClientOption<String> = ClientOption("AwsSigningService")
3131

3232
/**
3333
* Override the date to complete the signing process with. Defaults to current time when not specified.
3434
*
3535
* **Note**: This is an advanced configuration option that does not normally need to be set manually.
3636
*/
37-
val SigningDate: ClientOption<Instant> = ClientOption("SigningDate")
37+
public val SigningDate: ClientOption<Instant> = ClientOption("SigningDate")
3838

3939
/**
4040
* The [CredentialsProvider] to complete the signing process with. Defaults to the provider configured
4141
* on the service client.
4242
*
4343
* **Note**: This is an advanced configuration option that does not normally need to be set manually.
4444
*/
45-
val CredentialsProvider: ClientOption<CredentialsProvider> = ClientOption("CredentialsProvider")
45+
public val CredentialsProvider: ClientOption<CredentialsProvider> = ClientOption("CredentialsProvider")
4646

4747
/**
4848
* The specification for determining the hash value for the request.
4949
*
5050
* **Note**: This is an advanced configuration option that does not normally need to be set manually.
5151
*/
52-
val HashSpecification: ClientOption<HashSpecification> = ClientOption("HashSpecification")
52+
public val HashSpecification: ClientOption<HashSpecification> = ClientOption("HashSpecification")
5353

5454
/**
5555
* The signed body header type.
5656
*
5757
* **Note**: This is an advanced configuration option that does not normally need to be set manually.
5858
*/
59-
val SignedBodyHeader: ClientOption<AwsSignedBodyHeader> = ClientOption("SignedBodyHeader")
59+
public val SignedBodyHeader: ClientOption<AwsSignedBodyHeader> = ClientOption("SignedBodyHeader")
6060

6161
/**
6262
* The signature of the HTTP request. This will only exist after the request has been signed.
6363
*/
64-
val RequestSignature: AttributeKey<ByteArray> = AttributeKey("AWS_HTTP_SIGNATURE")
64+
public val RequestSignature: AttributeKey<ByteArray> = AttributeKey("AWS_HTTP_SIGNATURE")
6565
}

runtime/auth/aws-signing-common/common/src/aws/smithy/kotlin/runtime/auth/awssigning/AwsSigningConfig.kt

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProvider
88
import aws.smithy.kotlin.runtime.time.Instant
99
import kotlin.time.Duration
1010

11-
typealias ShouldSignHeaderPredicate = (String) -> Boolean
11+
public typealias ShouldSignHeaderPredicate = (String) -> Boolean
1212

1313
/**
1414
* Defines the AWS signature version to use
1515
*/
16-
enum class AwsSigningAlgorithm {
16+
public enum class AwsSigningAlgorithm {
1717
/**
1818
* AWS Signature Version 4
1919
* see: https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
@@ -29,7 +29,7 @@ enum class AwsSigningAlgorithm {
2929
/**
3030
* Defines the type of signature to compute
3131
*/
32-
enum class AwsSignatureType {
32+
public enum class AwsSignatureType {
3333
/**
3434
* A signature for a full http request should be computed and applied via headers
3535
*/
@@ -51,7 +51,7 @@ enum class AwsSignatureType {
5151
HTTP_REQUEST_EVENT,
5252
}
5353

54-
enum class AwsSignedBodyHeader {
54+
public enum class AwsSignedBodyHeader {
5555
/**
5656
* Do not add a header.
5757
*/
@@ -66,26 +66,26 @@ enum class AwsSignedBodyHeader {
6666
/**
6767
* The configuration for an individual signing operation.
6868
*/
69-
class AwsSigningConfig(builder: Builder) {
70-
companion object {
71-
inline operator fun invoke(block: Builder.() -> Unit): AwsSigningConfig = Builder().apply(block).build()
69+
public class AwsSigningConfig(builder: Builder) {
70+
public companion object {
71+
public inline operator fun invoke(block: Builder.() -> Unit): AwsSigningConfig = Builder().apply(block).build()
7272
}
7373

7474
/**
7575
* The region for which requests will be signed.
7676
*/
77-
val region: String = requireNotNull(builder.region) { "Signing config must specify a region" }
77+
public val region: String = requireNotNull(builder.region) { "Signing config must specify a region" }
7878

7979
/**
8080
* The name of service for which requests will be signed.
8181
*/
82-
val service: String = requireNotNull(builder.service) { "Signing config must specify a service" }
82+
public val service: String = requireNotNull(builder.service) { "Signing config must specify a service" }
8383

8484
/**
8585
* Indicates the signing date/timestamp to use for the signature. Defaults to the current date at config
8686
* construction time.
8787
*/
88-
val signingDate: Instant = builder.signingDate ?: Instant.now()
88+
public val signingDate: Instant = builder.signingDate ?: Instant.now()
8989

9090
/**
9191
* A predicate to control which headers are a part of the canonical request. Note that skipping auth-required
@@ -97,29 +97,29 @@ class AwsSigningConfig(builder: Builder) {
9797
*
9898
* The default predicate is to not reject signing any headers (i.e., `_ -> true`).
9999
*/
100-
val shouldSignHeader: ShouldSignHeaderPredicate = builder.shouldSignHeader
100+
public val shouldSignHeader: ShouldSignHeaderPredicate = builder.shouldSignHeader
101101

102102
/**
103103
* The algorithm to use when signing requests.
104104
*/
105-
val algorithm: AwsSigningAlgorithm = builder.algorithm
105+
public val algorithm: AwsSigningAlgorithm = builder.algorithm
106106

107107
/**
108108
* Indicates what type of signature to compute.
109109
*/
110-
val signatureType: AwsSignatureType = builder.signatureType
110+
public val signatureType: AwsSignatureType = builder.signatureType
111111

112112
/**
113113
* Normally we assume the URI will be encoded once in preparation for transmission. Certain services do not decode
114114
* before checking signature, requiring the URI to be double-encoded in the canonical request in order to match a
115115
* signature check.
116116
*/
117-
val useDoubleUriEncode: Boolean = builder.useDoubleUriEncode
117+
public val useDoubleUriEncode: Boolean = builder.useDoubleUriEncode
118118

119119
/**
120120
* Controls whether URI paths should be normalized when building the canonical request.
121121
*/
122-
val normalizeUriPath: Boolean = builder.normalizeUriPath
122+
public val normalizeUriPath: Boolean = builder.normalizeUriPath
123123

124124
/**
125125
* Determines whether the `X-Amz-Security-Token` query param should be omitted from the canonical signing
@@ -129,24 +129,25 @@ class AwsSigningConfig(builder: Builder) {
129129
* If this value is false, a non-null security token is _still added to the request_ but it is not used in signature
130130
* calculation.
131131
*/
132-
val omitSessionToken: Boolean = builder.omitSessionToken
132+
public val omitSessionToken: Boolean = builder.omitSessionToken
133133

134134
/**
135135
* Determines the source of the canonical request's body public value. The default is
136136
* [HashSpecification.CalculateFromPayload], indicating that a public value will be calculated from the payload
137137
* during signing.
138138
*/
139-
val hashSpecification: HashSpecification = builder.hashSpecification ?: HashSpecification.CalculateFromPayload
139+
public val hashSpecification: HashSpecification =
140+
builder.hashSpecification ?: HashSpecification.CalculateFromPayload
140141

141142
/**
142143
* Determines which body "hash" header, if any, should be added to the canonical request and the signed request.
143144
*/
144-
val signedBodyHeader: AwsSignedBodyHeader = builder.signedBodyHeader
145+
public val signedBodyHeader: AwsSignedBodyHeader = builder.signedBodyHeader
145146

146147
/**
147148
* Indicates the AWS credentials provider from which to fetch credentials.
148149
*/
149-
val credentialsProvider: CredentialsProvider = requireNotNull(builder.credentialsProvider) {
150+
public val credentialsProvider: CredentialsProvider = requireNotNull(builder.credentialsProvider) {
150151
"Signing config must specify a credentials provider"
151152
}
152153

@@ -156,9 +157,9 @@ class AwsSigningConfig(builder: Builder) {
156157
* value is null or if header signing is being used then this parameter has no effect. Note that the resolution of
157158
* expiration is in seconds.
158159
*/
159-
val expiresAfter: Duration? = builder.expiresAfter
160+
public val expiresAfter: Duration? = builder.expiresAfter
160161

161-
fun toBuilder(): Builder = Builder().also {
162+
public fun toBuilder(): Builder = Builder().also {
162163
it.region = region
163164
it.service = service
164165
it.signingDate = signingDate
@@ -174,21 +175,21 @@ class AwsSigningConfig(builder: Builder) {
174175
it.expiresAfter = expiresAfter
175176
}
176177

177-
class Builder {
178-
var region: String? = null
179-
var service: String? = null
180-
var signingDate: Instant? = null
181-
var shouldSignHeader: ShouldSignHeaderPredicate = { _ -> true } // Don't reject signing any headers by default
182-
var algorithm: AwsSigningAlgorithm = AwsSigningAlgorithm.SIGV4
183-
var signatureType: AwsSignatureType = AwsSignatureType.HTTP_REQUEST_VIA_HEADERS
184-
var useDoubleUriEncode: Boolean = true
185-
var normalizeUriPath: Boolean = true
186-
var omitSessionToken: Boolean = false
187-
var hashSpecification: HashSpecification? = null
188-
var signedBodyHeader: AwsSignedBodyHeader = AwsSignedBodyHeader.NONE
189-
var credentialsProvider: CredentialsProvider? = null
190-
var expiresAfter: Duration? = null
191-
192-
fun build(): AwsSigningConfig = AwsSigningConfig(this)
178+
public class Builder {
179+
public var region: String? = null
180+
public var service: String? = null
181+
public var signingDate: Instant? = null
182+
public var shouldSignHeader: ShouldSignHeaderPredicate = { _ -> true } // Don't reject any headers by default
183+
public var algorithm: AwsSigningAlgorithm = AwsSigningAlgorithm.SIGV4
184+
public var signatureType: AwsSignatureType = AwsSignatureType.HTTP_REQUEST_VIA_HEADERS
185+
public var useDoubleUriEncode: Boolean = true
186+
public var normalizeUriPath: Boolean = true
187+
public var omitSessionToken: Boolean = false
188+
public var hashSpecification: HashSpecification? = null
189+
public var signedBodyHeader: AwsSignedBodyHeader = AwsSignedBodyHeader.NONE
190+
public var credentialsProvider: CredentialsProvider? = null
191+
public var expiresAfter: Duration? = null
192+
193+
public fun build(): AwsSigningConfig = AwsSigningConfig(this)
193194
}
194195
}

runtime/auth/aws-signing-common/common/src/aws/smithy/kotlin/runtime/auth/awssigning/AwsSigningResult.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ package aws.smithy.kotlin.runtime.auth.awssigning
88
* The result of an AWS signing operation
99
* @param T The type of the result
1010
*/
11-
data class AwsSigningResult<T>(
11+
public data class AwsSigningResult<T>(
1212
/**
1313
* The signed output.
1414
*/
15-
val output: T,
15+
public val output: T,
1616

1717
/**
1818
* The signature value from the result. Depending on the requested signature type and algorithm, this value will be
@@ -23,7 +23,7 @@ data class AwsSigningResult<T>(
2323
* * `HTTP_REQUEST_CHUNK/SIGV4_ASYMMETRIC` - '*'-padded hex encoding of the binary signature value
2424
* * `HTTP_REQUEST_EVENT` - hex encoding of the binary signature value
2525
*/
26-
val signature: ByteArray,
26+
public val signature: ByteArray,
2727
) {
2828
override fun equals(other: Any?): Boolean {
2929
if (this === other) return true

runtime/auth/aws-signing-common/common/src/aws/smithy/kotlin/runtime/auth/awssigning/HashSpecification.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,40 @@ package aws.smithy.kotlin.runtime.auth.awssigning
77
/**
88
* Specifies a hash for a signable request
99
*/
10-
sealed class HashSpecification {
10+
public sealed class HashSpecification {
1111
/**
1212
* Indicates that the hash value should be calculated from the body payload of the request
1313
*/
14-
object CalculateFromPayload : HashSpecification()
14+
public object CalculateFromPayload : HashSpecification()
1515

1616
/**
1717
* Specifies a literal value to use as a hash
1818
*/
19-
sealed class HashLiteral(open val hash: String) : HashSpecification()
19+
public sealed class HashLiteral(public open val hash: String) : HashSpecification()
2020

2121
/**
2222
* The hash value should indicate an unsigned payload
2323
*/
24-
object UnsignedPayload : HashLiteral("UNSIGNED-PAYLOAD")
24+
public object UnsignedPayload : HashLiteral("UNSIGNED-PAYLOAD")
2525

2626
/**
27-
* The hash value should indicate an empty body
27+
* The hash value should indicate an empty body. The resulting hash literal is the SHA256 calculation for the empty
28+
* string.
2829
*/
29-
object EmptyBody : HashLiteral("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") // hash of ""
30+
public object EmptyBody : HashLiteral("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
3031

3132
/**
3233
* The hash value should indicate that signature covers only headers and that there is no payload
3334
*/
34-
object StreamingAws4HmacSha256Payload : HashLiteral("STREAMING-AWS4-HMAC-SHA256-PAYLOAD")
35+
public object StreamingAws4HmacSha256Payload : HashLiteral("STREAMING-AWS4-HMAC-SHA256-PAYLOAD")
3536

3637
/**
3738
* The hash value should indicate ???
3839
*/
39-
object StreamingAws4HmacSha256Events : HashLiteral("STREAMING-AWS4-HMAC-SHA256-EVENTS")
40+
public object StreamingAws4HmacSha256Events : HashLiteral("STREAMING-AWS4-HMAC-SHA256-EVENTS")
4041

4142
/**
4243
* Use an explicit, precalculated value for the hash
4344
*/
44-
data class Precalculated(override val hash: String) : HashLiteral(hash)
45+
public data class Precalculated(override val hash: String) : HashLiteral(hash)
4546
}

0 commit comments

Comments
 (0)