webpush 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e92718d71c8af0814d94b05cd58c9f8cd33fe3d3
4
- data.tar.gz: eb98e753a92b2ff88b1da5d11d2e1dac76ca1468
3
+ metadata.gz: 7e6ccc3dd4787eae13fbe2da57c74f0d9f9c5c46
4
+ data.tar.gz: 331ade4d71f9919f63984e1d2b746e73cda4d34a
5
5
  SHA512:
6
- metadata.gz: 22a36f491c7f711ca571679b822a7a21f2f5e31f51cee5e42e9cc0a1f5eae149ce822a25b6ee44d34e5437c880bce1a6223718274620a8ad6e93fa785aca76c6
7
- data.tar.gz: 07bca2ecbcd96810d91320559e922a0ad3c690ab5917f0aeacf7883c92b24257a0058c0feb365a226b2412b1671c974f8f1ab1c879a8664a632555438967376f
6
+ metadata.gz: e41e01d1e5018e304f53bcc3de50e2ad7c0e6906b9f46fad27248e98bf9e969f760a1f1b598721d3da303ca007b08debf01ed4f880f89035056dcaa4d86f999f
7
+ data.tar.gz: e48347fae1ea9fc2c14d13710b6ebe8344cc189189c135c1239110bc7d3404c20a791872687ee1f52c65299c8a53957c5de9bee52ef34f769a3bcad007a5f0db
data/.travis.yml CHANGED
@@ -3,3 +3,6 @@ rvm:
3
3
  - 2.3.0
4
4
  before_install: gem install bundler -v 1.11.2
5
5
  script: "bundle exec rake spec"
6
+ addons:
7
+ code_climate:
8
+ repo_token: 155202524386dfebe0c3267a5c868b5417ff4cc2cde8ed301fb36b177d46a458
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/zaru/webpush/badges/gpa.svg)](https://codeclimate.com/github/zaru/webpush)
4
4
  [![Build Status](https://travis-ci.org/zaru/webpush.svg?branch=master)](https://travis-ci.org/zaru/webpush)
5
+ [![Gem Version](https://badge.fury.io/rb/webpush.svg)](https://badge.fury.io/rb/webpush)
5
6
 
6
7
  This Gem will send the Web Push API. It supports the encryption necessary to payload.
7
8
 
@@ -39,6 +40,7 @@ Webpush.payload_send(
39
40
  message: JSON.generate(message),
40
41
  p256dh: "BO/aG9nYXNkZmFkc2ZmZHNmYWRzZmFl...",
41
42
  auth: "aW1hcmthcmFpa3V6ZQ==",
43
+ ttl: 600, #optional, ttl in seconds, defaults to 2419200 (4 weeks)
42
44
  api_key: "[GoogleDeveloper APIKEY]" # optional, not used in Firefox.
43
45
  )
44
46
  ```
@@ -48,6 +50,7 @@ Webpush.payload_send(
48
50
  ```ruby
49
51
  Webpush.payload_send(
50
52
  endpoint: "https://android.googleapis.com/gcm/send/eah7hak....",
53
+ ttl: 600, #optional, ttl in seconds, defaults to 2419200 (4 weeks)
51
54
  api_key: "[GoogleDeveloper APIKEY]" # optional, not used in Firefox.
52
55
  )
53
56
  ```
@@ -10,7 +10,12 @@ module Webpush
10
10
  uri = URI.parse(@endpoint)
11
11
  http = Net::HTTP.new(uri.host, uri.port)
12
12
  http.use_ssl = true
13
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
13
+ if @options[:cert_store]
14
+ http.cert_store = @options[:cert_store]
15
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
16
+ else
17
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
18
+ end
14
19
  req = Net::HTTP::Post.new(uri.request_uri, headers)
15
20
  req.body = body
16
21
  http.request(req)
@@ -49,7 +54,7 @@ module Webpush
49
54
  end
50
55
 
51
56
  def api_key?
52
- !(api_key.nil? || api_key.empty?)
57
+ !(api_key.nil? || api_key.empty?) && @endpoint =~ /\Ahttps:\/\/.+\.googleapis\.com/
53
58
  end
54
59
 
55
60
  def encrypted_payload?
@@ -1,3 +1,3 @@
1
1
  module Webpush
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webpush
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - zaru@sakuraba
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hkdf