binxtils 0.5.2 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8af9c778119b7f329d28122fcdaf2957914abe72ee7b43fde8a5b5e25a0e6294
4
- data.tar.gz: 9573e86af8de64e62d98cb64c47c59040897fe3202d2b1167b740404301d270f
3
+ metadata.gz: 5d72b64353d985a2d1473b717fe1adff0e04c89af0d62ef6b5a1a1af9d274509
4
+ data.tar.gz: dc3707cc25fd903d65bddca88af6eeea7ea1e05abad11ae17f9f53b2afacc880
5
5
  SHA512:
6
- metadata.gz: 3439600aa1a4add439671f2dcee1434f4627d9968645b05634f734d643d007fbec2a5eb40b93192b457edc0a14bcbab3b4ed4e64a05d5f560a0f1df924fe2fe0
7
- data.tar.gz: 6e77b0e688d8c58b5d9bdc20d636ad743f95bd4b7218c49b97ad86c8011010aa8d116414ecd1206f6e2d6ecb855c7587bbbca46938485c820a004aba0edcd7e9
6
+ metadata.gz: 965dbfb38c5dc90180f92ebd1ca5a1403d39cc4688183c42ee474d859efc396387453eec0647ec04a67b57df64a10b05bf29b99294a5d72c2f6f4e80b35f1a9f
7
+ data.tar.gz: b3a516d70a73ae33f9d4486f23c292f6f644c4a341e591c07d83d67737813e1cda77b6f3649a268887bd6902e611cbabe83f0ae76c291ab339f825c790e365d4
data/README.md CHANGED
@@ -9,6 +9,7 @@ gem "binxtils"
9
9
  ## Modules
10
10
 
11
11
  - **Binxtils::InputNormalizer** - Sanitize and normalize user input strings
12
+ - **Binxtils::Secure** - Constant-time comparison of a value against an expected secret
12
13
  - **Binxtils::TimeParser** - Parse fuzzy time/date strings into `Time` objects
13
14
  - **Binxtils::TimeZoneParser** - Parse and resolve time zone strings
14
15
 
@@ -20,6 +21,7 @@ These modules use [Functionable](https://github.com/sethherr/functionable) and a
20
21
  Binxtils::TimeParser.parse("next thursday")
21
22
  Binxtils::InputNormalizer.string(" Some Input ")
22
23
  Binxtils::TimeZoneParser.parse("Eastern Time")
24
+ Binxtils::Secure.compare?(params[:token], ENV["WEBHOOK_TOKEN"])
23
25
  ```
24
26
 
25
27
  ### Rails concerns
@@ -59,9 +61,18 @@ end
59
61
 
60
62
  ## npm package
61
63
 
62
- This repo also publishes `@bikeindex/time-localizer`, an npm package for localizing time elements in the browser. Luxon is bundled into the published package, so consumers don't need to install it separately.
64
+ This repo also publishes `@bikeindex/time-localizer`, an npm package for localizing time elements in the browser. It ships two builds of the same source:
63
65
 
64
- To publish a new version: update the version in `package.json`, then run `npm publish` from the repo root (requires npm login with access to the `@bikeindex` scope). The `prepublishOnly` script automatically builds `dist/index.js` before publishing.
66
+ | Build | Luxon | Use when |
67
+ | --- | --- | --- |
68
+ | `dist/index.js` (default) | external — install it yourself | You have a bundler. Luxon stays deduped with your own copy, so `Settings.defaultLocale`, `Settings.now` etc. apply to both. |
69
+ | `dist/index.bundle.js` | bundled in | You have no bundler (e.g. importmap-rails). One request, nothing to resolve. |
70
+
71
+ Import the default as `@bikeindex/time-localizer` and the standalone as `@bikeindex/time-localizer/bundle`, or reference either file path directly over a CDN.
72
+
73
+ Don't use the bundled build alongside your own Luxon: you'd ship two copies, and because Luxon's `Settings` are module-scoped, your global config would silently apply to only one of them.
74
+
75
+ To publish a new version: update the version in `package.json`, then run `npm publish` from the repo root (requires npm login with access to the `@bikeindex` scope). The `prepublishOnly` script builds both artifacts before publishing.
65
76
 
66
77
  ## Releasing
67
78
 
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Binxtils
4
+ module Secure
5
+ extend Functionable
6
+
7
+ def compare?(value, expected)
8
+ expected.present? && ActiveSupport::SecurityUtils.secure_compare(value.to_s, expected.to_s)
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Binxtils
4
- VERSION = "0.5.2"
4
+ VERSION = "0.6.0"
5
5
  end
data/lib/binxtils.rb CHANGED
@@ -4,10 +4,12 @@ require "functionable"
4
4
  require "active_support"
5
5
  require "active_support/core_ext"
6
6
  require "active_record"
7
+ require "active_support/security_utils"
7
8
  require "loofah"
8
9
  require "rails-html-sanitizer"
9
10
 
10
11
  require_relative "binxtils/input_normalizer"
12
+ require_relative "binxtils/secure"
11
13
  require_relative "binxtils/time_zone_parser"
12
14
  require_relative "binxtils/time_parser"
13
15
  require "binxtils/set_period"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: binxtils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bike Index
@@ -81,6 +81,7 @@ files:
81
81
  - lib/binxtils.rb
82
82
  - lib/binxtils/engine.rb
83
83
  - lib/binxtils/input_normalizer.rb
84
+ - lib/binxtils/secure.rb
84
85
  - lib/binxtils/time_parser.rb
85
86
  - lib/binxtils/time_zone_parser.rb
86
87
  - lib/binxtils/version.rb