fuser 0.2.0 → 0.3.0

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: 5d39fd7173f7cc8131e6594ebef9ede3171195b615a3bbfb576d417724c62803
4
- data.tar.gz: e9c9e60b2310c1b52b995810676e3d4c20c5001d5cdec126aab2a53fd718e524
3
+ metadata.gz: 11ac302f3ee23d43fec0c350b09f1317485b1a1ec423afb33d7e65be6b2150f7
4
+ data.tar.gz: 7efcd7a776ee06b5061726d214daefd41ee87208e075d0374615d407804bb803
5
5
  SHA512:
6
- metadata.gz: 0023a507b6fcbb80500ab216af1c4cad4bbed370e4c9a6245ce8121c845ddcfea522a302eb6f5a7ccb5ee7711bac414231e598d95d8a472ccac139d50094b8a3
7
- data.tar.gz: 975b6a235b3020ea883ef9a9814dfca1705a78ac65c7a8a9f5a90de1b246d50afdee43b5f3081b374789cdf6c85081d59ddbfa4bbd812a4eb5d7b0c9387842dc
6
+ metadata.gz: 838ea320e12b9fb06bcec1c6be1d6771a05b5e435021a2d00cd583c8ae7172fbb3810e19f258fdb37cfe321ef39abef7e627a483fb197169aa8fd03128dcc943
7
+ data.tar.gz: 03c04133004f2ed30ae80d03a54d871ff652f7e1c1c5e544be39a10bce97546720f8361a87dd85b7511b57540cc0a6843a883280aca995a8b71f93a2511adf1d
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ /.env
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fuser (0.2.0)
4
+ fuser (0.3.0)
5
5
  httparty (~> 0.16.2)
6
6
  i18n (~> 1.1, >= 1.1.0)
7
7
 
@@ -10,10 +10,11 @@ GEM
10
10
  specs:
11
11
  addressable (2.5.2)
12
12
  public_suffix (>= 2.0.2, < 4.0)
13
- concurrent-ruby (1.1.4)
13
+ concurrent-ruby (1.1.5)
14
14
  crack (0.4.3)
15
15
  safe_yaml (~> 1.0.0)
16
16
  diff-lcs (1.3)
17
+ dotenv (2.7.1)
17
18
  hashdiff (0.3.7)
18
19
  httparty (0.16.4)
19
20
  mime-types (~> 3.0)
@@ -50,6 +51,7 @@ PLATFORMS
50
51
 
51
52
  DEPENDENCIES
52
53
  bundler (~> 1.16)
54
+ dotenv
53
55
  fuser!
54
56
  rake (~> 10.0)
55
57
  rspec (~> 3.0)
