firebase-admin-sdk 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 123d6d32ec877dc2478f43d37762c2fad6dee697d21bc746dbd63d16c7688ab0
4
- data.tar.gz: 9a4decd758386fb6c87ad73607d949842f7a7f2e659b6d6fe659f62d0bdd0d40
3
+ metadata.gz: 70f5ac81488726bd977898980155890e557f9e2894072ad8e1873e6c60ab99b6
4
+ data.tar.gz: 97732224127a66ffe81483584706ce505471c7a8f0965d7b2be1f9a135fd3cbf
5
5
  SHA512:
6
- metadata.gz: c806d219be3867c552aff868f296854ac0a348fa9d9c04063c874e201810dda370a63b7fb425d38fe2bbfe8af13043bcef8cef632a2f888eca547bfa48815dbc
7
- data.tar.gz: 7c187c93c943c8dbc352cf153f82d45fb27b1cd1febde4773c7e5cc3cdbb5492848c051afd96f139c2af4e7b6fad3bce11cd86e5fa280155d8d434286d36d841
6
+ metadata.gz: 55f1db8f3ea1cb752e50f4cfff1d94230e86270021210e3a3f16d4bc49f8974b80440ebc1f507e4e454aa72d61adf9b62595d92f4a1a08205f2af15534fd5c1c
7
+ data.tar.gz: 85d8984833119d962ee80c1dc90bb45276f13ae006e7e165f2ae15e938529782379cfca5fa117764449ed4963f8d6c94a6d7ef5c913b926077ca615ca0c13737
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
- # Firebase::Admin::Sdk
1
+ # Firebase Admin Ruby SDK
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/firebase/admin/sdk`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ The Firebase Admin Ruby SDK enables access to Firebase services from privileged environments (such as servers or cloud)
4
+ in Ruby.
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ For more information, visit the
7
+ [Firebase Admin SDK setup guide](https://firebase.google.com/docs/admin/setup/).
8
+
9
+ This gem is currently in alpha and not recommended for production use (yet).
6
10
 
7
11
  ## Installation
8
12
 
@@ -22,22 +26,27 @@ Or install it yourself as:
22
26
 
23
27
  ## Usage
24
28
 
25
- TODO: Write usage instructions here
29
+ ### Application Default Credentials
26
30
 
27
- ## Development
31
+ ```ruby
32
+ gem 'firebase-admin-sdk'
28
33
 
