acme-client 2.0.14 → 2.0.16

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6238349e171138af08de444bf08268ab3bebab0c4d0497bee91d9d4a30d397ab
4
- data.tar.gz: 9928049d9997c284cec6d75e12bf6b5f07150459775d8f852adbc09b7c923178
3
+ metadata.gz: f26a6196b6e5f7bfe464c6d5e3068f29a295c914aaa2af7a086b949cfb00e132
4
+ data.tar.gz: 20ae05784979ec85c880736ded0915de4ad07a743262eb203a089e7fd7fbf79c
5
5
  SHA512:
6
- metadata.gz: 8543f742ee8fe3822c8c989a7e5f8b1f75473f01a36d7a2218c44b43ebec55fa538beabc4545c4798a7b35005ad1fddbd0ed59dbae6942413812fae9ce625f92
7
- data.tar.gz: 77cd41773aa293bcb65ebdb9489c500a06b144e0efb2dc5af23baa8dec8c36c1af32fd9f1c97eb77e40eb4a521a9c904448d5765f64dcbe56a67f4907225aaf3
6
+ metadata.gz: 1c89f451807ab8f10529c3feabc4d96d961bddfc915eeaa2cc76d9f4ed31b9e6376e80327f82ce0daafa7df2d74e5585403b354cb53d1942b1e5bf0db9c4c0d0
7
+ data.tar.gz: 21970923591d7133201257ad95e456b429eb3d906bd12d1fcd17a0305ba2edce0e16d0bdd8edfbb03764d8d35b2a845f08a0f5e6e116385735d6e081b7d094e2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## `2.0.16`
2
+
3
+ * Refactor Directory
4
+ * Fix an issue where the client would crash when ACME provider return nonce for directory endpoint
5
+
6
+ ## `2.0.15`
7
+
8
+ * Also pass connection_options to Faraday for Client#get_nonce
9
+
10
+
1
11
  ## `2.0.14`
2
12
 
3
13
  * Fix Faraday HTTP exceptions leaking out, always raise `Acme::Client::Error` instead
data/acme-client.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.homepage = 'http://github.com/unixcharles/acme-client'
12
12
  spec.license = 'MIT'
13
13
 
14
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) || f.start_with?('.') }
15
15
  spec.require_paths = ['lib']
16
16
 
17
17
  spec.required_ruby_version = '>= 2.3.0'
@@ -17,12 +17,13 @@ class Acme::Client::Resources::Directory
17
17
  external_account_required: 'externalAccountRequired'
18
18
  }
19
19
 
20
- def initialize(url, connection_options)
21
- @url, @connection_options = url, connection_options
20
+ def initialize(client, **arguments)
21
+ @client = client
22
+ assign_attributes(**arguments)
22
23
  end
23
24
 
24
25
  def endpoint_for(key)
25
- directory.fetch(key) do |missing_key|
26
+ @directory.fetch(key) do |missing_key|
26
27
  raise Acme::Client::Error::UnsupportedOperation,
27
28
  "Directory at #{@url} does not include `#{missing_key}`"
28
29
  end
@@ -45,31 +46,16 @@ class Acme::Client::Resources::Directory
45
46
  end
46
47
 
47
48
  def meta
48
- directory[:meta]
49
+ @directory[:meta]
49
50
  end
50
51
 
51
52
  private
52
53
 
53
- def directory
54
- @directory ||= load_directory
55
- end
56
-
57
- def load_directory
58
- body = fetch_directory
59
- result = {}
60
- result[:meta] = body.delete('meta')
54
+ def assign_attributes(directory:)
55
+ @directory = {}
56
+ @directory[:meta] = directory.delete('meta')
61
57
  DIRECTORY_RESOURCES.each do |key, entry|
62
- result[key] = URI(body[entry]) if body[entry]
58
+ @directory[key] = URI(directory[entry]) if directory[entry]
63
59
  end
64
- result
65
- rescue JSON::ParserError => exception
66
- raise Acme::Client::Error::InvalidDirectory,
67
- "Invalid directory url\n#{@directory} did not return a valid directory\n#{exception.inspect}"
68
- end
69
-
70
- def fetch_directory
71
- http_client = Acme::Client::HTTPClient.new_acme_connection(url: @directory, options: @connection_options, client: nil, mode: nil)
72
- response = http_client.get(@url)
73
- response.body
74
60
  end
75
61
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Acme
4
4
  class Client
