pubnub 6.1.1 → 6.2.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/.pubnub.yml +14 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +1 -1
- data/README.md +157 -71
- data/VERSION +1 -1
- data/docs-snippets/access_manager.rb +49 -0
- data/lib/pubnub/client/paged_history.rb +2 -2
- data/lib/pubnub/events/grant.rb +18 -4
- data/lib/pubnub/events/grant_token.rb +16 -1
- data/lib/pubnub/validators/grant.rb +22 -0
- data/lib/pubnub/validators/grant_token.rb +22 -0
- data/lib/pubnub/version.rb +1 -1
- data/pubnub.gemspec +4 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a790180f0c884132234cb47e28d9da09b35f649a2759a0d31e7577914b351f99
|
|
4
|
+
data.tar.gz: f9f12be27e3cb44f44ab616db1d399f2703b296c24ae1d4fcceb0c48c52751b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1eedcea454e1b94e51a8befc4dcaf93c07161b1410fd34573cb37cc01befdcef6867ad8050abe22f3b83c8d35b793cbbc1371889eeb7d5ba0a15645a7714cb73
|
|
7
|
+
data.tar.gz: 2c47fb1b98cc5a0c0fe3b37845911c83a048be3c74d3a95dcb41cc361787985e920f7404095d38567e8633a03b66136699634176695f25b1822fbde419179327
|
data/.pubnub.yml
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
---
|
|
2
|
-
version: "6.
|
|
2
|
+
version: "6.2.1"
|
|
3
3
|
changelog:
|
|
4
|
+
- date: 2026-11-23
|
|
5
|
+
version: v6.2.1
|
|
6
|
+
changes:
|
|
7
|
+
- type: bug
|
|
8
|
+
text: "Preserve block callbacks in async history methods."
|
|
9
|
+
- date: 2026-10-21
|
|
10
|
+
version: v6.2.0
|
|
11
|
+
changes:
|
|
12
|
+
- type: feature
|
|
13
|
+
text: "Add `categories` support to `grant` and `grant_token` for granting enumeration (`get`) permission on all `channels` and `uuids` metadata."
|
|
4
14
|
- date: 2026-07-21
|
|
5
15
|
version: v6.1.1
|
|
6
16
|
changes:
|
|
@@ -656,7 +666,7 @@ sdks:
|
|
|
656
666
|
- x86-64
|
|
657
667
|
- distribution-type: package
|
|
658
668
|
distribution-repository: RubyGems
|
|
659
|
-
package-name: pubnub-6.
|
|
669
|
+
package-name: pubnub-6.2.1.gem
|
|
660
670
|
location: https://rubygems.org/gems/pubnub
|
|
661
671
|
requires:
|
|
662
672
|
- name: addressable
|
|
@@ -761,8 +771,8 @@ sdks:
|
|
|
761
771
|
- x86-64
|
|
762
772
|
- distribution-type: library
|
|
763
773
|
distribution-repository: GitHub release
|
|
764
|
-
package-name: pubnub-6.
|
|
765
|
-
location: https://github.com/pubnub/ruby/releases/download/v6.
|
|
774
|
+
package-name: pubnub-6.2.1.gem
|
|
775
|
+
location: https://github.com/pubnub/ruby/releases/download/v6.2.1/pubnub-6.2.1.gem
|
|
766
776
|
requires:
|
|
767
777
|
- name: addressable
|
|
768
778
|
min-version: 2.0.0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## v6.2.1
|
|
2
|
+
November 23 2026
|
|
3
|
+
|
|
4
|
+
#### Fixed
|
|
5
|
+
- Preserve block callbacks in async history methods. Fixed the following issues reported by [@pcbeingused333](https://github.com/pcbeingused333): [#182](https://github.com/pubnub/ruby/issues/182).
|
|
6
|
+
|
|
7
|
+
## v6.2.0
|
|
8
|
+
October 21 2026
|
|
9
|
+
|
|
10
|
+
#### Added
|
|
11
|
+
- Add `categories` support to `grant` and `grant_token` for granting enumeration (`get`) permission on all `channels` and `uuids` metadata.
|
|
12
|
+
|
|
1
13
|
## v6.1.1
|
|
2
14
|
July 21 2026
|
|
3
15
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,71 +1,157 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
PubNub
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
<img width="1920" height="600" alt="ruby-header" src="https://github.com/user-attachments/assets/ddf7134b-804c-48d6-aa74-cc67ee5aab94" />
|
|
2
|
+
|
|
3
|
+
# PubNub Ruby SDK
|
|
4
|
+
|
|
5
|
+
[](https://rubygems.org/gems/pubnub)
|
|
6
|
+
|
|
7
|
+
PubNub provides global infrastructure for real-time, interactive applications.
|
|
8
|
+
|
|
9
|
+
Publish and receive messages in Ruby. Use this SDK for Ruby server, command-line, and backend applications.
|
|
10
|
+
|
|
11
|
+
[Documentation](https://www.pubnub.com/docs/sdks/ruby) · [API reference](https://www.pubnub.com/docs/sdks/ruby/api-reference/publish-and-subscribe) · [Changelog](https://www.pubnub.com/docs/sdks/ruby/changelog) · [Support](https://support.pubnub.com/)
|
|
12
|
+
|
|
13
|
+
## Requirements
|
|
14
|
+
|
|
15
|
+
| Requirement | Supported version or setup |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| Ruby | [Ruby 3.0.0 or later](https://github.com/pubnub/ruby/blob/master/pubnub.gemspec) |
|
|
18
|
+
| Dependency manager | RubyGems or Bundler. Install the `pubnub` gem directly or declare it in the application's Gemfile. |
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
From the Ruby environment:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
gem install pubnub
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For other installation methods, see [environment setup](https://www.pubnub.com/docs/sdks/ruby).
|
|
29
|
+
|
|
30
|
+
## Quickstart
|
|
31
|
+
|
|
32
|
+
This example runs in a Ruby CLI application. It subscribes to `hello_world`, publishes one message, and prints the received text.
|
|
33
|
+
|
|
34
|
+
### Get your keys
|
|
35
|
+
|
|
36
|
+
1. Open the [PubNub Admin Portal](https://admin.pubnub.com/).
|
|
37
|
+
2. Create an app and a keyset for development, or select an existing development keyset.
|
|
38
|
+
3. Copy its publish key and subscribe key.
|
|
39
|
+
|
|
40
|
+
If Access Manager is enabled, obtain a token from your trusted backend and call `pubnub.set_token(token)`. Keep the secret key on the backend.
|
|
41
|
+
|
|
42
|
+
### Send and receive a message
|
|
43
|
+
|
|
44
|
+
Create `app.rb` in the project root and add:
|
|
45
|
+
|
|
46
|
+
Replace the key placeholders. Use a User ID that identifies the user or device in your app.
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
require 'pubnub'
|
|
50
|
+
|
|
51
|
+
pubnub = Pubnub.new(
|
|
52
|
+
subscribe_key: 'YOUR_SUBSCRIBE_KEY',
|
|
53
|
+
publish_key: 'YOUR_PUBLISH_KEY',
|
|
54
|
+
user_id: 'hello-world-user'
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
received = Queue.new
|
|
58
|
+
published = false
|
|
59
|
+
|
|
60
|
+
callback = Pubnub::SubscribeCallback.new(
|
|
61
|
+
message: ->(envelope) do
|
|
62
|
+
puts envelope.result[:data][:message]
|
|
63
|
+
received << true
|
|
64
|
+
end,
|
|
65
|
+
|
|
66
|
+
status: ->(envelope) do
|
|
67
|
+
if !published && !envelope.error?
|
|
68
|
+
published = true
|
|
69
|
+
|
|
70
|
+
pubnub.publish(
|
|
71
|
+
channel: 'hello_world',
|
|
72
|
+
message: 'Hello world'
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
pubnub.add_listener(callback: callback)
|
|
79
|
+
|
|
80
|
+
pubnub.subscribe(
|
|
81
|
+
channels: ['hello_world']
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
received.pop
|
|
85
|
+
|
|
86
|
+
pubnub.unsubscribe(
|
|
87
|
+
channels: ['hello_world']
|
|
88
|
+
)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Run the example
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
ruby app.rb
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The terminal should show:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
Hello world
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The example unsubscribes from `hello_world` after receiving the message, and the script then exits.
|
|
104
|
+
|
|
105
|
+
For a complete application, see the [getting started guide](https://www.pubnub.com/docs/sdks/ruby).
|
|
106
|
+
|
|
107
|
+
## Next steps
|
|
108
|
+
|
|
109
|
+
| Task | Documentation |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| Configure the client | [Configuration](https://www.pubnub.com/docs/sdks/ruby/api-reference/configuration) |
|
|
112
|
+
| Work with subscriptions and messages | [Publish & Subscribe](https://www.pubnub.com/docs/sdks/ruby/api-reference/publish-and-subscribe) |
|
|
113
|
+
| Check channel occupancy | [Presence](https://www.pubnub.com/docs/sdks/ruby/api-reference/presence) |
|
|
114
|
+
| Read message history | [Message Persistence](https://www.pubnub.com/docs/sdks/ruby/api-reference/storage-and-playback) |
|
|
115
|
+
|
|
116
|
+
## Build with an AI coding assistant
|
|
117
|
+
|
|
118
|
+
The [PubNub MCP server](https://www.pubnub.com/docs/ai/pubnub-mcp-server) gives an AI coding assistant access to PubNub SDK documentation and PubNub APIs. Connect the assistant to the hosted server at `https://mcp.pubnub.com`, or run `npx @pubnub/mcp@latest` locally.
|
|
119
|
+
|
|
120
|
+
The [server repository](https://github.com/pubnub/pubnub-mcp-server) has setup steps for VS Code, Cursor, Claude Code, Claude Desktop, Codex, Gemini CLI, and OpenCode.
|
|
121
|
+
|
|
122
|
+
## Before production
|
|
123
|
+
|
|
124
|
+
Use [Access Manager](https://www.pubnub.com/docs/sdks/ruby/api-reference/access-manager) to grant each client the permissions it needs. Keep the secret key on your backend. Never include it in a distributed client.
|
|
125
|
+
|
|
126
|
+
Reuse the PubNub client for the owning service/application lifetime. Call `pubnub.unsubscribe(channels: [...])` for channel subscriptions that are no longer needed.
|
|
127
|
+
|
|
128
|
+
Live delivery through PubNub SDKs is at-most-once. A subscriber can miss messages while disconnected or if its buffer overflows. For longer-gap recovery, see [Message Persistence](https://www.pubnub.com/docs/sdks/ruby/api-reference/storage-and-playback).
|
|
129
|
+
|
|
130
|
+
## Troubleshooting
|
|
131
|
+
|
|
132
|
+
| Symptom | Check |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| Ruby loads a different PubNub gem version than the application expects | When using Bundler, declare `gem 'pubnub'` in the Gemfile and run the application with `bundle exec ruby app.rb`. See the [Ruby SDK guide](https://www.pubnub.com/docs/sdks/ruby). |
|
|
135
|
+
| A publish succeeds but no message appears | Check the message handler, subscription readiness, keyset, and channel name. |
|
|
136
|
+
| The process continues running after the owning workflow ends | Unsubscribe channels that are no longer needed with `pubnub.unsubscribe(channels: [...])`. See [Ruby troubleshooting](https://www.pubnub.com/docs/sdks/ruby/troubleshoot). |
|
|
137
|
+
| Extra clients or duplicate messages during development | For long-running Ruby servers/workers, create the PubNub client at application/service scope rather than on each request or code reload. |
|
|
138
|
+
|
|
139
|
+
For setup help, see [troubleshooting](https://www.pubnub.com/docs/sdks/ruby/troubleshoot). Check [network status](https://status.pubnub.com/) for service incidents.
|
|
140
|
+
|
|
141
|
+
## Releases
|
|
142
|
+
|
|
143
|
+
Read the [changelog](https://www.pubnub.com/docs/sdks/ruby/changelog) before upgrading.
|
|
144
|
+
|
|
145
|
+
For a major version change, review the [Ruby SDK changelog](https://www.pubnub.com/docs/sdks/ruby/changelog) for breaking changes before upgrading.
|
|
146
|
+
|
|
147
|
+
## Support and contributions
|
|
148
|
+
|
|
149
|
+
For setup or account help, contact [PubNub Support](https://support.pubnub.com/).
|
|
150
|
+
|
|
151
|
+
For a reproducible SDK bug, use [GitHub Issues](https://github.com/pubnub/ruby/issues). Include the SDK version, runtime, and a small reproduction with credentials removed.
|
|
152
|
+
|
|
153
|
+
Install the repository development dependencies, run the test suite, and include tests for behavioral changes before opening a pull request.
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
See the [PubNub Software Development Kit License](https://github.com/pubnub/ruby/blob/master/LICENSE.txt).
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
6.
|
|
1
|
+
6.2.1
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'pubnub'
|
|
2
|
+
|
|
3
|
+
pubnub = Pubnub.new(
|
|
4
|
+
subscribe_key: 'demo',
|
|
5
|
+
publish_key: 'demo',
|
|
6
|
+
secret_key: 'demo',
|
|
7
|
+
user_id: 'myUniqueUserId'
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
# snippet.grantTokenWithCategories
|
|
11
|
+
# Grants `my-authorized-user-id` permission to list all channel metadata and all uuid metadata.
|
|
12
|
+
# Category permissions support only the `get` operation.
|
|
13
|
+
envelope = pubnub.grant_token(
|
|
14
|
+
ttl: 15,
|
|
15
|
+
authorized_user_id: 'my-authorized-user-id',
|
|
16
|
+
categories: {
|
|
17
|
+
channels: Pubnub::Permissions.cat(get: true),
|
|
18
|
+
uuids: Pubnub::Permissions.cat(get: true)
|
|
19
|
+
},
|
|
20
|
+
http_sync: true
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
puts envelope.result[:data][:token]
|
|
24
|
+
# snippet.end
|
|
25
|
+
|
|
26
|
+
# snippet.parseTokenWithCategories
|
|
27
|
+
# Decodes a token that was granted with category permissions.
|
|
28
|
+
# The `cat` section holds the permission bitmask for each category: `chan` for channel
|
|
29
|
+
# metadata and `uuid` for uuid metadata. The `get` permission has the value 32.
|
|
30
|
+
parsed_token = pubnub.parse_token('use-token-string-generated-by-grant_token')
|
|
31
|
+
|
|
32
|
+
categories = parsed_token['cat']
|
|
33
|
+
puts "Channel metadata category: #{categories['chan']}"
|
|
34
|
+
puts "Uuid metadata category: #{categories['uuid']}"
|
|
35
|
+
# snippet.end
|
|
36
|
+
|
|
37
|
+
# snippet.grantWithCategories
|
|
38
|
+
# Grants the auth key permission to list all channel metadata and all uuid metadata.
|
|
39
|
+
# This legacy `grant` method requires the secret key to be set on the client.
|
|
40
|
+
envelope = pubnub.grant(
|
|
41
|
+
categories: %w[channels uuids],
|
|
42
|
+
auth_key: 'my-auth-key',
|
|
43
|
+
get: true,
|
|
44
|
+
ttl: 15,
|
|
45
|
+
http_sync: true
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
puts envelope.status
|
|
49
|
+
# snippet.end
|
|
@@ -25,7 +25,7 @@ module Pubnub
|
|
|
25
25
|
if options[:http_sync]
|
|
26
26
|
sync_all_history_messages(channel, include_token, page_size, reverse, maximum, callback, start: start_tt, end: end_tt)
|
|
27
27
|
else
|
|
28
|
-
async_all_history_messages(options)
|
|
28
|
+
async_all_history_messages(options.merge(callback: callback))
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -42,7 +42,7 @@ module Pubnub
|
|
|
42
42
|
if options[:http_sync]
|
|
43
43
|
sync_paged_history(channel, page, limit, include_token, callback, start: start_tt, end: end_tt)
|
|
44
44
|
else
|
|
45
|
-
async_paged_history(options)
|
|
45
|
+
async_paged_history(options.merge(callback: callback))
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
|
data/lib/pubnub/events/grant.rb
CHANGED
|
@@ -7,6 +7,7 @@ module Pubnub
|
|
|
7
7
|
|
|
8
8
|
def initialize(options, app)
|
|
9
9
|
@event = current_operation
|
|
10
|
+
@categories = format_categories(options[:categories])
|
|
10
11
|
super
|
|
11
12
|
@uuids = Formatter::format_uuid(options[:uuids]) unless options[:uuids].nil?
|
|
12
13
|
@ttl ||= Pubnub::Constants::DEFAULT_TTL
|
|
@@ -18,10 +19,22 @@ module Pubnub
|
|
|
18
19
|
Pubnub::Constants::OPERATION_GRANT
|
|
19
20
|
end
|
|
20
21
|
|
|
22
|
+
def format_categories(categories)
|
|
23
|
+
formatted = case categories
|
|
24
|
+
when NilClass then return nil
|
|
25
|
+
when Array then categories.map { |category| category.to_s.strip }
|
|
26
|
+
when String, Symbol then categories.to_s.split(',').map(&:strip)
|
|
27
|
+
else return categories
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
formatted.empty? ? nil : formatted
|
|
31
|
+
end
|
|
32
|
+
|
|
21
33
|
def parameters(signature = false)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
category_grant = !@categories.nil?
|
|
35
|
+
write = (category_grant && @write.nil?) || [0, '0', false].include?(@write) ? 0 : 1
|
|
36
|
+
read = (category_grant && @read.nil?) || [0, '0', false].include?(@read) ? 0 : 1
|
|
37
|
+
manage = (category_grant && @manage.nil?) || [0, '0', false].include?(@manage) ? 0 : 1 # unless @group.blank?
|
|
25
38
|
delete = [0, '0', false].include?(@delete) ? 0 : 1 unless @delete.nil?
|
|
26
39
|
get = [0, '0', false].include?(@get) ? 0 : 1 unless @get.nil?
|
|
27
40
|
update = [0, '0', false].include?(@update) ? 0 : 1 unless @update.nil?
|
|
@@ -35,7 +48,8 @@ module Pubnub
|
|
|
35
48
|
g: get,
|
|
36
49
|
u: update,
|
|
37
50
|
j: join,
|
|
38
|
-
ttl: @ttl
|
|
51
|
+
ttl: @ttl,
|
|
52
|
+
category: (@categories.join(',') unless @categories.nil?) }.delete_if { |_k, v| v.nil? }.merge(super(signature))
|
|
39
53
|
end
|
|
40
54
|
|
|
41
55
|
def path
|
|
@@ -12,6 +12,7 @@ module Pubnub
|
|
|
12
12
|
options[:channel_groups] = options[:channel_groups] || {}
|
|
13
13
|
@spaces_permissions = options[:spaces_permissions] || {}
|
|
14
14
|
@users_permissions = options[:users_permissions] || {}
|
|
15
|
+
@categories = options[:categories] || {}
|
|
15
16
|
super
|
|
16
17
|
end
|
|
17
18
|
|
|
@@ -31,7 +32,8 @@ module Pubnub
|
|
|
31
32
|
meta: @meta,
|
|
32
33
|
uuid: uuid,
|
|
33
34
|
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)
|
|
35
|
+
patterns: prepare_permissions(:pattern, @channels, @channel_groups, @uuids, @spaces_permissions, @users_permissions),
|
|
36
|
+
categories: prepare_categories(@categories)
|
|
35
37
|
}.select { |_, v| v }
|
|
36
38
|
}
|
|
37
39
|
body = Formatter.format_message(raw_body, nil, false)
|
|
@@ -70,6 +72,12 @@ module Pubnub
|
|
|
70
72
|
.to_h { |k, v| [k, v.calculate_bitmask] }
|
|
71
73
|
end
|
|
72
74
|
|
|
75
|
+
def prepare_categories(categories)
|
|
76
|
+
return nil if categories.empty?
|
|
77
|
+
|
|
78
|
+
categories.to_h { |k, v| [k.to_s, v.calculate_bitmask] }
|
|
79
|
+
end
|
|
80
|
+
|
|
73
81
|
def valid_envelope(parsed_response, req_res_objects)
|
|
74
82
|
Pubnub::Envelope.new(
|
|
75
83
|
event: @event,
|
|
@@ -146,6 +154,13 @@ module Pubnub
|
|
|
146
154
|
join: join
|
|
147
155
|
)
|
|
148
156
|
end
|
|
157
|
+
|
|
158
|
+
def cat(get: false)
|
|
159
|
+
Permissions.new(
|
|
160
|
+
type: :category,
|
|
161
|
+
get: get
|
|
162
|
+
)
|
|
163
|
+
end
|
|
149
164
|
end
|
|
150
165
|
|
|
151
166
|
def initialize(options)
|
|
@@ -12,6 +12,7 @@ module Pubnub
|
|
|
12
12
|
validate_keys!
|
|
13
13
|
validate_ttl!
|
|
14
14
|
validate_uuids!
|
|
15
|
+
validate_categories!
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
private
|
|
@@ -37,6 +38,27 @@ module Pubnub
|
|
|
37
38
|
)
|
|
38
39
|
end
|
|
39
40
|
|
|
41
|
+
def validate_categories!
|
|
42
|
+
return if @categories.nil?
|
|
43
|
+
|
|
44
|
+
raise(
|
|
45
|
+
ArgumentError.new(object: self, message: ':categories has to be kind of String, Symbol or Array for grant event.'),
|
|
46
|
+
':categories has to be kind of String, Symbol or Array for grant event.'
|
|
47
|
+
) unless @categories.is_a?(Array)
|
|
48
|
+
|
|
49
|
+
raise(
|
|
50
|
+
ArgumentError.new(object: self, message: ':categories supports only channels and uuids for grant event.'),
|
|
51
|
+
':categories supports only channels and uuids for grant event.'
|
|
52
|
+
) unless (@categories - %w[channels uuids]).empty?
|
|
53
|
+
|
|
54
|
+
# Use the per-call option: PAM#initialize resets @auth_key to options[:auth_key], so a client-level
|
|
55
|
+
# auth_key is never sent as the grant target `auth`.
|
|
56
|
+
raise(
|
|
57
|
+
ArgumentError.new(object: self, message: ':auth_key is required for grant event on categories.'),
|
|
58
|
+
':auth_key is required for grant event on categories.'
|
|
59
|
+
) if @given_options[:auth_key].nil? || @given_options[:auth_key].to_s.empty?
|
|
60
|
+
end
|
|
61
|
+
|
|
40
62
|
def validate_uuids!
|
|
41
63
|
return if @uuids.nil?
|
|
42
64
|
|
|
@@ -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_categories!
|
|
15
16
|
validate_objects_entities_separation!
|
|
16
17
|
end
|
|
17
18
|
|
|
@@ -47,6 +48,27 @@ module Pubnub
|
|
|
47
48
|
) unless arg.is_a?(Hash)
|
|
48
49
|
end
|
|
49
50
|
|
|
51
|
+
def validate_categories!
|
|
52
|
+
return if @categories.nil?
|
|
53
|
+
|
|
54
|
+
raise(
|
|
55
|
+
ArgumentError.new(object: self, message: ':categories has to be kind of Hash for grant token event.'),
|
|
56
|
+
':categories has to be kind of Hash for grant token event.'
|
|
57
|
+
) unless @categories.is_a?(Hash)
|
|
58
|
+
|
|
59
|
+
@categories.each do |key, value|
|
|
60
|
+
raise(
|
|
61
|
+
ArgumentError.new(object: self, message: ':categories supports only :channels and :uuids keys for grant token event.'),
|
|
62
|
+
':categories supports only :channels and :uuids keys for grant token event.'
|
|
63
|
+
) unless %w[channels uuids].include?(key.to_s)
|
|
64
|
+
|
|
65
|
+
raise(
|
|
66
|
+
ArgumentError.new(object: self, message: ':categories values have to be created with Pubnub::Permissions.cat for grant token event.'),
|
|
67
|
+
':categories values have to be created with Pubnub::Permissions.cat for grant token event.'
|
|
68
|
+
) unless value.is_a?(Pubnub::Permissions) && value.type == :category
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
50
72
|
def validate_objects_entities_separation!
|
|
51
73
|
entities_set = !@spaces_permissions.empty? ||
|
|
52
74
|
!@users_permissions.empty?
|
data/lib/pubnub/version.rb
CHANGED
data/pubnub.gemspec
CHANGED
|
@@ -11,6 +11,10 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.description = 'Ruby anywhere in the world in 250ms with PubNub!'
|
|
12
12
|
spec.homepage = 'https://github.com/pubnub/ruby'
|
|
13
13
|
spec.licenses = ['LicenseRef-LICENSE.txt']
|
|
14
|
+
spec.metadata = {
|
|
15
|
+
"changelog_uri" => "https://www.pubnub.com/docs/sdks/ruby/changelog",
|
|
16
|
+
"documentation_uri" => "https://www.pubnub.com/docs/sdks/ruby",
|
|
17
|
+
}
|
|
14
18
|
|
|
15
19
|
spec.files = `git ls-files -z`.split("\x0").grep_v(/^(test|spec|fixtures)/)
|
|
16
20
|
spec.executables = spec.files.grep(%r{^bin\/}) { |f| File.basename(f) }
|
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: 6.
|
|
4
|
+
version: 6.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PubNub
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -185,6 +185,7 @@ files:
|
|
|
185
185
|
- Rakefile
|
|
186
186
|
- VERSION
|
|
187
187
|
- config/cucumber.yml
|
|
188
|
+
- docs-snippets/access_manager.rb
|
|
188
189
|
- docs.md
|
|
189
190
|
- features/step_definitions/access_steps.rb
|
|
190
191
|
- features/step_definitions/crypto_steps.rb
|
|
@@ -332,7 +333,9 @@ files:
|
|
|
332
333
|
homepage: https://github.com/pubnub/ruby
|
|
333
334
|
licenses:
|
|
334
335
|
- LicenseRef-LICENSE.txt
|
|
335
|
-
metadata:
|
|
336
|
+
metadata:
|
|
337
|
+
changelog_uri: https://www.pubnub.com/docs/sdks/ruby/changelog
|
|
338
|
+
documentation_uri: https://www.pubnub.com/docs/sdks/ruby
|
|
336
339
|
post_install_message:
|
|
337
340
|
rdoc_options: []
|
|
338
341
|
require_paths:
|