Skip to content

Commit c038125

Browse files
authored
Add an RBS signature for sigv4 (#3152)
1 parent 9b7d84b commit c038125

File tree

14 files changed

+170
-13
lines changed

14 files changed

+170
-13
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333
bundle config set --local with 'build rbs'
3434
bundle install
3535
36+
- name: Install rbs collection
37+
run: rbs collection install
38+
3639
- name: Build SDK
3740
run: bundle exec rake build
3841

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
/.byebug_history
44
/.bundle
5+
/.gem_rbs_collection
56
/.yardoc
67
/api-docs
78
/Gemfile.lock
89
/coverage
10+
/rbs_collection.lock.yaml
911
*.gem
1012
benchmark_report.json
1113

gems/aws-sigv4/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased Changes
22
------------------
33

4+
* Feature - Add RBS signature files to support static type checking
5+
46
1.10.1 (2024-10-21)
57
------------------
68

gems/aws-sigv4/lib/aws-sigv4/request.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Sigv4
77
class Request
88

99
# @option options [required, String] :http_method
10-
# @option options [required, HTTP::URI, HTTPS::URI, String] :endpoint
10+
# @option options [required, String, URI::HTTP, URI::HTTPS] :endpoint
1111
# @option options [Hash<String,String>] :headers ({})
1212
# @option options [String, IO] :body ('')
1313
def initialize(options = {})
@@ -30,12 +30,12 @@ def http_method
3030
@http_method
3131
end
3232

33-
# @param [String, HTTP::URI, HTTPS::URI] endpoint
33+
# @param [String, URI::HTTP, URI::HTTPS] endpoint
3434
def endpoint=(endpoint)
3535
@endpoint = URI.parse(endpoint.to_s)
3636
end
3737

38-
# @return [HTTP::URI, HTTPS::URI]
38+
# @return [URI::HTTP, URI::HTTPS]
3939
def endpoint
4040
@endpoint
4141
end

gems/aws-sigv4/lib/aws-sigv4/signer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def initialize(options = {})
205205
# @option request [required, String] :http_method One of
206206
# 'GET', 'HEAD', 'PUT', 'POST', 'PATCH', or 'DELETE'
207207
#
208-
# @option request [required, String, URI::HTTPS, URI::HTTP] :url
208+
# @option request [required, String, URI::HTTP, URI::HTTPS] :url
209209
# The request URI. Must be a valid HTTP or HTTPS URI.
210210
#
211211
# @option request [optional, Hash] :headers ({}) A hash of headers
@@ -383,7 +383,7 @@ def sign_event(prior_signature, payload, encoder)
383383
# @option options [required, String] :http_method The HTTP request method,
384384
# e.g. 'GET', 'HEAD', 'PUT', 'POST', 'PATCH', or 'DELETE'.
385385
#
386-
# @option options [required, String, HTTPS::URI, HTTP::URI] :url
386+
# @option options [required, String, URI::HTTP, URI::HTTPS] :url
387387
# The URI to sign.
388388
#
389389
# @option options [Hash] :headers ({}) Headers that should

gems/aws-sigv4/sig/errors.rbs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Aws
2+
module Sigv4
3+
module Errors
4+
class MissingCredentialsError < ArgumentError
5+
def initialize: (?String msg) -> void
6+
end
7+
8+
class MissingRegionError < ArgumentError
9+
def initialize: (*untyped) -> void
10+
end
11+
end
12+
end
13+
end

gems/aws-sigv4/sig/interfaces.rbs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Aws
2+
module Sigv4
3+
interface _Credentials
4+
def access_key_id: () -> String
5+
def secret_access_key: () -> String
6+
def session_token: () -> String?
7+
def set?: () -> bool
8+
end
9+
10+
interface _CredentialsProvider
11+
def credentials: () -> _Credentials
12+
def set?: () -> bool
13+
end
14+
end
15+
end

gems/aws-sigv4/sig/manifest.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dependencies:
2+
- name: tempfile
3+
- name: stringio
4+
- name: uri

gems/aws-sigv4/sig/request.rbs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Aws
2+
module Sigv4
3+
class Request
4+
def initialize: (
5+
http_method: String,
6+
endpoint: String | URI::HTTP | URI::HTTPS,
7+
?headers: Hash[String, String],
8+
?body: String | IO
9+
) -> void
10+
| (?Hash[Symbol, untyped]) -> void
11+
12+
def http_method=: (String http_method) -> void
13+
def http_method: () -> String
14+
15+
def endpoint: () -> (URI::HTTP | URI::HTTPS)
16+
def endpoint=: (String | URI::HTTP | URI::HTTPS endpoint) -> void
17+
18+
def headers=: (Hash[String, String] headers) -> void
19+
def headers: () -> Hash[String, String]
20+
21+
def body=: (String | IO body) -> void
22+
def body: () -> (String | IO)
23+
end
24+
end
25+
end

gems/aws-sigv4/sig/signature.rbs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module Aws
2+
module Sigv4
3+
class Signature
4+
attr_accessor headers: Hash[String, String]
5+
attr_accessor canonical_request: String
6+
attr_accessor string_to_sign: String
7+
attr_accessor content_sha256: String
8+
attr_accessor signature: String
9+
attr_accessor extra: Hash[untyped, untyped]
10+
end
11+
end
12+
end

0 commit comments

Comments
 (0)