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
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')
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
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