Class: LiveKit::TokenVerifier
- Inherits:
-
Object
- Object
- LiveKit::TokenVerifier
- Defined in:
- lib/livekit/token_verifier.rb
Instance Method Summary collapse
-
#initialize(api_key: nil, api_secret: nil) ⇒ TokenVerifier
constructor
A new instance of TokenVerifier.
- #verify(token) ⇒ Object
Constructor Details
#initialize(api_key: nil, api_secret: nil) ⇒ TokenVerifier
Returns a new instance of TokenVerifier.
7 8 9 10 |
# File 'lib/livekit/token_verifier.rb', line 7 def initialize(api_key: nil, api_secret: nil) @api_key = api_key @api_secret = api_secret end |
Instance Method Details
#verify(token) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/livekit/token_verifier.rb', line 12 def verify(token) decoded_token = JWT.decode(token, @api_secret, true, algorithm: AccessToken::SIGNING_ALGORITHM) decoded = decoded_token.first if decoded["iss"] != @api_key raise "Invalid issuer" end ClaimGrant.from_hash(decoded) end |