line-bot-api 2.2.0 → 2.4.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: 44ce823e0e9998cc204a39d55321ec85e6b7903adcf7ed1630b222c69116566a
4
- data.tar.gz: 9a8119c82379fe431bc8ccaa4526e4647256f41179d3edd4022643712911ddc8
3
+ metadata.gz: be6eb3e791b7dcee332f13b1e1e4c42940b15b6518de39a5f7357fbdf74d4283
4
+ data.tar.gz: 2a320c486f1a21761aa04c7e80948fb95c3f8e19c283f8ca93249b1f649f2cf4
5
5
  SHA512:
6
- metadata.gz: 6999af99e5f87523518756b29690f4036762924037cf38cc1c11c614c8d2721a125b8c4b8046c9095f2efd38db5d6ceb2430f6e91de775f3e9f7d66c5a2a33c7
7
- data.tar.gz: a3dd071068394ed5dfd5f565f8dd1bdf1a306b8be83c99d10c503d704b9839b3df168b77a2ef0b5bb9fa14b1cdc5c6dfd92833663dbc6e227e4e0e91a5d94f27
6
+ metadata.gz: 441bc6461be06d17727b6451a3ae298a8995533397fad4d6b3eabe1e56035454b4288fcc0d4777f2749a1a157c01719a567c3fc4fe0216ecd695f46e7b396296
7
+ data.tar.gz: ed25dc17d4624daaf62deb3894584f66a224c4ce5d1df609cf0dd7f3c189a31fc03592955db9617765359876cbd81587990baf0977880f286995719332203af1
@@ -20,17 +20,23 @@ module Line
20
20
  # @!attribute [rw] up_to_remaining_quota
21
21
  # @return [Boolean,nil] If true, the message will be sent within the maximum number of deliverable messages. The default value is `false`. Targets will be selected at random.
22
22
  attr_accessor :up_to_remaining_quota
23
+ # @!attribute [rw] forbid_partial_delivery
24
+ # @return [Boolean,nil] This option prevents messages from being delivered to only a subset of the target audience. If true, the narrowcast request success but fails asynchronously. You can check whether message delivery was canceled by retrieving the narrowcast message progress. This property can be set to true only if upToRemainingQuota is set to true.
25
+ attr_accessor :forbid_partial_delivery
23
26
 
24
27
  # @param max [Integer,nil] The maximum number of narrowcast messages to send. Use this parameter to limit the number of narrowcast messages sent. The recipients will be chosen at random.
25
28
  # @param up_to_remaining_quota [Boolean,nil] If true, the message will be sent within the maximum number of deliverable messages. The default value is `false`. Targets will be selected at random.
29
+ # @param forbid_partial_delivery [Boolean,nil] This option prevents messages from being delivered to only a subset of the target audience. If true, the narrowcast request success but fails asynchronously. You can check whether message delivery was canceled by retrieving the narrowcast message progress. This property can be set to true only if upToRemainingQuota is set to true.
26
30
  def initialize(
27
31
  max: nil,
28
32
  up_to_remaining_quota: false,
33
+ forbid_partial_delivery: false,
29
34
  **dynamic_attributes
30
35
  )
31
36
 
32
37
  @max = max
33
38
  @up_to_remaining_quota = up_to_remaining_quota
39
+ @forbid_partial_delivery = forbid_partial_delivery
34
40
 
35
41
  dynamic_attributes.each do |key, value|
36
42
  self.class.attr_accessor key
@@ -29,7 +29,7 @@ module Line
29
29
  # @return [String,nil] The reason the message failed to be sent. This is only included with a `phase` property value of `failed`.
30
30
  attr_accessor :failed_description
31
31
  # @!attribute [rw] error_code
32
- # @return [Integer,nil] Error summary. This is only included with a phase property value of failed. One of: `1`: An internal error occurred. `2`: An error occurred because there weren't enough recipients. `3`: A conflict error of requests occurs because a request that has already been accepted is retried. `4`: An audience of less than 50 recipients is included as a condition of sending.
32
+ # @return [Integer,nil] Error summary. This is only included with a phase property value of failed. One of: `1`: An internal error occurred. `2`: An error occurred because there weren't enough recipients. `3`: A conflict error of requests occurs because a request that has already been accepted is retried. `4`: An audience of less than 50 recipients is included as a condition of sending. `5`: Message delivery has been canceled to prevent messages from being delivered only to a subset of the target audience.
33
33
  attr_accessor :error_code
34
34
  # @!attribute [rw] accepted_time
35
35
  # @return [String] Narrowcast message request accepted time in milliseconds. Format: ISO 8601 (e.g. 2020-12-03T10:15:30.121Z) Timezone: UTC
@@ -43,7 +43,7 @@ module Line
43
43
  # @param failure_count [Integer,nil] The number of users who failed to send the message.
