Sha256: 27763b9b1f68eb19bc22386fabf217e8f1695c2c4f02e2d93239ede111b42022

Contents?: true

Size: 651 Bytes

Versions: 1

Compression:

Stored size: 651 Bytes

Contents

##
# Singleton module for exposing tokens
module Limp
  class << self
    def tokens
      @tokens ||= db_files.map { |x| read_tokens(x) }.flatten.uniq
    end

    private

    def base_dir
      @base_dir ||= File.expand_path(
        '~/Library/Application Support/Google/Chrome'
      )
    end

    def base_glob
      @base_glob ||= File.join(base_dir, '*/Local Storage/leveldb/*.ldb')
    end

    def db_files
      @db_files ||= Dir.glob(base_glob)
    end

    def token_regex
      @token_regex ||= /xoxs-\d+-\d+-\d+-\h+/
    end

    def read_tokens(db)
      File.read(db).force_encoding('ASCII-8BIT').scan(token_regex)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
limp-0.0.3 lib/limp.rb