linzer 0.7.9.beta3 → 0.7.9
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 +4 -4
- data/CHANGELOG.md +19 -0
- data/lib/linzer/message/adapter/abstract.rb +30 -4
- data/lib/linzer/message/adapter/faraday/response.rb +11 -9
- data/lib/linzer/message/adapter/generic/request.rb +11 -8
- data/lib/linzer/message/adapter/generic/response.rb +11 -8
- data/lib/linzer/message/adapter/http_gem/common.rb +11 -8
- data/lib/linzer/message/adapter/rack/request.rb +11 -8
- data/lib/linzer/message/adapter/rack/response.rb +11 -8
- data/lib/linzer/version.rb +1 -1
- data/lib/linzer.rb +0 -1
- metadata +1 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91f1e3986fae03eb9bf01d4dc8e9c919cd7072ea3ae0f8168099261da0da8c11
|
|
4
|
+
data.tar.gz: fb07600d19e8e2198e7cbcfb910516d9300e3aa89d94e81e3bc3ebd6a9d007e8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aed32987b8ea9fc398ef1d263a94ce3df3ec86e8cd331d2e9b23383c0c6de1db3f0bdaa621990eb1809c210b0ae3f38b045abd2e8e48229a9ec8129cf4213c65
|
|
7
|
+
data.tar.gz: 26a21c99d8e383af31395f5ebfa5581b0fedf126bb1bb806db3cb1eb0f0d89306dde3af7bf54100cd0251235f54e5cd4f852f8d61007b74fe079716b4447986a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.7.9] - 2026-04-30
|
|
4
|
+
|
|
5
|
+
(No changes since the last beta release, this new stable release just
|
|
6
|
+
bundles all the features/changes introduced during 0.7.9 beta releases)
|
|
7
|
+
|
|
8
|
+
- Add support for http gem 6.x while maintaining compatibility with 5.x.
|
|
9
|
+
Handles API differences introduced in 6.0.
|
|
10
|
+
|
|
11
|
+
- Improve README clarity and align it with current behavior and production
|
|
12
|
+
usage.
|
|
13
|
+
|
|
14
|
+
- Enforce `expires` signature parameter validation in Verifier.
|
|
15
|
+
|
|
16
|
+
- Add Faraday middleware and adapters for HTTP message signatures.
|
|
17
|
+
|
|
18
|
+
- Add support for multiple signatures on a single HTTP message
|
|
19
|
+
This fixes a bug on multi-signature header overwrite when calling sign!
|
|
20
|
+
multiple times.
|
|
21
|
+
|
|
3
22
|
## [0.7.9.beta3] - 2026-04-27
|
|
4
23
|
|
|
5
24
|
- Enforce `expires` signature parameter validation in Verifier.
|
|
@@ -10,8 +10,8 @@ module Linzer
|
|
|
10
10
|
# implements field retrieval, header access, and signature attachment
|
|
11
11
|
# for a specific HTTP message type.
|
|
12
12
|
#
|
|
13
|
-
# @abstract Subclass and implement {#header}, {#
|
|
14
|
-
#
|
|
13
|
+
# @abstract Subclass and implement {#header}, {#derived}, and {#field}
|
|
14
|
+
# to create a new adapter.
|
|
15
15
|
#
|
|
16
16
|
# @see Rack::Request Rack request adapter
|
|
17
17
|
# @see Rack::Response Rack response adapter
|
|
@@ -84,13 +84,39 @@ module Linzer
|
|
|
84
84
|
raise Linzer::Error, "Sub-classes are required to implement this method!"
|
|
85
85
|
end
|
|
86
86
|
|
|
87
|
+
# Checks whether the request contains HTTP Message Signature headers.
|
|
88
|
+
#
|
|
89
|
+
# Returns true if either the "signature-input" or "signature" header
|
|
90
|
+
# is present.
|
|
91
|
+
#
|
|
92
|
+
# @return [Boolean] true if the request includes HTTP Message Signature headers
|
|
93
|
+
def has_signature?
|
|
94
|
+
!!header("signature-input") || !!header("signature")
|
|
95
|
+
end
|
|
96
|
+
|
|
87
97
|
# Attaches a signature to the underlying HTTP message.
|
|
88
98
|
#
|
|
89
|
-
# @abstract Subclasses must implement this method.
|
|
90
99
|
# @param signature [Signature] The signature to attach
|
|
91
100
|
# @return [Object] The underlying HTTP message
|
|
92
101
|
def attach!(signature)
|
|
93
|
-
|
|
102
|
+
signature_headers = signature.to_h
|
|
103
|
+
|
|
104
|
+
unless has_signature?
|
|
105
|
+
signature_headers.each { |h, v| set_header!(h, v) }
|
|
106
|
+
return @operation
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
signature_headers.each do |hdr, value|
|
|
110
|
+
merged = Starry.parse_dictionary(String(header(hdr)))
|
|
111
|
+
merged.merge!(Starry.parse_dictionary(value))
|
|
112
|
+
set_header!(hdr, Starry.serialize_dictionary(merged))
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
@operation
|
|
116
|
+
rescue Starry::ParseError => e
|
|
117
|
+
raise Error,
|
|
118
|
+
"Cannot attach signature, invalid signature header(s)!",
|
|
119
|
+
cause: e
|
|
94
120
|
end
|
|
95
121
|
|
|
96
122
|
private
|
|
@@ -16,15 +16,6 @@ module Linzer
|
|
|
16
16
|
# @see Generic::Response
|
|
17
17
|
# @see https://github.com/lostisland/faraday faraday gem
|
|
18
18
|
class Response < Generic::Response
|
|
19
|
-
# Attaches a signature to the underlying response headers.
|
|
20
|
-
#
|
|
21
|
-
# @param signature [Linzer::Signature] the signature to attach
|
|
22
|
-
# @return [::Faraday::Response] the underlying response object
|
|
23
|
-
def attach!(signature)
|
|
24
|
-
signature.to_h.each { |h, v| @operation.headers[h] = v }
|
|
25
|
-
@operation
|
|
26
|
-
end
|
|
27
|
-
|
|
28
19
|
private
|
|
29
20
|
|
|
30
21
|
# Resolves a derived component value from the response.
|
|
@@ -37,6 +28,17 @@ module Linzer
|
|
|
37
28
|
when "@status" then @operation.status.to_i
|
|
38
29
|
end
|
|
39
30
|
end
|
|
31
|
+
|
|
32
|
+
# Sets a header on the underlying HTTP message.
|
|
33
|
+
#
|
|
34
|
+
# If a header with the given name already exists, its value is overwritten.
|
|
35
|
+
#
|
|
36
|
+
# @param header [String] the header name
|
|
37
|
+
# @param value [String] the header value
|
|
38
|
+
# @return [String] the value assigned to the header
|
|
39
|
+
def set_header!(header, value)
|
|
40
|
+
@operation.headers[header] = value
|
|
41
|
+
end
|
|
40
42
|
end
|
|
41
43
|
end
|
|
42
44
|
end
|
|
@@ -40,14 +40,6 @@ module Linzer
|
|
|
40
40
|
@operation[name]
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
-
# Attaches a signature to the request.
|
|
44
|
-
# @param signature [Signature] The signature to attach
|
|
45
|
-
# @return [Object] The underlying request object
|
|
46
|
-
def attach!(signature)
|
|
47
|
-
signature.to_h.each { |h, v| @operation[h] = v }
|
|
48
|
-
@operation
|
|
49
|
-
end
|
|
50
|
-
|
|
51
43
|
private
|
|
52
44
|
|
|
53
45
|
def derived(name)
|
|
@@ -68,6 +60,17 @@ module Linzer
|
|
|
68
60
|
end
|
|
69
61
|
end
|
|
70
62
|
|
|
63
|
+
# Sets a header on the underlying HTTP message.
|
|
64
|
+
#
|
|
65
|
+
# If a header with the given name already exists, its value is overwritten.
|
|
66
|
+
#
|
|
67
|
+
# @param header [String] the header name
|
|
68
|
+
# @param value [String] the header value
|
|
69
|
+
# @return [String] the value assigned to the header
|
|
70
|
+
def set_header!(header, value)
|
|
71
|
+
@operation[header] = value
|
|
72
|
+
end
|
|
73
|
+
|
|
71
74
|
def query_param(uri_query, name)
|
|
72
75
|
param_name = name.parameters["name"]
|
|
73
76
|
return nil if !param_name
|
|
@@ -31,16 +31,19 @@ module Linzer
|
|
|
31
31
|
@operation[name]
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
# Attaches a signature to the response.
|
|
35
|
-
# @param signature [Signature] The signature to attach
|
|
36
|
-
# @return [Object] The underlying response object
|
|
37
|
-
def attach!(signature)
|
|
38
|
-
signature.to_h.each { |h, v| @operation[h] = v }
|
|
39
|
-
@operation
|
|
40
|
-
end
|
|
41
|
-
|
|
42
34
|
private
|
|
43
35
|
|
|
36
|
+
# Sets a header on the underlying HTTP message.
|
|
37
|
+
#
|
|
38
|
+
# If a header with the given name already exists, its value is overwritten.
|
|
39
|
+
#
|
|
40
|
+
# @param header [String] the header name
|
|
41
|
+
# @param value [String] the header value
|
|
42
|
+
# @return [String] the value assigned to the header
|
|
43
|
+
def set_header!(header, value)
|
|
44
|
+
@operation[header] = value
|
|
45
|
+
end
|
|
46
|
+
|
|
44
47
|
def derived(name)
|
|
45
48
|
raise Linzer::Error, "Sub-classes are required to implement this method!"
|
|
46
49
|
end
|
|
@@ -20,14 +20,6 @@ module Linzer
|
|
|
20
20
|
@operation.headers[name]
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
# Attaches a signature to the response.
|
|
24
|
-
# @param signature [Signature] The signature to attach
|
|
25
|
-
# @return [Object] The underlying response object
|
|
26
|
-
def attach!(signature)
|
|
27
|
-
signature.to_h.each { |h, v| @operation.headers[h] = v }
|
|
28
|
-
@operation
|
|
29
|
-
end
|
|
30
|
-
|
|
31
23
|
private
|
|
32
24
|
|
|
33
25
|
# Retrieves an HTTP field value from the request or response headers.
|
|
@@ -41,6 +33,17 @@ module Linzer
|
|
|
41
33
|
value = @operation.headers[name.value.to_s]
|
|
42
34
|
value.dup&.strip
|
|
43
35
|
end
|
|
36
|
+
|
|
37
|
+
# Sets a header on the underlying HTTP message.
|
|
38
|
+
#
|
|
39
|
+
# If a header with the given name already exists, its value is overwritten.
|
|
40
|
+
#
|
|
41
|
+
# @param header [String] the header name
|
|
42
|
+
# @param value [String] the header value
|
|
43
|
+
# @return [String] the value assigned to the header
|
|
44
|
+
def set_header!(header, value)
|
|
45
|
+
@operation.headers[header] = value
|
|
46
|
+
end
|
|
44
47
|
end
|
|
45
48
|
end
|
|
46
49
|
end
|
|
@@ -27,14 +27,17 @@ module Linzer
|
|
|
27
27
|
@operation.get_header(rack_header_name(name))
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
# Sets a header on the underlying HTTP message.
|
|
33
|
+
#
|
|
34
|
+
# If a header with the given name already exists, its value is overwritten.
|
|
35
|
+
#
|
|
36
|
+
# @param header [String] the header name
|
|
37
|
+
# @param value [String] the header value
|
|
38
|
+
# @return [String] the value assigned to the header
|
|
39
|
+
def set_header!(header, value)
|
|
40
|
+
@operation.set_header(rack_header_name(header), value)
|
|
38
41
|
end
|
|
39
42
|
end
|
|
40
43
|
end
|
|
@@ -28,14 +28,17 @@ module Linzer
|
|
|
28
28
|
@operation.get_header(name)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
#
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
# Sets a header on the underlying HTTP message.
|
|
34
|
+
#
|
|
35
|
+
# If a header with the given name already exists, its value is overwritten.
|
|
36
|
+
#
|
|
37
|
+
# @param header [String] the header name
|
|
38
|
+
# @param value [String] the header value
|
|
39
|
+
# @return [String] the value assigned to the header
|
|
40
|
+
def set_header!(header, value)
|
|
41
|
+
@operation.set_header(header, value)
|
|
39
42
|
end
|
|
40
43
|
end
|
|
41
44
|
end
|
data/lib/linzer/version.rb
CHANGED
data/lib/linzer.rb
CHANGED
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.9
|
|
4
|
+
version: 0.7.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Miguel Landaeta
|
|
@@ -63,26 +63,6 @@ dependencies:
|
|
|
63
63
|
- - ">="
|
|
64
64
|
- !ruby/object:Gem::Version
|
|
65
65
|
version: 1.0.2
|
|
66
|
-
- !ruby/object:Gem::Dependency
|
|
67
|
-
name: stringio
|
|
68
|
-
requirement: !ruby/object:Gem::Requirement
|
|
69
|
-
requirements:
|
|
70
|
-
- - "~>"
|
|
71
|
-
- !ruby/object:Gem::Version
|
|
72
|
-
version: '3.1'
|
|
73
|
-
- - ">="
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: 3.1.2
|
|
76
|
-
type: :runtime
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '3.1'
|
|
83
|
-
- - ">="
|
|
84
|
-
- !ruby/object:Gem::Version
|
|
85
|
-
version: 3.1.2
|
|
86
66
|
- !ruby/object:Gem::Dependency
|
|
87
67
|
name: logger
|
|
88
68
|
requirement: !ruby/object:Gem::Requirement
|