data/README.md CHANGED
@@ -18,6 +18,70 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ Add api to Fuser config:
22
+
23
+
24
+ # config/initializers
25
+ Fuser.configure do |config|
26
+ config.api_key = <your_firebase_app_api_key>
27
+ end
28
+
29
+
30
+ # Basic Usage
31
+
32
+ Fuser.<action>(<action_params_hash>)
33
+
34
+ => #<Fuser::Response:0x000056231221eb08 @response=#<Net::HTTPOK 200 OK readbody=true>, @action=<action_name>>
35
+
36
+
37
+ # Example
38
+
39
+ Sign Up with emain/password:
40
+
41
+
42
+ firebase_response = Fuser.sign_up(email: 'email@example.com', password: 'password')
43
+
44
+ => #<Fuser::Response:0x000056231221eb08 @response=#<Net::HTTPOK 200 OK readbody=true>, @action=:sign_up>
45
+
46
+ firebase_response.body
47
+
48
+ {
49
+ "kind" =>
50
+ "identitytoolkit#SignupNewUserResponse",
51
+ "idToken" => "eyJhbGciOiJSUzI1NiIsImtpZCI6IjBhZDdkNTY3ZWQ3M2M2NTEzZWQ0ZTE0ZTc4OGRjZWU4NjZlMzY3ZDMiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL3NlY3VyZXRva2VuLmdvb2dsZS5jb20vZnVzZXItdGVzdCIsImF1ZCI6ImZ1c2VyLXRlc3QiLCJhdXRoX3RpbWUiOjE1NTI1NzgwMzUsInVzZXJfaWQiOiJIWjVKR0t5MlVYYlk5Nk9VMTdseFBQZXdiUHExIiwic3ViIjoiSFo1SkdLeTJVWGJZOTZPVTE3bHhQUGV3YlBxMSIsImlhdCI6MTU1MjU3ODAzNSwiZXhwIjoxNTUyNTgxNjM1LCJlbWFpbCI6ImRlZW1hazEzQHJhbWJsZXIucnUiLCJlbWFpbF92ZXJpZmllZCI6ZmFsc2UsImZpcmViYXNlIjp7ImlkZW50aXRpZXMiOnsiZW1haWwiOlsiZGVlbWFrMTNAcmFtYmxlci5ydSJdfSwic2lnbl9pbl9wcm92aWRlciI6InBhc3N3b3JkIn19.tY8vf2tDfzInbsTAA01GkJmwAwIOfLdqv25BR4ag9eGgR5mo2J9FR9qNRTfoclWiFBl0qlh1bq_XkYYWixkr4zasEhzJwvYBuUYJ1Q3I0R9VHEIB2FudQGRvQhLr8ZbTzGu4E-Q_6BP9zP27pBvGbYDBQmy23TkWXLUKTA_drOrwB-vSwkeFDqf2hmhct9tbDzy8a3G764oPBPgANjkTUVHMtGz-gPoZQ8GZQG9MtAJu4dh01oM6jJtole-0DfQydoTZfvCPuTlHtUa0TOqzn6mZ51pS2XzCEct15TJabpKkRbHHJUSDQRpxQtWPfdeluwbKrshm-RvAqxsXPj2IAg",
52
+ "email" => "deemak13@rambler.ru",
53
+ "refreshToken" => "AEu4IL1UAqJCMvidiR0v62n6Ajf6JqJrpc2GvemoQ1Ip-HC-JzjIWZ_qslYF6p_vMOjcy6jbALuz7Bpj3RkH0qa5tUZZ7crex3F8a-7r9aDH62gGBPilC20d4luieSHKTX14e_naquuJtBoNjuk6r9F4KLVgs1Ay-AtuWSwCN4pC318uZW_9tuictUpnFuJJMFgdJtFYDzAo",
54
+ "expiresIn"=>"3600",
55
+ "localId"=>"HZ5JGKy2UXbY96OU17lxPPewbPq1"
56
+ }
57
+
58
+ firebase_response.success?
59
+
60
+ => true
61
+
62
+
63
+
64
+ Actions List:
65
+
66
+
67
+ Action (method) | Params
68
+ --------------------------- | ----------------
69
+ verify_token | `token` - A Firebase Auth custom token from which to create an ID and refresh token pair.
70
+ refreshToken | `token` - A Firebase Auth refresh token.
71
+ sign_up, sign_in | `email` - The email for the user sign in / sign up.<br>`password` - The password for the user to sign in / sign up
72
+ anonymous_sign_in | sign in a user anonymously, no params needed
73
+ reset_password | `email` - User's email address.
74
+ verify_reset_password | `oob_code` - The email action code sent to the user's email for resetting the password.
75
+ confirm_reset_password | `email` - User's email address.<br>`oob_code` - The email action code sent to the user's email for resetting the password.
76
+ set_account_info | `token` - A Firebase Auth ID token for the user.<br>`email` - user's new email.<br>`password` - user's new password<br>`display_name` - user's new display name.<br>`photo_url` - user's new photo url<br>`delete_attributes` - List of attributes to delete, "DISPLAY_NAME" or "PHOTO_URL". This will nullify these values.
77
+ get_account_info | `token` - A Firebase Auth ID token of the user.
78
+ oauth_sign_in | `access_token` - For login with OAuth Access Token<br>`id_token` - For login with OAuth ID Token<br>`oauth_token_secret` - OAuth Token Secret (for Twitter)<br>`provider_id` - OAuth provider (`facebook.com`, `google.com` or `twitter.com`)<br>`request_uri` - The URI to which the IDP redirects the user back.
79
+ oauth_link | `token` - A Firebase Auth ID toke of the user to link<br>`access_token` - For login with OAuth Access Token<br>`id_token` - For login with OAuth ID Token<br>`oauth_token_secret` - OAuth Token Secret (for Twitter)<br>`provider_id` - OAuth provider (`facebook.com`, `google.com` or `twitter.com`)<br>`request_uri` - The URI to which the IDP redirects the user back.
80
+ unlink_provider | `token` - A Firebase Auth ID toke of the user to unlink<br>`providers` - The list of provider IDs to unlink, eg: 'google.com', 'password', etc.
81
+ send_email_verification | `token` - A Firebase Auth ID toke of the user to unlink
82
+ confirm_email_verification | `oob_code` - The action code sent to user's email for email verification.
83
+ delete_account | `token` - A Firebase Auth ID toke of the user to unlink
84
+
21
85
  ## Development
