Skip to content

Commit

Permalink
Format GDScript files using Razoric's formatter + manual review
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronfranke committed Aug 27, 2022
1 parent a165c7a commit a73193c
Show file tree
Hide file tree
Showing 41 changed files with 3,314 additions and 3,220 deletions.
826 changes: 414 additions & 412 deletions addons/godot-firebase/auth/auth.gd

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions addons/godot-firebase/auth/auth_provider.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@ tool
class_name AuthProvider
extends Reference


var redirect_uri: String = ""
var access_token_uri: String = ""
var provider_id: String = ""
var params: Dictionary = {
client_id = "",
scope = "",
response_type = "",
state = "",
redirect_type = "redirect_uri",
client_id = "",
scope = "",
response_type = "",
state = "",
redirect_type = "redirect_uri",
}
var client_secret: String = ""
var should_exchange: bool = false


func set_client_id(client_id: String) -> void:
self.params.client_id = client_id
self.params.client_id = client_id


func set_client_secret(client_secret: String) -> void:
self.client_secret = client_secret
self.client_secret = client_secret


func get_client_id() -> String:
return self.params.client_id
return self.params.client_id


func get_client_secret() -> String:
return self.client_secret
return self.client_secret


func get_oauth_params() -> String:
return ""
return ""
35 changes: 17 additions & 18 deletions addons/godot-firebase/auth/providers/facebook.gd
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
class_name FacebookProvider
class_name FacebookProvider
extends AuthProvider


func _init(client_id: String, client_secret: String) -> void:
randomize()
set_client_id(client_id)
set_client_secret(client_secret)

self.redirect_uri = "https://www.facebook.com/v13.0/dialog/oauth?"
self.access_token_uri = "https://graph.facebook.com/v13.0/oauth/access_token"
self.provider_id = "facebook.com"
self.params.scope = "public_profile"
self.params.state = str(rand_range(0, 1))
if OS.get_name() == "HTML5":
self.should_exchange = false
self.params.response_type = "token"
else:
self.should_exchange = true
self.params.response_type = "code"


randomize()
set_client_id(client_id)
set_client_secret(client_secret)

self.redirect_uri = "https://www.facebook.com/v13.0/dialog/oauth?"
self.access_token_uri = "https://graph.facebook.com/v13.0/oauth/access_token"
self.provider_id = "facebook.com"
self.params.scope = "public_profile"
self.params.state = str(rand_range(0, 1))
if OS.get_name() == "HTML5":
self.should_exchange = false
self.params.response_type = "token"
else:
self.should_exchange = true
self.params.response_type = "code"
23 changes: 12 additions & 11 deletions addons/godot-firebase/auth/providers/github.gd
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
class_name GitHubProvider
class_name GitHubProvider
extends AuthProvider


func _init(client_id: String, client_secret: String) -> void:
randomize()
set_client_id(client_id)
set_client_secret(client_secret)
self.should_exchange = true
self.redirect_uri = "https://github.com/login/oauth/authorize?"
self.access_token_uri = "https://github.com/login/oauth/access_token"
self.provider_id = "github.com"
self.params.scope = "user:read"
self.params.state = str(rand_range(0, 1))
self.params.response_type = "code"
randomize()
set_client_id(client_id)
set_client_secret(client_secret)
self.should_exchange = true
self.redirect_uri = "https://github.com/login/oauth/authorize?"
self.access_token_uri = "https://github.com/login/oauth/access_token"
self.provider_id = "github.com"
self.params.scope = "user:read"
self.params.state = str(rand_range(0, 1))
self.params.response_type = "code"
19 changes: 10 additions & 9 deletions addons/godot-firebase/auth/providers/google.gd
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
class_name GoogleProvider
extends AuthProvider


func _init(client_id: String, client_secret: String) -> void:
set_client_id(client_id)
set_client_secret(client_secret)
self.should_exchange = true
self.redirect_uri = "https://accounts.google.com/o/oauth2/v2/auth?"
self.access_token_uri = "https://oauth2.googleapis.com/token"
self.provider_id = "google.com"
self.params.response_type = "code"
self.params.scope = "email openid profile"
self.params.response_type = "code"
set_client_id(client_id)
set_client_secret(client_secret)
self.should_exchange = true
self.redirect_uri = "https://accounts.google.com/o/oauth2/v2/auth?"
self.access_token_uri = "https://oauth2.googleapis.com/token"
self.provider_id = "google.com"
self.params.response_type = "code"
self.params.scope = "email openid profile"
self.params.response_type = "code"
60 changes: 31 additions & 29 deletions addons/godot-firebase/auth/providers/twitter.gd
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
class_name TwitterProvider
class_name TwitterProvider
extends AuthProvider


