pubnub 5.0.0 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pubnub might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.pubnub.yml +11 -5
- data/.travis.yml +1 -1
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/pubnub/client/getters_setters.rb +38 -6
- data/lib/pubnub/client.rb +7 -3
- data/lib/pubnub/event.rb +3 -3
- data/lib/pubnub/events/get_memberships.rb +1 -1
- data/lib/pubnub/events/get_uuid_metadata.rb +1 -1
- data/lib/pubnub/events/grant_token.rb +15 -6
- data/lib/pubnub/events/remove_memberships.rb +1 -1
- data/lib/pubnub/events/remove_uuid_metadata.rb +1 -1
- data/lib/pubnub/events/set_memberships.rb +1 -1
- data/lib/pubnub/events/set_state.rb +1 -1
- data/lib/pubnub/events/set_uuid_metadata.rb +1 -1
- data/lib/pubnub/events/state.rb +1 -1
- data/lib/pubnub/events/where_now.rb +1 -1
- data/lib/pubnub/subscriber.rb +1 -1
- data/lib/pubnub/validators/client.rb +1 -1
- data/lib/pubnub/validators/common_validator.rb +6 -7
- data/lib/pubnub/validators/grant_token.rb +14 -0
- data/lib/pubnub/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9393969418b064ec9d7b89500f7fbf2556607985ba14c3a61f77a5452830b2d
|
4
|
+
data.tar.gz: bb033ee292892b54dd13d606eee102f719bd1d51012307e3e87aa8f33ed6cde0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a9eabe43321053374680972c48aea024f80c47b53fb98650698bffb522fd53995246749eb9561b2e136564c1a1367e6eda7a6b2307646690e8f670ff88bd30f
|
7
|
+
data.tar.gz: 2160579b9069914c28f0fdc2992608737cfc5a7235b9eac86e42a2f02fa984f5179c327cb1a3a93c4f22d0de596e662e2ce8dea84e51ade44a29f770196c60a6
|
data/.pubnub.yml
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
---
|
2
|
-
version: "5.
|
2
|
+
version: "5.1.0"
|
3
3
|
changelog:
|
4
|
+
- date: 2022-07-26
|
5
|
+
version: v5.1.0
|
6
|
+
changes:
|
7
|
+
- type: feature
|
8
|
+
text: "Add support for spaces and users permissions in grant_token."
|
9
|
+
- type: feature
|
10
|
+
text: "Add user_id and deprecate uuid when creating new pubnub instance."
|
4
11
|
- date: 2022-01-13
|
5
12
|
version: v5.0.0
|
6
13
|
changes:
|
@@ -447,7 +454,6 @@ features:
|
|
447
454
|
- PUSH-TYPE-APNS
|
448
455
|
- PUSH-TYPE-APNS2
|
449
456
|
- PUSH-TYPE-FCM
|
450
|
-
- PUSH-TYPE-MPNS
|
451
457
|
storage:
|
452
458
|
- STORAGE-REVERSE
|
453
459
|
- STORAGE-INCLUDE-TIMETOKEN
|
@@ -626,7 +632,7 @@ sdks:
|
|
626
632
|
- x86-64
|
627
633
|
- distribution-type: package
|
628
634
|
distribution-repository: RubyGems
|
629
|
-
package-name: pubnub-5.
|
635
|
+
package-name: pubnub-5.1.0.gem
|
630
636
|
location: https://rubygems.org/gems/pubnub
|
631
637
|
requires:
|
632
638
|
- name: addressable
|
@@ -731,8 +737,8 @@ sdks:
|
|
731
737
|
- x86-64
|
732
738
|
- distribution-type: library
|
733
739
|
distribution-repository: GitHub release
|
734
|
-
package-name: pubnub-5.
|
735
|
-
location: https://github.com/pubnub/ruby/releases/download/v5.
|
740
|
+
package-name: pubnub-5.1.0.gem
|
741
|
+
location: https://github.com/pubnub/ruby/releases/download/v5.1.0/pubnub-5.1.0.gem
|
736
742
|
requires:
|
737
743
|
- name: addressable
|
738
744
|
min-version: 2.0.0
|
data/.travis.yml
CHANGED
@@ -26,7 +26,7 @@ jobs:
|
|
26
26
|
rvm: '2.7.1'
|
27
27
|
script: bundle exec rspec
|
28
28
|
- name: 'Ruby JRuby'
|
29
|
-
rvm: 'jruby-
|
29
|
+
rvm: 'jruby-9.3.4.0'
|
30
30
|
env: JRUBY_TEST=true NO_COVERAGE=true JRUBY_OPTS="--server -J-Xms2048m -J-Xmx2048m -J-XX:-UseGCOverheadLimit -J-XX:+CMSClassUnloadingEnabled"
|
31
31
|
jdk: oraclejdk11
|
32
32
|
script:
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.1.0
|
@@ -7,6 +7,8 @@ module Pubnub
|
|
7
7
|
# Module that holds some getters and setters
|
8
8
|
module GettersSetters
|
9
9
|
|
10
|
+
extend Gem::Deprecate
|
11
|
+
|
10
12
|
def sdk_version
|
11
13
|
"PubNub-Ruby/#{Pubnub::VERSION}"
|
12
14
|
end
|
@@ -15,7 +17,7 @@ module Pubnub
|
|
15
17
|
# ===========
|
16
18
|
# <dl>
|
17
19
|
# <dt>uuid</dt>
|
18
|
-
# <dd>New uuid to be set
|
20
|
+
# <dd>New uuid to be set. Note that this will override user_id value</dd>
|
19
21
|
# </dl>
|
20
22
|
#
|
21
23
|
# Returns:
|
@@ -26,16 +28,38 @@ module Pubnub
|
|
26
28
|
# ==============
|
27
29
|
# Can't change uuid while subscribed. You have to leave every subscribed channel.
|
28
30
|
def change_uuid(uuid)
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
change_user_id(uuid)
|
32
|
+
end
|
33
|
+
deprecate :change_uuid, :change_user_id, 2023, 1
|
32
34
|
|
33
|
-
|
35
|
+
# Parameters:
|
36
|
+
# ===========
|
37
|
+
# <dl>
|
38
|
+
# <dt>user_id</dt>
|
39
|
+
# <dd>New user_id to be set. Note that this will override uuid value</dd>
|
40
|
+
# </dl>
|
41
|
+
#
|
42
|
+
# Returns:
|
43
|
+
# ========
|
44
|
+
# New user_id.
|
45
|
+
#
|
46
|
+
# Functionality:
|
47
|
+
# ==============
|
48
|
+
# Can't change user_id while subscribed. You have to leave every subscribed channel.
|
49
|
+
def change_user_id(user_id)
|
50
|
+
Pubnub.logger.debug('Pubnub::Client') { 'Changing user_id' }
|
51
|
+
raise('Cannot change user_id while subscribed.') if subscribed?
|
52
|
+
Validator::Client.validate_user_id user_id
|
53
|
+
|
54
|
+
@env[:user_id] = user_id
|
34
55
|
end
|
35
56
|
|
36
57
|
alias session_uuid= change_uuid
|
37
58
|
alias uuid= change_uuid
|
38
59
|
alias set_uuid= change_uuid
|
60
|
+
alias session_user_id= change_user_id
|
61
|
+
alias user_id= change_user_id
|
62
|
+
alias set_user_id= change_user_id
|
39
63
|
|
40
64
|
# Returns:
|
41
65
|
# ========
|
@@ -97,7 +121,15 @@ module Pubnub
|
|
97
121
|
# ========
|
98
122
|
# Current uuid.
|
99
123
|
def uuid
|
100
|
-
|
124
|
+
user_id
|
125
|
+
end
|
126
|
+
deprecate :uuid, :user_id, 2023, 1
|
127
|
+
|
128
|
+
# Returns:
|
129
|
+
# ========
|
130
|
+
# Current user_id.
|
131
|
+
def user_id
|
132
|
+
@env[:user_id]
|
101
133
|
end
|
102
134
|
|
103
135
|
# Returns:
|
data/lib/pubnub/client.rb
CHANGED
@@ -111,7 +111,10 @@ module Pubnub
|
|
111
111
|
# <dd><b>optional.</b> Required to encrypt messages.</dd>
|
112
112
|
#
|
113
113
|
# <dt>uuid</dt>
|
114
|
-
# <dd><b>optional.</b> Sets given uuid as client uuid, does not generates random uuid on init as usually
|
114
|
+
# <dd><b>optional.</b> <b>Deprecated.</b> Sets given uuid as client uuid, does not generates random uuid on init as usually</dd>
|
115
|
+
#
|
116
|
+
# <dt>user_id</dt>
|
117
|
+
# <dd><b>required.</b> Sets given user_id as client user_id.</dd>
|
115
118
|
#
|
116
119
|
# <dt>origin</dt>
|
117
120
|
# <dd><b>optional.</b> Specifies the fully qualified domain name of the PubNub origin.
|
@@ -155,7 +158,7 @@ module Pubnub
|
|
155
158
|
# publish_key: :demo,
|
156
159
|
# secret_key: :secret,
|
157
160
|
# cipher_key: :other_secret,
|
158
|
-
#
|
161
|
+
# user_id: :mad_max,
|
159
162
|
# origin: 'custom.pubnub.com',
|
160
163
|
# callback: ->(envelope) { puts envelope.message },
|
161
164
|
# connect_callback: ->(message) { puts message },
|
@@ -289,7 +292,7 @@ module Pubnub
|
|
289
292
|
|
290
293
|
def sequence_number_for_publish!
|
291
294
|
@env[:sequence_number_for_publish] += 1
|
292
|
-
@env[:sequence_number_for_publish] % 2**32
|
295
|
+
@env[:sequence_number_for_publish] % 2 ** 32
|
293
296
|
end
|
294
297
|
|
295
298
|
def apply_state(event)
|
@@ -379,6 +382,7 @@ module Pubnub
|
|
379
382
|
Pubnub.logger = options[:logger] || Logger.new('pubnub.log')
|
380
383
|
Concurrent.global_logger = Pubnub.logger
|
381
384
|
@subscriber = Subscriber.new(self)
|
385
|
+
options[:user_id] = options[:uuid] if options[:user_id].nil?
|
382
386
|
@env = options
|
383
387
|
end
|
384
388
|
|
data/lib/pubnub/event.rb
CHANGED
@@ -148,7 +148,7 @@ module Pubnub
|
|
148
148
|
token = @app.env[:token]
|
149
149
|
empty_if_blank = {
|
150
150
|
auth: token ? token : @auth_key,
|
151
|
-
uuid: @app.
|
151
|
+
uuid: @app.user_id,
|
152
152
|
@telemetry_name => @current_telemetry
|
153
153
|
}
|
154
154
|
|
@@ -175,7 +175,7 @@ module Pubnub
|
|
175
175
|
state channel_group channel_groups compressed meta customs include_token
|
176
176
|
replicate with_presence cipher_key_selector include_meta join update get
|
177
177
|
add remove push_token push_gateway environment topic authorized_uuid
|
178
|
-
token
|
178
|
+
authorized_user_id token
|
179
179
|
]
|
180
180
|
|
181
181
|
options = options.each_with_object({}) { |option, obj| obj[option.first.to_sym] = option.last }
|
@@ -223,7 +223,7 @@ module Pubnub
|
|
223
223
|
def get_config
|
224
224
|
{
|
225
225
|
tls: @app.env[:ssl],
|
226
|
-
uuid: @app.
|
226
|
+
uuid: @app.user_id,
|
227
227
|
auth_key: @app.env[:auth_key],
|
228
228
|
origin: @app.current_origin
|
229
229
|
}
|
@@ -10,7 +10,7 @@ module Pubnub
|
|
10
10
|
def initialize(options, app)
|
11
11
|
@event = current_operation
|
12
12
|
@telemetry_name = :l_obj
|
13
|
-
@uuid = options[:uuid].nil? ? app.
|
13
|
+
@uuid = options[:uuid].nil? ? app.user_id : options[:uuid]
|
14
14
|
@limit = [options[:limit], 100].min unless options[:limit].nil?
|
15
15
|
@sort = options[:sort].join(",") if options[:sort] && !options[:sort].empty?
|
16
16
|
@filter = options[:filter] if options[:filter] && !options[:filter].empty?
|
@@ -10,7 +10,7 @@ module Pubnub
|
|
10
10
|
def initialize(options, app)
|
11
11
|
@event = current_operation
|
12
12
|
@telemetry_name = :l_obj
|
13
|
-
@uuid = options[:uuid].nil? ? app.
|
13
|
+
@uuid = options[:uuid].nil? ? app.user_id : options[:uuid]
|
14
14
|
|
15
15
|
if options[:include]
|
16
16
|
@include = "custom" unless [0, '0', false].include?(options[:include][:custom])
|
@@ -10,19 +10,28 @@ module Pubnub
|
|
10
10
|
@uuids = options[:uuids] || {}
|
11
11
|
options[:channels] = options[:channels] || {}
|
12
12
|
options[:channel_groups] = options[:channel_groups] || {}
|
13
|
+
@spaces_permissions = options[:spaces_permissions] || {}
|
14
|
+
@users_permissions = options[:users_permissions] || {}
|
13
15
|
super
|
14
16
|
end
|
15
17
|
|
16
18
|
def fire
|
17
19
|
Pubnub.logger.debug('Pubnub::GrantToken') { "Fired event #{self.class}" }
|
20
|
+
if @authorized_user_id != nil
|
21
|
+
uuid = @authorized_user_id
|
22
|
+
elsif @authorized_uuid != nil
|
23
|
+
uuid = @authorized_uuid
|
24
|
+
else
|
25
|
+
uuid = nil
|
26
|
+
end
|
18
27
|
|
19
28
|
raw_body = {
|
20
29
|
ttl: @ttl,
|
21
30
|
permissions: {
|
22
31
|
meta: @meta,
|
23
|
-
uuid:
|
24
|
-
resources: prepare_permissions(:resource, @channels, @channel_groups, @uuids),
|
25
|
-
patterns: prepare_permissions(:pattern, @channels, @channel_groups, @uuids)
|
32
|
+
uuid: uuid,
|
33
|
+
resources: prepare_permissions(:resource, @channels, @channel_groups, @uuids, @spaces_permissions, @users_permissions),
|
34
|
+
patterns: prepare_permissions(:pattern, @channels, @channel_groups, @uuids, @spaces_permissions, @users_permissions)
|
26
35
|
}.select { |_, v| v }
|
27
36
|
}
|
28
37
|
body = Formatter.format_message(raw_body, "", false, false)
|
@@ -47,11 +56,11 @@ module Pubnub
|
|
47
56
|
Pubnub::Constants::OPERATION_GRANT_TOKEN
|
48
57
|
end
|
49
58
|
|
50
|
-
def prepare_permissions(type, channels, groups, uuids)
|
59
|
+
def prepare_permissions(type, channels, groups, uuids, spaces_permissions, users_permissions)
|
51
60
|
{
|
52
|
-
channels: prepare_single_permissions(type, channels),
|
61
|
+
channels: prepare_single_permissions(type, channels).merge!(prepare_single_permissions(type, spaces_permissions)),
|
53
62
|
groups: prepare_single_permissions(type, groups),
|
54
|
-
uuids: prepare_single_permissions(type, uuids)
|
63
|
+
uuids: prepare_single_permissions(type, uuids).merge!(prepare_single_permissions(type, users_permissions))
|
55
64
|
}
|
56
65
|
end
|
57
66
|
|
@@ -10,7 +10,7 @@ module Pubnub
|
|
10
10
|
def initialize(options, app)
|
11
11
|
@event = current_operation
|
12
12
|
@telemetry_name = :l_obj
|
13
|
-
@uuid = options[:uuid].nil? ? app.
|
13
|
+
@uuid = options[:uuid].nil? ? app.user_id : options[:uuid]
|
14
14
|
@limit = [options[:limit], 100].min unless options[:limit].nil?
|
15
15
|
@sort = options[:sort].join(",") if options[:sort] && !options[:sort].empty?
|
16
16
|
@filter = options[:filter] if options[:filter] && !options[:filter].empty?
|
@@ -10,7 +10,7 @@ module Pubnub
|
|
10
10
|
def initialize(options, app)
|
11
11
|
@event = current_operation
|
12
12
|
@telemetry_name = :l_obj
|
13
|
-
@uuid = options[:uuid].nil? ? app.
|
13
|
+
@uuid = options[:uuid].nil? ? app.user_id : options[:uuid]
|
14
14
|
@limit = [options[:limit], 100].min unless options[:limit].nil?
|
15
15
|
@sort = options[:sort].join(",") if options[:sort] && !options[:sort].empty?
|
16
16
|
@filter = options[:filter] if options[:filter] && !options[:filter].empty?
|
@@ -10,7 +10,7 @@ module Pubnub
|
|
10
10
|
def initialize(options, app)
|
11
11
|
@event = current_operation
|
12
12
|
@telemetry_name = :l_obj
|
13
|
-
@uuid = options[:uuid].nil? ? app.
|
13
|
+
@uuid = options[:uuid].nil? ? app.user_id : options[:uuid]
|
14
14
|
|
15
15
|
# Clean up user-provided metadata object from nils.
|
16
16
|
@metadata = options[:metadata].delete_if { |_k, v| v.blank? } unless options[:metadata].nil?
|
data/lib/pubnub/events/state.rb
CHANGED
data/lib/pubnub/subscriber.rb
CHANGED
@@ -11,7 +11,7 @@ module Pubnub
|
|
11
11
|
validate_origin parameters[:origin], true
|
12
12
|
validate_subscribe_key parameters[:subscribe_key], true
|
13
13
|
validate_publish_key parameters[:publish_key]
|
14
|
-
|
14
|
+
validate_user_id parameters[:user_id]
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
@@ -53,18 +53,17 @@ module Pubnub
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
if !uuid || uuid.blank?
|
56
|
+
def validate_user_id(user_id)
|
57
|
+
if !user_id || user_id.blank?
|
59
58
|
raise(
|
60
59
|
InitializationError.new,
|
61
|
-
'Missing required :
|
60
|
+
'Missing required :user_id parameter.'
|
62
61
|
)
|
63
|
-
elsif !([String, Symbol].include?(
|
64
|
-
|
62
|
+
elsif !([String, Symbol].include?(user_id.class) ||
|
63
|
+
user_id.blank?)
|
65
64
|
raise(
|
66
65
|
InitializationError.new,
|
67
|
-
'
|
66
|
+
'user_id parameter is not valid. \
|
68
67
|
Should be type of String or Symbol.'
|
69
68
|
)
|
70
69
|
end
|
@@ -12,6 +12,7 @@ module Pubnub
|
|
12
12
|
validate_permissions!(@uuids, ":uuids")
|
13
13
|
validate_permissions!(@channels, ":channels")
|
14
14
|
validate_permissions!(@channel_groups, ":uuids")
|
15
|
+
validate_objects_entities_separation!
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
@@ -45,6 +46,19 @@ module Pubnub
|
|
45
46
|
":#{name} has to be kind of Hash for grant token event."
|
46
47
|
) unless arg.is_a?(Hash)
|
47
48
|
end
|
49
|
+
|
50
|
+
def validate_objects_entities_separation!
|
51
|
+
entities_set = !@spaces_permissions.empty? ||
|
52
|
+
!@users_permissions.empty?
|
53
|
+
objects_set = !@channels.empty? ||
|
54
|
+
!@channel_groups.empty? ||
|
55
|
+
!@uuids.empty?
|
56
|
+
|
57
|
+
raise(
|
58
|
+
ArgumentError.new(object: self, message: "Can't mix entities and objects"),
|
59
|
+
"Can't mix entities and objects"
|
60
|
+
) if (entities_set && objects_set)
|
61
|
+
end
|
48
62
|
end
|
49
63
|
end
|
50
64
|
end
|
data/lib/pubnub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubnub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PubNub
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|