44
44
  # @param target_count [Integer,nil] The number of intended recipients of the message.
45
45
  # @param failed_description [String,nil] The reason the message failed to be sent. This is only included with a `phase` property value of `failed`.
46
- # @param error_code [Integer,nil] Error summary. This is only included with a phase property value of failed. One of: `1`: An internal error occurred. `2`: An error occurred because there weren't enough recipients. `3`: A conflict error of requests occurs because a request that has already been accepted is retried. `4`: An audience of less than 50 recipients is included as a condition of sending.
46
+ # @param error_code [Integer,nil] Error summary. This is only included with a phase property value of failed. One of: `1`: An internal error occurred. `2`: An error occurred because there weren't enough recipients. `3`: A conflict error of requests occurs because a request that has already been accepted is retried. `4`: An audience of less than 50 recipients is included as a condition of sending. `5`: Message delivery has been canceled to prevent messages from being delivered only to a subset of the target audience.
47
47
  # @param accepted_time [String] Narrowcast message request accepted time in milliseconds. Format: ISO 8601 (e.g. 2020-12-03T10:15:30.121Z) Timezone: UTC
48
48
  # @param completed_time [String,nil] Processing of narrowcast message request completion time in milliseconds. Returned when the phase property is succeeded or failed. Format: ISO 8601 (e.g. 2020-12-03T10:15:30.121Z) Timezone: UTC
