Sha256: 01b6c91b72cc7b9ce7c149a334dcfa0005bf366a5f3947b342bbdf081821e9ca

Contents?: true

Size: 713 Bytes

Versions: 13

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

module GraphQL
  class Query
    # @api private
    # @see Query#query_fingerprint
    # @see Query#variables_fingerprint
    # @see Query#fingerprint
    module Fingerprint
      # Make an obfuscated hash of the given string (either a query string or variables JSON)
      # @param string [String]
      # @return [String] A normalized, opaque hash
      def self.generate(input_str)
        # Implemented to be:
        # - Short (and uniform) length
        # - Stable
        # - Irreversibly Opaque (don't want to leak variable values)
        # - URL-friendly
        bytes = Digest::SHA256.digest(input_str)
        Base64.urlsafe_encode64(bytes)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
graphql-1.11.3 lib/graphql/query/fingerprint.rb
graphql-1.11.2 lib/graphql/query/fingerprint.rb
graphql-1.10.14 lib/graphql/query/fingerprint.rb
graphql-1.11.1 lib/graphql/query/fingerprint.rb
graphql-1.10.13 lib/graphql/query/fingerprint.rb
graphql-1.11.0 lib/graphql/query/fingerprint.rb
graphql-1.10.12 lib/graphql/query/fingerprint.rb
graphql-1.10.11 lib/graphql/query/fingerprint.rb
graphql-1.10.10 lib/graphql/query/fingerprint.rb
graphql-1.10.9 lib/graphql/query/fingerprint.rb
graphql-1.10.8 lib/graphql/query/fingerprint.rb
graphql-1.10.7 lib/graphql/query/fingerprint.rb
graphql-1.10.6 lib/graphql/query/fingerprint.rb