linzer 0.7.0 → 0.7.1

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: b5767ac6b96b624e2098faa01e7cda512ca5f1530d6331c0a95c8f57a262da3d
4
- data.tar.gz: 0ec39dbe4697fd2617770be2937ec062d5a9336ef5365dd3c3b028e541670903
3
+ metadata.gz: 9d495888382dc17a4fae60d05b853dd0cbb0036119ae725f960471baa6ff0d4b
4
+ data.tar.gz: a6860cf3dcfb586e1591b0b683c883bbf8a42de941f57ec6a2ba6f8574a5a2dd
5
5
  SHA512:
6
- metadata.gz: c471b814bc6310ca41f60947df7a5097c738bb79e89720c3e7da0b7e331949b244bb0e030162363eb00bce411d3b2d6735615f3b529cd7e42815a4cee769b828
7
- data.tar.gz: 3beaf6ab15820fb61473811d63da3f0bbd58653d62e58f193dd5709dd8e5e7b54914f420dbec61af557dcb9afd8da571ae0ab007ba39f7b19d48324084f30df7
6
+ metadata.gz: c4d53b9d1102eaa3fc0241938afa86fd194a9ae780233bdabd171190ab9b83958193f5bc28b5bd78fb11a234c3a25c3145ee87e6ac6116f544cb04e73c67a5bd
7
+ data.tar.gz: 40e9c1e6bf52d944cd1a82b67502a41ae2939852e723143f1b154bab0b984fb9db6d944ecdf56b6845b6419096f4cbcef01ac545b9b9df73fe8ccc6f0489ace9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.7.1] - 2025-05-18
4
+
5
+ - Introduce specific exception classes for message signing errors
6
+ and signature verification exceptions (i.e. Linzer::SigningError
7
+ and Linzer::VerifyError)
8
+
9
+ - Fix bug in Linzer::HTTP client that prevented it from working with https URLs.
10
+
3
11
  ## [0.7.0] - 2025-05-17
4
12
 
5
13
  (No changes since the last beta release, this new stable release just
data/lib/linzer/http.rb CHANGED
@@ -33,6 +33,8 @@ module Linzer
33
33
 
34
34
  req_uri = URI(uri)
35
35
  http = Net::HTTP.new(req_uri.host, req_uri.port)
36
+
37
+ http.use_ssl = req_uri.scheme == "https"
36
38
  http.set_debug_output($stderr) if options[:debug]
37
39
 
38
40
  headers = build_headers(options[:headers] || {})
data/lib/linzer/signer.rb CHANGED
@@ -27,11 +27,15 @@ module Linzer
27
27
 
28
28
  def validate(key, message, components)
29
29
  msg = "Message cannot be signed with null %s"
30
- raise Error.new msg % "value" if message.nil?
31
- raise Error.new msg % "key" if key.nil?
32
- raise Error.new msg % "component" if components.nil?
33
-
34
- validate_components message, components
30
+ raise SigningError, msg % "value" if message.nil?
31
+ raise SigningError, msg % "key" if key.nil?
32
+ raise SigningError, msg % "component" if components.nil?
33
+
34
+ begin
35
+ validate_components message, components
36
+ rescue Error => ex
37
+ raise SigningError, ex.message, cause: ex
38
+ end
35
39
  end
36
40
 
37
41
  def populate_parameters(key, options)
@@ -19,26 +19,35 @@ module Linzer
19
19
  private
20
20
 
21
21
  def validate(message, key, signature, no_older_than: nil)
22
- raise Error.new "Message to verify cannot be null" if message.nil?
23
- raise Error.new "Key to verify signature cannot be null" if key.nil?
24
- raise Error.new "Signature to verify cannot be null" if signature.nil?
22
+ raise VerifyError, "Message to verify cannot be null" if message.nil?
23
+ raise VerifyError, "Key to verify signature cannot be null" if key.nil?
24
+ raise VerifyError, "Signature to verify cannot be null" if signature.nil?
25
25
 
26
26
  if !signature.respond_to?(:value) || !signature.respond_to?(:components)
27
- raise Error.new "Signature is invalid"
27
+ raise VerifyError, "Signature is invalid"
28
28
  end
29
29
 
30
- raise Error.new "Signature raw value to cannot be null" if signature.value.nil?
31
- raise Error.new "Components cannot be null" if signature.components.nil?
30
+ raise VerifyError, "Signature raw value to cannot be null" if signature.value.nil?
31
+ raise VerifyError, "Components cannot be null" if signature.components.nil?
32
32
 
33
- validate_components message, signature.components
33
+ begin
34
+ validate_components message, signature.components
35
+ rescue Error => ex
36
+ raise VerifyError, ex.message, cause: ex
37
+ end
34
38
 
35
39
  return unless no_older_than
36
- raise Error.new "Signature created more than #{no_older_than} seconds ago" if signature.older_than?(no_older_than.to_i)
40
+ old_sig_msg = "Signature created more than #{no_older_than} seconds ago"
41
+ begin
42
+ raise VerifyError, old_sig_msg if signature.older_than?(no_older_than.to_i)
43
+ rescue Error => ex
44
+ raise VerifyError, ex.message, cause: ex
45
+ end
37
46
  end
38
47
 
39
48
  def verify_or_fail(key, signature, data)
40
49
  return true if key.verify(signature, data)
41
- raise Error.new "Failed to verify message: Invalid signature."
50
+ raise VerifyError, "Failed to verify message: Invalid signature."
42
51
  end
43
52
  end
44
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Linzer
4
- VERSION = "0.7.0"
4
+ VERSION = "0.7.1"
5
5
  end
data/lib/linzer.rb CHANGED
@@ -29,6 +29,10 @@ require_relative "rack/auth/signature"
29
29
  module Linzer
30
30
  class Error < StandardError; end
31
31
 
32
+ class VerifyError < Error; end
33
+
34
+ class SigningError < Error; end
35
+
32
36
  class << self
33
37
  include Key::Helper
34
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Landaeta