49
49
  def initialize(
@@ -11,8 +11,20 @@ module Line
11
11
  class WebhookParser
12
12
  class InvalidSignatureError < StandardError; end
13
13
 
14
- def initialize(channel_secret:)
14
+ # Initialize webhook parser
15
+ #
16
+ # @param channel_secret [String]
17
+ # The channel secret used for signature verification.
18
+ # @param skip_signature_verification [() -> bool, nil]
19
+ # A callable object with type `() -> bool` that determines whether to skip
20
+ # webhook signature verification. Signature verification is skipped if and
21
+ # only if this callable is provided and returns `true`.
22
+ # This can be useful in scenarios such as when you're in the process of
23
+ # updating the channel secret and need to temporarily bypass verification
24
+ # to avoid disruptions.
25
+ def initialize(channel_secret:, skip_signature_verification: nil)
15
26
  @channel_secret = channel_secret
27
+ @skip_signature_verification = skip_signature_verification
16
28
  end
17
29
 
18
30
  # Parse events from the raw request body and validate the signature.
@@ -31,7 +43,10 @@ module Line
31
43
  #
32
44
  # @example Sinatra usage
33
45
  # def parser
34
- # @parser ||= Line::Bot::V2::WebhookParser.new(channel_secret: ENV.fetch("LINE_CHANNEL_SECRET"))
46
+ # @parser ||= Line::Bot::V2::WebhookParser.new(
47
+ # channel_secret: ENV.fetch("LINE_CHANNEL_SECRET"),
48
+ # skip_signature_verification: -> { ENV['SKIP_SIGNATURE_VERIFICATION'] == 'true' }
49
+ # )
35
50
  # end
36
51
  #
37
52
  # post '/callback' do
@@ -54,7 +69,11 @@ module Line
54
69
  # "OK"
55
70
  # end
56
71
  def parse(body:, signature:)
57
- raise InvalidSignatureError.new("Invalid signature: #{signature}") unless verify_signature(body: body, signature: signature)
72
+ should_skip = @skip_signature_verification&.call || false
73
+
74
+ unless should_skip == true || verify_signature(body: body, signature: signature)
75
+ raise InvalidSignatureError.new("Invalid signature: #{signature}")
76
+ end
58
77
 
59
78
  data = JSON.parse(body.chomp, symbolize_names: true)
60
79
  data = Line::Bot::V2::Utils.deep_underscore(data)
@@ -66,14 +85,14 @@ module Line
66
85
  end
67
86
  end
68
87
 
69
- private
70
-
71
88
  def verify_signature(body:, signature:)
72
89
  hash = OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'), @channel_secret, body)
73
90
  expected = Base64.strict_encode64(hash)
74
91
  variable_secure_compare(signature, expected)
75
92
  end
76
93
 
94
+ private
95
+
77
96
  # To avoid timing attacks
78
97
  def variable_secure_compare(a, b)
79
98
  secure_compare(::Digest::SHA256.hexdigest(a), ::Digest::SHA256.hexdigest(b))
@@ -2,6 +2,6 @@ module Line
2
2
  module Bot
3
3
  # This version is updated before releasing a new version in the release process.
4
4
  # You don't have to update this version manually.
5
- VERSION = "2.2.0"
5
+ VERSION = "2.4.0"
6
6
  end
7
7
  end
@@ -16,13 +16,16 @@ module Line
16
16
  class Limit
17
17
  attr_accessor max: Integer?
18
18
  attr_accessor up_to_remaining_quota: bool?
19
+ attr_accessor forbid_partial_delivery: bool?
19
20
 
20
21
 
21
22
  # @param max [Integer,nil] The maximum number of narrowcast messages to send. Use this parameter to limit the number of narrowcast messages sent. The recipients will be chosen at random.
22
23
  # @param up_to_remaining_quota [bool,nil] If true, the message will be sent within the maximum number of deliverable messages. The default value is `false`. Targets will be selected at random.
24
+ # @param forbid_partial_delivery [bool,nil] This option prevents messages from being delivered to only a subset of the target audience. If true, the narrowcast request success but fails asynchronously. You can check whether message delivery was canceled by retrieving the narrowcast message progress. This property can be set to true only if upToRemainingQuota is set to true.
23
25
  def initialize: (
24
26
  ?max: Integer?,
25
27
  ?up_to_remaining_quota: bool?,
28
+ ?forbid_partial_delivery: bool?,
26
29
  **untyped dynamic_attributes
27
30
  ) -> void
28
31
 
@@ -28,7 +28,7 @@ module Line
28
28
  # @param failure_count [Integer,nil] The number of users who failed to send the message.
29
29
  # @param target_count [Integer,nil] The number of intended recipients of the message.
30
30
  # @param failed_description [String,nil] The reason the message failed to be sent. This is only included with a `phase` property value of `failed`.
31
- # @param error_code [Integer,nil] Error summary. This is only included with a phase property value of failed. One of: `1`: An internal error occurred. `2`: An error occurred because there weren't enough recipients. `3`: A conflict error of requests occurs because a request that has already been accepted is retried. `4`: An audience of less than 50 recipients is included as a condition of sending.
31
+ # @param error_code [Integer,nil] Error summary. This is only included with a phase property value of failed. One of: `1`: An internal error occurred. `2`: An error occurred because there weren't enough recipients. `3`: A conflict error of requests occurs because a request that has already been accepted is retried. `4`: An audience of less than 50 recipients is included as a condition of sending. `5`: Message delivery has been canceled to prevent messages from being delivered only to a subset of the target audience.
32
32
  # @param accepted_time [String] Narrowcast message request accepted time in milliseconds. Format: ISO 8601 (e.g. 2020-12-03T10:15:30.121Z) Timezone: UTC
33
33
  # @param completed_time [String,nil] Processing of narrowcast message request completion time in milliseconds. Returned when the phase property is succeeded or failed. Format: ISO 8601 (e.g. 2020-12-03T10:15:30.121Z) Timezone: UTC
34
34
  def initialize: (
@@ -5,18 +5,19 @@ module Line
5
5
  class InvalidSignatureError < ::StandardError
6
6
  end
7
7
  @channel_secret: String
8
+ @skip_signature_verification: (^() -> bool) | nil
8
9
 
9
- def initialize: (channel_secret: String) -> void
10
+ def initialize: (channel_secret: String, ?skip_signature_verification: (^() -> bool) | nil) -> void
10
11
 
11
12
  def parse: (
12
13
  body: String,
13
14
  signature: String
14
15
  ) -> Array[Webhook::Event]
16
+
17
+ def verify_signature: (body: String, signature: String) -> bool
15
18
 
16
19
  private
17
20
 
18
- def verify_signature: (body: String, signature: String) -> bool
19
-
20
21
  def variable_secure_compare: (String, String) -> bool
21
22
 
22
23
  def secure_compare: (String, String) -> bool
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: line-bot-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LINE Corporation
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-08-26 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: multipart-post
@@ -39,7 +38,6 @@ dependencies:
39
38
  - !ruby/object:Gem::Version
40
39
  version: '0.2'
41
40
  description: SDK of the LINE Messaging API for Ruby
42
- email:
43
41
  executables: []
44
42
  extensions: []
45
43
  extra_rdoc_files: []
@@ -746,7 +744,6 @@ metadata:
746
744
  documentation_uri: https://line.github.io/line-bot-sdk-ruby/
747
745
  homepage_uri: https://github.com/line/line-bot-sdk-ruby
748
746
  source_code_uri: https://github.com/line/line-bot-sdk-ruby
749
- post_install_message:
750
747
  rdoc_options: []
751
748
  require_paths:
752
749
  - lib
@@ -761,8 +758,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
761
758
  - !ruby/object:Gem::Version
762
759
  version: '0'
763
760
  requirements: []
764
- rubygems_version: 3.5.22
765
- signing_key:
761
+ rubygems_version: 3.6.9
766
762
  specification_version: 4
767
763
  summary: SDK of the LINE Messaging API for Ruby
768
764
  test_files: []