5
- VERSION = '2.0.14'.freeze
5
+ VERSION = '2.0.16'.freeze
6
6
  end
7
7
  end
data/lib/acme/client.rb CHANGED
@@ -44,7 +44,7 @@ class Acme::Client
44
44
 
45
45
  @kid, @connection_options = kid, connection_options
46
46
  @bad_nonce_retry = bad_nonce_retry
47
- @directory = Acme::Client::Resources::Directory.new(URI(directory), @connection_options)
47
+ @directory_url = URI(directory)
48
48
  @nonces ||= []
49
49
  end
50
50
 
@@ -223,34 +223,50 @@ class Acme::Client
223
223
  end
224
224
 
225
225
  def get_nonce
226
- http_client = Acme::Client::HTTPClient.new_connection(url: endpoint_for(:new_nonce))
226
+ http_client = Acme::Client::HTTPClient.new_connection(url: endpoint_for(:new_nonce), options: @connection_options)
227
227
  response = http_client.head(nil, nil)
228
228
  nonces << response.headers['replay-nonce']
229
229
  true
230
230
  end
231
231
 
232
+ def directory
233
+ @directory ||= load_directory
234
+ end
235
+
232
236
  def meta
233
- @directory.meta
237
+ directory.meta
234
238
  end
235
239
 
236
240
  def terms_of_service
237
- @directory.terms_of_service
241
+ directory.terms_of_service
238
242
  end
239
243
 
240
244
  def website
241
- @directory.website
245
+ directory.website
242
246
  end
243
247
 
244
248
  def caa_identities
245
- @directory.caa_identities
249
+ directory.caa_identities
246
250
  end
247
251
 
248
252
  def external_account_required
249
- @directory.external_account_required
253
+ directory.external_account_required
250
254
  end
251
255
 
252
256
  private
253
257
 
258
+ def load_directory
259
+ Acme::Client::Resources::Directory.new(self, directory: fetch_directory)
260
+ end
261
+
262
+ def fetch_directory
263
+ response = get(@directory_url)
264
+ response.body
265
+ rescue JSON::ParserError => exception
266
+ raise Acme::Client::Error::InvalidDirectory,
267
+ "Invalid directory url\n#{@directory_url} did not return a valid directory\n#{exception.inspect}"
268
+ end
269
+
254
270
  def prepare_order_identifiers(identifiers)
255
271
  if identifiers.is_a?(Hash)
256
272
  [identifiers]
@@ -351,6 +367,6 @@ class Acme::Client
351
367
  end
352
368
 
353
369
  def endpoint_for(key)
354
- @directory.endpoint_for(key)
370
+ directory.endpoint_for(key)
355
371
  end
356
372
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acme-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.14
4
+ version: 2.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Barbier
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-16 00:00:00.000000000 Z
11
+ date: 2024-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -134,18 +134,13 @@ dependencies:
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: 3.0.0
137
- description:
137
+ description:
138
138
  email:
139
139
  - unixcharles@gmail.com
140
140
  executables: []
141
141
  extensions: []
142
142
  extra_rdoc_files: []
143
143
  files:
144
- - ".github/workflows/rubocop.yml"
145
- - ".github/workflows/test.yml"
146
- - ".gitignore"
147
- - ".rspec"
148
- - ".rubocop.yml"
149
144
  - CHANGELOG.md
150
145
  - Gemfile
151
146
  - LICENSE.txt
@@ -184,7 +179,7 @@ homepage: http://github.com/unixcharles/acme-client
184
179
  licenses:
185
180
  - MIT
186
181
  metadata: {}
187
- post_install_message:
182
+ post_install_message:
188
183
  rdoc_options: []
189
184
  require_paths:
190
185
  - lib
@@ -199,8 +194,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
194
  - !ruby/object:Gem::Version
200
195
  version: '0'
201
196
  requirements: []
202
- rubygems_version: 3.0.3.1
203
- signing_key:
197
+ rubygems_version: 3.4.20
198
+ signing_key:
204
199
  specification_version: 4
205
200
  summary: Client for the ACME protocol.
206
201
  test_files: []
