Sha256: 8f7f9959b3871f0723f4fd872d7855b36cac724e605a185e22cb245023b0f984

Contents?: true

Size: 489 Bytes

Versions: 21

Compression:

Stored size: 489 Bytes

Contents

# frozen_string_literal: true

require "jwt"

module LiveKit
  class TokenVerifier
    def initialize(api_key: nil, api_secret: nil)
      @api_key = api_key
      @api_secret = api_secret
    end

    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
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
livekit-server-sdk-0.8.0 lib/livekit/token_verifier.rb
livekit-server-sdk-0.7.1 lib/livekit/token_verifier.rb
livekit-server-sdk-0.7.0 lib/livekit/token_verifier.rb
livekit-server-sdk-0.6.5 lib/livekit/token_verifier.rb
livekit-server-sdk-0.6.4 lib/livekit/token_verifier.rb
livekit-server-sdk-0.6.3 lib/livekit/token_verifier.rb
livekit-server-sdk-0.6.2 lib/livekit/token_verifier.rb
livekit-server-sdk-0.6.1 lib/livekit/token_verifier.rb
livekit-server-sdk-0.5.6 lib/livekit/token_verifier.rb
livekit-server-sdk-0.5.5 lib/livekit/token_verifier.rb
livekit-server-sdk-0.5.4 lib/livekit/token_verifier.rb
livekit-server-sdk-0.5.3 lib/livekit/token_verifier.rb
livekit-server-sdk-0.5.2 lib/livekit/token_verifier.rb
livekit-server-sdk-0.5.1 lib/livekit/token_verifier.rb
livekit-server-sdk-0.5.0 lib/livekit/token_verifier.rb
livekit-server-sdk-0.4.0 lib/livekit/token_verifier.rb
livekit-server-sdk-0.3.1 lib/livekit/token_verifier.rb
livekit-server-sdk-0.3.0 lib/livekit/token_verifier.rb
livekit-server-sdk-0.2.2 lib/livekit/token_verifier.rb
livekit-server-sdk-0.2.1 lib/livekit/token_verifier.rb