Skip to content

πŸš’ πŸ‘¨β€πŸš’ πŸ‘©β€πŸš’ Talk to Firebase API from Ruby

License

Notifications You must be signed in to change notification settings

penseo/firefighter

Folders and files

NameName
Last commit message
Last commit date
Jul 10, 2020
Jul 12, 2018
Jan 5, 2021
Oct 10, 2020
Jul 12, 2018
Apr 16, 2019
Jul 12, 2018
Jan 5, 2021
Jul 12, 2018
Nov 27, 2018
Jul 12, 2021
Apr 16, 2019
Jan 5, 2021
Jul 12, 2018
Jul 10, 2020

Repository files navigation

Firefighter

Talk to Firebase API from Ruby:

  • identity: signup, account_info, accounts_download, verify_password
  • realtime: read, listen, write, add, delete data
  • tokens: generate JWT tokens for token-auth

Installation

Add this line to your application's Gemfile:

gem 'firefighter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install firefighter

Usage

# Firefighter::Identitytoolkit
# from_env uses environment variables:
# - FIREBASE_WEB_API_KEY
# - FIREBASE_SERVICE_ACCOUNT_EMAIL
identitytoolkit = Firefighter::Identitytoolkit.from_env

account = identitytoolkit.signup('test@test.de', 'totalgeheimespasswort')

account = identitytoolkit.account_info(account['idToken'])

accounts = identitytoolkit.download_accounts

account = identitytoolkit.verify_password('test@test.de', 'totalgeheimespasswort')
# Firefighter::RealtimeDatabase
# from_env uses environment variables:
# - FIREBASE_WEB_DB_NAME
# - FIREBASE_WEB_DB_SECRET
# - FIREBASE_WEB_DB_HOST (defaults to host for us-central1)

realtime_database = Firefighter::RealtimeDatabase.from_env

realtime_database.write("some-path/key", {some: 'data'})

hash = realtime_database.read("some-path/key")

realtime_database.add("some-path/list", {some: 'data'})

list = realtime_database.read("some-path/list")

realtime_database.delete("some-path/list")

realtime_database.listen("some-test/write/") do |connection, event, path, data|
  puts event, path, data
  connection.close
end
# Firefighter::TokenGenerator
# from_env uses environment variables:
# - FIREBASE_SERVICE_ACCOUNT_EMAIL
# - FIREBASE_SERVICE_ACCOUNT_PRIVATE_KEY
token_generator = Firefighter::TokenGenerator.from_env

access_token = token_generator.create_access_token

custom_token = token_generator.create_custom_token('someUid', data: {some: 'payload'})

payload = token_generator.read_token(custom_token)

token = token_generator.fetch_access_token

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/penseo/firefighter. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Code of Conduct

Everyone interacting in the Firefighter project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Changelog

changelog

About

πŸš’ πŸ‘¨β€πŸš’ πŸ‘©β€πŸš’ Talk to Firebase API from Ruby

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published