Sha256: d6b63c95cff68157e53138c7f7c07ba817a23ebf8388633e1cf367f49c519c98
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true require_relative "intercode_client/version" require 'graphql/client' require 'graphql/client/http' require 'json/jwt' module IntercodeClient class Error < StandardError; end def self.intercode_url ENV['INTERCODE_URL'] || 'https://www.neilhosting.net' end HTTP = GraphQL::Client::HTTP.new("#{IntercodeClient.intercode_url}/graphql") do def headers(context) context[:headers] || {} end end Schema = GraphQL::Client.load_schema( File.expand_path('../intercode_schema.json', __FILE__) ) Client = GraphQL::Client.new(schema: Schema, execute: HTTP) def self.decode_jwt(jwt) JSON::JWT.decode(jwt, IntercodeClient.jwk_set) end def self.jwk_set JSON::JWK::Set.new(JSON.parse(jwk_response)) end def self.jwk_response if !@jwk_response_last_fetched || @jwk_response_last_fetched < Time.now.to_i - 3600 @jwk_response_last_fetched = Time.now.to_i @jwk_response = Net::HTTP.get(URI("#{IntercodeClient.intercode_url}/oauth/discovery/keys")) end @jwk_response end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
intercode_client-0.1.1 | lib/intercode_client.rb |
intercode_client-0.1.0 | lib/intercode_client.rb |