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 +4 -4
- data/README.md +21 -12
- data/firebase-admin-sdk.gemspec +1 -2
- data/lib/firebase/admin/auth/token_verifier.rb +1 -1
- data/lib/firebase/admin/auth/user_info.rb +6 -6
- data/lib/firebase/admin/auth/user_manager.rb +2 -2
- data/lib/firebase/admin/auth/user_record.rb +5 -5
- data/lib/firebase/admin/internal/http_client.rb +0 -1
- data/lib/firebase/admin/version.rb +1 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70f5ac81488726bd977898980155890e557f9e2894072ad8e1873e6c60ab99b6
|
4
|
+
data.tar.gz: 97732224127a66ffe81483584706ce505471c7a8f0965d7b2be1f9a135fd3cbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55f1db8f3ea1cb752e50f4cfff1d94230e86270021210e3a3f16d4bc49f8974b80440ebc1f507e4e454aa72d61adf9b62595d92f4a1a08205f2af15534fd5c1c
|
7
|
+
data.tar.gz: 85d8984833119d962ee80c1dc90bb45276f13ae006e7e165f2ae15e938529782379cfca5fa117764449ed4963f8d6c94a6d7ef5c913b926077ca615ca0c13737
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
# Firebase
|
1
|
+
# Firebase Admin Ruby SDK
|
2
2
|
|
3
|
-
|
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
|
-
|
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
|
-
|
29
|
+
### Application Default Credentials
|
26
30
|
|
27
|
-
|
31
|
+
```ruby
|
32
|
+
gem 'firebase-admin-sdk'
|
28
33
|
|
29
|
-
|
34
|
+
app = Firebase::Admin::App.new
|
35
|
+
```
|
30
36
|
|
31
|
-
|
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/
|
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).
|
data/firebase-admin-sdk.gemspec
CHANGED
@@ -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
|
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."
|
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
|
20
|
+
@data["rawId"]
|
21
21
|
end
|
22
22
|
|
23
23
|
# Gets the display name of this user.
|
24
24
|
def display_name
|
25
|
-
@data
|
25
|
+
@data["displayName"]
|
26
26
|
end
|
27
27
|
|
28
28
|
# Gets the email address associated with this user.
|
29
29
|
def email
|
30
|
-
@data
|
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
|
35
|
+
@data["phoneNumber"]
|
36
36
|
end
|
37
37
|
|
38
38
|
# Gets the photo url of this user.
|
39
39
|
def photo_url
|
40
|
-
@data
|
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
|
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(
|
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[
|
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
|
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
|
21
|
+
!!@data["emailVerified"]
|
22
22
|
end
|
23
23
|
|
24
24
|
def disabled?
|
25
|
-
!!@data
|
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
|
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
|
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)
|
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.
|
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-
|
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
|
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
|
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
|