intercom-rails 1.0.4 → 1.0.5

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: 6a0dbbf87c42ebfc8d7ef419b8419c603affa9b404c60aa24fb08d9b97a4d497
4
- data.tar.gz: 4d651bdef674633a6f2ace4576a8450e97edfb176f05af5227676cebe1568c61
3
+ metadata.gz: 8672ce0798e1f6ed14669e026fb048640c70592e27a3d34e217a6bddb0cbf097
4
+ data.tar.gz: e62b7cb80da4e200b47b4454b67e87c5a229702a6f626b471c117de433e28794
5
5
  SHA512:
6
- metadata.gz: 736a52b2db369ed6e3716dbac46cd1b30b333644c7a248d45ebceeb2e2c0a7ffc2eb8bb7032c0ba6d931ec715b7356dbfc66f802239d0a437f4a477466c4c388
7
- data.tar.gz: d3dce65e7f52e5ca96104a65b63434fd2dff1bdd5652a533e2cd9dd13afb00c74d23153d2658ad01e4ba8b0dfb90d5bf5711c49265e94f56d5ff92222518a6fb
6
+ metadata.gz: f5ee15eb8b021131a761f45ac8a749a7c2ecec50813c7d0befdb6aa59a9b0f8281e9867a65b09bdbfdf4b5e2894ebebef940d03aae85618b4cb7490308f181b9
7
+ data.tar.gz: 6a5b063fde892db61708f02a868af8fe2879a54225b2d471fcdd15fb4af654318b2a26af3d0e8f1eba9a99fc01ee2424af3a1b95e6cb849e26dbd61ea51b3527
@@ -110,7 +110,6 @@ module IntercomRails
110
110
  config_accessor :hide_default_launcher
111
111
  config_accessor :api_base
112
112
  config_accessor :encrypted_mode
113
- config_accessor :jwt_enabled
114
113
 
115
114
  def self.api_key=(*)
116
115
  warn "Setting an Intercom API key is no longer supported; remove the `config.api_key = ...` line from config/initializers/intercom.rb"
@@ -144,6 +143,15 @@ module IntercomRails
144
143
  end
145
144
  end
146
145
 
146
+ config_group :jwt do
147
+ config_accessor :enabled
148
+ config_accessor :signed_user_fields do |value|
149
+ unless value.nil? || (value.kind_of?(Array) && value.all? { |v| v.kind_of?(Symbol) || v.kind_of?(String) })
150
+ raise ArgumentError, "jwt.signed_user_fields must be an array of symbols or strings"
151
+ end
152
+ end
153
+ end
154
+
147
155
  end
148
156
 
149
157
  end
@@ -26,7 +26,7 @@ module IntercomRails
26
26
  self.controller = options[:controller]
27
27
  @show_everywhere = options[:show_everywhere]
28
28
  @session_duration = session_duration_from_config
29
- self.jwt_enabled = options[:jwt_enabled] || Config.jwt_enabled
29
+ self.jwt_enabled = options[:jwt_enabled] || Config.jwt.enabled
30
30
 
31
31
  initial_user_details = if options[:find_current_user_details]
32
32
  find_current_user_details
@@ -128,6 +128,14 @@ module IntercomRails
128
128
  user_id: user_details[:user_id].to_s,
129
129
  exp: 24.hours.from_now.to_i
130
130
  }
131
+
132
+ if Config.jwt.signed_user_fields.present?
133
+ Config.jwt.signed_user_fields.each do |field|
134
+ field = field.to_sym
135
+ payload[field] = user_details[field].to_s if user_details[field].present?
136
+ end
137
+ end
138
+
131
139
  JWT.encode(payload, secret, 'HS256')
132
140
  end
133
141
 
@@ -139,7 +147,11 @@ module IntercomRails
139
147
  if secret.present?
140
148
  if jwt_enabled && u[:user_id].present?
141
149
  u[:intercom_user_jwt] ||= generate_jwt
142
- u.delete(:user_id) # No need to send plaintext user_id when using JWT
150
+
151
+ u.delete(:user_id)
152
+ Config.jwt.signed_user_fields&.each do |field|
153
+ u.delete(field.to_sym)
154
+ end
143
155
  elsif (u[:user_id] || u[:email]).present?
144
156
  u[:user_hash] ||= user_hash
145
157
  end
@@ -1,3 +1,3 @@
1
1
  module IntercomRails
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intercom-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben McRedmond
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-12-19 00:00:00.000000000 Z
13
+ date: 2024-12-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport