digest_fields 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ea76394e2f56ef9da13f17ae08ee86e8f85f157fdf8b10dbb7cd2eb69256e47b
4
+ data.tar.gz: e0ba82e591f64ab9a12c0003a1b224cbe242e71816e5ac6f42f089a168af39bf
5
+ SHA512:
6
+ metadata.gz: 809b925c68acdb80c3a178889970bcb3bf8d8e9b72cae9eea48c46554424d9b476109491e0020a4b9c10eb53fdadcff7e2336b26c46e9b2fe37cb4ea7a1f1ebf
7
+ data.tar.gz: a32ea12572fb2c7bc6fe3f2006910b2cd604dd81d71c2736ab8cf4f936fc1c5793b2f554487b176abebcd23f99645c8363f7108e615921cf6ae913959874d859
checksums.yaml.gz.sig ADDED
Binary file
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2026-02-28
4
+
5
+ - Initial release
@@ -0,0 +1,10 @@
1
+ # Code of Conduct
2
+
3
+ "digest_fields" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
+
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
9
+
10
+ If you have any concerns about behaviour within this project, please contact us at ["aupajo@gmail.com"](mailto:"aupajo@gmail.com").
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Pete Nicholls
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # Digest Fields
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/digest_fields.svg)](https://badge.fury.io/rb/digest_fields)
4
+
5
+ Support for `Content-Digest` and `Repl-Digest` header digests that follows the [RFC 9530](https://www.rfc-editor.org/rfc/rfc9530.html) specification.
6
+
7
+ > [!WARNING]
8
+ > This library currently only offers low-level primitives, and does not interact with Rack, does not set headers or trailers, or decide what consistitues content to digest. This is currently an exercise left to the user.
9
+
10
+ ## Usage
11
+
12
+ ### Library
13
+
14
+ ```ruby
15
+ digest = DigestFields.digest(body)
16
+ digest.to_s # => "sha-256=:X48E9qOok...:, sha-512=:jas48SD...:"
17
+
18
+ digest = DigestFields.digest(body, algorithms: [:sha256])
19
+ digest.to_s # => "sha-256=:X48E9qOok...:
20
+ ```
21
+
22
+ ## Installation
23
+
24
+ Add to your project's `Gemfile`:
25
+
26
+ ```bash
27
+ bundle add digest_fields
28
+ ```
29
+
30
+ Or, install gem directly:
31
+
32
+ ```bash
33
+ gem install digest_fields
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/aupajo/digest_fields. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/aupajo/digest_fields/blob/main/CODE_OF_CONDUCT.md).
45
+
46
+ ## License
47
+
48
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
49
+
50
+ ## Code of Conduct
51
+
52
+ Everyone interacting in the DigestFields project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/aupajo/digest_fields/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require "standard/rake"
7
+
8
+ task default: %i[spec standard]
data/certs/aupajo.pem ADDED
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEaDCCAtCgAwIBAgIBATANBgkqhkiG9w0BAQsFADA9MQ8wDQYDVQQDDAZhdXBh
3
+ am8xFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2NvbTAe
4
+ Fw0yNjAzMDEwMjA3MDVaFw0yNzAzMDEwMjA3MDVaMD0xDzANBgNVBAMMBmF1cGFq
5
+ bzEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29tMIIB
6
+ ojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAoNMWP6HfUURqWyFbQu5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XVCfLW1kjExBGNmYMU236ZTFDJ+zRbpyuGIICz9I
23
+ jxF6y1i3IOL1W1iDfyahqNGB/VYe6oxx7r8+9+27xjriby9NWbFVdvmHsTxap9U4
24
+ Btq0DeYxN1nivUwGxfgXhYMfsvVPXteER6vZumzsOghBmkc9C5q0T1bWmWkLV+RC
25
+ IceGwNDMSZadLPqSF9SpTcoJO8dEH2Qe0FhKTw==
26
+ -----END CERTIFICATE-----
@@ -0,0 +1,24 @@
1
+ module DigestFields::Digestion
2
+ ALGORITHMS = {
3
+ sha256: ->(body) { Digest::SHA256.base64digest(body) },
4
+ sha512: ->(body) { Digest::SHA512.base64digest(body) }
5
+ }
6
+
7
+ module_function
8
+
9
+ def compute(body, algorithms: %i[sha256 sha512])
10
+ algorithms = [algorithms].flatten
11
+
12
+ algorithms.map do |algorithm|
13
+ key = algorithm.to_s.sub(/(\d+)$/, '-\1')
14
+
15
+ algorithm = ALGORITHMS.fetch(algorithm) do
16
+ raise ArgumentError, "#{algorithm.inspect} not available (try one of: #{ALGORITHMS.keys.join(", ")})"
17
+ end
18
+
19
+ digest = algorithm.call(body)
20
+
21
+ "#{key}=:#{digest}:"
22
+ end.join(", ")
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module DigestFields
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,12 @@
1
+ require "digest"
2
+
3
+ module DigestFields
4
+ module_function
5
+
6
+ def digest(*, **)
7
+ Digestion.compute(*, **)
8
+ end
9
+ end
10
+
11
+ require_relative "digest_fields/version"
12
+ require_relative "digest_fields/digestion"
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: digest_fields
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pete Nicholls
8
+ bindir: exe
9
+ cert_chain:
10
+ - |
11
+ -----BEGIN CERTIFICATE-----
12
+ MIIEaDCCAtCgAwIB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Wv2ohkUZ+gSZ
28
+ xt8k7TTIcUYUUvrBBtX22SHykwXpKmllCIk7n2plLNVBM0x0wP1YqKPqi78HVSds
29
+ j8QoBoEqP5MX1nqOBuHV+ygLVWDW7j47WiVG0ec2A8cyhY9YV+9YAZUvHFUM49Ds
30
+ J4mrIabwRdxikaRtDuIrvNOSF7UXtwh+jI7gVAY6fXP5g6zV/uUXHrYoo9b5NlPI
31
+ 2w0L6HGDAg/l5mkQzYq9Eew528BxFLiGec3K4AF79Zb/P3DMXt81uZdiFoBGPu6U
32
+ 4xzqi41vEpMbhUWdYefasXl3XVCfLW1kjExBGNmYMU236ZTFDJ+zRbpyuGIICz9I
33
+ jxF6y1i3IOL1W1iDfyahqNGB/VYe6oxx7r8+9+27xjriby9NWbFVdvmHsTxap9U4
34
+ Btq0DeYxN1nivUwGxfgXhYMfsvVPXteER6vZumzsOghBmkc9C5q0T1bWmWkLV+RC
35
+ IceGwNDMSZadLPqSF9SpTcoJO8dEH2Qe0FhKTw==
36
+ -----END CERTIFICATE-----
37
+ date: 1980-01-02 00:00:00.000000000 Z
38
+ dependencies: []
39
+ email:
40
+ - aupajo@gmail.com
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - CHANGELOG.md
46
+ - CODE_OF_CONDUCT.md
47
+ - LICENSE.txt
48
+ - README.md
49
+ - Rakefile
50
+ - certs/aupajo.pem
51
+ - lib/digest_fields.rb
52
+ - lib/digest_fields/digestion.rb
53
+ - lib/digest_fields/version.rb
54
+ homepage: https://github.com/aupajo/digest_fields
55
+ licenses:
56
+ - MIT
57
+ metadata:
58
+ allowed_push_host: https://rubygems.org
59
+ homepage_uri: https://github.com/aupajo/digest_fields
60
+ source_code_uri: https://github.com/aupajo/digest_fields
61
+ changelog_uri: https://github.com/aupajo/digest_fields
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 3.2.0
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 4.0.3
77
+ specification_version: 4
78
+ summary: Content-Digest header support following Digest Fields spec (RFC 9530)
79
+ test_files: []
metadata.gz.sig ADDED
Binary file