nylas 5.16.0 → 5.17.0

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
  SHA256:
3
- metadata.gz: 611d01fd47937e73177b033115d17ca69f1f3fbc9176e50120710f02ffa9bdef
4
- data.tar.gz: 9f2aebcb84e01fe7806d3c099b019227b7dd65eedb3c1556416170d8a6e42213
3
+ metadata.gz: 0660c04f6656d846a55819153819877b599ed5342d8f2ea9c18a7b19e0799ec3
4
+ data.tar.gz: bf1bd6d4382a6705a5146ff86202436512cf0fc5c68817c77a932e846c3150cf
5
5
  SHA512:
6
- metadata.gz: e9cfa68642a3f477ed36ce9ff76932a814ed86385405a46517c465f39d92b6d9c0d3c41a554cbceb30d531058451040797e8ba5fab6aa5abdbb84356226a420e
7
- data.tar.gz: 0af23985e245070c6fa58457cbcd3b85df2098da21071b245d167c5be4944259da7fb0029ba9cbed79aa677ec9ef6164e1406ac84eadee2f2604fc73aa8f0600
6
+ metadata.gz: 076702b69e4ea6a7ef882f3ac65490d54c90bae69cdc8f940aab62a4d29997627d7936b3426158e10935f1aecfad517e17b2d3c5502aa26a636e48319c492fcd
7
+ data.tar.gz: 1d7fd956e5676c2b418ed2d0d79ecfd9cf3b6a961f8768ee0dd97952f0ea043810e90499063b1940efc055506a79187f78d4daf04fe386dfbdf64141bd1d9262
data/lib/nylas/api.rb CHANGED
@@ -24,14 +24,16 @@ module Nylas
24
24
  end
25
25
 
26
26
  # @return [String] A Nylas access token for that particular user.
27
- def authenticate(name:, email_address:, provider:, settings:, reauth_account_id: nil, scopes: nil)
27
+ def authenticate(name:, email_address:, provider:, settings:, reauth_account_id: nil, scopes: nil,
28
+ return_full_response: false)
28
29
  NativeAuthentication.new(api: self).authenticate(
29
30
  name: name,
30
31
  email_address: email_address,
31
32
  provider: provider,
32
33
  settings: settings,
33
34
  reauth_account_id: reauth_account_id,
34
- scopes: scopes
35
+ scopes: scopes,
36
+ return_full_response: return_full_response
35
37
  )
36
38
  end
37
39
 
data/lib/nylas/event.rb CHANGED
@@ -46,6 +46,7 @@ module Nylas
46
46
  attribute :reminder_method, :string
47
47
  attribute :job_status_id, :string, read_only: true
48
48
  attribute :visibility, :string
49
+ attribute :updated_at, :unix_timestamp, read_only: true
49
50
 
50
51
  attr_accessor :notify_participants
51
52
 
@@ -11,13 +11,13 @@ module Nylas
11
11
  end
12
12
 
13
13
  def authenticate(name:, email_address:, provider:, settings:, reauth_account_id: nil,
14
- scopes: nil)
14
+ scopes: nil, return_full_response: false)
15
15
  scopes ||= %w[email calendar contacts]
16
16
  scopes = scopes.join(",") unless scopes.is_a?(String)
17
17
  code = retrieve_code(name: name, email_address: email_address, provider: provider,
18
18
  settings: settings, reauth_account_id: reauth_account_id, scopes: scopes)
19
19
 
20
- exchange_code_for_access_token(code)
20
+ exchange_code_for_access_token(code, return_full_response)
21
21
  end
22
22
 
23
23
  private
@@ -30,10 +30,10 @@ module Nylas
30
30
  response[:code]
31
31
  end
32
32
 
33
- def exchange_code_for_access_token(code)
33
+ def exchange_code_for_access_token(code, return_full_response)
34
34
  payload = { client_id: api.client.app_id, client_secret: api.client.app_secret, code: code }
35
35
  response = api.execute(method: :post, path: "/connect/token", payload: JSON.dump(payload))
36
- response[:access_token]
36
+ return_full_response ? response : response[:access_token]
37
37
  end
38
38
  end
39
39
  end
data/lib/nylas/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nylas
4
- VERSION = "5.16.0"
4
+ VERSION = "5.17.0"
5
5
  end
data/lib/nylas/webhook.rb CHANGED
@@ -42,6 +42,7 @@ module Nylas
42
42
  # Represents a webhook attached to your application.
43
43
  # @see https://docs.nylas.com/reference#webhooks
44
44
  class Webhook
45
+ require "openssl"
45
46
  include Model
46
47
  self.creatable = true
47
48
  self.listable = true
@@ -91,6 +92,16 @@ module Nylas
91
92
  "/a/#{api.app_id}/webhooks"
92
93
  end
93
94
 
95
+ # Verify incoming webhook signature came from Nylas
96
+ # @param nylas_signature [str] The signature to verify
97
+ # @param raw_body [str] The raw body from the payload
98
+ # @param client_secret [str] Client secret of the app receiving the webhook
99
+ # @return [Boolean] True if the webhook signature was verified from Nylas
100
+ def self.verify_webhook_signature(nylas_signature, raw_body, client_secret)
101
+ digest = OpenSSL::HMAC.hexdigest("SHA256", client_secret, raw_body)
102
+ digest == nylas_signature
103
+ end
104
+
94
105
  private
95
106
 
96
107
  def update_payload
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nylas
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.16.0
4
+ version: 5.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nylas, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-14 00:00:00.000000000 Z
11
+ date: 2023-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler