intercom-rails 1.0.6 → 1.1.1
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 +4 -4
- data/README.md +48 -1
- data/lib/intercom-rails/script_tag.rb +3 -1
- data/lib/intercom-rails/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff14436633adc07b04ea0fff8507abf54e6fd34e4c4ab943c3a26aa691d69801
|
|
4
|
+
data.tar.gz: 7fe20bd0ce9cff4efe03a935886b43ac8bed8f56366e75f1733a5948f7145299
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 744323aa7316eebe9923ef4a15897e6cf0ee24fda86e42f19ee865f1050e09840a4921be0b8f706a4fd610d66d584f4155a83a7483686949ec46e858ca2a9623
|
|
7
|
+
data.tar.gz: a93f75e039d873083243e3c847b8ccc4e2f35e812c4e05d5423fca83c36419aa908348003770133384044629584e63d4f55feafa6ff6b9f68e9d4b172274e2e0
|
data/README.md
CHANGED
|
@@ -69,6 +69,53 @@ It is possible to enable Identity Verification for the Intercom Messenger and yo
|
|
|
69
69
|
```
|
|
70
70
|
**Note: This example is just for the sake of simplicity, you should never include this secret in source control. Instead, you should use the Rails [secret config](http://guides.rubyonrails.org/4_1_release_notes.html#config-secrets-yml) feature.**
|
|
71
71
|
|
|
72
|
+
### JWT Authentication
|
|
73
|
+
You can enable JWT authentication for enhanced security with the Intercom Messenger. This feature uses JSON Web Tokens (JWTs) to authenticate users instead of the traditional user_hash method. To enable JWT authentication, add the following to your `config/initializers/intercom.rb`:
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
config.jwt.enabled = true
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### JWT Expiry
|
|
80
|
+
You can set an expiry time for JWTs. This determines how long the token remains valid:
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
config.jwt.expiry = 12.hours # Token expires after 12 hours
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If no expiry is set, the JWT will not include an expiration claim.
|
|
87
|
+
|
|
88
|
+
#### Signed User Fields
|
|
89
|
+
You can specify which user fields should be included in the JWT payload and removed from the client-side settings for enhanced security:
|
|
90
|
+
|
|
91
|
+
```ruby
|
|
92
|
+
config.jwt.signed_user_fields = [:email, :name, :plan, :team_id]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
With this configuration, these fields will be:
|
|
96
|
+
- Included in the signed JWT payload
|
|
97
|
+
- Removed from the client-side `intercomSettings` object
|
|
98
|
+
- Still available to Intercom through the secure JWT
|
|
99
|
+
|
|
100
|
+
#### Per-Request JWT Configuration
|
|
101
|
+
You can also configure JWT settings on a per-request basis using the `intercom_script_tag` helper:
|
|
102
|
+
|
|
103
|
+
```erb
|
|
104
|
+
<%= intercom_script_tag({
|
|
105
|
+
:user_id => current_user.id,
|
|
106
|
+
:email => current_user.email
|
|
107
|
+
}, {
|
|
108
|
+
:jwt_enabled => true,
|
|
109
|
+
:jwt_expiry => 1.hour
|
|
110
|
+
}) %>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Important Notes:**
|
|
114
|
+
- JWT authentication requires an `api_secret` to be configured
|
|
115
|
+
- JWT is only generated when a `user_id` is present
|
|
116
|
+
- When JWT is enabled, the `user_id` is removed from client-side settings and only included in the secure JWT
|
|
117
|
+
- Other configured signed fields are also removed from client-side settings when JWT is used
|
|
118
|
+
|
|
72
119
|
### Shutdown
|
|
73
120
|
We make use of first-party cookies so that we can identify your users the next time they open your messenger. When people share devices with someone else, they might be able to see the most recently logged in user’s conversation history until the cookie expires. Because of this, it’s very important to properly shutdown Intercom when a user’s session on your app ends (either manually or due to an automated logout).
|
|
74
121
|
|
|
@@ -342,7 +389,7 @@ CSP support for automatic insertion exposes two namespaces that can be defined b
|
|
|
342
389
|
- String CoreExtensions::IntercomRails::AutoInclude.csp_nonce_hook(controller)
|
|
343
390
|
- nil CoreExtensions::IntercomRails::AutoInclude.csp_sha256_hook(controller, SHA-256 whitelist entry)
|
|
344
391
|
|
|
345
|
-
For instance, a CSP nonce can be inserted using the [
|
|
392
|
+
For instance, a CSP nonce can be inserted using the [Github Secure Headers](https://github.com/github/secure_headers) gem with the following code:
|
|
346
393
|
```ruby
|
|
347
394
|
module CoreExtensions
|
|
348
395
|
module IntercomRails
|
|
@@ -54,7 +54,7 @@ module IntercomRails
|
|
|
54
54
|
return false if user_details[:excluded_user] == true
|
|
55
55
|
valid = user_details[:app_id].present?
|
|
56
56
|
unless @show_everywhere
|
|
57
|
-
valid = valid &&
|
|
57
|
+
valid = valid && @has_identity
|
|
58
58
|
end
|
|
59
59
|
if nonce
|
|
60
60
|
valid = valid && valid_nonce?
|
|
@@ -146,6 +146,8 @@ module IntercomRails
|
|
|
146
146
|
@user_details = @user_details.with_indifferent_access.tap do |u|
|
|
147
147
|
[:email, :name, :user_id].each { |k| u.delete(k) if u[k].nil? }
|
|
148
148
|
|
|
149
|
+
@has_identity = (u[:user_id] || u[:email]).present?
|
|
150
|
+
|
|
149
151
|
if secret.present?
|
|
150
152
|
if jwt_enabled && u[:user_id].present?
|
|
151
153
|
u[:intercom_user_jwt] ||= generate_jwt
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: intercom-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben McRedmond
|
|
8
8
|
- Ciaran Lee
|
|
9
9
|
- Darragh Curran
|
|
10
|
-
autorequire:
|
|
10
|
+
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2026-04-20 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activesupport
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
name: jwt
|
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
|
32
32
|
requirements:
|
|
33
|
-
- - "
|
|
33
|
+
- - ">="
|
|
34
34
|
- !ruby/object:Gem::Version
|
|
35
35
|
version: '2.0'
|
|
36
36
|
type: :runtime
|
|
37
37
|
prerelease: false
|
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
39
39
|
requirements:
|
|
40
|
-
- - "
|
|
40
|
+
- - ">="
|
|
41
41
|
- !ruby/object:Gem::Version
|
|
42
42
|
version: '2.0'
|
|
43
43
|
- !ruby/object:Gem::Dependency
|
|
@@ -187,7 +187,7 @@ homepage: http://www.intercom.io
|
|
|
187
187
|
licenses:
|
|
188
188
|
- MIT
|
|
189
189
|
metadata: {}
|
|
190
|
-
post_install_message:
|
|
190
|
+
post_install_message:
|
|
191
191
|
rdoc_options: []
|
|
192
192
|
require_paths:
|
|
193
193
|
- lib
|
|
@@ -202,8 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
202
202
|
- !ruby/object:Gem::Version
|
|
203
203
|
version: '0'
|
|
204
204
|
requirements: []
|
|
205
|
-
rubygems_version: 3.
|
|
206
|
-
signing_key:
|
|
205
|
+
rubygems_version: 3.0.3.1
|
|
206
|
+
signing_key:
|
|
207
207
|
specification_version: 4
|
|
208
208
|
summary: Rails helper for emitting javascript script tags for Intercom
|
|
209
209
|
test_files: []
|