wave-dispatch 0.4.1 → 0.4.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/wave_dispatch.rb +6 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 95acf7cef0856e85acae48205e63ff6c189401d70f1522620913f2a03e0c882b
4
- data.tar.gz: 1f3e3de91593113d5be872f50996b9fc002e6a7f0843962ce6392aa5dc3267eb
3
+ metadata.gz: 1fd26b4979ac3ed427931f9c252e36a4b95baeb7e791bda8de0794828f40695a
4
+ data.tar.gz: 903f7c9da83728d1bb489f4af52b27763fee4be2c7739a4e0121d43d4a44107a
5
5
  SHA512:
6
- metadata.gz: 9476819a8d1df712150556e7621c06b5afddccaa347b57901772af549928234257f9d8c0c9763fa179c6493ed2555750731a35e4167ac5e267b055affd9f5f0a
7
- data.tar.gz: 91c660f8fc044fb34af84288c1817966083e7cd16e20b5a3272fafc93d5659de373ccd96636c71902ab3c1808c19503561548b4654bc8b9b5734eda79fa85d01
6
+ metadata.gz: 72ac4dda805c6cc4df28108070b2e1d2ed73cd106248fc70f0aac6046564550ec3efa22787a42029cea39ab894ab3fb804364702c9869c5bba1a906b672f6acf
7
+ data.tar.gz: 41cfb28c916af48ff7e0f120d1d2b06de3accba7174f6c464b78399237bd3013489bc031dea96c8f6d8fba97a15ee3c7bb62452bd9956ad4d26632aa4df34724
data/lib/wave_dispatch.rb CHANGED
@@ -3,9 +3,10 @@
3
3
  require "net/http"
4
4
  require "json"
5
5
  require "uri"
6
+ require "openssl"
6
7
 
7
8
  module WaveDispatch
8
- VERSION = "0.2.0"
9
+ VERSION = "0.4.2"
9
10
 
10
11
  class Client
11
12
  def initialize(license = ENV["WAVE_LICENSE"], endpoint: "https://dispatch.wave.online",
@@ -42,9 +43,12 @@ module WaveDispatch
42
43
  req = (method == :post ? Net::HTTP::Post : Net::HTTP::Get).new(uri, "content-type" => "application/json")
43
44
  req["authorization"] = "Bearer #{@license}" if @license
44
45
  req.body = body.to_json if body
45
- res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") { |h| h.request(req) }
46
+ res = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https",
47
+ verify_mode: OpenSSL::SSL::VERIFY_PEER) { |h| h.request(req) }
46
48
  raise "dispatch: 402 payment required (x402)" if res.code == "402"
47
49
  raise "dispatch: 401 unauthorized — set a valid license" if res.code == "401"
50
+ # any other non-2xx must raise — never JSON.parse an error body and return it as a success result
51
+ raise "dispatch: #{res.code} #{res.body.to_s[0, 160]}" unless res.code.start_with?("2")
48
52
  JSON.parse(res.body)
49
53
  end
50
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wave-dispatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - WAVE Online, LLC