22
86
 
23
87
  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.
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require 'bundler/setup'
5
+ require 'dotenv/load'
5
6
  require 'fuser'
6
7
 
7
8
  # You can add fixtures and/or initialization code here to make experimenting
@@ -11,5 +12,9 @@ require 'fuser'
11
12
  # require "pry"
12
13
  # Pry.start
13
14
 
15
+ Fuser.configure do |config|
16
+ config.api_key = ENV['FIREBASE_API_KEY']
17
+ end
18
+
14
19
  require 'irb'
15
20
  IRB.start(__FILE__)
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency 'rake', '~> 10.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
29
  spec.add_development_dependency 'webmock', '~> 3.4', '>= 3.4.2'
30
+ spec.add_development_dependency 'dotenv'
30
31
  end
@@ -24,7 +24,7 @@ module Fuser
24
24
  end
25
25
 
26
26
  I18n.t('fuser.endpoints').keys.each do |request_action|
27
- define_singleton_method request_action do |params|
27
+ define_singleton_method request_action do |params = {}|
28
28
  call(request_action, params)
29
29
  end
30
30
  end
@@ -8,7 +8,7 @@ module Fuser
8
8
  new(*args).call
9
9
  end
10
10
 
11
- def initialize(action, params:)
11
+ def initialize(action, params: {})
12
12
  @action = action
13
13
  @params = params
14
14
  end
@@ -65,25 +65,20 @@ module Fuser
65
65
  'oobCode': params[:oob_code],
66
66
  'newPassword': params[:new_password]
67
67
  }
68
- when :change_email then
69
- {
70
- 'idToken': params[:token],
71
- 'email': params[:email],
72
- 'returnSecureToken': true
73
- }
74
- when :change_password then
75
- {
76
- 'idToken': params[:token],
77
- 'password': params[:password],
78
- 'returnSecureToken': true
79
- }
80
68
  when :set_account_info then
81
69
  {
82
70
  'idToken': params[:token],
83
71
  'email': params[:email],
84
72
  'password': params[:password],
73
+ 'displayName': params[:display_name],
74
+ 'photoUrl': params[:photo_url],
75
+ 'deleteAttribute': params[:delete_attributes],
85
76
  'returnSecureToken': true
86
77
  }.compact
78
+ when :get_account_info then
79
+ {
80
+ 'idToken': params[:token]
81
+ }
87
82
  when :oauth_sign_in then
88
83
  {
89
84
  'postBody': oauth_post_body(params),
@@ -91,6 +86,32 @@ module Fuser
91
86
  'returnSecureToken': true,
92
87
  'returnIdpCredential': true
93
88
  }
89
+ when :oauth_link then
90
+ {
91
+ 'idToken': params[:token],
92
+ 'postBody': oauth_post_body(params),
93
+ 'requestUri': params[:request_uri],
94
+ 'returnSecureToken': true,
95
+ 'returnIdpCredential': true
96
+ }
97
+ when :unlink_provider then
98
+ {
99
+ 'idToken': params[:token],
100
+ 'deleteProvider': params[:providers]
101
+ }
102
+ when :send_email_verification then
103
+ {
104
+ 'idToken': params[:token],
105
+ 'requestType': 'VERIFY_EMAIL'
106
+ }
107
+ when :confirm_email_verification then
108
+ {
109
+ 'oobCode': params[:oob_code]
110
+ }
111
+ when :delete_account then
112
+ {
113
+ 'idToken': params[:token]
114
+ }
94
115
  end