@@ -1,23 +0,0 @@
1
- name: Lint
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- rubocop:
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- ruby-version: ['3.0']
15
- steps:
16
- - uses: actions/checkout@v2
17
- - name: Set up Ruby
18
- uses: ruby/setup-ruby@v1
19
- with:
20
- ruby-version: ${{ matrix.ruby-version }}
21
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
22
- - name: Run tests
23
- run: bundle exec rake rubocop
@@ -1,26 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [ master ]
6
- pull_request:
7
- branches: [ master ]
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
- strategy:
13
- matrix:
14
- ruby-version: ['2.7', '3.0', '3.1', '3.2']
15
- faraday-version: ['~> 1.10', '~> 2.7']
16
- env:
17
- FARADAY_VERSION: ${{ matrix.faraday-version }}
18
- steps:
19
- - uses: actions/checkout@v2
20
- - name: Set up Ruby
21
- uses: ruby/setup-ruby@v1
22
- with:
23
- ruby-version: ${{ matrix.ruby-version }}
24
- bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
- - name: Run tests
26
- run: bundle exec rake spec
data/.gitignore DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- /vendor/bundle
11
- /.idea/
12
- .tool-versions
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --order rand
data/.rubocop.yml DELETED
@@ -1,134 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.1
3
- Exclude:
4
- - 'bin/*'
5
- - 'vendor/**/*'
6
-
7
- Rails:
8
- Enabled: false
9
-
10
- Layout/AlignParameters:
11
- EnforcedStyle: with_fixed_indentation
12
-
13
- Layout/ElseAlignment:
14
- Enabled: false
15
-
16
- Layout/FirstParameterIndentation:
17
- EnforcedStyle: consistent
18
-
19
- Layout/IndentationWidth:
20
- Enabled: false
21
-
22
- Layout/MultilineOperationIndentation:
23
- Enabled: false
24
-
25
- Layout/SpaceInsideBlockBraces:
26
- Enabled: false
27
-
28
- Lint/AmbiguousOperator:
29
- Enabled: false
30
-
31
- Lint/AssignmentInCondition:
32
- Enabled: false
33
-
34
- Lint/EndAlignment:
35
- Enabled: false
36
-
37
- Lint/UnusedMethodArgument:
38
- AllowUnusedKeywordArguments: true
39
-
40
- Metrics/AbcSize:
41
- Enabled: false
42
-
43
- Metrics/BlockLength:
44
- Enabled: false
45
-
46
- Metrics/ClassLength:
47
- Enabled: false
48
-
49
- Metrics/CyclomaticComplexity:
50
- Enabled: false
51
-
52
- Metrics/LineLength:
53
- Max: 140
54
-
55
- Metrics/MethodLength:
56
- Max: 15
57
- Enabled: false
58
-
59
- Metrics/ParameterLists:
60
- Max: 5
61
- CountKeywordArgs: false
62
-
63
- Metrics/PerceivedComplexity:
64
- Enabled: false
65
-
66
- Security/JSONLoad:
67
- Enabled: false
68
-
69
- Style/AccessorMethodName:
70
- Enabled: false
71
-
72
- Style/Alias:
73
- Enabled: false
74
-
75
- Style/BlockDelimiters:
76
- EnforcedStyle: semantic
77
-
78
- Style/ClassAndModuleChildren:
79
- Enabled: false
80
-
81
- Style/Documentation:
82
- Enabled: false
83
-
84
- Style/DoubleNegation:
85
- Enabled: false
86
-
87
- Style/FileName:
88
- Exclude:
89
- - 'lib/acme-client.rb'
90
-
91
- Style/GlobalVars:
92
- Enabled: false
93
-
94
- Style/GuardClause:
95
- Enabled: false
96
-
97
- Style/IfUnlessModifier:
98
- Enabled: false
99
-
100
- Style/Lambda:
101
- Enabled: false
102
-
103
- Style/ModuleFunction:
104
- Enabled: false
105
-
106
- Style/MultilineBlockChain:
107
- Enabled: false
108
-
109
- Style/MultipleComparison:
110
- Enabled: false
111
-
112
- Style/MutableConstant:
113
- Enabled: false
114
-
115
- Style/ParallelAssignment:
116
- Enabled: false
117
-
118
- Style/PercentLiteralDelimiters:
119
- Enabled: false
120
-
121
- Style/SignalException:
122
- EnforcedStyle: only_raise
123
-
124
- Style/SymbolArray:
125
- Enabled: false
126
-
127
- Style/StringLiterals:
128
- Enabled: single_quotes
129
-
130
- Style/TrailingCommaInArguments:
131
- Enabled: false
132
-
133
- Style/TrivialAccessors:
134
- AllowPredicates: true