0.0
No commit activity in last 3 years
No release in over 3 years
Firebase API Wrapper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

> 3.0
> 2.0
 Project Readme

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