active_hashcash 0.6.0 → 0.6.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/app/models/active_hashcash/stamp.rb +4 -0
- data/lib/active_hashcash/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: abcb93cb16e4d2dd9dd6b7ac7706f4aa9ad03543828c2a67490f3cdba49d5c1c
|
|
4
|
+
data.tar.gz: f004201911b2a75db4bbcaf002a697c4c55e8e139a51c348a28b845d65f3f22a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a156de1587f52cc2f4f03ac10dae94146d3dc10f2da06aba6663931b00c6789b20c04897ed78f43dda2cfeb89153e6222f18080cb26adfa423552cb2203db8c
|
|
7
|
+
data.tar.gz: cd56b11ebd6fc83f647a292969bda59e9806afae9b5502adaf95d5bdf1f8b62a22ea74206d98714cfca0ddbbd0ba1a6fff2112467af028c5b82261dcbaf718e9
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog of ActiveHashcash
|
|
2
2
|
|
|
3
|
+
## 0.6.1 (2026-11-11)
|
|
4
|
+
|
|
5
|
+
- Reject non-canonical stamps so one proof of work cannot be spent multiple times (@schmijos)
|
|
6
|
+
- Treat unparsable stamp dates as invalid hashcash instead of raising a server error (@schmijos)
|
|
7
|
+
- Cap stamp field lengths to prevent storage bloat and index overflow errors (@schmijos)
|
|
8
|
+
|
|
3
9
|
## 0.6.0 (2026-09-22)
|
|
4
10
|
|
|
5
11
|
- Penalize bad IPs reported by FireHOL lists. For this feature to do anything you must run the migration and schedule the sync job from a cron:
|
|
@@ -5,6 +5,7 @@ module ActiveHashcash
|
|
|
5
5
|
# Unless you need something really specific, you should not need interact directly with that class.
|
|
6
6
|
class Stamp < ApplicationRecord
|
|
7
7
|
validates_presence_of :version, :bits, :date, :resource, :rand, :counter
|
|
8
|
+
validates_length_of :version, :resource, :ext, :rand, :counter, maximum: 255
|
|
8
9
|
|
|
9
10
|
scope :created_from, -> (date) { where(created_at: date..) }
|
|
10
11
|
scope :created_to, -> (date) { where(created_at: ..date) }
|
|
@@ -48,6 +49,7 @@ module ActiveHashcash
|
|
|
48
49
|
# Saving in the database prevent from double spending the same stamp.
|
|
49
50
|
def self.spend(string, resource, bits, date, options = {})
|
|
50
51
|
return false unless stamp = parse(string)
|
|
52
|
+
return false if stamp.to_s != string.to_s
|
|
51
53
|
stamp.attributes = options
|
|
52
54
|
stamp.verify(resource, bits, date) && stamp.save
|
|
53
55
|
rescue ActiveRecord::RecordNotUnique
|
|
@@ -61,6 +63,8 @@ module ActiveHashcash
|
|
|
61
63
|
args = string.to_s.split(":")
|
|
62
64
|
return if args.size != 7
|
|
63
65
|
new(version: args[0], bits: args[1], date: Date.strptime(args[2], ActiveHashcash.date_format), resource: args[3], ext: args[4], rand: args[5], counter: args[6])
|
|
66
|
+
rescue Date::Error
|
|
67
|
+
nil
|
|
64
68
|
end
|
|
65
69
|
|
|
66
70
|
def self.mint(resource, attributes = {})
|