29
- 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.
34
+ app = Firebase::Admin::App.new
35
+ ```
30
36
 
31
- 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37
+ ### Using a service account
38
+
39
+ ```ruby
40
+ gem 'firebase-admin-sdk'
41
+
42
+ creds = Firebase::Admin::Credentials.from_file('service_account.json')
43
+ app = Firebase::Admin::App.new(credentials: creds)
44
+ ```
32
45
 
33
46
  ## Contributing
34
47
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/firebase-admin-sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/firebase-admin-sdk/blob/master/CODE_OF_CONDUCT.md).
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cheddar-me/firebase-admin-sdk.
36
49
 
37
50
  ## License
38
51
 
39
52
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the Firebase::Admin::Sdk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/firebase-admin-sdk/blob/master/CODE_OF_CONDUCT.md).
@@ -21,10 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = "bin"
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_runtime_dependency "googleauth", "~> 0.16.2"
24
+ spec.add_runtime_dependency "googleauth", "~> 0.16"
25
25
  spec.add_runtime_dependency "faraday", "< 2"
26
26
  spec.add_runtime_dependency "faraday_middleware", "~> 1.0"
27
- spec.add_runtime_dependency "hashie", "~> 4.1"
28
27
  spec.add_runtime_dependency "jwt", ">= 1.5", "< 3.0"
29
28
 
30
29
  spec.add_development_dependency "rake", "~> 13.0"
@@ -78,7 +78,7 @@ module Firebase
78
78
  def decode_unsigned(token)
79
79
  raise InvalidTokenError, "token must not be nil" unless token
80
80
  raise InvalidTokenError, "token must be a string" unless token.is_a?(String)
81
- raise InvalidTokenError, "The auth emulator only accepts unsigned ID tokens." unless token.split(".").length == 2
81
+ raise InvalidTokenError, "The auth emulator only accepts unsigned ID tokens." if token.split(".").length == 3
82
82
  options = decode_options.merge({algorithm: "none"})
83
83
  JWT.decode(token, nil, false, options)
84
84
  end
@@ -17,27 +17,27 @@ module Firebase
17
17
 
18
18
  # Gets the ID of this user.
19
19
  def uid
20
- @data.fetch(:rawId)
20
+ @data["rawId"]
21
21
  end
22
22
 
23
23
  # Gets the display name of this user.
24
24
  def display_name
25
- @data.fetch(:displayName)
25
+ @data["displayName"]
26
26
  end
27
27
 
28
28
  # Gets the email address associated with this user.
29
29
  def email
30
- @data.fetch(:email)
30
+ @data["email"]
31
31
  end
32
32
 
33
33
  # Gets the phone number associated with this user.
34
34
  def phone_number
35
- @data.fetch(:phoneNumber)
35
+ @data["phoneNumber"]
36
36
  end
37
37
 
38
38
  # Gets the photo url of this user.
39
39
  def photo_url
40
- @data.fetch(:photoUrl)
40
+ @data["photoUrl"]
41
41
  end
42
42
 
43
43
  # Gets the id of the identity provider.
@@ -45,7 +45,7 @@ module Firebase
45
45
  # This can be a short domain name (e.g. google.com), or the identity of an OpenID
46
46
  # identity provider.
47
47
  def provider_id
48
- @data.fetch(:providerId)
48
+ @data["providerId"]
49
49
  end
50
50
 
51
51
  # Converts the object into a hash.
@@ -43,7 +43,7 @@ module Firebase
43
43
  disabled: to_boolean(disabled)
44
44
  }.compact
45
45
  res = @client.post(with_path("accounts"), payload).body
46
- uid = res&.fetch(:localId)
46
+ uid = res&.fetch("localId")
47
47
  raise CreateUserError, "failed to create user #{res}" if uid.nil?
48
48
  get_user_by(uid: uid)
49
49
  end
@@ -67,7 +67,7 @@ module Firebase
67
67
  raise ArgumentError, "Unsupported query: #{query}"
68
68
  end
69
69
  res = @client.post(with_path("accounts:lookup"), payload).body
70
- users = res[:users] if res
70
+ users = res["users"] if res
71
71
  UserRecord.new(users[0]) if users.is_a?(Array) && users.length > 0
72
72
  end
73
73
 
@@ -7,7 +7,7 @@ module Firebase
7
7
  class UserRecord < UserInfo
8
8
  # Gets the ID of this user.
9
9
  def uid
10
- @data.fetch(:localId)
10
+ @data["localId"]
11
11
  end
12
12
 
13
13
  # Gets the id of the identity provider.
@@ -18,11 +18,11 @@ module Firebase
18
18
  end
19
19
 
20
20
  def email_verified?
21
- !!@data.fetch(:emailVerified)
21
+ !!@data["emailVerified"]
22
22
  end
23
23
 
24
24
  def disabled?
25
- !!@data.fetch(:disabled)
25
+ !!@data["disabled"]
26
26
  end
27
27
 
28
28
  # Gets the time, in milliseconds since the epoch, before which tokens are invalid.
@@ -49,13 +49,13 @@ module Firebase
49
49
  #
50
50
  # @return [Array of UserInfo]
51
51
  def provider_data
52
- providers = @data.fetch(:providerUserInfo) || []
52
+ providers = @data["providerUserInfo"] || []
53
53
  providers.to_a.map { |p| UserInfo.new(p) }
54
54
  end
55
55
 
56
56
  # Gets any custom claims set on this user account.
57
57
  def custom_claims
58
- claims = @data.fetch(:customAttributes)
58
+ claims = @data["customAttributes"]
59
59
  parsed = JSON.parse(claims) unless claims.nil?
60
60
  parsed if parsed.is_a?(Hash) && !parsed.empty?
61
61
  end
@@ -58,7 +58,6 @@ module Firebase
58
58
  c.use CredentialsMiddleware, credentials: @credentials unless @credentials.nil?
59
59
  c.use Faraday::Request::UrlEncoded
60
60
  c.use FaradayMiddleware::EncodeJson
61
- c.use FaradayMiddleware::Mashify
62
61
  c.use Faraday::Response::ParseJson
63
62
  c.use Faraday::Response::RaiseError
64
63
  c.adapter(Faraday.default_adapter)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Firebase
4
4
  module Admin
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firebase-admin-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tariq Zaid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-12 00:00:00.000000000 Z
11
+ date: 2021-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: googleauth
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.16.2
19
+ version: '0.16'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.16.2
26
+ version: '0.16'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
- - !ruby/object:Gem::Dependency
56
- name: hashie
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '4.1'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '4.1'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: jwt
71
57
  requirement: !ruby/object:Gem::Requirement