line-bot-api 0.1.0 → 0.1.1

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: 0cd22ba8ed93ba3f1577f70a5095439755dda529
4
- data.tar.gz: 75eae8e81a15b2e6d950487dd18516aea4fd95f9
3
+ metadata.gz: 53328dc34338632959e4d41e639b22fb47c0c2b5
4
+ data.tar.gz: ce8777fa1029e0ab4094e86591684795911f0089
5
5
  SHA512:
6
- metadata.gz: dce0e680763a9d4929580cdb9e0fb75ee7591071d95d2687496e696dbc5ffe666e51644e615c94a31934ffe53e7c66e1e73739fe826dae62471678e114163842
7
- data.tar.gz: 7a9538fb64eed37b366366658af3707dce8664e3b26967db41809c2bd0379ec476a60f2359e97f8eb029f6c0c963cd802621492b38e67fd0be6086b59912168b
6
+ metadata.gz: c9edcef377b3c0cbc1a70260eec62addfb93b4bf4353ca19b45ffc0545008b328369d8428fb0d36b776914c6ca933eff6cc4296b56c861d6f520b92aa02554a5
7
+ data.tar.gz: b577b38f12b817325958a474578010c404c9069d93409d0d32e6593210e50f5b76c2df33656c32a62498483449aa30d977e535c589ccd009ae917771632c83e0
data/README.md CHANGED
@@ -1,6 +1,24 @@
1
- # LINE::Bot::API
1
+ # Line::Bot::API
2
2
 
3
- LINE::Bot::API - SDK of the LINE BOT API Trial for Ruby
3
+ Line::Bot::API - SDK of the LINE BOT API Trial for Ruby
4
+
5
+ [![Gem-version](https://img.shields.io/gem/v/line-bot-api.svg)](https://rubygems.org/gems/) [![Build Status](https://travis-ci.org/line/line-bot-sdk-ruby.svg?branch=master)](https://travis-ci.org/line/line-bot-sdk-ruby)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'line-bot-api'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install line-bot-api
4
22
 
5
23
  ## Configuration
6
24
 
@@ -201,8 +219,7 @@ Get the preview image file which was sent by user.
201
219
  ```
202
220
  user_profile = client.get_user_profile("1234567")
203
221
  user_profile #=> [Line::Bot::Response::User::Profile]
204
- contacts = user_profile.contacts
205
- contacts #=> [Array] Line::Bot::Response::User::Contacts
222
+ user_profile.contacts #=> [Array] Line::Bot::Response::User::Contact
206
223
  ```
207
224
 
208
225
  ## License
@@ -1,7 +1,7 @@
1
1
  module Line
2
2
  module Bot
3
3
  module API
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
@@ -241,7 +241,26 @@ module Line
241
241
  hash = OpenSSL::HMAC::digest(OpenSSL::Digest::SHA256.new, channel_secret, content)
242
242
  signature = Base64.strict_encode64(hash)
243
243
 
244
- channel_signature == signature
244
+ variable_secure_compare(channel_signature, signature)
245
+ end
246
+
247
+ private
248
+ # Constant time string comparison.
249
+ #
250
+ # via timing attacks.
251
+ # reference: https://github.com/rails/rails/blob/master/activesupport/lib/active_support/security_utils.rb
252
+ def variable_secure_compare(a, b)
253
+ secure_compare(::Digest::SHA256.hexdigest(a), ::Digest::SHA256.hexdigest(b))
254
+ end
255
+
256
+ def secure_compare(a, b)
257
+ return false unless a.bytesize == b.bytesize
258
+
259
+ l = a.unpack "C#{a.bytesize}"
260
+
261
+ res = 0
262
+ b.each_byte { |byte| res |= byte ^ l.shift }
263
+ res == 0
245
264
  end
246
265
  end
247
266
 
@@ -2,7 +2,7 @@ module Line
2
2
  module Bot
3
3
  module Receive
4
4
  class Message
5
- attr_reader :id, :from_mid, :to_mid, :from_channel_id, :to_channel_id, :event_type, :content
5
+ attr_reader :id, :from_mid, :to_mid, :from_channel_id, :to_channel_id, :event_type, :created_time, :content
6
6
 
7
7
  def initialize(env)
8
8
  @id = env['content']['id']
@@ -13,6 +13,10 @@ module Line
13
13
  @to_channel_id = env['toChannel']
14
14
 
15
15
  @event_type = env['eventType']
16
+
17
+ (time, usec) = env['content']['createdTime'].to_i.divmod(1000)
18
+ @created_time = Time.at(time, usec)
19
+
16
20
  @content = create_content(env['content'])
17
21
  end
18
22
 
data/line-bot-api.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.required_ruby_version = '>= 2.0.0'
22
+
21
23
  spec.add_dependency 'rack', '~> 1.6.4'
22
24
 
23
25
  spec.add_development_dependency "bundler", "~> 1.11"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: line-bot-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - LINE Corporation
@@ -91,13 +91,14 @@ files:
91
91
  - CODE_OF_CONDUCT.md
92
92
  - LICENSE
93
93
  - README.md
94
- - line-bot-api.gemspec
94
+ - lib/line/bot.rb
95
95
  - lib/line/bot/api/errors.rb
96
96
  - lib/line/bot/api/version.rb
97
97
  - lib/line/bot/builder/multiple_message.rb
98
98
  - lib/line/bot/builder/rich_message.rb
99
99
  - lib/line/bot/client.rb
100
100
  - lib/line/bot/event_type.rb
101
+ - lib/line/bot/message.rb
101
102
  - lib/line/bot/message/audio.rb
102
103
  - lib/line/bot/message/base.rb
103
104
  - lib/line/bot/message/content_type.rb
@@ -106,19 +107,18 @@ files:
106
107
  - lib/line/bot/message/sticker.rb
107
108
  - lib/line/bot/message/text.rb
108
109
  - lib/line/bot/message/video.rb
109
- - lib/line/bot/message.rb
110
+ - lib/line/bot/operation.rb
110
111
  - lib/line/bot/operation/add_friend.rb
111
112
  - lib/line/bot/operation/base.rb
112
113
  - lib/line/bot/operation/block_account.rb
113
114
  - lib/line/bot/operation/op_type.rb
114
- - lib/line/bot/operation.rb
115
115
  - lib/line/bot/receive/message.rb
116
116
  - lib/line/bot/receive/operation.rb
117
117
  - lib/line/bot/receive/request.rb
118
118
  - lib/line/bot/request.rb
119
119
  - lib/line/bot/response/user/contact.rb
120
120
  - lib/line/bot/response/user/profile.rb
121
- - lib/line/bot.rb
121
+ - line-bot-api.gemspec
122
122
  homepage: https://github.com/line/line-bot-sdk-ruby
123
123
  licenses:
124
124
  - Apache License, Version 2.0
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  requirements:
132
132
  - - '>='
133
133
  - !ruby/object:Gem::Version
134
- version: '0'
134
+ version: 2.0.0
135
135
  required_rubygems_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - '>='
@@ -139,9 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.0.14.1
142
+ rubygems_version: 2.4.8
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: LINE::Bot::API - SDK of the LINE BOT API
146
146
  test_files: []
147
- has_rdoc: