Class: Stream::Signer
- Inherits:
-
Object
- Object
- Stream::Signer
- Defined in:
- lib/stream/signer.rb
Class Method Summary collapse
- .create_jwt_token(resource, action, api_secret, feed_id = nil, user_id = nil) ⇒ Object
- .create_user_token(user_id, payload = {}, api_secret) ⇒ Object
Instance Method Summary collapse
-
#initialize(key) ⇒ Signer
constructor
A new instance of Signer.
Constructor Details
#initialize(key) ⇒ Signer
Returns a new instance of Signer.
8 9 10 |
# File 'lib/stream/signer.rb', line 8 def initialize(key) @key = key.to_s end |
Class Method Details
.create_jwt_token(resource, action, api_secret, feed_id = nil, user_id = nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/stream/signer.rb', line 17 def self.create_jwt_token(resource, action, api_secret, feed_id = nil, user_id = nil) payload = { resource: resource, action: action } payload['feed_id'] = feed_id if feed_id payload['user_id'] = user_id if user_id JWT.encode(payload, api_secret, 'HS256') end |
.create_user_token(user_id, payload = {}, api_secret) ⇒ Object
12 13 14 15 |
# File 'lib/stream/signer.rb', line 12 def self.create_user_token(user_id, payload = {}, api_secret) payload['user_id'] = user_id JWT.encode(payload, api_secret, 'HS256') end |