aws-sdk-cloudfront 1.128.0 → 1.140.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # utility classes
4
3
  module Aws
5
4
  module CloudFront
6
5
  autoload :Signer, 'aws-sdk-cloudfront/signer'
@@ -13,22 +13,22 @@ module Aws::CloudFront
13
13
  # @!attribute use_dual_stack
14
14
  # When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.
15
15
  #
16
- # @return [Boolean]
16
+ # @return [boolean]
17
17
  #
18
18
  # @!attribute use_fips
19
19
  # When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.
20
20
  #
21
- # @return [Boolean]
21
+ # @return [boolean]
22
22
  #
23
23
  # @!attribute endpoint
24
24
  # Override the endpoint used to send this request
25
25
  #
26
- # @return [String]
26
+ # @return [string]
27
27
  #
28
28
  # @!attribute region
29
29
  # The AWS region used to dispatch the request.
30
30
  #
31
- # @return [String]
31
+ # @return [string]
32
32
  #
33
33
  EndpointParameters = Struct.new(
34
34
  :use_dual_stack,
@@ -7,25 +7,22 @@ require 'openssl'
7
7
 
8
8
  module Aws
9
9
  module CloudFront
10
-
11
10
  module Signer
12
-
13
11
  # @option options [String] :key_pair_id
14
12
  # @option options [String] :private_key
15
13
  # @option options [String] :private_key_path
16
14
  def initialize(options = {})
17
15
  @key_pair_id = key_pair_id(options)
18
- @cipher = OpenSSL::Digest::SHA1.new
19
- @private_key = OpenSSL::PKey::RSA.new(private_key(options))
16
+ @cipher = OpenSSL::Digest.new('SHA1')
17
+ @private_key = OpenSSL::PKey.read(private_key(options))
20
18
  end
21
19
 
22
20
  private
23
21
 
24
22
  def scheme_and_uri(url)
25
23
  url_sections = url.split('://', 2)
26
- if url_sections.length < 2
27
- raise ArgumentError, "Invalid URL:#{url}"
28
- end
24
+ raise ArgumentError, "Invalid URL:#{url}" if url_sections.length < 2
25
+
29
26
  scheme = url_sections[0].delete('*')
30
27
  uri = "#{scheme}://#{url_sections[1]}"
31
28
  [scheme, uri]
@@ -69,7 +66,7 @@ module Aws
69
66
  resource_content
70
67
  end
71
68
  else
72
- msg = "Invalid URI scheme:#{scheme}.Scheme must be one of: http, https or rtmp."
69
+ msg = "Invalid URI scheme:#{scheme}. Scheme must be one of: http, https or rtmp."
73
70
  raise ArgumentError, msg
74
71
  end
75
72
  end
@@ -87,7 +84,7 @@ module Aws
87
84
  policy = canned_policy(params[:resource], params[:expires])
88
85
  signature_content['Expires'] = params[:expires]
89
86
  else
90
- msg = "Either a policy or a resource with an expiration time must be provided."
87
+ msg = 'Either a policy or a resource with an expiration time must be provided.'
91
88
  raise ArgumentError, msg
92
89
  end
93
90
 
@@ -106,37 +103,34 @@ module Aws
106
103
  json_hash = {
107
104
  'Statement' => [
108
105
  'Resource' => resource,
109
- 'Condition' => {
110
- 'DateLessThan' => {'AWS:EpochTime' => expires}
111
- }
106
+ 'Condition' => { 'DateLessThan' => { 'AWS:EpochTime' => expires } }
112
107
  ]
113
108
  }
114
109
  Aws::Json.dump(json_hash)
115
110
  end
116
111
 
117
112
  def encode(policy)
118
- Base64.encode64(policy).gsub(/[+=\/]/, '+' => '-', '=' => '_', '/' => '~')
113
+ Base64.encode64(policy).gsub(%r{[+=/]}, '+' => '-', '=' => '_', '/' => '~')
119
114
  end
120
115
 
121
116
  def key_pair_id(options)
122
- if options[:key_pair_id].nil? or options[:key_pair_id] == ''
123
- raise ArgumentError, ":key_pair_id must not be blank"
124
- else
125
- options[:key_pair_id]
117
+ if options[:key_pair_id].nil? || (options[:key_pair_id] == '')
118
+ raise ArgumentError, ':key_pair_id must not be blank'
126
119
  end
120
+
121
+ options[:key_pair_id]
127
122
  end
128
123
 
129
124
  def private_key(options)
130
125
  if options[:private_key]
131
126
  options[:private_key]
132
127
  elsif options[:private_key_path]
133
- File.open(options[:private_key_path], 'rb') { |f| f.read }
128
+ File.open(options[:private_key_path], 'rb', &:read)
134
129
  else
135
- msg = ":private_key or :private_key_path should be provided"
130
+ msg = ':private_key or :private_key_path should be provided'
136
131
  raise ArgumentError, msg
137
132
  end
138
133
  end
139
-
140
134
  end
141
135
  end
142
136
  end