var request_token_endpoint: String = "https://api.twitter.com/oauth/access_token?oauth_callback="

var oauth_header: Dictionary = {
oauth_callback="",
oauth_consumer_key="",
oauth_nonce="",
oauth_signature="",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="",
oauth_version="1.0"
oauth_callback = "",
oauth_consumer_key = "",
oauth_nonce = "",
oauth_signature = "",
oauth_signature_method = "HMAC-SHA1",
oauth_timestamp = "",
oauth_version = "1.0"
}


func _init(client_id: String, client_secret: String) -> void:
randomize()
set_client_id(client_id)
set_client_secret(client_secret)
self.oauth_header.oauth_consumer_key = client_id
self.oauth_header.oauth_nonce = OS.get_ticks_usec()
self.oauth_header.oauth_timestamp = OS.get_ticks_msec()
self.should_exchange = true
self.redirect_uri = "https://twitter.com/i/oauth2/authorize?"
self.access_token_uri = "https://api.twitter.com/2/oauth2/token"
self.provider_id = "twitter.com"
self.params.redirect_type = "redirect_uri"
self.params.response_type = "code"
self.params.scope = "users.read"
self.params.state = str(rand_range(0, 1))
randomize()
set_client_id(client_id)
set_client_secret(client_secret)

self.oauth_header.oauth_consumer_key = client_id
self.oauth_header.oauth_nonce = OS.get_ticks_usec()
self.oauth_header.oauth_timestamp = OS.get_ticks_msec()

self.should_exchange = true
self.redirect_uri = "https://twitter.com/i/oauth2/authorize?"
self.access_token_uri = "https://api.twitter.com/2/oauth2/token"
self.provider_id = "twitter.com"
self.params.redirect_type = "redirect_uri"
self.params.response_type = "code"
self.params.scope = "users.read"
self.params.state = str(rand_range(0, 1))


func get_oauth_params() -> String:
var params: PoolStringArray = []
for key in self.oauth.keys():
params.append(key+"="+self.oauth.get(key))
return params.join("&")
var params: PoolStringArray = []
for key in self.oauth.keys():
params.append(key + "=" + self.oauth.get(key))
return params.join("&")
68 changes: 36 additions & 32 deletions addons/godot-firebase/auth/user_data.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,43 @@ tool
class_name FirebaseUserData
extends Reference

var local_id : String = "" # The uid of the current user.
var email : String = ""
var email_verified := false # Whether or not the account's email has been verified.
var password_updated_at : float = 0 # The timestamp, in milliseconds, that the account password was last changed.
var last_login_at : float = 0 # The timestamp, in milliseconds, that the account last logged in at.
var created_at : float = 0 # The timestamp, in milliseconds, that the account was created at.
var provider_user_info : Array = []

var provider_id : String = ""
var display_name : String = ""
var photo_url : String = ""

func _init(p_userdata : Dictionary) -> void:
local_id = p_userdata.get("localId", "")
email = p_userdata.get("email", "")
email_verified = p_userdata.get("emailVerified", false)
last_login_at = float(p_userdata.get("lastLoginAt", 0))
created_at = float(p_userdata.get("createdAt", 0))
password_updated_at = float(p_userdata.get("passwordUpdatedAt", 0))
display_name = p_userdata.get("displayName", "")
provider_user_info = p_userdata.get("providerUserInfo", [])
if not provider_user_info.empty():
provider_id = provider_user_info[0].get("providerId", "")
photo_url = provider_user_info[0].get("photoUrl", "")
display_name = provider_user_info[0].get("displayName", "")

var local_id: String = "" # The uid of the current user.
var email: String = ""
var email_verified := false # Whether or not the account's email has been verified.
var password_updated_at: float = 0 # The timestamp, in milliseconds, that the account password was last changed.
var last_login_at: float = 0 # The timestamp, in milliseconds, that the account last logged in at.
var created_at: float = 0 # The timestamp, in milliseconds, that the account was created at.
var provider_user_info: Array = []

var provider_id: String = ""
var display_name: String = ""
var photo_url: String = ""