95
116
  end
96
117
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fuser
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -1,17 +1,24 @@
1
1
  en:
2
2
  fuser:
3
3
  endpoints:
4
- verify_token: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getAccountInfo?key=%{api_key}"
5
- refresh_token: "https://securetoken.googleapis.com/v1/token?key=%{api_key}"
6
- sign_up: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=%{api_key}"
7
- sign_in: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=%{api_key}"
8
- reset_password: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getOobConfirmationCode?key=%{api_key}"
9
- verify_reset_password: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/resetPassword?key=%{api_key}"
10
- confirm_reset_password: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/resetPassword?key=%{api_key}"
11
- change_email: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=%{api_key}"
12
- change_password: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=%{api_key}"
13
- set_account_info: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=%{api_key}"
14
- oauth_sign_in: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key=%{api_key}"
4
+ verify_token: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getAccountInfo?key=%{api_key}"
5
+ refresh_token: "https://securetoken.googleapis.com/v1/token?key=%{api_key}"
6
+ anonymous_sign_in: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=%{api_key}"
7
+ sign_up: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/signupNewUser?key=%{api_key}"
8
+ sign_in: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=%{api_key}"
9
+ reset_password: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getOobConfirmationCode?key=%{api_key}"
10
+ verify_reset_password: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/resetPassword?key=%{api_key}"
11
+ confirm_reset_password: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/resetPassword?key=%{api_key}"
12
+ change_email: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=%{api_key}"
13
+ change_password: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=%{api_key}"
14
+ set_account_info: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=%{api_key}"
15
+ get_account_info: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getAccountInfo?key=%{api_key}"
16
+ oauth_sign_in: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key=%{api_key}"
17
+ oauth_link: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key=%{api_key}"
18
+ unlink_provider: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=%{api_key}"
19
+ send_email_verification: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/getOobConfirmationCode?key=%{api_key}"
20
+ confirm_email_verification: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=%{api_key}"
21
+ delete_account: "https://www.googleapis.com/identitytoolkit/v3/relyingparty/deleteAccount?key=%{api_key}"
15
22
  errors:
16
23
  default: "Something went wrong please try again."
17
24
  sign_up:
@@ -25,6 +32,7 @@ en:
25
32
  anonymous_sign_in:
26
33
  operation_not_allowed: "Anonymous user sign-in is disabled for this project."
27
34
  verify_token:
35
+ invalid_id_token: "ID Token format is incorrect or the token is invalid for some reason."
28
36
  invalid_custom_token: "The custom token format is incorrect or the token is invalid for some reason."
29
37
  credential_mismatch: "The custom token corresponds to a different Firebase project."
30
38
  refresh_token:
@@ -45,12 +53,6 @@ en:
45
53
  expired_oob_code: "The action code has expired."
46
54
  invalid_oob_code: "The action code is invalid. This can happen if the code is malformed, expired, or has already been used."
47
55
  user_disabled: "The user account has been disabled by an administrator."
48
- change_email:
49
- email_exists: "The email address is already in use by another account."
50
- invalid_id_token: "The user's credential is no longer valid. The user must sign in again."
51
- change_password:
52
- invalid_id_token: "The user's credential is no longer valid. The user must sign in again."
53
- weak_password: "The password must be 6 characters long or more."
54
56
  set_account_info:
55
57
  credentials_too_old_login_again: "The user's credential is no longer valid. The user must sign in again."
56
58
  invalid_id_token: "The user's credential is no longer valid. The user must sign in again."
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DeeMak13
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-08 00:00:00.000000000 Z
11
+ date: 2019-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -106,6 +106,20 @@ dependencies:
106
106
  - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: 3.4.2
109
+ - !ruby/object:Gem::Dependency
110
+ name: dotenv
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
109
123
  description: Ruby wrapper for Firebase's native and third-party authentication.
110
124
  email:
111
125
  - deemakk13@gmail.com