Skip to content

Commit

Permalink
feat: add magic link login
Browse files Browse the repository at this point in the history
  • Loading branch information
kuruk-mm committed Aug 13, 2024
1 parent 39223b0 commit c949646
Show file tree
Hide file tree
Showing 70 changed files with 1,408 additions and 59 deletions.
12 changes: 12 additions & 0 deletions godot/.godot/global_script_class_cache.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ list=Array[Dictionary]([{
"language": &"GDScript",
"path": "res://src/config/graphic_settings.gd"
}, {
"base": &"Control",
"class": &"Lobby",
"icon": "",
"language": &"GDScript",
"path": "res://src/ui/components/auth/lobby.gd"
}, {
"base": &"RefCounted",
"class": &"MagicLinkPluginInterface",
"icon": "",
"language": &"GDScript",
"path": "res://addons/GodotAndroidPluginMagicLink/MagicLinkPluginInterface.gd"
}, {
"base": &"Node",
"class": &"MusicPlayer",
"icon": "",
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="778bc8d9f87581f06e92917b5214dbd3"
dest_md5="3c28e9ae9b2281681e8c49b5d5d363d9"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="ee61b4c9433056c58df21a294add6d30"
dest_md5="d81639693d91a4051ab9488fe3a8b561"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="6847e2cbc4b76020977eddd74b3e845d"
dest_md5="1bd326d6f05d63a18febd1d6fecd5b87"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="29905828089fc22f91298a053b83eed5"
dest_md5="971d6f319c0be1800eaabfd5f37353c6"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="2eaf2b48a586d872fadff9b3eef3f74a"
dest_md5="ee902025e732e2a3310620ee7ab7e62a"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="3b11cd2a5f3cfe0f27b13471974858c0"
dest_md5="ac96a58e05292cb44690bd8fe2d59b7e"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="9898554a9551d85c2ebce1bccbdfe7f9"
dest_md5="e9dfba0bc5b661d7c45cc48a39470f75"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="46eb5ab4f2d3fcfdbb09c4bb0897cba0"
dest_md5="28a7b91100fd48d10f0ecd42aa5a79fe"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="67b9c88b63853487c8aecf0786f775e8"
dest_md5="9b90704ac05c5c28f6846018b5ac48cc"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="1b578fdf8fb61b007cc47bc8ea6cf81a"
dest_md5="302c4a1d004d999fd5d81bab1ee84c59"

115 changes: 115 additions & 0 deletions godot/addons/GodotAndroidPluginMagicLink/MagicLinkPluginInterface.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
class_name MagicLinkPluginInterface

signal connected(address: String)
signal logout

const PLUGIN_NAME = "GodotAndroidPluginMagicLink"

var wallet_connected: bool = false
var public_address: String = ""

static var _plugin_singleton = null


func get_singleton():
if _plugin_singleton != null:
return _plugin_singleton

if Engine.has_singleton(PLUGIN_NAME):
_plugin_singleton = Engine.get_singleton(PLUGIN_NAME)
return _plugin_singleton

printerr("Initialization error: unable to access the java logic")
return null


func _on_connected(address: String):
public_address = address
wallet_connected = true

connected.emit(address)


func _on_logout():
public_address = ""
wallet_connected = false

logout.emit()


func setup(magic_key: String, callback_url: String, network: String = "ethereum"):
var singleton = get_singleton()
if singleton == null:
printerr("Initialization error")
return

singleton.setup(magic_key, callback_url, network)
singleton.connected.connect(self._on_connected)
singleton.on_logout.connect(self._on_logout)


func async_check_connection() -> bool:
var singleton = get_singleton()
if singleton == null:
printerr("Initialization error")
return false

singleton.checkConnection()

return await singleton.connection_state == "true"


func async_login_email(email: String):
var singleton = get_singleton()
if singleton == null:
printerr("Initialization error")
return

singleton.loginEmailOTP(email)
await singleton.connected


func async_login_social(oauth_provider: String):
var singleton = get_singleton()
if singleton == null:
printerr("Initialization error")
return

singleton.loginSocial(oauth_provider)
await singleton.connected


func async_logout():
var singleton = get_singleton()
if singleton == null:
printerr("Initialization error")
return

singleton.logout()
await singleton.on_logout


func open_wallet():
if wallet_connected != true:
printerr("Please, check if you're connected first...")
return

var singleton = get_singleton()
if singleton == null:
printerr("Initialization error")
return

singleton.openWallet()


func async_sign(message: String) -> String:
if wallet_connected != true:
printerr("Please, check if you're connected first...")
return ""
var singleton = get_singleton()
if singleton == null:
printerr("Initialization error")
return ""

singleton.sign(message)
return await singleton.signed_message
Binary file not shown.
49 changes: 49 additions & 0 deletions godot/addons/GodotAndroidPluginMagicLink/export_plugin.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@tool
extends EditorPlugin

# A class member to hold the editor export plugin during its lifecycle.
var export_plugin: AndroidExportPlugin


func _enter_tree():
# Initialization of the plugin goes here.
export_plugin = AndroidExportPlugin.new()
add_export_plugin(export_plugin)


func _exit_tree():
# Clean-up of the plugin goes here.
remove_export_plugin(export_plugin)
export_plugin = null


class AndroidExportPlugin:
extends EditorExportPlugin
const PLUGIN_NAME = "GodotAndroidPluginMagicLink"

func _supports_platform(platform):
if platform is EditorExportPlatformAndroid:
return true
return false

func _get_android_libraries(_platform, debug):
if debug:
return PackedStringArray([PLUGIN_NAME + "/bin/debug/" + PLUGIN_NAME + "-debug.aar"])

return PackedStringArray([PLUGIN_NAME + "/bin/release/" + PLUGIN_NAME + "-release.aar"])

func _get_android_dependencies(_platform, _debug):
var default_dependencies = PackedStringArray(
[
"link.magic:magic-android:10.6.0",
"link.magic:magic-ext-oauth:5.0.1",
"link.magic:magic-ext-oidc:2.0.4",
"org.web3j:core:4.8.8-android",
"org.web3j:geth:4.8.8-android"
]
)

return default_dependencies

func _get_name():
return PLUGIN_NAME
6 changes: 6 additions & 0 deletions godot/addons/GodotAndroidPluginMagicLink/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[plugin]
name="GodotAndroidPluginMagicLink"
description="Plugin for connecting with Magic Link on Android"
author="Kuruk"
version="0.1"
script="export_plugin.gd"
2 changes: 1 addition & 1 deletion godot/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ custom_template/release="./../.bin/godot/templates/templates/android_release.apk
gradle_build/use_gradle_build=true
gradle_build/export_format=0
gradle_build/min_sdk=""
gradle_build/target_sdk=""
gradle_build/target_sdk="34"
architectures/armeabi-v7a=false
architectures/arm64-v8a=true
architectures/x86=false
Expand Down
2 changes: 1 addition & 1 deletion godot/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ run/main_run_args="--clear-cache-startup"

[editor_plugins]

enabled=PackedStringArray("res://addons/resource_tracker/plugin.cfg")
enabled=PackedStringArray("res://addons/GodotAndroidPluginMagicLink/plugin.cfg", "res://addons/resource_tracker/plugin.cfg")

[filesystem]

Expand Down
2 changes: 1 addition & 1 deletion godot/src/decentraland_components/avatar/avatar.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ bones/61/rotation = Quaternion(-0.0187227, 0.0752644, -0.00259158, 0.996984)
bones/61/scale = Vector3(1, 1, 1)

[node name="BoneAttachment3D_Name" type="BoneAttachment3D" parent="Armature/Skeleton3D"]
transform = Transform3D(1, 3.03891e-06, -2.27988e-06, 2.45869e-06, -0.0728592, 0.997342, 2.87499e-06, -0.997342, -0.0728593, -0.218822, -4.1166, -172.159)
transform = Transform3D(1, 3.01981e-06, -2.17557e-06, 2.35438e-06, -0.0728586, 0.997342, 2.85544e-06, -0.997342, -0.0728585, -0.218824, -4.11655, -172.159)
bone_name = "Avatar_Head"
bone_idx = 61

Expand Down
8 changes: 8 additions & 0 deletions godot/src/global.gd
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ func _ready():
self.realm = Realm.new()
self.realm.set_name("realm")

self.dcl_tokio_rpc = DclTokioRpc.new()
self.dcl_tokio_rpc.set_name("dcl_tokio_rpc")

self.magic_link = MagicLink.new()
self.magic_link.set_name("magic_link")

self.player_identity = PlayerIdentity.new()
self.player_identity.set_name("player_identity")

Expand All @@ -103,6 +109,8 @@ func _ready():
get_tree().root.add_child.call_deferred(self.content_provider)
get_tree().root.add_child.call_deferred(self.scene_runner)
get_tree().root.add_child.call_deferred(self.realm)
get_tree().root.add_child.call_deferred(self.dcl_tokio_rpc)
get_tree().root.add_child.call_deferred(self.magic_link)
get_tree().root.add_child.call_deferred(self.player_identity)
get_tree().root.add_child.call_deferred(self.comms)
get_tree().root.add_child.call_deferred(self.avatars)
Expand Down
10 changes: 10 additions & 0 deletions godot/src/ui/components/auth/images/apple.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions godot/src/ui/components/auth/images/apple.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://kxlueau7wo2u"
path="res://.godot/imported/apple.svg-641aec9d79b14fbb47eb0d04902e71d2.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://src/ui/components/auth/images/apple.svg"
dest_files=["res://.godot/imported/apple.svg-641aec9d79b14fbb47eb0d04902e71d2.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
1 change: 1 addition & 0 deletions godot/src/ui/components/auth/images/coinbase.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions godot/src/ui/components/auth/images/coinbase.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://d1woawj5lwo2f"
path="res://.godot/imported/coinbase.svg-8106001dab373e0975a9afab1d75672a.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://src/ui/components/auth/images/coinbase.svg"
dest_files=["res://.godot/imported/coinbase.svg-8106001dab373e0975a9afab1d75672a.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false
10 changes: 10 additions & 0 deletions godot/src/ui/components/auth/images/discord.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c949646

Please sign in to comment.