func _init(p_userdata: Dictionary) -> void:
local_id = p_userdata.get("localId", "")
email = p_userdata.get("email", "")
email_verified = p_userdata.get("emailVerified", false)
last_login_at = float(p_userdata.get("lastLoginAt", 0))
created_at = float(p_userdata.get("createdAt", 0))
password_updated_at = float(p_userdata.get("passwordUpdatedAt", 0))
display_name = p_userdata.get("displayName", "")
provider_user_info = p_userdata.get("providerUserInfo", [])
if not provider_user_info.empty():
provider_id = provider_user_info[0].get("providerId", "")
photo_url = provider_user_info[0].get("photoUrl", "")
display_name = provider_user_info[0].get("displayName", "")


func as_text() -> String:
return _to_string()
return _to_string()


func _to_string() -> String:
var txt = "local_id : %s\n" % local_id
txt += "email : %s\n" % email
txt += "last_login_at : %d\n" % last_login_at
txt += "provider_id : %s\n" % provider_id
txt += "display name : %s\n" % display_name
return txt
var txt = "local_id : %s\n" % local_id
txt += "email : %s\n" % email
txt += "last_login_at : %d\n" % last_login_at
txt += "provider_id : %s\n" % provider_id
txt += "display name : %s\n" % display_name
return txt
74 changes: 39 additions & 35 deletions addons/godot-firebase/database/database.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,53 @@ tool
class_name FirebaseDatabase
extends Node

var _base_url : String = ""

var _config : Dictionary = {}
var _base_url: String = ""

var _auth : Dictionary = {}
var _config: Dictionary = {}

func _set_config(config_json : Dictionary) -> void:
_config = config_json
_check_emulating()
var _auth: Dictionary = {}


func _check_emulating() -> void :
## Check emulating
if not Firebase.emulating:
_base_url = _config.databaseURL
else:
var port : String = _config.emulators.ports.realtimeDatabase
if port == "":
Firebase._printerr("You are in 'emulated' mode, but the port for Realtime Database has not been configured.")
else:
_base_url = "http://localhost"
func _set_config(config_json: Dictionary) -> void:
_config = config_json
_check_emulating()


func _check_emulating() -> void:
## Check emulating
if not Firebase.emulating:
_base_url = _config.databaseURL
else:
var port: String = _config.emulators.ports.realtimeDatabase
if port == "":
Firebase._printerr("You are in 'emulated' mode, but the port for Realtime Database has not been configured.")
else:
_base_url = "http://localhost"

func _on_FirebaseAuth_login_succeeded(auth_result : Dictionary) -> void:
_auth = auth_result

func _on_FirebaseAuth_token_refresh_succeeded(auth_result : Dictionary) -> void:
_auth = auth_result
func _on_FirebaseAuth_login_succeeded(auth_result: Dictionary) -> void:
_auth = auth_result


func _on_FirebaseAuth_token_refresh_succeeded(auth_result: Dictionary) -> void:
_auth = auth_result


func _on_FirebaseAuth_logout() -> void:
_auth = {}

func get_database_reference(path : String, filter : Dictionary = {}) -> FirebaseDatabaseReference:
var firebase_reference : FirebaseDatabaseReference = FirebaseDatabaseReference.new()
var pusher : HTTPRequest = HTTPRequest.new()
var listener : Node = Node.new()
listener.set_script(load("res://addons/http-sse-client/HTTPSSEClient.gd"))
var store : FirebaseDatabaseStore = FirebaseDatabaseStore.new()
firebase_reference.set_db_path(path, filter)
firebase_reference.set_auth_and_config(_auth, _config)
firebase_reference.set_pusher(pusher)
firebase_reference.set_listener(listener)
firebase_reference.set_store(store)
add_child(firebase_reference)
return firebase_reference
_auth = {}


func get_database_reference(path: String, filter: Dictionary = {}) -> FirebaseDatabaseReference:
var firebase_reference: FirebaseDatabaseReference = FirebaseDatabaseReference.new()
var pusher: HTTPRequest = HTTPRequest.new()
var listener: Node = Node.new()
listener.set_script(load("res://addons/http-sse-client/HTTPSSEClient.gd"))
var store: FirebaseDatabaseStore = FirebaseDatabaseStore.new()
firebase_reference.set_db_path(path, filter)
firebase_reference.set_auth_and_config(_auth, _config)
firebase_reference.set_pusher(pusher)
firebase_reference.set_listener(listener)
firebase_reference.set_store(store)
add_child(firebase_reference)
return firebase_reference
Loading

0 comments on commit a73193c

Please sign in to comment.